js-build-tools 6.1.0 → 6.2.2

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 (58) hide show
  1. package/README.md +89 -25
  2. package/dist/build.js +5 -2
  3. package/dist/build.min.js +1 -1
  4. package/dist/bundle.js +40 -40
  5. package/dist/bundleMinify.js +18 -18
  6. package/dist/copyFiles.js +47 -0
  7. package/dist/copyFiles.min.js +1 -0
  8. package/dist/copyFonts.js +13 -13
  9. package/dist/default.js +15 -15
  10. package/dist/distMinify.js +13 -13
  11. package/dist/docs.js +19 -0
  12. package/dist/docs.min.js +1 -0
  13. package/dist/jsdocDocs.js +15 -0
  14. package/dist/jsdocDocs.min.js +1 -0
  15. package/dist/partials/addToReadme.js +25 -25
  16. package/dist/partials/beginWatcher.js +13 -13
  17. package/dist/partials/clean.js +15 -15
  18. package/dist/partials/copyFor.js +10 -2
  19. package/dist/partials/distFor.js +22 -22
  20. package/dist/partials/distForSrc.js +12 -12
  21. package/dist/partials/distSeries.js +20 -20
  22. package/dist/partials/imagesFor.js +43 -43
  23. package/dist/partials/jsdocDocsFor.js +155 -0
  24. package/dist/partials/neostandardLint.js +121 -121
  25. package/dist/partials/readmeTemplate.js +15 -15
  26. package/dist/partials/resolveDocsMethod.js +19 -0
  27. package/dist/partials/runOnChange.js +29 -29
  28. package/dist/partials/sassFor.js +29 -29
  29. package/dist/partials/tsFor.js +71 -71
  30. package/dist/partials/typeDocsFor.js +203 -203
  31. package/dist/partials.js +149 -135
  32. package/dist/partials.min.js +1 -1
  33. package/dist/sourceLint.js +26 -26
  34. package/dist/test-helpers/neostandardLintWithRealNeostandard.js +49 -49
  35. package/dist/test-helpers/setUp.js +95 -95
  36. package/dist/testFull.js +20 -20
  37. package/dist/testHelpers.js +10 -10
  38. package/dist/testQuick.js +22 -22
  39. package/dist/utilities/dotNotate.js +48 -48
  40. package/dist/utilities/getBundleConfigs.js +28 -28
  41. package/dist/watchTest.js +16 -16
  42. package/functions/build.mjs +5 -2
  43. package/functions/build.test.mjs +50 -1
  44. package/functions/copyFiles.mjs +32 -0
  45. package/functions/copyFiles.test.mjs +78 -0
  46. package/functions/docs.mjs +13 -0
  47. package/functions/docs.test.mjs +45 -0
  48. package/functions/jsdocDocs.mjs +10 -0
  49. package/functions/partials/copyFor.mjs +4 -1
  50. package/functions/partials/jsdocDocsFor.mjs +132 -0
  51. package/functions/partials/jsdocDocsFor.test.mjs +101 -0
  52. package/functions/partials/resolveDocsMethod.mjs +10 -0
  53. package/functions/partials/resolveDocsMethod.test.mjs +33 -0
  54. package/functions/partials.mjs +2 -0
  55. package/functions/partials.test.mjs +1 -1
  56. package/gulp.config.mjs +28 -5
  57. package/gulpfile.base.mjs +4 -1
  58. package/package.json +14 -1
package/README.md CHANGED
@@ -11,7 +11,9 @@ Using this tool suite, you can:
11
11
  * Bundle your distribution files to be used in a browser environment.
12
12
  * Run tests and watch for changes.
13
13
  * Generate jsdoc readme files.
14
- * Generate HTML documentation straight from your TypeScript source (with TypeDoc), with a module for each of your folders.
14
+ * Generate real HTML documentation straight from your source - TypeDoc for a TypeScript project (a module for
15
+ each of your folders), or jsdoc with a modern theme for a plain JavaScript one.
16
+ * Copy files (a bundle, or anything else) to another location, on demand.
15
17
 
16
18
  ## Installation
17
19
 
@@ -281,10 +283,12 @@ module.exports = {
281
283
  }
