@fern-api/generator-cli 0.6.6 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/api.js +1 -1
  2. package/dist/cli.js +22 -15
  3. package/package.json +1 -1
package/dist/api.js CHANGED
@@ -10126,7 +10126,7 @@ var GithubStep = class extends BaseStep {
10126
10126
  updatedExistingPr: isUpdatingExistingPR
10127
10127
  };
10128
10128
  if (!this.config.previewMode) {
10129
- if (skipCommit && isUpdatingExistingPR) {
10129
+ if (isUpdatingExistingPR) {
10130
10130
  await repository.forcePush();
10131
10131
  } else {
10132
10132
  await repository.push();
package/dist/cli.js CHANGED
@@ -31253,7 +31253,7 @@ var GithubStep = class extends BaseStep {
31253
31253
  updatedExistingPr: isUpdatingExistingPR
31254
31254
  };
31255
31255
  if (!this.config.previewMode) {
31256
- if (skipCommit && isUpdatingExistingPR) {
31256
+ if (isUpdatingExistingPR) {
31257
31257
  await repository.forcePush();
31258
31258
  } else {
31259
31259
  await repository.push();
@@ -32111,6 +32111,7 @@ async function loadReferenceConfig({
32111
32111
  }
32112
32112
 
32113
32113
  // src/cli.ts
32114
+ var STDIN_MARKER = "-";
32114
32115
  void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "generator-cli").strict().command(
32115
32116
  "generate readme",
32116
32117
  "Generate a README.md using the provided configuration file.",
@@ -32244,15 +32245,11 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
32244
32245
  return subYargs.option("config", {
32245
32246
  string: true,
32246
32247
  required: true,
32247
- description: "Path to pipeline config JSON"
32248
+ description: "The file or data to use for pipeline configuration"
32248
32249
  }).option("output-dir", {
32249
32250
  string: true,
32250
32251
  required: true,
32251
32252
  description: "Path to SDK output directory"
32252
- }).option("result-file", {
32253
- string: true,
32254
- required: false,
32255
- description: "Path to write result JSON"
32256
32253
  });
32257
32254
  },
32258
32255
  async (argv) => {
@@ -32264,16 +32261,18 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
32264
32261
  }
32265
32262
  try {
32266
32263
  const wd = cwd();
32267
- const configContent = await (0, import_promises9.readFile)(resolve(wd, argv.config), "utf-8");
32268
- const config = JSON.parse(configContent);
32264
+ const configValue = argv.config;
32265
+ const configContent = configValue === STDIN_MARKER ? await readStdin() : configValue.trimStart().startsWith("{") ? configValue : await (0, import_promises9.readFile)(resolve(wd, configValue), "utf-8");
32266
+ let config;
32267
+ try {
32268
+ config = JSON.parse(configContent);
32269
+ } catch (parseError) {
32270
+ const parseMessage = parseError instanceof Error ? parseError.message : String(parseError);
32271
+ throw new Error(`Failed to parse pipeline config as JSON: ${parseMessage}`);
32272
+ }
32269
32273
  config.outputDir = resolve(wd, argv["output-dir"]);
32270
32274
  const pipeline = new PostGenerationPipeline(config);
32271
32275
  const result = await pipeline.run();
32272
- if (argv["result-file"] != null) {
32273
- const resultPath = resolve(wd, argv["result-file"]);
32274
- await (0, import_promises9.mkdir)(import_path16.default.dirname(resultPath), { recursive: true });
32275
- await import_fs14.default.promises.writeFile(resultPath, JSON.stringify(result, null, 2));
32276
- }
32277
32276
  process.stderr.write(`Pipeline ${result.success ? "succeeded" : "failed"}
32278
32277
  `);
32279
32278
  if (result.steps.replay != null) {
@@ -32299,12 +32298,13 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
32299
32298
  ${result.errors.map((e) => ` - ${e}`).join("\n")}
32300
32299
  `);
32301
32300
  }
32302
- process.exit(result.success ? 0 : 1);
32301
+ process.stdout.write(JSON.stringify(result) + "\n");
32302
+ process.exitCode = result.success ? 0 : 1;
32303
32303
  } catch (error) {
32304
32304
  const errorMessage = error instanceof Error ? error.message : String(error);
32305
32305
  process.stderr.write(`Pipeline failed: ${errorMessage}
32306
32306
  `);
32307
- process.exit(1);
32307
+ process.exitCode = 1;
32308
32308
  }
32309
32309
  }
32310
32310
  ).demandCommand();
@@ -32473,6 +32473,13 @@ Bootstrap complete! Lockfile saved to ${outputDir}/.fern/replay.lock
32473
32473
  handler: () => {
32474
32474
  }
32475
32475
  }).demandCommand().showHelpOnFail(true).parse();
32476
+ async function readStdin() {
32477
+ const chunks = [];
32478
+ for await (const chunk of process.stdin) {
32479
+ chunks.push(chunk);
32480
+ }
32481
+ return Buffer.concat(chunks).toString("utf-8");
32482
+ }
32476
32483
  async function createWriteStream(outputPath) {
32477
32484
  return outputPath != null ? await createWriteStreamFromFile(resolve(cwd(), outputPath)) : process.stdout;
32478
32485
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fern-api/generator-cli",
3
- "version": "0.6.6",
3
+ "version": "0.6.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/fern-api/fern.git",