clean-jsdoc-theme 5.0.2 → 5.0.4
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 +0 -3
- package/dist/publish.d.mts +14 -2
- package/dist/publish.d.ts +14 -2
- package/dist/publish.js +29 -12
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +40 -18
- package/dist/publish.mjs.map +1 -1
- package/package.json +6 -6
package/dist/publish.mjs
CHANGED
|
@@ -5,12 +5,18 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
5
5
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.10_tsx@4.22.3_typescript@5.9.3_yaml@2.9.0/node_modules/tsup/assets/esm_shims.js
|
|
9
|
+
import path from "path";
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
|
+
var getFilename = () => fileURLToPath(import.meta.url);
|
|
12
|
+
var __filename = /* @__PURE__ */ getFilename();
|
|
13
|
+
|
|
8
14
|
// src/publish.ts
|
|
9
|
-
import { mkdir as mkdir2, readFile, readdir, writeFile as writeFile2 } from "fs/promises";
|
|
15
|
+
import { mkdir as mkdir2, readFile, readdir, rm, writeFile as writeFile2 } from "fs/promises";
|
|
10
16
|
import { readFileSync } from "fs";
|
|
11
17
|
import { createHash } from "crypto";
|
|
12
18
|
import { basename, dirname as dirname2, extname, join as joinPath, resolve as resolvePath } from "path";
|
|
13
|
-
import { pathToFileURL
|
|
19
|
+
import { pathToFileURL } from "url";
|
|
14
20
|
|
|
15
21
|
// src/write-output-files.ts
|
|
16
22
|
import { mkdir, writeFile } from "fs/promises";
|
|
@@ -28,18 +34,8 @@ async function writeOutputFiles(destination, files) {
|
|
|
28
34
|
var JSDOC_TUTORIAL_TYPE_MARKDOWN = 2;
|
|
29
35
|
function anchorPath() {
|
|
30
36
|
if (typeof __filename === "string") return __filename;
|
|
31
|
-
try {
|
|
32
|
-
const getEsmUrl = new Function(
|
|
33
|
-
"try { return import.meta && import.meta.url; } catch { return undefined; }"
|
|
34
|
-
);
|
|
35
|
-
const url = getEsmUrl();
|
|
36
|
-
if (typeof url === "string" && url.startsWith("file://")) {
|
|
37
|
-
return fileURLToPath(url);
|
|
38
|
-
}
|
|
39
|
-
} catch {
|
|
40
|
-
}
|
|
41
37
|
throw new Error(
|
|
42
|
-
"clean-jsdoc-theme: could not determine the running module path (
|
|
38
|
+
"clean-jsdoc-theme: could not determine the running module path (__filename is unavailable)."
|
|
43
39
|
);
|
|
44
40
|
}
|
|
45
41
|
function resolvePackageDir(name) {
|
|
@@ -105,6 +101,7 @@ var loadUtils = () => loadDep("@clean-jsdoc-theme/utils", [
|
|
|
105
101
|
"createGoogleFontResolver",
|
|
106
102
|
"formatDiagnostics",
|
|
107
103
|
"formatBuildReport",
|
|
104
|
+
"formatRenderError",
|
|
108
105
|
"normalizeBasePath",
|
|
109
106
|
"withBase",
|
|
110
107
|
"toExtractManifest"
|
|
@@ -415,6 +412,15 @@ function sourceLinkToCommentEnabled(opts) {
|
|
|
415
412
|
if (opts?.templates?.default?.sourceLinkToComment === true) return true;
|
|
416
413
|
return false;
|
|
417
414
|
}
|
|
415
|
+
function cleanOutputDirEnabled(opts) {
|
|
416
|
+
try {
|
|
417
|
+
const env = __require("jsdoc/env");
|
|
418
|
+
if (env?.conf?.templates?.default?.cleanOutputDir === false) return false;
|
|
419
|
+
} catch {
|
|
420
|
+
}
|
|
421
|
+
if (opts?.templates?.default?.cleanOutputDir === false) return false;
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
418
424
|
function hasMarkdownPlugin(plugins) {
|
|
419
425
|
if (!Array.isArray(plugins)) return false;
|
|
420
426
|
return plugins.some((p) => typeof p === "string" && /(^|[\\/])markdown(\.js)?$/i.test(p.trim()));
|
|
@@ -759,16 +765,16 @@ function createBuildProgress(ora) {
|
|
|
759
765
|
return { stage };
|
|
760
766
|
}
|
|
761
767
|
function readBuildSpec() {
|
|
762
|
-
const
|
|
763
|
-
if (!
|
|
764
|
-
const spec = JSON.parse(readFileSync(
|
|
768
|
+
const path2 = process.env.CLEAN_JSDOC_THEME_BUILD?.trim();
|
|
769
|
+
if (!path2) return null;
|
|
770
|
+
const spec = JSON.parse(readFileSync(path2, "utf8"));
|
|
765
771
|
if (typeof spec.version === "number" && spec.version !== 1) {
|
|
766
772
|
throw new Error(
|
|
767
773
|
`clean-jsdoc-theme: build spec version ${spec.version} unsupported (expected 1) \u2014 update clean-jsdoc-theme and aadesh together.`
|
|
768
774
|
);
|
|
769
775
|
}
|
|
770
776
|
if (typeof spec.destination !== "string" || typeof spec.basePath !== "string") {
|
|
771
|
-
throw new Error(`clean-jsdoc-theme: malformed build spec at "${
|
|
777
|
+
throw new Error(`clean-jsdoc-theme: malformed build spec at "${path2}".`);
|
|
772
778
|
}
|
|
773
779
|
return {
|
|
774
780
|
locale: typeof spec.locale === "string" ? spec.locale : "",
|
|
@@ -806,6 +812,7 @@ async function publish(data, opts, tutorials) {
|
|
|
806
812
|
createGoogleFontResolver,
|
|
807
813
|
formatDiagnostics,
|
|
808
814
|
formatBuildReport,
|
|
815
|
+
formatRenderError,
|
|
809
816
|
normalizeBasePath,
|
|
810
817
|
withBase,
|
|
811
818
|
toExtractManifest
|
|
@@ -966,6 +973,12 @@ async function publish(data, opts, tutorials) {
|
|
|
966
973
|
...docImageFiles,
|
|
967
974
|
...favicon?.files ?? []
|
|
968
975
|
];
|
|
976
|
+
if (!buildSpec && cleanOutputDirEnabled(opts)) {
|
|
977
|
+
await progress.stage(
|
|
978
|
+
"Cleaning output",
|
|
979
|
+
() => rm(absoluteDestination, { recursive: true, force: true })
|
|
980
|
+
);
|
|
981
|
+
}
|
|
969
982
|
await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
|
|
970
983
|
const zlib = await import("zlib");
|
|
971
984
|
const gzipSizer = (b) => zlib.gzipSync(b).length;
|
|
@@ -983,7 +996,15 @@ async function publish(data, opts, tutorials) {
|
|
|
983
996
|
`clean-jsdoc-theme: ${result.errors.length} page(s) failed to render and were skipped:`
|
|
984
997
|
);
|
|
985
998
|
for (const e of result.errors) {
|
|
986
|
-
console.warn(
|
|
999
|
+
console.warn(formatRenderError(e));
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
if (result.warnings && result.warnings.length > 0) {
|
|
1003
|
+
console.warn(
|
|
1004
|
+
`clean-jsdoc-theme: ${result.warnings.length} content warning(s) (non-fatal):`
|
|
1005
|
+
);
|
|
1006
|
+
for (const w of result.warnings) {
|
|
1007
|
+
console.warn(formatRenderError(w));
|
|
987
1008
|
}
|
|
988
1009
|
}
|
|
989
1010
|
try {
|
|
@@ -996,6 +1017,7 @@ async function publish(data, opts, tutorials) {
|
|
|
996
1017
|
}
|
|
997
1018
|
}
|
|
998
1019
|
export {
|
|
1020
|
+
cleanOutputDirEnabled,
|
|
999
1021
|
collectDocs,
|
|
1000
1022
|
computeRelPaths,
|
|
1001
1023
|
hasMarkdownPlugin,
|