• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript cli-color.whiteBright类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中cli-color.whiteBright的典型用法代码示例。如果您正苦于以下问题:TypeScript whiteBright类的具体用法?TypeScript whiteBright怎么用?TypeScript whiteBright使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了whiteBright类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: generateType

function generateType(ast: AST, options: Options): string {
  log(whiteBright.bgMagenta('generator'), ast)

  if (hasStandaloneName(ast)) {
    return toSafeString(ast.standaloneName)
  }

  switch (ast.type) {
    case 'ANY': return 'any'
    case 'ARRAY': return (() => {
      let type = generateType(ast.params, options)
      return type.endsWith('"') ? '(' + type + ')[]' : type + '[]'
    })()
    case 'BOOLEAN': return 'boolean'
    case 'INTERFACE': return generateInterface(ast, options)
    case 'INTERSECTION': return generateSetOperation(ast, options)
    case 'LITERAL': return JSON.stringify(ast.params)
    case 'NUMBER': return 'number'
    case 'NULL': return 'null'
    case 'OBJECT': return 'object'
    case 'REFERENCE': return ast.params
    case 'STRING': return 'string'
    case 'TUPLE': return '['
      + ast.params.map(_ => generateType(_, options)).join(', ')
      + ']'
    case 'UNION': return generateSetOperation(ast, options)
    case 'CUSTOM_TYPE': return ast.params
  }
}
开发者ID:bcherny,项目名称:json-schema-to-typescript,代码行数:29,代码来源:generator.ts


示例2: deploy

    deploy():Q.IPromise<IDeployResult> {
        let start           = new Date().getTime(),
            config          = this.serviceContainer.config,
            packageData:any = JSON.parse('' + fs.readFileSync(__dirname + '/../../package.json'));

        this.log.logAndKeepColors(
            color.yellow(
                "\n\n+----------------------------------------------------+" +
                "\n|      ") + color.xterm(200).bold('Mouflon - your deployment manager') + ' ' + ('        v' + packageData.version).substr(-10, 10) + color.yellow("  |" +
                "\n+----------------------------------------------------+") +
            "\n\n");

        this.log.startSection(`Deploying "${config.projectName}" to "${config.stageName}"...`);
        this.log.debug('Timestamp is ' + color.whiteBright.bold(this.timestamp));
        if (config.verbose) {
            this.log.debug('Verbose mode is enabled');
        }
        this.log.debug('Working pathConfig: ' + config.pathConfig.getReadable());

        return this.deployManager.deploy().then(() => {
            let end = new Date().getTime();

            let result: IDeployResult = {
                project: config.projectName,
                stage: config.stageName,
                projectConfig: config.projectConfig,
                globalConfig: config.globalConfig,
                start: start,
                end: end,
            };
            return result;
        });
    }
开发者ID:stvnwrgs,项目名称:mouflon,代码行数:33,代码来源:Mouflon.ts


示例3: optimize

export function optimize(ast: AST, processed = new Map<AST, AST>()): AST {

  log(whiteBright.bgCyan('optimizer'), ast, processed.has(ast) ? '(FROM CACHE)' : '')

  if (processed.has(ast)) {
    return processed.get(ast)!
  }

  processed.set(ast, ast)

  switch (ast.type) {
    case 'INTERFACE':
      return Object.assign(ast, {
        params: ast.params.map(_ =>
          Object.assign(_, { ast: optimize(_.ast, processed) })
        )
      })
    case 'INTERSECTION':
    case 'UNION':

      // [A, B, C, Any] -> Any
      if (ast.params.some(_ => _.type === 'ANY')) {
        log(whiteBright.bgCyan('optimizer'), ast, '<- T_ANY')
        return T_ANY
      }

      // [A, B, B] -> [A, B]
      ast.params = uniqBy(ast.params, _ =>
        `${_.type}------${stringify((_ as any).params)}`
      )

      return Object.assign(ast, {
        params: ast.params.map(_ => optimize(_, processed))
      })
    default:
      return ast
  }
}
开发者ID:bcherny,项目名称:json-schema-to-typescript,代码行数:38,代码来源:optimizer.ts


示例4: main

async function main(argv: minimist.ParsedArgs) {

  if (argv.help) {
    printHelp()
    process.exit(0)
  }

  const argIn: string = argv._[0] || argv.input
  const argOut: string = argv._[1] || argv.output

  try {
    const schema: JSONSchema4 = JSON.parse(await readInput(argIn))
    const ts = await compile(schema, argIn, argv as Partial<Options>)
    await writeOutput(ts, argOut)
  } catch (e) {
    console.error(whiteBright.bgRedBright('error'), e)
    process.exit(1)
  }

}
开发者ID:bcherny,项目名称:json-schema-to-typescript,代码行数:20,代码来源:cli.ts


示例5: deploy

    deploy() {
        var start = (new Date()).getTime(),
            deployPromise: Q.IPromise<boolean>,
            config = this.serviceContainer.config,
            packageData: any = JSON.parse('' + fs.readFileSync(__dirname + '/../../package.json'));

        this.serviceContainer.log.logAndKeepColors(
            color.yellow(
                "\n\n+----------------------------------------------------+" +
                "\n|      ") + color.xterm(200).bold('Mouflon - your deployment manager') + ' ' + ('        v' + packageData.version).substr(-10, 10) + color.yellow("  |" +
            "\n+----------------------------------------------------+") +
            "\n\n");

        this.serviceContainer.log.startSection(sprintf('Deploying "%s" to "%s"...', config.projectName, config.stageName));
        this.serviceContainer.log.debug('Timestamp is ' + color.whiteBright.bold(this.timestamp));
        if (this.serviceContainer.config.verbose) {
            this.serviceContainer.log.debug('Verbose mode is enabled');
        }
        this.serviceContainer.log.debug('Working paths: ' + this.serviceContainer.config.paths.getReadable());

        deployPromise = this.deployManager.deploy();

        deployPromise.then(
            () => {
                var end = (new Date()).getTime();
                this.serviceContainer.log.closeSection(sprintf(
                    'It took %ss to deploy "%s" to "%s". :)' + "\n\n",
                    (0.001 * (end - start)).toFixed(3),
                    config.projectName,
                    config.stageName
                ));
            },
            (error) => {
                Utils.exitWithError(error);
            }
        );
    }
