@fern-api/generator-cli 0.0.42 → 0.1.0
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 +87 -7
- 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) {
|
|
@@ -13509,6 +13550,42 @@ var ReadmeGenerator = class {
|
|
|
13509
13550
|
content: writer.toString()
|
|
13510
13551
|
});
|
|
13511
13552
|
}
|
|
13553
|
+
getCustomSectionTemplateOptions() {
|
|
13554
|
+
let options = {
|
|
13555
|
+
apiName: this.apiName
|
|
13556
|
+
};
|
|
13557
|
+
if (this.readmeConfig.language.publishInfo != null) {
|
|
13558
|
+
options = {
|
|
13559
|
+
...options,
|
|
13560
|
+
...this.readmeConfig.language.publishInfo
|
|
13561
|
+
};
|
|
13562
|
+
}
|
|
13563
|
+
return options;
|
|
13564
|
+
}
|
|
13565
|
+
applyTemplateOptions(content, options) {
|
|
13566
|
+
try {
|
|
13567
|
+
return (0, import_compat.template)(content, { interpolate: /{{([^}]+)}}/g })(options);
|
|
13568
|
+
} catch (error) {
|
|
13569
|
+
console.error(`[templates] ${JSON.stringify(error)}`);
|
|
13570
|
+
return content;
|
|
13571
|
+
}
|
|
13572
|
+
}
|
|
13573
|
+
async generateCustomSection({
|
|
13574
|
+
customSection,
|
|
13575
|
+
templateOptions
|
|
13576
|
+
}) {
|
|
13577
|
+
const writer = new StringWriter();
|
|
13578
|
+
await writer.writeLine(`## ${customSection.name}`);
|
|
13579
|
+
await writer.writeLine();
|
|
13580
|
+
await writer.writeLine(
|
|
13581
|
+
this.applyTemplateOptions(customSection.content, templateOptions)
|
|
13582
|
+
);
|
|
13583
|
+
await writer.writeLine();
|
|
13584
|
+
return new Block({
|
|
13585
|
+
id: toScreamingSnakeCase(customSection.name),
|
|
13586
|
+
content: writer.toString()
|
|
13587
|
+
});
|
|
13588
|
+
}
|
|
13512
13589
|
async generateRequirements({
|
|
13513
13590
|
requirements
|
|
13514
13591
|
}) {
|
|
@@ -13995,6 +14072,9 @@ function getMajorVersion(version) {
|
|
|
13995
14072
|
function assertNever(x) {
|
|
13996
14073
|
throw new Error(`unexpected value: ${JSON.stringify(x)}`);
|
|
13997
14074
|
}
|
|
14075
|
+
function toScreamingSnakeCase(s) {
|
|
14076
|
+
return s.toUpperCase().replace(/ /g, "_");
|
|
14077
|
+
}
|
|
13998
14078
|
|
|
13999
14079
|
// src/readme/ReadmeParser.ts
|
|
14000
14080
|
var import_string2 = require("es-toolkit/string");
|