282
284
  ```
283
285
 
284
- ### Configure HTML JS Documentation (optional)
286
+ ### Configure HTML JS Documentation, full manual control (optional, advanced)
285
287
 
286
- It may be desirable to generate HTML documentation for your JS files.
287
- (For a TypeScript project, see 'Configure TypeScript documentation' instead.)
288
+ For most projects, `docs.enabled` with `docs.method: 'jsdoc'` (see 'Configure HTML documentation' below) is the
289
+ simpler path - no `.jsdoc.conf.js` file to maintain by hand, wired straight into `gulp build`/`gulp docs`. This
290
+ section is for when you want full, direct control over jsdoc's own config instead (a plugin or option this
291
+ project's own generated config does not expose, for example).
288
292
 
289
293
  Create a `.jsdoc.conf.js` file and add the following:
290
294
 
@@ -376,6 +380,33 @@ exports if you want it documented this cleanly:
376
380
  }
377
381
  ```
378
382
 
383
+ ### Configure copy files (optional)
384
+
385
+ Copy files (a bundle, or anything else) to another location - any number of entries, each independent. Unlike
386
+ every other task here, this is never run automatically as part of `gulp build` - what this copies is often the
387
+ live, publicly-reachable version of something, so publishing it should be a deliberate step your own script
388
+ opts into, not a side effect of a routine local build.
389
+
390
+ Add the following to the exports in your `build-tools.config.json`:
391
+
392
+ ```json
393
+ {
394
+ "copyFiles": [
395
+ {
396
+ // The glob pattern(s) of files to copy
397
+ "from": "browser/**/*.js",
398
+ // The directory to copy them into
399
+ "to": "../my-other-project/vendor",
400
+ // Optional - preserves this glob's own subdirectory structure in the destination, instead of flattening it
401
+ "base": "browser"
402
+ }
403
+ ]
404
+ }
405
+ ```
406
+
407
+ If you also export `copyFiles` from your gulpfile you can run it on its own with `gulp copyFiles`, and can then
408
+ add your own script for it, for example `"publish:bundle": "gulp copyFiles"`.
409
+
379
410
  ### Configure move fonts (optional)
380
411
 
381
412
  Be able to copy a source directory of fonts into the distribution path.
@@ -498,32 +529,46 @@ babelConfig.presets.push('@babel/preset-typescript')
498
529
  module.exports = babelConfig
499
530
  ```
500
531
 
501
- ### Configure TypeScript documentation (optional)
502
-
503
- `jsdoc-to-markdown` only reads `.js` files, so the types in your `.ts` files (and the comments on them) do not reach
504
- the readme it generates. Instead, this can generate HTML documentation straight from the TypeScript source with
505
- [TypeDoc](https://typedoc.org/). Every folder in your source directory becomes a module of the documentation, the default
506
- export of each file (one function per file) is listed under the name of the file, and everything else a file exports (for
507
- example the types in a `types.ts`) is listed as it is. Index files, tests and declaration files are left out. A file
508
- which sits directly in the source directory, beside the folders, is a module of its own (unless it is `index` or
509
- `main`). The first comment of a folder's `index.ts` (or the header comment of such a file) describes its module. The
510
- comments on your code are the documentation, and the types come from the code itself, so `@module`, `@memberOf`,
511
- `@typedef` and the `{Type}` of `@param` are not needed.
512
-
513
- `typedoc` is an optional peer dependency (like `typescript`), install it in your project with
514
- `npm install --save-dev typedoc` (this needs a `typescript` version it supports).
532
+ ### Configure HTML documentation (optional)
533
+
534
+ `jsdoc-to-markdown` (the readme generator) only reads `.js` files, so the types in your `.ts` files (and the
535
+ comments on them) never reach the readme it generates, and even for a plain JavaScript project a single
536
+ markdown readme is a thinner result than a real browsable site. Instead, `docs.enabled` generates real HTML
537
+ documentation straight from your source, with either engine:
538
+
539
+ * **TypeDoc** (for a TypeScript project) - every folder in your source directory becomes a module of the
540
+ documentation, the default export of each file (one function per file) is listed under the name of the file,
541
+ and everything else a file exports (for example the types in a `types.ts`) is listed as it is. Index files,
542
+ tests and declaration files are left out. A file which sits directly in the source directory, beside the
543
+ folders, is a module of its own (unless it is `index` or `main`). The first comment of a folder's `index.ts`
544
+ (or the header comment of such a file) describes its module. The comments on your code are the documentation,
545
+ and the types come from the code itself, so `@module`, `@memberOf`, `@typedef` and the `{Type}` of `@param`
546
+ are not needed. `typedoc` is an optional peer dependency (like `typescript`), install it in your project with
547
+ `npm install --save-dev typedoc` (this needs a `typescript` version it supports).
548
+ * **jsdoc** (for a plain JavaScript project, where TypeDoc has no real types to read) - scans your source
549
+ recursively with jsdoc itself, rendered with a modern theme (`clean-jsdoc-theme` by default, used instead of
550
+ jsdoc's own classic default template) instead of the manual `.jsdoc.conf.js` setup described further below.
551
+ `jsdoc` and whichever theme you configure are optional peer dependencies, install them with
552
+ `npm install --save-dev jsdoc clean-jsdoc-theme` (or your own chosen theme package).
515
553
 
516
554
  Add the following to the exports in your `build-tools.config.json`:
517
555
 
518
556
  ```json
