当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript bold.cyan方法代码示例

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


在下文中一共展示了bold.cyan方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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