@fern-api/generator-cli 0.12.0 → 0.12.1
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.js +10 -3
- package/dist/cli.js +36 -15
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -6303,12 +6303,18 @@ function newRepositoryReference({ remote, owner, repo }) {
|
|
|
6303
6303
|
repoUrl,
|
|
6304
6304
|
cloneUrl,
|
|
6305
6305
|
getAuthedCloneUrl: (installationToken) => {
|
|
6306
|
-
const
|
|
6307
|
-
const userPrefix = isInstallationToken ? "x-access-token:" : "";
|
|
6306
|
+
const userPrefix = isGithubAppToken(installationToken) ? "x-access-token:" : "";
|
|
6308
6307
|
return cloneUrl.replace("https://", `https://${userPrefix}${installationToken}@`);
|
|
6309
6308
|
}
|
|
6310
6309
|
};
|
|
6311
6310
|
}
|
|
6311
|
+
function getGitAuthorizationHeader(installationToken) {
|
|
6312
|
+
const credentials = isGithubAppToken(installationToken) ? `x-access-token:${installationToken}` : `${installationToken}:`;
|
|
6313
|
+
return `Authorization: Basic ${Buffer.from(credentials).toString("base64")}`;
|
|
6314
|
+
}
|
|
6315
|
+
function isGithubAppToken(token) {
|
|
6316
|
+
return token.startsWith("ghs_") || token.startsWith("ghu_");
|
|
6317
|
+
}
|
|
6312
6318
|
function getRepoUrl({ remote, owner, repo }) {
|
|
6313
6319
|
return `https://${remote}/${owner}/${repo}`;
|
|
6314
6320
|
}
|
|
@@ -6369,7 +6375,8 @@ async function cloneRepository({ githubRepository, installationToken, targetDire
|
|
|
6369
6375
|
});
|
|
6370
6376
|
const startTime = Date.now();
|
|
6371
6377
|
try {
|
|
6372
|
-
|
|
6378
|
+
const cloneOptions = installationToken != null ? ["--config", `http.extraHeader=${getGitAuthorizationHeader(installationToken)}`] : [];
|
|
6379
|
+
await git.clone(cloneUrl, ".", cloneOptions);
|
|
6373
6380
|
} catch (error) {
|
|
6374
6381
|
const elapsed = Date.now() - startTime;
|
|
6375
6382
|
const errorMessage = extractErrorMessage(error);
|
package/dist/cli.js
CHANGED
|
@@ -7176,18 +7176,18 @@ var require_build3 = __commonJS({
|
|
|
7176
7176
|
var require_sync = __commonJS({
|
|
7177
7177
|
"../../node_modules/.pnpm/escalade@3.2.0/node_modules/escalade/sync/index.js"(exports2, module2) {
|
|
7178
7178
|
"use strict";
|
|
7179
|
-
var { dirname:
|
|
7179
|
+
var { dirname: dirname7, resolve: resolve8 } = require("path");
|
|
7180
7180
|
var { readdirSync: readdirSync2, statSync: statSync4 } = require("fs");
|
|
7181
7181
|
module2.exports = function(start, callback) {
|
|
7182
7182
|
let dir = resolve8(".", start);
|
|
7183
7183
|
let tmp4, stats = statSync4(dir);
|
|
7184
7184
|
if (!stats.isDirectory()) {
|
|
7185
|
-
dir =
|
|
7185
|
+
dir = dirname7(dir);
|
|
7186
7186
|
}
|
|
7187
7187
|
while (true) {
|
|
7188
7188
|
tmp4 = callback(dir, readdirSync2(dir));
|
|
7189
7189
|
if (tmp4) return resolve8(dir, tmp4);
|
|
7190
|
-
dir =
|
|
7190
|
+
dir = dirname7(tmp4 = dir);
|
|
7191
7191
|
if (tmp4 === dir) break;
|
|
7192
7192
|
}
|
|
7193
7193
|
};
|
|
@@ -7225,7 +7225,7 @@ var require_require_directory = __commonJS({
|
|
|
7225
7225
|
var fs3 = require("fs");
|
|
7226
7226
|
var join19 = require("path").join;
|
|
7227
7227
|
var resolve8 = require("path").resolve;
|
|
7228
|
-
var
|
|
7228
|
+
var dirname7 = require("path").dirname;
|
|
7229
7229
|
var defaultOptions2 = {
|
|
7230
7230
|
extensions: ["js", "json", "coffee"],
|
|
7231
7231
|
recurse: true,
|
|
@@ -7258,7 +7258,7 @@ var require_require_directory = __commonJS({
|
|
|
7258
7258
|
options[prop] = defaultOptions2[prop];
|
|
7259
7259
|
}
|
|
7260
7260
|
}
|
|
7261
|
-
path5 = !path5 ?
|
|
7261
|
+
path5 = !path5 ? dirname7(m.filename) : resolve8(dirname7(m.filename), path5);
|
|
7262
7262
|
fs3.readdirSync(path5).forEach(function(filename) {
|
|
7263
7263
|
var joined = join19(path5, filename), files, key, obj;
|
|
7264
7264
|
if (fs3.statSync(joined).isDirectory() && options.recurse) {
|
|
@@ -30515,7 +30515,7 @@ function resolve(...paths) {
|
|
|
30515
30515
|
// src/cli.ts
|
|
30516
30516
|
var import_fs18 = __toESM(require("fs"));
|
|
30517
30517
|
var import_promises19 = require("fs/promises");
|
|
30518
|
-
var
|
|
30518
|
+
var import_path28 = __toESM(require("path"));
|
|
30519
30519
|
|
|
30520
30520
|
// ../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/build/lib/yerror.js
|
|
30521
30521
|
var YError = class _YError extends Error {
|
|
@@ -32530,12 +32530,18 @@ function newRepositoryReference({ remote, owner, repo }) {
|
|
|
32530
32530
|
repoUrl,
|
|
32531
32531
|
cloneUrl,
|
|
32532
32532
|
getAuthedCloneUrl: (installationToken) => {
|
|
32533
|
-
const
|
|
32534
|
-
const userPrefix = isInstallationToken ? "x-access-token:" : "";
|
|
32533
|
+
const userPrefix = isGithubAppToken(installationToken) ? "x-access-token:" : "";
|
|
32535
32534
|
return cloneUrl.replace("https://", `https://${userPrefix}${installationToken}@`);
|
|
32536
32535
|
}
|
|
32537
32536
|
};
|
|
32538
32537
|
}
|
|
32538
|
+
function getGitAuthorizationHeader(installationToken) {
|
|
32539
|
+
const credentials = isGithubAppToken(installationToken) ? `x-access-token:${installationToken}` : `${installationToken}:`;
|
|
32540
|
+
return `Authorization: Basic ${Buffer.from(credentials).toString("base64")}`;
|
|
32541
|
+
}
|
|
32542
|
+
function isGithubAppToken(token) {
|
|
32543
|
+
return token.startsWith("ghs_") || token.startsWith("ghu_");
|
|
32544
|
+
}
|
|
32539
32545
|
function getRepoUrl({ remote, owner, repo }) {
|
|
32540
32546
|
return `https://${remote}/${owner}/${repo}`;
|
|
32541
32547
|
}
|
|
@@ -32596,7 +32602,8 @@ async function cloneRepository({ githubRepository, installationToken, targetDire
|
|
|
32596
32602
|
});
|
|
32597
32603
|
const startTime = Date.now();
|
|
32598
32604
|
try {
|
|
32599
|
-
|
|
32605
|
+
const cloneOptions = installationToken != null ? ["--config", `http.extraHeader=${getGitAuthorizationHeader(installationToken)}`] : [];
|
|
32606
|
+
await git.clone(cloneUrl, ".", cloneOptions);
|
|
32600
32607
|
} catch (error) {
|
|
32601
32608
|
const elapsed = Date.now() - startTime;
|
|
32602
32609
|
const errorMessage = extractErrorMessage(error);
|
|
@@ -44379,6 +44386,7 @@ ${stderr}`);
|
|
|
44379
44386
|
|
|
44380
44387
|
// ../cli/generation/local-generation/docker-utils/lib/runDocker.js
|
|
44381
44388
|
var import_promises18 = require("fs/promises");
|
|
44389
|
+
var import_path26 = require("path");
|
|
44382
44390
|
var import_tmp_promise3 = __toESM(require_tmp_promise(), 1);
|
|
44383
44391
|
|
|
44384
44392
|
// ../cli/generation/local-generation/docker-utils/lib/buildContainerEnvVars.js
|
|
@@ -44454,9 +44462,7 @@ async function execInContainer({ logger, containerId, command, runner, envVars =
|
|
|
44454
44462
|
});
|
|
44455
44463
|
const logs = stdout + stderr;
|
|
44456
44464
|
if (writeLogsToFile) {
|
|
44457
|
-
|
|
44458
|
-
await (0, import_promises18.writeFile)(tmpFile.path, logs);
|
|
44459
|
-
logger.info(`Generator logs here: ${tmpFile.path}`);
|
|
44465
|
+
await writeLogsFile({ logger, logs });
|
|
44460
44466
|
}
|
|
44461
44467
|
const resolvedExitCode = exitCode ?? 1;
|
|
44462
44468
|
if (reject && resolvedExitCode !== 0) {
|
|
@@ -44485,6 +44491,21 @@ async function stopContainer({ logger, containerId, runner }) {
|
|
|
44485
44491
|
doNotPipeOutput: true
|
|
44486
44492
|
});
|
|
44487
44493
|
}
|
|
44494
|
+
async function writeLogsFile({ logger, logs, logFilePath }) {
|
|
44495
|
+
if (logFilePath != null) {
|
|
44496
|
+
try {
|
|
44497
|
+
await (0, import_promises18.mkdir)((0, import_path26.dirname)(logFilePath), { recursive: true });
|
|
44498
|
+
await (0, import_promises18.writeFile)(logFilePath, logs);
|
|
44499
|
+
logger.info(`Generator logs here: ${logFilePath}`);
|
|
44500
|
+
return;
|
|
44501
|
+
} catch (error) {
|
|
44502
|
+
logger.warn(`Failed to write logs to ${logFilePath} (${String(error)}); using a temporary file instead.`);
|
|
44503
|
+
}
|
|
44504
|
+
}
|
|
44505
|
+
const tmpFile = await import_tmp_promise3.default.file();
|
|
44506
|
+
await (0, import_promises18.writeFile)(tmpFile.path, logs);
|
|
44507
|
+
logger.info(`Generator logs here: ${tmpFile.path}`);
|
|
44508
|
+
}
|
|
44488
44509
|
|
|
44489
44510
|
// ../cli/logger/lib/LogLevel.js
|
|
44490
44511
|
var LogLevel2 = {
|
|
@@ -44542,7 +44563,7 @@ function createLogger4(log) {
|
|
|
44542
44563
|
|
|
44543
44564
|
// src/pipeline/steps/VerificationStep.ts
|
|
44544
44565
|
var import_fs17 = require("fs");
|
|
44545
|
-
var
|
|
44566
|
+
var import_path27 = require("path");
|
|
44546
44567
|
var CONTAINER_WORKSPACE_PATH = "/workspace";
|
|
44547
44568
|
var VERIFY_SCRIPT_RELATIVE_PATH = ".fern/verify.sh";
|
|
44548
44569
|
var VERIFY_SCRIPT_CONTAINER_PATH = `${CONTAINER_WORKSPACE_PATH}/${VERIFY_SCRIPT_RELATIVE_PATH}`;
|
|
@@ -44558,7 +44579,7 @@ var VerificationStep = class extends BaseStep {
|
|
|
44558
44579
|
generatorVersions;
|
|
44559
44580
|
name = "verify";
|
|
44560
44581
|
async execute(_context) {
|
|
44561
|
-
const verifyScriptHostPath = (0,
|
|
44582
|
+
const verifyScriptHostPath = (0, import_path27.join)(this.outputDir, VERIFY_SCRIPT_RELATIVE_PATH);
|
|
44562
44583
|
if (!(0, import_fs17.existsSync)(verifyScriptHostPath)) {
|
|
44563
44584
|
return { executed: true, success: true, skipped: true };
|
|
44564
44585
|
}
|
|
@@ -45258,7 +45279,7 @@ async function createWriteStream(outputPath) {
|
|
|
45258
45279
|
}
|
|
45259
45280
|
async function createWriteStreamFromFile(filepath) {
|
|
45260
45281
|
if (!await doesPathExist(filepath)) {
|
|
45261
|
-
await (0, import_promises19.mkdir)(
|
|
45282
|
+
await (0, import_promises19.mkdir)(import_path28.default.dirname(filepath), { recursive: true });
|
|
45262
45283
|
}
|
|
45263
45284
|
return import_fs18.default.createWriteStream(filepath);
|
|
45264
45285
|
}
|