519
557
  {
520
558
  "docs": {
521
- // Generate the documentation from the TypeScript source
559
+ // Generate the documentation from the source
522
560
  "enabled": true,
523
- // The directory holding the TypeScript source, each folder in it becomes a module
561
+ // The directory holding the source, each folder in it becomes a module (TypeDoc) or is scanned recursively (jsdoc)
524
562
  "from": "src",
525
563
  // The markdown file used as the front page of the documentation (a short overview of your project)
526
564
  "index": "MAIN.md",
565
+ // 'typedoc' or 'jsdoc'. Left out (or false), it's inferred from typescript.enabled - 'typedoc' when your
566
+ // project is TypeScript, 'jsdoc' when it is not - so most projects never need to set this at all. Set it
567
+ // explicitly to override that inference either way.
568
+ "method": false,
569
+ // Only meaningful when method is (or resolves to) 'jsdoc' - the theme package to render with. TypeDoc
570
+ // always keeps its own default regardless of this setting.
571
+ "theme": "clean-jsdoc-theme",
527
572
  // Where the HTML is generated (the directory is cleared first)
528
573
  "to": "docs"
529
574
  }
@@ -569,6 +614,7 @@ In your `package.json` file, add the following scripts:
569
614
  "dev": "gulp",
570
615
  "docs": "gulp docs",
571
616
  "htmldocs": "jsdoc -R MAIN.md -c ./.jsdoc.conf.js -d docs",
617
+ "publish:bundle": "gulp copyFiles",
572
618
  "readme": "gulp readme",
573
619
  "sass": "gulp sass",
574
620
  "test": "gulp testFull",
@@ -629,6 +675,7 @@ Modify these configurations to match your project specifications.
629
675
  * [~JestTestFlags](#module_gulpConfig..JestTestFlags) : <code>FlagsSetting</code>
630
676
  * [~StringSetting](#module_gulpConfig..StringSetting) : <code>string</code>
631
677
  * [~Setting](#module_gulpConfig..Setting) : <code>ArrayableSetting</code> \| <code>BooleanSetting</code> \| <code>FlagsSetting</code> \| <code>StringSetting</code>
678
+ * [~CopyFilesEntry](#module_gulpConfig..CopyFilesEntry) : <code>Object</code>
632
679
  * [~BrowserConfig](#module_gulpConfig..BrowserConfig) : <code>Object.&lt;string, Setting&gt;</code>
633
680
  * [~AdditionalBundleConfig](#module_gulpConfig..AdditionalBundleConfig) : <code>Object.&lt;string, Setting&gt;</code>
634
681
  * [~DistConfig](#module_gulpConfig..DistConfig) : <code>Object.&lt;string, Setting&gt;</code>
@@ -722,6 +769,20 @@ A setting that may only be a string.
722
769
  Any single configuration option is a Setting.
723
770
 
724
771
  **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
772
+ <a name="module_gulpConfig..CopyFilesEntry"></a>
773
+
774
+ ### gulpConfig~CopyFilesEntry : <code>Object</code>
775
+ One copy-files entry: a glob (or array of globs) to copy, and where to copy it.
776
+
777
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
778
+ **Properties**
779
+
780
+ | Name | Type | Description |
781
+ | --- | --- | --- |
782
+ | from | <code>ArrayableSetting</code> | The glob pattern(s) of files to copy. |
783
+ | to | <code>StringSetting</code> | The directory to copy them into. |
784
+ | base | <code>FlagStringSetting</code> | Optional base for gulp's own src(pattern, {base}), to preserve a glob's own subdirectory structure in the destination instead of flattening it. false (the default) uses gulp's own default base behaviour. |
785
+
725
786
  <a name="module_gulpConfig..BrowserConfig"></a>
726
787
 
727
788
  ### gulpConfig~BrowserConfig : <code>Object.&lt;string, Setting&gt;</code>
@@ -829,20 +890,22 @@ Configurations to compile and generate the Readme file.
829
890
  <a name="module_gulpConfig..DocsConfig"></a>
830
891
 
831
892
  ### gulpConfig~DocsConfig : <code>Object.&lt;string, Setting&gt;</code>
832
- Configurations for generating the HTML documentation of a TypeScript project (with TypeDoc, from the source).
893
+ Configurations for generating the HTML documentation of a project's own source, with either TypeDoc (real
833
894
 
834
895
  **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
835
896
  **Properties**
836
897
 
837
898
  | Name | Type | Description |
838
899
  | --- | --- | --- |
839
- | enabled | <code>BooleanSetting</code> | Toggle generating the documentation from the TypeScript source. When it is on the build does this instead of generating the readme from the jsdoc comments of the compiled files. |
840
- | from | <code>StringSetting</code> | The directory holding the TypeScript source, each folder in it becomes a module. |
900
+ | enabled | <code>BooleanSetting</code> | Toggle generating the documentation from the source. When it is on the build does this instead of generating the readme from the jsdoc comments of the compiled files. |
901
+ | from | <code>StringSetting</code> | The directory holding the source, each folder in it becomes a module (TypeDoc) or is scanned recursively (jsdoc). |
841
902
  | index | <code>StringSetting</code> | The markdown file used as the front page of the documentation. |
842
- | logLevel | <code>StringSetting</code> | How much TypeDoc reports: Verbose, Info, Warn, Error or None. |
903
+ | logLevel | <code>StringSetting</code> | How much TypeDoc reports: Verbose, Info, Warn, Error or None. Not used by jsdoc. |
904
+ | method | <code>FlagStringSetting</code> | 'typedoc' or 'jsdoc'. False (the default) infers it from typescript.enabled - 'typedoc' when on, 'jsdoc' when off - so an existing TypeScript project's config needs no change to keep working exactly as it already does; set this explicitly to override that inference either way. |
905
+ | theme | <code>StringSetting</code> | The jsdoc theme package to use (only meaningful when method is 'jsdoc' - TypeDoc keeps its own default regardless). Defaults to 'clean-jsdoc-theme'. |
843
906
  | title | <code>StringSetting</code> | The name of the documentation, defaults to the name in the package.json. |
844
907
  | to | <code>StringSetting</code> | The directory to generate the documentation in (it is cleared first). |
845
- | tsconfig | <code>FlagStringSetting</code> | The tsconfig file to read the source with, defaults to the one of typescript.config. |
908
+ | tsconfig | <code>FlagStringSetting</code> | The tsconfig file to read the source with (TypeDoc only), defaults to the one of typescript.config. |
846
909
 
847
910
  <a name="module_gulpConfig..SassConfig"></a>
848
911
 
@@ -900,6 +963,7 @@ A set of Configurations options defined by Settings.
900
963
  | --- | --- | --- |
901
964
  | browser | <code>BrowserConfig</code> | Browser bundling configuration group. |
902
965
  | cleanPaths | <code>ArrayableSetting</code> | The paths for directories to delete before build. |
966
+ | copyFiles | <code>Array.&lt;CopyFilesEntry&gt;</code> | Files to copy elsewhere, run via the copyFiles task - never automatically as part of build, since what this copies is often the live, publicly-reachable version of something (e.g. a bundle), and publishing it should be a deliberate step. |
903
967
  | dist | <code>DistConfig</code> | Distribution file generation configuration group. |
904
968
  | docs | <code>DocsConfig</code> | Generate the documentation of a TypeScript project configuration group. |
905
969
  | fonts | <code>FontConfig</code> | Fonts copy configuration group. |
package/dist/build.js CHANGED
@@ -10,12 +10,14 @@ var _bundleMinify = require("./bundleMinify.js");
10
10
  var _partials = require("./partials.js");
11
11
  var _compileReadme = require("./compileReadme.js");
12
12
  var _typeDocs = require("./typeDocs.js");
13
+ var _jsdocDocs = require("./jsdocDocs.js");
13
14
  var _distMinify = require("./distMinify.js");
14
15
  var _sourceLint = require("./sourceLint.js");
15
16
  var _gulp = require("gulp");
16
17
  var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
17
18
  var _copyFonts = require("./copyFonts.js");
18
19
  var _images = require("./images.js");
20
+ var _resolveDocsMethod = require("./partials/resolveDocsMethod.js");
19
21
  var _sass = require("./sass.js");
20
22
  var _testFull = require("./testFull.js");
21
23
  var cache;
@@ -30,9 +32,10 @@ function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e;
30
32
  const build = (done = null) => {
31
33
  const buildActions = [(0, _partials.distSeries)(), _distMinify.distMinify];
32
34
  const generateDocs = gulpConfig.get('docs.enabled');
35
+ const docsMethod = (0, _resolveDocsMethod.resolveDocsMethod)();
33
36
  if (generateDocs) {
34
- // The documentation is generated from the TypeScript source itself, the readme is written by hand
35
- buildActions.push(_typeDocs.typeDocs);
37
+ // The documentation is generated from the source itself, the readme is written by hand
38
+ buildActions.push(docsMethod === 'jsdoc' ? _jsdocDocs.jsdocDocs : _typeDocs.typeDocs);
36
39
  } else if (gulpConfig.get('typescript.enabled')) {
37
40
  // For ts usage, we need to run the readme on the dist directly since that is where the .js files are located
38
41
  buildActions.push(_compileReadme.compileReadme);
package/dist/build.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";require("core-js/modules/esnext.weak-map.delete-all.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.build=void 0;var cache,_bundle=require("./bundle.js"),_bundleMinify=require("./bundleMinify.js"),_partials=require("./partials.js"),_compileReadme=require("./compileReadme.js"),_typeDocs=require("./typeDocs.js"),_distMinify=require("./distMinify.js"),_sourceLint=require("./sourceLint.js"),_gulp=require("gulp"),gulpConfig=_interopRequireWildcard(require("../gulp.config.js")),_copyFonts=require("./copyFonts.js"),_images=require("./images.js"),_sass=require("./sass.js"),_testFull=require("./testFull.js");function _interopRequireWildcard(e,s){if(!s&&e&&e.__esModule)return e;var i,r,t=Object.defineProperty,l={__proto__:null,default:e};if(Object(e)!==e)return l;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,l)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=t&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?t(l,r,i):l[r]=e[r]);return l}const build=(e=null)=>{const s=[(0,_partials.distSeries)(),_distMinify.distMinify],i=gulpConfig.get("docs.enabled");i?s.push(_typeDocs.typeDocs):gulpConfig.get("typescript.enabled")&&s.push(_compileReadme.compileReadme),gulpConfig.get("browser.enabled")&&(s.push(_bundle.bundle),s.push(_bundleMinify.bundleMinify));const r=[(0,_gulp.series)(...s)];return i||gulpConfig.get("typescript.enabled")||r.push(_compileReadme.compileReadme),r.push(_testFull.testFull),gulpConfig.get("fonts.enabled")&&r.push(_copyFonts.copyFonts),gulpConfig.get("images.enabled")&&r.push(_images.images),gulpConfig.get("sass.enabled")&&r.push(_sass.sass),(0,_gulp.series)((0,_gulp.parallel)(_partials.clean,_sourceLint.sourceLint),(0,_gulp.parallel)(...r))(e)};exports.build=build;
1
+ "use strict";require("core-js/modules/esnext.weak-map.delete-all.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.build=void 0;var cache,_bundle=require("./bundle.js"),_bundleMinify=require("./bundleMinify.js"),_partials=require("./partials.js"),_compileReadme=require("./compileReadme.js"),_typeDocs=require("./typeDocs.js"),_jsdocDocs=require("./jsdocDocs.js"),_distMinify=require("./distMinify.js"),_sourceLint=require("./sourceLint.js"),_gulp=require("gulp"),gulpConfig=_interopRequireWildcard(require("../gulp.config.js")),_copyFonts=require("./copyFonts.js"),_images=require("./images.js"),_resolveDocsMethod=require("./partials/resolveDocsMethod.js"),_sass=require("./sass.js"),_testFull=require("./testFull.js");function _interopRequireWildcard(e,s){if(!s&&e&&e.__esModule)return e;var i,r,t=Object.defineProperty,l={__proto__:null,default:e};if(Object(e)!==e)return l;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,l)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=t&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?t(l,r,i):l[r]=e[r]);return l}const build=(e=null)=>{const s=[(0,_partials.distSeries)(),_distMinify.distMinify],i=gulpConfig.get("docs.enabled"),r=(0,_resolveDocsMethod.resolveDocsMethod)();i?s.push("jsdoc"===r?_jsdocDocs.jsdocDocs:_typeDocs.typeDocs):gulpConfig.get("typescript.enabled")&&s.push(_compileReadme.compileReadme),gulpConfig.get("browser.enabled")&&(s.push(_bundle.bundle),s.push(_bundleMinify.bundleMinify));const t=[(0,_gulp.series)(...s)];return i||gulpConfig.get("typescript.enabled")||t.push(_compileReadme.compileReadme),t.push(_testFull.testFull),gulpConfig.get("fonts.enabled")&&t.push(_copyFonts.copyFonts),gulpConfig.get("images.enabled")&&t.push(_images.images),gulpConfig.get("sass.enabled")&&t.push(_sass.sass),(0,_gulp.series)((0,_gulp.parallel)(_partials.clean,_sourceLint.sourceLint),(0,_gulp.parallel)(...t))(e)};exports.build=build;
package/dist/bundle.js CHANGED
@@ -1,21 +1,21 @@
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.bundle = void 0;
8
- require("core-js/modules/esnext.iterator.constructor.js");
9
- require("core-js/modules/esnext.iterator.map.js");
10
- var _browserify = _interopRequireDefault(require("browserify"));
11
- var _gulp = require("gulp");
12
- var _mergeStream = _interopRequireDefault(require("merge-stream"));
13
- var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
14
- var _vinylSourceStream = _interopRequireDefault(require("vinyl-source-stream"));
15
- var _getBundleConfigs = require("./utilities/getBundleConfigs.js");
16
- var cache;
17
- 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; }
18
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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.bundle = void 0;
8
+ require("core-js/modules/esnext.iterator.constructor.js");
9
+ require("core-js/modules/esnext.iterator.map.js");
10
+ var _browserify = _interopRequireDefault(require("browserify"));
11
+ var _gulp = require("gulp");
12
+ var _mergeStream = _interopRequireDefault(require("merge-stream"));
13
+ var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
14
+ var _vinylSourceStream = _interopRequireDefault(require("vinyl-source-stream"));
15
+ var _getBundleConfigs = require("./utilities/getBundleConfigs.js");
16
+ var cache;
17
+ 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; }
18
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
19
  /**
20
20
  * Starting at each bundle's own entry point (dist.main for the primary bundle, or its own
21
21
  * override from browser.bundles), bundle all the reachable files into a single file per bundle and
@@ -35,26 +35,26 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
35
35
  * code must not require it, or provide it another way, such as a separate script tag).
36
36
  * @memberOf module:js-build-tools
37
37
  * @returns {stream.Stream}
38
- */
39
- const bundle = () => (0, _mergeStream.default)((0, _getBundleConfigs.getBundleConfigs)().map(({
40
- name,
41
- main,
42
- ignore,
43
- exclude
44
- }) => {
45
- const bundler = (0, _browserify.default)(main, {
46
- standalone: name
47
- });
48
- if (ignore.length) {
49
- bundler.ignore(ignore);
50
- }
51
- if (exclude.length) {
52
- bundler.exclude(exclude);
53
- }
54
- return bundler.bundle().pipe((0, _vinylSourceStream.default)(`${name}.js`));
55
- })
56
- // One shared dest() for every bundle, not one per bundle - vinyl-fs's dest() races against
57
- // itself (a real "write after end" failure) when two separate dest() streams target the same
58
- // directory concurrently, which every additional bundle's own dest() call otherwise would.
59
- ).pipe((0, _gulp.dest)(gulpConfig.get('browser.to')));
38
+ */
39
+ const bundle = () => (0, _mergeStream.default)((0, _getBundleConfigs.getBundleConfigs)().map(({
40
+ name,
41
+ main,
42
+ ignore,
43
+ exclude
44
+ }) => {
45
+ const bundler = (0, _browserify.default)(main, {
46
+ standalone: name
47
+ });
48
+ if (ignore.length) {
49
+ bundler.ignore(ignore);
50
+ }
51
+ if (exclude.length) {
52
+ bundler.exclude(exclude);
53
+ }
54
+ return bundler.bundle().pipe((0, _vinylSourceStream.default)(`${name}.js`));
55
+ })
56
+ // One shared dest() for every bundle, not one per bundle - vinyl-fs's dest() races against
57
+ // itself (a real "write after end" failure) when two separate dest() streams target the same
58
+ // directory concurrently, which every additional bundle's own dest() call otherwise would.
59
+ ).pipe((0, _gulp.dest)(gulpConfig.get('browser.to')));
60
60
  exports.bundle = bundle;
@@ -1,17 +1,17 @@
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.bundleMinify = void 0;
8
- require("core-js/modules/esnext.iterator.constructor.js");
9
- require("core-js/modules/esnext.iterator.map.js");
10
- var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
11
- var _minifyFor = require("./partials/minifyFor.js");
12
- var _getBundleConfigs = require("./utilities/getBundleConfigs.js");
13
- var cache;
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; }
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.bundleMinify = void 0;
8
+ require("core-js/modules/esnext.iterator.constructor.js");
9
+ require("core-js/modules/esnext.iterator.map.js");
10
+ var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
11
+ var _minifyFor = require("./partials/minifyFor.js");
12
+ var _getBundleConfigs = require("./utilities/getBundleConfigs.js");
13
+ var cache;
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
15
  /**
16
16
  * Creates the minified file for every bundle (the primary bundle, plus any additional ones from
17
17
  * browser.bundles). The minify step itself never varies per bundle, so this is one shared
@@ -19,8 +19,8 @@ function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e;
19
19
  * pipeline per bundle - gulp's src() accepts an array of paths natively.
20
20
  * @memberOf module:js-build-tools
21
21
  * @returns {*}
22
- */
23
- const bundleMinify = () => (0, _minifyFor.minifyFor)((0, _getBundleConfigs.getBundleConfigs)().map(({
24
- name
25
- }) => `${gulpConfig.get('browser.to')}/${name}.js`), gulpConfig.get('browser.to'));
22
+ */
23
+ const bundleMinify = () => (0, _minifyFor.minifyFor)((0, _getBundleConfigs.getBundleConfigs)().map(({
24
+ name
25
+ }) => `${gulpConfig.get('browser.to')}/${name}.js`), gulpConfig.get('browser.to'));
26
26
  exports.bundleMinify = bundleMinify;
@@ -0,0 +1,47 @@
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.copyFiles = void 0;
8
+ require("core-js/modules/esnext.iterator.constructor.js");
9
+ require("core-js/modules/esnext.iterator.map.js");
10
+ var _copyFor = require("./partials/copyFor.js");
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
+ /**
15
+ * Copy files from one place to another - any number of { from, to, base? } entries, configured via copyFiles.
16
+ * A project with no copyFiles entries gets a task that does nothing. Meant to be run explicitly (its own script,
17
+ * e.g. `gulp copyFiles`), not folded into the default build - a bundle (or any other file this copies) is often
18
+ * the live, publicly-reachable version of something, so publishing it elsewhere should be a deliberate step, not
19
+ * a side effect of every routine local build.
20
+ *
21
+ * Reuses copyFor (already shared with copyFonts) rather than a fresh src()/dest() pair - that keeps its existing
22
+ * encoding: false fix (Gulp 5's default utf8 handling corrupts binary files such as fonts or a minified bundle)
23
+ * instead of silently losing it in a parallel implementation.
24
+ *
25
+ * Each entry runs as its own independent copyFor(), awaited via Promise.all rather than merged into one combined
26
+ * stream (mergeStream, the pattern bundle.mjs uses) - that pattern assumes every merged stream ends up at the
27
+ * same shared destination; here, each entry can have a genuinely different one, and merging streams that each
28
+ * already terminate at their own separate dest() hit a real "write after end" error in practice.
29
+ * @memberOf module:js-build-tools
30
+ * @returns {Promise<void>}
31
+ */
32
+ const copyFiles = () => {
33
+ const copies = gulpConfig.get('copyFiles', []);
34
+ if (!copies.length) {
35
+ return Promise.resolve();
36
+ }
37
+ return Promise.all(copies.map(({
38
+ from,
39
+ to,
40
+ base
41
+ }) => new Promise((resolve, reject) => {
42
+ (0, _copyFor.copyFor)(from, to, {
43
+ base
44
+ }).on('finish', resolve).on('error', reject);
45
+ }))).then(() => {});
46
+ };
47
+ exports.copyFiles = copyFiles;
@@ -0,0 +1 @@
1
+ "use strict";require("core-js/modules/esnext.weak-map.delete-all.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.copyFiles=void 0,require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.map.js");var cache,_copyFor=require("./partials/copyFor.js"),gulpConfig=_interopRequireWildcard(require("../gulp.config.js"));function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var o,t,c=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((o=c&&Object.getOwnPropertyDescriptor(e,t))&&(o.get||o.set)?c(s,t,o):s[t]=e[t]);return s}const copyFiles=()=>{const e=gulpConfig.get("copyFiles",[]);return e.length?Promise.all(e.map(({from:e,to:r,base:o})=>new Promise((t,c)=>{(0,_copyFor.copyFor)(e,r,{base:o}).on("finish",t).on("error",c)}))).then(()=>{}):Promise.resolve()};exports.copyFiles=copyFiles;
package/dist/copyFonts.js CHANGED
@@ -1,18 +1,18 @@
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.copyFonts = void 0;
8
- var _copyFor = require("./partials/copyFor.js");
9
- var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
10
- var cache;
11
- 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; }
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.copyFonts = void 0;
8
+ var _copyFor = require("./partials/copyFor.js");
9
+ var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
10
+ var cache;
11
+ 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; }
12
12
  /**
13
13
  * Move the font files into the browser directory.
14
14
  * @memberOf module:js-build-tools
15
15
  * @return {stream.Stream}
16
- */
17
- const copyFonts = () => (0, _copyFor.copyFor)(gulpConfig.get('fonts.from'), gulpConfig.get('fonts.to'));
16
+ */
17
+ const copyFonts = () => (0, _copyFor.copyFor)(gulpConfig.get('fonts.from'), gulpConfig.get('fonts.to'));
18
18
  exports.copyFonts = copyFonts;
package/dist/default.js CHANGED
@@ -1,21 +1,21 @@
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.defaultCmd = void 0;
8
- var _dist = require("./dist.js");
9
- var _bundle = require("./bundle.js");
10
- var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
11
- var _gulp = require("gulp");
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; }
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.defaultCmd = void 0;
8
+ var _dist = require("./dist.js");
9
+ var _bundle = require("./bundle.js");
10
+ var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
11
+ var _gulp = require("gulp");
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
14
  /**
15
15
  * Recommended as the default task, runs the simple dist and bundle tasks.
16
16
  * @memberOf module:js-build-tools
17
17
  * @param {function} [done=null]
18
18
  * @returns {stream.Stream}
19
- */
20
- const defaultCmd = (done = null) => gulpConfig.get('browser.enabled') ? (0, _gulp.series)(_dist.dist, _bundle.bundle)(done) : (0, _gulp.series)(_dist.dist)(done);
19
+ */
20
+ const defaultCmd = (done = null) => gulpConfig.get('browser.enabled') ? (0, _gulp.series)(_dist.dist, _bundle.bundle)(done) : (0, _gulp.series)(_dist.dist)(done);
21
21
  exports.defaultCmd = defaultCmd;
@@ -1,18 +1,18 @@
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.distMinify = void 0;
8
- var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
9
- var _minifyFor = require("./partials/minifyFor.js");
10
- var cache;
11
- 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; }
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.distMinify = void 0;
8
+ var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
9
+ var _minifyFor = require("./partials/minifyFor.js");
10
+ var cache;
11
+ 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; }
12
12
  /**
13
13
  * Creates minified versions of the dist files.
14
14
  * @memberOf module:js-build-tools
15
15
  * @returns {*}
16
- */
17
- const distMinify = () => (0, _minifyFor.minifyFor)(gulpConfig.get('browser.from'), gulpConfig.get('dist.to'));
16
+ */
17
+ const distMinify = () => (0, _minifyFor.minifyFor)(gulpConfig.get('browser.from'), gulpConfig.get('dist.to'));
18
18
  exports.distMinify = distMinify;
