clean-jsdoc-theme 5.0.3 → 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/dist/publish.d.mts +14 -2
- package/dist/publish.d.ts +14 -2
- package/dist/publish.js +18 -11
- package/dist/publish.js.map +1 -1
- package/dist/publish.mjs +29 -17
- 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) {
|
|
@@ -416,6 +412,15 @@ function sourceLinkToCommentEnabled(opts) {
|
|
|
416
412
|
if (opts?.templates?.default?.sourceLinkToComment === true) return true;
|
|
417
413
|
return false;
|
|
418
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
|
+
}
|
|
419
424
|
function hasMarkdownPlugin(plugins) {
|
|
420
425
|
if (!Array.isArray(plugins)) return false;
|
|
421
426
|
return plugins.some((p) => typeof p === "string" && /(^|[\\/])markdown(\.js)?$/i.test(p.trim()));
|
|
@@ -760,16 +765,16 @@ function createBuildProgress(ora) {
|
|
|
760
765
|
return { stage };
|
|
761
766
|
}
|
|
762
767
|
function readBuildSpec() {
|
|
763
|
-
const
|
|
764
|
-
if (!
|
|
765
|
-
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"));
|
|
766
771
|
if (typeof spec.version === "number" && spec.version !== 1) {
|
|
767
772
|
throw new Error(
|
|
768
773
|
`clean-jsdoc-theme: build spec version ${spec.version} unsupported (expected 1) \u2014 update clean-jsdoc-theme and aadesh together.`
|
|
769
774
|
);
|
|
770
775
|
}
|
|
771
776
|
if (typeof spec.destination !== "string" || typeof spec.basePath !== "string") {
|
|
772
|
-
throw new Error(`clean-jsdoc-theme: malformed build spec at "${
|
|
777
|
+
throw new Error(`clean-jsdoc-theme: malformed build spec at "${path2}".`);
|
|
773
778
|
}
|
|
774
779
|
return {
|
|
775
780
|
locale: typeof spec.locale === "string" ? spec.locale : "",
|
|
@@ -968,6 +973,12 @@ async function publish(data, opts, tutorials) {
|
|
|
968
973
|
...docImageFiles,
|
|
969
974
|
...favicon?.files ?? []
|
|
970
975
|
];
|
|
976
|
+
if (!buildSpec && cleanOutputDirEnabled(opts)) {
|
|
977
|
+
await progress.stage(
|
|
978
|
+
"Cleaning output",
|
|
979
|
+
() => rm(absoluteDestination, { recursive: true, force: true })
|
|
980
|
+
);
|
|
981
|
+
}
|
|
971
982
|
await progress.stage("Writing files", () => writeOutputFiles(absoluteDestination, outputFiles));
|
|
972
983
|
const zlib = await import("zlib");
|
|
973
984
|
const gzipSizer = (b) => zlib.gzipSync(b).length;
|
|
@@ -1006,6 +1017,7 @@ async function publish(data, opts, tutorials) {
|
|
|
1006
1017
|
}
|
|
1007
1018
|
}
|
|
1008
1019
|
export {
|
|
1020
|
+
cleanOutputDirEnabled,
|
|
1009
1021
|
collectDocs,
|
|
1010
1022
|
computeRelPaths,
|
|
1011
1023
|
hasMarkdownPlugin,
|