@fern-api/generator-cli 0.0.23 → 0.0.25
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 +46 -8
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -12569,8 +12569,12 @@ var import_path6 = __toESM(require("path"), 1);
|
|
|
12569
12569
|
// ../commons/github/dist/constants.js
|
|
12570
12570
|
var DEFAULT_REMOTE = "github.com";
|
|
12571
12571
|
var README_FILEPATH = "README.md";
|
|
12572
|
+
var FERNIGNORE = ".fernignore";
|
|
12573
|
+
var GITIGNORE = ".gitignore";
|
|
12574
|
+
var GIT_DIR = ".git";
|
|
12572
12575
|
|
|
12573
12576
|
// ../commons/github/dist/ClonedRepository.js
|
|
12577
|
+
var DEFAULT_IGNORED_FILES = [FERNIGNORE, GITIGNORE, GIT_DIR];
|
|
12574
12578
|
var ClonedRepository = class {
|
|
12575
12579
|
clonePath;
|
|
12576
12580
|
git;
|
|
@@ -12593,13 +12597,26 @@ var ClonedRepository = class {
|
|
|
12593
12597
|
async getReadme() {
|
|
12594
12598
|
return await this.readFile({ relativeFilePath: README_FILEPATH });
|
|
12595
12599
|
}
|
|
12600
|
+
async getFernignore() {
|
|
12601
|
+
return await this.readFile({ relativeFilePath: FERNIGNORE });
|
|
12602
|
+
}
|
|
12596
12603
|
async add(files) {
|
|
12597
12604
|
await this.git.cwd(this.clonePath);
|
|
12598
12605
|
await this.git.add(files);
|
|
12599
12606
|
}
|
|
12607
|
+
async restoreFiles({ files, staged }) {
|
|
12608
|
+
await this.git.cwd(this.clonePath);
|
|
12609
|
+
const args = ["restore"];
|
|
12610
|
+
if (staged) {
|
|
12611
|
+
args.push("--staged");
|
|
12612
|
+
}
|
|
12613
|
+
await this.git.raw([...args, ...Array.isArray(files) ? files : [files]]);
|
|
12614
|
+
}
|
|
12600
12615
|
async commit(message) {
|
|
12601
12616
|
await this.git.cwd(this.clonePath);
|
|
12602
|
-
await this.git.commit(message ?? `Automated commit
|
|
12617
|
+
await this.git.commit(message ?? `Automated commit`, void 0, {
|
|
12618
|
+
"--allow-empty": null
|
|
12619
|
+
});
|
|
12603
12620
|
}
|
|
12604
12621
|
async checkout(branch) {
|
|
12605
12622
|
await this.git.cwd(this.clonePath);
|
|
@@ -12623,13 +12640,13 @@ var ClonedRepository = class {
|
|
|
12623
12640
|
(0, import_promises5.readdir)(sourceDirectoryPath),
|
|
12624
12641
|
(0, import_promises5.readdir)(this.clonePath)
|
|
12625
12642
|
]);
|
|
12626
|
-
await Promise.all(destContents.filter((content) => content
|
|
12643
|
+
await Promise.all(destContents.filter((content) => !DEFAULT_IGNORED_FILES.includes(content)).map(async (content) => {
|
|
12627
12644
|
await (0, import_promises5.rm)((0, import_path6.resolve)(this.clonePath, content), {
|
|
12628
12645
|
recursive: true,
|
|
12629
12646
|
force: true
|
|
12630
12647
|
});
|
|
12631
12648
|
}));
|
|
12632
|
-
await Promise.all(sourceContents.filter((content) => content
|
|
12649
|
+
await Promise.all(sourceContents.filter((content) => !DEFAULT_IGNORED_FILES.includes(content)).map(async (content) => {
|
|
12633
12650
|
const path4 = (0, import_path6.resolve)(sourceDirectoryPath, content);
|
|
12634
12651
|
await (0, import_promises5.cp)(path4, (0, import_path6.resolve)(this.clonePath, content), { recursive: true });
|
|
12635
12652
|
}));
|
|
@@ -12653,7 +12670,7 @@ async function doesPathExist2(filepath) {
|
|
|
12653
12670
|
|
|
12654
12671
|
// ../commons/github/dist/parseRepository.js
|
|
12655
12672
|
function parseRepository(githubRepository) {
|
|
12656
|
-
|
|
12673
|
+
let remote = DEFAULT_REMOTE;
|
|
12657
12674
|
let owner;
|
|
12658
12675
|
let repo;
|
|
12659
12676
|
if (githubRepository.startsWith("https://")) {
|
|
@@ -12665,8 +12682,8 @@ function parseRepository(githubRepository) {
|
|
|
12665
12682
|
const parts = githubRepository.split("/");
|
|
12666
12683
|
if (parts.length === 2 && parts[0] != null && parts[1] != null) {
|
|
12667
12684
|
[owner, repo] = parts;
|
|
12668
|
-
} else if (parts.length === 3 && parts[0]
|
|
12669
|
-
[, owner, repo] = parts;
|
|
12685
|
+
} else if (parts.length === 3 && parts[0] != null && parts[1] != null && parts[2] != null) {
|
|
12686
|
+
[remote, owner, repo] = parts;
|
|
12670
12687
|
} else {
|
|
12671
12688
|
throw new Error(`Failed to parse GitHub repostiory ${githubRepository}`);
|
|
12672
12689
|
}
|
|
@@ -12726,12 +12743,14 @@ var GitHub = class {
|
|
|
12726
12743
|
const branch = this.githubConfig.branch ?? await repository.getDefaultBranch();
|
|
12727
12744
|
await repository.checkout(branch);
|
|
12728
12745
|
await repository.pull(branch);
|
|
12746
|
+
const fernIgnore = await repository.getFernignore();
|
|
12729
12747
|
await repository.overwriteLocalContents(sourceDirectory);
|
|
12730
12748
|
await repository.add(".");
|
|
12731
|
-
await
|
|
12749
|
+
await this.restoreFernignoreFiles(repository, fernIgnore);
|
|
12750
|
+
await repository.commit("SDK Generation");
|
|
12732
12751
|
await repository.push();
|
|
12733
12752
|
} catch (error) {
|
|
12734
|
-
console.error(error);
|
|
12753
|
+
console.error("Error during GitHub push:", error);
|
|
12735
12754
|
throw error;
|
|
12736
12755
|
}
|
|
12737
12756
|
}
|
|
@@ -12741,6 +12760,25 @@ var GitHub = class {
|
|
|
12741
12760
|
async release() {
|
|
12742
12761
|
console.log("TODO: Implement release");
|
|
12743
12762
|
}
|
|
12763
|
+
getFernignoreFiles(fernignore) {
|
|
12764
|
+
const fernignoreLines = fernignore.split("\n");
|
|
12765
|
+
const fernignoreFiles = [];
|
|
12766
|
+
for (const line of fernignoreLines) {
|
|
12767
|
+
const trimmedLine = line.trim();
|
|
12768
|
+
if (!trimmedLine.startsWith("#") && trimmedLine.length > 0) {
|
|
12769
|
+
fernignoreFiles.push(trimmedLine);
|
|
12770
|
+
}
|
|
12771
|
+
}
|
|
12772
|
+
return fernignoreFiles;
|
|
12773
|
+
}
|
|
12774
|
+
async restoreFernignoreFiles(repository, fernignore) {
|
|
12775
|
+
if (fernignore === void 0) {
|
|
12776
|
+
return;
|
|
12777
|
+
}
|
|
12778
|
+
const files = this.getFernignoreFiles(fernignore);
|
|
12779
|
+
await repository.restoreFiles({ files, staged: true });
|
|
12780
|
+
await repository.restoreFiles({ files });
|
|
12781
|
+
}
|
|
12744
12782
|
};
|
|
12745
12783
|
|
|
12746
12784
|
// src/readme/ReadmeGenerator.ts
|