How to use @kosko/generate - 5 common examples

To help you get started, we’ve selected a few @kosko/generate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tommy351 / kosko / packages / cli / src / commands / generate.ts View on Github external
builder(argv) {
    /* istanbul ignore next */
    return generateBuilder(argv)
      .option("output", {
        type: "string",
        describe: "Output format",
        default: PrintFormat.YAML,
        choices: Object.keys(PrintFormat).map(key => (PrintFormat as any)[key]),
        alias: "o"
      })
      .option("validate", {
        type: "boolean",
        describe: "Validate components",
        default: true
      })
      .example("$0 generate", "Generate manifests")
      .example("$0 generate foo bar", "Specify components")
      .example("$0 generate foo_*", "Use glob pattern")
      .example("$0 generate --env foo", "Set environment")
      .example("$0 generate -r ts-node/register", "Require external modules");
  },
  async handler(args) {
github tommy351 / kosko / packages / cli / src / commands / generate.ts View on Github external
if (config.paths && config.paths.environment) {
      const paths = config.paths.environment;
      if (paths.global) env.paths.global = paths.global;
      if (paths.component) env.paths.component = paths.component;
    }

    debug("Set env as", args.env);
  }

  // Require external modules
  for (const id of config.require) {
    await localRequire(id, args.cwd);
  }

  // Generate manifests
  const result = await generate({
    path: join(args.cwd, "components"),
    components: config.components,
    extensions: config.extensions,
    validate: args.validate
  });

  if (!result.manifests.length) {
    throw new CLIError("No manifests are exported from components", {
      output: `No manifests are exported from components. Make sure there are exported manifests in components.`
    });
  }

  return result;
}
github tommy351 / kosko / packages / cli / src / commands / __tests__ / generate.ts View on Github external
test("should call print with given format", () => {
      expect(print).toHaveBeenCalledWith(result, {
        format: PrintFormat.YAML,
        writer: process.stdout
      });
    });
  });
github tommy351 / kosko / packages / cli / src / commands / generate.ts View on Github external
async handler(args) {
    const result = await generateHandler(args);

    print(result, {
      format: args.output,
      writer: process.stdout
    });
  }
};

@kosko/generate

Find and print components in a kosko app directory.

MIT
Latest version published 13 days ago

Package Health Score

75 / 100
Full package analysis