change-case#constantCase TypeScript Examples

The following examples show how to use change-case#constantCase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts    From graphql-mesh with MIT License 6 votes vote down vote up
NAMING_CONVENTIONS: Record<NamingConventionType, NamingConventionFn> = {
  camelCase,
  capitalCase,
  constantCase,
  dotCase,
  headerCase,
  noCase,
  paramCase,
  pascalCase,
  pathCase,
  sentenceCase,
  snakeCase,
  upperCase,
  lowerCase,
}
Example #2
Source File: appsync-java-visitor.ts    From amplify-codegen with Apache License 2.0 6 votes vote down vote up
/**
   * Add query field used for construction of conditions by SyncEngine
   */
  protected generateQueryFields(model: CodeGenModel, field: CodeGenField, classDeclarationBlock: JavaDeclarationBlock): void {
    const queryFieldName = constantCase(field.name);
    // belongsTo field is computed field. the value needed to query the field is in targetName
    const fieldName =
      field.connectionInfo && field.connectionInfo.kind === CodeGenConnectionType.BELONGS_TO
        ? field.connectionInfo.targetName
        : this.getFieldName(field);
    classDeclarationBlock.addClassMember(
      queryFieldName,
      'QueryField',
      `field("${this.getModelName(model)}", "${fieldName}")`,
      [],
      'public',
      {
        final: true,
        static: true,
      },
    );
  }
Example #3
Source File: FormatHelpers.ts    From modelina with Apache License 2.0 5 votes vote down vote up
/**
   * Transform into upper case string with an underscore between words.
   * @param {string} value to transform
   * @returns {string}
   */
  static toConstantCase = constantCase;
Example #4
Source File: appsync-visitor.ts    From amplify-codegen with Apache License 2.0 5 votes vote down vote up
protected getEnumValue(value: string): string {
    return constantCase(value);
  }
Example #5
Source File: index.tsx    From devtools-ds with MIT License 5 votes vote down vote up
main = async () => {
  signale.start("Starting devtools-ds project generation..");
  const defaultName = defaultAuthorName();
  const defaultEmail = defaultAuthorEmail();
  try {
    let responses = (await prompt([
      {
        type: "select",
        name: "template",
        message: "What template would you like to use?",
        choices: getTemplates(),
      },
      {
        type: "input",
        name: "projectName",
        message: "What is your devtools project's name?",
        initial: "my-devtools",
      },
      {
        type: "input",
        name: "devName",
        message: "What is your name?",
        initial: defaultName,
      },
      {
        type: "input",
        name: "devEmail",
        message: "What is your email?",
        initial: defaultEmail,
      },
      {
        type: "input",
        name: "projectOrg",
        message: "What will your project's GitHub organization be?",
        initial: paramCase(defaultName),
      },
    ])) as any;

    let { projectName } = responses;
    const projectNameConstant = constantCase(projectName);
    const projectNameCapital = capitalCase(projectName);
    projectName = paramCase(projectName);

    responses = {
      ...responses,
      projectName,
      projectNameCapital,
      projectNameConstant,
      uuid: `{${uuid()}}`,
    };

    signale.success("Recorded responses");
    signale.await(`Loading ${responses.template} template..`);

    const srcPath = getTemplatePath(responses.template);
    const outPath = `${process.cwd()}/${responses.projectName}/`;

    copy(srcPath, outPath, responses, async (err, createdFiles) => {
      if (err) throw err;
      createdFiles.forEach((filePath) =>
        signale.complete(`Created ${filePath}`)
      );

      // Copy assets which may get damaged by the templates
      await reflect({
        src: `${srcPath}/src/assets`,
        dest: `${outPath}/src/assets`,
        recursive: false,
      });

      signale.complete(`Copied assets`);

      signale.success(
        `Navigate into ${responses.projectName}/ to get started!`
      );
    });
  } catch (e) {
    signale.complete("Cancelling template creation");
  }
}
Example #6
Source File: ts.ts    From fantasticon with MIT License 5 votes vote down vote up
generator: FontGenerator = {
  generate: async ({
    name,
    codepoints,
    assets,
    formatOptions: { ts } = {}
  }) => {
    const quote = Boolean(ts?.singleQuotes) ? "'" : '"';
    const generateKind: Record<string, boolean> = (
      Boolean(ts?.types?.length)
        ? ts.types
        : ['enum', 'constant', 'literalId', 'literalKey']
    )
      .map(kind => ({ [kind]: true }))
      .reduce((prev, curr) => Object.assign(prev, curr), {});

    const enumName = pascalCase(name);
    const codepointsName = `${constantCase(name)}_CODEPOINTS`;
    const literalIdName = `${pascalCase(name)}Id`;
    const literalKeyName = `${pascalCase(name)}Key`;
    const names = { enumName, codepointsName, literalIdName, literalKeyName };

    const enumKeys = generateEnumKeys(Object.keys(assets));

    const stringLiteralId = generateKind.literalId
      ? generateStringLiterals(literalIdName, Object.keys(enumKeys), quote)
      : null;
    const stringLiteralKey = generateKind.literalKey
      ? generateStringLiterals(literalKeyName, Object.values(enumKeys), quote)
      : null;

    const enums = generateKind.enum
      ? generateEnums(enumName, enumKeys, quote)
      : null;
    const constant = generateKind.constant
      ? generateConstant({
          ...names,
          enumKeys,
          codepoints,
          quote,
          kind: generateKind
        })
      : null;

    return [stringLiteralId, stringLiteralKey, enums, constant]
      .filter(Boolean)
      .join('\n');
  }
}