fern-api 0.39.16 → 0.39.17
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/bundle.cjs +465 -467
- package/package.json +1 -1
package/bundle.cjs
CHANGED
|
@@ -1192625,7 +1192625,7 @@ var AccessTokenPosthogManager = class {
|
|
|
1192625
1192625
|
properties: {
|
|
1192626
1192626
|
...event,
|
|
1192627
1192627
|
...event.properties,
|
|
1192628
|
-
version: "0.39.
|
|
1192628
|
+
version: "0.39.17",
|
|
1192629
1192629
|
usingAccessToken: true
|
|
1192630
1192630
|
}
|
|
1192631
1192631
|
});
|
|
@@ -1192687,7 +1192687,7 @@ var UserPosthogManager = class {
|
|
|
1192687
1192687
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
1192688
1192688
|
event: "CLI",
|
|
1192689
1192689
|
properties: {
|
|
1192690
|
-
version: "0.39.
|
|
1192690
|
+
version: "0.39.17",
|
|
1192691
1192691
|
...event,
|
|
1192692
1192692
|
...event.properties
|
|
1192693
1192693
|
}
|
|
@@ -1197750,10 +1197750,10 @@ var CliContext = class {
|
|
|
1197750
1197750
|
return "fern-api";
|
|
1197751
1197751
|
}
|
|
1197752
1197752
|
getPackageVersion() {
|
|
1197753
|
-
if ("0.39.
|
|
1197753
|
+
if ("0.39.17" == null) {
|
|
1197754
1197754
|
this.logger.error("CLI_VERSION is not defined");
|
|
1197755
1197755
|
}
|
|
1197756
|
-
return "0.39.
|
|
1197756
|
+
return "0.39.17";
|
|
1197757
1197757
|
}
|
|
1197758
1197758
|
getCliName() {
|
|
1197759
1197759
|
if ("fern" == null) {
|
|
@@ -1223078,6 +1223078,125 @@ async function getOrganziation({
|
|
|
1223078
1223078
|
}
|
|
1223079
1223079
|
}
|
|
1223080
1223080
|
|
|
1223081
|
+
// src/commands/upgrade/upgradeGenerator.ts
|
|
1223082
|
+
var import_promises32 = require("fs/promises");
|
|
1223083
|
+
var import_path27 = __toESM(require("path"), 1);
|
|
1223084
|
+
var semver3 = __toESM(require_semver2(), 1);
|
|
1223085
|
+
var import_yaml = __toESM(require_dist5(), 1);
|
|
1223086
|
+
async function loadAndUpdateGenerators({
|
|
1223087
|
+
absolutePathToWorkspace,
|
|
1223088
|
+
context,
|
|
1223089
|
+
generatorFilter,
|
|
1223090
|
+
groupFilter,
|
|
1223091
|
+
includeMajor
|
|
1223092
|
+
}) {
|
|
1223093
|
+
const filepath = generators_yml_exports.getPathToGeneratorsConfiguration({ absolutePathToWorkspace });
|
|
1223094
|
+
if (!await doesPathExist(filepath)) {
|
|
1223095
|
+
context.failAndThrow("Generators configuration file was not found, no generators to upgrade.");
|
|
1223096
|
+
return void 0;
|
|
1223097
|
+
}
|
|
1223098
|
+
const contents = await (0, import_promises32.readFile)(filepath);
|
|
1223099
|
+
context.logger.debug(`Found generators: ${contents.toString()}`);
|
|
1223100
|
+
const parsedDocument = import_yaml.default.parseDocument(contents.toString());
|
|
1223101
|
+
const generatorGroups = parsedDocument.get("groups");
|
|
1223102
|
+
if (generatorGroups == null) {
|
|
1223103
|
+
context.failAndThrow("No groups were found within the generators configuration, no generators to upgrade.");
|
|
1223104
|
+
return void 0;
|
|
1223105
|
+
}
|
|
1223106
|
+
if (!import_yaml.default.isMap(generatorGroups)) {
|
|
1223107
|
+
context.failAndThrow(`Expected 'groups' to be a map in ${import_path27.default.relative(process.cwd(), filepath)}`);
|
|
1223108
|
+
return void 0;
|
|
1223109
|
+
}
|
|
1223110
|
+
context.logger.debug(`Groups found: ${generatorGroups.toString()}`);
|
|
1223111
|
+
for (const groupBlock of generatorGroups.items) {
|
|
1223112
|
+
const groupName = groupBlock.key;
|
|
1223113
|
+
const group = groupBlock.value;
|
|
1223114
|
+
if (!import_yaml.default.isMap(group)) {
|
|
1223115
|
+
context.failAndThrow(
|
|
1223116
|
+
`Expected group ${groupName} to be a map in ${import_path27.default.relative(process.cwd(), filepath)}`
|
|
1223117
|
+
);
|
|
1223118
|
+
continue;
|
|
1223119
|
+
}
|
|
1223120
|
+
if (groupFilter != null && group.get("name") !== groupName) {
|
|
1223121
|
+
continue;
|
|
1223122
|
+
}
|
|
1223123
|
+
const generators = group.get("generators");
|
|
1223124
|
+
if (!import_yaml.default.isSeq(generators)) {
|
|
1223125
|
+
context.failAndThrow(
|
|
1223126
|
+
`Expected group ${groupName} to have a 'generators' key in ${import_path27.default.relative(process.cwd(), filepath)}`
|
|
1223127
|
+
);
|
|
1223128
|
+
continue;
|
|
1223129
|
+
}
|
|
1223130
|
+
context.logger.debug(`Generators found: ${generators.toString()}`);
|
|
1223131
|
+
for (const generator of generators.items) {
|
|
1223132
|
+
if (!import_yaml.default.isMap(generator)) {
|
|
1223133
|
+
context.failAndThrow(
|
|
1223134
|
+
`Expected generator in group ${groupName} to be a map in ${import_path27.default.relative(process.cwd(), filepath)}`
|
|
1223135
|
+
);
|
|
1223136
|
+
}
|
|
1223137
|
+
if (generatorFilter != null && generator.get("name") !== generatorFilter) {
|
|
1223138
|
+
continue;
|
|
1223139
|
+
}
|
|
1223140
|
+
const generatorName = generator.get("name");
|
|
1223141
|
+
const normalizedGeneratorName = generators_yml_exports.getGeneratorNameOrThrow(generatorName, context);
|
|
1223142
|
+
const currentVersion = generator.get("version");
|
|
1223143
|
+
const latestVersion2 = await generators_yml_exports.getLatestGeneratorVersion(normalizedGeneratorName, context);
|
|
1223144
|
+
context.logger.debug(`${generatorName}, ${currentVersion}, ${latestVersion2}`);
|
|
1223145
|
+
if (latestVersion2 == null) {
|
|
1223146
|
+
continue;
|
|
1223147
|
+
}
|
|
1223148
|
+
const currentMajor = semver3.major(currentVersion);
|
|
1223149
|
+
const latestMajor = semver3.major(latestVersion2);
|
|
1223150
|
+
if (currentMajor === latestMajor || includeMajor) {
|
|
1223151
|
+
generator.set("version", latestVersion2);
|
|
1223152
|
+
context.logger.info(source_default.green(`${generatorName} has been upgraded to latest in group: ${groupName}`));
|
|
1223153
|
+
}
|
|
1223154
|
+
}
|
|
1223155
|
+
}
|
|
1223156
|
+
return parsedDocument.toString();
|
|
1223157
|
+
}
|
|
1223158
|
+
async function upgradeGenerator2({
|
|
1223159
|
+
cliContext,
|
|
1223160
|
+
generator,
|
|
1223161
|
+
group,
|
|
1223162
|
+
project: { apiWorkspaces },
|
|
1223163
|
+
includeMajor
|
|
1223164
|
+
}) {
|
|
1223165
|
+
await Promise.all(
|
|
1223166
|
+
apiWorkspaces.map(async (workspace) => {
|
|
1223167
|
+
await cliContext.runTaskForWorkspace(workspace, async (context) => {
|
|
1223168
|
+
var _a6;
|
|
1223169
|
+
const generatorsConfiguration = await generators_yml_exports.loadRawGeneratorsConfiguration({
|
|
1223170
|
+
absolutePathToWorkspace: workspace.absoluteFilepath,
|
|
1223171
|
+
context
|
|
1223172
|
+
}) ?? {};
|
|
1223173
|
+
if (generatorsConfiguration == null || generatorsConfiguration.groups == null) {
|
|
1223174
|
+
context.failAndThrow(
|
|
1223175
|
+
"No groups were found within the generators configuration, no generators to upgrade."
|
|
1223176
|
+
);
|
|
1223177
|
+
return;
|
|
1223178
|
+
}
|
|
1223179
|
+
context.logger.info(`Upgrading generators in workspace: ${workspace.workspaceName}`);
|
|
1223180
|
+
const updatedConfiguration = await loadAndUpdateGenerators({
|
|
1223181
|
+
absolutePathToWorkspace: workspace.absoluteFilepath,
|
|
1223182
|
+
context,
|
|
1223183
|
+
generatorFilter: generator,
|
|
1223184
|
+
groupFilter: group,
|
|
1223185
|
+
includeMajor
|
|
1223186
|
+
});
|
|
1223187
|
+
if (updatedConfiguration != null) {
|
|
1223188
|
+
await (0, import_promises32.writeFile)(
|
|
1223189
|
+
((_a6 = workspace.generatorsConfiguration) == null ? void 0 : _a6.absolutePathToConfiguration) ?? generators_yml_exports.getPathToGeneratorsConfiguration({
|
|
1223190
|
+
absolutePathToWorkspace: workspace.absoluteFilepath
|
|
1223191
|
+
}),
|
|
1223192
|
+
updatedConfiguration
|
|
1223193
|
+
);
|
|
1223194
|
+
}
|
|
1223195
|
+
});
|
|
1223196
|
+
})
|
|
1223197
|
+
);
|
|
1223198
|
+
}
|
|
1223199
|
+
|
|
1223081
1223200
|
// src/cliV2.ts
|
|
1223082
1223201
|
function addGetOrganizationCommand(cli, cliContext) {
|
|
1223083
1223202
|
cli.command(
|
|
@@ -1223106,55 +1223225,96 @@ function addGetOrganizationCommand(cli, cliContext) {
|
|
|
1223106
1223225
|
}
|
|
1223107
1223226
|
);
|
|
1223108
1223227
|
}
|
|
1223109
|
-
function
|
|
1223110
|
-
cli.command(
|
|
1223111
|
-
|
|
1223112
|
-
|
|
1223113
|
-
|
|
1223114
|
-
|
|
1223115
|
-
|
|
1223116
|
-
|
|
1223117
|
-
|
|
1223118
|
-
|
|
1223119
|
-
|
|
1223120
|
-
|
|
1223121
|
-
|
|
1223122
|
-
|
|
1223123
|
-
|
|
1223124
|
-
|
|
1223125
|
-
|
|
1223126
|
-
|
|
1223127
|
-
|
|
1223128
|
-
|
|
1223129
|
-
|
|
1223130
|
-
|
|
1223131
|
-
|
|
1223132
|
-
|
|
1223133
|
-
|
|
1223134
|
-
|
|
1223135
|
-
|
|
1223136
|
-
|
|
1223228
|
+
function addGeneratorCommands(cli, cliContext) {
|
|
1223229
|
+
cli.command("generator", "Operate on the generators within your Fern configuration", (yargs) => {
|
|
1223230
|
+
yargs.command(
|
|
1223231
|
+
"list",
|
|
1223232
|
+
false,
|
|
1223233
|
+
(yargs2) => yargs2.option("output", {
|
|
1223234
|
+
string: true,
|
|
1223235
|
+
alias: "o",
|
|
1223236
|
+
description: "The location to output the list as a text file, defaults to standard out."
|
|
1223237
|
+
}).option("generators", {
|
|
1223238
|
+
string: true,
|
|
1223239
|
+
type: "array",
|
|
1223240
|
+
description: "The type of generator to include in the list, ex: `fern-typescript-node-sdk`. If omitted, all generators will be listed."
|
|
1223241
|
+
}).option("groups", {
|
|
1223242
|
+
type: "array",
|
|
1223243
|
+
string: true,
|
|
1223244
|
+
description: "The groups to include generators from, if group is not specified, the all generators of the specified type will be listed."
|
|
1223245
|
+
}).option("apis", {
|
|
1223246
|
+
type: "array",
|
|
1223247
|
+
string: true,
|
|
1223248
|
+
description: "The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."
|
|
1223249
|
+
}).option("api-fallback", {
|
|
1223250
|
+
string: true,
|
|
1223251
|
+
description: "The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."
|
|
1223252
|
+
}),
|
|
1223253
|
+
async (argv) => {
|
|
1223254
|
+
cliContext.instrumentPostHogEvent({
|
|
1223255
|
+
command: "fern generator list",
|
|
1223256
|
+
properties: {
|
|
1223257
|
+
outputLocation: argv.output
|
|
1223258
|
+
}
|
|
1223259
|
+
});
|
|
1223260
|
+
await getGeneratorList({
|
|
1223261
|
+
project: await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
|
|
1223262
|
+
commandLineApiWorkspace: void 0,
|
|
1223263
|
+
defaultToAllApiWorkspaces: true
|
|
1223264
|
+
}),
|
|
1223265
|
+
generatorFilter: argv.generators ? new Set(argv.generators) : void 0,
|
|
1223266
|
+
groupFilter: argv.groups ? new Set(argv.groups) : void 0,
|
|
1223267
|
+
apiFilter: argv.apis ? new Set(argv.apis) : void 0,
|
|
1223268
|
+
apiKeyFallback: argv.apiFallback,
|
|
1223269
|
+
cliContext,
|
|
1223137
1223270
|
outputLocation: argv.output
|
|
1223138
|
-
}
|
|
1223139
|
-
}
|
|
1223140
|
-
|
|
1223141
|
-
|
|
1223142
|
-
|
|
1223143
|
-
|
|
1223144
|
-
|
|
1223145
|
-
|
|
1223146
|
-
|
|
1223147
|
-
|
|
1223148
|
-
|
|
1223149
|
-
|
|
1223150
|
-
|
|
1223151
|
-
|
|
1223152
|
-
|
|
1223153
|
-
|
|
1223271
|
+
});
|
|
1223272
|
+
}
|
|
1223273
|
+
).command(
|
|
1223274
|
+
"upgrade",
|
|
1223275
|
+
`Upgrades the specified generator in ${GENERATORS_CONFIGURATION_FILENAME} to the latest stable version.`,
|
|
1223276
|
+
(yargs2) => yargs2.option("generator", {
|
|
1223277
|
+
string: true,
|
|
1223278
|
+
description: "The type of generator to upgrade, ex: `fern-typescript-node-sdk`."
|
|
1223279
|
+
}).option("group", {
|
|
1223280
|
+
string: true,
|
|
1223281
|
+
description: "The group in which the generator is located, if group is not specified, the all generators of the specified type will be upgraded."
|
|
1223282
|
+
}).option("api", {
|
|
1223283
|
+
string: true,
|
|
1223284
|
+
description: "The API to upgrade the generator for. If not specified, the generator will be upgraded for all APIs."
|
|
1223285
|
+
}).option("include-major", {
|
|
1223286
|
+
boolean: true,
|
|
1223287
|
+
default: false,
|
|
1223288
|
+
description: "Whether or not to include major versions within the upgrade. Defaults to false, meaning major versions will be skipped."
|
|
1223289
|
+
}),
|
|
1223290
|
+
async (argv) => {
|
|
1223291
|
+
cliContext.instrumentPostHogEvent({
|
|
1223292
|
+
command: "fern generator upgrade",
|
|
1223293
|
+
properties: {
|
|
1223294
|
+
generator: argv.generator,
|
|
1223295
|
+
version: argv.version,
|
|
1223296
|
+
api: argv.api,
|
|
1223297
|
+
group: argv.group,
|
|
1223298
|
+
includeMajor: argv.includeMajor
|
|
1223299
|
+
}
|
|
1223300
|
+
});
|
|
1223301
|
+
await upgradeGenerator2({
|
|
1223302
|
+
cliContext,
|
|
1223303
|
+
generator: argv.generator,
|
|
1223304
|
+
group: argv.group,
|
|
1223305
|
+
project: await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
|
|
1223306
|
+
commandLineApiWorkspace: argv.api,
|
|
1223307
|
+
defaultToAllApiWorkspaces: true
|
|
1223308
|
+
}),
|
|
1223309
|
+
includeMajor: argv.includeMajor
|
|
1223310
|
+
});
|
|
1223311
|
+
}
|
|
1223312
|
+
);
|
|
1223313
|
+
});
|
|
1223154
1223314
|
}
|
|
1223155
1223315
|
|
|
1223156
1223316
|
// src/commands/add-generator/addGeneratorToWorkspaces.ts
|
|
1223157
|
-
var
|
|
1223317
|
+
var import_promises33 = require("fs/promises");
|
|
1223158
1223318
|
async function addGeneratorToWorkspaces({
|
|
1223159
1223319
|
project: { apiWorkspaces },
|
|
1223160
1223320
|
generatorName,
|
|
@@ -1223175,7 +1223335,7 @@ async function addGeneratorToWorkspaces({
|
|
|
1223175
1223335
|
groupName,
|
|
1223176
1223336
|
context
|
|
1223177
1223337
|
});
|
|
1223178
|
-
await (0,
|
|
1223338
|
+
await (0, import_promises33.writeFile)(
|
|
1223179
1223339
|
((_a6 = workspace.generatorsConfiguration) == null ? void 0 : _a6.absolutePathToConfiguration) ?? generators_yml_exports.getPathToGeneratorsConfiguration({
|
|
1223180
1223340
|
absolutePathToWorkspace: workspace.absoluteFilepath
|
|
1223181
1223341
|
}),
|
|
@@ -1232597,10 +1232757,10 @@ function visitFrontmatterImages(data2, keys7, mapImage) {
|
|
|
1232597
1232757
|
}
|
|
1232598
1232758
|
|
|
1232599
1232759
|
// ../docs-markdown-utils/lib/replaceReferencedMarkdown.js
|
|
1232600
|
-
var
|
|
1232760
|
+
var import_promises34 = require("fs/promises");
|
|
1232601
1232761
|
var import_gray_matter2 = __toESM(require_gray_matter(), 1);
|
|
1232602
1232762
|
async function defaultMarkdownLoader(filepath) {
|
|
1232603
|
-
const { content: content3 } = (0, import_gray_matter2.default)(await (0,
|
|
1232763
|
+
const { content: content3 } = (0, import_gray_matter2.default)(await (0, import_promises34.readFile)(filepath));
|
|
1232604
1232764
|
return content3;
|
|
1232605
1232765
|
}
|
|
1232606
1232766
|
async function replaceReferencedMarkdown({
|
|
@@ -1232637,9 +1232797,9 @@ async function replaceReferencedMarkdown({
|
|
|
1232637
1232797
|
}
|
|
1232638
1232798
|
|
|
1232639
1232799
|
// ../docs-markdown-utils/lib/replaceReferencedCode.js
|
|
1232640
|
-
var
|
|
1232800
|
+
var import_promises35 = require("fs/promises");
|
|
1232641
1232801
|
async function defaultFileLoader(filepath) {
|
|
1232642
|
-
const file = await (0,
|
|
1232802
|
+
const file = await (0, import_promises35.readFile)(filepath);
|
|
1232643
1232803
|
return file.toString();
|
|
1232644
1232804
|
}
|
|
1232645
1232805
|
async function replaceReferencedCode({
|
|
@@ -1237724,12 +1237884,12 @@ function stringifyFernFilepath(fernFilepath) {
|
|
|
1237724
1237884
|
}
|
|
1237725
1237885
|
|
|
1237726
1237886
|
// ../generation/ir-generator/lib/utils/convertToFernFilepath.js
|
|
1237727
|
-
var
|
|
1237887
|
+
var import_path28 = __toESM(require("path"), 1);
|
|
1237728
1237888
|
function convertToFernFilepath({ relativeFilepath, casingsGenerator }) {
|
|
1237729
1237889
|
const pathToPackage = dirname(relativeFilepath);
|
|
1237730
|
-
const filename = (0,
|
|
1237731
|
-
const packagePath = pathToPackage === "." ? [] : pathToPackage.split(
|
|
1237732
|
-
const file = filename !== FERN_PACKAGE_MARKER_FILENAME ? casingsGenerator.generateName(
|
|
1237890
|
+
const filename = (0, import_path28.basename)(relativeFilepath);
|
|
1237891
|
+
const packagePath = pathToPackage === "." ? [] : pathToPackage.split(import_path28.default.sep).map((part) => casingsGenerator.generateName(part));
|
|
1237892
|
+
const file = filename !== FERN_PACKAGE_MARKER_FILENAME ? casingsGenerator.generateName(import_path28.default.parse(filename).name) : void 0;
|
|
1237733
1237893
|
const allParts = [];
|
|
1237734
1237894
|
allParts.push(...packagePath);
|
|
1237735
1237895
|
if (file != null) {
|
|
@@ -1239674,7 +1239834,7 @@ function convertObject4({ typeName, rawObject, example, fileContainingType, file
|
|
|
1239674
1239834
|
throw new Error(`Example is not an object. Got: ${JSON.stringify(example)}`);
|
|
1239675
1239835
|
}
|
|
1239676
1239836
|
return ExampleTypeShape.object({
|
|
1239677
|
-
properties: rawObject.properties != null ? Object.entries(example).reduce((exampleProperties, [wireKey, propertyExample]) => {
|
|
1239837
|
+
properties: rawObject.properties != null || rawObject.extends != null ? Object.entries(example).reduce((exampleProperties, [wireKey, propertyExample]) => {
|
|
1239678
1239838
|
const originalTypeDeclaration = getOriginalTypeDeclarationForProperty({
|
|
1239679
1239839
|
typeName,
|
|
1239680
1239840
|
wirePropertyKey: wireKey,
|
|
@@ -1244298,10 +1244458,10 @@ var PropertyResolverImpl = class {
|
|
|
1244298
1244458
|
};
|
|
1244299
1244459
|
|
|
1244300
1244460
|
// ../generation/ir-generator/lib/parsers/ProtobufParser.js
|
|
1244301
|
-
var
|
|
1244461
|
+
var import_promises36 = require("fs/promises");
|
|
1244302
1244462
|
var ProtobufParser = class {
|
|
1244303
1244463
|
async parse({ absoluteFilePath }) {
|
|
1244304
|
-
const content3 = await (0,
|
|
1244464
|
+
const content3 = await (0, import_promises36.readFile)(absoluteFilePath, "utf-8");
|
|
1244305
1244465
|
const csharpNamespaceMatch = content3.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/);
|
|
1244306
1244466
|
const packageNameMatch = content3.match(/package\s+([a-zA-Z_][\w.]*);/);
|
|
1244307
1244467
|
const serviceNameMatch = content3.match(/service\s+([a-zA-Z_]\w*)\s*{/);
|
|
@@ -1245096,7 +1245256,7 @@ function filterServiceTypeReferenceInfoForAudiences(serviceTypeReferenceInfo, fi
|
|
|
1245096
1245256
|
// ../docs-resolver/lib/DocsDefinitionResolver.js
|
|
1245097
1245257
|
var import_dayjs3 = __toESM(require_dayjs_min(), 1);
|
|
1245098
1245258
|
var import_utc3 = __toESM(require_utc(), 1);
|
|
1245099
|
-
var
|
|
1245259
|
+
var import_promises37 = require("fs/promises");
|
|
1245100
1245260
|
var import_gray_matter3 = __toESM(require_gray_matter(), 1);
|
|
1245101
1245261
|
|
|
1245102
1245262
|
// ../docs-resolver/lib/utils/isSubpackage.js
|
|
@@ -1247303,7 +1247463,7 @@ var DocsDefinitionResolver = class {
|
|
|
1247303
1247463
|
const jsFilePaths = /* @__PURE__ */ new Set();
|
|
1247304
1247464
|
await Promise.all(this._parsedDocsConfig.experimental.mdxComponents.map(async (filepath) => {
|
|
1247305
1247465
|
const absoluteFilePath = resolve(this.docsWorkspace.absoluteFilepath, filepath);
|
|
1247306
|
-
const stats = await (0,
|
|
1247466
|
+
const stats = await (0, import_promises37.stat)(absoluteFilePath);
|
|
1247307
1247467
|
if (stats.isDirectory()) {
|
|
1247308
1247468
|
const files = await listFiles(absoluteFilePath, "{js,ts,jsx,tsx}");
|
|
1247309
1247469
|
files.forEach((file) => {
|
|
@@ -1247315,7 +1247475,7 @@ var DocsDefinitionResolver = class {
|
|
|
1247315
1247475
|
}));
|
|
1247316
1247476
|
jsFiles = Object.fromEntries(await Promise.all([...jsFilePaths].map(async (filePath) => {
|
|
1247317
1247477
|
const relativeFilePath = this.toRelativeFilepath(filePath);
|
|
1247318
|
-
const contents = (await (0,
|
|
1247478
|
+
const contents = (await (0, import_promises37.readFile)(filePath)).toString();
|
|
1247319
1247479
|
return [relativeFilePath, contents];
|
|
1247320
1247480
|
})));
|
|
1247321
1247481
|
}
|
|
@@ -1247735,7 +1247895,7 @@ function convertAvailability5(availability) {
|
|
|
1247735
1247895
|
var import_cors = __toESM(require_lib20(), 1);
|
|
1247736
1247896
|
var import_express = __toESM(require_express3(), 1);
|
|
1247737
1247897
|
var import_http2 = __toESM(require("http"), 1);
|
|
1247738
|
-
var
|
|
1247898
|
+
var import_path30 = __toESM(require("path"), 1);
|
|
1247739
1247899
|
|
|
1247740
1247900
|
// ../../../node_modules/.pnpm/watcher@2.3.1/node_modules/watcher/dist/watcher.js
|
|
1247741
1247901
|
var import_node_events = require("events");
|
|
@@ -1249392,10 +1249552,10 @@ var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
|
1249392
1249552
|
// ../docs-preview/lib/downloadLocalDocsBundle.js
|
|
1249393
1249553
|
var import_decompress = __toESM(require_decompress(), 1);
|
|
1249394
1249554
|
var import_fs7 = require("fs");
|
|
1249395
|
-
var
|
|
1249555
|
+
var import_promises38 = require("fs/promises");
|
|
1249396
1249556
|
var import_os4 = require("os");
|
|
1249397
|
-
var
|
|
1249398
|
-
var
|
|
1249557
|
+
var import_path29 = __toESM(require("path"), 1);
|
|
1249558
|
+
var import_promises39 = require("stream/promises");
|
|
1249399
1249559
|
var import_tmp_promise5 = __toESM(require_tmp_promise(), 1);
|
|
1249400
1249560
|
var import_xml2js = __toESM(require_xml2js(), 1);
|
|
1249401
1249561
|
var ETAG_FILENAME = "etag";
|
|
@@ -1249426,7 +1249586,7 @@ async function downloadBundle({ bucketUrl, logger, preferCached }) {
|
|
|
1249426
1249586
|
let currentETag = void 0;
|
|
1249427
1249587
|
if (currentETagExists) {
|
|
1249428
1249588
|
logger.debug("Reading existing ETag");
|
|
1249429
|
-
currentETag = (await (0,
|
|
1249589
|
+
currentETag = (await (0, import_promises38.readFile)(eTagFilepath)).toString();
|
|
1249430
1249590
|
}
|
|
1249431
1249591
|
if (currentETag != null && currentETag === eTag) {
|
|
1249432
1249592
|
logger.debug("ETag matches. Using already downloaded bundle");
|
|
@@ -1249440,7 +1249600,7 @@ async function downloadBundle({ bucketUrl, logger, preferCached }) {
|
|
|
1249440
1249600
|
const dir = await import_tmp_promise5.default.dir({ prefix: "fern" });
|
|
1249441
1249601
|
const absoluteDirectoryToTmpDir = AbsoluteFilePath.of(dir.path);
|
|
1249442
1249602
|
logger.debug(`Created tmp directory ${absoluteDirectoryToTmpDir}`);
|
|
1249443
|
-
const docsBundleZipResponse = await fetch(`${
|
|
1249603
|
+
const docsBundleZipResponse = await fetch(`${import_path29.default.join(bucketUrl, key)}`);
|
|
1249444
1249604
|
const outputZipPath = join(absoluteDirectoryToTmpDir, RelativeFilePath.of("output.zip"));
|
|
1249445
1249605
|
const contents = docsBundleZipResponse.body;
|
|
1249446
1249606
|
if (contents == null) {
|
|
@@ -1249448,18 +1249608,18 @@ async function downloadBundle({ bucketUrl, logger, preferCached }) {
|
|
|
1249448
1249608
|
type: "failure"
|
|
1249449
1249609
|
};
|
|
1249450
1249610
|
}
|
|
1249451
|
-
await (0,
|
|
1249611
|
+
await (0, import_promises39.pipeline)(contents, (0, import_fs7.createWriteStream)(outputZipPath));
|
|
1249452
1249612
|
logger.debug(`Wrote output.zip to ${outputZipPath}`);
|
|
1249453
1249613
|
const absolutePathToPreviewFolder = getPathToPreviewFolder();
|
|
1249454
1249614
|
if (await doesPathExist(absolutePathToPreviewFolder)) {
|
|
1249455
|
-
await (0,
|
|
1249615
|
+
await (0, import_promises38.rm)(absolutePathToPreviewFolder, { recursive: true });
|
|
1249456
1249616
|
}
|
|
1249457
|
-
await (0,
|
|
1249617
|
+
await (0, import_promises38.mkdir)(absolutePathToPreviewFolder, { recursive: true });
|
|
1249458
1249618
|
logger.debug(`rm -rf ${absolutePathToPreviewFolder}`);
|
|
1249459
1249619
|
const absolutePathToBundleFolder = getPathToBundleFolder();
|
|
1249460
|
-
await (0,
|
|
1249620
|
+
await (0, import_promises38.mkdir)(absolutePathToBundleFolder, { recursive: true });
|
|
1249461
1249621
|
await (0, import_decompress.default)(outputZipPath, absolutePathToBundleFolder);
|
|
1249462
|
-
await (0,
|
|
1249622
|
+
await (0, import_promises38.writeFile)(eTagFilepath, eTag);
|
|
1249463
1249623
|
logger.debug(`Downloaded bundle to ${absolutePathToBundleFolder}`);
|
|
1249464
1249624
|
return {
|
|
1249465
1249625
|
type: "success"
|
|
@@ -1249653,9 +1249813,9 @@ async function runPreviewServer({ initialProject, reloadProject, validateProject
|
|
|
1249653
1249813
|
}
|
|
1249654
1249814
|
return next2();
|
|
1249655
1249815
|
});
|
|
1249656
|
-
app.use("/_next", import_express.default.static(
|
|
1249816
|
+
app.use("/_next", import_express.default.static(import_path30.default.join(getPathToBundleFolder(), "/_next")));
|
|
1249657
1249817
|
app.use("*", async (_req, res) => {
|
|
1249658
|
-
return res.sendFile(
|
|
1249818
|
+
return res.sendFile(import_path30.default.join(getPathToBundleFolder(), "/[[...slug]].html"));
|
|
1249659
1249819
|
});
|
|
1249660
1249820
|
app.listen(port);
|
|
1249661
1249821
|
context.logger.info(`Running server on http://localhost:${port}`);
|
|
@@ -1250400,7 +1250560,7 @@ function convertRequestWrapperPropertyToString(property5) {
|
|
|
1250400
1250560
|
}
|
|
1250401
1250561
|
|
|
1250402
1250562
|
// ../yaml/validator/lib/rules/no-duplicate-declarations/no-duplicate-declarations.js
|
|
1250403
|
-
var
|
|
1250563
|
+
var import_path31 = __toESM(require("path"), 1);
|
|
1250404
1250564
|
var NoDuplicateDeclarationsRule = {
|
|
1250405
1250565
|
name: "no-duplicate-declarations",
|
|
1250406
1250566
|
create: async ({ workspace, logger }) => {
|
|
@@ -1250408,7 +1250568,7 @@ var NoDuplicateDeclarationsRule = {
|
|
|
1250408
1250568
|
const seenTypes = {};
|
|
1250409
1250569
|
const getRuleViolations = ({ declaredName, relativeFilepath }) => {
|
|
1250410
1250570
|
var _a6;
|
|
1250411
|
-
const relativeDirectoryPath =
|
|
1250571
|
+
const relativeDirectoryPath = import_path31.default.dirname(relativeFilepath);
|
|
1250412
1250572
|
const declarationsForName = (_a6 = declarations[relativeDirectoryPath]) == null ? void 0 : _a6[declaredName];
|
|
1250413
1250573
|
if (declarationsForName == null) {
|
|
1250414
1250574
|
logger.error(`Could not find declarations for name: ${declaredName}. This is an error in the Fern validator.`);
|
|
@@ -1250445,7 +1250605,7 @@ var NoDuplicateDeclarationsRule = {
|
|
|
1250445
1250605
|
async function getDeclarations(workspace) {
|
|
1250446
1250606
|
const declarations = {};
|
|
1250447
1250607
|
await visitAllDefinitionFiles(workspace, async (relativeFilepath, file) => {
|
|
1250448
|
-
const relativeDirectoryPath =
|
|
1250608
|
+
const relativeDirectoryPath = import_path31.default.dirname(relativeFilepath);
|
|
1250449
1250609
|
const declarationsForDirectory = declarations[relativeDirectoryPath] ?? (declarations[relativeDirectoryPath] = {});
|
|
1250450
1250610
|
const addDeclaration = (declaredName) => {
|
|
1250451
1250611
|
(declarationsForDirectory[declaredName] ?? (declarationsForDirectory[declaredName] = [])).push(relativeFilepath);
|
|
@@ -1252060,7 +1252220,7 @@ var ValidFieldNamesRule = {
|
|
|
1252060
1252220
|
};
|
|
1252061
1252221
|
|
|
1252062
1252222
|
// ../yaml/validator/lib/rules/valid-navigation/valid-navigation.js
|
|
1252063
|
-
var
|
|
1252223
|
+
var import_path32 = __toESM(require("path"), 1);
|
|
1252064
1252224
|
var ValidNavigationRule = {
|
|
1252065
1252225
|
name: "valid-navigation",
|
|
1252066
1252226
|
create: ({ workspace }) => {
|
|
@@ -1252069,7 +1252229,7 @@ var ValidNavigationRule = {
|
|
|
1252069
1252229
|
const directoryToChildren = allNamedDefinitionFilepaths.reduce((acc, definitionFilepath) => {
|
|
1252070
1252230
|
var _a6;
|
|
1252071
1252231
|
const children2 = acc[_a6 = dirname(definitionFilepath)] ?? (acc[_a6] = /* @__PURE__ */ new Set());
|
|
1252072
|
-
children2.add(
|
|
1252232
|
+
children2.add(import_path32.default.basename(definitionFilepath));
|
|
1252073
1252233
|
return acc;
|
|
1252074
1252234
|
}, {});
|
|
1252075
1252235
|
return {
|
|
@@ -1265862,7 +1266022,7 @@ function compile(vfileCompatible, compileOptions) {
|
|
|
1265862
1266022
|
}
|
|
1265863
1266023
|
|
|
1265864
1266024
|
// ../../../node_modules/.pnpm/vfile-matter@5.0.0/node_modules/vfile-matter/lib/index.js
|
|
1265865
|
-
var
|
|
1266025
|
+
var import_yaml2 = __toESM(require_dist5(), 1);
|
|
1265866
1266026
|
var regex3 = /^---(?:\r?\n|\r)(?:([\s\S]*?)(?:\r?\n|\r))?---(?:\r?\n|\r|$)/;
|
|
1265867
1266027
|
function matter2(file, options2) {
|
|
1265868
1266028
|
const options_ = options2 || {};
|
|
@@ -1265871,7 +1266031,7 @@ function matter2(file, options2) {
|
|
|
1265871
1266031
|
let doc = String(file);
|
|
1265872
1266032
|
const match = regex3.exec(doc);
|
|
1265873
1266033
|
if (match) {
|
|
1265874
|
-
file.data.matter =
|
|
1266034
|
+
file.data.matter = import_yaml2.default.parse(match[1], yamlOptions);
|
|
1265875
1266035
|
if (strip) {
|
|
1265876
1266036
|
doc = doc.slice(match[0].length);
|
|
1265877
1266037
|
file.value = file.value && typeof file.value === "object" ? new TextEncoder().encode(doc) : doc;
|
|
@@ -1267639,7 +1267799,7 @@ var domain = {
|
|
|
1267639
1267799
|
tokenize: tokenizeDomain,
|
|
1267640
1267800
|
partial: true
|
|
1267641
1267801
|
};
|
|
1267642
|
-
var
|
|
1267802
|
+
var path33 = {
|
|
1267643
1267803
|
tokenize: tokenizePath,
|
|
1267644
1267804
|
partial: true
|
|
1267645
1267805
|
};
|
|
@@ -1267747,7 +1267907,7 @@ function tokenizeWwwAutolink(effects, ok4, nok) {
|
|
|
1267747
1267907
|
}
|
|
1267748
1267908
|
effects.enter("literalAutolink");
|
|
1267749
1267909
|
effects.enter("literalAutolinkWww");
|
|
1267750
|
-
return effects.check(wwwPrefix, effects.attempt(domain, effects.attempt(
|
|
1267910
|
+
return effects.check(wwwPrefix, effects.attempt(domain, effects.attempt(path33, wwwAfter), nok), nok)(code4);
|
|
1267751
1267911
|
}
|
|
1267752
1267912
|
function wwwAfter(code4) {
|
|
1267753
1267913
|
effects.exit("literalAutolinkWww");
|
|
@@ -1267797,7 +1267957,7 @@ function tokenizeProtocolAutolink(effects, ok4, nok) {
|
|
|
1267797
1267957
|
return nok(code4);
|
|
1267798
1267958
|
}
|
|
1267799
1267959
|
function afterProtocol(code4) {
|
|
1267800
|
-
return code4 === null || asciiControl(code4) || markdownLineEndingOrSpace(code4) || unicodeWhitespace(code4) || unicodePunctuation(code4) ? nok(code4) : effects.attempt(domain, effects.attempt(
|
|
1267960
|
+
return code4 === null || asciiControl(code4) || markdownLineEndingOrSpace(code4) || unicodeWhitespace(code4) || unicodePunctuation(code4) ? nok(code4) : effects.attempt(domain, effects.attempt(path33, protocolAfter), nok)(code4);
|
|
1267801
1267961
|
}
|
|
1267802
1267962
|
function protocolAfter(code4) {
|
|
1267803
1267963
|
effects.exit("literalAutolinkHttp");
|
|
@@ -1269832,7 +1269992,7 @@ var innerPath = function innerPath2(name2, height2) {
|
|
|
1269832
1269992
|
return "";
|
|
1269833
1269993
|
}
|
|
1269834
1269994
|
};
|
|
1269835
|
-
var
|
|
1269995
|
+
var path34 = {
|
|
1269836
1269996
|
doubleleftarrow: "M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z",
|
|
1269837
1269997
|
doublerightarrow: "M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z",
|
|
1269838
1269998
|
leftarrow: "M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z",
|
|
@@ -1272739,7 +1272899,7 @@ var PathNode = class {
|
|
|
1272739
1272899
|
if (this.alternate) {
|
|
1272740
1272900
|
node2.setAttribute("d", this.alternate);
|
|
1272741
1272901
|
} else {
|
|
1272742
|
-
node2.setAttribute("d",
|
|
1272902
|
+
node2.setAttribute("d", path34[this.pathName]);
|
|
1272743
1272903
|
}
|
|
1272744
1272904
|
return node2;
|
|
1272745
1272905
|
}
|
|
@@ -1272747,7 +1272907,7 @@ var PathNode = class {
|
|
|
1272747
1272907
|
if (this.alternate) {
|
|
1272748
1272908
|
return '<path d="' + utils.escape(this.alternate) + '"/>';
|
|
1272749
1272909
|
} else {
|
|
1272750
|
-
return '<path d="' + utils.escape(
|
|
1272910
|
+
return '<path d="' + utils.escape(path34[this.pathName]) + '"/>';
|
|
1272751
1272911
|
}
|
|
1272752
1272912
|
}
|
|
1272753
1272913
|
};
|
|
@@ -1292050,8 +1292210,8 @@ function createDocsConfigFileAstVisitorForRules({ relativeFilepath, allRuleVisit
|
|
|
1292050
1292210
|
}
|
|
1292051
1292211
|
|
|
1292052
1292212
|
// ../yaml/docs-validator/lib/docsAst/visitDocsConfigFileAst.js
|
|
1292053
|
-
var
|
|
1292054
|
-
var
|
|
1292213
|
+
var import_promises40 = require("fs/promises");
|
|
1292214
|
+
var import_path33 = __toESM(require("path"), 1);
|
|
1292055
1292215
|
async function visitDocsConfigFileYamlAst(contents, visitor, absoluteFilepathToConfiguration, absolutePathToFernFolder, context, loadAPIWorkspace2) {
|
|
1292056
1292216
|
var _a6, _b4, _c4, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1292057
1292217
|
await ((_a6 = visitor.file) == null ? void 0 : _a6.call(visitor, {
|
|
@@ -1292090,7 +1292250,7 @@ async function visitDocsConfigFileYamlAst(contents, visitor, absoluteFilepathToC
|
|
|
1292090
1292250
|
for (const filepath of filepaths) {
|
|
1292091
1292251
|
await ((_b4 = visitor.filepath) == null ? void 0 : _b4.call(visitor, {
|
|
1292092
1292252
|
absoluteFilepath: filepath,
|
|
1292093
|
-
value:
|
|
1292253
|
+
value: import_path33.default.relative(absolutePathToFernFolder, filepath),
|
|
1292094
1292254
|
willBeUploaded: true
|
|
1292095
1292255
|
}, [relativePath]));
|
|
1292096
1292256
|
}
|
|
@@ -1292251,7 +1292411,7 @@ async function visitDocsConfigFileYamlAst(contents, visitor, absoluteFilepathToC
|
|
|
1292251
1292411
|
willBeUploaded: false
|
|
1292252
1292412
|
});
|
|
1292253
1292413
|
const absoluteFilepath = resolve(dirname(absoluteFilepathToConfiguration), version3.path);
|
|
1292254
|
-
const content3 = js_yaml_default.load((await (0,
|
|
1292414
|
+
const content3 = js_yaml_default.load((await (0, import_promises40.readFile)(absoluteFilepath)).toString());
|
|
1292255
1292415
|
if (await doesPathExist(absoluteFilepath)) {
|
|
1292256
1292416
|
await ((_a7 = visitor.versionFile) == null ? void 0 : _a7.call(visitor, {
|
|
1292257
1292417
|
path: version3.path,
|
|
@@ -1292322,7 +1292482,7 @@ async function visitNavigationItem({ navigationItem, visitor, nodePath, absolute
|
|
|
1292322
1292482
|
});
|
|
1292323
1292483
|
const absoluteFilepath = resolve(dirname(absoluteFilepathToConfiguration), navigationItem.path);
|
|
1292324
1292484
|
if (await doesPathExist(absoluteFilepath)) {
|
|
1292325
|
-
const content3 = (await (0,
|
|
1292485
|
+
const content3 = (await (0, import_promises40.readFile)(absoluteFilepath)).toString();
|
|
1292326
1292486
|
await ((_a6 = visitor.markdownPage) == null ? void 0 : _a6.call(visitor, {
|
|
1292327
1292487
|
title: navigationItem.page,
|
|
1292328
1292488
|
content: content3,
|
|
@@ -1294751,8 +1294911,8 @@ var supportedExtensions = new Set(extensions);
|
|
|
1294751
1294911
|
var supportedMimeTypes = new Set(mimeTypes);
|
|
1294752
1294912
|
|
|
1294753
1294913
|
// ../yaml/docs-validator/lib/rules/valid-file-types/valid-file-types.js
|
|
1294754
|
-
var
|
|
1294755
|
-
var
|
|
1294914
|
+
var import_promises41 = require("fs/promises");
|
|
1294915
|
+
var import_path34 = __toESM(require("path"), 1);
|
|
1294756
1294916
|
var ALLOWED_FILE_TYPES = /* @__PURE__ */ new Set([
|
|
1294757
1294917
|
"image/jpeg",
|
|
1294758
1294918
|
"image/png",
|
|
@@ -1294828,7 +1294988,7 @@ var ValidFileTypes = {
|
|
|
1294828
1294988
|
}
|
|
1294829
1294989
|
};
|
|
1294830
1294990
|
var getViolationsForFile = async (absoluteFilepath) => {
|
|
1294831
|
-
const file = await (0,
|
|
1294991
|
+
const file = await (0, import_promises41.readFile)(absoluteFilepath);
|
|
1294832
1294992
|
const fileType = await fileTypeFromBuffer(file);
|
|
1294833
1294993
|
if (fileType != null) {
|
|
1294834
1294994
|
if (ALLOWED_FILE_TYPES.has(fileType.mime)) {
|
|
@@ -1294842,7 +1295002,7 @@ var getViolationsForFile = async (absoluteFilepath) => {
|
|
|
1294842
1295002
|
];
|
|
1294843
1295003
|
}
|
|
1294844
1295004
|
}
|
|
1294845
|
-
let extension2 =
|
|
1295005
|
+
let extension2 = import_path34.default.extname(absoluteFilepath).toLowerCase();
|
|
1294846
1295006
|
if (extension2.startsWith(".")) {
|
|
1294847
1295007
|
extension2 = extension2.substring(1);
|
|
1294848
1295008
|
}
|
|
@@ -1295029,8 +1295189,8 @@ async function formatWorkspaces({
|
|
|
1295029
1295189
|
}
|
|
1295030
1295190
|
|
|
1295031
1295191
|
// src/commands/generate-fdr/generateFdrApiDefinitionForWorkspaces.ts
|
|
1295032
|
-
var
|
|
1295033
|
-
var
|
|
1295192
|
+
var import_promises42 = require("fs/promises");
|
|
1295193
|
+
var import_path35 = __toESM(require("path"), 1);
|
|
1295034
1295194
|
|
|
1295035
1295195
|
// src/commands/generate-ir/generateIrForFernWorkspace.ts
|
|
1295036
1295196
|
async function generateIrForFernWorkspace({
|
|
@@ -1295083,8 +1295243,8 @@ async function generateFdrApiDefinitionForWorkspaces({
|
|
|
1295083
1295243
|
ir,
|
|
1295084
1295244
|
snippetsConfig: {}
|
|
1295085
1295245
|
});
|
|
1295086
|
-
const resolvedOutputFilePath =
|
|
1295087
|
-
await (0,
|
|
1295246
|
+
const resolvedOutputFilePath = import_path35.default.resolve(outputFilepath);
|
|
1295247
|
+
await (0, import_promises42.writeFile)(resolvedOutputFilePath, await stringifyLargeObject(apiDefinition, { pretty: true }));
|
|
1295088
1295248
|
context.logger.info(`Wrote FDR API definition to ${resolvedOutputFilePath}`);
|
|
1295089
1295249
|
});
|
|
1295090
1295250
|
})
|
|
@@ -1305599,8 +1305759,8 @@ function migrateIntermediateRepresentationThroughVersion({ intermediateRepresent
|
|
|
1305599
1305759
|
}
|
|
1305600
1305760
|
|
|
1305601
1305761
|
// src/commands/generate-ir/generateIrForWorkspaces.ts
|
|
1305602
|
-
var
|
|
1305603
|
-
var
|
|
1305762
|
+
var import_promises43 = require("fs/promises");
|
|
1305763
|
+
var import_path36 = __toESM(require("path"), 1);
|
|
1305604
1305764
|
async function generateIrForWorkspaces({
|
|
1305605
1305765
|
project,
|
|
1305606
1305766
|
irFilepath,
|
|
@@ -1305628,8 +1305788,8 @@ async function generateIrForWorkspaces({
|
|
|
1305628
1305788
|
version: version3,
|
|
1305629
1305789
|
readme
|
|
1305630
1305790
|
});
|
|
1305631
|
-
const irOutputFilePath =
|
|
1305632
|
-
await (0,
|
|
1305791
|
+
const irOutputFilePath = import_path36.default.resolve(irFilepath);
|
|
1305792
|
+
await (0, import_promises43.writeFile)(
|
|
1305633
1305793
|
irOutputFilePath,
|
|
1305634
1305794
|
await stringifyLargeObject(intermediateRepresentation, { pretty: true })
|
|
1305635
1305795
|
);
|
|
@@ -1305672,8 +1305832,8 @@ async function getIntermediateRepresentation({
|
|
|
1305672
1305832
|
}
|
|
1305673
1305833
|
|
|
1305674
1305834
|
// src/commands/generate-openapi-ir/generateOpenAPIIrForWorkspaces.ts
|
|
1305675
|
-
var
|
|
1305676
|
-
var
|
|
1305835
|
+
var import_promises44 = require("fs/promises");
|
|
1305836
|
+
var import_path37 = __toESM(require("path"), 1);
|
|
1305677
1305837
|
async function generateOpenAPIIrForWorkspaces({
|
|
1305678
1305838
|
project,
|
|
1305679
1305839
|
irFilepath,
|
|
@@ -1305693,11 +1305853,11 @@ async function generateOpenAPIIrForWorkspaces({
|
|
|
1305693
1305853
|
specs: openAPISpecs,
|
|
1305694
1305854
|
taskContext: context
|
|
1305695
1305855
|
});
|
|
1305696
|
-
const irOutputFilePath =
|
|
1305856
|
+
const irOutputFilePath = import_path37.default.resolve(irFilepath);
|
|
1305697
1305857
|
const openApiIrJson = await serialization_exports3.OpenApiIntermediateRepresentation.jsonOrThrow(openAPIIr, {
|
|
1305698
1305858
|
skipValidation: true
|
|
1305699
1305859
|
});
|
|
1305700
|
-
await (0,
|
|
1305860
|
+
await (0, import_promises44.writeFile)(irOutputFilePath, await stringifyLargeObject(openApiIrJson, { pretty: true }));
|
|
1305701
1305861
|
context.logger.info(`Wrote IR to ${irOutputFilePath}`);
|
|
1305702
1305862
|
});
|
|
1305703
1305863
|
})
|
|
@@ -1305705,7 +1305865,7 @@ async function generateOpenAPIIrForWorkspaces({
|
|
|
1305705
1305865
|
}
|
|
1305706
1305866
|
|
|
1305707
1305867
|
// src/commands/generate-overrides/writeOverridesForWorkspaces.ts
|
|
1305708
|
-
var
|
|
1305868
|
+
var import_promises45 = require("fs/promises");
|
|
1305709
1305869
|
async function writeOverridesForWorkspaces({
|
|
1305710
1305870
|
project,
|
|
1305711
1305871
|
includeModels,
|
|
@@ -1305730,7 +1305890,7 @@ async function writeOverridesForWorkspaces({
|
|
|
1305730
1305890
|
async function readExistingOverrides(overridesFilepath, context) {
|
|
1305731
1305891
|
let parsedOverrides = null;
|
|
1305732
1305892
|
try {
|
|
1305733
|
-
const contents = (await (0,
|
|
1305893
|
+
const contents = (await (0, import_promises45.readFile)(overridesFilepath, "utf8")).toString();
|
|
1305734
1305894
|
try {
|
|
1305735
1305895
|
parsedOverrides = JSON.parse(contents);
|
|
1305736
1305896
|
} catch (err) {
|
|
@@ -1305788,7 +1305948,7 @@ async function writeDefinitionForOpenAPIWorkspace({
|
|
|
1305788
1305948
|
}
|
|
1305789
1305949
|
}
|
|
1305790
1305950
|
const components = { schemas };
|
|
1305791
|
-
await (0,
|
|
1305951
|
+
await (0, import_promises45.writeFile)(
|
|
1305792
1305952
|
join(dirname(spec.absoluteFilepath), RelativeFilePath.of("openapi-overrides.yml")),
|
|
1305793
1305953
|
js_yaml_default.dump({ paths, components })
|
|
1305794
1305954
|
);
|
|
@@ -1305806,15 +1305966,15 @@ var import_generator_exec_sdk = __toESM(require_generator_exec_sdk(), 1);
|
|
|
1305806
1305966
|
var import_api3 = __toESM(require_api35(), 1);
|
|
1305807
1305967
|
|
|
1305808
1305968
|
// ../generation/local-generation/local-workspace-runner/lib/constants.js
|
|
1305809
|
-
var
|
|
1305969
|
+
var import_path38 = __toESM(require("path"), 1);
|
|
1305810
1305970
|
var DOCKER_FERN_DIRECTORY = "/fern";
|
|
1305811
|
-
var DOCKER_CODEGEN_OUTPUT_DIRECTORY =
|
|
1305812
|
-
var DOCKER_GENERATOR_CONFIG_PATH =
|
|
1305813
|
-
var DOCKER_PATH_TO_IR =
|
|
1305814
|
-
var DOCKER_PATH_TO_SNIPPET =
|
|
1305815
|
-
var DOCKER_PATH_TO_SNIPPET_TEMPLATES =
|
|
1305816
|
-
var DOCKER_GENERATORS_DIRECTORY =
|
|
1305817
|
-
var DOCKER_SOURCES_DIRECTORY =
|
|
1305971
|
+
var DOCKER_CODEGEN_OUTPUT_DIRECTORY = import_path38.default.join(DOCKER_FERN_DIRECTORY, "output");
|
|
1305972
|
+
var DOCKER_GENERATOR_CONFIG_PATH = import_path38.default.join(DOCKER_FERN_DIRECTORY, "config.json");
|
|
1305973
|
+
var DOCKER_PATH_TO_IR = import_path38.default.join(DOCKER_FERN_DIRECTORY, "ir.json");
|
|
1305974
|
+
var DOCKER_PATH_TO_SNIPPET = import_path38.default.join(DOCKER_FERN_DIRECTORY, "snippet.json");
|
|
1305975
|
+
var DOCKER_PATH_TO_SNIPPET_TEMPLATES = import_path38.default.join(DOCKER_FERN_DIRECTORY, "snippet-templates.json");
|
|
1305976
|
+
var DOCKER_GENERATORS_DIRECTORY = import_path38.default.join(DOCKER_FERN_DIRECTORY, "generators");
|
|
1305977
|
+
var DOCKER_SOURCES_DIRECTORY = import_path38.default.join(DOCKER_FERN_DIRECTORY, "sources");
|
|
1305818
1305978
|
|
|
1305819
1305979
|
// ../generation/local-generation/local-workspace-runner/lib/getGeneratorConfig.js
|
|
1305820
1305980
|
var DEFAULT_OUTPUT_VERSION = "0.0.1";
|
|
@@ -1306061,7 +1306221,7 @@ async function getIntermediateRepresentation2({ workspace, audiences, generatorI
|
|
|
1306061
1306221
|
|
|
1306062
1306222
|
// ../generation/local-generation/docker-utils/lib/runDocker.js
|
|
1306063
1306223
|
var import_dockerode2 = __toESM(require_docker(), 1);
|
|
1306064
|
-
var
|
|
1306224
|
+
var import_promises46 = require("fs/promises");
|
|
1306065
1306225
|
var import_stream3 = require("stream");
|
|
1306066
1306226
|
var import_tmp_promise6 = __toESM(require_tmp_promise(), 1);
|
|
1306067
1306227
|
async function runDocker({ imageName, args, binds, writeLogsToFile = true, removeAfterCompletion = false }) {
|
|
@@ -1306100,7 +1306260,7 @@ async function tryRunDocker({ docker, imageName, args, binds, removeAfterComplet
|
|
|
1306100
1306260
|
if (status.StatusCode !== 0) {
|
|
1306101
1306261
|
if (writeLogsToFile) {
|
|
1306102
1306262
|
const tmpFile = await import_tmp_promise6.default.file();
|
|
1306103
|
-
await (0,
|
|
1306263
|
+
await (0, import_promises46.writeFile)(tmpFile.path, logs);
|
|
1306104
1306264
|
throw new Error(`Docker exited with a non-zero exit code. Logs here: ${tmpFile.path}`);
|
|
1306105
1306265
|
} else {
|
|
1306106
1306266
|
throw new Error("Docker exited with a non-zero exit code.");
|
|
@@ -1306122,12 +1306282,12 @@ async function pullImage(docker, imageName) {
|
|
|
1306122
1306282
|
|
|
1306123
1306283
|
// ../generation/local-generation/local-workspace-runner/lib/runGenerator.js
|
|
1306124
1306284
|
var FernGeneratorExecParsing = __toESM(require_serialization33(), 1);
|
|
1306125
|
-
var
|
|
1306285
|
+
var import_promises48 = require("fs/promises");
|
|
1306126
1306286
|
var import_tmp_promise8 = __toESM(require_tmp_promise(), 1);
|
|
1306127
1306287
|
|
|
1306128
1306288
|
// ../generation/local-generation/local-workspace-runner/lib/LocalTaskHandler.js
|
|
1306129
1306289
|
var import_decompress2 = __toESM(require_decompress(), 1);
|
|
1306130
|
-
var
|
|
1306290
|
+
var import_promises47 = require("fs/promises");
|
|
1306131
1306291
|
var import_tmp_promise7 = __toESM(require_tmp_promise(), 1);
|
|
1306132
1306292
|
var LocalTaskHandler = class {
|
|
1306133
1306293
|
context;
|
|
@@ -1306173,7 +1306333,7 @@ var LocalTaskHandler = class {
|
|
|
1306173
1306333
|
const tmpOutputResolutionDir = AbsoluteFilePath.of((await import_tmp_promise7.default.dir({})).path);
|
|
1306174
1306334
|
const absolutePathToFernignore = AbsoluteFilePath.of(join(this.absolutePathToLocalOutput, RelativeFilePath.of(FERNIGNORE_FILENAME)));
|
|
1306175
1306335
|
const fernIngnorePaths = await getFernIgnorePaths({ absolutePathToFernignore });
|
|
1306176
|
-
await (0,
|
|
1306336
|
+
await (0, import_promises47.cp)(this.absolutePathToLocalOutput, tmpOutputResolutionDir, { recursive: true });
|
|
1306177
1306337
|
await this.runGitCommand(["init"], tmpOutputResolutionDir);
|
|
1306178
1306338
|
await this.runGitCommand(["add", "."], tmpOutputResolutionDir);
|
|
1306179
1306339
|
const response = await this.runGitCommand(["config", "--list"], tmpOutputResolutionDir);
|
|
@@ -1306186,16 +1306346,16 @@ var LocalTaskHandler = class {
|
|
|
1306186
1306346
|
await this.copyGeneratedFilesToDirectory(tmpOutputResolutionDir);
|
|
1306187
1306347
|
await this.runGitCommand(["reset", "--", ...fernIngnorePaths], tmpOutputResolutionDir);
|
|
1306188
1306348
|
await this.runGitCommand(["restore", "."], tmpOutputResolutionDir);
|
|
1306189
|
-
await (0,
|
|
1306190
|
-
await (0,
|
|
1306349
|
+
await (0, import_promises47.rmdir)(this.absolutePathToLocalOutput, { recursive: true });
|
|
1306350
|
+
await (0, import_promises47.cp)(tmpOutputResolutionDir, this.absolutePathToLocalOutput, { recursive: true });
|
|
1306191
1306351
|
}
|
|
1306192
1306352
|
async copyGeneratedFilesNoFernIgnore() {
|
|
1306193
1306353
|
this.context.logger.debug(`rm -rf ${this.absolutePathToLocalOutput}`);
|
|
1306194
|
-
await (0,
|
|
1306354
|
+
await (0, import_promises47.rm)(this.absolutePathToLocalOutput, { force: true, recursive: true });
|
|
1306195
1306355
|
await this.copyGeneratedFilesToDirectory(this.absolutePathToLocalOutput);
|
|
1306196
1306356
|
}
|
|
1306197
1306357
|
async copyGeneratedFilesToDirectory(outputPath) {
|
|
1306198
|
-
const [firstLocalOutputItem, ...remaininglocalOutputItems] = await (0,
|
|
1306358
|
+
const [firstLocalOutputItem, ...remaininglocalOutputItems] = await (0, import_promises47.readdir)(this.absolutePathToTmpOutputDirectory);
|
|
1306199
1306359
|
if (firstLocalOutputItem == null) {
|
|
1306200
1306360
|
return;
|
|
1306201
1306361
|
}
|
|
@@ -1306203,15 +1306363,15 @@ var LocalTaskHandler = class {
|
|
|
1306203
1306363
|
if (firstLocalOutputItem.endsWith(".zip")) {
|
|
1306204
1306364
|
await (0, import_decompress2.default)(join(this.absolutePathToTmpOutputDirectory, RelativeFilePath.of(firstLocalOutputItem)), outputPath);
|
|
1306205
1306365
|
for (const localOutputItem of remaininglocalOutputItems) {
|
|
1306206
|
-
await (0,
|
|
1306366
|
+
await (0, import_promises47.cp)(join(this.absolutePathToTmpOutputDirectory, RelativeFilePath.of(localOutputItem)), join(outputPath, RelativeFilePath.of(localOutputItem)), { recursive: true });
|
|
1306207
1306367
|
}
|
|
1306208
1306368
|
} else {
|
|
1306209
|
-
await (0,
|
|
1306369
|
+
await (0, import_promises47.cp)(this.absolutePathToTmpOutputDirectory, outputPath, { recursive: true });
|
|
1306210
1306370
|
}
|
|
1306211
1306371
|
}
|
|
1306212
1306372
|
async copySnippetJSON({ absolutePathToTmpSnippetJSON, absolutePathToLocalSnippetJSON }) {
|
|
1306213
1306373
|
this.context.logger.debug(`Copying generated snippets to ${absolutePathToLocalSnippetJSON}`);
|
|
1306214
|
-
await (0,
|
|
1306374
|
+
await (0, import_promises47.cp)(absolutePathToTmpSnippetJSON, absolutePathToLocalSnippetJSON);
|
|
1306215
1306375
|
}
|
|
1306216
1306376
|
async runGitCommand(options2, cwd2) {
|
|
1306217
1306377
|
const response = await loggingExeca(this.context.logger, "git", options2, {
|
|
@@ -1306223,7 +1306383,7 @@ var LocalTaskHandler = class {
|
|
|
1306223
1306383
|
};
|
|
1306224
1306384
|
var NEW_LINE_REGEX = /\r?\n/;
|
|
1306225
1306385
|
async function getFernIgnorePaths({ absolutePathToFernignore }) {
|
|
1306226
|
-
const fernIgnoreFileContents = (await (0,
|
|
1306386
|
+
const fernIgnoreFileContents = (await (0, import_promises47.readFile)(absolutePathToFernignore)).toString();
|
|
1306227
1306387
|
return [
|
|
1306228
1306388
|
FERNIGNORE_FILENAME,
|
|
1306229
1306389
|
...fernIgnoreFileContents.trim().split(NEW_LINE_REGEX).filter((line) => !line.startsWith("#") && line.length > 0)
|
|
@@ -1306316,7 +1306476,7 @@ async function writeIrToFile({ workspace, audiences, generatorInvocation, worksp
|
|
|
1306316
1306476
|
tmpdir: workspaceTempDir.path
|
|
1306317
1306477
|
});
|
|
1306318
1306478
|
const absolutePathToIr = AbsoluteFilePath.of(irFile.path);
|
|
1306319
|
-
await (0,
|
|
1306479
|
+
await (0, import_promises48.writeFile)(absolutePathToIr, JSON.stringify(intermediateRepresentation, void 0, 4));
|
|
1306320
1306480
|
context.logger.debug(`Wrote IR to ${absolutePathToIr}`);
|
|
1306321
1306481
|
return absolutePathToIr;
|
|
1306322
1306482
|
}
|
|
@@ -1306348,7 +1306508,7 @@ async function runGenerator({ workspaceName, organization, outputVersion, absolu
|
|
|
1306348
1306508
|
if (!parsedConfig.ok) {
|
|
1306349
1306509
|
throw new Error(`Failed to parse config.json into ${absolutePathToWriteConfigJson}`);
|
|
1306350
1306510
|
}
|
|
1306351
|
-
await (0,
|
|
1306511
|
+
await (0, import_promises48.writeFile)(absolutePathToWriteConfigJson, JSON.stringify(parsedConfig.value, void 0, 4));
|
|
1306352
1306512
|
const doesConfigJsonExist = await waitUntilPathExists(absolutePathToWriteConfigJson, 5e3);
|
|
1306353
1306513
|
if (!doesConfigJsonExist) {
|
|
1306354
1306514
|
throw new Error(`Failed to create ${absolutePathToWriteConfigJson}`);
|
|
@@ -1306379,7 +1306539,7 @@ function getDockerDestinationForSource(source) {
|
|
|
1306379
1306539
|
|
|
1306380
1306540
|
// ../generation/local-generation/local-workspace-runner/lib/runLocalGenerationForWorkspace.js
|
|
1306381
1306541
|
var import_os5 = __toESM(require("os"), 1);
|
|
1306382
|
-
var
|
|
1306542
|
+
var import_path39 = __toESM(require("path"), 1);
|
|
1306383
1306543
|
var import_tmp_promise9 = __toESM(require_tmp_promise(), 1);
|
|
1306384
1306544
|
async function runLocalGenerationForWorkspace({ projectConfig, workspace, generatorGroup, keepDocker, context }) {
|
|
1306385
1306545
|
const workspaceTempDir = await getWorkspaceTempDir();
|
|
@@ -1306422,7 +1306582,7 @@ async function runLocalGenerationForWorkspace({ projectConfig, workspace, genera
|
|
|
1306422
1306582
|
}
|
|
1306423
1306583
|
async function getWorkspaceTempDir() {
|
|
1306424
1306584
|
return import_tmp_promise9.default.dir({
|
|
1306425
|
-
tmpdir: import_os5.default.platform() === "darwin" ?
|
|
1306585
|
+
tmpdir: import_os5.default.platform() === "darwin" ? import_path39.default.join("/private", import_os5.default.tmpdir()) : void 0,
|
|
1306426
1306586
|
prefix: "fern"
|
|
1306427
1306587
|
});
|
|
1306428
1306588
|
}
|
|
@@ -1306433,8 +1306593,8 @@ var import_fiddle_sdk5 = __toESM(require_fiddle_sdk(), 1);
|
|
|
1306433
1306593
|
// ../generation/remote-generation/remote-workspace-runner/lib/downloadSnippetsForTask.js
|
|
1306434
1306594
|
var import_axios5 = __toESM(require_axios4(), 1);
|
|
1306435
1306595
|
var import_fs8 = require("fs");
|
|
1306436
|
-
var
|
|
1306437
|
-
var
|
|
1306596
|
+
var import_promises49 = require("fs/promises");
|
|
1306597
|
+
var import_promises50 = require("stream/promises");
|
|
1306438
1306598
|
async function downloadSnippetsForTask({ snippetsS3PreSignedReadUrl, absolutePathToLocalSnippetJSON, context }) {
|
|
1306439
1306599
|
try {
|
|
1306440
1306600
|
await downloadFileForTask({
|
|
@@ -1306451,18 +1306611,18 @@ async function downloadFileForTask({ s3PreSignedReadUrl, absolutePathToLocalOutp
|
|
|
1306451
1306611
|
responseType: "stream"
|
|
1306452
1306612
|
});
|
|
1306453
1306613
|
if (await doesPathExist(absolutePathToLocalOutput)) {
|
|
1306454
|
-
await (0,
|
|
1306614
|
+
await (0, import_promises49.rm)(absolutePathToLocalOutput, { recursive: true });
|
|
1306455
1306615
|
}
|
|
1306456
|
-
await (0,
|
|
1306457
|
-
await (0,
|
|
1306616
|
+
await (0, import_promises49.mkdir)(dirname(absolutePathToLocalOutput), { recursive: true });
|
|
1306617
|
+
await (0, import_promises50.pipeline)(request.data, (0, import_fs8.createWriteStream)(absolutePathToLocalOutput));
|
|
1306458
1306618
|
}
|
|
1306459
1306619
|
|
|
1306460
1306620
|
// ../generation/remote-generation/remote-workspace-runner/lib/createAndStartJob.js
|
|
1306461
1306621
|
var import_fiddle_sdk4 = __toESM(require_fiddle_sdk(), 1);
|
|
1306462
1306622
|
var import_axios6 = __toESM(require_axios4(), 1);
|
|
1306463
1306623
|
var import_form_data2 = __toESM(require_form_data(), 1);
|
|
1306464
|
-
var
|
|
1306465
|
-
var
|
|
1306624
|
+
var import_promises51 = require("fs/promises");
|
|
1306625
|
+
var import_path40 = require("path");
|
|
1306466
1306626
|
var import_tar2 = __toESM(require_tar(), 1);
|
|
1306467
1306627
|
var import_tmp_promise10 = __toESM(require_tmp_promise(), 1);
|
|
1306468
1306628
|
async function createAndStartJob({ projectConfig, workspace, organization, intermediateRepresentation, generatorInvocation, version: version3, context, shouldLogS3Url, token, whitelabel, irVersionOverride, absolutePathToPreview }) {
|
|
@@ -1306502,23 +1306662,23 @@ async function createJob({ projectConfig, workspace, organization, generatorInvo
|
|
|
1306502
1306662
|
context.logger.debug(`Writing mock fern definition to ${absolutePathToTmpDir}`);
|
|
1306503
1306663
|
const absolutePathToTmpFernDirectory = join(absolutePathToTmpDir, RelativeFilePath.of(FERN_DIRECTORY));
|
|
1306504
1306664
|
const absolutePathToTmpDefinitionDirectory = join(absolutePathToTmpFernDirectory, RelativeFilePath.of(DEFINITION_DIRECTORY));
|
|
1306505
|
-
await (0,
|
|
1306665
|
+
await (0, import_promises51.mkdir)(absolutePathToTmpDefinitionDirectory, { recursive: true });
|
|
1306506
1306666
|
const absolutePathToApiYml = join(absolutePathToTmpDefinitionDirectory, RelativeFilePath.of(ROOT_API_FILENAME));
|
|
1306507
|
-
await (0,
|
|
1306667
|
+
await (0, import_promises51.writeFile)(absolutePathToApiYml, js_yaml_default.dump(workspace.definition.rootApiFile.contents));
|
|
1306508
1306668
|
await writeFernDefinition({
|
|
1306509
1306669
|
absolutePathToDefinitionDirectory: absolutePathToTmpDefinitionDirectory,
|
|
1306510
1306670
|
definition: workspace.definition
|
|
1306511
1306671
|
});
|
|
1306512
1306672
|
const absolutePathToFernConfigJson = join(absolutePathToTmpFernDirectory, RelativeFilePath.of(PROJECT_CONFIG_FILENAME));
|
|
1306513
|
-
await (0,
|
|
1306673
|
+
await (0, import_promises51.writeFile)(absolutePathToFernConfigJson, JSON.stringify(projectConfig.rawConfig, void 0, 2));
|
|
1306514
1306674
|
try {
|
|
1306515
1306675
|
const sources = workspace.getSources();
|
|
1306516
1306676
|
for (const source of sources) {
|
|
1306517
|
-
const sourceContents = await (0,
|
|
1306518
|
-
const relativeLocation = (0,
|
|
1306677
|
+
const sourceContents = await (0, import_promises51.readFile)(source.absoluteFilePath);
|
|
1306678
|
+
const relativeLocation = (0, import_path40.relative)(workspace.absoluteFilepath, source.absoluteFilePath);
|
|
1306519
1306679
|
const absolutePathToSourceFile = join(absolutePathToTmpFernDirectory, RelativeFilePath.of(relativeLocation));
|
|
1306520
|
-
await (0,
|
|
1306521
|
-
await (0,
|
|
1306680
|
+
await (0, import_promises51.mkdir)(dirname(absolutePathToSourceFile), { recursive: true });
|
|
1306681
|
+
await (0, import_promises51.writeFile)(absolutePathToSourceFile, sourceContents);
|
|
1306522
1306682
|
}
|
|
1306523
1306683
|
} catch (error) {
|
|
1306524
1306684
|
context.logger.debug(`Failed to write source files to disk, continuing: ${error}`);
|
|
@@ -1306541,7 +1306701,7 @@ async function createJob({ projectConfig, workspace, organization, generatorInvo
|
|
|
1306541
1306701
|
}
|
|
1306542
1306702
|
} else {
|
|
1306543
1306703
|
context.logger.debug("Uploading definition...");
|
|
1306544
|
-
await import_axios6.default.put(definitionUploadUrlRequest.body.s3Url, await (0,
|
|
1306704
|
+
await import_axios6.default.put(definitionUploadUrlRequest.body.s3Url, await (0, import_promises51.readFile)(tarPath));
|
|
1306545
1306705
|
fernDefinitionMetadata = {
|
|
1306546
1306706
|
definitionS3DownloadUrl: definitionUploadUrlRequest.body.s3Url,
|
|
1306547
1306707
|
outputPath: ".mock",
|
|
@@ -1306603,14 +1306763,14 @@ async function createJob({ projectConfig, workspace, organization, generatorInvo
|
|
|
1306603
1306763
|
async function writeFernDefinition({ absolutePathToDefinitionDirectory, definition: definition3 }) {
|
|
1306604
1306764
|
for (const [relativePath, definitionFile] of Object.entries(definition3.namedDefinitionFiles)) {
|
|
1306605
1306765
|
const absolutePathToDefinitionFile = join(absolutePathToDefinitionDirectory, RelativeFilePath.of(relativePath));
|
|
1306606
|
-
await (0,
|
|
1306607
|
-
await (0,
|
|
1306766
|
+
await (0, import_promises51.mkdir)(dirname(absolutePathToDefinitionFile), { recursive: true });
|
|
1306767
|
+
await (0, import_promises51.writeFile)(absolutePathToDefinitionFile, js_yaml_default.dump(definitionFile.contents));
|
|
1306608
1306768
|
}
|
|
1306609
1306769
|
for (const [relativePath, packageMarker] of Object.entries(definition3.packageMarkers)) {
|
|
1306610
1306770
|
if (packageMarker.contents.export == null) {
|
|
1306611
1306771
|
const absolutePathToPackageMarker = join(absolutePathToDefinitionDirectory, RelativeFilePath.of(relativePath));
|
|
1306612
|
-
await (0,
|
|
1306613
|
-
await (0,
|
|
1306772
|
+
await (0, import_promises51.mkdir)(dirname(absolutePathToPackageMarker), { recursive: true });
|
|
1306773
|
+
await (0, import_promises51.writeFile)(absolutePathToPackageMarker, js_yaml_default.dump(packageMarker.contents));
|
|
1306614
1306774
|
}
|
|
1306615
1306775
|
}
|
|
1306616
1306776
|
for (const [relativePath, importedDefinition] of Object.entries(definition3.importedDefinitions)) {
|
|
@@ -1306726,9 +1306886,9 @@ function pollJobAndReportStatus({ job, taskId, taskHandler, context }) {
|
|
|
1306726
1306886
|
var import_axios7 = __toESM(require_axios4(), 1);
|
|
1306727
1306887
|
var import_decompress3 = __toESM(require_decompress(), 1);
|
|
1306728
1306888
|
var import_fs9 = require("fs");
|
|
1306729
|
-
var
|
|
1306730
|
-
var
|
|
1306731
|
-
var
|
|
1306889
|
+
var import_promises52 = require("fs/promises");
|
|
1306890
|
+
var import_path41 = __toESM(require("path"), 1);
|
|
1306891
|
+
var import_promises53 = require("stream/promises");
|
|
1306732
1306892
|
var import_tmp_promise11 = __toESM(require_tmp_promise(), 1);
|
|
1306733
1306893
|
var _isFinished, _createdSnippets, _snippetsS3PreSignedReadUrl;
|
|
1306734
1306894
|
var RemoteTaskHandler = class {
|
|
@@ -1306812,7 +1306972,7 @@ var RemoteTaskHandler = class {
|
|
|
1306812
1306972
|
} : void 0;
|
|
1306813
1306973
|
}
|
|
1306814
1306974
|
getAbsolutePathToLocalOutput() {
|
|
1306815
|
-
return this.absolutePathToPreview != null ? join(this.absolutePathToPreview, RelativeFilePath.of(
|
|
1306975
|
+
return this.absolutePathToPreview != null ? join(this.absolutePathToPreview, RelativeFilePath.of(import_path41.default.basename(this.generatorInvocation.name))) : this.generatorInvocation.absolutePathToLocalOutput;
|
|
1306816
1306976
|
}
|
|
1306817
1306977
|
get isFinished() {
|
|
1306818
1306978
|
return __privateGet(this, _isFinished);
|
|
@@ -1306843,12 +1307003,12 @@ async function downloadZipForTask({ s3PreSignedReadUrl, absolutePathToLocalOutpu
|
|
|
1306843
1307003
|
responseType: "stream"
|
|
1306844
1307004
|
});
|
|
1306845
1307005
|
const tmpDir = await import_tmp_promise11.default.dir({ prefix: "fern", unsafeCleanup: true });
|
|
1306846
|
-
const outputZipPath =
|
|
1306847
|
-
await (0,
|
|
1307006
|
+
const outputZipPath = import_path41.default.join(tmpDir.path, "output.zip");
|
|
1307007
|
+
await (0, import_promises53.pipeline)(request.data, (0, import_fs9.createWriteStream)(outputZipPath));
|
|
1306848
1307008
|
if (await doesPathExist(absolutePathToLocalOutput)) {
|
|
1306849
|
-
await (0,
|
|
1307009
|
+
await (0, import_promises52.rm)(absolutePathToLocalOutput, { recursive: true });
|
|
1306850
1307010
|
}
|
|
1306851
|
-
await (0,
|
|
1307011
|
+
await (0, import_promises52.mkdir)(absolutePathToLocalOutput, { recursive: true });
|
|
1306852
1307012
|
await (0, import_decompress3.default)(outputZipPath, absolutePathToLocalOutput);
|
|
1306853
1307013
|
}
|
|
1306854
1307014
|
function convertLogLevel(logLevel) {
|
|
@@ -1306867,7 +1307027,7 @@ function convertLogLevel(logLevel) {
|
|
|
1306867
1307027
|
}
|
|
1306868
1307028
|
|
|
1306869
1307029
|
// ../generation/remote-generation/remote-workspace-runner/lib/SourceUploader.js
|
|
1306870
|
-
var
|
|
1307030
|
+
var import_promises54 = require("fs/promises");
|
|
1306871
1307031
|
var import_tmp_promise12 = __toESM(require_tmp_promise(), 1);
|
|
1306872
1307032
|
var PROTOBUF_ZIP_FILENAME = "proto.zip";
|
|
1306873
1307033
|
var SourceUploader = class {
|
|
@@ -1306888,7 +1307048,7 @@ var SourceUploader = class {
|
|
|
1306888
1307048
|
}
|
|
1306889
1307049
|
async uploadSource(source, uploadURL) {
|
|
1306890
1307050
|
const uploadCommand = await this.getUploadCommand(source);
|
|
1306891
|
-
const fileData = await (0,
|
|
1307051
|
+
const fileData = await (0, import_promises54.readFile)(uploadCommand.absoluteFilePath);
|
|
1306892
1307052
|
const response = await fetch(uploadURL, {
|
|
1306893
1307053
|
method: "PUT",
|
|
1306894
1307054
|
body: fileData,
|
|
@@ -1306908,7 +1307068,7 @@ var SourceUploader = class {
|
|
|
1306908
1307068
|
absoluteFilePath,
|
|
1306909
1307069
|
cleanup: async () => {
|
|
1306910
1307070
|
this.context.logger.debug(`Removing ${absoluteFilePath}`);
|
|
1306911
|
-
await (0,
|
|
1307071
|
+
await (0, import_promises54.unlink)(absoluteFilePath);
|
|
1306912
1307072
|
}
|
|
1306913
1307073
|
};
|
|
1306914
1307074
|
}
|
|
@@ -1307153,7 +1307313,7 @@ async function runRemoteGenerationForAPIWorkspace({ projectConfig, organization,
|
|
|
1307153
1307313
|
|
|
1307154
1307314
|
// ../generation/remote-generation/remote-workspace-runner/lib/publishDocs.js
|
|
1307155
1307315
|
var import_axios8 = __toESM(require_axios4(), 1);
|
|
1307156
|
-
var
|
|
1307316
|
+
var import_promises55 = require("fs/promises");
|
|
1307157
1307317
|
var mime = __toESM(require_mime_types(), 1);
|
|
1307158
1307318
|
|
|
1307159
1307319
|
// ../generation/remote-generation/remote-workspace-runner/lib/measureImageSizes.js
|
|
@@ -1307308,7 +1307468,7 @@ async function uploadFiles(filesToUpload, docsWorkspacePath, context, batchSize)
|
|
|
1307308
1307468
|
const absoluteFilePath = resolve(docsWorkspacePath, relativeFilePath);
|
|
1307309
1307469
|
try {
|
|
1307310
1307470
|
const mimeType = mime.lookup(absoluteFilePath);
|
|
1307311
|
-
await import_axios8.default.put(uploadUrl, await (0,
|
|
1307471
|
+
await import_axios8.default.put(uploadUrl, await (0, import_promises55.readFile)(absoluteFilePath), {
|
|
1307312
1307472
|
headers: {
|
|
1307313
1307473
|
"Content-Type": mimeType === false ? "application/octet-stream" : mimeType
|
|
1307314
1307474
|
}
|
|
@@ -1307928,8 +1308088,8 @@ async function mockServer({
|
|
|
1307928
1308088
|
// src/commands/register/registerWorkspacesV1.ts
|
|
1307929
1308089
|
var import_fiddle_sdk6 = __toESM(require_fiddle_sdk(), 1);
|
|
1307930
1308090
|
var import_axios9 = __toESM(require_axios4(), 1);
|
|
1307931
|
-
var
|
|
1307932
|
-
var
|
|
1308091
|
+
var import_promises56 = require("fs/promises");
|
|
1308092
|
+
var import_path42 = __toESM(require("path"), 1);
|
|
1307933
1308093
|
var import_tar3 = __toESM(require_tar(), 1);
|
|
1307934
1308094
|
var import_tmp_promise13 = __toESM(require_tmp_promise(), 1);
|
|
1307935
1308095
|
async function registerWorkspacesV1({
|
|
@@ -1307974,11 +1308134,11 @@ async function registerWorkspacesV1({
|
|
|
1307974
1308134
|
return;
|
|
1307975
1308135
|
}
|
|
1307976
1308136
|
const tmpDir = await import_tmp_promise13.default.dir();
|
|
1307977
|
-
const tarPath =
|
|
1308137
|
+
const tarPath = import_path42.default.join(tmpDir.path, "definition.tgz");
|
|
1307978
1308138
|
context.logger.debug(`Compressing definition at ${tmpDir.path}`);
|
|
1307979
1308139
|
await import_tar3.default.create({ file: tarPath, cwd: resolvedWorkspace.absoluteFilepath }, ["."]);
|
|
1307980
1308140
|
context.logger.info("Uploading definition...");
|
|
1307981
|
-
await import_axios9.default.put(registerApiResponse.body.definitionS3UploadUrl, await (0,
|
|
1308141
|
+
await import_axios9.default.put(registerApiResponse.body.definitionS3UploadUrl, await (0, import_promises56.readFile)(tarPath));
|
|
1307982
1308142
|
context.logger.info(
|
|
1307983
1308143
|
`Registered @${project.config.organization}/${resolvedWorkspace.definition.rootApiFile.contents.name}:${registerApiResponse.body.version}`
|
|
1307984
1308144
|
);
|
|
@@ -1308105,20 +1308265,20 @@ async function generateToken({
|
|
|
1308105
1308265
|
|
|
1308106
1308266
|
// src/commands/upgrade/updateApiSpec.ts
|
|
1308107
1308267
|
var fs7 = __toESM(require("fs"), 1);
|
|
1308108
|
-
var
|
|
1308268
|
+
var import_promises57 = require("fs/promises");
|
|
1308109
1308269
|
var import_stream4 = require("stream");
|
|
1308110
|
-
var
|
|
1308270
|
+
var import_promises58 = require("stream/promises");
|
|
1308111
1308271
|
async function fetchAndWriteFile(url, path45, logger) {
|
|
1308112
1308272
|
const resp = await fetch(url);
|
|
1308113
1308273
|
if (resp.ok && resp.body) {
|
|
1308114
1308274
|
logger.debug("Origin successfully fetched, writing to file");
|
|
1308115
1308275
|
const fileStream = fs7.createWriteStream(path45);
|
|
1308116
|
-
await (0,
|
|
1308117
|
-
const fileContents = await (0,
|
|
1308276
|
+
await (0, import_promises58.finished)(import_stream4.Readable.fromWeb(resp.body).pipe(fileStream));
|
|
1308277
|
+
const fileContents = await (0, import_promises57.readFile)(path45, "utf8");
|
|
1308118
1308278
|
try {
|
|
1308119
|
-
await (0,
|
|
1308279
|
+
await (0, import_promises57.writeFile)(path45, JSON.stringify(JSON.parse(fileContents), void 0, 2), "utf8");
|
|
1308120
1308280
|
} catch (e) {
|
|
1308121
|
-
await (0,
|
|
1308281
|
+
await (0, import_promises57.writeFile)(path45, js_yaml_default.dump(js_yaml_default.load(fileContents)), "utf8");
|
|
1308122
1308282
|
}
|
|
1308123
1308283
|
logger.debug("File written successfully");
|
|
1308124
1308284
|
}
|
|
@@ -1308206,7 +1308366,7 @@ async function updateApiSpec({
|
|
|
1308206
1308366
|
}
|
|
1308207
1308367
|
|
|
1308208
1308368
|
// ../yaml/yaml-migrations/lib/migrations/0.0.191/discriminant/migration.js
|
|
1308209
|
-
var
|
|
1308369
|
+
var import_promises59 = require("fs/promises");
|
|
1308210
1308370
|
|
|
1308211
1308371
|
// ../yaml/yaml-migrations/lib/migrations/0.0.191/discriminant/getAllYamlFiles.js
|
|
1308212
1308372
|
var import_glob_promise2 = __toESM(require_lib(), 1);
|
|
@@ -1308240,7 +1308400,7 @@ var migration = {
|
|
|
1308240
1308400
|
try {
|
|
1308241
1308401
|
const fileContents = await getFileContents(yamlFilepath);
|
|
1308242
1308402
|
const newContents = addDiscriminantToFile(fileContents);
|
|
1308243
|
-
await (0,
|
|
1308403
|
+
await (0, import_promises59.writeFile)(yamlFilepath, newContents);
|
|
1308244
1308404
|
} catch (error) {
|
|
1308245
1308405
|
context.failAndThrow("Failed to migrate " + yamlFilepath, error);
|
|
1308246
1308406
|
}
|
|
@@ -1308248,7 +1308408,7 @@ var migration = {
|
|
|
1308248
1308408
|
}
|
|
1308249
1308409
|
};
|
|
1308250
1308410
|
async function getFileContents(filepath) {
|
|
1308251
|
-
const buffer = await (0,
|
|
1308411
|
+
const buffer = await (0, import_promises59.readFile)(filepath);
|
|
1308252
1308412
|
return buffer.toString();
|
|
1308253
1308413
|
}
|
|
1308254
1308414
|
var UNION_REGEX = /^(\s{2,})union:\s*$/gm;
|
|
@@ -1308277,8 +1308437,8 @@ var versionMigrations = {
|
|
|
1308277
1308437
|
var __default = versionMigrations;
|
|
1308278
1308438
|
|
|
1308279
1308439
|
// ../yaml/yaml-migrations/lib/migrations/0.0.203/union-single-property-key/migration.js
|
|
1308280
|
-
var
|
|
1308281
|
-
var
|
|
1308440
|
+
var import_promises60 = require("fs/promises");
|
|
1308441
|
+
var import_yaml3 = __toESM(require_dist5(), 1);
|
|
1308282
1308442
|
|
|
1308283
1308443
|
// ../yaml/yaml-migrations/lib/migrations/0.0.203/union-single-property-key/getAllYamlFiles.js
|
|
1308284
1308444
|
var import_glob_promise3 = __toESM(require_lib(), 1);
|
|
@@ -1308318,39 +1308478,39 @@ var migration2 = {
|
|
|
1308318
1308478
|
}
|
|
1308319
1308479
|
};
|
|
1308320
1308480
|
async function migrateFile(filepath, context) {
|
|
1308321
|
-
const contents = await (0,
|
|
1308322
|
-
const parsedDocument =
|
|
1308481
|
+
const contents = await (0, import_promises60.readFile)(filepath);
|
|
1308482
|
+
const parsedDocument = import_yaml3.default.parseDocument(contents.toString());
|
|
1308323
1308483
|
const types3 = parsedDocument.get("types");
|
|
1308324
1308484
|
if (types3 == null) {
|
|
1308325
1308485
|
return;
|
|
1308326
1308486
|
}
|
|
1308327
|
-
if (!
|
|
1308487
|
+
if (!import_yaml3.default.isMap(types3)) {
|
|
1308328
1308488
|
context.failWithoutThrowing(`"types" is not a map in ${filepath}`);
|
|
1308329
1308489
|
return;
|
|
1308330
1308490
|
}
|
|
1308331
1308491
|
for (const typeDeclaration of types3.items) {
|
|
1308332
|
-
if (
|
|
1308492
|
+
if (import_yaml3.default.isMap(typeDeclaration.value)) {
|
|
1308333
1308493
|
const union4 = typeDeclaration.value.get("union");
|
|
1308334
1308494
|
if (union4 == null) {
|
|
1308335
1308495
|
continue;
|
|
1308336
1308496
|
}
|
|
1308337
|
-
if (!
|
|
1308497
|
+
if (!import_yaml3.default.isMap(union4)) {
|
|
1308338
1308498
|
context.failWithoutThrowing(`"union" is not a map in ${filepath}`);
|
|
1308339
1308499
|
continue;
|
|
1308340
1308500
|
}
|
|
1308341
1308501
|
for (const singleUnionType of union4.items) {
|
|
1308342
|
-
if (
|
|
1308502
|
+
if (import_yaml3.default.isScalar(singleUnionType.value)) {
|
|
1308343
1308503
|
singleUnionType.value = {
|
|
1308344
1308504
|
type: singleUnionType.value,
|
|
1308345
1308505
|
key: singleUnionType.key
|
|
1308346
1308506
|
};
|
|
1308347
|
-
} else if (
|
|
1308348
|
-
singleUnionType.value.add(new
|
|
1308507
|
+
} else if (import_yaml3.default.isMap(singleUnionType.value)) {
|
|
1308508
|
+
singleUnionType.value.add(new import_yaml3.default.Pair("key", singleUnionType.key));
|
|
1308349
1308509
|
}
|
|
1308350
1308510
|
}
|
|
1308351
1308511
|
}
|
|
1308352
1308512
|
}
|
|
1308353
|
-
await (0,
|
|
1308513
|
+
await (0, import_promises60.writeFile)(filepath, parsedDocument.toString());
|
|
1308354
1308514
|
}
|
|
1308355
1308515
|
|
|
1308356
1308516
|
// ../yaml/yaml-migrations/lib/migrations/0.0.203/index.js
|
|
@@ -1308361,8 +1308521,8 @@ var versionMigrations2 = {
|
|
|
1308361
1308521
|
var __default2 = versionMigrations2;
|
|
1308362
1308522
|
|
|
1308363
1308523
|
// ../yaml/yaml-migrations/lib/migrations/0.0.207/add-mode-to-draft-generators/migration.js
|
|
1308364
|
-
var
|
|
1308365
|
-
var
|
|
1308524
|
+
var import_promises61 = require("fs/promises");
|
|
1308525
|
+
var import_yaml4 = __toESM(require_dist5(), 1);
|
|
1308366
1308526
|
|
|
1308367
1308527
|
// ../yaml/yaml-migrations/lib/migrations/0.0.207/add-mode-to-draft-generators/getAllGeneratorYamlFiles.js
|
|
1308368
1308528
|
var import_glob_promise4 = __toESM(require_lib(), 1);
|
|
@@ -1308402,18 +1308562,18 @@ var migration3 = {
|
|
|
1308402
1308562
|
}
|
|
1308403
1308563
|
};
|
|
1308404
1308564
|
async function migrateGeneratorsYml(filepath, context) {
|
|
1308405
|
-
const contents = await (0,
|
|
1308406
|
-
const parsedDocument =
|
|
1308565
|
+
const contents = await (0, import_promises61.readFile)(filepath);
|
|
1308566
|
+
const parsedDocument = import_yaml4.default.parseDocument(contents.toString());
|
|
1308407
1308567
|
const draftGenerators = parsedDocument.get("draft");
|
|
1308408
1308568
|
if (draftGenerators == null) {
|
|
1308409
1308569
|
return;
|
|
1308410
1308570
|
}
|
|
1308411
|
-
if (!
|
|
1308571
|
+
if (!import_yaml4.default.isSeq(draftGenerators)) {
|
|
1308412
1308572
|
context.failWithoutThrowing(`draft generators are not a list in ${filepath}`);
|
|
1308413
1308573
|
return;
|
|
1308414
1308574
|
}
|
|
1308415
1308575
|
draftGenerators.items.forEach((draftGenerator) => {
|
|
1308416
|
-
if (!
|
|
1308576
|
+
if (!import_yaml4.default.isMap(draftGenerator)) {
|
|
1308417
1308577
|
context.failWithoutThrowing(`draft generator is not an object in ${filepath}`);
|
|
1308418
1308578
|
return;
|
|
1308419
1308579
|
}
|
|
@@ -1308429,7 +1308589,7 @@ async function migrateGeneratorsYml(filepath, context) {
|
|
|
1308429
1308589
|
draftGenerator.set("output-path", name2.value.includes("openapi") ? "./generated-openapi" : name2.value.includes("postman") ? "./generated-postman" : localOutput);
|
|
1308430
1308590
|
}
|
|
1308431
1308591
|
});
|
|
1308432
|
-
await (0,
|
|
1308592
|
+
await (0, import_promises61.writeFile)(filepath, parsedDocument.toString());
|
|
1308433
1308593
|
}
|
|
1308434
1308594
|
|
|
1308435
1308595
|
// ../yaml/yaml-migrations/lib/migrations/0.0.207/index.js
|
|
@@ -1308440,8 +1308600,8 @@ var versionMigrations3 = {
|
|
|
1308440
1308600
|
var __default3 = versionMigrations3;
|
|
1308441
1308601
|
|
|
1308442
1308602
|
// ../yaml/yaml-migrations/lib/migrations/0.0.210/remove-inline-error-declarations/migration.js
|
|
1308443
|
-
var
|
|
1308444
|
-
var
|
|
1308603
|
+
var import_promises62 = require("fs/promises");
|
|
1308604
|
+
var import_yaml5 = __toESM(require_dist5(), 1);
|
|
1308445
1308605
|
|
|
1308446
1308606
|
// ../yaml/yaml-migrations/lib/migrations/0.0.210/remove-inline-error-declarations/getAllYamlFiles.js
|
|
1308447
1308607
|
var import_glob_promise5 = __toESM(require_lib(), 1);
|
|
@@ -1308481,15 +1308641,15 @@ var migration4 = {
|
|
|
1308481
1308641
|
}
|
|
1308482
1308642
|
};
|
|
1308483
1308643
|
async function migrateFile2(filepath, context) {
|
|
1308484
|
-
const contents = await (0,
|
|
1308485
|
-
const parsedDocument =
|
|
1308644
|
+
const contents = await (0, import_promises62.readFile)(filepath);
|
|
1308645
|
+
const parsedDocument = import_yaml5.default.parseDocument(contents.toString());
|
|
1308486
1308646
|
const addType = (typeName, typeDeclaration) => {
|
|
1308487
1308647
|
const types3 = parsedDocument.get("types");
|
|
1308488
1308648
|
if (types3 == null) {
|
|
1308489
1308649
|
parsedDocument.set("types", {
|
|
1308490
1308650
|
[typeName]: typeDeclaration
|
|
1308491
1308651
|
});
|
|
1308492
|
-
} else if (!
|
|
1308652
|
+
} else if (!import_yaml5.default.isMap(types3)) {
|
|
1308493
1308653
|
context.failWithoutThrowing(`"types" is not a map in ${filepath}`);
|
|
1308494
1308654
|
} else {
|
|
1308495
1308655
|
types3.set(typeName, typeDeclaration);
|
|
@@ -1308499,12 +1308659,12 @@ async function migrateFile2(filepath, context) {
|
|
|
1308499
1308659
|
if (errors2 == null) {
|
|
1308500
1308660
|
return;
|
|
1308501
1308661
|
}
|
|
1308502
|
-
if (!
|
|
1308662
|
+
if (!import_yaml5.default.isMap(errors2)) {
|
|
1308503
1308663
|
context.failWithoutThrowing(`"errors" is not a map in ${filepath}`);
|
|
1308504
1308664
|
return;
|
|
1308505
1308665
|
}
|
|
1308506
1308666
|
for (const errorDeclaration of errors2.items) {
|
|
1308507
|
-
if (!
|
|
1308667
|
+
if (!import_yaml5.default.isMap(errorDeclaration.value)) {
|
|
1308508
1308668
|
context.failWithoutThrowing(`Error "${errorDeclaration.key}" is not a map in ${filepath}`);
|
|
1308509
1308669
|
continue;
|
|
1308510
1308670
|
}
|
|
@@ -1308516,7 +1308676,7 @@ async function migrateFile2(filepath, context) {
|
|
|
1308516
1308676
|
}
|
|
1308517
1308677
|
const httpSection = errorDeclaration.value.get("http");
|
|
1308518
1308678
|
if (httpSection != null) {
|
|
1308519
|
-
if (!
|
|
1308679
|
+
if (!import_yaml5.default.isMap(httpSection)) {
|
|
1308520
1308680
|
context.failWithoutThrowing(`http in "${errorDeclaration.key}" is not a map in ${filepath}`);
|
|
1308521
1308681
|
} else {
|
|
1308522
1308682
|
const statusCode = httpSection.get("statusCode", true);
|
|
@@ -1308525,7 +1308685,7 @@ async function migrateFile2(filepath, context) {
|
|
|
1308525
1308685
|
}
|
|
1308526
1308686
|
}
|
|
1308527
1308687
|
}
|
|
1308528
|
-
await (0,
|
|
1308688
|
+
await (0, import_promises62.writeFile)(filepath, parsedDocument.toString());
|
|
1308529
1308689
|
}
|
|
1308530
1308690
|
|
|
1308531
1308691
|
// ../yaml/yaml-migrations/lib/migrations/0.0.210/index.js
|
|
@@ -1308536,8 +1308696,8 @@ var versionMigrations4 = {
|
|
|
1308536
1308696
|
var __default4 = versionMigrations4;
|
|
1308537
1308697
|
|
|
1308538
1308698
|
// ../yaml/yaml-migrations/lib/migrations/0.0.212/add-publishing-to-release-generators/migration.js
|
|
1308539
|
-
var
|
|
1308540
|
-
var
|
|
1308699
|
+
var import_promises63 = require("fs/promises");
|
|
1308700
|
+
var import_yaml6 = __toESM(require_dist5(), 1);
|
|
1308541
1308701
|
|
|
1308542
1308702
|
// ../yaml/yaml-migrations/lib/migrations/0.0.212/add-publishing-to-release-generators/getAllGeneratorYamlFiles.js
|
|
1308543
1308703
|
var import_glob_promise6 = __toESM(require_lib(), 1);
|
|
@@ -1308577,37 +1308737,37 @@ var migration5 = {
|
|
|
1308577
1308737
|
}
|
|
1308578
1308738
|
};
|
|
1308579
1308739
|
async function migrateGeneratorsYml2(filepath, context) {
|
|
1308580
|
-
const contents = await (0,
|
|
1308581
|
-
const parsedDocument =
|
|
1308740
|
+
const contents = await (0, import_promises63.readFile)(filepath);
|
|
1308741
|
+
const parsedDocument = import_yaml6.default.parseDocument(contents.toString());
|
|
1308582
1308742
|
const releaseGenerators = parsedDocument.get("release");
|
|
1308583
1308743
|
if (releaseGenerators == null) {
|
|
1308584
1308744
|
return;
|
|
1308585
1308745
|
}
|
|
1308586
|
-
if (!
|
|
1308746
|
+
if (!import_yaml6.default.isSeq(releaseGenerators)) {
|
|
1308587
1308747
|
context.failWithoutThrowing(`release generators are not a list in ${filepath}`);
|
|
1308588
1308748
|
return;
|
|
1308589
1308749
|
}
|
|
1308590
1308750
|
releaseGenerators.items.forEach((releaseGenerator) => {
|
|
1308591
|
-
if (!
|
|
1308751
|
+
if (!import_yaml6.default.isMap(releaseGenerator)) {
|
|
1308592
1308752
|
context.failWithoutThrowing(`release generator is not an object in ${filepath}`);
|
|
1308593
1308753
|
return;
|
|
1308594
1308754
|
}
|
|
1308595
1308755
|
const outputs = releaseGenerator.get("outputs");
|
|
1308596
|
-
if (!
|
|
1308756
|
+
if (!import_yaml6.default.isMap(outputs)) {
|
|
1308597
1308757
|
context.failWithoutThrowing(`outputs is not an object in ${filepath}`);
|
|
1308598
1308758
|
return;
|
|
1308599
1308759
|
}
|
|
1308600
1308760
|
const githubOutput = outputs.get("github");
|
|
1308601
|
-
if (
|
|
1308761
|
+
if (import_yaml6.default.isMap(githubOutput) && githubOutput.has("repository")) {
|
|
1308602
1308762
|
releaseGenerator.set("github", githubOutput);
|
|
1308603
1308763
|
}
|
|
1308604
1308764
|
const publishing = {};
|
|
1308605
1308765
|
const npmOutput = outputs.get("npm");
|
|
1308606
|
-
if (
|
|
1308766
|
+
if (import_yaml6.default.isMap(npmOutput)) {
|
|
1308607
1308767
|
publishing.npm = npmOutput;
|
|
1308608
1308768
|
}
|
|
1308609
1308769
|
const mavenOutput = outputs.get("maven");
|
|
1308610
|
-
if (
|
|
1308770
|
+
if (import_yaml6.default.isMap(mavenOutput)) {
|
|
1308611
1308771
|
publishing.maven = mavenOutput;
|
|
1308612
1308772
|
}
|
|
1308613
1308773
|
if (Object.keys(publishing).length > 0) {
|
|
@@ -1308615,7 +1308775,7 @@ async function migrateGeneratorsYml2(filepath, context) {
|
|
|
1308615
1308775
|
}
|
|
1308616
1308776
|
releaseGenerator.delete("outputs");
|
|
1308617
1308777
|
});
|
|
1308618
|
-
await (0,
|
|
1308778
|
+
await (0, import_promises63.writeFile)(filepath, parsedDocument.toString());
|
|
1308619
1308779
|
}
|
|
1308620
1308780
|
|
|
1308621
1308781
|
// ../yaml/yaml-migrations/lib/migrations/0.0.212/index.js
|
|
@@ -1308626,7 +1308786,7 @@ var versionMigrations5 = {
|
|
|
1308626
1308786
|
var __default5 = versionMigrations5;
|
|
1308627
1308787
|
|
|
1308628
1308788
|
// ../yaml/yaml-migrations/lib/migrations/0.0.220/rename-alias-key-to-type/migration.js
|
|
1308629
|
-
var
|
|
1308789
|
+
var import_promises64 = require("fs/promises");
|
|
1308630
1308790
|
|
|
1308631
1308791
|
// ../yaml/yaml-migrations/lib/migrations/0.0.220/rename-alias-key-to-type/getAllYamlFiles.js
|
|
1308632
1308792
|
var import_glob_promise7 = __toESM(require_lib(), 1);
|
|
@@ -1308657,9 +1308817,9 @@ var migration6 = {
|
|
|
1308657
1308817
|
run: async ({ context }) => {
|
|
1308658
1308818
|
const yamlFiles = await getAllYamlFiles4(context);
|
|
1308659
1308819
|
for (const filepath of yamlFiles) {
|
|
1308660
|
-
const contents = await (0,
|
|
1308820
|
+
const contents = await (0, import_promises64.readFile)(filepath);
|
|
1308661
1308821
|
const newContents = contents.toString().replaceAll(" alias:", " type:");
|
|
1308662
|
-
await (0,
|
|
1308822
|
+
await (0, import_promises64.writeFile)(filepath, newContents);
|
|
1308663
1308823
|
}
|
|
1308664
1308824
|
}
|
|
1308665
1308825
|
};
|
|
@@ -1308672,7 +1308832,7 @@ var versionMigrations6 = {
|
|
|
1308672
1308832
|
var __default6 = versionMigrations6;
|
|
1308673
1308833
|
|
|
1308674
1308834
|
// ../yaml/yaml-migrations/lib/migrations/0.0.221/add-error-discriminant/migration.js
|
|
1308675
|
-
var
|
|
1308835
|
+
var import_promises65 = require("fs/promises");
|
|
1308676
1308836
|
|
|
1308677
1308837
|
// ../yaml/yaml-migrations/lib/migrations/0.0.221/add-error-discriminant/getAllRootApiYamlFiles.js
|
|
1308678
1308838
|
var import_glob_promise8 = __toESM(require_lib(), 1);
|
|
@@ -1308703,9 +1308863,9 @@ var migration7 = {
|
|
|
1308703
1308863
|
run: async ({ context }) => {
|
|
1308704
1308864
|
const yamlFiles = await getAllRootApiYamlFiles(context);
|
|
1308705
1308865
|
for (const filepath of yamlFiles) {
|
|
1308706
|
-
const contents = await (0,
|
|
1308866
|
+
const contents = await (0, import_promises65.readFile)(filepath);
|
|
1308707
1308867
|
const newContents = contents.toString() + "\nerror-discriminant: error";
|
|
1308708
|
-
await (0,
|
|
1308868
|
+
await (0, import_promises65.writeFile)(filepath, newContents);
|
|
1308709
1308869
|
}
|
|
1308710
1308870
|
}
|
|
1308711
1308871
|
};
|
|
@@ -1308718,7 +1308878,7 @@ var versionMigrations7 = {
|
|
|
1308718
1308878
|
var __default7 = versionMigrations7;
|
|
1308719
1308879
|
|
|
1308720
1308880
|
// ../yaml/yaml-migrations/lib/migrations/0.0.241/add-generator-groups/migration.js
|
|
1308721
|
-
var
|
|
1308881
|
+
var import_promises66 = require("fs/promises");
|
|
1308722
1308882
|
|
|
1308723
1308883
|
// ../yaml/yaml-migrations/lib/migrations/0.0.241/add-generator-groups/getAllGeneratorYamlFiles.js
|
|
1308724
1308884
|
var import_glob_promise9 = __toESM(require_lib(), 1);
|
|
@@ -1308825,7 +1308985,7 @@ var migration8 = {
|
|
|
1308825
1308985
|
}
|
|
1308826
1308986
|
};
|
|
1308827
1308987
|
async function migrateGeneratorsYml3(filepath) {
|
|
1308828
|
-
const contentsStr = await (0,
|
|
1308988
|
+
const contentsStr = await (0, import_promises66.readFile)(filepath);
|
|
1308829
1308989
|
const contents = js_yaml_default.load(contentsStr.toString());
|
|
1308830
1308990
|
const oldGeneratorsConfiguration = GeneratorsConfigurationSchema2.parse(contents);
|
|
1308831
1308991
|
let newGeneratorsConfiguration = {};
|
|
@@ -1308843,7 +1309003,7 @@ async function migrateGeneratorsYml3(filepath) {
|
|
|
1308843
1309003
|
generators: oldGeneratorsConfiguration.release.map((releaseGeneratorInvocation) => convertReleaseGeneratorInvocation(releaseGeneratorInvocation))
|
|
1308844
1309004
|
};
|
|
1308845
1309005
|
}
|
|
1308846
|
-
await (0,
|
|
1309006
|
+
await (0, import_promises66.writeFile)(filepath, js_yaml_default.dump(newGeneratorsConfiguration));
|
|
1308847
1309007
|
}
|
|
1308848
1309008
|
function convertDraftGeneratorInvocation(draftGeneratorInvocation) {
|
|
1308849
1309009
|
const newSchema = {
|
|
@@ -1308918,8 +1309078,8 @@ var versionMigrations8 = {
|
|
|
1308918
1309078
|
var __default8 = versionMigrations8;
|
|
1308919
1309079
|
|
|
1308920
1309080
|
// ../yaml/yaml-migrations/lib/migrations/0.0.248/add-error-discrimination-config/migration.js
|
|
1308921
|
-
var
|
|
1308922
|
-
var
|
|
1309081
|
+
var import_promises67 = require("fs/promises");
|
|
1309082
|
+
var import_yaml7 = __toESM(require_dist5(), 1);
|
|
1308923
1309083
|
|
|
1308924
1309084
|
// ../yaml/yaml-migrations/lib/migrations/0.0.248/add-error-discrimination-config/getAllRootApiYamlFiles.js
|
|
1308925
1309085
|
var import_glob_promise10 = __toESM(require_lib(), 1);
|
|
@@ -1308959,10 +1309119,10 @@ var migration9 = {
|
|
|
1308959
1309119
|
}
|
|
1308960
1309120
|
};
|
|
1308961
1309121
|
async function migrateRootApiFile(filepath) {
|
|
1308962
|
-
const contents = await (0,
|
|
1308963
|
-
const parsedDocument =
|
|
1309122
|
+
const contents = await (0, import_promises67.readFile)(filepath);
|
|
1309123
|
+
const parsedDocument = import_yaml7.default.parseDocument(contents.toString());
|
|
1308964
1309124
|
const errorDiscriminant = parsedDocument.get("error-discriminant", true);
|
|
1308965
|
-
if (errorDiscriminant == null || !
|
|
1309125
|
+
if (errorDiscriminant == null || !import_yaml7.default.isScalar(errorDiscriminant) || typeof errorDiscriminant.value !== "string") {
|
|
1308966
1309126
|
return;
|
|
1308967
1309127
|
}
|
|
1308968
1309128
|
parsedDocument.set("error-discrimination", {
|
|
@@ -1308970,7 +1309130,7 @@ async function migrateRootApiFile(filepath) {
|
|
|
1308970
1309130
|
"property-name": errorDiscriminant.value
|
|
1308971
1309131
|
});
|
|
1308972
1309132
|
parsedDocument.delete("error-discriminant");
|
|
1308973
|
-
await (0,
|
|
1309133
|
+
await (0, import_promises67.writeFile)(filepath, parsedDocument.toString());
|
|
1308974
1309134
|
}
|
|
1308975
1309135
|
|
|
1308976
1309136
|
// ../yaml/yaml-migrations/lib/migrations/0.0.248/index.js
|
|
@@ -1308981,8 +1309141,8 @@ var versionMigrations9 = {
|
|
|
1308981
1309141
|
var __default9 = versionMigrations9;
|
|
1308982
1309142
|
|
|
1308983
1309143
|
// ../yaml/yaml-migrations/lib/migrations/0.1.3-rc3/add-inline-requests/migration.js
|
|
1308984
|
-
var
|
|
1308985
|
-
var
|
|
1309144
|
+
var import_promises68 = require("fs/promises");
|
|
1309145
|
+
var import_yaml8 = __toESM(require_dist5(), 1);
|
|
1308986
1309146
|
|
|
1308987
1309147
|
// ../yaml/yaml-migrations/lib/migrations/0.1.3-rc3/add-inline-requests/getAllYamlFiles.js
|
|
1308988
1309148
|
var import_glob_promise11 = __toESM(require_lib(), 1);
|
|
@@ -1309022,24 +1309182,24 @@ var migration10 = {
|
|
|
1309022
1309182
|
}
|
|
1309023
1309183
|
};
|
|
1309024
1309184
|
async function migrateYamlFile(filepath, context) {
|
|
1309025
|
-
const contents = await (0,
|
|
1309026
|
-
const parsedDocument =
|
|
1309185
|
+
const contents = await (0, import_promises68.readFile)(filepath);
|
|
1309186
|
+
const parsedDocument = import_yaml8.default.parseDocument(contents.toString());
|
|
1309027
1309187
|
const services = parsedDocument.get("services");
|
|
1309028
1309188
|
if (services == null) {
|
|
1309029
1309189
|
return;
|
|
1309030
1309190
|
}
|
|
1309031
|
-
if (!
|
|
1309191
|
+
if (!import_yaml8.default.isMap(services)) {
|
|
1309032
1309192
|
throw new Error("'services' is not a map");
|
|
1309033
1309193
|
}
|
|
1309034
1309194
|
const httpServices = services.get("http");
|
|
1309035
1309195
|
if (httpServices == null) {
|
|
1309036
1309196
|
return;
|
|
1309037
1309197
|
}
|
|
1309038
|
-
if (!
|
|
1309198
|
+
if (!import_yaml8.default.isMap(httpServices)) {
|
|
1309039
1309199
|
throw new Error("'http' is not a map");
|
|
1309040
1309200
|
}
|
|
1309041
1309201
|
for (const service of httpServices.items) {
|
|
1309042
|
-
if (!
|
|
1309202
|
+
if (!import_yaml8.default.isMap(service.value)) {
|
|
1309043
1309203
|
context.failWithoutThrowing(`Service '${service.key}' is not a map`);
|
|
1309044
1309204
|
continue;
|
|
1309045
1309205
|
}
|
|
@@ -1309047,12 +1309207,12 @@ async function migrateYamlFile(filepath, context) {
|
|
|
1309047
1309207
|
if (endpoints == null) {
|
|
1309048
1309208
|
continue;
|
|
1309049
1309209
|
}
|
|
1309050
|
-
if (!
|
|
1309210
|
+
if (!import_yaml8.default.isMap(endpoints)) {
|
|
1309051
1309211
|
context.failWithoutThrowing(`Endpoints are not a map in service '${service.key}'`);
|
|
1309052
1309212
|
continue;
|
|
1309053
1309213
|
}
|
|
1309054
1309214
|
for (const endpoint of endpoints.items) {
|
|
1309055
|
-
if (!
|
|
1309215
|
+
if (!import_yaml8.default.isMap(endpoint.value)) {
|
|
1309056
1309216
|
context.failWithoutThrowing(`Endpoint ${endpoint.key} is not a map in service '${service.key}'`);
|
|
1309057
1309217
|
continue;
|
|
1309058
1309218
|
}
|
|
@@ -1309062,14 +1309222,14 @@ async function migrateYamlFile(filepath, context) {
|
|
|
1309062
1309222
|
context.failWithoutThrowing("Failed to convert endpoint", e);
|
|
1309063
1309223
|
}
|
|
1309064
1309224
|
}
|
|
1309065
|
-
await (0,
|
|
1309225
|
+
await (0, import_promises68.writeFile)(filepath, parsedDocument.toString());
|
|
1309066
1309226
|
}
|
|
1309067
1309227
|
}
|
|
1309068
1309228
|
function convertEndpoint18({ document: document4, endpoint }) {
|
|
1309069
|
-
const newRequest = new
|
|
1309229
|
+
const newRequest = new import_yaml8.default.YAMLMap();
|
|
1309070
1309230
|
const parsedRequestBody = parseRequestBody(endpoint);
|
|
1309071
1309231
|
if (parsedRequestBody != null) {
|
|
1309072
|
-
let newBody = new
|
|
1309232
|
+
let newBody = new import_yaml8.default.YAMLMap();
|
|
1309073
1309233
|
const { requestBodyType, docs: originalRequestDocs } = parsedRequestBody;
|
|
1309074
1309234
|
if (originalRequestDocs != null) {
|
|
1309075
1309235
|
newBody.set("docs", originalRequestDocs);
|
|
@@ -1309077,11 +1309237,11 @@ function convertEndpoint18({ document: document4, endpoint }) {
|
|
|
1309077
1309237
|
newBody.set("type", requestBodyType);
|
|
1309078
1309238
|
const documentTypes = document4.get("types");
|
|
1309079
1309239
|
if (documentTypes != null) {
|
|
1309080
|
-
if (!
|
|
1309240
|
+
if (!import_yaml8.default.isMap(documentTypes)) {
|
|
1309081
1309241
|
throw new Error("types are not a map");
|
|
1309082
1309242
|
}
|
|
1309083
1309243
|
const maybeTypeDeclarationForRequest = documentTypes.get(requestBodyType);
|
|
1309084
|
-
if (maybeTypeDeclarationForRequest != null &&
|
|
1309244
|
+
if (maybeTypeDeclarationForRequest != null && import_yaml8.default.isMap(maybeTypeDeclarationForRequest)) {
|
|
1309085
1309245
|
const objectExtends = maybeTypeDeclarationForRequest.get("extends");
|
|
1309086
1309246
|
const objectProperties = maybeTypeDeclarationForRequest.get("properties");
|
|
1309087
1309247
|
if (objectExtends != null || objectProperties != null) {
|
|
@@ -1309116,7 +1309276,7 @@ function parseRequestBody(endpoint) {
|
|
|
1309116
1309276
|
if (typeof requestBody === "string") {
|
|
1309117
1309277
|
return { requestBodyType: requestBody, docs: void 0 };
|
|
1309118
1309278
|
}
|
|
1309119
|
-
if (
|
|
1309279
|
+
if (import_yaml8.default.isMap(requestBody)) {
|
|
1309120
1309280
|
const type2 = requestBody.get("type");
|
|
1309121
1309281
|
if (type2 == null) {
|
|
1309122
1309282
|
throw new Error("request type does not exist");
|
|
@@ -1309146,10 +1309306,10 @@ var import_legacy_docs_config = __toESM(require_legacy_docs_config(), 1);
|
|
|
1309146
1309306
|
var LegacyDocsSerializers = __toESM(require_serialization34(), 1);
|
|
1309147
1309307
|
|
|
1309148
1309308
|
// ../yaml/yaml-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/docs-config/loadRawDocsConfiguration.js
|
|
1309149
|
-
var
|
|
1309309
|
+
var import_promises69 = require("fs/promises");
|
|
1309150
1309310
|
async function loadRawDocsConfiguration2({ absolutePathToWorkspace }) {
|
|
1309151
1309311
|
const filepath = getAbsolutePathToDocsYaml({ absolutePathToWorkspace });
|
|
1309152
|
-
const contentsStr = await (0,
|
|
1309312
|
+
const contentsStr = await (0, import_promises69.readFile)(filepath);
|
|
1309153
1309313
|
const contentsParsed = js_yaml_default.load(contentsStr.toString());
|
|
1309154
1309314
|
const result = await LegacyDocsSerializers.DocsConfiguration.parse(contentsParsed);
|
|
1309155
1309315
|
if (result.ok) {
|
|
@@ -1309167,7 +1309327,7 @@ function getAbsolutePathToDocsFolder({ absolutePathToWorkspace }) {
|
|
|
1309167
1309327
|
}
|
|
1309168
1309328
|
|
|
1309169
1309329
|
// ../yaml/yaml-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateDocsAndMultipleAPIs.js
|
|
1309170
|
-
var
|
|
1309330
|
+
var import_promises71 = require("fs/promises");
|
|
1309171
1309331
|
|
|
1309172
1309332
|
// ../yaml/yaml-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/docs-config/convertLegacyDocsConfig.js
|
|
1309173
1309333
|
function convertLegacyDocsConfig({ docsConfiguration, docsURLs, apiName }) {
|
|
@@ -1309348,10 +1309508,10 @@ __export(legacy_exports, {
|
|
|
1309348
1309508
|
});
|
|
1309349
1309509
|
|
|
1309350
1309510
|
// ../yaml/yaml-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/generators-configuration/loadRawGeneratorsConfiguration.js
|
|
1309351
|
-
var
|
|
1309511
|
+
var import_promises70 = require("fs/promises");
|
|
1309352
1309512
|
async function loadRawGeneratorsConfiguration2({ absolutePathToWorkspace }) {
|
|
1309353
1309513
|
const filepath = getAbsolutePathToGeneratorsConfiguration({ absolutePathToWorkspace });
|
|
1309354
|
-
const contentsStr = await (0,
|
|
1309514
|
+
const contentsStr = await (0, import_promises70.readFile)(filepath);
|
|
1309355
1309515
|
const contentsParsed = js_yaml_default.load(contentsStr.toString());
|
|
1309356
1309516
|
const result = await legacy_exports.GeneratorsConfigurationSchema.safeParseAsync(contentsParsed);
|
|
1309357
1309517
|
if (result.success) {
|
|
@@ -1309381,7 +1309541,7 @@ function migrateDocsInstances(docsURLs) {
|
|
|
1309381
1309541
|
var APIS_DIRECTORY2 = "apis";
|
|
1309382
1309542
|
async function migrateDocsAndMultipleAPIs({ absolutePathToFernDirectory, workspaces, workspaceContainingDocs }) {
|
|
1309383
1309543
|
const absolutePathToApisDirectory = join(absolutePathToFernDirectory, RelativeFilePath.of(APIS_DIRECTORY2));
|
|
1309384
|
-
await (0,
|
|
1309544
|
+
await (0, import_promises71.mkdir)(absolutePathToApisDirectory);
|
|
1309385
1309545
|
for (const workspace of workspaces) {
|
|
1309386
1309546
|
const absolutePathToWorkspace = join(absolutePathToFernDirectory, RelativeFilePath.of(workspace));
|
|
1309387
1309547
|
const docsURLs = await migrateAndWriteGeneratorsYml({ absolutePathToWorkspace });
|
|
@@ -1309389,11 +1309549,11 @@ async function migrateDocsAndMultipleAPIs({ absolutePathToFernDirectory, workspa
|
|
|
1309389
1309549
|
await migrateAndWriteDocsYml({ absolutePathToWorkspace, docsURLs, apiName: workspaceContainingDocs });
|
|
1309390
1309550
|
const absolutePathToDocsFolder = getAbsolutePathToDocsFolder({ absolutePathToWorkspace });
|
|
1309391
1309551
|
await moveFolder({ src: absolutePathToDocsFolder, dest: absolutePathToFernDirectory });
|
|
1309392
|
-
await (0,
|
|
1309552
|
+
await (0, import_promises71.rm)(absolutePathToDocsFolder, { recursive: true });
|
|
1309393
1309553
|
}
|
|
1309394
1309554
|
const absolutePathToNestedWorkspace = join(absolutePathToApisDirectory, RelativeFilePath.of(workspace));
|
|
1309395
1309555
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToNestedWorkspace });
|
|
1309396
|
-
await (0,
|
|
1309556
|
+
await (0, import_promises71.rm)(absolutePathToWorkspace, { recursive: true });
|
|
1309397
1309557
|
}
|
|
1309398
1309558
|
}
|
|
1309399
1309559
|
async function migrateAndWriteGeneratorsYml({ absolutePathToWorkspace }) {
|
|
@@ -1309406,7 +1309566,7 @@ async function migrateAndWriteGeneratorsYml({ absolutePathToWorkspace }) {
|
|
|
1309406
1309566
|
generatorsConfiguration,
|
|
1309407
1309567
|
pathModificationStrategy: PathModificationStrategy.Nest
|
|
1309408
1309568
|
});
|
|
1309409
|
-
await (0,
|
|
1309569
|
+
await (0, import_promises71.writeFile)(absolutePathToGeneratorsConfiguration, js_yaml_default.dump(convertedResponse.value));
|
|
1309410
1309570
|
return convertedResponse.docsURLs;
|
|
1309411
1309571
|
}
|
|
1309412
1309572
|
async function migrateAndWriteDocsYml({ absolutePathToWorkspace, docsURLs, apiName }) {
|
|
@@ -1309420,19 +1309580,19 @@ async function migrateAndWriteDocsYml({ absolutePathToWorkspace, docsURLs, apiNa
|
|
|
1309420
1309580
|
apiName
|
|
1309421
1309581
|
});
|
|
1309422
1309582
|
const absolutePathToDocsConfig = getAbsolutePathToDocsYaml({ absolutePathToWorkspace });
|
|
1309423
|
-
await (0,
|
|
1309583
|
+
await (0, import_promises71.writeFile)(absolutePathToDocsConfig, js_yaml_default.dump(convertedDocsConfig));
|
|
1309424
1309584
|
}
|
|
1309425
1309585
|
|
|
1309426
1309586
|
// ../yaml/yaml-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateDocsAndSingleAPI.js
|
|
1309427
|
-
var
|
|
1309587
|
+
var import_promises72 = require("fs/promises");
|
|
1309428
1309588
|
async function migrateDocsAndSingleAPI({ absolutePathToFernDirectory, absolutePathToWorkspace }) {
|
|
1309429
1309589
|
const docsURLs = await migrateAndWriteGeneratorsYml2({ absolutePathToWorkspace });
|
|
1309430
1309590
|
await migrateAndWriteDocsYml2({ absolutePathToWorkspace, docsURLs });
|
|
1309431
1309591
|
const absolutePathToDocsFolder = getAbsolutePathToDocsFolder({ absolutePathToWorkspace });
|
|
1309432
1309592
|
await moveFolder({ src: absolutePathToDocsFolder, dest: absolutePathToFernDirectory });
|
|
1309433
1309593
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToFernDirectory });
|
|
1309434
|
-
await (0,
|
|
1309435
|
-
await (0,
|
|
1309594
|
+
await (0, import_promises72.rm)(absolutePathToDocsFolder, { recursive: true });
|
|
1309595
|
+
await (0, import_promises72.rm)(absolutePathToWorkspace, { recursive: true });
|
|
1309436
1309596
|
}
|
|
1309437
1309597
|
async function migrateAndWriteDocsYml2({ absolutePathToWorkspace, docsURLs }) {
|
|
1309438
1309598
|
const docsConfiguration = await loadRawDocsConfiguration2({ absolutePathToWorkspace });
|
|
@@ -1309445,7 +1309605,7 @@ async function migrateAndWriteDocsYml2({ absolutePathToWorkspace, docsURLs }) {
|
|
|
1309445
1309605
|
apiName: void 0
|
|
1309446
1309606
|
});
|
|
1309447
1309607
|
const absolutePathToDocsConfig = getAbsolutePathToDocsYaml({ absolutePathToWorkspace });
|
|
1309448
|
-
await (0,
|
|
1309608
|
+
await (0, import_promises72.writeFile)(absolutePathToDocsConfig, js_yaml_default.dump(convertedDocsConfig));
|
|
1309449
1309609
|
}
|
|
1309450
1309610
|
async function migrateAndWriteGeneratorsYml2({ absolutePathToWorkspace }) {
|
|
1309451
1309611
|
const generatorsConfiguration = await loadRawGeneratorsConfiguration2({ absolutePathToWorkspace });
|
|
@@ -1309457,22 +1309617,22 @@ async function migrateAndWriteGeneratorsYml2({ absolutePathToWorkspace }) {
|
|
|
1309457
1309617
|
generatorsConfiguration,
|
|
1309458
1309618
|
pathModificationStrategy: "MoveUp"
|
|
1309459
1309619
|
});
|
|
1309460
|
-
await (0,
|
|
1309620
|
+
await (0, import_promises72.writeFile)(absolutePathToGeneratorsConfiguration, js_yaml_default.dump(convertedResponse.value));
|
|
1309461
1309621
|
return convertedResponse.docsURLs;
|
|
1309462
1309622
|
}
|
|
1309463
1309623
|
|
|
1309464
1309624
|
// ../yaml/yaml-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateOnlyMultipleAPIs.js
|
|
1309465
|
-
var
|
|
1309625
|
+
var import_promises73 = require("fs/promises");
|
|
1309466
1309626
|
var APIS_DIRECTORY3 = "apis";
|
|
1309467
1309627
|
async function migrateOnlyMultipleAPIs({ absolutePathToFernDirectory, workspaces }) {
|
|
1309468
1309628
|
const absolutePathToApisDirectory = join(absolutePathToFernDirectory, RelativeFilePath.of(APIS_DIRECTORY3));
|
|
1309469
|
-
await (0,
|
|
1309629
|
+
await (0, import_promises73.mkdir)(absolutePathToApisDirectory);
|
|
1309470
1309630
|
for (const workspace of workspaces) {
|
|
1309471
1309631
|
const absolutePathToWorkspace = join(absolutePathToFernDirectory, RelativeFilePath.of(workspace));
|
|
1309472
1309632
|
await migrateAndWriteGeneratorsYml3({ absolutePathToWorkspace });
|
|
1309473
1309633
|
const absolutePathToNestedWorkspace = join(absolutePathToApisDirectory, RelativeFilePath.of(workspace));
|
|
1309474
1309634
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToNestedWorkspace });
|
|
1309475
|
-
await (0,
|
|
1309635
|
+
await (0, import_promises73.rm)(absolutePathToWorkspace, { recursive: true });
|
|
1309476
1309636
|
}
|
|
1309477
1309637
|
}
|
|
1309478
1309638
|
async function migrateAndWriteGeneratorsYml3({ absolutePathToWorkspace }) {
|
|
@@ -1309485,15 +1309645,15 @@ async function migrateAndWriteGeneratorsYml3({ absolutePathToWorkspace }) {
|
|
|
1309485
1309645
|
generatorsConfiguration,
|
|
1309486
1309646
|
pathModificationStrategy: PathModificationStrategy.Nest
|
|
1309487
1309647
|
});
|
|
1309488
|
-
await (0,
|
|
1309648
|
+
await (0, import_promises73.writeFile)(absolutePathToGeneratorsConfiguration, js_yaml_default.dump(convertedResponse.value));
|
|
1309489
1309649
|
}
|
|
1309490
1309650
|
|
|
1309491
1309651
|
// ../yaml/yaml-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateOnlySingleAPI.js
|
|
1309492
|
-
var
|
|
1309652
|
+
var import_promises74 = require("fs/promises");
|
|
1309493
1309653
|
async function migrateOnlySingleAPI({ absolutePathToFernDirectory, absolutePathToWorkspace }) {
|
|
1309494
1309654
|
await migrateAndWriteGeneratorsYml4({ absolutePathToWorkspace });
|
|
1309495
1309655
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToFernDirectory });
|
|
1309496
|
-
await (0,
|
|
1309656
|
+
await (0, import_promises74.rmdir)(absolutePathToWorkspace, { recursive: true });
|
|
1309497
1309657
|
}
|
|
1309498
1309658
|
async function migrateAndWriteGeneratorsYml4({ absolutePathToWorkspace }) {
|
|
1309499
1309659
|
const generatorsConfiguration = await loadRawGeneratorsConfiguration2({ absolutePathToWorkspace });
|
|
@@ -1309505,7 +1309665,7 @@ async function migrateAndWriteGeneratorsYml4({ absolutePathToWorkspace }) {
|
|
|
1309505
1309665
|
generatorsConfiguration,
|
|
1309506
1309666
|
pathModificationStrategy: "MoveUp"
|
|
1309507
1309667
|
});
|
|
1309508
|
-
await (0,
|
|
1309668
|
+
await (0, import_promises74.writeFile)(absolutePathToGeneratorsConfiguration, js_yaml_default.dump(convertedResponse.value));
|
|
1309509
1309669
|
}
|
|
1309510
1309670
|
|
|
1309511
1309671
|
// ../yaml/yaml-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migration.js
|
|
@@ -1309582,8 +1309742,8 @@ var versionMigrations11 = {
|
|
|
1309582
1309742
|
var __default11 = versionMigrations11;
|
|
1309583
1309743
|
|
|
1309584
1309744
|
// ../yaml/yaml-migrations/lib/migrations/0.3.0-rc12/add-value-key-to-type-examples/migration.js
|
|
1309585
|
-
var
|
|
1309586
|
-
var
|
|
1309745
|
+
var import_promises75 = require("fs/promises");
|
|
1309746
|
+
var import_yaml9 = __toESM(require_dist5(), 1);
|
|
1309587
1309747
|
|
|
1309588
1309748
|
// ../yaml/yaml-migrations/lib/migrations/0.3.0-rc12/add-value-key-to-type-examples/getAllYamlFiles.js
|
|
1309589
1309749
|
var import_glob_promise12 = __toESM(require_lib(), 1);
|
|
@@ -1309623,24 +1309783,24 @@ var migration12 = {
|
|
|
1309623
1309783
|
}
|
|
1309624
1309784
|
};
|
|
1309625
1309785
|
async function migrateYamlFile2(filepath, context) {
|
|
1309626
|
-
const contents = await (0,
|
|
1309627
|
-
const parsedDocument =
|
|
1309786
|
+
const contents = await (0, import_promises75.readFile)(filepath);
|
|
1309787
|
+
const parsedDocument = import_yaml9.default.parseDocument(contents.toString());
|
|
1309628
1309788
|
const types3 = parsedDocument.get("types");
|
|
1309629
1309789
|
if (types3 == null) {
|
|
1309630
1309790
|
return;
|
|
1309631
1309791
|
}
|
|
1309632
|
-
if (!
|
|
1309792
|
+
if (!import_yaml9.default.isMap(types3)) {
|
|
1309633
1309793
|
throw new Error("'types' is not a map");
|
|
1309634
1309794
|
}
|
|
1309635
1309795
|
for (const type2 of types3.items) {
|
|
1309636
|
-
if (!
|
|
1309796
|
+
if (!import_yaml9.default.isMap(type2.value)) {
|
|
1309637
1309797
|
continue;
|
|
1309638
1309798
|
}
|
|
1309639
1309799
|
const examples = type2.value.get("examples");
|
|
1309640
1309800
|
if (examples == null) {
|
|
1309641
1309801
|
continue;
|
|
1309642
1309802
|
}
|
|
1309643
|
-
if (!
|
|
1309803
|
+
if (!import_yaml9.default.isSeq(examples)) {
|
|
1309644
1309804
|
context.failWithoutThrowing("'examples' are not a list");
|
|
1309645
1309805
|
continue;
|
|
1309646
1309806
|
}
|
|
@@ -1309649,7 +1309809,7 @@ async function migrateYamlFile2(filepath, context) {
|
|
|
1309649
1309809
|
examples.set(i2, { value });
|
|
1309650
1309810
|
}
|
|
1309651
1309811
|
}
|
|
1309652
|
-
await (0,
|
|
1309812
|
+
await (0, import_promises75.writeFile)(filepath, parsedDocument.toString());
|
|
1309653
1309813
|
}
|
|
1309654
1309814
|
|
|
1309655
1309815
|
// ../yaml/yaml-migrations/lib/migrations/0.3.0-rc12/index.js
|
|
@@ -1309660,8 +1309820,8 @@ var versionMigrations12 = {
|
|
|
1309660
1309820
|
var __default12 = versionMigrations12;
|
|
1309661
1309821
|
|
|
1309662
1309822
|
// ../yaml/yaml-migrations/lib/migrations/0.3.23/change-services-key-to-service/migration.js
|
|
1309663
|
-
var
|
|
1309664
|
-
var
|
|
1309823
|
+
var import_promises76 = require("fs/promises");
|
|
1309824
|
+
var import_yaml10 = __toESM(require_dist5(), 1);
|
|
1309665
1309825
|
|
|
1309666
1309826
|
// ../yaml/yaml-migrations/lib/migrations/0.3.23/change-services-key-to-service/getAllYamlFiles.js
|
|
1309667
1309827
|
var import_glob_promise13 = __toESM(require_lib(), 1);
|
|
@@ -1309701,14 +1309861,14 @@ var migration13 = {
|
|
|
1309701
1309861
|
}
|
|
1309702
1309862
|
};
|
|
1309703
1309863
|
async function migrateYamlFile3(filepath, context) {
|
|
1309704
|
-
const contents = await (0,
|
|
1309705
|
-
const parsedDocument =
|
|
1309706
|
-
if (!
|
|
1309864
|
+
const contents = await (0, import_promises76.readFile)(filepath);
|
|
1309865
|
+
const parsedDocument = import_yaml10.default.parseDocument(contents.toString());
|
|
1309866
|
+
if (!import_yaml10.default.isMap(parsedDocument.contents)) {
|
|
1309707
1309867
|
return context.failAndThrow("File is not a map");
|
|
1309708
1309868
|
}
|
|
1309709
1309869
|
for (const pair of parsedDocument.contents.items) {
|
|
1309710
|
-
if (
|
|
1309711
|
-
if (!
|
|
1309870
|
+
if (import_yaml10.default.isScalar(pair.key) && pair.key.value === "services") {
|
|
1309871
|
+
if (!import_yaml10.default.isMap(pair.value)) {
|
|
1309712
1309872
|
return context.failAndThrow("Services are not a map");
|
|
1309713
1309873
|
}
|
|
1309714
1309874
|
const httpServices = pair.value.get("http");
|
|
@@ -1309716,7 +1309876,7 @@ async function migrateYamlFile3(filepath, context) {
|
|
|
1309716
1309876
|
parsedDocument.contents.delete("services");
|
|
1309717
1309877
|
return;
|
|
1309718
1309878
|
}
|
|
1309719
|
-
if (!
|
|
1309879
|
+
if (!import_yaml10.default.isMap(httpServices)) {
|
|
1309720
1309880
|
return context.failAndThrow("http is not a map");
|
|
1309721
1309881
|
}
|
|
1309722
1309882
|
const [firstService, ...remainingServices] = httpServices.items;
|
|
@@ -1309731,7 +1309891,7 @@ async function migrateYamlFile3(filepath, context) {
|
|
|
1309731
1309891
|
pair.value = firstService.value;
|
|
1309732
1309892
|
}
|
|
1309733
1309893
|
}
|
|
1309734
|
-
await (0,
|
|
1309894
|
+
await (0, import_promises76.writeFile)(filepath, parsedDocument.toString());
|
|
1309735
1309895
|
}
|
|
1309736
1309896
|
|
|
1309737
1309897
|
// ../yaml/yaml-migrations/lib/migrations/0.3.23/index.js
|
|
@@ -1309742,8 +1309902,8 @@ var versionMigrations13 = {
|
|
|
1309742
1309902
|
var __default13 = versionMigrations13;
|
|
1309743
1309903
|
|
|
1309744
1309904
|
// ../yaml/yaml-migrations/lib/migrations/0.5.4/move-service-docs-to-top-level/migration.js
|
|
1309745
|
-
var
|
|
1309746
|
-
var
|
|
1309905
|
+
var import_promises77 = require("fs/promises");
|
|
1309906
|
+
var import_yaml11 = __toESM(require_dist5(), 1);
|
|
1309747
1309907
|
|
|
1309748
1309908
|
// ../yaml/yaml-migrations/lib/migrations/0.5.4/move-service-docs-to-top-level/getAllYamlFiles.js
|
|
1309749
1309909
|
var import_glob_promise14 = __toESM(require_lib(), 1);
|
|
@@ -1309783,26 +1309943,26 @@ var migration14 = {
|
|
|
1309783
1309943
|
}
|
|
1309784
1309944
|
};
|
|
1309785
1309945
|
async function migrateYamlFile4(filepath, context) {
|
|
1309786
|
-
const contents = await (0,
|
|
1309787
|
-
const parsedDocument =
|
|
1309788
|
-
if (!
|
|
1309946
|
+
const contents = await (0, import_promises77.readFile)(filepath);
|
|
1309947
|
+
const parsedDocument = import_yaml11.default.parseDocument(contents.toString());
|
|
1309948
|
+
if (!import_yaml11.default.isMap(parsedDocument.contents)) {
|
|
1309789
1309949
|
return context.failAndThrow("File is not a map");
|
|
1309790
1309950
|
}
|
|
1309791
1309951
|
const service = parsedDocument.contents.get("service");
|
|
1309792
1309952
|
if (service == null) {
|
|
1309793
1309953
|
return;
|
|
1309794
1309954
|
}
|
|
1309795
|
-
if (!
|
|
1309955
|
+
if (!import_yaml11.default.isMap(service)) {
|
|
1309796
1309956
|
return context.failAndThrow("service is not a map");
|
|
1309797
1309957
|
}
|
|
1309798
|
-
const indexOfServiceDocsPair = service.items.findIndex((item) =>
|
|
1309958
|
+
const indexOfServiceDocsPair = service.items.findIndex((item) => import_yaml11.default.isScalar(item.key) && item.key.value === "docs");
|
|
1309799
1309959
|
const docsPair = service.items[indexOfServiceDocsPair];
|
|
1309800
1309960
|
if (docsPair == null) {
|
|
1309801
1309961
|
return;
|
|
1309802
1309962
|
}
|
|
1309803
1309963
|
service.items.splice(indexOfServiceDocsPair, 1);
|
|
1309804
1309964
|
parsedDocument.contents.items.unshift(docsPair);
|
|
1309805
|
-
await (0,
|
|
1309965
|
+
await (0, import_promises77.writeFile)(filepath, parsedDocument.toString());
|
|
1309806
1309966
|
}
|
|
1309807
1309967
|
|
|
1309808
1309968
|
// ../yaml/yaml-migrations/lib/migrations/0.5.4/index.js
|
|
@@ -1309813,7 +1309973,7 @@ var versionMigrations14 = {
|
|
|
1309813
1309973
|
var __default14 = versionMigrations14;
|
|
1309814
1309974
|
|
|
1309815
1309975
|
// ../yaml/yaml-migrations/lib/migrations/0.9.10/add-suffix-to-docs-domain/migration.js
|
|
1309816
|
-
var
|
|
1309976
|
+
var import_promises78 = require("fs/promises");
|
|
1309817
1309977
|
|
|
1309818
1309978
|
// ../yaml/yaml-migrations/lib/migrations/0.9.10/add-suffix-to-docs-domain/getAllGeneratorYamlFiles.js
|
|
1309819
1309979
|
var import_glob_promise15 = __toESM(require_lib(), 1);
|
|
@@ -1309853,14 +1310013,14 @@ var migration15 = {
|
|
|
1309853
1310013
|
}
|
|
1309854
1310014
|
};
|
|
1309855
1310015
|
async function migrateYamlFile5(filepath) {
|
|
1309856
|
-
const contents = await (0,
|
|
1310016
|
+
const contents = await (0, import_promises78.readFile)(filepath);
|
|
1309857
1310017
|
const domainSuffix = process.env.DOMAIN_SUFFIX ?? "docs.buildwithfern.com";
|
|
1309858
1310018
|
const regex4 = /(docs:\s*domain:\s*)"([^"]*)"/g;
|
|
1309859
1310019
|
const updatedSnapshot = contents.toString().replace(regex4, (_match, _prefix, domain2) => {
|
|
1309860
1310020
|
return `docs:
|
|
1309861
1310021
|
domain: "${domain2}.${domainSuffix}"`;
|
|
1309862
1310022
|
});
|
|
1309863
|
-
await (0,
|
|
1310023
|
+
await (0, import_promises78.writeFile)(filepath, updatedSnapshot.toString());
|
|
1309864
1310024
|
}
|
|
1309865
1310025
|
|
|
1309866
1310026
|
// ../yaml/yaml-migrations/lib/migrations/0.9.10/index.js
|
|
@@ -1309961,7 +1310121,7 @@ ${source_default.dim(migration16.summary)}`
|
|
|
1309961
1310121
|
}
|
|
1309962
1310122
|
|
|
1309963
1310123
|
// src/commands/upgrade/upgrade.ts
|
|
1309964
|
-
var
|
|
1310124
|
+
var import_promises79 = require("fs/promises");
|
|
1309965
1310125
|
|
|
1309966
1310126
|
// ../../../node_modules/.pnpm/immer@9.0.15/node_modules/immer/dist/immer.esm.mjs
|
|
1309967
1310127
|
function n(n2) {
|
|
@@ -1310450,7 +1310610,7 @@ async function upgrade({
|
|
|
1310450
1310610
|
const newProjectConfig = immer_esm_default(projectConfig.rawConfig, (draft) => {
|
|
1310451
1310611
|
draft.version = fernCliUpgradeInfo.latestVersion;
|
|
1310452
1310612
|
});
|
|
1310453
|
-
await (0,
|
|
1310613
|
+
await (0, import_promises79.writeFile)(projectConfig._absolutePath, JSON.stringify(newProjectConfig, void 0, 2));
|
|
1310454
1310614
|
cliContext.logger.info(
|
|
1310455
1310615
|
`Upgrading from ${source_default.dim(cliContext.environment.packageVersion)} \u2192 ${source_default.green(
|
|
1310456
1310616
|
fernCliUpgradeInfo.latestVersion
|
|
@@ -1310471,125 +1310631,6 @@ async function upgrade({
|
|
|
1310471
1310631
|
}
|
|
1310472
1310632
|
}
|
|
1310473
1310633
|
|
|
1310474
|
-
// src/commands/upgrade/upgradeGenerator.ts
|
|
1310475
|
-
var import_promises79 = require("fs/promises");
|
|
1310476
|
-
var import_path42 = __toESM(require("path"), 1);
|
|
1310477
|
-
var semver3 = __toESM(require_semver2(), 1);
|
|
1310478
|
-
var import_yaml11 = __toESM(require_dist5(), 1);
|
|
1310479
|
-
async function loadAndUpdateGenerators({
|
|
1310480
|
-
absolutePathToWorkspace,
|
|
1310481
|
-
context,
|
|
1310482
|
-
generatorFilter,
|
|
1310483
|
-
groupFilter,
|
|
1310484
|
-
includeMajor
|
|
1310485
|
-
}) {
|
|
1310486
|
-
const filepath = generators_yml_exports.getPathToGeneratorsConfiguration({ absolutePathToWorkspace });
|
|
1310487
|
-
if (!await doesPathExist(filepath)) {
|
|
1310488
|
-
context.failAndThrow("Generators configuration file was not found, no generators to upgrade.");
|
|
1310489
|
-
return void 0;
|
|
1310490
|
-
}
|
|
1310491
|
-
const contents = await (0, import_promises79.readFile)(filepath);
|
|
1310492
|
-
context.logger.debug(`Found generators: ${contents.toString()}`);
|
|
1310493
|
-
const parsedDocument = import_yaml11.default.parseDocument(contents.toString());
|
|
1310494
|
-
const generatorGroups = parsedDocument.get("groups");
|
|
1310495
|
-
if (generatorGroups == null) {
|
|
1310496
|
-
context.failAndThrow("No groups were found within the generators configuration, no generators to upgrade.");
|
|
1310497
|
-
return void 0;
|
|
1310498
|
-
}
|
|
1310499
|
-
if (!import_yaml11.default.isMap(generatorGroups)) {
|
|
1310500
|
-
context.failAndThrow(`Expected 'groups' to be a map in ${import_path42.default.relative(process.cwd(), filepath)}`);
|
|
1310501
|
-
return void 0;
|
|
1310502
|
-
}
|
|
1310503
|
-
context.logger.debug(`Groups found: ${generatorGroups.toString()}`);
|
|
1310504
|
-
for (const groupBlock of generatorGroups.items) {
|
|
1310505
|
-
const groupName = groupBlock.key;
|
|
1310506
|
-
const group = groupBlock.value;
|
|
1310507
|
-
if (!import_yaml11.default.isMap(group)) {
|
|
1310508
|
-
context.failAndThrow(
|
|
1310509
|
-
`Expected group ${groupName} to be a map in ${import_path42.default.relative(process.cwd(), filepath)}`
|
|
1310510
|
-
);
|
|
1310511
|
-
continue;
|
|
1310512
|
-
}
|
|
1310513
|
-
if (groupFilter != null && group.get("name") !== groupName) {
|
|
1310514
|
-
continue;
|
|
1310515
|
-
}
|
|
1310516
|
-
const generators = group.get("generators");
|
|
1310517
|
-
if (!import_yaml11.default.isSeq(generators)) {
|
|
1310518
|
-
context.failAndThrow(
|
|
1310519
|
-
`Expected group ${groupName} to have a 'generators' key in ${import_path42.default.relative(process.cwd(), filepath)}`
|
|
1310520
|
-
);
|
|
1310521
|
-
continue;
|
|
1310522
|
-
}
|
|
1310523
|
-
context.logger.debug(`Generators found: ${generators.toString()}`);
|
|
1310524
|
-
for (const generator of generators.items) {
|
|
1310525
|
-
if (!import_yaml11.default.isMap(generator)) {
|
|
1310526
|
-
context.failAndThrow(
|
|
1310527
|
-
`Expected generator in group ${groupName} to be a map in ${import_path42.default.relative(process.cwd(), filepath)}`
|
|
1310528
|
-
);
|
|
1310529
|
-
}
|
|
1310530
|
-
if (generatorFilter != null && generator.get("name") !== generatorFilter) {
|
|
1310531
|
-
continue;
|
|
1310532
|
-
}
|
|
1310533
|
-
const generatorName = generator.get("name");
|
|
1310534
|
-
const normalizedGeneratorName = generators_yml_exports.getGeneratorNameOrThrow(generatorName, context);
|
|
1310535
|
-
const currentVersion = generator.get("version");
|
|
1310536
|
-
const latestVersion2 = await generators_yml_exports.getLatestGeneratorVersion(normalizedGeneratorName, context);
|
|
1310537
|
-
context.logger.debug(`${generatorName}, ${currentVersion}, ${latestVersion2}`);
|
|
1310538
|
-
if (latestVersion2 == null) {
|
|
1310539
|
-
continue;
|
|
1310540
|
-
}
|
|
1310541
|
-
const currentMajor = semver3.major(currentVersion);
|
|
1310542
|
-
const latestMajor = semver3.major(latestVersion2);
|
|
1310543
|
-
if (currentMajor === latestMajor || includeMajor) {
|
|
1310544
|
-
generator.set("version", latestVersion2);
|
|
1310545
|
-
context.logger.info(source_default.green(`${generatorName} has been upgraded to latest in group: ${groupName}`));
|
|
1310546
|
-
}
|
|
1310547
|
-
}
|
|
1310548
|
-
}
|
|
1310549
|
-
return parsedDocument.toString();
|
|
1310550
|
-
}
|
|
1310551
|
-
async function upgradeGenerator2({
|
|
1310552
|
-
cliContext,
|
|
1310553
|
-
generator,
|
|
1310554
|
-
group,
|
|
1310555
|
-
project: { apiWorkspaces },
|
|
1310556
|
-
includeMajor
|
|
1310557
|
-
}) {
|
|
1310558
|
-
await Promise.all(
|
|
1310559
|
-
apiWorkspaces.map(async (workspace) => {
|
|
1310560
|
-
await cliContext.runTaskForWorkspace(workspace, async (context) => {
|
|
1310561
|
-
var _a6;
|
|
1310562
|
-
const generatorsConfiguration = await generators_yml_exports.loadRawGeneratorsConfiguration({
|
|
1310563
|
-
absolutePathToWorkspace: workspace.absoluteFilepath,
|
|
1310564
|
-
context
|
|
1310565
|
-
}) ?? {};
|
|
1310566
|
-
if (generatorsConfiguration == null || generatorsConfiguration.groups == null) {
|
|
1310567
|
-
context.failAndThrow(
|
|
1310568
|
-
"No groups were found within the generators configuration, no generators to upgrade."
|
|
1310569
|
-
);
|
|
1310570
|
-
return;
|
|
1310571
|
-
}
|
|
1310572
|
-
context.logger.info(`Upgrading generators in workspace: ${workspace.workspaceName}`);
|
|
1310573
|
-
const updatedConfiguration = await loadAndUpdateGenerators({
|
|
1310574
|
-
absolutePathToWorkspace: workspace.absoluteFilepath,
|
|
1310575
|
-
context,
|
|
1310576
|
-
generatorFilter: generator,
|
|
1310577
|
-
groupFilter: group,
|
|
1310578
|
-
includeMajor
|
|
1310579
|
-
});
|
|
1310580
|
-
if (updatedConfiguration != null) {
|
|
1310581
|
-
await (0, import_promises79.writeFile)(
|
|
1310582
|
-
((_a6 = workspace.generatorsConfiguration) == null ? void 0 : _a6.absolutePathToConfiguration) ?? generators_yml_exports.getPathToGeneratorsConfiguration({
|
|
1310583
|
-
absolutePathToWorkspace: workspace.absoluteFilepath
|
|
1310584
|
-
}),
|
|
1310585
|
-
updatedConfiguration
|
|
1310586
|
-
);
|
|
1310587
|
-
}
|
|
1310588
|
-
});
|
|
1310589
|
-
})
|
|
1310590
|
-
);
|
|
1310591
|
-
}
|
|
1310592
|
-
|
|
1310593
1310634
|
// src/commands/validate/validateWorkspaces.ts
|
|
1310594
1310635
|
async function validateWorkspaces({
|
|
1310595
1310636
|
project,
|
|
@@ -1310795,7 +1310836,6 @@ async function tryRunCli(cliContext) {
|
|
|
1310795
1310836
|
addWriteOverridesCommand(cli, cliContext);
|
|
1310796
1310837
|
addTestCommand(cli, cliContext);
|
|
1310797
1310838
|
addUpdateApiSpecCommand(cli, cliContext);
|
|
1310798
|
-
addUpgradeGeneratorCommand(cli, cliContext);
|
|
1310799
1310839
|
addUpgradeCommand({
|
|
1310800
1310840
|
cli,
|
|
1310801
1310841
|
cliContext,
|
|
@@ -1310804,7 +1310844,7 @@ async function tryRunCli(cliContext) {
|
|
|
1310804
1310844
|
}
|
|
1310805
1310845
|
});
|
|
1310806
1310846
|
addGetOrganizationCommand(cli, cliContext);
|
|
1310807
|
-
|
|
1310847
|
+
addGeneratorCommands(cli, cliContext);
|
|
1310808
1310848
|
cli.middleware(async (argv) => {
|
|
1310809
1310849
|
cliContext.setLogLevel(argv["log-level"]);
|
|
1310810
1310850
|
cliContext.logDebugInfo();
|
|
@@ -1311238,48 +1311278,6 @@ function addUpgradeCommand({
|
|
|
1311238
1311278
|
}
|
|
1311239
1311279
|
);
|
|
1311240
1311280
|
}
|
|
1311241
|
-
function addUpgradeGeneratorCommand(cli, cliContext) {
|
|
1311242
|
-
cli.command(
|
|
1311243
|
-
"generator upgrade",
|
|
1311244
|
-
`Upgrades the specified generator in ${GENERATORS_CONFIGURATION_FILENAME} to the latest stable version.`,
|
|
1311245
|
-
(yargs) => yargs.option("generator", {
|
|
1311246
|
-
string: true,
|
|
1311247
|
-
description: "The type of generator to upgrade, ex: `fern-typescript-node-sdk`."
|
|
1311248
|
-
}).option("group", {
|
|
1311249
|
-
string: true,
|
|
1311250
|
-
description: "The group in which the generator is located, if group is not specified, the all generators of the specified type will be upgraded."
|
|
1311251
|
-
}).option("api", {
|
|
1311252
|
-
string: true,
|
|
1311253
|
-
description: "The API to upgrade the generator for. If not specified, the generator will be upgraded for all APIs."
|
|
1311254
|
-
}).option("include-major", {
|
|
1311255
|
-
boolean: true,
|
|
1311256
|
-
default: false,
|
|
1311257
|
-
description: "Whether or not to include major versions within the upgrade. Defaults to false, meaning major versions will be skipped."
|
|
1311258
|
-
}),
|
|
1311259
|
-
async (argv) => {
|
|
1311260
|
-
cliContext.instrumentPostHogEvent({
|
|
1311261
|
-
command: "fern generator upgrade",
|
|
1311262
|
-
properties: {
|
|
1311263
|
-
generator: argv.generator,
|
|
1311264
|
-
version: argv.version,
|
|
1311265
|
-
api: argv.api,
|
|
1311266
|
-
group: argv.group,
|
|
1311267
|
-
includeMajor: argv.includeMajor
|
|
1311268
|
-
}
|
|
1311269
|
-
});
|
|
1311270
|
-
await upgradeGenerator2({
|
|
1311271
|
-
cliContext,
|
|
1311272
|
-
generator: argv.generator,
|
|
1311273
|
-
group: argv.group,
|
|
1311274
|
-
project: await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
|
|
1311275
|
-
commandLineApiWorkspace: argv.api,
|
|
1311276
|
-
defaultToAllApiWorkspaces: true
|
|
1311277
|
-
}),
|
|
1311278
|
-
includeMajor: argv.includeMajor
|
|
1311279
|
-
});
|
|
1311280
|
-
}
|
|
1311281
|
-
);
|
|
1311282
|
-
}
|
|
1311283
1311281
|
function addUpdateApiSpecCommand(cli, cliContext) {
|
|
1311284
1311282
|
cli.command(
|
|
1311285
1311283
|
"api update",
|