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

TypeScript cli-color.bold类代码示例

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

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



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

示例1: deploy

  /**
   * Deploy an index specification to the specified project.
   * @param project the Firebase project ID.
   * @param indexes an array of objects, each will be validated and then converted
   * to an {@link Spec.Index}.
   * @param fieldOverrides an array of objects, each will be validated and then
   * converted to an {@link Spec.FieldOverride}.
   */
  async deploy(project: string, indexes: any[], fieldOverrides: any[]): Promise<void> {
    const spec = this.upgradeOldSpec({
      indexes,
      fieldOverrides,
    });

    this.validateSpec(spec);

    // Now that the spec is validated we can safely assert these types.
    const indexesToDeploy: Spec.Index[] = spec.indexes;
    const fieldOverridesToDeploy: Spec.FieldOverride[] = spec.fieldOverrides;

    const existingIndexes = await this.listIndexes(project);
    const existingFieldOverrides = await this.listFieldOverrides(project);

    if (existingIndexes.length > indexesToDeploy.length) {
      utils.logBullet(
        clc.bold.cyan("firestore:") +
          " there are some indexes defined in your project that are not present in your " +
          "firestore indexes file. Run firebase firestore:indexes and save the result to correct the discrepancy."
      );
    }

    for (const index of indexesToDeploy) {
      const exists = existingIndexes.some((x) => this.indexMatchesSpec(x, index));
      if (exists) {
        logger.debug(`Skipping existing index: ${JSON.stringify(index)}`);
      } else {
        logger.debug(`Creating new index: ${JSON.stringify(index)}`);
        await this.createIndex(project, index);
      }
    }

    if (existingFieldOverrides.length > fieldOverridesToDeploy.length) {
      utils.logBullet(
        clc.bold.cyan("firestore:") +
          " there are some field overrides defined in your project that are not present in your " +
          "firestore indexes file. Run firebase firestore:indexes and save the result to correct the discrepancy."
      );
    }

    for (const field of fieldOverridesToDeploy) {
      const exists = existingFieldOverrides.some((x) => this.fieldMatchesSpec(x, field));
      if (exists) {
        logger.debug(`Skipping existing field override: ${JSON.stringify(field)}`);
      } else {
        logger.debug(`Updating field override: ${JSON.stringify(field)}`);
        await this.patchField(project, field);
      }
    }
  }
开发者ID:firebase,项目名称:firebase-tools,代码行数:59,代码来源:indexes.ts


示例2: upgradeOldSpec

  /**
   * Take a object that may represent an old v1beta1 indexes spec
   * and convert it to the new v1beta2/v1 spec format.
   *
   * This function is meant to be run **before** validation and
   * works on a purely best-effort basis.
   */
  upgradeOldSpec(spec: any): any {
    const result = {
      indexes: [],
      fieldOverrides: spec.fieldOverrides || [],
    };

    if (!(spec.indexes && spec.indexes.length > 0)) {
      return result;
    }

    // Try to detect use of the old API, warn the users.
    if (spec.indexes[0].collectionId) {
      utils.logBullet(
        clc.bold.cyan("firestore:") +
          " your indexes indexes are specified in the v1beta1 API format. " +
          "Please upgrade to the new index API format by running " +
          clc.bold("firebase firestore:indexes") +
          " again and saving the result."
      );
    }

    result.indexes = spec.indexes.map((index: any) => {
      const i = {
        collectionGroup: index.collectionGroup || index.collectionId,
        queryScope: index.queryScope || API.QueryScope.COLLECTION,
        fields: [],
      };

      if (index.fields) {
        i.fields = index.fields.map((field: any) => {
          const f: any = {
            fieldPath: field.fieldPath,
          };

          if (field.order) {
            f.order = field.order;
          } else if (field.arrayConfig) {
            f.arrayConfig = field.arrayConfig;
          } else if (field.mode === API.Mode.ARRAY_CONTAINS) {
            f.arrayConfig = API.ArrayConfig.CONTAINS;
          } else {
            f.order = field.mode;
          }

          return f;
        });
      }

      return i;
    });

    return result;
  }
开发者ID:firebase,项目名称:firebase-tools,代码行数:60,代码来源:indexes.ts


示例3:

  .action(async (options: any) => {
    const indexApi = new fsi.FirestoreIndexes();

    const indexes = await indexApi.listIndexes(options.project);
    const fieldOverrides = await indexApi.listFieldOverrides(options.project);

    const indexSpec = indexApi.makeIndexSpec(indexes, fieldOverrides);

    if (options.pretty) {
      logger.info(clc.bold.white("Compound Indexes"));
      indexApi.prettyPrintIndexes(indexes);

      if (fieldOverrides) {
        logger.info();
        logger.info(clc.bold.white("Field Overrides"));
        indexApi.printFieldOverrides(fieldOverrides);
      }
    } else {
      logger.info(JSON.stringify(indexSpec, undefined, 2));
    }

    return indexSpec;
  });
开发者ID:firebase,项目名称:firebase-tools,代码行数:23,代码来源:firestore-indexes-list.ts


