@fern-api/generator-cli 0.0.42 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +90 -8
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -5148,14 +5148,14 @@ var require_common = __commonJS({
|
|
|
5148
5148
|
}
|
|
5149
5149
|
}
|
|
5150
5150
|
}
|
|
5151
|
-
function matchesTemplate(search,
|
|
5151
|
+
function matchesTemplate(search, template2) {
|
|
5152
5152
|
let searchIndex = 0;
|
|
5153
5153
|
let templateIndex = 0;
|
|
5154
5154
|
let starIndex = -1;
|
|
5155
5155
|
let matchIndex = 0;
|
|
5156
5156
|
while (searchIndex < search.length) {
|
|
5157
|
-
if (templateIndex <
|
|
5158
|
-
if (
|
|
5157
|
+
if (templateIndex < template2.length && (template2[templateIndex] === search[searchIndex] || template2[templateIndex] === "*")) {
|
|
5158
|
+
if (template2[templateIndex] === "*") {
|
|
5159
5159
|
starIndex = templateIndex;
|
|
5160
5160
|
matchIndex = searchIndex;
|
|
5161
5161
|
templateIndex++;
|
|
@@ -5171,10 +5171,10 @@ var require_common = __commonJS({
|
|
|
5171
5171
|
return false;
|
|
5172
5172
|
}
|
|
5173
5173
|
}
|
|
5174
|
-
while (templateIndex <
|
|
5174
|
+
while (templateIndex < template2.length && template2[templateIndex] === "*") {
|
|
5175
5175
|
templateIndex++;
|
|
5176
5176
|
}
|
|
5177
|
-
return templateIndex ===
|
|
5177
|
+
return templateIndex === template2.length;
|
|
5178
5178
|
}
|
|
5179
5179
|
function disable() {
|
|
5180
5180
|
const namespaces = [
|
|
@@ -12833,6 +12833,7 @@ var GitHub = class {
|
|
|
12833
12833
|
};
|
|
12834
12834
|
|
|
12835
12835
|
// src/readme/ReadmeGenerator.ts
|
|
12836
|
+
var import_compat = require("es-toolkit/compat");
|
|
12836
12837
|
var import_string = require("es-toolkit/string");
|
|
12837
12838
|
|
|
12838
12839
|
// src/configuration/generated/api/index.ts
|
|
@@ -13216,9 +13217,9 @@ var BlockMerger = class {
|
|
|
13216
13217
|
merged.addBlock(originalBlock);
|
|
13217
13218
|
}
|
|
13218
13219
|
}
|
|
13219
|
-
for (const updatedBlock of this.updated) {
|
|
13220
|
+
for (const [index, updatedBlock] of this.updated.reverse().entries()) {
|
|
13220
13221
|
if (!processedUpdated.has(updatedBlock.id)) {
|
|
13221
|
-
merged.
|
|
13222
|
+
merged.insertBlock(updatedBlock, this.updated[index - 1]?.id);
|
|
13222
13223
|
}
|
|
13223
13224
|
}
|
|
13224
13225
|
return merged.getBlocks();
|
|
@@ -13241,6 +13242,33 @@ var BlockList = class {
|
|
|
13241
13242
|
this.ids.add(block.id);
|
|
13242
13243
|
this.blocks.push(block);
|
|
13243
13244
|
}
|
|
13245
|
+
// private addBlockToFront(block: Block): void {
|
|
13246
|
+
// if (this.hasBlock(block.id)) {
|
|
13247
|
+
// throw new Error(`block with id "${block.id}" already exists`);
|
|
13248
|
+
// }
|
|
13249
|
+
// this.ids.add(block.id);
|
|
13250
|
+
// this.blocks.unshift(block);
|
|
13251
|
+
// }
|
|
13252
|
+
insertBlock(block, precedingBlockId) {
|
|
13253
|
+
if (this.hasBlock(block.id)) {
|
|
13254
|
+
throw new Error(`block with id "${block.id}" already exists`);
|
|
13255
|
+
}
|
|
13256
|
+
if (precedingBlockId === void 0) {
|
|
13257
|
+
this.addBlock(block);
|
|
13258
|
+
return;
|
|
13259
|
+
}
|
|
13260
|
+
if (!this.hasBlock(precedingBlockId)) {
|
|
13261
|
+
throw new Error(
|
|
13262
|
+
`preceding block with id "${precedingBlockId}" does not exist`
|
|
13263
|
+
);
|
|
13264
|
+
}
|
|
13265
|
+
this.ids.add(block.id);
|
|
13266
|
+
this.blocks.splice(
|
|
13267
|
+
this.blocks.findIndex((b) => b.id === precedingBlockId),
|
|
13268
|
+
0,
|
|
13269
|
+
block
|
|
13270
|
+
);
|
|
13271
|
+
}
|
|
13244
13272
|
hasBlock(id) {
|
|
13245
13273
|
return this.ids.has(id);
|
|
13246
13274
|
}
|
|
@@ -13317,6 +13345,19 @@ var ReadmeGenerator = class {
|
|
|
13317
13345
|
})
|
|
13318
13346
|
);
|
|
13319
13347
|
}
|
|
13348
|
+
if (this.readmeConfig.customSections != null) {
|
|
13349
|
+
const templateOptions = this.getCustomSectionTemplateOptions();
|
|
13350
|
+
for (const customSection of this.readmeConfig.customSections.filter(
|
|
13351
|
+
(section) => section.language.toLowerCase() === this.readmeConfig.language.type.toLowerCase()
|
|
13352
|
+
)) {
|
|
13353
|
+
blocks.push(
|
|
13354
|
+
await this.generateCustomSection({
|
|
13355
|
+
customSection,
|
|
13356
|
+
templateOptions
|
|
13357
|
+
})
|
|
13358
|
+
);
|
|
13359
|
+
}
|
|
13360
|
+
}
|
|
13320
13361
|
const coreFeatures = this.readmeConfig.features?.filter((feat) => !this.isAdvanced(feat)) ?? [];
|
|
13321
13362
|
const advancedFeatures = this.readmeConfig.features?.filter((feat) => this.isAdvanced(feat)) ?? [];
|
|
13322
13363
|
for (const feature of coreFeatures) {
|
|
@@ -13410,7 +13451,9 @@ var ReadmeGenerator = class {
|
|
|
13410
13451
|
content: originalReadmeContent
|
|
13411
13452
|
});
|
|
13412
13453
|
const merger = new BlockMerger({
|
|
13413
|
-
original: parsed.blocks
|
|
13454
|
+
original: parsed.blocks.filter(
|
|
13455
|
+
(block) => !this.readmeConfig.disabledFeatures?.includes(block.id.toUpperCase())
|
|
13456
|
+
),
|
|
13414
13457
|
updated: blocks
|
|
13415
13458
|
});
|
|
13416
13459
|
return merger.merge();
|
|
@@ -13509,6 +13552,42 @@ var ReadmeGenerator = class {
|
|
|
13509
13552
|
content: writer.toString()
|
|
13510
13553
|
});
|
|
13511
13554
|
}
|
|
13555
|
+
getCustomSectionTemplateOptions() {
|
|
13556
|
+
let options = {
|
|
13557
|
+
apiName: this.apiName
|
|
13558
|
+
};
|
|
13559
|
+
if (this.readmeConfig.language.publishInfo != null) {
|
|
13560
|
+
options = {
|
|
13561
|
+
...options,
|
|
13562
|
+
...this.readmeConfig.language.publishInfo
|
|
13563
|
+
};
|
|
13564
|
+
}
|
|
13565
|
+
return options;
|
|
13566
|
+
}
|
|
13567
|
+
applyTemplateOptions(content, options) {
|
|
13568
|
+
try {
|
|
13569
|
+
return (0, import_compat.template)(content, { interpolate: /{{([^}]+)}}/g })(options);
|
|
13570
|
+
} catch (error) {
|
|
13571
|
+
console.error(`[templates] ${JSON.stringify(error)}`);
|
|
13572
|
+
return content;
|
|
13573
|
+
}
|
|
13574
|
+
}
|
|
13575
|
+
async generateCustomSection({
|
|
13576
|
+
customSection,
|
|
13577
|
+
templateOptions
|
|
13578
|
+
}) {
|
|
13579
|
+
const writer = new StringWriter();
|
|
13580
|
+
await writer.writeLine(`## ${customSection.name}`);
|
|
13581
|
+
await writer.writeLine();
|
|
13582
|
+
await writer.writeLine(
|
|
13583
|
+
this.applyTemplateOptions(customSection.content, templateOptions)
|
|
13584
|
+
);
|
|
13585
|
+
await writer.writeLine();
|
|
13586
|
+
return new Block({
|
|
13587
|
+
id: toScreamingSnakeCase(customSection.name),
|
|
13588
|
+
content: writer.toString()
|
|
13589
|
+
});
|
|
13590
|
+
}
|
|
13512
13591
|
async generateRequirements({
|
|
13513
13592
|
requirements
|
|
13514
13593
|
}) {
|
|
@@ -13995,6 +14074,9 @@ function getMajorVersion(version) {
|
|
|
13995
14074
|
function assertNever(x) {
|
|
13996
14075
|
throw new Error(`unexpected value: ${JSON.stringify(x)}`);
|
|
13997
14076
|
}
|
|
14077
|
+
function toScreamingSnakeCase(s) {
|
|
14078
|
+
return s.toUpperCase().replace(/ /g, "_");
|
|
14079
|
+
}
|
|
13998
14080
|
|
|
13999
14081
|
// src/readme/ReadmeParser.ts
|
|
14000
14082
|
var import_string2 = require("es-toolkit/string");
|