package/dist/docs.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.docs = void 0;
7
+ var _jsdocDocs = require("./jsdocDocs.js");
8
+ var _resolveDocsMethod = require("./partials/resolveDocsMethod.js");
9
+ var _typeDocs = require("./typeDocs.js");
10
+ /**
11
+ * Generate the HTML documentation with whichever engine docs.method (or its typescript.enabled-based default)
12
+ * resolves to - see {@link module:partials.resolveDocsMethod}. The standalone counterpart to build's own
13
+ * internal branching, for running `gulp docs` directly instead of as part of a full build.
14
+ * @memberOf module:js-build-tools
15
+ * @param {Function} [done]
16
+ * @returns {*}
17
+ */
18
+ const docs = (done = null) => ((0, _resolveDocsMethod.resolveDocsMethod)() === 'jsdoc' ? _jsdocDocs.jsdocDocs : _typeDocs.typeDocs)(done);
19
+ exports.docs = docs;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.docs=void 0;var _jsdocDocs=require("./jsdocDocs.js"),_resolveDocsMethod=require("./partials/resolveDocsMethod.js"),_typeDocs=require("./typeDocs.js");const docs=(o=null)=>("jsdoc"===(0,_resolveDocsMethod.resolveDocsMethod)()?_jsdocDocs.jsdocDocs:_typeDocs.typeDocs)(o);exports.docs=docs;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.jsdocDocs = void 0;
7
+ var _jsdocDocsFor = require("./partials/jsdocDocsFor.js");
8
+ /**
9
+ * Generate the HTML documentation of a plain-JavaScript project from its source, with a modern jsdoc theme
10
+ * instead of jsdoc's own classic default. Turn it on with docs.enabled and docs.method: 'jsdoc' (the default
11
+ * when typescript.enabled is off), see {@link module:partials.jsdocDocsFor}.
12
+ * @memberOf module:js-build-tools
13
+ * @returns {Function}
14
+ */
15
+ const jsdocDocs = exports.jsdocDocs = (0, _jsdocDocsFor.jsdocDocsFor)();
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.jsdocDocs=void 0;var _jsdocDocsFor=require("./partials/jsdocDocsFor.js");const jsdocDocs=exports.jsdocDocs=(0,_jsdocDocsFor.jsdocDocsFor)();