@fern-api/generator-cli 0.1.2 → 0.1.4
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 +19 -34
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -11969,34 +11969,16 @@ var ClonedRepository = class {
|
|
|
11969
11969
|
await this.git.cwd(this.clonePath);
|
|
11970
11970
|
await this.git.add(files);
|
|
11971
11971
|
}
|
|
11972
|
+
async fileExists({ relativeFilePath }) {
|
|
11973
|
+
return await doesPathExist2(import_path6.default.join(this.clonePath, relativeFilePath));
|
|
11974
|
+
}
|
|
11972
11975
|
async restoreFiles({ files, staged }) {
|
|
11973
11976
|
await this.git.cwd(this.clonePath);
|
|
11974
|
-
const
|
|
11975
|
-
|
|
11976
|
-
|
|
11977
|
-
try {
|
|
11978
|
-
const status = await this.git.raw([
|
|
11979
|
-
"ls-files",
|
|
11980
|
-
"--error-unmatch",
|
|
11981
|
-
file
|
|
11982
|
-
]);
|
|
11983
|
-
if (status.trim()) {
|
|
11984
|
-
existingFiles.push(file);
|
|
11985
|
-
}
|
|
11986
|
-
} catch (error) {
|
|
11987
|
-
if (error?.exitCode === 1) {
|
|
11988
|
-
continue;
|
|
11989
|
-
}
|
|
11990
|
-
throw error;
|
|
11991
|
-
}
|
|
11992
|
-
}
|
|
11993
|
-
if (existingFiles.length > 0) {
|
|
11994
|
-
const args = ["restore"];
|
|
11995
|
-
if (staged) {
|
|
11996
|
-
args.push("--staged");
|
|
11997
|
-
}
|
|
11998
|
-
await this.git.raw([...args, ...existingFiles]);
|
|
11977
|
+
const args = ["restore --source=HEAD"];
|
|
11978
|
+
if (staged) {
|
|
11979
|
+
args.push("--staged");
|
|
11999
11980
|
}
|
|
11981
|
+
await this.git.raw([...args, ...Array.isArray(files) ? files : [files]]);
|
|
12000
11982
|
}
|
|
12001
11983
|
async commit(message) {
|
|
12002
11984
|
await this.git.cwd(this.clonePath);
|
|
@@ -12129,10 +12111,10 @@ var GitHub = class {
|
|
|
12129
12111
|
const branch = this.githubConfig.branch ?? await repository.getDefaultBranch();
|
|
12130
12112
|
await repository.checkout(branch);
|
|
12131
12113
|
await repository.pull(branch);
|
|
12132
|
-
const
|
|
12114
|
+
const fernIgnoreFiles = await this.getFernignoreFiles(repository);
|
|
12133
12115
|
await repository.overwriteLocalContents(sourceDirectory);
|
|
12134
12116
|
await repository.add(".");
|
|
12135
|
-
await this.
|
|
12117
|
+
await this.restoreFiles(repository, fernIgnoreFiles);
|
|
12136
12118
|
await repository.commit("SDK Generation");
|
|
12137
12119
|
await repository.push();
|
|
12138
12120
|
} catch (error) {
|
|
@@ -12155,10 +12137,10 @@ var GitHub = class {
|
|
|
12155
12137
|
await repository.checkout(baseBranch);
|
|
12156
12138
|
await repository.pull(baseBranch);
|
|
12157
12139
|
await repository.checkout(prBranch);
|
|
12158
|
-
const
|
|
12140
|
+
const fernIgnoreFiles = await this.getFernignoreFiles(repository);
|
|
12159
12141
|
await repository.overwriteLocalContents(sourceDirectory);
|
|
12160
12142
|
await repository.add(".");
|
|
12161
|
-
await this.
|
|
12143
|
+
await this.restoreFiles(repository, fernIgnoreFiles);
|
|
12162
12144
|
await repository.commit("SDK Generation");
|
|
12163
12145
|
await repository.push();
|
|
12164
12146
|
const octokit = new import_rest.Octokit({
|
|
@@ -12194,22 +12176,25 @@ var GitHub = class {
|
|
|
12194
12176
|
async release() {
|
|
12195
12177
|
console.log("TODO: Implement release");
|
|
12196
12178
|
}
|
|
12197
|
-
getFernignoreFiles(
|
|
12179
|
+
async getFernignoreFiles(repository) {
|
|
12180
|
+
const fernignore = await repository.getFernignore();
|
|
12181
|
+
if (fernignore === void 0) {
|
|
12182
|
+
return [];
|
|
12183
|
+
}
|
|
12198
12184
|
const fernignoreLines = fernignore.split("\n");
|
|
12199
12185
|
const fernignoreFiles = [];
|
|
12200
12186
|
for (const line of fernignoreLines) {
|
|
12201
12187
|
const trimmedLine = line.trim();
|
|
12202
|
-
if (!trimmedLine.startsWith("#") && trimmedLine.length > 0) {
|
|
12188
|
+
if (!trimmedLine.startsWith("#") && trimmedLine.length > 0 && await repository.fileExists({ relativeFilePath: trimmedLine })) {
|
|
12203
12189
|
fernignoreFiles.push(trimmedLine);
|
|
12204
12190
|
}
|
|
12205
12191
|
}
|
|
12206
12192
|
return fernignoreFiles;
|
|
12207
12193
|
}
|
|
12208
|
-
async
|
|
12209
|
-
if (
|
|
12194
|
+
async restoreFiles(repository, files) {
|
|
12195
|
+
if (files.length === 0) {
|
|
12210
12196
|
return;
|
|
12211
12197
|
}
|
|
12212
|
-
const files = this.getFernignoreFiles(fernignore);
|
|
12213
12198
|
await repository.restoreFiles({ files, staged: true });
|
|
12214
12199
|
await repository.restoreFiles({ files });
|
|
12215
12200
|
}
|