@fern-api/generator-cli 0.1.8 → 0.2.0

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 (2) hide show
  1. package/dist/cli.cjs +48 -14
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -5846,7 +5846,7 @@ function resolve(...paths) {
5846
5846
 
5847
5847
  // src/cli.ts
5848
5848
  var import_fs6 = __toESM(require("fs"), 1);
5849
- var import_promises6 = require("fs/promises");
5849
+ var import_promises7 = require("fs/promises");
5850
5850
  var import_path7 = __toESM(require("path"), 1);
5851
5851
 
5852
5852
  // ../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/build/lib/yerror.js
@@ -7444,24 +7444,33 @@ async function loadGitHubConfig({
7444
7444
  return JSON.parse(rawContents);
7445
7445
  }
7446
7446
 
7447
- // src/configuration/loadReadmeConfig.ts
7447
+ // src/configuration/loadMetadataConfig.ts
7448
7448
  var import_promises3 = require("fs/promises");
7449
- async function loadReadmeConfig({
7449
+ async function loadMetadataConfig({
7450
7450
  absolutePathToConfig
7451
7451
  }) {
7452
7452
  const rawContents = await (0, import_promises3.readFile)(absolutePathToConfig, "utf8");
7453
7453
  return JSON.parse(rawContents);
7454
7454
  }
7455
7455
 
7456
- // src/configuration/loadReferenceConfig.ts
7456
+ // src/configuration/loadReadmeConfig.ts
7457
7457
  var import_promises4 = require("fs/promises");
7458
- async function loadReferenceConfig({
7458
+ async function loadReadmeConfig({
7459
7459
  absolutePathToConfig
7460
7460
  }) {
7461
7461
  const rawContents = await (0, import_promises4.readFile)(absolutePathToConfig, "utf8");
7462
7462
  return JSON.parse(rawContents);
7463
7463
  }
7464
7464
 
7465
+ // src/configuration/loadReferenceConfig.ts
7466
+ var import_promises5 = require("fs/promises");
7467
+ async function loadReferenceConfig({
7468
+ absolutePathToConfig
7469
+ }) {
7470
+ const rawContents = await (0, import_promises5.readFile)(absolutePathToConfig, "utf8");
7471
+ return JSON.parse(rawContents);
7472
+ }
7473
+
7465
7474
  // ../../node_modules/.pnpm/simple-git@3.24.0/node_modules/simple-git/dist/esm/index.js
7466
7475
  var import_file_exists = __toESM(require_dist(), 1);
7467
7476
  var import_debug = __toESM(require_src(), 1);
@@ -11969,7 +11978,7 @@ var esm_default2 = gitInstanceFactory;
11969
11978
  var import_tmp_promise = __toESM(require_tmp_promise(), 1);
11970
11979
 
11971
11980
  // ../commons/github/dist/ClonedRepository.js
11972
- var import_promises5 = require("fs/promises");
11981
+ var import_promises6 = require("fs/promises");
11973
11982
  var import_path6 = __toESM(require("path"), 1);
11974
11983
 
11975
11984
  // ../commons/github/dist/constants.js
@@ -12046,18 +12055,18 @@ var ClonedRepository = class {
12046
12055
  }
12047
12056
  async overwriteLocalContents(sourceDirectoryPath) {
12048
12057
  const [sourceContents, destContents] = await Promise.all([
12049
- (0, import_promises5.readdir)(sourceDirectoryPath),
12050
- (0, import_promises5.readdir)(this.clonePath)
12058
+ (0, import_promises6.readdir)(sourceDirectoryPath),
12059
+ (0, import_promises6.readdir)(this.clonePath)
12051
12060
  ]);
12052
12061
  await Promise.all(destContents.filter((content) => !DEFAULT_IGNORED_FILES.includes(content)).map(async (content) => {
12053
- await (0, import_promises5.rm)((0, import_path6.resolve)(this.clonePath, content), {
12062
+ await (0, import_promises6.rm)((0, import_path6.resolve)(this.clonePath, content), {
12054
12063
  recursive: true,
12055
12064
  force: true
12056
12065
  });
12057
12066
  }));
12058
12067
  await Promise.all(sourceContents.filter((content) => !DEFAULT_IGNORED_FILES.includes(content)).map(async (content) => {
12059
12068
  const path4 = (0, import_path6.resolve)(sourceDirectoryPath, content);
12060
- await (0, import_promises5.cp)(path4, (0, import_path6.resolve)(this.clonePath, content), { recursive: true });
12069
+ await (0, import_promises6.cp)(path4, (0, import_path6.resolve)(this.clonePath, content), { recursive: true });
12061
12070
  }));
12062
12071
  }
12063
12072
  async readFile({ relativeFilePath }) {
@@ -12065,12 +12074,12 @@ var ClonedRepository = class {
12065
12074
  if (!await doesPathExist2(absoluteFilePath)) {
12066
12075
  return void 0;
12067
12076
  }
12068
- return await (0, import_promises5.readFile)(absoluteFilePath, "utf-8");
12077
+ return await (0, import_promises6.readFile)(absoluteFilePath, "utf-8");
12069
12078
  }
12070
12079
  };
12071
12080
  async function doesPathExist2(filepath) {
12072
12081
  try {
12073
- await (0, import_promises5.lstat)(filepath);
12082
+ await (0, import_promises6.lstat)(filepath);
12074
12083
  return true;
12075
12084
  } catch {
12076
12085
  return false;
@@ -13621,7 +13630,7 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
13621
13630
  const generator = new ReadmeGenerator({
13622
13631
  readmeParser: new ReadmeParser(),
13623
13632
  readmeConfig,
13624
- originalReadme: argv.originalReadme != null ? await (0, import_promises6.readFile)(argv.originalReadme, "utf8") : void 0
13633
+ originalReadme: argv.originalReadme != null ? await (0, import_promises7.readFile)(argv.originalReadme, "utf8") : void 0
13625
13634
  });
13626
13635
  await generator.generateReadme({
13627
13636
  output: await createWriteStream(argv.output)
@@ -13655,6 +13664,31 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
13655
13664
  });
13656
13665
  process.exit(0);
13657
13666
  }
13667
+ ).command(
13668
+ "write-metadata",
13669
+ "Write metadata to the output directory using the provided configuration file.",
13670
+ (argv) => argv.option("config", {
13671
+ string: true,
13672
+ required: true
13673
+ }).option("output", {
13674
+ string: true,
13675
+ required: false
13676
+ }),
13677
+ async (argv) => {
13678
+ if (argv.config == null) {
13679
+ process.stderr.write("missing required arguments; please specify the --config flag\n");
13680
+ process.exit(1);
13681
+ }
13682
+ const wd = cwd();
13683
+ const metadata = await loadMetadataConfig({
13684
+ absolutePathToConfig: resolve(wd, argv.config)
13685
+ });
13686
+ const outputPath = argv.output != null ? resolve(wd, argv.output) : resolve(wd, ".fern/metadata.json");
13687
+ const formattedMetadata = JSON.stringify(metadata, null, 2);
13688
+ await (0, import_promises7.mkdir)(import_path7.default.dirname(outputPath), { recursive: true });
13689
+ await (0, import_promises7.writeFile)(outputPath, formattedMetadata, "utf8");
13690
+ process.exit(0);
13691
+ }
13658
13692
  ).command("github", "GitHub operations", (yargs) => {
13659
13693
  return yargs.command(
13660
13694
  "push",
@@ -13743,7 +13777,7 @@ async function createWriteStream(outputPath) {
13743
13777
  }
13744
13778
  async function createWriteStreamFromFile(filepath) {
13745
13779
  if (!await doesPathExist(filepath)) {
13746
- await (0, import_promises6.mkdir)(import_path7.default.dirname(filepath), { recursive: true });
13780
+ await (0, import_promises7.mkdir)(import_path7.default.dirname(filepath), { recursive: true });
13747
13781
  }
13748
13782
  return import_fs6.default.createWriteStream(filepath);
13749
13783
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fern-api/generator-cli",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern-platform"