@fern-api/generator-cli 0.0.30 → 0.0.31
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.cjs +52 -1
- package/package.json +2 -1
package/dist/cli.cjs
CHANGED
|
@@ -8056,6 +8056,9 @@ async function loadReferenceConfig({
|
|
|
8056
8056
|
return JSON.parse(rawContents);
|
|
8057
8057
|
}
|
|
8058
8058
|
|
|
8059
|
+
// src/github/GitHub.ts
|
|
8060
|
+
var import_rest = require("@octokit/rest");
|
|
8061
|
+
|
|
8059
8062
|
// ../../node_modules/.pnpm/simple-git@3.24.0/node_modules/simple-git/dist/esm/index.js
|
|
8060
8063
|
var import_file_exists = __toESM(require_dist(), 1);
|
|
8061
8064
|
var import_debug = __toESM(require_src3(), 1);
|
|
@@ -12755,7 +12758,55 @@ var GitHub = class {
|
|
|
12755
12758
|
}
|
|
12756
12759
|
}
|
|
12757
12760
|
async pr() {
|
|
12758
|
-
|
|
12761
|
+
try {
|
|
12762
|
+
const wd = cwd();
|
|
12763
|
+
const sourceDirectory = resolve5(wd, this.githubConfig.sourceDirectory);
|
|
12764
|
+
const repository = await cloneRepository({
|
|
12765
|
+
githubRepository: this.githubConfig.uri,
|
|
12766
|
+
installationToken: this.githubConfig.token
|
|
12767
|
+
});
|
|
12768
|
+
const baseBranch = this.githubConfig.branch ?? await repository.getDefaultBranch();
|
|
12769
|
+
const now = /* @__PURE__ */ new Date();
|
|
12770
|
+
const formattedDate = now.toISOString().replace("T", "_").replace(/:/g, "-").replace(/\..+/, "");
|
|
12771
|
+
const prBranch = `fern-bot/${formattedDate}`;
|
|
12772
|
+
await repository.checkout(baseBranch);
|
|
12773
|
+
await repository.pull(baseBranch);
|
|
12774
|
+
await repository.checkout(prBranch);
|
|
12775
|
+
const fernIgnore = await repository.getFernignore();
|
|
12776
|
+
await repository.overwriteLocalContents(sourceDirectory);
|
|
12777
|
+
await repository.add(".");
|
|
12778
|
+
await this.restoreFernignoreFiles(repository, fernIgnore);
|
|
12779
|
+
await repository.commit("SDK Generation");
|
|
12780
|
+
await repository.push();
|
|
12781
|
+
const octokit = new import_rest.Octokit({
|
|
12782
|
+
auth: this.githubConfig.token
|
|
12783
|
+
});
|
|
12784
|
+
const [owner, repo] = this.githubConfig.uri.split("/");
|
|
12785
|
+
if (!owner || !repo) {
|
|
12786
|
+
throw new Error(`Invalid repository URI: ${this.githubConfig.uri}`);
|
|
12787
|
+
}
|
|
12788
|
+
const head = `${owner}:${prBranch}`;
|
|
12789
|
+
try {
|
|
12790
|
+
await octokit.pulls.create({
|
|
12791
|
+
owner,
|
|
12792
|
+
repo,
|
|
12793
|
+
title: "SDK Generation",
|
|
12794
|
+
body: "Automated SDK generation by Fern",
|
|
12795
|
+
head,
|
|
12796
|
+
base: baseBranch,
|
|
12797
|
+
draft: false
|
|
12798
|
+
});
|
|
12799
|
+
} catch (e) {
|
|
12800
|
+
if (typeof e?.message === "string" && e.message.includes("A pull request already exists for")) {
|
|
12801
|
+
console.error(`A pull request already exists for ${head}`);
|
|
12802
|
+
} else {
|
|
12803
|
+
throw e;
|
|
12804
|
+
}
|
|
12805
|
+
}
|
|
12806
|
+
} catch (error) {
|
|
12807
|
+
console.error("Error during GitHub PR flow:", error);
|
|
12808
|
+
throw error;
|
|
12809
|
+
}
|
|
12759
12810
|
}
|
|
12760
12811
|
async release() {
|
|
12761
12812
|
console.log("TODO: Implement release");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fern-api/generator-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/cli.cjs",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"test:update": "vitest -u --run --passWithNoTests --globals --disable-console-intercept"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"@octokit/rest": "^17.8.0",
|
|
27
28
|
"es-toolkit": "^1.32.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|