开发者ID:reasn,项目名称:mouflon,代码行数:37,代码来源:Mouflon.ts


示例6: parseNonLiteral

function parseNonLiteral(
  schema: JSONSchema,
  options: Options,
  rootSchema: JSONSchema,
  keyName: string | undefined,
  keyNameFromDefinition: string | undefined,
  set: (ast: AST) => AST,
  processed: Processed,
  usedNames: UsedNames
) {

  log(whiteBright.bgBlue('parser'), schema, '<-' + typeOfSchema(schema), processed.has(schema) ? '(FROM CACHE)' : '')

  switch (typeOfSchema(schema)) {
    case 'ALL_OF':
      return set({
        comment: schema.description,
        keyName,
        params: schema.allOf!.map(_ => parse(_, options, rootSchema, undefined, true, processed, usedNames)),
        standaloneName: standaloneName(schema, keyNameFromDefinition, usedNames),
        type: 'INTERSECTION'
      })
    case 'ANY':
      return set({
        comment: schema.description,
        keyName,
        standaloneName: standaloneName(schema, keyNameFromDefinition, usedNames),
        type: 'ANY'
      })
    case 'ANY_OF':
      return set({
        comment: schema.description,
        keyName,
        params: schema.anyOf!.map(_ => parse(_, options, rootSchema, undefined, true, processed, usedNames)),
        standaloneName: standaloneName(schema, keyNameFromDefinition, usedNames),
        type: 'UNION'
      })
    case 'BOOLEAN':
      return set({
        comment: schema.description,
        keyName,
        standaloneName: standaloneName(schema, keyNameFromDefinition, usedNames),
        type: 'BOOLEAN'
      })
    case 'CUSTOM_TYPE':
      return set({
        comment: schema.description,
        keyName,
        params: schema.tsType!,
        standaloneName: standaloneName(schema, keyNameFromDefinition, usedNames),
        type: 'CUSTOM_TYPE'
      })
    case 'NAMED_ENUM':
      return set({
        comment: schema.description,
        keyName,
        params: schema.enum!.map((_, n) => ({
          ast: parse(_, options, rootSchema, undefined, false, processed, usedNames),
          keyName: schema.tsEnumNames![n]
        })),
        standaloneName: standaloneName(schema, keyName, usedNames)!,
        type: 'ENUM'
      })
    case 'NAMED_SCHEMA':
      return set(newInterface(schema as SchemaSchema, options, rootSchema, processed, usedNames, keyName))
    case 'NULL':
      return set({
        comment: schema.description,
        keyName,
        standaloneName: standaloneName(schema, keyNameFromDefinition, usedNames),
        type: 'NULL'
      })
    case 'NUMBER':
      return set({
        comment: schema.description,
        keyName,
        standaloneName: standaloneName(schema, keyNameFromDefinition, usedNames),
        type: 'NUMBER'
      })
    case 'OBJECT':
      return set({
        comment: schema.description,
        keyName,
        standaloneName: standaloneName(schema, keyNameFromDefinition, usedNames),
        type: 'OBJECT'
      })
    case 'ONE_OF':
      return set({
        comment: schema.description,
        keyName,
        params: schema.oneOf!.map(_ => parse(_, options, rootSchema, undefined, true, processed, usedNames)),
        standaloneName: standaloneName(schema, keyNameFromDefinition, usedNames),
        type: 'UNION'
      })
    case 'REFERENCE':
      throw Error(format('Refs should have been resolved by the resolver!', schema))
    case 'STRING':
      return set({
        comment: schema.description,
        keyName,
//.........这里部分代码省略.........
开发者ID:bcherny,项目名称:json-schema-to-typescript,代码行数:101,代码来源:parser.ts


示例7: log

export function log(...messages: any[]) {
  if (process.env.VERBOSE) {
    console.info(whiteBright.bgCyan('debug'), ...messages)
  }
}
开发者ID:bcherny,项目名称:json-schema-to-typescript,代码行数:5,代码来源:utils.ts


示例8: error

export function error(...messages: any[]) {
  console.error(whiteBright.bgRedBright('error'), ...messages)
}
开发者ID:bcherny,项目名称:json-schema-to-typescript,代码行数:3,代码来源:utils.ts


示例9: dereference

export async function dereference(schema: JSONSchema, {cwd, $refOptions}: {cwd: string, $refOptions: $RefParser.Options}): Promise<JSONSchema> {
  log(whiteBright.bgGreen('resolver'), schema, cwd)
  const parser = new $RefParser
  return parser.dereference(cwd, schema, $refOptions)
}
开发者ID:bcherny,项目名称:json-schema-to-typescript,代码行数:5,代码来源:resolver.ts


示例10: mapDeep

 rules.forEach((rule, key) => {
   _schema = mapDeep(_schema, schema => rule(schema, _schema, filename)) as NormalizedJSONSchema
   log(whiteBright.bgYellow('normalizer'), `Applied rule: "${key}"`)
 })
开发者ID:bcherny,项目名称:json-schema-to-typescript,代码行数:4,代码来源:normalizer.ts



注:本文中的cli-color.whiteBright类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript cli-table.push函数代码示例发布时间:2022-05-24
下一篇:
TypeScript cli-color.bold类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap