js-build-tools 6.5.0 → 6.7.0

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 (169) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +762 -692
  3. package/babel.config.js +28 -28
  4. package/dist/build.js +75 -75
  5. package/dist/bundle.js +19 -19
  6. package/dist/bundleMinify.js +7 -7
  7. package/dist/compileReadme.js +4 -4
  8. package/dist/copyFiles.js +17 -17
  9. package/dist/copyFonts.js +4 -4
  10. package/dist/default.js +5 -5
  11. package/dist/dist.js +4 -4
  12. package/dist/distMinify.js +4 -4
  13. package/dist/docs.js +7 -7
  14. package/dist/images.js +4 -4
  15. package/dist/jsdocDocs.js +6 -6
  16. package/dist/lint.js +16 -16
  17. package/dist/partials/addToReadme.js +9 -9
  18. package/dist/partials/beginWatcher.js +4 -4
  19. package/dist/partials/clean.js +5 -5
  20. package/dist/partials/copyFor.js +9 -9
  21. package/dist/partials/distFor.js +6 -6
  22. package/dist/partials/distForSrc.js +5 -5
  23. package/dist/partials/distSeries.js +7 -7
  24. package/dist/partials/imagesFor.js +93 -56
  25. package/dist/partials/jsdocDocsFor.js +46 -46
  26. package/dist/partials/lintSource.js +51 -51
  27. package/dist/partials/loadPeer.js +99 -99
  28. package/dist/partials/loadPlaywright.js +14 -14
  29. package/dist/partials/minifyFor.js +20 -20
  30. package/dist/partials/neostandardLint.js +175 -175
  31. package/dist/partials/readmeTemplate.js +4 -4
  32. package/dist/partials/removeDirectory.js +11 -11
  33. package/dist/partials/resolveDocsMethod.js +6 -6
  34. package/dist/partials/runOnChange.js +31 -31
  35. package/dist/partials/sassFor.js +6 -6
  36. package/dist/partials/serveStatic.js +9 -9
  37. package/dist/partials/tsFor.js +32 -32
  38. package/dist/partials/typeDocsFor.js +57 -51
  39. package/dist/partials.js +176 -176
  40. package/dist/sourceLint.js +18 -18
  41. package/dist/test-helpers/isolateGulpCache.js +24 -24
  42. package/dist/test-helpers/setUp.js +4 -4
  43. package/dist/testFull.js +5 -5
  44. package/dist/testQuick.js +5 -5
  45. package/dist/typeDocs.js +5 -5
  46. package/dist/typeScript.js +4 -4
  47. package/dist/utilities/convertMjsFilesForDocs.js +12 -12
  48. package/dist/utilities/dotGet.js +54 -54
  49. package/dist/utilities/dotNotate.js +79 -79
  50. package/dist/utilities/dotSet.js +45 -45
  51. package/dist/utilities/esmNamedExportsToCjs.js +15 -15
  52. package/dist/utilities/getBundleConfigs.js +9 -9
  53. package/dist/utilities/isObject.js +6 -6
  54. package/dist/utilities/strAfter.js +7 -7
  55. package/dist/utilities/strBefore.js +7 -7
  56. package/dist/watchFull.js +4 -4
  57. package/dist/watchTest.js +4 -4
  58. package/functions/build.mjs +72 -72
  59. package/functions/build.test.mjs +763 -759
  60. package/functions/bundle.mjs +44 -44
  61. package/functions/bundle.test.mjs +219 -219
  62. package/functions/bundleMinify.mjs +16 -16
  63. package/functions/bundleMinify.test.mjs +37 -37
  64. package/functions/compileReadme.mjs +9 -9
  65. package/functions/compileReadme.test.mjs +18 -18
  66. package/functions/copyFiles.mjs +32 -32
  67. package/functions/copyFiles.test.mjs +78 -78
  68. package/functions/copyFonts.mjs +9 -9
  69. package/functions/copyFonts.test.mjs +32 -32
  70. package/functions/default.mjs +12 -12
  71. package/functions/default.test.mjs +33 -33
  72. package/functions/dist.mjs +8 -8
  73. package/functions/dist.test.mjs +44 -44
  74. package/functions/distMinify.mjs +9 -9
  75. package/functions/distMinify.test.mjs +15 -15
  76. package/functions/docs.mjs +13 -13
  77. package/functions/docs.test.mjs +45 -45
  78. package/functions/gulpConfigEntries.test.mjs +23 -23
  79. package/functions/images.mjs +8 -8
  80. package/functions/images.test.mjs +142 -142
  81. package/functions/jsdocDocs.mjs +10 -10
  82. package/functions/jsdocEsmExports.test.mjs +24 -24
  83. package/functions/lint.mjs +9 -9
  84. package/functions/partials/addToReadme.mjs +25 -25
  85. package/functions/partials/addToReadme.test.mjs +34 -34
  86. package/functions/partials/beginWatcher.mjs +9 -9
  87. package/functions/partials/beginWatcher.test.mjs +19 -19
  88. package/functions/partials/clean.mjs +13 -13
  89. package/functions/partials/clean.test.mjs +22 -22
  90. package/functions/partials/copyFor.mjs +15 -15
  91. package/functions/partials/copyFor.test.mjs +53 -53
  92. package/functions/partials/distFor.mjs +22 -22
  93. package/functions/partials/distFor.test.mjs +195 -195
  94. package/functions/partials/distForSrc.mjs +11 -11
  95. package/functions/partials/distForSrc.test.mjs +18 -18
  96. package/functions/partials/distSeries.mjs +21 -21
  97. package/functions/partials/distSeries.test.mjs +34 -34
  98. package/functions/partials/imagesFor.mjs +83 -50
  99. package/functions/partials/imagesFor.test.mjs +287 -229
  100. package/functions/partials/jsdocDocsFor.mjs +163 -152
  101. package/functions/partials/jsdocDocsFor.test.mjs +182 -152
  102. package/functions/partials/lintSource.mjs +41 -41
  103. package/functions/partials/loadPeer.mjs +76 -76
  104. package/functions/partials/loadPeer.test.mjs +58 -58
  105. package/functions/partials/loadPlaywright.mjs +23 -23
  106. package/functions/partials/loadPlaywright.test.mjs +70 -70
  107. package/functions/partials/minifyFor.mjs +15 -15
  108. package/functions/partials/minifyFor.test.mjs +49 -49
  109. package/functions/partials/neostandardLint.mjs +142 -142
  110. package/functions/partials/neostandardLint.test.mjs +131 -131
  111. package/functions/partials/readmeTemplate.mjs +12 -12
  112. package/functions/partials/readmeTemplate.test.mjs +34 -34
  113. package/functions/partials/removeDirectory.mjs +34 -34
  114. package/functions/partials/removeDirectory.test.mjs +72 -72
  115. package/functions/partials/resolveDocsMethod.mjs +10 -10
  116. package/functions/partials/resolveDocsMethod.test.mjs +33 -33
  117. package/functions/partials/runOnChange.mjs +54 -54
  118. package/functions/partials/runOnChange.test.mjs +95 -95
  119. package/functions/partials/sassFor.mjs +25 -25
  120. package/functions/partials/sassFor.test.mjs +81 -81
  121. package/functions/partials/serveStatic.mjs +47 -47
  122. package/functions/partials/serveStatic.test.mjs +71 -71
  123. package/functions/partials/tsFor.mjs +92 -92
  124. package/functions/partials/tsFor.test.mjs +88 -88
  125. package/functions/partials/typeDocsFor.mjs +231 -227
  126. package/functions/partials/typeDocsFor.test.mjs +263 -252
  127. package/functions/partials.mjs +31 -31
  128. package/functions/partials.test.mjs +7 -7
  129. package/functions/sass.mjs +4 -4
  130. package/functions/sass.test.mjs +31 -31
  131. package/functions/sourceLint.mjs +13 -13
  132. package/functions/sourceLint.test.mjs +166 -166
  133. package/functions/test-helpers/isolateGulpCache.mjs +16 -16
  134. package/functions/test-helpers/neostandardLintWithRealNeostandard.mjs +40 -40
  135. package/functions/test-helpers/setUp.mjs +100 -100
  136. package/functions/test-helpers/setUp.test.mjs +19 -19
  137. package/functions/testFull.mjs +17 -17
  138. package/functions/testFull.test.mjs +17 -17
  139. package/functions/testHelpers.mjs +10 -10
  140. package/functions/testHelpers.test.mjs +7 -7
  141. package/functions/testQuick.mjs +17 -17
  142. package/functions/testQuick.test.mjs +17 -17
  143. package/functions/typeDocs.mjs +9 -9
  144. package/functions/typeDocs.test.mjs +11 -11
  145. package/functions/typeScript.mjs +8 -8
  146. package/functions/typeScript.test.mjs +11 -11
  147. package/functions/utilities/convertMjsFilesForDocs.mjs +34 -34
  148. package/functions/utilities/convertMjsFilesForDocs.test.mjs +58 -58
  149. package/functions/utilities/dotGet.mjs +49 -49
  150. package/functions/utilities/dotNotate.mjs +73 -73
  151. package/functions/utilities/dotNotate.test.mjs +41 -41
  152. package/functions/utilities/dotSet.mjs +40 -40
  153. package/functions/utilities/esmNamedExportsToCjs.mjs +30 -30
  154. package/functions/utilities/esmNamedExportsToCjs.test.mjs +47 -47
  155. package/functions/utilities/getBundleConfigs.mjs +30 -30
  156. package/functions/utilities/isObject.mjs +8 -8
  157. package/functions/utilities/strAfter.mjs +12 -12
  158. package/functions/utilities/strBefore.mjs +12 -12
  159. package/functions/watchFull.mjs +9 -9
  160. package/functions/watchFull.test.mjs +41 -41
  161. package/functions/watchTest.mjs +10 -10
  162. package/functions/watchTest.test.mjs +49 -49
  163. package/gulp.config.js +4 -4
  164. package/gulp.config.mjs +344 -327
  165. package/gulpfile.base.js +51 -51
  166. package/gulpfile.base.mjs +29 -29
  167. package/jsdoc.base.js +16 -16
  168. package/jsdoc.esmExports.js +17 -17
  169. package/package.json +146 -145
@@ -12,13 +12,13 @@ var _gulp = require("gulp");
12
12
  var _tsFor = require("./tsFor.js");
13
13
  var cache;
14
14
  function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
15
- /**
16
- * When using TypeScript, ensure that we process the ts first then run babel (dist)
17
- * @memberOf module:partials
18
- * @param {string} [srcPath='src/config/path/dist/for']
19
- * @param {string} [distFinalPath='dist/config/path']
20
- * @param {string} [tsSearch='ts/search/config/path']
21
- * @returns {function(null=): stream.Stream}
15
+ /**
16
+ * When using TypeScript, ensure that we process the ts first then run babel (dist)
17
+ * @memberOf module:partials
18
+ * @param {string} [srcPath='src/config/path/dist/for']
19
+ * @param {string} [distFinalPath='dist/config/path']
20
+ * @param {string} [tsSearch='ts/search/config/path']
21
+ * @returns {function(null=): stream.Stream}
22
22
  */
23
23
  const distSeries = (srcPath = (0, _distForSrc.distForSrc)(), distFinalPath = gulpConfig.get('dist.to'), tsSearch = gulpConfig.get('typescript.from')) => {
24
24
  const typescript = (0, _tsFor.tsFor)(tsSearch, distFinalPath);
@@ -1,57 +1,94 @@
1
- "use strict";
2
-
3
- require("core-js/modules/esnext.weak-map.delete-all.js");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.loadImagemin = exports.imagesFor = void 0;
8
- var _gulpCache = _interopRequireDefault(require("gulp-cache"));
9
- var _loadPeer = require("./loadPeer.js");
10
- var _gulp = require("gulp");
11
- var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
12
- var cache;
13
- function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- const installHint = 'Add it to your project with: npm install --save-dev github:jheagle/gulp-imagemin#common-js-compatibility ' + '(the CommonJS-compatible fork - upstream gulp-imagemin is ESM-only and cannot be require()d by this package\'s CommonJS build).';
16
-
17
- /**
18
- * Load `gulp-imagemin`, an optional peer dependency: image optimization is off by default and its binary-download
19
- * dependency chain is heavy, so it is only required once the images task actually runs, and it is resolved from the
20
- * consuming project's own directory rather than from this package.
21
- * @memberOf module:partials
22
- * @param {string} [projectPath=process.cwd()] - The project directory to resolve `gulp-imagemin` from.
23
- * @returns {Function} The gulp-imagemin plugin factory.
24
- * @throws {Error} With install instructions when gulp-imagemin is missing or is the ESM-only upstream release.
25
- */
26
- const loadImagemin = (projectPath = process.cwd()) => {
27
- const loaded = (0, _loadPeer.requirePeer)('gulp-imagemin', {
28
- task: 'images',
29
- installHint,
30
- esmOnlyMessage: `gulp-imagemin could not be loaded because it is ESM-only. ${installHint}`,
31
- projectPath
32
- });
33
- return loaded && (loaded.__esModule || loaded.default) ? loaded.default : loaded;
34
- };
35
-
36
- /**
37
- * Move and optimize images into the browser directory.
38
- * @memberOf module:partials
39
- * @param {string|array} [imageSrc=src/images/pattern]
40
- * @param {string} [imageDest=dest/image/folder]
41
- * @return {stream.Stream}
42
- */
43
- exports.loadImagemin = loadImagemin;
44
- const imagesFor = (imageSrc = gulpConfig.get('images.from'), imageDest = gulpConfig.get('images.to')) => {
45
- const imagemin = loadImagemin();
46
- // Gulp 5 reads files as utf8 text unless told otherwise, which corrupts binary images (and makes gulp-cache drop them).
47
- return (0, _gulp.src)(imageSrc, {
48
- encoding: false
49
- }).pipe(
50
- // Caching images that ran through imagemin
51
- (0, _gulpCache.default)(imagemin({
52
- interlaced: true,
53
- silent: true,
54
- verbose: false
55
- }))).pipe((0, _gulp.dest)(imageDest));
56
- };
1
+ "use strict";
2
+
3
+ require("core-js/modules/esnext.weak-map.delete-all.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.loadImageminPlugins = exports.loadImagemin = exports.imagesFor = exports.imageminPlugins = void 0;
8
+ var _gulpCache = _interopRequireDefault(require("gulp-cache"));
9
+ var _loadPeer = require("./loadPeer.js");
10
+ var _gulp = require("gulp");
11
+ var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
12
+ var cache;
13
+ function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ const installHint = 'Add it to your project with: npm install --save-dev github:jheagle/gulp-imagemin#common-js-compatibility ' + '(the CommonJS-compatible fork - upstream gulp-imagemin is ESM-only and cannot be require()d by this package\'s CommonJS build).';
16
+
17
+ /**
18
+ * Load `gulp-imagemin`, an optional peer dependency: image optimization is off by default and its binary-download
19
+ * dependency chain is heavy, so it is only required once the images task actually runs, and it is resolved from the
20
+ * consuming project's own directory rather than from this package.
21
+ * @memberOf module:partials
22
+ * @param {string} [projectPath=process.cwd()] - The project directory to resolve `gulp-imagemin` from.
23
+ * @returns {Function} The gulp-imagemin plugin factory.
24
+ * @throws {Error} With install instructions when gulp-imagemin is missing or is the ESM-only upstream release.
25
+ */
26
+ const loadImagemin = (projectPath = process.cwd()) => {
27
+ const loaded = (0, _loadPeer.requirePeer)('gulp-imagemin', {
28
+ task: 'images',
29
+ installHint,
30
+ esmOnlyMessage: `gulp-imagemin could not be loaded because it is ESM-only. ${installHint}`,
31
+ projectPath
32
+ });
33
+ return loaded && (loaded.__esModule || loaded.default) ? loaded.default : loaded;
34
+ };
35
+
36
+ /**
37
+ * Load the plugins `gulp-imagemin` exports by name (gifsicle, mozjpeg, optipng and svgo), each a promise of a plugin
38
+ * factory, for when they need options of their own (see images.jpegQuality). Resolved like {@link loadImagemin}.
39
+ * @memberOf module:partials
40
+ * @param {string} [projectPath=process.cwd()] - The project directory to resolve `gulp-imagemin` from.
41
+ * @returns {Object<string, Promise<Function>>} The plugin factories, by name.
42
+ */
43
+ exports.loadImagemin = loadImagemin;
44
+ const loadImageminPlugins = (projectPath = process.cwd()) => (0, _loadPeer.requirePeer)('gulp-imagemin', {
45
+ task: 'images',
46
+ installHint,
47
+ esmOnlyMessage: `gulp-imagemin could not be loaded because it is ESM-only. ${installHint}`,
48
+ projectPath
49
+ });
50
+
51
+ // The plugins imagemin runs when it isn't given any, in its own order
52
+ exports.loadImageminPlugins = loadImageminPlugins;
53
+ const defaultPluginNames = ['gifsicle', 'mozjpeg', 'optipng', 'svgo'];
54
+
55
+ /**
56
+ * The plugins imagemin uses by default, with mozjpeg set to the given JPEG quality instead of its own default (75).
57
+ * @memberOf module:partials
58
+ * @param {number} jpegQuality - The mozjpeg quality, 0 to 100.
59
+ * @param {Object<string, Promise<Function>>} [plugins=loadImageminPlugins()] - The plugin factories, by name.
60
+ * @returns {Array<Promise<Function>>} The plugins, in imagemin's default order.
61
+ */
62
+ const imageminPlugins = (jpegQuality, plugins = loadImageminPlugins()) => defaultPluginNames.map(name => Promise.resolve(plugins[name]).then(makePlugin => name === 'mozjpeg' ? makePlugin({
63
+ quality: jpegQuality
64
+ }) : makePlugin()));
65
+
66
+ /**
67
+ * Move and optimize images into the browser directory.
68
+ * @memberOf module:partials
69
+ * @param {string|array} [imageSrc=src/images/pattern]
70
+ * @param {string} [imageDest=dest/image/folder]
71
+ * @return {stream.Stream}
72
+ */
73
+ exports.imageminPlugins = imageminPlugins;
74
+ const imagesFor = (imageSrc = gulpConfig.get('images.from'), imageDest = gulpConfig.get('images.to')) => {
75
+ const imagemin = loadImagemin();
76
+ const jpegQuality = gulpConfig.get('images.jpegQuality');
77
+ // Left unset, imagemin runs its default plugins with their own defaults
78
+ const plugins = jpegQuality ? imageminPlugins(jpegQuality) : undefined;
79
+ // Gulp 5 reads files as utf8 text unless told otherwise, which corrupts binary images (and makes gulp-cache drop them).
80
+ return (0, _gulp.src)(imageSrc, {
81
+ encoding: false
82
+ }).pipe(
83
+ // Caching images that ran through imagemin
84
+ (0, _gulpCache.default)(imagemin(plugins, {
85
+ interlaced: true,
86
+ silent: true,
87
+ verbose: false
88
+ }),
89
+ // gulp-cache keys on the file's contents alone, so keep each quality's results apart
90
+ {
91
+ name: jpegQuality ? `jpeg-quality-${jpegQuality}` : 'default'
92
+ })).pipe((0, _gulp.dest)(imageDest));
93
+ };
57
94
  exports.imagesFor = imagesFor;
@@ -31,23 +31,23 @@ const escapeHtml = text => String(text).replace(/&/g, '&amp;').replace(/</g, '&l
31
31
  const jsdocInstallHint = 'Install it in your project with: npm install --save-dev jsdoc';
32
32
  const themeInstallHint = name => `Install it in your project with: npm install --save-dev ${name}`;
33
33
 
34
- /**
35
- * Resolve the installed directory of an optional peer dependency, from the project being built rather than from
36
- * this package. Deliberately not requirePeer/importPeer's own `require(name + '/package.json')` approach - that
37
- * breaks for any package whose own package.json restricts its exports map and does not expose that subpath
38
- * (clean-jsdoc-theme does; confirmed live, not assumed - resolving its own package.json throws
39
- * ERR_PACKAGE_PATH_NOT_EXPORTED in plain Node, and a differently-shaped MODULE_NOT_FOUND under Jest's own
40
- * resolver, which still is not "not installed" either way). Walking Node's own real module-lookup directories
41
- * (require.resolve.paths) and checking each on disk sidesteps the exports map entirely - this only ever reads
42
- * whether `<dir>/<name>/package.json` exists, never asks the module system to resolve a restricted subpath.
43
- * @memberOf module:partials
44
- * @param {string} name - The package name.
45
- * @param {Object} options
46
- * @param {string} options.task
47
- * @param {string} options.installHint
48
- * @param {string} [options.projectPath=process.cwd()]
49
- * @returns {string}
50
- * @throws {Error} With install instructions when the package is not installed.
34
+ /**
35
+ * Resolve the installed directory of an optional peer dependency, from the project being built rather than from
36
+ * this package. Deliberately not requirePeer/importPeer's own `require(name + '/package.json')` approach - that
37
+ * breaks for any package whose own package.json restricts its exports map and does not expose that subpath
38
+ * (clean-jsdoc-theme does; confirmed live, not assumed - resolving its own package.json throws
39
+ * ERR_PACKAGE_PATH_NOT_EXPORTED in plain Node, and a differently-shaped MODULE_NOT_FOUND under Jest's own
40
+ * resolver, which still is not "not installed" either way). Walking Node's own real module-lookup directories
41
+ * (require.resolve.paths) and checking each on disk sidesteps the exports map entirely - this only ever reads
42
+ * whether `<dir>/<name>/package.json` exists, never asks the module system to resolve a restricted subpath.
43
+ * @memberOf module:partials
44
+ * @param {string} name - The package name.
45
+ * @param {Object} options
46
+ * @param {string} options.task
47
+ * @param {string} options.installHint
48
+ * @param {string} [options.projectPath=process.cwd()]
49
+ * @returns {string}
50
+ * @throws {Error} With install instructions when the package is not installed.
51
51
  */
52
52
  const resolvePeerDir = (name, {
53
53
  task,
@@ -62,15 +62,15 @@ const resolvePeerDir = (name, {
62
62
  return found;
63
63
  };
64
64
 
65
- /**
66
- * Resolve jsdoc's own CLI entry point. jsdoc has no stable programmatic Node API for generating HTML docs (unlike
67
- * TypeDoc's Application.bootstrap()/convert()/generateDocs()) - gulp-jsdoc3, the established gulp wrapper, is
68
- * stale, and its own README admits jsdoc does not support piped input in the first place, a real anti-pattern for
69
- * this project's own gulp-stream conventions. Running its real CLI via child_process is the portable way in -
70
- * confirmed via `npm view jsdoc bin`, which reports "jsdoc.js" at the package root.
71
- * @memberOf module:partials
72
- * @param {string} [projectPath=process.cwd()]
73
- * @returns {string}
65
+ /**
66
+ * Resolve jsdoc's own CLI entry point. jsdoc has no stable programmatic Node API for generating HTML docs (unlike
67
+ * TypeDoc's Application.bootstrap()/convert()/generateDocs()) - gulp-jsdoc3, the established gulp wrapper, is
68
+ * stale, and its own README admits jsdoc does not support piped input in the first place, a real anti-pattern for
69
+ * this project's own gulp-stream conventions. Running its real CLI via child_process is the portable way in -
70
+ * confirmed via `npm view jsdoc bin`, which reports "jsdoc.js" at the package root.
71
+ * @memberOf module:partials
72
+ * @param {string} [projectPath=process.cwd()]
73
+ * @returns {string}
74
74
  */
75
75
  const resolveJsdocBin = (projectPath = process.cwd()) => _nodePath.default.join(resolvePeerDir('jsdoc', {
76
76
  task: 'docs',
@@ -78,14 +78,14 @@ const resolveJsdocBin = (projectPath = process.cwd()) => _nodePath.default.join(
78
78
  projectPath
79
79
  }), 'jsdoc.js');
80
80
 
81
- /**
82
- * Resolve a jsdoc theme package's own template directory, for jsdoc's own opts.template config key: the folder
83
- * holding its publish.js. That is the package root for a classic jsdoc template (clean-jsdoc-theme 4.x included),
84
- * but `dist` for a bundled one (clean-jsdoc-theme 5.x).
85
- * @memberOf module:partials
86
- * @param {string} name
87
- * @param {string} [projectPath=process.cwd()]
88
- * @returns {string}
81
+ /**
82
+ * Resolve a jsdoc theme package's own template directory, for jsdoc's own opts.template config key: the folder
83
+ * holding its publish.js. That is the package root for a classic jsdoc template (clean-jsdoc-theme 4.x included),
84
+ * but `dist` for a bundled one (clean-jsdoc-theme 5.x).
85
+ * @memberOf module:partials
86
+ * @param {string} name
87
+ * @param {string} [projectPath=process.cwd()]
88
+ * @returns {string}
89
89
  */
90
90
  exports.resolveJsdocBin = resolveJsdocBin;
91
91
  const resolveJsdocTheme = (name, projectPath = process.cwd()) => {
@@ -98,18 +98,18 @@ const resolveJsdocTheme = (name, projectPath = process.cwd()) => {
98
98
  return _nodeFs.default.existsSync(_nodePath.default.join(distDir, 'publish.js')) ? distDir : packageDir;
99
99
  };
100
100
 
101
- /**
102
- * Generate the HTML documentation of a plain-JavaScript project with jsdoc, using jsdoc.base.js's own shared
103
- * config (plugins, includePattern/excludePattern) as the starting point rather than a parallel one - the same
104
- * base a project's own .jsdoc.conf.js has always been able to extend, just with source.include and the output
105
- * options generated here instead of hand-maintained per project. Configure this with 'docs.from', 'docs.to',
106
- * 'docs.index', 'docs.theme' and 'docs.title'.
107
- * @memberOf module:partials
108
- * @param {string|Array<string>} [srcPath=gulpConfig.get('docs.from')] - The directory (or directories and files) holding
109
- * the JS source.
110
- * @param {string} [outPath=gulpConfig.get('docs.to')] - The directory the documentation is generated into (cleared first).
111
- * @param {function(string, Array<string>): Promise<Object>} [runJsdoc] - Runs the jsdoc CLI, tests can inject a stand-in.
112
- * @returns {Function} A gulp task, it accepts an optional callback and returns a promise.
101
+ /**
102
+ * Generate the HTML documentation of a plain-JavaScript project with jsdoc, using jsdoc.base.js's own shared
103
+ * config (plugins, includePattern/excludePattern) as the starting point rather than a parallel one - the same
104
+ * base a project's own .jsdoc.conf.js has always been able to extend, just with source.include and the output
105
+ * options generated here instead of hand-maintained per project. Configure this with 'docs.from', 'docs.to',
106
+ * 'docs.index', 'docs.theme' and 'docs.title'.
107
+ * @memberOf module:partials
108
+ * @param {string|Array<string>} [srcPath=gulpConfig.get('docs.from')] - The directory (or directories and files) holding
109
+ * the JS source.
110
+ * @param {string} [outPath=gulpConfig.get('docs.to')] - The directory the documentation is generated into (cleared first).
111
+ * @param {function(string, Array<string>): Promise<Object>} [runJsdoc] - Runs the jsdoc CLI, tests can inject a stand-in.
112
+ * @returns {Function} A gulp task, it accepts an optional callback and returns a promise.
113
113
  */
114
114
  exports.resolveJsdocTheme = resolveJsdocTheme;
115
115
  const jsdocDocsFor = (srcPath = gulpConfig.get('docs.from'), outPath = gulpConfig.get('docs.to'), runJsdoc = (bin, args) => execFileAsync(process.execPath, [bin, ...args])) => {
@@ -1,52 +1,52 @@
1
- "use strict";
2
-
3
- require("core-js/modules/esnext.weak-map.delete-all.js");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.lintSource = void 0;
8
- var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
9
- var _gulp = require("gulp");
10
- var _neostandardLint = require("./neostandardLint.js");
11
- var _nodeStream = require("node:stream");
12
- var cache;
13
- function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
14
- /**
15
- * Lint the project's source (srcPath: .js, .mjs and .cjs, plus .ts when typescript.enabled) with neostandard and
16
- * write the automatic fixes back in place. Shared by the sourceLint (build) and lint (standalone) tasks.
17
- * @memberOf module:partials
18
- * @param {Object} [options={}]
19
- * @param {boolean} [options.failOnError=false] - Fail once linting finishes if any errors could not be fixed.
20
- * @returns {stream.Stream}
21
- */
22
- const lintSource = ({
23
- failOnError = false
24
- } = {}) => {
25
- const srcPath = gulpConfig.get('srcPath');
26
- const ts = gulpConfig.get('typescript.enabled');
27
- const patterns = [`${srcPath}/**/*.{js,mjs,cjs}`];
28
- if (ts) {
29
- patterns.push(`${srcPath}/**/*.ts`);
30
- }
31
- const linter = (0, _neostandardLint.neostandardLint)({
32
- fix: true,
33
- ts,
34
- rules: gulpConfig.get('lint.rules')
35
- });
36
- // Fail only once dest() has written every fixed file: gulp exits as soon as a task fails, so failing from the
37
- // linter itself (before dest() finished) could leave a file that dest() had opened, but not yet written, empty.
38
- // dest() passes each file on only after writing it, so this last step's flush runs after the final write. Files
39
- // are consumed here rather than passed on, so nothing downstream has to read them.
40
- const written = new _nodeStream.Transform({
41
- objectMode: true,
42
- transform: (file, enc, callback) => callback(),
43
- flush: callback => failOnError && linter.totals.errors ? callback(new Error(`neostandard found ${linter.totals.errors} lint error(s) that could not be fixed automatically.`)) : callback()
44
- });
45
- const saved = (0, _gulp.src)(patterns).pipe(linter).pipe((0, _gulp.dest)(srcPath));
46
- saved.pipe(written);
47
- // pipe() does not forward errors, and gulp only watches the returned stream, so pass any failure along.
48
- linter.on('error', error => written.destroy(error));
49
- saved.on('error', error => written.destroy(error));
50
- return written;
51
- };
1
+ "use strict";
2
+
3
+ require("core-js/modules/esnext.weak-map.delete-all.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.lintSource = void 0;
8
+ var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
9
+ var _gulp = require("gulp");
10
+ var _neostandardLint = require("./neostandardLint.js");
11
+ var _nodeStream = require("node:stream");
12
+ var cache;
13
+ function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
14
+ /**
15
+ * Lint the project's source (srcPath: .js, .mjs and .cjs, plus .ts when typescript.enabled) with neostandard and
16
+ * write the automatic fixes back in place. Shared by the sourceLint (build) and lint (standalone) tasks.
17
+ * @memberOf module:partials
18
+ * @param {Object} [options={}]
19
+ * @param {boolean} [options.failOnError=false] - Fail once linting finishes if any errors could not be fixed.
20
+ * @returns {stream.Stream}
21
+ */
22
+ const lintSource = ({
23
+ failOnError = false
24
+ } = {}) => {
25
+ const srcPath = gulpConfig.get('srcPath');
26
+ const ts = gulpConfig.get('typescript.enabled');
27
+ const patterns = [`${srcPath}/**/*.{js,mjs,cjs}`];
28
+ if (ts) {
29
+ patterns.push(`${srcPath}/**/*.ts`);
30
+ }
31
+ const linter = (0, _neostandardLint.neostandardLint)({
32
+ fix: true,
33
+ ts,
34
+ rules: gulpConfig.get('lint.rules')
35
+ });
36
+ // Fail only once dest() has written every fixed file: gulp exits as soon as a task fails, so failing from the
37
+ // linter itself (before dest() finished) could leave a file that dest() had opened, but not yet written, empty.
38
+ // dest() passes each file on only after writing it, so this last step's flush runs after the final write. Files
39
+ // are consumed here rather than passed on, so nothing downstream has to read them.
40
+ const written = new _nodeStream.Transform({
41
+ objectMode: true,
42
+ transform: (file, enc, callback) => callback(),
43
+ flush: callback => failOnError && linter.totals.errors ? callback(new Error(`neostandard found ${linter.totals.errors} lint error(s) that could not be fixed automatically.`)) : callback()
44
+ });
45
+ const saved = (0, _gulp.src)(patterns).pipe(linter).pipe((0, _gulp.dest)(srcPath));
46
+ saved.pipe(written);
47
+ // pipe() does not forward errors, and gulp only watches the returned stream, so pass any failure along.
48
+ linter.on('error', error => written.destroy(error));
49
+ saved.on('error', error => written.destroy(error));
50
+ return written;
51
+ };
52
52
  exports.lintSource = lintSource;
@@ -1,100 +1,100 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.requirePeer = exports.importPeer = exports.importModule = void 0;
7
- require("core-js/modules/es.array.includes.js");
8
- var _nodeModule = require("node:module");
9
- var _nodePath = _interopRequireDefault(require("node:path"));
10
- var _nodeUrl = require("node:url");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- // Several dependencies ship ESM-only (standard, gulp-ts-compile, typedoc), but this package also publishes a CommonJS
13
- // build (dist/*.js) whose babel transform would turn even a dynamic import() into a require() that cannot load an ES
14
- // module. Hiding the import() inside a Function constructor keeps it a genuine dynamic import that works from either
15
- // build, because babel cannot see (and so cannot rewrite) an import expression which only exists as a runtime string.
16
- // eslint-disable-next-line no-new-func -- deliberate, see above
17
- const dynamicImport = new Function('specifier', 'return import(specifier)');
18
-
19
- /**
20
- * Import an ES module (or any module) with a real dynamic import(), whichever build (ESM or CommonJS) this runs from.
21
- * @memberOf module:partials
22
- * @param {string} specifier - The package name, or the URL of a file.
23
- * @returns {Promise<Object>} The module namespace.
24
- */
25
- const importModule = specifier => dynamicImport(specifier);
26
- exports.importModule = importModule;
27
- const isMissing = (error, name) => error.code === 'MODULE_NOT_FOUND' && error.message.includes(`'${name}'`);
28
- const notInstalled = (name, {
29
- task,
30
- installHint
31
- }) => new Error(`The ${task} task needs the optional peer dependency ${name}, which is not installed. ${installHint}`);
32
-
33
- /**
34
- * Load an optional peer dependency (one which is only needed once a task runs, so projects which never use that task
35
- * do not have to install it) with require(), from the project being built rather than from this package. When it is
36
- * missing the error explains how to install it.
37
- * @memberOf module:partials
38
- * @param {string} name - The package name.
39
- * @param {Object} options
40
- * @param {string} options.task - The task which needs the package, for the error message.
41
- * @param {string} options.installHint - How to install it, for the error message.
42
- * @param {string} [options.esmOnlyMessage] - The error message when the package turns out to be ESM-only (it cannot be require()d).
43
- * @param {string} [options.projectPath=process.cwd()] - The folder of the project (which has the package.json) being built.
44
- * @returns {*} Whatever the package exports.
45
- * @throws {Error} With install instructions when the package is not installed.
46
- */
47
- const requirePeer = (name, {
48
- task,
49
- installHint,
50
- esmOnlyMessage,
51
- projectPath = process.cwd()
52
- }) => {
53
- try {
54
- return (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json'))(name);
55
- } catch (error) {
56
- if (isMissing(error, name)) {
57
- throw notInstalled(name, {
58
- task,
59
- installHint
60
- });
61
- }
62
- if (error.code === 'ERR_REQUIRE_ESM' && esmOnlyMessage) {
63
- throw new Error(esmOnlyMessage);
64
- }
65
- throw error;
66
- }
67
- };
68
-
69
- /**
70
- * Import an optional peer dependency which ships ESM-only, from the project being built. See {@link requirePeer}.
71
- * @memberOf module:partials
72
- * @param {string} name - The package name.
73
- * @param {Object} options
74
- * @param {string} options.task - The task which needs the package, for the error message.
75
- * @param {string} options.installHint - How to install it, for the error message.
76
- * @param {string} [options.projectPath=process.cwd()] - The folder of the project (which has the package.json) being built.
77
- * @returns {Promise<Object>} The module namespace.
78
- * @throws {Error} With install instructions when the package is not installed.
79
- */
80
- exports.requirePeer = requirePeer;
81
- const importPeer = async (name, {
82
- task,
83
- installHint,
84
- projectPath = process.cwd()
85
- }) => {
86
- let resolved;
87
- try {
88
- resolved = (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json')).resolve(name);
89
- } catch (error) {
90
- if (isMissing(error, name)) {
91
- throw notInstalled(name, {
92
- task,
93
- installHint
94
- });
95
- }
96
- throw error;
97
- }
98
- return importModule((0, _nodeUrl.pathToFileURL)(resolved).href);
99
- };
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.requirePeer = exports.importPeer = exports.importModule = void 0;
7
+ require("core-js/modules/es.array.includes.js");
8
+ var _nodeModule = require("node:module");
9
+ var _nodePath = _interopRequireDefault(require("node:path"));
10
+ var _nodeUrl = require("node:url");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ // Several dependencies ship ESM-only (standard, gulp-ts-compile, typedoc), but this package also publishes a CommonJS
13
+ // build (dist/*.js) whose babel transform would turn even a dynamic import() into a require() that cannot load an ES
14
+ // module. Hiding the import() inside a Function constructor keeps it a genuine dynamic import that works from either
15
+ // build, because babel cannot see (and so cannot rewrite) an import expression which only exists as a runtime string.
16
+ // eslint-disable-next-line no-new-func -- deliberate, see above
17
+ const dynamicImport = new Function('specifier', 'return import(specifier)');
18
+
19
+ /**
20
+ * Import an ES module (or any module) with a real dynamic import(), whichever build (ESM or CommonJS) this runs from.
21
+ * @memberOf module:partials
22
+ * @param {string} specifier - The package name, or the URL of a file.
23
+ * @returns {Promise<Object>} The module namespace.
24
+ */
25
+ const importModule = specifier => dynamicImport(specifier);
26
+ exports.importModule = importModule;
27
+ const isMissing = (error, name) => error.code === 'MODULE_NOT_FOUND' && error.message.includes(`'${name}'`);
28
+ const notInstalled = (name, {
29
+ task,
30
+ installHint
31
+ }) => new Error(`The ${task} task needs the optional peer dependency ${name}, which is not installed. ${installHint}`);
32
+
33
+ /**
34
+ * Load an optional peer dependency (one which is only needed once a task runs, so projects which never use that task
35
+ * do not have to install it) with require(), from the project being built rather than from this package. When it is
36
+ * missing the error explains how to install it.
37
+ * @memberOf module:partials
38
+ * @param {string} name - The package name.
39
+ * @param {Object} options
40
+ * @param {string} options.task - The task which needs the package, for the error message.
41
+ * @param {string} options.installHint - How to install it, for the error message.
42
+ * @param {string} [options.esmOnlyMessage] - The error message when the package turns out to be ESM-only (it cannot be require()d).
43
+ * @param {string} [options.projectPath=process.cwd()] - The folder of the project (which has the package.json) being built.
44
+ * @returns {*} Whatever the package exports.
45
+ * @throws {Error} With install instructions when the package is not installed.
46
+ */
47
+ const requirePeer = (name, {
48
+ task,
49
+ installHint,
50
+ esmOnlyMessage,
51
+ projectPath = process.cwd()
52
+ }) => {
53
+ try {
54
+ return (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json'))(name);
55
+ } catch (error) {
56
+ if (isMissing(error, name)) {
57
+ throw notInstalled(name, {
58
+ task,
59
+ installHint
60
+ });
61
+ }
62
+ if (error.code === 'ERR_REQUIRE_ESM' && esmOnlyMessage) {
63
+ throw new Error(esmOnlyMessage);
64
+ }
65
+ throw error;
66
+ }
67
+ };
68
+
69
+ /**
70
+ * Import an optional peer dependency which ships ESM-only, from the project being built. See {@link requirePeer}.
71
+ * @memberOf module:partials
72
+ * @param {string} name - The package name.
73
+ * @param {Object} options
74
+ * @param {string} options.task - The task which needs the package, for the error message.
75
+ * @param {string} options.installHint - How to install it, for the error message.
76
+ * @param {string} [options.projectPath=process.cwd()] - The folder of the project (which has the package.json) being built.
77
+ * @returns {Promise<Object>} The module namespace.
78
+ * @throws {Error} With install instructions when the package is not installed.
79
+ */
80
+ exports.requirePeer = requirePeer;
81
+ const importPeer = async (name, {
82
+ task,
83
+ installHint,
84
+ projectPath = process.cwd()
85
+ }) => {
86
+ let resolved;
87
+ try {
88
+ resolved = (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json')).resolve(name);
89
+ } catch (error) {
90
+ if (isMissing(error, name)) {
91
+ throw notInstalled(name, {
92
+ task,
93
+ installHint
94
+ });
95
+ }
96
+ throw error;
97
+ }
98
+ return importModule((0, _nodeUrl.pathToFileURL)(resolved).href);
99
+ };
100
100
  exports.importPeer = importPeer;