docgen-tool 5.0.0-beta.1 → 5.0.0-beta.3

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.
Files changed (2) hide show
  1. package/dist/cli.js +17 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { program } from 'commander';
3
3
  import pico from 'picocolors';
4
- import path from 'path';
4
+ import path, { dirname, join } from 'path';
5
5
  import { promises } from 'fs';
6
6
  import fs from 'fs-extra';
7
+ import { fileURLToPath } from 'url';
7
8
  import schemaValidator from 'z-schema';
8
9
  import * as cheerio from 'cheerio';
9
10
  import MarkdownIt from 'markdown-it';
@@ -13,6 +14,8 @@ import Html from 'react-pdf-html';
13
14
  import pkg from 'lodash';
14
15
  import ReactDOMServer from 'react-dom/server';
15
16
 
17
+ fileURLToPath(new URL(".", import.meta.url));
18
+ dirname(fileURLToPath(import.meta.url));
16
19
  const readFile = async (filePath) => {
17
20
  const normalized = path.normalize(filePath);
18
21
  try {
@@ -264,6 +267,8 @@ const loadMeta = async ({
264
267
  }
265
268
  };
266
269
 
270
+ const packageAbsolutePath = import.meta.dirname;
271
+
267
272
  const loadTemplates = async ({
268
273
  options,
269
274
  mainProcess
@@ -272,8 +277,10 @@ const loadTemplates = async ({
272
277
  console.log(pico.green("Loading templates"));
273
278
  try {
274
279
  let files = {
275
- main: await readFile("./src/include/templates/main.html"),
276
- redirect: await readFile("./src/include/templates/redirect.html")
280
+ main: await readFile(join(packageAbsolutePath, "include/templates/main.html")),
281
+ redirect: await readFile(
282
+ join(packageAbsolutePath, "include/templates/redirect.html")
283
+ )
277
284
  };
278
285
  for (let key in files) {
279
286
  if (files.hasOwnProperty(key)) {
@@ -730,7 +737,11 @@ const generatePdf = ({
730
737
 
731
738
  const scaffold$1 = async ({ outputDirectory, verbose }) => {
732
739
  console.log(pico.green("Creating scaffold template directory"));
733
- await copyDirectory("./src/include/example", outputDirectory, verbose);
740
+ await copyDirectory(
741
+ join(packageAbsolutePath, "include/example"),
742
+ outputDirectory,
743
+ verbose
744
+ );
734
745
  };
735
746
 
736
747
  const sortPages = ({ contents }) => {
@@ -1023,7 +1034,7 @@ const writePages = async ({
1023
1034
  await Promise.all(promises);
1024
1035
  await writeFile(options.output + "ownership.html", hydratedPages.webCover);
1025
1036
  await copyDirectory(
1026
- "./src/include/require",
1037
+ join(packageAbsolutePath, "include/require"),
1027
1038
  options.output + "require",
1028
1039
  options.verbose
1029
1040
  );
@@ -1063,7 +1074,7 @@ let createRedirect = async ({ options, redirectPage, homePage }) => {
1063
1074
  }
1064
1075
  };
1065
1076
 
1066
- var version = "5.0.0-beta.1";
1077
+ var version = "5.0.0-beta.2";
1067
1078
 
1068
1079
  function DocGen(process) {
1069
1080
  let mainProcess = process;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docgen-tool",
3
3
  "type": "module",
4
- "version": "5.0.0-beta.1",
4
+ "version": "5.0.0-beta.3",
5
5
  "description": "A tool for creating HTML and PDF documentation",
6
6
  "bin": "./dist/cli.js",
7
7
  "files": [