@graphql-markdown/core 1.25.0 → 1.26.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/README.md +4 -3
- package/dist/config.d.ts +8 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +22 -19
- package/dist/const/homepage.d.ts +6 -0
- package/dist/const/homepage.d.ts.map +1 -1
- package/dist/const/homepage.js +7 -1
- package/dist/const/patterns.d.ts.map +1 -1
- package/dist/diff.d.ts +2 -2
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +19 -3
- package/dist/event-emitter.d.ts.map +1 -1
- package/dist/event-handlers.js +5 -5
- package/dist/event-map.d.ts +8 -0
- package/dist/event-map.d.ts.map +1 -1
- package/dist/event-map.js +21 -30
- package/dist/events/index.d.ts +17 -17
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +34 -34
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +52 -39
- package/dist/graphql-config.d.ts.map +1 -1
- package/dist/graphql-config.js +20 -5
- package/dist/index.d.ts +18 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -25
- package/dist/optional-dependencies.d.ts +2 -0
- package/dist/optional-dependencies.d.ts.map +1 -0
- package/dist/optional-dependencies.js +9 -0
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +38 -35
- package/dist/telemetry.d.ts +8 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +5 -14
- package/dist/version.d.ts +6 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +8 -0
- package/package.json +15 -15
package/dist/generator.js
CHANGED
|
@@ -32,6 +32,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
36
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
37
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
38
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return path;
|
|
42
|
+
};
|
|
35
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
44
|
exports.generateDocFromSchema = exports.resolveSkipAndOnlyDirectives = exports.checkSchemaDifferences = exports.loadGraphqlSchema = exports.getFormatterFromMDXModule = exports.getMDXModuleProperty = exports.loadMDXModule = void 0;
|
|
37
45
|
const logger_1 = __importStar(require("@graphql-markdown/logger"));
|
|
@@ -39,14 +47,14 @@ const graphql_1 = require("@graphql-markdown/graphql");
|
|
|
39
47
|
const printer_legacy_1 = require("@graphql-markdown/printer-legacy");
|
|
40
48
|
const utils_1 = require("@graphql-markdown/utils");
|
|
41
49
|
const node_path_1 = require("node:path");
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
+
const config_ts_1 = require("./config.js");
|
|
51
|
+
const diff_ts_1 = require("./diff.js");
|
|
52
|
+
const printer_ts_1 = require("./printer.js");
|
|
53
|
+
const renderer_ts_1 = require("./renderer.js");
|
|
54
|
+
const event_emitter_ts_1 = require("./event-emitter.js");
|
|
55
|
+
const index_ts_1 = require("./events/index.js");
|
|
56
|
+
const event_handlers_ts_1 = require("./event-handlers.js");
|
|
57
|
+
const telemetry_ts_1 = require("./telemetry.js");
|
|
50
58
|
/**
|
|
51
59
|
* Supported file extensions for generated documentation files.
|
|
52
60
|
*
|
|
@@ -82,13 +90,18 @@ const SEC_DECIMALS = 3;
|
|
|
82
90
|
* @internal
|
|
83
91
|
*/
|
|
84
92
|
const loadMDXModule = async (mdxParser) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
if (mdxParser === undefined || mdxParser === null) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
// Specifier is only known at runtime (user-configured formatter package).
|
|
97
|
+
// Resolved into a variable first: tsgo's CJS emit of `import(fn(x))` with
|
|
98
|
+
// rewriteRelativeImportExtensions leaves `fn` unqualified (ReferenceError).
|
|
99
|
+
const specifier = (0, utils_1.runtimeModuleSpecifier)(mdxParser);
|
|
100
|
+
return import(__rewriteRelativeImportExtension(specifier)).catch((error) => {
|
|
101
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
102
|
+
(0, logger_1.log)(`An error occurred while loading MDX formatter "${mdxParser}": ${errorMessage}`, logger_1.LogLevel.warn);
|
|
103
|
+
return undefined;
|
|
104
|
+
});
|
|
92
105
|
};
|
|
93
106
|
exports.loadMDXModule = loadMDXModule;
|
|
94
107
|
/**
|
|
@@ -220,8 +233,8 @@ exports.loadGraphqlSchema = loadGraphqlSchema;
|
|
|
220
233
|
// Used only by unit tests for direct whitebox coverage; not part of the production public API.
|
|
221
234
|
const checkSchemaDifferences = async (schema, schemaLocation, diffMethod, tmpDir) => {
|
|
222
235
|
let changed = true;
|
|
223
|
-
if (diffMethod !==
|
|
224
|
-
changed = await (0,
|
|
236
|
+
if (diffMethod !== config_ts_1.DiffMethod.NONE) {
|
|
237
|
+
changed = await (0, diff_ts_1.hasChanges)(schema, tmpDir, diffMethod);
|
|
225
238
|
if (!changed) {
|
|
226
239
|
(0, logger_1.log)(`No changes detected in schema "${(0, utils_1.toString)(schemaLocation)}".`);
|
|
227
240
|
}
|
|
@@ -272,18 +285,18 @@ const runGeneration = async (options, start, outcome) => {
|
|
|
272
285
|
const mdxModule = await (0, exports.loadMDXModule)(options.formatter);
|
|
273
286
|
// Register MDX lifecycle event handlers if mdxModule loaded successfully
|
|
274
287
|
// This must be called BEFORE getEvents() because it resets the singleton
|
|
275
|
-
(0,
|
|
288
|
+
(0, event_handlers_ts_1.registerMDXEventHandlers)(mdxModule);
|
|
276
289
|
// Get events AFTER registration (registerMDXEventHandlers resets and recreates the singleton)
|
|
277
|
-
const events = (0,
|
|
290
|
+
const events = (0, event_emitter_ts_1.getEvents)();
|
|
278
291
|
// Emitted before destructuring `options` below, so a hook that mutates
|
|
279
292
|
// `event.data.config` (same object reference as `options`) is picked up.
|
|
280
|
-
await events.emitAsync(
|
|
293
|
+
await events.emitAsync(index_ts_1.ConfigBuildEvents.AFTER_BUILD, new index_ts_1.ConfigBuildEvent({ config: options }));
|
|
281
294
|
const { baseURL, customDirective, decorators, diffMethod, docOptions, force, groupByDirective, homepageLocation, linkRoot, loaders: loadersList, metatags, onlyDocDirective, outputAdapter, outputDir, prettify, printTypeOptions, schemaLocation, skipDocDirective, tmpDir, } = options;
|
|
282
|
-
await events.emitAsync(
|
|
295
|
+
await events.emitAsync(index_ts_1.SchemaEvents.BEFORE_LOAD, new index_ts_1.SchemaEvent({
|
|
283
296
|
schemaLocation: schemaLocation,
|
|
284
297
|
}));
|
|
285
298
|
const schema = await (0, exports.loadGraphqlSchema)(schemaLocation, loadersList);
|
|
286
|
-
await events.emitAsync(
|
|
299
|
+
await events.emitAsync(index_ts_1.SchemaEvents.AFTER_LOAD, new index_ts_1.SchemaEvent({
|
|
287
300
|
schemaLocation: schemaLocation,
|
|
288
301
|
schema,
|
|
289
302
|
}));
|
|
@@ -292,16 +305,16 @@ const runGeneration = async (options, start, outcome) => {
|
|
|
292
305
|
outcome.noSchema = true;
|
|
293
306
|
return;
|
|
294
307
|
}
|
|
295
|
-
await events.emitAsync(
|
|
308
|
+
await events.emitAsync(index_ts_1.DiffEvents.BEFORE_CHECK, new index_ts_1.DiffCheckEvent({
|
|
296
309
|
schema,
|
|
297
310
|
outputDir: tmpDir,
|
|
298
311
|
}));
|
|
299
312
|
const schemaHasChanges = await (0, exports.checkSchemaDifferences)(schema, schemaLocation, diffMethod, tmpDir);
|
|
300
|
-
await events.emitAsync(
|
|
313
|
+
await events.emitAsync(index_ts_1.DiffEvents.AFTER_CHECK, new index_ts_1.DiffCheckEvent({ schemaHasChanges }));
|
|
301
314
|
const [onlyDocDirectives, skipDocDirectives] = (0, exports.resolveSkipAndOnlyDirectives)(onlyDocDirective, skipDocDirective, schema);
|
|
302
|
-
events.emit(
|
|
315
|
+
events.emit(index_ts_1.SchemaEvents.BEFORE_MAP, new index_ts_1.SchemaEvent({ schema }));
|
|
303
316
|
const rootTypes = (0, graphql_1.getSchemaMap)(schema);
|
|
304
|
-
events.emit(
|
|
317
|
+
events.emit(index_ts_1.SchemaEvents.AFTER_MAP, new index_ts_1.SchemaEvent({ schema, rootTypes }));
|
|
305
318
|
// `customDirective` is schema-resolved here, then immediately converted
|
|
306
319
|
// into decorators and merged into `decorators` itself: the printer never
|
|
307
320
|
// sees `customDirective` or the resolved `CustomDirectiveMap` it produces,
|
|
@@ -315,7 +328,7 @@ const runGeneration = async (options, start, outcome) => {
|
|
|
315
328
|
const mdxFormatter = (0, exports.getFormatterFromMDXModule)(mdxModule, docOptions);
|
|
316
329
|
// Extract mdxDeclaration from the MDX module (if available)
|
|
317
330
|
const mdxDeclaration = (0, exports.getMDXModuleProperty)(mdxModule, "mdxDeclaration");
|
|
318
|
-
const printer = await (0,
|
|
331
|
+
const printer = await (0, printer_ts_1.getPrinter)(
|
|
319
332
|
// config mandatory
|
|
320
333
|
{
|
|
321
334
|
baseURL,
|
|
@@ -350,7 +363,7 @@ const runGeneration = async (options, start, outcome) => {
|
|
|
350
363
|
else {
|
|
351
364
|
mdxExtension = FILE_EXTENSION.MD;
|
|
352
365
|
}
|
|
353
|
-
const renderer = await (0,
|
|
366
|
+
const renderer = await (0, renderer_ts_1.getRenderer)({
|
|
354
367
|
printer,
|
|
355
368
|
outputDir,
|
|
356
369
|
baseURL,
|
|
@@ -369,29 +382,29 @@ const runGeneration = async (options, start, outcome) => {
|
|
|
369
382
|
// Pre-collect all categories before rendering to ensure consistent positions
|
|
370
383
|
renderer.preCollectCategories(Object.keys(rootTypes));
|
|
371
384
|
renderer.preCollectGeneratedDocPaths(rootTypes);
|
|
372
|
-
const beforeRenderRootTypesEvent = new
|
|
385
|
+
const beforeRenderRootTypesEvent = new index_ts_1.RenderRootTypesEvent({
|
|
373
386
|
rootTypes,
|
|
374
387
|
});
|
|
375
|
-
await events.emitAsync(
|
|
388
|
+
await events.emitAsync(index_ts_1.RenderRootTypesEvents.BEFORE_RENDER, beforeRenderRootTypesEvent);
|
|
376
389
|
const pages = await Promise.all(Object.keys(rootTypes).map(async (name) => {
|
|
377
390
|
const typeName = name;
|
|
378
391
|
return renderer.renderRootTypes(typeName, rootTypes[typeName]);
|
|
379
392
|
}));
|
|
380
393
|
outcome.pages = pages.flat().length;
|
|
381
|
-
const afterRenderRootTypesEvent = new
|
|
394
|
+
const afterRenderRootTypesEvent = new index_ts_1.RenderRootTypesEvent({
|
|
382
395
|
rootTypes,
|
|
383
396
|
});
|
|
384
|
-
await events.emitAsync(
|
|
385
|
-
const beforeRenderHomepageEvent = new
|
|
397
|
+
await events.emitAsync(index_ts_1.RenderRootTypesEvents.AFTER_RENDER, afterRenderRootTypesEvent);
|
|
398
|
+
const beforeRenderHomepageEvent = new index_ts_1.RenderHomepageEvent({
|
|
386
399
|
outputDir,
|
|
387
400
|
});
|
|
388
|
-
await events.emitAsync(
|
|
401
|
+
await events.emitAsync(index_ts_1.RenderHomepageEvents.BEFORE_RENDER, beforeRenderHomepageEvent);
|
|
389
402
|
await renderer.renderHomepage(homepageLocation);
|
|
390
|
-
const afterRenderHomepageEvent = new
|
|
403
|
+
const afterRenderHomepageEvent = new index_ts_1.RenderHomepageEvent({
|
|
391
404
|
outputDir,
|
|
392
405
|
});
|
|
393
|
-
await events.emitAsync(
|
|
394
|
-
const { errors: renderFilesErrors } = await events.emitAsync(
|
|
406
|
+
await events.emitAsync(index_ts_1.RenderHomepageEvents.AFTER_RENDER, afterRenderHomepageEvent);
|
|
407
|
+
const { errors: renderFilesErrors } = await events.emitAsync(index_ts_1.RenderFilesEvents.AFTER_RENDER, new index_ts_1.RenderFilesEvent({
|
|
395
408
|
baseURL,
|
|
396
409
|
outputDir,
|
|
397
410
|
rootDir: (0, node_path_1.dirname)(outputDir),
|
|
@@ -401,7 +414,7 @@ const runGeneration = async (options, start, outcome) => {
|
|
|
401
414
|
}));
|
|
402
415
|
// without this a failure to write mdBook's SUMMARY.md is dropped, and the
|
|
403
416
|
// success line below claims the documentation is complete
|
|
404
|
-
(0,
|
|
417
|
+
(0, renderer_ts_1.logHandlerErrors)(index_ts_1.RenderFilesEvents.AFTER_RENDER, renderFilesErrors);
|
|
405
418
|
outcome.postError = renderFilesErrors[0];
|
|
406
419
|
const duration = (Number(process.hrtime.bigint() - start) / NS_PER_SEC).toFixed(SEC_DECIMALS);
|
|
407
420
|
// a formatter that could not finish its output must not be reported as a
|
|
@@ -441,7 +454,7 @@ const generateDocFromSchema = async (options) => {
|
|
|
441
454
|
throw error;
|
|
442
455
|
}
|
|
443
456
|
finally {
|
|
444
|
-
void (0,
|
|
457
|
+
void (0, telemetry_ts_1.reportGeneration)({
|
|
445
458
|
telemetry: options.telemetryContext,
|
|
446
459
|
pages: outcome.pages,
|
|
447
460
|
durationMs: Number(process.hrtime.bigint() - start) / 1e6,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-config.d.ts","sourceRoot":"","sources":["../src/graphql-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAEV,sBAAsB,EACtB,2BAA2B,EAC3B,YAAY,EACZ,KAAK,EAEL,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"graphql-config.d.ts","sourceRoot":"","sources":["../src/graphql-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAEV,sBAAsB,EACtB,2BAA2B,EAC3B,YAAY,EACZ,KAAK,EAEL,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAgCjC;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,sBAAsB,EAAE,2BAEpC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAWD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,eAAO,MAAM,gBAAgB,YAClB,YAAY,WACZ,oBAAoB,KAC5B,YAeF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,OACxB,KAAK,CAAC,MAAM,CAAC,YACP,KAAK,CAAC,oBAAoB,CAAC,qCACH,YAAY,KAC7C,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAwDjD,CAAC"}
|
package/dist/graphql-config.js
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
3
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
4
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
5
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
return path;
|
|
9
|
+
};
|
|
2
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
11
|
exports.loadConfiguration = exports.setLoaderOptions = exports.graphQLConfigExtension = void 0;
|
|
4
12
|
const logger_1 = require("@graphql-markdown/logger");
|
|
5
|
-
const
|
|
13
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
14
|
+
const optional_dependencies_ts_1 = require("./optional-dependencies.js");
|
|
15
|
+
const validation_ts_1 = require("./directives/validation.js");
|
|
16
|
+
// Kept out of static analysis so JSR does not turn the optional peer into a hard dependency.
|
|
17
|
+
const GRAPHQL_CONFIG_MODULE = "graphql-config";
|
|
6
18
|
/**
|
|
7
19
|
* The name of the GraphQL Markdown extension.
|
|
8
20
|
* Used to identify the extension in graphql-config.
|
|
@@ -60,7 +72,7 @@ const DEFAULT_THROW_OPTIONS = {
|
|
|
60
72
|
// Used only by unit tests for direct whitebox coverage; not part of the production public API.
|
|
61
73
|
const setLoaderOptions = (loaders, options) => {
|
|
62
74
|
for (const loader in loaders) {
|
|
63
|
-
if ((0,
|
|
75
|
+
if ((0, validation_ts_1.isLoaderString)(loaders[loader])) {
|
|
64
76
|
loaders[loader] = {
|
|
65
77
|
module: loaders[loader],
|
|
66
78
|
options,
|
|
@@ -110,7 +122,10 @@ const loadConfiguration = async (id, options, { throwOnMissing, throwOnEmpty } =
|
|
|
110
122
|
return undefined;
|
|
111
123
|
}
|
|
112
124
|
try {
|
|
113
|
-
|
|
125
|
+
// Resolved into a variable first: tsgo's CJS emit of `import(fn(x))` with
|
|
126
|
+
// rewriteRelativeImportExtensions leaves `fn` unqualified (ReferenceError).
|
|
127
|
+
const specifier = (0, utils_1.runtimeModuleSpecifier)(GRAPHQL_CONFIG_MODULE, optional_dependencies_ts_1.OPTIONAL_DEPENDENCY_RANGES[GRAPHQL_CONFIG_MODULE]);
|
|
128
|
+
graphQLConfig = (await import(__rewriteRelativeImportExtension(specifier)));
|
|
114
129
|
}
|
|
115
130
|
catch (error) {
|
|
116
131
|
(0, logger_1.log)(`Cannot load module 'graphql-config': ${error.message}`);
|
|
@@ -131,10 +146,10 @@ const loadConfiguration = async (id, options, { throwOnMissing, throwOnEmpty } =
|
|
|
131
146
|
.extension(EXTENSION_NAME);
|
|
132
147
|
if (Array.isArray(projectConfig.schema)) {
|
|
133
148
|
const schema = projectConfig.schema[0];
|
|
134
|
-
if ((0,
|
|
149
|
+
if ((0, validation_ts_1.isSchemaString)(schema)) {
|
|
135
150
|
projectConfig.schema = schema;
|
|
136
151
|
}
|
|
137
|
-
else if ((0,
|
|
152
|
+
else if ((0, validation_ts_1.isSchemaObject)(schema)) {
|
|
138
153
|
projectConfig.schema = Object.keys(schema)[0];
|
|
139
154
|
if (projectConfig.loaders) {
|
|
140
155
|
projectConfig.loaders = (0, exports.setLoaderOptions)(projectConfig.loaders, Object.values(schema)[0]);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @primaryExport
|
|
3
3
|
*/
|
|
4
|
-
export { generateDocFromSchema } from "./generator";
|
|
5
|
-
export { buildConfig } from "./config";
|
|
6
|
-
export { getEvents, resetEvents, type CancellableEventEmitter, type EmitResult, } from "./event-emitter";
|
|
7
|
-
export { registerMDXEventHandlers } from "./event-handlers";
|
|
8
|
-
export { EVENT_CALLBACK_MAP } from "./event-map";
|
|
9
|
-
export { SchemaEvents } from "./events/schema-events";
|
|
10
|
-
export { DiffEvents } from "./events/diff-events";
|
|
11
|
-
export { RenderRootTypesEvents } from "./events/render-root-types-events";
|
|
12
|
-
export { RenderHomepageEvents } from "./events/render-homepage-events";
|
|
13
|
-
export { RenderTypeEntitiesEvents } from "./events/render-type-entities-events";
|
|
14
|
-
export { GenerateIndexMetafileEvents } from "./events/generate-index-metafile-events";
|
|
15
|
-
export { PrintTypeEvents } from "./events/print-type-events";
|
|
16
|
-
export type { SchemaEvent as SchemaLoadEvent } from "./events/schema-load";
|
|
17
|
-
export type { DiffCheckEvent } from "./events/diff-check";
|
|
18
|
-
export type { RenderRootTypesEvent } from "./events/render-root-types";
|
|
19
|
-
export type { RenderHomepageEvent } from "./events/render-homepage";
|
|
20
|
-
export type { RenderTypeEntitiesEvent } from "./events/render-type-entities";
|
|
21
|
-
export type { GenerateIndexMetafileEvent } from "./events/generate-index-metafile";
|
|
4
|
+
export { generateDocFromSchema } from "./generator.ts";
|
|
5
|
+
export { buildConfig } from "./config.ts";
|
|
6
|
+
export { getEvents, resetEvents, type CancellableEventEmitter, type EmitResult, } from "./event-emitter.ts";
|
|
7
|
+
export { registerMDXEventHandlers } from "./event-handlers.ts";
|
|
8
|
+
export { EVENT_CALLBACK_MAP } from "./event-map.ts";
|
|
9
|
+
export { SchemaEvents } from "./events/schema-events.ts";
|
|
10
|
+
export { DiffEvents } from "./events/diff-events.ts";
|
|
11
|
+
export { RenderRootTypesEvents } from "./events/render-root-types-events.ts";
|
|
12
|
+
export { RenderHomepageEvents } from "./events/render-homepage-events.ts";
|
|
13
|
+
export { RenderTypeEntitiesEvents } from "./events/render-type-entities-events.ts";
|
|
14
|
+
export { GenerateIndexMetafileEvents } from "./events/generate-index-metafile-events.ts";
|
|
15
|
+
export { PrintTypeEvents } from "./events/print-type-events.ts";
|
|
16
|
+
export type { SchemaEvent as SchemaLoadEvent } from "./events/schema-load.ts";
|
|
17
|
+
export type { DiffCheckEvent } from "./events/diff-check.ts";
|
|
18
|
+
export type { RenderRootTypesEvent } from "./events/render-root-types.ts";
|
|
19
|
+
export type { RenderHomepageEvent } from "./events/render-homepage.ts";
|
|
20
|
+
export type { RenderTypeEntitiesEvent } from "./events/render-type-entities.ts";
|
|
21
|
+
export type { GenerateIndexMetafileEvent } from "./events/generate-index-metafile.ts";
|
|
22
22
|
export type { ComposePageTypeEventData, IPrintCodeEvent, IPrintTypeEvent, PageSection, PageSections, PrintCodeEventData, PrintTypeEventData, } from "@graphql-markdown/types";
|
|
23
23
|
export { CancellableEvent } from "@graphql-markdown/utils";
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,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AAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,32 +4,32 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CancellableEvent = exports.PrintTypeEvents = exports.GenerateIndexMetafileEvents = exports.RenderTypeEntitiesEvents = exports.RenderHomepageEvents = exports.RenderRootTypesEvents = exports.DiffEvents = exports.SchemaEvents = exports.EVENT_CALLBACK_MAP = exports.registerMDXEventHandlers = exports.resetEvents = exports.getEvents = exports.buildConfig = exports.generateDocFromSchema = void 0;
|
|
7
|
-
var
|
|
8
|
-
Object.defineProperty(exports, "generateDocFromSchema", { enumerable: true, get: function () { return
|
|
9
|
-
var
|
|
10
|
-
Object.defineProperty(exports, "buildConfig", { enumerable: true, get: function () { return
|
|
7
|
+
var generator_ts_1 = require("./generator.js");
|
|
8
|
+
Object.defineProperty(exports, "generateDocFromSchema", { enumerable: true, get: function () { return generator_ts_1.generateDocFromSchema; } });
|
|
9
|
+
var config_ts_1 = require("./config.js");
|
|
10
|
+
Object.defineProperty(exports, "buildConfig", { enumerable: true, get: function () { return config_ts_1.buildConfig; } });
|
|
11
11
|
// Event system exports
|
|
12
|
-
var
|
|
13
|
-
Object.defineProperty(exports, "getEvents", { enumerable: true, get: function () { return
|
|
14
|
-
Object.defineProperty(exports, "resetEvents", { enumerable: true, get: function () { return
|
|
15
|
-
var
|
|
16
|
-
Object.defineProperty(exports, "registerMDXEventHandlers", { enumerable: true, get: function () { return
|
|
17
|
-
var
|
|
18
|
-
Object.defineProperty(exports, "EVENT_CALLBACK_MAP", { enumerable: true, get: function () { return
|
|
12
|
+
var event_emitter_ts_1 = require("./event-emitter.js");
|
|
13
|
+
Object.defineProperty(exports, "getEvents", { enumerable: true, get: function () { return event_emitter_ts_1.getEvents; } });
|
|
14
|
+
Object.defineProperty(exports, "resetEvents", { enumerable: true, get: function () { return event_emitter_ts_1.resetEvents; } });
|
|
15
|
+
var event_handlers_ts_1 = require("./event-handlers.js");
|
|
16
|
+
Object.defineProperty(exports, "registerMDXEventHandlers", { enumerable: true, get: function () { return event_handlers_ts_1.registerMDXEventHandlers; } });
|
|
17
|
+
var event_map_ts_1 = require("./event-map.js");
|
|
18
|
+
Object.defineProperty(exports, "EVENT_CALLBACK_MAP", { enumerable: true, get: function () { return event_map_ts_1.EVENT_CALLBACK_MAP; } });
|
|
19
19
|
// Event constant exports
|
|
20
|
-
var
|
|
21
|
-
Object.defineProperty(exports, "SchemaEvents", { enumerable: true, get: function () { return
|
|
22
|
-
var
|
|
23
|
-
Object.defineProperty(exports, "DiffEvents", { enumerable: true, get: function () { return
|
|
24
|
-
var
|
|
25
|
-
Object.defineProperty(exports, "RenderRootTypesEvents", { enumerable: true, get: function () { return
|
|
26
|
-
var
|
|
27
|
-
Object.defineProperty(exports, "RenderHomepageEvents", { enumerable: true, get: function () { return
|
|
28
|
-
var
|
|
29
|
-
Object.defineProperty(exports, "RenderTypeEntitiesEvents", { enumerable: true, get: function () { return
|
|
30
|
-
var
|
|
31
|
-
Object.defineProperty(exports, "GenerateIndexMetafileEvents", { enumerable: true, get: function () { return
|
|
32
|
-
var
|
|
33
|
-
Object.defineProperty(exports, "PrintTypeEvents", { enumerable: true, get: function () { return
|
|
20
|
+
var schema_events_ts_1 = require("./events/schema-events.js");
|
|
21
|
+
Object.defineProperty(exports, "SchemaEvents", { enumerable: true, get: function () { return schema_events_ts_1.SchemaEvents; } });
|
|
22
|
+
var diff_events_ts_1 = require("./events/diff-events.js");
|
|
23
|
+
Object.defineProperty(exports, "DiffEvents", { enumerable: true, get: function () { return diff_events_ts_1.DiffEvents; } });
|
|
24
|
+
var render_root_types_events_ts_1 = require("./events/render-root-types-events.js");
|
|
25
|
+
Object.defineProperty(exports, "RenderRootTypesEvents", { enumerable: true, get: function () { return render_root_types_events_ts_1.RenderRootTypesEvents; } });
|
|
26
|
+
var render_homepage_events_ts_1 = require("./events/render-homepage-events.js");
|
|
27
|
+
Object.defineProperty(exports, "RenderHomepageEvents", { enumerable: true, get: function () { return render_homepage_events_ts_1.RenderHomepageEvents; } });
|
|
28
|
+
var render_type_entities_events_ts_1 = require("./events/render-type-entities-events.js");
|
|
29
|
+
Object.defineProperty(exports, "RenderTypeEntitiesEvents", { enumerable: true, get: function () { return render_type_entities_events_ts_1.RenderTypeEntitiesEvents; } });
|
|
30
|
+
var generate_index_metafile_events_ts_1 = require("./events/generate-index-metafile-events.js");
|
|
31
|
+
Object.defineProperty(exports, "GenerateIndexMetafileEvents", { enumerable: true, get: function () { return generate_index_metafile_events_ts_1.GenerateIndexMetafileEvents; } });
|
|
32
|
+
var print_type_events_ts_1 = require("./events/print-type-events.js");
|
|
33
|
+
Object.defineProperty(exports, "PrintTypeEvents", { enumerable: true, get: function () { return print_type_events_ts_1.PrintTypeEvents; } });
|
|
34
34
|
var utils_1 = require("@graphql-markdown/utils");
|
|
35
35
|
Object.defineProperty(exports, "CancellableEvent", { enumerable: true, get: function () { return utils_1.CancellableEvent; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional-dependencies.d.ts","sourceRoot":"","sources":["../src/optional-dependencies.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGvE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Deno version ranges of the optional dependencies, generated from package.json
|
|
3
|
+
// by `bun run jsr:sync` (verified by `bun run jsr:check`). Do not edit by hand.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.OPTIONAL_DEPENDENCY_RANGES = void 0;
|
|
6
|
+
exports.OPTIONAL_DEPENDENCY_RANGES = {
|
|
7
|
+
"@graphql-markdown/diff": "^1.1.24",
|
|
8
|
+
"graphql-config": "^6.0.0",
|
|
9
|
+
};
|
package/dist/renderer.d.ts
CHANGED
|
@@ -209,7 +209,7 @@ export declare class Renderer {
|
|
|
209
209
|
* @returns Promise that resolves when the homepage is rendered
|
|
210
210
|
* @example
|
|
211
211
|
*/
|
|
212
|
-
renderHomepage(homepageLocation: Maybe<string>): Promise<void>;
|
|
212
|
+
renderHomepage(homepageLocation: Maybe<string | symbol>): Promise<void>;
|
|
213
213
|
/**
|
|
214
214
|
* Registers custom group names from the current group configuration.
|
|
215
215
|
* Custom groups are always registered at the ROOT level.
|
package/dist/renderer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,QAAQ,EAER,KAAK,EAEL,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EAGb,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,QAAQ,EAER,KAAK,EAEL,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EAGb,MAAM,yBAAyB,CAAC;AA6FjC;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,oBAAoB,CAG5C,CAAC;AAEX;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,iBAAiB,SACtB,OAAO,WACJ,KAAK,CAAC,oBAAoB,GAAG,OAAO,CAAC,KAC7C,MAMF,CAAC;AA6CF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;C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CAAC,0BAA0B;IAiClC;;;;;;;OAOG;IACH,OAAO,CAAC,wBAAwB;IAiBhC;;;;;;OAMG;IACH,OAAO,CAAC,8BAA8B;IAiCtC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,wBAAwB;IAgChC;;;;;;;;;OASG;YACW,WAAW;CAM1B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,WAAW,yGAUrB,eAAe,KAAG,OAAO,CAAC,YAAY,CAAC,OAAO,QAAQ,CAAC,CAgBzD,CAAC"}
|
package/dist/renderer.js
CHANGED
|
@@ -5,11 +5,11 @@ const node_path_1 = require("node:path");
|
|
|
5
5
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
6
6
|
const utils_1 = require("@graphql-markdown/utils");
|
|
7
7
|
const logger_1 = require("@graphql-markdown/logger");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
8
|
+
const config_ts_1 = require("./config.js");
|
|
9
|
+
const homepage_ts_1 = require("./const/homepage.js");
|
|
10
|
+
const validation_ts_1 = require("./directives/validation.js");
|
|
11
|
+
const event_emitter_ts_1 = require("./event-emitter.js");
|
|
12
|
+
const index_ts_1 = require("./events/index.js");
|
|
13
13
|
/**
|
|
14
14
|
* Constant representing the string literal for deprecated entities.
|
|
15
15
|
* Used for grouping deprecated schema entities when the deprecated option is set to "group".
|
|
@@ -114,7 +114,7 @@ exports.API_GROUPS = {
|
|
|
114
114
|
// Used only by unit tests for direct whitebox coverage; not part of the production public API.
|
|
115
115
|
const getApiGroupFolder = (type, groups) => {
|
|
116
116
|
let folderNames = exports.API_GROUPS;
|
|
117
|
-
if ((0,
|
|
117
|
+
if ((0, validation_ts_1.isGroupsObject)(groups)) {
|
|
118
118
|
folderNames = { ...exports.API_GROUPS, ...groups };
|
|
119
119
|
}
|
|
120
120
|
return (0, graphql_1.isApiType)(type) ? folderNames.operations : folderNames.types;
|
|
@@ -336,8 +336,8 @@ class Renderer {
|
|
|
336
336
|
const finalOptions = options ?? defaultOptions;
|
|
337
337
|
const sidebarPosition = finalOptions.sidebarPosition ??
|
|
338
338
|
this.categoryPositionManager.getPosition(category);
|
|
339
|
-
const events = (0,
|
|
340
|
-
const event = new
|
|
339
|
+
const events = (0, event_emitter_ts_1.getEvents)();
|
|
340
|
+
const event = new index_ts_1.GenerateIndexMetafileEvent({
|
|
341
341
|
dirPath,
|
|
342
342
|
category,
|
|
343
343
|
outputAdapter: this.outputAdapter,
|
|
@@ -349,14 +349,14 @@ class Renderer {
|
|
|
349
349
|
});
|
|
350
350
|
// emitAsync resolves to an EmitResult, never an array: the previous
|
|
351
351
|
// Array.isArray() guard was always false, so handler errors went unreported
|
|
352
|
-
const { errors } = await events.emitAsync(
|
|
353
|
-
(0, exports.logHandlerErrors)(
|
|
354
|
-
const { errors: afterErrors } = await events.emitAsync(
|
|
352
|
+
const { errors } = await events.emitAsync(index_ts_1.GenerateIndexMetafileEvents.BEFORE_GENERATE, event);
|
|
353
|
+
(0, exports.logHandlerErrors)(index_ts_1.GenerateIndexMetafileEvents.BEFORE_GENERATE, errors);
|
|
354
|
+
const { errors: afterErrors } = await events.emitAsync(index_ts_1.GenerateIndexMetafileEvents.AFTER_GENERATE, new index_ts_1.GenerateIndexMetafileEvent({
|
|
355
355
|
dirPath,
|
|
356
356
|
category,
|
|
357
357
|
outputAdapter: this.outputAdapter,
|
|
358
358
|
}));
|
|
359
|
-
(0, exports.logHandlerErrors)(
|
|
359
|
+
(0, exports.logHandlerErrors)(index_ts_1.GenerateIndexMetafileEvents.AFTER_GENERATE, afterErrors);
|
|
360
360
|
}
|
|
361
361
|
/**
|
|
362
362
|
* Generates the directory path and metafiles for a specific schema entity type.
|
|
@@ -370,10 +370,10 @@ class Renderer {
|
|
|
370
370
|
*/
|
|
371
371
|
async generateCategoryMetafileType(type, name, rootTypeName) {
|
|
372
372
|
let dirPath = this.outputDir;
|
|
373
|
-
if (!(0,
|
|
373
|
+
if (!(0, validation_ts_1.isPath)(dirPath)) {
|
|
374
374
|
throw new Error("Output directory is empty or not specified");
|
|
375
375
|
}
|
|
376
|
-
if (isHierarchy(this.options,
|
|
376
|
+
if (isHierarchy(this.options, config_ts_1.TypeHierarchy.FLAT)) {
|
|
377
377
|
return dirPath;
|
|
378
378
|
}
|
|
379
379
|
// Deprecated gets highest priority - at ROOT level before even custom groups
|
|
@@ -395,9 +395,9 @@ class Renderer {
|
|
|
395
395
|
dirPath = (0, node_path_1.join)(dirPath, formattedRootGroup);
|
|
396
396
|
await this.generateIndexMetafile(dirPath, rootGroup);
|
|
397
397
|
}
|
|
398
|
-
const useApiGroup = isHierarchy(this.options,
|
|
399
|
-
? this.options.hierarchy[
|
|
400
|
-
: !isHierarchy(this.options,
|
|
398
|
+
const useApiGroup = isHierarchy(this.options, config_ts_1.TypeHierarchy.API)
|
|
399
|
+
? this.options.hierarchy[config_ts_1.TypeHierarchy.API]
|
|
400
|
+
: !isHierarchy(this.options, config_ts_1.TypeHierarchy.ENTITY);
|
|
401
401
|
if (useApiGroup) {
|
|
402
402
|
const typeCat = (0, exports.getApiGroupFolder)(type, useApiGroup);
|
|
403
403
|
// API groups are root-level if no custom groups exist, nested if custom groups exist
|
|
@@ -432,7 +432,7 @@ class Renderer {
|
|
|
432
432
|
if (typeof type !== "object" || type === null) {
|
|
433
433
|
return undefined;
|
|
434
434
|
}
|
|
435
|
-
const isFlat = isHierarchy(this.options,
|
|
435
|
+
const isFlat = isHierarchy(this.options, config_ts_1.TypeHierarchy.FLAT);
|
|
436
436
|
const isOperationRootType = rootTypeName === "queries" ||
|
|
437
437
|
rootTypeName === "mutations" ||
|
|
438
438
|
rootTypeName === "subscriptions";
|
|
@@ -474,7 +474,7 @@ class Renderer {
|
|
|
474
474
|
* @example
|
|
475
475
|
*/
|
|
476
476
|
async renderTypeEntities(dirPath, name, type, operationNamespaceParts, entity) {
|
|
477
|
-
if (!(0,
|
|
477
|
+
if (!(0, validation_ts_1.isPath)(dirPath)) {
|
|
478
478
|
throw new Error("Output directory is empty or not specified");
|
|
479
479
|
}
|
|
480
480
|
// Regex patterns to parse page metadata from file paths
|
|
@@ -483,7 +483,7 @@ class Renderer {
|
|
|
483
483
|
// NOSONAR - pattern is safe, hyphen in character class doesn't cause backtracking
|
|
484
484
|
const PageRegex = /(?<category>[a-z0-9-]+)[\\/]+(?<pageId>[a-z0-9-]+)\.mdx?$/i; // NOSONAR
|
|
485
485
|
const PageRegexFlat = /(?<pageId>[a-z0-9-]+)\.mdx?$/i; // NOSONAR
|
|
486
|
-
const isFlat = isHierarchy(this.options,
|
|
486
|
+
const isFlat = isHierarchy(this.options, config_ts_1.TypeHierarchy.FLAT);
|
|
487
487
|
// Flat hierarchy has no folders to keep same-named entities of different
|
|
488
488
|
// kinds apart (a `type User` and a `Query.user` field both slugify to
|
|
489
489
|
// "user") — prefixing with `entity` (the `SchemaEntity` root type this
|
|
@@ -548,8 +548,8 @@ class Renderer {
|
|
|
548
548
|
? page.groups.pageId
|
|
549
549
|
: stripNumericPrefix(page.groups.category);
|
|
550
550
|
const category = isFlat ? "schema" : (0, utils_1.startCase)(extractedCategory);
|
|
551
|
-
const events = (0,
|
|
552
|
-
const event = new
|
|
551
|
+
const events = (0, event_emitter_ts_1.getEvents)();
|
|
552
|
+
const event = new index_ts_1.RenderTypeEntitiesEvent({
|
|
553
553
|
baseURL: this.baseURL,
|
|
554
554
|
...(this.linkRoot !== undefined && { linkRoot: this.linkRoot }),
|
|
555
555
|
name,
|
|
@@ -558,8 +558,8 @@ class Renderer {
|
|
|
558
558
|
outputAdapter: this.outputAdapter,
|
|
559
559
|
knownDocPaths: this.knownDocPaths,
|
|
560
560
|
});
|
|
561
|
-
const { errors } = await events.emitAsync(
|
|
562
|
-
(0, exports.logHandlerErrors)(
|
|
561
|
+
const { errors } = await events.emitAsync(index_ts_1.RenderTypeEntitiesEvents.AFTER_RENDER, event);
|
|
562
|
+
(0, exports.logHandlerErrors)(index_ts_1.RenderTypeEntitiesEvents.AFTER_RENDER, errors);
|
|
563
563
|
return {
|
|
564
564
|
category,
|
|
565
565
|
filePath,
|
|
@@ -572,7 +572,7 @@ class Renderer {
|
|
|
572
572
|
* @param rootTypes - Map of schema entity names to their generated types
|
|
573
573
|
*/
|
|
574
574
|
preCollectGeneratedDocPaths(rootTypes) {
|
|
575
|
-
if (!isHierarchy(this.options,
|
|
575
|
+
if (!isHierarchy(this.options, config_ts_1.TypeHierarchy.FLAT)) {
|
|
576
576
|
return;
|
|
577
577
|
}
|
|
578
578
|
for (const [entity, type] of Object.entries(rootTypes)) {
|
|
@@ -606,13 +606,13 @@ class Renderer {
|
|
|
606
606
|
const rootCategories = new Set();
|
|
607
607
|
const nestedCategories = new Set();
|
|
608
608
|
// Skip if flat hierarchy
|
|
609
|
-
if (isHierarchy(this.options,
|
|
609
|
+
if (isHierarchy(this.options, config_ts_1.TypeHierarchy.FLAT)) {
|
|
610
610
|
return;
|
|
611
611
|
}
|
|
612
612
|
// Determine if using API hierarchy
|
|
613
|
-
const useApiGroup = isHierarchy(this.options,
|
|
614
|
-
? this.options.hierarchy[
|
|
615
|
-
: !isHierarchy(this.options,
|
|
613
|
+
const useApiGroup = isHierarchy(this.options, config_ts_1.TypeHierarchy.API)
|
|
614
|
+
? this.options.hierarchy[config_ts_1.TypeHierarchy.API]
|
|
615
|
+
: !isHierarchy(this.options, config_ts_1.TypeHierarchy.ENTITY);
|
|
616
616
|
// Register custom groups at root level
|
|
617
617
|
this.registerCustomGroups(rootCategories);
|
|
618
618
|
// Register categories based on hierarchy type
|
|
@@ -638,13 +638,16 @@ class Renderer {
|
|
|
638
638
|
* @example
|
|
639
639
|
*/
|
|
640
640
|
async renderHomepage(homepageLocation) {
|
|
641
|
-
if (typeof homepageLocation !== "string"
|
|
641
|
+
if (typeof homepageLocation !== "string" &&
|
|
642
|
+
homepageLocation !== config_ts_1.ASSET_HOMEPAGE_LOCATION) {
|
|
642
643
|
return;
|
|
643
644
|
}
|
|
644
|
-
if (!(0,
|
|
645
|
+
if (!(0, validation_ts_1.isPath)(this.outputDir)) {
|
|
645
646
|
throw new Error("Output directory is empty or not specified");
|
|
646
647
|
}
|
|
647
|
-
const homePage =
|
|
648
|
+
const homePage = homepageLocation === config_ts_1.ASSET_HOMEPAGE_LOCATION
|
|
649
|
+
? homepage_ts_1.DEFAULT_HOMEPAGE_FILENAME
|
|
650
|
+
: (0, node_path_1.basename)(homepageLocation);
|
|
648
651
|
const destLocation = (0, node_path_1.join)(this.outputDir, homePage);
|
|
649
652
|
const slug = utils_1.pathUrl.resolve("/", this.baseURL);
|
|
650
653
|
try {
|
|
@@ -655,8 +658,8 @@ class Renderer {
|
|
|
655
658
|
//
|
|
656
659
|
// The built-in template is inlined, so the default path performs no
|
|
657
660
|
// filesystem read at all. Only a caller-supplied `homepage` path does.
|
|
658
|
-
const template = homepageLocation ===
|
|
659
|
-
?
|
|
661
|
+
const template = homepageLocation === config_ts_1.ASSET_HOMEPAGE_LOCATION
|
|
662
|
+
? homepage_ts_1.DEFAULT_HOMEPAGE_TEMPLATE
|
|
660
663
|
: await (0, utils_1.readFile)(homepageLocation);
|
|
661
664
|
const data = template
|
|
662
665
|
.toString()
|
|
@@ -665,7 +668,7 @@ class Renderer {
|
|
|
665
668
|
await this.writeOutput(destLocation, data);
|
|
666
669
|
}
|
|
667
670
|
catch (error) {
|
|
668
|
-
(0, logger_1.log)(`An error occurred while processing the homepage ${homepageLocation}: ${error}`, logger_1.LogLevel.warn);
|
|
671
|
+
(0, logger_1.log)(`An error occurred while processing the homepage ${String(homepageLocation)}: ${error}`, logger_1.LogLevel.warn);
|
|
669
672
|
}
|
|
670
673
|
}
|
|
671
674
|
/**
|