Uname:Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64

403WebShell
403Webshell
Server IP : 82.148.16.210  /  Your IP : 216.73.216.249
Web Server : nginx/1.29.5
System : Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /srv/projects/env4/src/dev/frontend3/node_modules/table/node_modules/ajv-cli/src/commands/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /srv/projects/env4/src/dev/frontend3/node_modules/table/node_modules/ajv-cli/src/commands/ajv.ts
import type AjvCore from "ajv/dist/core"
import type {ParsedArgs} from "minimist"
import type {SchemaSpec} from "./types"
import Ajv7, {Plugin} from "ajv"
import Ajv2019 from "ajv/dist/2019"
import Ajv2020 from "ajv/dist/2020"
import AjvJTD from "ajv/dist/jtd"
import {Service} from "ts-node"
import {getOptions} from "./options"
import * as util from "./util"
import * as path from "path"
import * as draft6metaSchema from "ajv/lib/refs/json-schema-draft-06.json"

type AjvMethod = "addSchema" | "addMetaSchema"

// copied from https://github.com/babel/babel/blob/d8da63c929f2d28c401571e2a43166678c555bc4/packages/babel-helpers/src/helpers.js#L602-L606
/* istanbul ignore next */
const interopRequireDefault = (obj: any): {default: any} =>
  obj && obj.__esModule ? obj : {default: obj}

const importDefault = <T = unknown>(moduleName: string): T =>
  interopRequireDefault(require(moduleName)).default

const AjvClass: {[S in SchemaSpec]?: typeof AjvCore} = {
  jtd: AjvJTD,
  draft7: Ajv7,
  draft2019: Ajv2019,
  draft2020: Ajv2020,
}

export default function (argv: ParsedArgs): AjvCore {
  const opts = getOptions(argv)
  if (argv.o) opts.code.source = true
  const Ajv: typeof AjvCore = AjvClass[argv.spec as SchemaSpec] || Ajv7
  const ajv = new Ajv(opts)
  let invalid: boolean | undefined
  if (argv.spec !== "jtd") ajv.addMetaSchema(draft6metaSchema)
  addSchemas(argv.m, "addMetaSchema", "meta-schema")
  addSchemas(argv.r, "addSchema", "schema")
  customFormatsKeywords(argv.c)
  if (invalid) process.exit(1)
  return ajv

  function addSchemas(
    args: string | string[] | undefined,
    method: AjvMethod,
    fileType: string
  ): void {
    if (!args) return
    const files = util.getFiles(args)
    files.forEach((file) => {
      const schema = util.openFile(file, fileType)
      try {
        ajv[method](schema)
      } catch (err) {
        console.error(`${fileType} ${file} is invalid`)
        console.error(`error: ${(err as Error).message}`)
        invalid = true
      }
    })
  }

  function customFormatsKeywords(args: string | string[] | undefined): void {
    if (!args) return
    const files = util.getFiles(args)
    files.forEach((file) => {
      if (file[0] === ".") file = path.resolve(process.cwd(), file)
      try {
        if (file.endsWith(".ts")) {
          requireTypeScriptKeyword(file)
        } else {
          require(file)(ajv)
        }
      } catch (err) {
        console.error(`module ${file} is invalid; it should export function`)
        console.error(`error: ${(err as Error).message}`)
        invalid = true
      }
    })
  }

  function requireTypeScriptKeyword(file: string): void {
    let registerer: Service

    try {
      registerer = require("ts-node").register()
    } catch (err) {
      /* istanbul ignore next */
      if (err.code === "MODULE_NOT_FOUND") {
        throw new Error(
          `'ts-node' is required for the TypeScript configuration files. Make sure it is installed\nError: ${err.message}`
        )
      }

      throw err
    }

    registerer.enabled(true)

    importDefault<Plugin<undefined>>(file)(ajv)

    registerer.enabled(false)
  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit