@fern-api/generator-cli 0.0.23 → 0.0.24
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 +44 -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,24 @@ 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`);
|
|
12603
12618
|
}
|
|
12604
12619
|
async checkout(branch) {
|
|
12605
12620
|
await this.git.cwd(this.clonePath);
|
|
@@ -12623,13 +12638,13 @@ var ClonedRepository = class {
|
|
|
12623
12638
|
(0, import_promises5.readdir)(sourceDirectoryPath),
|
|
12624
12639
|
(0, import_promises5.readdir)(this.clonePath)
|
|
12625
12640
|
]);
|
|
12626
|
-
await Promise.all(destContents.filter((content) => content
|
|
12641
|
+
await Promise.all(destContents.filter((content) => !DEFAULT_IGNORED_FILES.includes(content)).map(async (content) => {
|
|
12627
12642
|
await (0, import_promises5.rm)((0, import_path6.resolve)(this.clonePath, content), {
|
|
12628
12643
|
recursive: true,
|
|
12629
12644
|
force: true
|
|
12630
12645
|
});
|
|
12631
12646
|
}));
|
|
12632
|
-
await Promise.all(sourceContents.filter((content) => content
|
|
12647
|
+
await Promise.all(sourceContents.filter((content) => !DEFAULT_IGNORED_FILES.includes(content)).map(async (content) => {
|
|
12633
12648
|
const path4 = (0, import_path6.resolve)(sourceDirectoryPath, content);
|
|
12634
12649
|
await (0, import_promises5.cp)(path4, (0, import_path6.resolve)(this.clonePath, content), { recursive: true });
|
|
12635
12650
|
}));
|
|
@@ -12653,7 +12668,7 @@ async function doesPathExist2(filepath) {
|
|
|
12653
12668
|
|
|
12654
12669
|
// ../commons/github/dist/parseRepository.js
|
|
12655
12670
|
function parseRepository(githubRepository) {
|
|
12656
|
-
|
|
12671
|
+
let remote = DEFAULT_REMOTE;
|
|
12657
12672
|
let owner;
|
|
12658
12673
|
let repo;
|
|
12659
12674
|
if (githubRepository.startsWith("https://")) {
|
|
@@ -12665,8 +12680,8 @@ function parseRepository(githubRepository) {
|
|
|
12665
12680
|
const parts = githubRepository.split("/");
|
|
12666
12681
|
if (parts.length === 2 && parts[0] != null && parts[1] != null) {
|
|
12667
12682
|
[owner, repo] = parts;
|
|
12668
|
-
} else if (parts.length === 3 && parts[0]
|
|
12669
|
-
[, owner, repo] = parts;
|
|
12683
|
+
} else if (parts.length === 3 && parts[0] != null && parts[1] != null && parts[2] != null) {
|
|
12684
|
+
[remote, owner, repo] = parts;
|
|
12670
12685
|
} else {
|
|
12671
12686
|
throw new Error(`Failed to parse GitHub repostiory ${githubRepository}`);
|
|
12672
12687
|
}
|
|
@@ -12726,12 +12741,14 @@ var GitHub = class {
|
|
|
12726
12741
|
const branch = this.githubConfig.branch ?? await repository.getDefaultBranch();
|
|
12727
12742
|
await repository.checkout(branch);
|
|
12728
12743
|
await repository.pull(branch);
|
|
12744
|
+
const fernIgnore = await repository.getFernignore();
|
|
12729
12745
|
await repository.overwriteLocalContents(sourceDirectory);
|
|
12730
12746
|
await repository.add(".");
|
|
12731
|
-
await
|
|
12747
|
+
await this.restoreFernignoreFiles(repository, fernIgnore);
|
|
12748
|
+
await repository.commit("SDK Generation");
|
|
12732
12749
|
await repository.push();
|
|
12733
12750
|
} catch (error) {
|
|
12734
|
-
console.error(error);
|
|
12751
|
+
console.error("Error during GitHub push:", error);
|
|
12735
12752
|
throw error;
|
|
12736
12753
|
}
|
|
12737
12754
|
}
|
|
@@ -12741,6 +12758,25 @@ var GitHub = class {
|
|
|
12741
12758
|
async release() {
|
|
12742
12759
|
console.log("TODO: Implement release");
|
|
12743
12760
|
}
|
|
12761
|
+
getFernignoreFiles(fernignore) {
|
|
12762
|
+
const fernignoreLines = fernignore.split("\n");
|
|
12763
|
+
const fernignoreFiles = [];
|
|
12764
|
+
for (const line of fernignoreLines) {
|
|
12765
|
+
const trimmedLine = line.trim();
|
|
12766
|
+
if (!trimmedLine.startsWith("#") && trimmedLine.length > 0) {
|
|
12767
|
+
fernignoreFiles.push(trimmedLine);
|
|
12768
|
+
}
|
|
12769
|
+
}
|
|
12770
|
+
return fernignoreFiles;
|
|
12771
|
+
}
|
|
12772
|
+
async restoreFernignoreFiles(repository, fernignore) {
|
|
12773
|
+
if (fernignore === void 0) {
|
|
12774
|
+
return;
|
|
12775
|
+
}
|
|
12776
|
+
const files = this.getFernignoreFiles(fernignore);
|
|
12777
|
+
await repository.restoreFiles({ files, staged: true });
|
|
12778
|
+
await repository.restoreFiles({ files });
|
|
12779
|
+
}
|
|
12744
12780
|
};
|
|
12745
12781
|
|
|
12746
12782
|
// src/readme/ReadmeGenerator.ts
|