@t8/docsgen 0.2.40 → 0.2.42

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/bin.js CHANGED
@@ -1,27 +1,4 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
25
2
 
26
3
  // node_modules/args-json/dist/index.js
27
4
  function toCamelCase(x) {
@@ -111,7 +88,7 @@ function parseArgs(input, map) {
111
88
  }
112
89
 
113
90
  // src/bin/fetchContent.ts
114
- var import_promises = require("node:fs/promises");
91
+ import { readFile } from "node:fs/promises";
115
92
  async function fetchContent(location) {
116
93
  if (!location) return "";
117
94
  if (/^https?:\/\//.test(location)) {
@@ -123,7 +100,7 @@ async function fetchContent(location) {
123
100
  }
124
101
  }
125
102
  let locationPath = location.replace(/^\//, "");
126
- return (await (0, import_promises.readFile)(locationPath)).toString();
103
+ return (await readFile(locationPath)).toString();
127
104
  }
128
105
 
129
106
  // src/bin/getLocation.ts
@@ -138,11 +115,11 @@ function getLocation(ctx, path, preferredLocation) {
138
115
  }
139
116
 
140
117
  // src/bin/stripHTML.ts
141
- var import_jsdom = require("jsdom");
118
+ import { JSDOM } from "jsdom";
142
119
  function stripHTML(content, replaceNbsp = false) {
143
120
  try {
144
121
  let t = content.replaceAll("<sup>", " (").replaceAll("</sup>", ")");
145
- let s = new import_jsdom.JSDOM(t).window.document.body.textContent;
122
+ let s = new JSDOM(t).window.document.body.textContent;
146
123
  if (replaceNbsp) s = s.replaceAll("\xA0", " ");
147
124
  s = s.replace(/ +/g, " ");
148
125
  return s;
@@ -243,40 +220,40 @@ async function getConfig() {
243
220
  }
244
221
 
245
222
  // src/bin/runEntry.ts
246
- var import_node_child_process2 = require("node:child_process");
247
- var import_promises7 = require("node:fs/promises");
248
- var import_node_util2 = require("node:util");
223
+ import { exec as defaultExec2 } from "node:child_process";
224
+ import { access as access3 } from "node:fs/promises";
225
+ import { promisify as promisify2 } from "node:util";
249
226
 
250
227
  // src/bin/cleanup.ts
251
- var import_promises2 = require("node:fs/promises");
252
- var import_node_path = require("node:path");
228
+ import { rm } from "node:fs/promises";
229
+ import { join } from "node:path";
253
230
  async function cleanup({ dir = "" }) {
254
231
  await Promise.all(
255
232
  ["x", "index.html", "start.html"].map((path) => {
256
- return (0, import_promises2.rm)((0, import_node_path.join)(dir, path), { force: true, recursive: true });
233
+ return rm(join(dir, path), { force: true, recursive: true });
257
234
  })
258
235
  );
259
236
  }
260
237
 
261
238
  // src/bin/createFiles.ts
262
- var import_promises6 = require("node:fs/promises");
239
+ import { access as access2, mkdir as mkdir2 } from "node:fs/promises";
263
240
 
264
241
  // src/bin/setCName.ts
265
- var import_promises3 = require("node:fs/promises");
266
- var import_node_path2 = require("node:path");
242
+ import { writeFile } from "node:fs/promises";
243
+ import { join as join2 } from "node:path";
267
244
  async function setCName({ dir = "", name, cname, jsorg }) {
268
245
  let domain = "";
269
246
  if (cname) domain = cname;
270
247
  else if (typeof jsorg === "string") domain = jsorg ? `${jsorg}.js.org` : "";
271
248
  else if (jsorg === true) domain = name ? `${name}.js.org` : "";
272
- if (domain !== "") await (0, import_promises3.writeFile)((0, import_node_path2.join)(dir, "CNAME"), domain);
249
+ if (domain !== "") await writeFile(join2(dir, "CNAME"), domain);
273
250
  }
274
251
 
275
252
  // src/bin/setContent.ts
276
- var import_node_child_process = require("node:child_process");
277
- var import_promises4 = require("node:fs/promises");
278
- var import_node_path3 = require("node:path");
279
- var import_node_util = require("node:util");
253
+ import { exec as defaultExec } from "node:child_process";
254
+ import { access, cp, mkdir, writeFile as writeFile2 } from "node:fs/promises";
255
+ import { join as join3 } from "node:path";
256
+ import { promisify } from "node:util";
280
257
 
281
258
  // src/const/packageName.ts
282
259
  var packageName = "@t8/docsgen";
@@ -352,7 +329,7 @@ function getInjectedContent(ctx, page, target, mode = "append") {
352
329
  }
353
330
 
354
331
  // src/bin/getNav.ts
355
- var import_jsdom2 = require("jsdom");
332
+ import { JSDOM as JSDOM2 } from "jsdom";
356
333
 
357
334
  // src/bin/getRepoLink.ts
358
335
  function getRepoLink({ repo }, className) {
@@ -367,7 +344,7 @@ async function getNav(ctx, navItems) {
367
344
  let navContent = await fetchContent(nav);
368
345
  let s = "";
369
346
  if (navContent) {
370
- let navDom = new import_jsdom2.JSDOM(navContent).window.document.body;
347
+ let navDom = new JSDOM2(navContent).window.document.body;
371
348
  for (let link of navDom.querySelectorAll("a")) {
372
349
  if (link.dataset.name === name) {
373
350
  let parent = link.parentElement;
@@ -454,8 +431,8 @@ function getTitle(ctx, { cover, originalContent, withPackageURL } = {}) {
454
431
  }
455
432
 
456
433
  // src/bin/parsing/getParsedContent.ts
457
- var import_jsdom3 = require("jsdom");
458
- var import_markdown_it = __toESM(require("markdown-it"), 1);
434
+ import { JSDOM as JSDOM3 } from "jsdom";
435
+ import Markdown from "markdown-it";
459
436
 
460
437
  // src/bin/getSlug.ts
461
438
  function getSlug(title) {
@@ -579,7 +556,7 @@ function preprocessContent(s) {
579
556
  }
580
557
 
581
558
  // src/bin/parsing/getParsedContent.ts
582
- var md = new import_markdown_it.default({
559
+ var md = new Markdown({
583
560
  html: true
584
561
  });
585
562
  async function getParsedContent(ctx) {
@@ -588,7 +565,7 @@ async function getParsedContent(ctx) {
588
565
  getLocation(ctx, "README.md", ctx.source)
589
566
  );
590
567
  let content = md.render(preprocessContent(rawContent));
591
- let dom = new import_jsdom3.JSDOM(content);
568
+ let dom = new JSDOM3(content);
592
569
  let { nav, linkMap: navLinkMap } = buildNav(ctx, dom);
593
570
  let badges = "";
594
571
  let title = "";
@@ -688,7 +665,7 @@ function toFileContent(x) {
688
665
  }
689
666
 
690
667
  // src/bin/setContent.ts
691
- var exec = (0, import_node_util.promisify)(import_node_child_process.exec);
668
+ var exec = promisify(defaultExec);
692
669
  function getDefaultCodeStyleContent(cssRoot) {
693
670
  return `
694
671
  <link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/stackoverflow-light.min.css" media="(prefers-color-scheme: light)">
@@ -728,7 +705,7 @@ async function setContent(ctx) {
728
705
  if (assetsDir) {
729
706
  cssRoot.index = assetsDir;
730
707
  cssRoot.content = `../${assetsDir}`;
731
- await (0, import_promises4.cp)((0, import_node_path3.join)(__dirname, "css"), (0, import_node_path3.join)(dir, cssRoot.index), {
708
+ await cp(join3(__dirname, "css"), join3(dir, cssRoot.index), {
732
709
  force: true,
733
710
  recursive: true
734
711
  });
@@ -749,8 +726,8 @@ async function setContent(ctx) {
749
726
  let iconTag = icon.url ? `<link rel="icon"${icon.type ? ` type="${icon.type}"` : ""} href="${icon.url}">` : "";
750
727
  if (redirect) {
751
728
  let escapedRedirect = escapeHTML(redirect);
752
- await (0, import_promises4.writeFile)(
753
- (0, import_node_path3.join)(dir, "index.html"),
729
+ await writeFile2(
730
+ join3(dir, "index.html"),
754
731
  toFileContent(`
755
732
  <!DOCTYPE html>
756
733
  <html lang="en" class="blank"${rootAttrs}>
@@ -777,18 +754,18 @@ ${getInjectedContent(ctx, "redirect", "body")}
777
754
  let dirs = [contentDir];
778
755
  await Promise.all(
779
756
  dirs.map(async (path) => {
780
- let dirPath = (0, import_node_path3.join)(dir, path);
757
+ let dirPath = join3(dir, path);
781
758
  try {
782
- await (0, import_promises4.access)(dirPath);
759
+ await access(dirPath);
783
760
  } catch {
784
- await (0, import_promises4.mkdir)(dirPath);
761
+ await mkdir(dirPath);
785
762
  }
786
763
  })
787
764
  );
788
765
  await Promise.all([
789
766
  ...sections.map(
790
- async (content, i) => (0, import_promises4.writeFile)(
791
- (0, import_node_path3.join)(dir, contentDir, `${nav[i]?.id ?? `_untitled_${i}`}.html`),
767
+ async (content, i) => writeFile2(
768
+ join3(dir, contentDir, `${nav[i]?.id ?? `_untitled_${i}`}.html`),
792
769
  toFileContent(`
793
770
  <!DOCTYPE html>
794
771
  <html lang="en"${rootAttrs}>
@@ -838,8 +815,8 @@ ${getInjectedContent(ctx, "section", "body")}
838
815
  `)
839
816
  )
840
817
  ),
841
- (0, import_promises4.writeFile)(
842
- (0, import_node_path3.join)(dir, "index.html"),
818
+ writeFile2(
819
+ join3(dir, "index.html"),
843
820
  toFileContent(`
844
821
  <!DOCTYPE html>
845
822
  <html lang="en"${rootAttrs}>
@@ -895,8 +872,8 @@ ${getInjectedContent(ctx, "index", "body")}
895
872
  </html>
896
873
  `)
897
874
  ),
898
- (0, import_promises4.writeFile)(
899
- (0, import_node_path3.join)(dir, "start.html"),
875
+ writeFile2(
876
+ join3(dir, "start.html"),
900
877
  toFileContent(`
901
878
  <!DOCTYPE html>
902
879
  <html lang="en" class="blank"${rootAttrs}>
@@ -925,8 +902,8 @@ ${getInjectedContent(ctx, "start", "body")}
925
902
  }
926
903
 
927
904
  // src/bin/setImages.ts
928
- var import_promises5 = require("node:fs/promises");
929
- var import_node_path4 = require("node:path");
905
+ import { writeFile as writeFile3 } from "node:fs/promises";
906
+ import { join as join4 } from "node:path";
930
907
 
931
908
  // src/utils/getIconContent.ts
932
909
  function getIconContent(baseColor = "gray") {
@@ -946,7 +923,7 @@ function getIconContent(baseColor = "gray") {
946
923
  // src/bin/setImages.ts
947
924
  async function setImages({ dir = "", baseColor, favicon }) {
948
925
  if (favicon) return;
949
- await (0, import_promises5.writeFile)((0, import_node_path4.join)(dir, "./favicon.svg"), `${getIconContent(baseColor)}
926
+ await writeFile3(join4(dir, "./favicon.svg"), `${getIconContent(baseColor)}
950
927
  `);
951
928
  }
952
929
 
@@ -955,20 +932,20 @@ async function createFiles(ctx) {
955
932
  let { dir } = ctx;
956
933
  if (dir) {
957
934
  try {
958
- await (0, import_promises6.access)(dir);
935
+ await access2(dir);
959
936
  } catch {
960
- await (0, import_promises6.mkdir)(dir);
937
+ await mkdir2(dir);
961
938
  }
962
939
  }
963
940
  await Promise.all([setCName(ctx), setContent(ctx), setImages(ctx)]);
964
941
  }
965
942
 
966
943
  // src/bin/runEntry.ts
967
- var exec2 = (0, import_node_util2.promisify)(import_node_child_process2.exec);
944
+ var exec2 = promisify2(defaultExec2);
968
945
  var stdout = async (cmd) => (await exec2(cmd)).stdout.trim();
969
946
  async function isGitDir() {
970
947
  try {
971
- await (0, import_promises7.access)("./.git");
948
+ await access3("./.git");
972
949
  return true;
973
950
  } catch {
974
951
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/docsgen",
3
- "version": "0.2.40",
3
+ "version": "0.2.42",
4
4
  "description": "",
5
5
  "main": "dist/bin.js",
6
6
  "type": "module",
@@ -9,11 +9,11 @@
9
9
  },
10
10
  "scripts": {
11
11
  "build": "npx npm-run-all clean build-bin build-css",
12
- "build-bin": "npx esbuild ./src/bin/run.ts --bundle --outfile=dist/bin.js --platform=node --external:jsdom --external:markdown-it",
12
+ "build-bin": "npx esbuild ./src/bin/run.ts --bundle --outfile=dist/bin.js --platform=node --external:jsdom --external:markdown-it --format=esm",
13
13
  "build-css": "node -e \"require('node:fs').cpSync('src/css', 'dist/css', { force: true, recursive: true });\"",
14
14
  "build-schema": "npx ts-json-schema-generator -p src/types/Config.ts -t Config -o schema.json --minify",
15
15
  "clean": "node -e \"require('node:fs').rmSync('dist', { force: true, recursive: true });\"",
16
- "postinstall": "node src/scripts/postinstall.ts",
16
+ "patch": "node src/scripts/patch.ts",
17
17
  "prepublishOnly": "npm run build",
18
18
  "preversion": "npx npm-run-all shape build-schema build",
19
19
  "shape": "npx codeshape --typecheck"
File without changes