@fern-api/generator-cli 0.9.53 → 0.9.55
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 +1 -1
- package/dist/cli.js +90 -15
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -10834,7 +10834,7 @@ var ReadmeGenerator = class {
|
|
|
10834
10834
|
})
|
|
10835
10835
|
);
|
|
10836
10836
|
}
|
|
10837
|
-
if (this.readmeConfig.requirements != null) {
|
|
10837
|
+
if (this.readmeConfig.requirements != null && this.readmeConfig.requirements.length > 0) {
|
|
10838
10838
|
blocks.push(
|
|
10839
10839
|
await this.generateRequirements({
|
|
10840
10840
|
requirements: this.readmeConfig.requirements
|
package/dist/cli.js
CHANGED
|
@@ -30446,6 +30446,9 @@ function extractErrorMessage(e) {
|
|
|
30446
30446
|
return stringified.length > 0 ? stringified : "Unknown error";
|
|
30447
30447
|
}
|
|
30448
30448
|
|
|
30449
|
+
// ../commons/core-utils/lib/fernEnvVars.js
|
|
30450
|
+
var FERN_JAVA_SKIP_FORMATTING_ENV_VAR = "FERN_JAVA_SKIP_FORMATTING";
|
|
30451
|
+
|
|
30449
30452
|
// ../commons/path-utils/lib/convertToOsPath.js
|
|
30450
30453
|
function convertToOsPath(path5) {
|
|
30451
30454
|
return path5.replace(/\\/g, "/");
|
|
@@ -39242,7 +39245,7 @@ var ReadmeGenerator = class {
|
|
|
39242
39245
|
})
|
|
39243
39246
|
);
|
|
39244
39247
|
}
|
|
39245
|
-
if (this.readmeConfig.requirements != null) {
|
|
39248
|
+
if (this.readmeConfig.requirements != null && this.readmeConfig.requirements.length > 0) {
|
|
39246
39249
|
blocks.push(
|
|
39247
39250
|
await this.generateRequirements({
|
|
39248
39251
|
requirements: this.readmeConfig.requirements
|
|
@@ -41843,11 +41846,20 @@ var SEMVER_PATTERN = /^(v)?(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/;
|
|
|
41843
41846
|
function isValidSemver(version2) {
|
|
41844
41847
|
return SEMVER_PATTERN.test(version2);
|
|
41845
41848
|
}
|
|
41849
|
+
function isPlaceholderVersion(version2) {
|
|
41850
|
+
const withoutPrefix = version2.startsWith("v") ? version2.slice(1) : version2;
|
|
41851
|
+
return withoutPrefix === MAGIC_VERSION || withoutPrefix.startsWith(`${MAGIC_VERSION}.`) || withoutPrefix === MAGIC_VERSION_PYTHON || withoutPrefix.startsWith(`${MAGIC_VERSION_PYTHON}.`);
|
|
41852
|
+
}
|
|
41846
41853
|
function incrementVersion(currentVersion, versionBump) {
|
|
41847
41854
|
const matcher = currentVersion.match(SEMVER_PATTERN);
|
|
41848
41855
|
if (!matcher) {
|
|
41849
41856
|
throw new AutoVersioningException("Invalid semantic version format: " + currentVersion);
|
|
41850
41857
|
}
|
|
41858
|
+
if (isPlaceholderVersion(currentVersion)) {
|
|
41859
|
+
throw new AutoVersioningException(
|
|
41860
|
+
"Refusing to increment the magic placeholder version: " + currentVersion + ". A real previous version must be resolved first."
|
|
41861
|
+
);
|
|
41862
|
+
}
|
|
41851
41863
|
const prefix = matcher[1] ?? "";
|
|
41852
41864
|
const versionWithoutPrefix = currentVersion.slice(prefix.length);
|
|
41853
41865
|
const preRelease = matcher[5];
|
|
@@ -41918,7 +41930,8 @@ var AutoVersionStep = class extends BaseStep {
|
|
|
41918
41930
|
}
|
|
41919
41931
|
async handleFirstGeneration(params) {
|
|
41920
41932
|
const { service, language, mappedMagicVersion, commit } = params;
|
|
41921
|
-
const
|
|
41933
|
+
const configuredBaseVersion = this.usableVersion(this.config.baseVersion, "baseVersion");
|
|
41934
|
+
const initialVersion = configuredBaseVersion ?? (mappedMagicVersion.startsWith("v") ? "v0.0.1" : "0.0.1");
|
|
41922
41935
|
if (!isValidSemver(initialVersion)) {
|
|
41923
41936
|
const errorMessage = `AutoVersionStep: baseVersion ${JSON.stringify(initialVersion)} is not a valid semver string (expected e.g. "1.2.3" or "v1.2.3"). Refusing to run.`;
|
|
41924
41937
|
this.logger.error(errorMessage);
|
|
@@ -42252,14 +42265,18 @@ var AutoVersionStep = class extends BaseStep {
|
|
|
42252
42265
|
*/
|
|
42253
42266
|
async resolvePreviousVersionNonReplay(params) {
|
|
42254
42267
|
const { service, rawDiff, mappedMagicVersion, baseVersion } = params;
|
|
42255
|
-
|
|
42268
|
+
const usableBaseVersion = this.usableVersion(baseVersion, "baseVersion");
|
|
42269
|
+
if (usableBaseVersion != null && isValidSemver(usableBaseVersion)) {
|
|
42256
42270
|
this.logger.debug(
|
|
42257
|
-
`AutoVersionStep (non-replay): previous version from pipeline baseVersion: ${
|
|
42271
|
+
`AutoVersionStep (non-replay): previous version from pipeline baseVersion: ${usableBaseVersion}`
|
|
42258
42272
|
);
|
|
42259
|
-
return this.normalizeVersionPrefix(
|
|
42273
|
+
return this.normalizeVersionPrefix(usableBaseVersion, mappedMagicVersion);
|
|
42260
42274
|
}
|
|
42261
42275
|
try {
|
|
42262
|
-
const extracted =
|
|
42276
|
+
const extracted = this.usableVersion(
|
|
42277
|
+
service.extractPreviousVersion(rawDiff, mappedMagicVersion) ?? void 0,
|
|
42278
|
+
"diff"
|
|
42279
|
+
);
|
|
42263
42280
|
if (extracted != null) {
|
|
42264
42281
|
this.logger.debug(`AutoVersionStep (non-replay): previous version from diff: ${extracted}`);
|
|
42265
42282
|
return extracted;
|
|
@@ -42270,12 +42287,15 @@ var AutoVersionStep = class extends BaseStep {
|
|
|
42270
42287
|
}
|
|
42271
42288
|
this.logger.info("AutoVersionStep (non-replay): magic version not in diff; trying metadata + git tags.");
|
|
42272
42289
|
}
|
|
42273
|
-
const metadataVersion = this.readVersionFromMetadataAtHead();
|
|
42290
|
+
const metadataVersion = this.usableVersion(this.readVersionFromMetadataAtHead(), "metadata.json");
|
|
42274
42291
|
if (metadataVersion != null) {
|
|
42275
42292
|
return this.normalizeVersionPrefix(metadataVersion, mappedMagicVersion);
|
|
42276
42293
|
}
|
|
42277
42294
|
try {
|
|
42278
|
-
const tagVersion =
|
|
42295
|
+
const tagVersion = this.usableVersion(
|
|
42296
|
+
await service.getLatestVersionFromGitTags(this.outputDir) ?? void 0,
|
|
42297
|
+
"git tags"
|
|
42298
|
+
);
|
|
42279
42299
|
if (tagVersion != null) {
|
|
42280
42300
|
return this.normalizeVersionPrefix(tagVersion, mappedMagicVersion);
|
|
42281
42301
|
}
|
|
@@ -42286,12 +42306,16 @@ var AutoVersionStep = class extends BaseStep {
|
|
|
42286
42306
|
}
|
|
42287
42307
|
async resolvePreviousVersion(params) {
|
|
42288
42308
|
const { service, rawDiff, mappedMagicVersion, baseVersion } = params;
|
|
42289
|
-
|
|
42290
|
-
|
|
42291
|
-
|
|
42309
|
+
const usableBaseVersion = this.usableVersion(baseVersion, "baseVersion");
|
|
42310
|
+
if (usableBaseVersion != null && isValidSemver(usableBaseVersion)) {
|
|
42311
|
+
this.logger.debug(`AutoVersionStep: previous version from pipeline baseVersion: ${usableBaseVersion}`);
|
|
42312
|
+
return this.normalizeVersionPrefix(usableBaseVersion, mappedMagicVersion);
|
|
42292
42313
|
}
|
|
42293
42314
|
try {
|
|
42294
|
-
const extracted =
|
|
42315
|
+
const extracted = this.usableVersion(
|
|
42316
|
+
service.extractPreviousVersion(rawDiff, mappedMagicVersion) ?? void 0,
|
|
42317
|
+
"diff"
|
|
42318
|
+
);
|
|
42295
42319
|
if (extracted != null) {
|
|
42296
42320
|
this.logger.debug(`AutoVersionStep: previous version from diff: ${extracted}`);
|
|
42297
42321
|
return extracted;
|
|
@@ -42302,12 +42326,15 @@ var AutoVersionStep = class extends BaseStep {
|
|
|
42302
42326
|
}
|
|
42303
42327
|
this.logger.info("AutoVersionStep: magic version not found in diff; falling back to metadata + git tags.");
|
|
42304
42328
|
}
|
|
42305
|
-
const metadataVersion = await this.readVersionFromMetadata();
|
|
42329
|
+
const metadataVersion = this.usableVersion(await this.readVersionFromMetadata(), "metadata.json");
|
|
42306
42330
|
if (metadataVersion != null) {
|
|
42307
42331
|
return this.normalizeVersionPrefix(metadataVersion, mappedMagicVersion);
|
|
42308
42332
|
}
|
|
42309
42333
|
try {
|
|
42310
|
-
const tagVersion =
|
|
42334
|
+
const tagVersion = this.usableVersion(
|
|
42335
|
+
await service.getLatestVersionFromGitTags(this.outputDir) ?? void 0,
|
|
42336
|
+
"git tags"
|
|
42337
|
+
);
|
|
42311
42338
|
if (tagVersion != null) {
|
|
42312
42339
|
return this.normalizeVersionPrefix(tagVersion, mappedMagicVersion);
|
|
42313
42340
|
}
|
|
@@ -42329,6 +42356,27 @@ var AutoVersionStep = class extends BaseStep {
|
|
|
42329
42356
|
return void 0;
|
|
42330
42357
|
}
|
|
42331
42358
|
}
|
|
42359
|
+
/**
|
|
42360
|
+
* Drops candidate previous versions that are the magic placeholder. SDK repos
|
|
42361
|
+
* that derive their published version at release time keep the placeholder
|
|
42362
|
+
* committed, so every resolution source (baseVersion, diff extraction,
|
|
42363
|
+
* metadata.json, git tags) can hand back the sentinel; incrementing it would
|
|
42364
|
+
* emit a mutated placeholder such as `0.0.0-fern-placeholder.0` instead of a
|
|
42365
|
+
* real version. Returning undefined lets the caller fall through to the next
|
|
42366
|
+
* source, and ultimately to the first-generation path.
|
|
42367
|
+
*/
|
|
42368
|
+
usableVersion(version2, source) {
|
|
42369
|
+
if (version2 == null) {
|
|
42370
|
+
return void 0;
|
|
42371
|
+
}
|
|
42372
|
+
if (isPlaceholderVersion(version2)) {
|
|
42373
|
+
this.logger.info(
|
|
42374
|
+
`AutoVersionStep: ignoring placeholder version ${version2} from ${source}; trying the next previous-version source.`
|
|
42375
|
+
);
|
|
42376
|
+
return void 0;
|
|
42377
|
+
}
|
|
42378
|
+
return version2;
|
|
42379
|
+
}
|
|
42332
42380
|
normalizeVersionPrefix(version2, mappedMagicVersion) {
|
|
42333
42381
|
const stripped = version2.startsWith("v") ? version2.slice(1) : version2;
|
|
42334
42382
|
return mappedMagicVersion.startsWith("v") ? `v${stripped}` : stripped;
|
|
@@ -43840,6 +43888,28 @@ var ReplayStep = class extends BaseStep {
|
|
|
43840
43888
|
// ../cli/generation/local-generation/docker-utils/lib/runDocker.js
|
|
43841
43889
|
var import_promises18 = require("fs/promises");
|
|
43842
43890
|
var import_tmp_promise3 = __toESM(require_tmp_promise(), 1);
|
|
43891
|
+
|
|
43892
|
+
// ../cli/generation/local-generation/docker-utils/lib/buildContainerEnvVars.js
|
|
43893
|
+
var FORWARDED_ENV_VARS = ["FERN_STACK_TRACK", FERN_JAVA_SKIP_FORMATTING_ENV_VAR];
|
|
43894
|
+
function buildContainerEnvVars({ envVars, processEnv }) {
|
|
43895
|
+
const forwardedEntries = FORWARDED_ENV_VARS.filter((name) => envVars[name] == null).map((name) => [name, processEnv[name]]).filter((entry) => entry[1] != null && entry[1] !== "");
|
|
43896
|
+
return {
|
|
43897
|
+
envVars: { ...Object.fromEntries(forwardedEntries), ...envVars },
|
|
43898
|
+
forwardedFromHost: forwardedEntries.map(([name]) => name)
|
|
43899
|
+
};
|
|
43900
|
+
}
|
|
43901
|
+
|
|
43902
|
+
// ../cli/generation/local-generation/docker-utils/lib/runDocker.js
|
|
43903
|
+
function logForwardedEnvVars({ logger, containerEnvVars, forwardedFromHost }) {
|
|
43904
|
+
for (const name of forwardedFromHost) {
|
|
43905
|
+
logger.info(`Forwarding ${name}=${containerEnvVars[name]} into the generator container`);
|
|
43906
|
+
}
|
|
43907
|
+
for (const name of FORWARDED_ENV_VARS) {
|
|
43908
|
+
if (!forwardedFromHost.includes(name) && containerEnvVars[name] == null) {
|
|
43909
|
+
logger.debug(`${name} is not set on the host; not forwarding it into the generator container`);
|
|
43910
|
+
}
|
|
43911
|
+
}
|
|
43912
|
+
}
|
|
43843
43913
|
async function pullImage(imageName, runner, signal) {
|
|
43844
43914
|
await loggingExeca(void 0, runner ?? "docker", ["pull", imageName], {
|
|
43845
43915
|
all: true,
|
|
@@ -43877,7 +43947,12 @@ ${stderr}`);
|
|
|
43877
43947
|
}
|
|
43878
43948
|
async function execInContainer({ logger, containerId, command, runner, envVars = {}, writeLogsToFile = true, reject = true }) {
|
|
43879
43949
|
const containerRunner = runner ?? "docker";
|
|
43880
|
-
const
|
|
43950
|
+
const { envVars: containerEnvVars, forwardedFromHost } = buildContainerEnvVars({
|
|
43951
|
+
envVars,
|
|
43952
|
+
processEnv: process.env
|
|
43953
|
+
});
|
|
43954
|
+
logForwardedEnvVars({ logger, containerEnvVars, forwardedFromHost });
|
|
43955
|
+
const envArgs = Object.entries(containerEnvVars).flatMap(([key, value]) => ["-e", `${key}=${value}`]);
|
|
43881
43956
|
const { stdout, stderr, exitCode } = await loggingExeca(logger, containerRunner, ["exec", "--user", "root", ...envArgs, containerId, ...command], {
|
|
43882
43957
|
reject: false,
|
|
43883
43958
|
all: true,
|