示例4: function

        }, function (error, response, body) {

            if (!error && response.statusCode === 200) {

                const
                    conn = require(rootDir + 'connections/' + process.env.DB_TYPE + '.js');
                // model = require(rootDir + 'models/' + process.env.DB_TYPE + '/Videos.js');


                conn.hlen('videos', (err, videos_count) => {
                    if (err) {
                        console.log(err);
                    }
                    let videoId = 'video' + Number(videos_count + 1);
                    // let title = body.title.replace(/"/g, '');

                    let title = body.title.replace(/(^[a-z]|\s[a-z])/g, (p) => {
                        return p.toUpperCase();
                    });

                    let videoUri = yt_id;

                    let thumb = body.thumbnail_url;

                    let order = String(videos_count + 1);
                    // Redis no acepta objetos JSON aun... ¬_¬
                    // let video_string = '{ "videoId": "' + videoId + '",' +
                    //     '"title": "' + title + '",' +
                    //     '"url": "' + yt_id + '",' +
                    //     '"img": "' + body.thumbnail_url + '",' +
                    //     '"order": ' + String(videos_count + 1) + '}';

                    let video_string = `{"videoId":"${videoId}","videoInfo":{"videoId":"${videoId}","title":"${title}","url":"${videoUri}","img":"${thumb}"},"order":${order}}`;

                    conn.hmset('videos', String(videoId), video_string, (err) => {

                        conn.hget('videos', videoId, (err, video) => {

                            if (err) {
                                console.log(err);
                            } else {
                                let vid = JSON.parse(video);
                                console.log(
                                    colors.green.bold('  [OK] Video inserted into Lantube DB!') + '\n' +
                                    colors.green.bold('   Details: ') + '\n' +
                                    colors.green.bold('   videoId: 	') + vid.videoId + '\n' +
                                    colors.green.bold('   title: ') + vid.title + '\n' +
                                    colors.green.bold('   url: 	') + vid.url + '\n' +
                                    colors.green.bold('   img: ') + vid.img + '\n' +
                                    colors.green.bold('   order: ') + (vid.order + 1)
                                );
                            }

                        });
                    });
                });


            } else {
                console.log(colors.bold.yellow('│  ') + colors.bold.red(error)) + colors.bold.yellow('│');
                console.log(colors.bold.yellow('╰────────────────────────────────────────────────────╯'));
            }

        });
开发者ID:andrrrl,项目名称:lantube,代码行数:64,代码来源:lantube-offline.ts


示例5: require

 *  - Author: Andrrr <[email protected]>
 *  - This little tool let's you add videos to storage (locar or remote)
 *
 */

let rootDir = '../../';
import * as colors from 'cli-color';

require('dotenv').config({
    path: rootDir + '.env'
});

// let colors = new colorsSafe();


console.log(colors.bold.yellow('             ╭───────────────────────────╮            '));
console.log(colors.bold.yellow('╭────────────┤  ▶ Lantube "OFFLINE" CLI  ├───────────╮'));
console.log(colors.bold.yellow('│            ╰───────────────────────────╯           │'));
console.log(colors.bold.yellow('│  Connection type: ' + process.env.DB_TYPE + '                            │'));

if (process.argv.length === 3) {

    if (process.argv[2] == 'help') {

        console.log(colors.bold('  Lantube offline tool'));
        console.log(colors.bold(' - This tool will add Youtube videos to ' + process.env.DB_TYPE));
        console.log(colors.bold(' - Use cases: '));
        console.log('   > The Lantube server is down.');
        console.log('   > The Lantube server is running in another computer.\n');
        console.log(colors.bold(' - Usage examples:'));
        console.log('   > $ node lantube-offline.js "YOUTUBE_ID"');
开发者ID:andrrrl,项目名称:lantube,代码行数:31,代码来源:lantube-offline.ts


示例6:

const ENGINE_RUNTIMES: { [key: string]: string } = {
  6: "nodejs6",
  8: "nodejs8",
  10: "nodejs10",
};

export const ENGINES_FIELD_REQUIRED_MSG = clc.bold(
  "Engines field is required in package.json but none was found."
);
export const UNSUPPORTED_NODE_VERSION_MSG = clc.bold(
  `package.json in functions directory has an engines field which is unsupported. ` +
    `The only valid choices are: ${clc.bold('{"node": "8"}')} and ${clc.bold('{"node": "10"}')}. ` +
    `Note that Node.js 6 is now deprecated.`
);
export const DEPRECATION_WARNING_MSG =
  clc.bold.yellow("functions: ") +
  "Deploying functions to Node 6 runtime, which is deprecated. Node 8 is available " +
  "and is the recommended runtime.";

export const FUNCTIONS_SDK_VERSION_TOO_OLD_WARNING =
  clc.bold.yellow("functions: ") +
  "You must have a " +
  clc.bold("firebase-functions") +
  " version that is at least 2.0.0. Please run " +
  clc.bold("npm i --save firebase-functions@latest") +
  " in the functions folder.";

/**
 * Returns a friendly string denoting the chosen runtime: Node.js 8 for nodejs 8
 * for example. If no friendly name for runtime is found, returns back the raw runtime.
 * @param runtime name of runtime in raw format, ie, "nodejs8" or "nodejs10"
开发者ID:firebase,项目名称:firebase-tools,代码行数:31,代码来源:runtimeChoiceSelector.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript cli-color.whiteBright类代码示例发布时间:2022-05-24
下一篇:
TypeScript cli-color.yellow函数代码示例发布时间: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