@fern-api/generator-cli 0.6.6 → 0.6.7
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.
- package/dist/cli.js +21 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -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: "
|
|
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
|
|
32268
|
-
const
|
|
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.
|
|
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.
|
|
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
|
}
|