@fern-api/generator-cli 0.2.0 → 0.3.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.
- package/dist/api.cjs +7563 -0
- package/dist/api.d.cts +586 -0
- package/dist/cli.cjs +212 -174
- package/package.json +6 -3
package/dist/cli.cjs
CHANGED
|
@@ -7435,41 +7435,8 @@ Yargs.hideBin = processArgv.hideBin;
|
|
|
7435
7435
|
Yargs.Parser = Parser2;
|
|
7436
7436
|
var yargs_default = Yargs;
|
|
7437
7437
|
|
|
7438
|
-
// src/
|
|
7439
|
-
var
|
|
7440
|
-
async function loadGitHubConfig({
|
|
7441
|
-
absolutePathToConfig
|
|
7442
|
-
}) {
|
|
7443
|
-
const rawContents = await (0, import_promises2.readFile)(absolutePathToConfig, "utf8");
|
|
7444
|
-
return JSON.parse(rawContents);
|
|
7445
|
-
}
|
|
7446
|
-
|
|
7447
|
-
// src/configuration/loadMetadataConfig.ts
|
|
7448
|
-
var import_promises3 = require("fs/promises");
|
|
7449
|
-
async function loadMetadataConfig({
|
|
7450
|
-
absolutePathToConfig
|
|
7451
|
-
}) {
|
|
7452
|
-
const rawContents = await (0, import_promises3.readFile)(absolutePathToConfig, "utf8");
|
|
7453
|
-
return JSON.parse(rawContents);
|
|
7454
|
-
}
|
|
7455
|
-
|
|
7456
|
-
// src/configuration/loadReadmeConfig.ts
|
|
7457
|
-
var import_promises4 = require("fs/promises");
|
|
7458
|
-
async function loadReadmeConfig({
|
|
7459
|
-
absolutePathToConfig
|
|
7460
|
-
}) {
|
|
7461
|
-
const rawContents = await (0, import_promises4.readFile)(absolutePathToConfig, "utf8");
|
|
7462
|
-
return JSON.parse(rawContents);
|
|
7463
|
-
}
|
|
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
|
-
}
|
|
7438
|
+
// src/api/generate-readme.ts
|
|
7439
|
+
var import_node_stream = require("stream");
|
|
7473
7440
|
|
|
7474
7441
|
// ../../node_modules/.pnpm/simple-git@3.24.0/node_modules/simple-git/dist/esm/index.js
|
|
7475
7442
|
var import_file_exists = __toESM(require_dist(), 1);
|
|
@@ -11978,7 +11945,7 @@ var esm_default2 = gitInstanceFactory;
|
|
|
11978
11945
|
var import_tmp_promise = __toESM(require_tmp_promise(), 1);
|
|
11979
11946
|
|
|
11980
11947
|
// ../commons/github/dist/ClonedRepository.js
|
|
11981
|
-
var
|
|
11948
|
+
var import_promises2 = require("fs/promises");
|
|
11982
11949
|
var import_path6 = __toESM(require("path"), 1);
|
|
11983
11950
|
|
|
11984
11951
|
// ../commons/github/dist/constants.js
|
|
@@ -12055,18 +12022,18 @@ var ClonedRepository = class {
|
|
|
12055
12022
|
}
|
|
12056
12023
|
async overwriteLocalContents(sourceDirectoryPath) {
|
|
12057
12024
|
const [sourceContents, destContents] = await Promise.all([
|
|
12058
|
-
(0,
|
|
12059
|
-
(0,
|
|
12025
|
+
(0, import_promises2.readdir)(sourceDirectoryPath),
|
|
12026
|
+
(0, import_promises2.readdir)(this.clonePath)
|
|
12060
12027
|
]);
|
|
12061
12028
|
await Promise.all(destContents.filter((content) => !DEFAULT_IGNORED_FILES.includes(content)).map(async (content) => {
|
|
12062
|
-
await (0,
|
|
12029
|
+
await (0, import_promises2.rm)((0, import_path6.resolve)(this.clonePath, content), {
|
|
12063
12030
|
recursive: true,
|
|
12064
12031
|
force: true
|
|
12065
12032
|
});
|
|
12066
12033
|
}));
|
|
12067
12034
|
await Promise.all(sourceContents.filter((content) => !DEFAULT_IGNORED_FILES.includes(content)).map(async (content) => {
|
|
12068
12035
|
const path4 = (0, import_path6.resolve)(sourceDirectoryPath, content);
|
|
12069
|
-
await (0,
|
|
12036
|
+
await (0, import_promises2.cp)(path4, (0, import_path6.resolve)(this.clonePath, content), { recursive: true });
|
|
12070
12037
|
}));
|
|
12071
12038
|
}
|
|
12072
12039
|
async readFile({ relativeFilePath }) {
|
|
@@ -12074,12 +12041,12 @@ var ClonedRepository = class {
|
|
|
12074
12041
|
if (!await doesPathExist2(absoluteFilePath)) {
|
|
12075
12042
|
return void 0;
|
|
12076
12043
|
}
|
|
12077
|
-
return await (0,
|
|
12044
|
+
return await (0, import_promises2.readFile)(absoluteFilePath, "utf-8");
|
|
12078
12045
|
}
|
|
12079
12046
|
};
|
|
12080
12047
|
async function doesPathExist2(filepath) {
|
|
12081
12048
|
try {
|
|
12082
|
-
await (0,
|
|
12049
|
+
await (0, import_promises2.lstat)(filepath);
|
|
12083
12050
|
return true;
|
|
12084
12051
|
} catch {
|
|
12085
12052
|
return false;
|
|
@@ -12142,115 +12109,6 @@ async function cloneRepository({ githubRepository, installationToken }) {
|
|
|
12142
12109
|
});
|
|
12143
12110
|
}
|
|
12144
12111
|
|
|
12145
|
-
// src/github/GitHub.ts
|
|
12146
|
-
var import_rest = require("@octokit/rest");
|
|
12147
|
-
var GitHub = class {
|
|
12148
|
-
githubConfig;
|
|
12149
|
-
constructor({
|
|
12150
|
-
githubConfig
|
|
12151
|
-
}) {
|
|
12152
|
-
this.githubConfig = githubConfig;
|
|
12153
|
-
}
|
|
12154
|
-
async push() {
|
|
12155
|
-
try {
|
|
12156
|
-
const wd = cwd();
|
|
12157
|
-
const sourceDirectory = resolve(wd, this.githubConfig.sourceDirectory);
|
|
12158
|
-
const repository = await cloneRepository({
|
|
12159
|
-
githubRepository: this.githubConfig.uri,
|
|
12160
|
-
installationToken: this.githubConfig.token
|
|
12161
|
-
});
|
|
12162
|
-
const branch = this.githubConfig.branch ?? await repository.getDefaultBranch();
|
|
12163
|
-
await repository.checkout(branch);
|
|
12164
|
-
await repository.pull(branch);
|
|
12165
|
-
const fernIgnoreFiles = await this.getFernignoreFiles(repository);
|
|
12166
|
-
await repository.overwriteLocalContents(sourceDirectory);
|
|
12167
|
-
await repository.add(".");
|
|
12168
|
-
await this.restoreFiles(repository, fernIgnoreFiles);
|
|
12169
|
-
await repository.commit("SDK Generation");
|
|
12170
|
-
await repository.push();
|
|
12171
|
-
} catch (error) {
|
|
12172
|
-
console.error("Error during GitHub push:", error);
|
|
12173
|
-
throw error;
|
|
12174
|
-
}
|
|
12175
|
-
}
|
|
12176
|
-
async pr() {
|
|
12177
|
-
try {
|
|
12178
|
-
const wd = cwd();
|
|
12179
|
-
const sourceDirectory = resolve(wd, this.githubConfig.sourceDirectory);
|
|
12180
|
-
const repository = await cloneRepository({
|
|
12181
|
-
githubRepository: this.githubConfig.uri,
|
|
12182
|
-
installationToken: this.githubConfig.token
|
|
12183
|
-
});
|
|
12184
|
-
const baseBranch = this.githubConfig.branch ?? await repository.getDefaultBranch();
|
|
12185
|
-
const now = /* @__PURE__ */ new Date();
|
|
12186
|
-
const formattedDate = now.toISOString().replace("T", "_").replace(/:/g, "-").replace(/\..+/, "");
|
|
12187
|
-
const prBranch = `fern-bot/${formattedDate}`;
|
|
12188
|
-
await repository.checkout(baseBranch);
|
|
12189
|
-
await repository.pull(baseBranch);
|
|
12190
|
-
await repository.checkout(prBranch);
|
|
12191
|
-
const fernIgnoreFiles = await this.getFernignoreFiles(repository);
|
|
12192
|
-
await repository.overwriteLocalContents(sourceDirectory);
|
|
12193
|
-
await repository.add(".");
|
|
12194
|
-
await this.restoreFiles(repository, fernIgnoreFiles);
|
|
12195
|
-
await repository.commit("SDK Generation");
|
|
12196
|
-
await repository.push();
|
|
12197
|
-
const octokit = new import_rest.Octokit({
|
|
12198
|
-
auth: this.githubConfig.token
|
|
12199
|
-
});
|
|
12200
|
-
const [owner, repo] = this.githubConfig.uri.split("/");
|
|
12201
|
-
if (!owner || !repo) {
|
|
12202
|
-
throw new Error(`Invalid repository URI: ${this.githubConfig.uri}`);
|
|
12203
|
-
}
|
|
12204
|
-
const head = `${owner}:${prBranch}`;
|
|
12205
|
-
try {
|
|
12206
|
-
await octokit.pulls.create({
|
|
12207
|
-
owner,
|
|
12208
|
-
repo,
|
|
12209
|
-
title: "SDK Generation",
|
|
12210
|
-
body: "Automated SDK generation by Fern",
|
|
12211
|
-
head,
|
|
12212
|
-
base: baseBranch,
|
|
12213
|
-
draft: false
|
|
12214
|
-
});
|
|
12215
|
-
} catch (e) {
|
|
12216
|
-
if (typeof e?.message === "string" && e.message.includes("A pull request already exists for")) {
|
|
12217
|
-
console.error(`A pull request already exists for ${head}`);
|
|
12218
|
-
} else {
|
|
12219
|
-
throw e;
|
|
12220
|
-
}
|
|
12221
|
-
}
|
|
12222
|
-
} catch (error) {
|
|
12223
|
-
console.error("Error during GitHub PR flow:", error);
|
|
12224
|
-
throw error;
|
|
12225
|
-
}
|
|
12226
|
-
}
|
|
12227
|
-
async release() {
|
|
12228
|
-
console.log("TODO: Implement release");
|
|
12229
|
-
}
|
|
12230
|
-
async getFernignoreFiles(repository) {
|
|
12231
|
-
const fernignore = await repository.getFernignore();
|
|
12232
|
-
if (fernignore === void 0) {
|
|
12233
|
-
return [];
|
|
12234
|
-
}
|
|
12235
|
-
const fernignoreLines = fernignore.split("\n");
|
|
12236
|
-
const fernignoreFiles = [];
|
|
12237
|
-
for (const line of fernignoreLines) {
|
|
12238
|
-
const trimmedLine = line.trim();
|
|
12239
|
-
if (!trimmedLine.startsWith("#") && trimmedLine.length > 0 && await repository.fileExists({ relativeFilePath: trimmedLine })) {
|
|
12240
|
-
fernignoreFiles.push(trimmedLine);
|
|
12241
|
-
}
|
|
12242
|
-
}
|
|
12243
|
-
return fernignoreFiles;
|
|
12244
|
-
}
|
|
12245
|
-
async restoreFiles(repository, files) {
|
|
12246
|
-
if (files.length === 0) {
|
|
12247
|
-
return;
|
|
12248
|
-
}
|
|
12249
|
-
await repository.restoreFiles({ files, staged: true });
|
|
12250
|
-
await repository.restoreFiles({ files });
|
|
12251
|
-
}
|
|
12252
|
-
};
|
|
12253
|
-
|
|
12254
12112
|
// src/readme/ReadmeGenerator.ts
|
|
12255
12113
|
var import_compat = require("es-toolkit/compat");
|
|
12256
12114
|
var import_string = require("es-toolkit/string");
|
|
@@ -13500,6 +13358,22 @@ function sectionNameToID(sectionName) {
|
|
|
13500
13358
|
).toUpperCase();
|
|
13501
13359
|
}
|
|
13502
13360
|
|
|
13361
|
+
// src/api/generate-readme.ts
|
|
13362
|
+
async function generateReadmeToStream(params) {
|
|
13363
|
+
const { originalReadmeContent, readmeConfig, outputStream } = params;
|
|
13364
|
+
const generator = new ReadmeGenerator({
|
|
13365
|
+
readmeParser: new ReadmeParser(),
|
|
13366
|
+
readmeConfig,
|
|
13367
|
+
originalReadme: originalReadmeContent
|
|
13368
|
+
});
|
|
13369
|
+
await generator.generateReadme({
|
|
13370
|
+
output: outputStream
|
|
13371
|
+
});
|
|
13372
|
+
}
|
|
13373
|
+
|
|
13374
|
+
// src/api/generate-reference.ts
|
|
13375
|
+
var import_node_stream2 = require("stream");
|
|
13376
|
+
|
|
13503
13377
|
// src/reference/ReferenceGenerator.ts
|
|
13504
13378
|
var ReferenceGenerator = class {
|
|
13505
13379
|
referenceConfig;
|
|
@@ -13604,6 +13478,183 @@ ${content}
|
|
|
13604
13478
|
}
|
|
13605
13479
|
};
|
|
13606
13480
|
|
|
13481
|
+
// src/api/generate-reference.ts
|
|
13482
|
+
async function generateReferenceToStream(params) {
|
|
13483
|
+
const { referenceConfig, outputStream } = params;
|
|
13484
|
+
const generator = new ReferenceGenerator({
|
|
13485
|
+
referenceConfig
|
|
13486
|
+
});
|
|
13487
|
+
await generator.generate({
|
|
13488
|
+
output: outputStream
|
|
13489
|
+
});
|
|
13490
|
+
}
|
|
13491
|
+
|
|
13492
|
+
// src/github/GitHub.ts
|
|
13493
|
+
var import_rest = require("@octokit/rest");
|
|
13494
|
+
var GitHub = class {
|
|
13495
|
+
githubConfig;
|
|
13496
|
+
constructor({
|
|
13497
|
+
githubConfig
|
|
13498
|
+
}) {
|
|
13499
|
+
this.githubConfig = githubConfig;
|
|
13500
|
+
}
|
|
13501
|
+
async push() {
|
|
13502
|
+
try {
|
|
13503
|
+
const wd = cwd();
|
|
13504
|
+
const sourceDirectory = resolve(wd, this.githubConfig.sourceDirectory);
|
|
13505
|
+
const repository = await cloneRepository({
|
|
13506
|
+
githubRepository: this.githubConfig.uri,
|
|
13507
|
+
installationToken: this.githubConfig.token
|
|
13508
|
+
});
|
|
13509
|
+
const branch = this.githubConfig.branch ?? await repository.getDefaultBranch();
|
|
13510
|
+
await repository.checkout(branch);
|
|
13511
|
+
await repository.pull(branch);
|
|
13512
|
+
const fernIgnoreFiles = await this.getFernignoreFiles(repository);
|
|
13513
|
+
await repository.overwriteLocalContents(sourceDirectory);
|
|
13514
|
+
await repository.add(".");
|
|
13515
|
+
await this.restoreFiles(repository, fernIgnoreFiles);
|
|
13516
|
+
await repository.commit("SDK Generation");
|
|
13517
|
+
await repository.push();
|
|
13518
|
+
} catch (error) {
|
|
13519
|
+
console.error("Error during GitHub push:", error);
|
|
13520
|
+
throw error;
|
|
13521
|
+
}
|
|
13522
|
+
}
|
|
13523
|
+
async pr() {
|
|
13524
|
+
try {
|
|
13525
|
+
const wd = cwd();
|
|
13526
|
+
const sourceDirectory = resolve(wd, this.githubConfig.sourceDirectory);
|
|
13527
|
+
const repository = await cloneRepository({
|
|
13528
|
+
githubRepository: this.githubConfig.uri,
|
|
13529
|
+
installationToken: this.githubConfig.token
|
|
13530
|
+
});
|
|
13531
|
+
const baseBranch = this.githubConfig.branch ?? await repository.getDefaultBranch();
|
|
13532
|
+
const now = /* @__PURE__ */ new Date();
|
|
13533
|
+
const formattedDate = now.toISOString().replace("T", "_").replace(/:/g, "-").replace(/\..+/, "");
|
|
13534
|
+
const prBranch = `fern-bot/${formattedDate}`;
|
|
13535
|
+
await repository.checkout(baseBranch);
|
|
13536
|
+
await repository.pull(baseBranch);
|
|
13537
|
+
await repository.checkout(prBranch);
|
|
13538
|
+
const fernIgnoreFiles = await this.getFernignoreFiles(repository);
|
|
13539
|
+
await repository.overwriteLocalContents(sourceDirectory);
|
|
13540
|
+
await repository.add(".");
|
|
13541
|
+
await this.restoreFiles(repository, fernIgnoreFiles);
|
|
13542
|
+
await repository.commit("SDK Generation");
|
|
13543
|
+
await repository.push();
|
|
13544
|
+
const octokit = new import_rest.Octokit({
|
|
13545
|
+
auth: this.githubConfig.token
|
|
13546
|
+
});
|
|
13547
|
+
const [owner, repo] = this.githubConfig.uri.split("/");
|
|
13548
|
+
if (!owner || !repo) {
|
|
13549
|
+
throw new Error(`Invalid repository URI: ${this.githubConfig.uri}`);
|
|
13550
|
+
}
|
|
13551
|
+
const head = `${owner}:${prBranch}`;
|
|
13552
|
+
try {
|
|
13553
|
+
await octokit.pulls.create({
|
|
13554
|
+
owner,
|
|
13555
|
+
repo,
|
|
13556
|
+
title: "SDK Generation",
|
|
13557
|
+
body: "Automated SDK generation by Fern",
|
|
13558
|
+
head,
|
|
13559
|
+
base: baseBranch,
|
|
13560
|
+
draft: false
|
|
13561
|
+
});
|
|
13562
|
+
} catch (e) {
|
|
13563
|
+
if (typeof e?.message === "string" && e.message.includes("A pull request already exists for")) {
|
|
13564
|
+
console.error(`A pull request already exists for ${head}`);
|
|
13565
|
+
} else {
|
|
13566
|
+
throw e;
|
|
13567
|
+
}
|
|
13568
|
+
}
|
|
13569
|
+
} catch (error) {
|
|
13570
|
+
console.error("Error during GitHub PR flow:", error);
|
|
13571
|
+
throw error;
|
|
13572
|
+
}
|
|
13573
|
+
}
|
|
13574
|
+
async release() {
|
|
13575
|
+
console.log("TODO: Implement release");
|
|
13576
|
+
}
|
|
13577
|
+
async getFernignoreFiles(repository) {
|
|
13578
|
+
const fernignore = await repository.getFernignore();
|
|
13579
|
+
if (fernignore === void 0) {
|
|
13580
|
+
return [];
|
|
13581
|
+
}
|
|
13582
|
+
const fernignoreLines = fernignore.split("\n");
|
|
13583
|
+
const fernignoreFiles = [];
|
|
13584
|
+
for (const line of fernignoreLines) {
|
|
13585
|
+
const trimmedLine = line.trim();
|
|
13586
|
+
if (!trimmedLine.startsWith("#") && trimmedLine.length > 0 && await repository.fileExists({ relativeFilePath: trimmedLine })) {
|
|
13587
|
+
fernignoreFiles.push(trimmedLine);
|
|
13588
|
+
}
|
|
13589
|
+
}
|
|
13590
|
+
return fernignoreFiles;
|
|
13591
|
+
}
|
|
13592
|
+
async restoreFiles(repository, files) {
|
|
13593
|
+
if (files.length === 0) {
|
|
13594
|
+
return;
|
|
13595
|
+
}
|
|
13596
|
+
await repository.restoreFiles({ files, staged: true });
|
|
13597
|
+
await repository.restoreFiles({ files });
|
|
13598
|
+
}
|
|
13599
|
+
};
|
|
13600
|
+
|
|
13601
|
+
// src/api/github-pr.ts
|
|
13602
|
+
async function githubPr(params) {
|
|
13603
|
+
const { githubConfig } = params;
|
|
13604
|
+
const github = new GitHub({ githubConfig });
|
|
13605
|
+
await github.pr();
|
|
13606
|
+
}
|
|
13607
|
+
|
|
13608
|
+
// src/api/github-push.ts
|
|
13609
|
+
async function githubPush(params) {
|
|
13610
|
+
const { githubConfig } = params;
|
|
13611
|
+
const github = new GitHub({ githubConfig });
|
|
13612
|
+
await github.push();
|
|
13613
|
+
}
|
|
13614
|
+
|
|
13615
|
+
// src/api/github-release.ts
|
|
13616
|
+
async function githubRelease(params) {
|
|
13617
|
+
const { githubConfig } = params;
|
|
13618
|
+
const github = new GitHub({ githubConfig });
|
|
13619
|
+
await github.release();
|
|
13620
|
+
}
|
|
13621
|
+
|
|
13622
|
+
// src/configuration/loadGitHubConfig.ts
|
|
13623
|
+
var import_promises3 = require("fs/promises");
|
|
13624
|
+
async function loadGitHubConfig({
|
|
13625
|
+
absolutePathToConfig
|
|
13626
|
+
}) {
|
|
13627
|
+
const rawContents = await (0, import_promises3.readFile)(absolutePathToConfig, "utf8");
|
|
13628
|
+
return JSON.parse(rawContents);
|
|
13629
|
+
}
|
|
13630
|
+
|
|
13631
|
+
// src/configuration/loadMetadataConfig.ts
|
|
13632
|
+
var import_promises4 = require("fs/promises");
|
|
13633
|
+
async function loadMetadataConfig({
|
|
13634
|
+
absolutePathToConfig
|
|
13635
|
+
}) {
|
|
13636
|
+
const rawContents = await (0, import_promises4.readFile)(absolutePathToConfig, "utf8");
|
|
13637
|
+
return JSON.parse(rawContents);
|
|
13638
|
+
}
|
|
13639
|
+
|
|
13640
|
+
// src/configuration/loadReadmeConfig.ts
|
|
13641
|
+
var import_promises5 = require("fs/promises");
|
|
13642
|
+
async function loadReadmeConfig({
|
|
13643
|
+
absolutePathToConfig
|
|
13644
|
+
}) {
|
|
13645
|
+
const rawContents = await (0, import_promises5.readFile)(absolutePathToConfig, "utf8");
|
|
13646
|
+
return JSON.parse(rawContents);
|
|
13647
|
+
}
|
|
13648
|
+
|
|
13649
|
+
// src/configuration/loadReferenceConfig.ts
|
|
13650
|
+
var import_promises6 = require("fs/promises");
|
|
13651
|
+
async function loadReferenceConfig({
|
|
13652
|
+
absolutePathToConfig
|
|
13653
|
+
}) {
|
|
13654
|
+
const rawContents = await (0, import_promises6.readFile)(absolutePathToConfig, "utf8");
|
|
13655
|
+
return JSON.parse(rawContents);
|
|
13656
|
+
}
|
|
13657
|
+
|
|
13607
13658
|
// src/cli.ts
|
|
13608
13659
|
void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "generator-cli").strict().command(
|
|
13609
13660
|
"generate readme",
|
|
@@ -13627,13 +13678,11 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
|
|
|
13627
13678
|
const readmeConfig = await loadReadmeConfig({
|
|
13628
13679
|
absolutePathToConfig: resolve(wd, argv.config)
|
|
13629
13680
|
});
|
|
13630
|
-
const
|
|
13631
|
-
|
|
13681
|
+
const originalReadmeContent = argv.originalReadme != null ? await (0, import_promises7.readFile)(argv.originalReadme, "utf8") : void 0;
|
|
13682
|
+
await generateReadmeToStream({
|
|
13683
|
+
originalReadmeContent,
|
|
13632
13684
|
readmeConfig,
|
|
13633
|
-
|
|
13634
|
-
});
|
|
13635
|
-
await generator.generateReadme({
|
|
13636
|
-
output: await createWriteStream(argv.output)
|
|
13685
|
+
outputStream: await createWriteStream(argv.output)
|
|
13637
13686
|
});
|
|
13638
13687
|
process.exit(0);
|
|
13639
13688
|
}
|
|
@@ -13656,11 +13705,9 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
|
|
|
13656
13705
|
const referenceConfig = await loadReferenceConfig({
|
|
13657
13706
|
absolutePathToConfig: resolve(wd, argv.config)
|
|
13658
13707
|
});
|
|
13659
|
-
|
|
13660
|
-
referenceConfig
|
|
13661
|
-
|
|
13662
|
-
await generator.generate({
|
|
13663
|
-
output: await createWriteStream(argv.output)
|
|
13708
|
+
await generateReferenceToStream({
|
|
13709
|
+
referenceConfig,
|
|
13710
|
+
outputStream: await createWriteStream(argv.output)
|
|
13664
13711
|
});
|
|
13665
13712
|
process.exit(0);
|
|
13666
13713
|
}
|
|
@@ -13709,10 +13756,7 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
|
|
|
13709
13756
|
const githubConfig = await loadGitHubConfig({
|
|
13710
13757
|
absolutePathToConfig: resolve(wd, argv.config)
|
|
13711
13758
|
});
|
|
13712
|
-
|
|
13713
|
-
githubConfig
|
|
13714
|
-
});
|
|
13715
|
-
await github.push();
|
|
13759
|
+
await githubPush({ githubConfig });
|
|
13716
13760
|
process.exit(0);
|
|
13717
13761
|
}
|
|
13718
13762
|
).command(
|
|
@@ -13734,10 +13778,7 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
|
|
|
13734
13778
|
const githubConfig = await loadGitHubConfig({
|
|
13735
13779
|
absolutePathToConfig: resolve(wd, argv.config)
|
|
13736
13780
|
});
|
|
13737
|
-
|
|
13738
|
-
githubConfig
|
|
13739
|
-
});
|
|
13740
|
-
await github.pr();
|
|
13781
|
+
await githubPr({ githubConfig });
|
|
13741
13782
|
process.stderr.write(`Creating PR on GitHub with config: ${resolve(wd, argv.config)}
|
|
13742
13783
|
`);
|
|
13743
13784
|
process.exit(0);
|
|
@@ -13759,10 +13800,7 @@ void yargs_default(hideBin(process.argv)).scriptName(process.env.CLI_NAME ?? "ge
|
|
|
13759
13800
|
const githubConfig = await loadGitHubConfig({
|
|
13760
13801
|
absolutePathToConfig: resolve(wd2, argv.config)
|
|
13761
13802
|
});
|
|
13762
|
-
|
|
13763
|
-
githubConfig
|
|
13764
|
-
});
|
|
13765
|
-
await github.release();
|
|
13803
|
+
await githubRelease({ githubConfig });
|
|
13766
13804
|
process.exit(1);
|
|
13767
13805
|
}
|
|
13768
13806
|
const wd = cwd();
|
package/package.json
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fern-api/generator-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/fern-api/fern-platform"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
|
-
"main": "dist/
|
|
9
|
+
"main": "dist/api.cjs",
|
|
10
10
|
"source": "src/index.ts",
|
|
11
|
+
"types": "dist/api.d.cts",
|
|
11
12
|
"bin": {
|
|
12
13
|
"generator-cli": "dist/cli.cjs"
|
|
13
14
|
},
|
|
14
15
|
"files": ["dist"],
|
|
15
16
|
"scripts": {
|
|
16
17
|
"clean": "rm -rf ./dist && tsc --build --clean",
|
|
17
|
-
"compile": "
|
|
18
|
+
"compile": "pnpm compile:api && pnpm compile:cli",
|
|
19
|
+
"compile:api": "tsup ./src/api.ts --format cjs --dts",
|
|
20
|
+
"compile:cli": "tsup ./src/cli.ts --format cjs && echo '#!/usr/bin/env node' | cat - dist/cli.cjs > dist/tmp && mv dist/tmp dist/cli.cjs",
|
|
18
21
|
"depcheck": "depcheck",
|
|
19
22
|
"format": "prettier --write --ignore-unknown \"**\"",
|
|
20
23
|
"format:check": "prettier --check --ignore-unknown \"**\"",
|