js-build-tools 6.4.1 → 6.5.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.
package/README.md CHANGED
@@ -561,6 +561,9 @@ Add the following to the exports in your `build-tools.config.json`:
561
561
  // The directory holding the source, each folder in it becomes a module (TypeDoc) or is scanned recursively (jsdoc).
562
562
  // jsdoc also takes a list of directories and files, for example ["functions", "gulpfile.base.mjs"]
563
563
  "from": "src",
564
+ // Generate the documentation as part of build (the default). Set it to false to only generate it when you run
565
+ // the docs task yourself (see below)
566
+ "inBuild": true,
564
567
  // The markdown file used as the front page of the documentation (a short overview of your project)
565
568
  "index": "MAIN.md",
566
569
  // 'typedoc' or 'jsdoc'. Left out (or false), it's inferred from typescript.enabled - 'typedoc' when your
@@ -582,6 +585,20 @@ While `docs.enabled` is on, `gulp build` generates the documentation instead of
582
585
  hand-written (a short overview which links to the documentation). If you also export `docs` from your gulpfile you can
583
586
  run it on its own with `gulp docs`, and can then add the script `"docs": "gulp docs"`.
584
587
 
588
+ To make generating the documentation a deliberate step instead, set `docs.inBuild` to `false`: `gulp build` then
589
+ generates neither the documentation nor the readme, and `gulp docs` is the only thing that writes to `docs.to`. This
590
+ suits a `docs.to` which points into another repository (a website, say): a build on a work-in-progress branch no
591
+ longer rewrites the published documentation, which you regenerate when you release instead. For example with
592
+ release-it, in `.release-it.json`:
593
+
594
+ ```json
595
+ {
596
+ "hooks": {
597
+ "after:bump": "npm run docs"
598
+ }
599
+ }
600
+ ```
601
+
585
602
  ### Browser automation (optional)
586
603
 
587
604
  Unlike the rest of this file, this isn't a `build-tools.config.json`-driven feature with its own task - it's a pair
package/dist/build.js CHANGED
@@ -1,73 +1,76 @@
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.build = void 0;
8
- var _bundle = require("./bundle.js");
9
- var _bundleMinify = require("./bundleMinify.js");
10
- var _partials = require("./partials.js");
11
- var _compileReadme = require("./compileReadme.js");
12
- var _typeDocs = require("./typeDocs.js");
13
- var _jsdocDocs = require("./jsdocDocs.js");
14
- var _distMinify = require("./distMinify.js");
15
- var _sourceLint = require("./sourceLint.js");
16
- var _gulp = require("gulp");
17
- var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
18
- var _copyFonts = require("./copyFonts.js");
19
- var _images = require("./images.js");
20
- var _resolveDocsMethod = require("./partials/resolveDocsMethod.js");
21
- var _sass = require("./sass.js");
22
- var _testFull = require("./testFull.js");
23
- var cache;
24
- 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.build = void 0;
8
+ var _bundle = require("./bundle.js");
9
+ var _bundleMinify = require("./bundleMinify.js");
10
+ var _partials = require("./partials.js");
11
+ var _compileReadme = require("./compileReadme.js");
12
+ var _typeDocs = require("./typeDocs.js");
13
+ var _jsdocDocs = require("./jsdocDocs.js");
14
+ var _distMinify = require("./distMinify.js");
15
+ var _sourceLint = require("./sourceLint.js");
16
+ var _gulp = require("gulp");
17
+ var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
18
+ var _copyFonts = require("./copyFonts.js");
19
+ var _images = require("./images.js");
20
+ var _resolveDocsMethod = require("./partials/resolveDocsMethod.js");
21
+ var _sass = require("./sass.js");
22
+ var _testFull = require("./testFull.js");
23
+ var cache;
24
+ 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; }
25
25
  /**
26
26
  * Runs several processes to build and validate the project.
27
27
  * Cleans and lints the source, distributes and minifies, bundles and minifies, creates the readme, then runs the
28
28
  * tests.
29
29
  * @memberOf module:js-build-tools
30
30
  * @returns {stream.Stream}
31
- */
32
- const build = (done = null) => {
33
- const buildActions = [(0, _partials.distSeries)(), _distMinify.distMinify];
34
- const generateDocs = gulpConfig.get('docs.enabled');
35
- const docsMethod = (0, _resolveDocsMethod.resolveDocsMethod)();
36
- if (generateDocs) {
37
- // The documentation is generated from the source itself, the readme is written by hand
38
- buildActions.push(docsMethod === 'jsdoc' ? _jsdocDocs.jsdocDocs : _typeDocs.typeDocs);
39
- } else if (gulpConfig.get('typescript.enabled')) {
40
- // For ts usage, we need to run the readme on the dist directly since that is where the .js files are located
41
- buildActions.push(_compileReadme.compileReadme);
42
- }
43
- if (gulpConfig.get('browser.enabled')) {
44
- // If not 'nodeOnly' then we also want to bundle for browser after we complete the dist directory
45
- buildActions.push(_bundle.bundle);
46
- buildActions.push(_bundleMinify.bundleMinify);
47
- }
48
- const runActions = [(0, _gulp.series)(...buildActions)];
49
- if (!generateDocs && !gulpConfig.get('typescript.enabled')) {
50
- // Since we didn't run this in series after dist because of typescript, we need to run it now. Potentially faster here.
51
- runActions.push(_compileReadme.compileReadme);
52
- }
53
- runActions.push(_testFull.testFull);
54
- if (gulpConfig.get('fonts.enabled')) {
55
- // Conditionally add Fonts process
56
- runActions.push(_copyFonts.copyFonts);
57
- }
58
- if (gulpConfig.get('images.enabled')) {
59
- // Conditionally add Images process
60
- runActions.push(_images.images);
61
- }
62
- if (gulpConfig.get('sass.enabled')) {
63
- // Conditionally add SASS process
64
- runActions.push(_sass.sass);
65
- }
66
- // clean has to finish before anything writes into the output folders - images, fonts and sass all write into
67
- // browser/, so running clean in parallel with them races (ENOTEMPTY errors from clean, or output deleted mid-write).
68
- // sourceLint fixes the real source in place before anything compiles from it (distSeries, tsFor inside it), so a
69
- // build never reads a mix of pre- and post-fix content; clean only touches dist/browser output, so the two can
70
- // run alongside each other.
71
- return (0, _gulp.series)((0, _gulp.parallel)(_partials.clean, _sourceLint.sourceLint), (0, _gulp.parallel)(...runActions))(done);
72
- };
31
+ */
32
+ const build = (done = null) => {
33
+ const buildActions = [(0, _partials.distSeries)(), _distMinify.distMinify];
34
+ const generateDocs = gulpConfig.get('docs.enabled');
35
+ const docsMethod = (0, _resolveDocsMethod.resolveDocsMethod)();
36
+ if (generateDocs) {
37
+ // The documentation is generated from the source itself, the readme is written by hand. With docs.inBuild off,
38
+ // generating it is left to the standalone docs task (gulp docs), so a build never rewrites it.
39
+ if (gulpConfig.get('docs.inBuild') !== false) {
40
+ buildActions.push(docsMethod === 'jsdoc' ? _jsdocDocs.jsdocDocs : _typeDocs.typeDocs);
41
+ }
42
+ } else if (gulpConfig.get('typescript.enabled')) {
43
+ // For ts usage, we need to run the readme on the dist directly since that is where the .js files are located
44
+ buildActions.push(_compileReadme.compileReadme);
45
+ }
46
+ if (gulpConfig.get('browser.enabled')) {
47
+ // If not 'nodeOnly' then we also want to bundle for browser after we complete the dist directory
48
+ buildActions.push(_bundle.bundle);
49
+ buildActions.push(_bundleMinify.bundleMinify);
50
+ }
51
+ const runActions = [(0, _gulp.series)(...buildActions)];
52
+ if (!generateDocs && !gulpConfig.get('typescript.enabled')) {
53
+ // Since we didn't run this in series after dist because of typescript, we need to run it now. Potentially faster here.
54
+ runActions.push(_compileReadme.compileReadme);
55
+ }
56
+ runActions.push(_testFull.testFull);
57
+ if (gulpConfig.get('fonts.enabled')) {
58
+ // Conditionally add Fonts process
59
+ runActions.push(_copyFonts.copyFonts);
60
+ }
61
+ if (gulpConfig.get('images.enabled')) {
62
+ // Conditionally add Images process
63
+ runActions.push(_images.images);
64
+ }
65
+ if (gulpConfig.get('sass.enabled')) {
66
+ // Conditionally add SASS process
67
+ runActions.push(_sass.sass);
68
+ }
69
+ // clean has to finish before anything writes into the output folders - images, fonts and sass all write into
70
+ // browser/, so running clean in parallel with them races (ENOTEMPTY errors from clean, or output deleted mid-write).
71
+ // sourceLint fixes the real source in place before anything compiles from it (distSeries, tsFor inside it), so a
72
+ // build never reads a mix of pre- and post-fix content; clean only touches dist/browser output, so the two can
73
+ // run alongside each other.
74
+ return (0, _gulp.series)((0, _gulp.parallel)(_partials.clean, _sourceLint.sourceLint), (0, _gulp.parallel)(...runActions))(done);
75
+ };
73
76
  exports.build = build;
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"),_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;
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?!1!==gulpConfig.get("docs.inBuild")&&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;
@@ -26,8 +26,11 @@ export const build = (done = null) => {
26
26
  const generateDocs = gulpConfig.get('docs.enabled')
27
27
  const docsMethod = resolveDocsMethod()
28
28
  if (generateDocs) {
29
- // The documentation is generated from the source itself, the readme is written by hand
30
- buildActions.push(docsMethod === 'jsdoc' ? jsdocDocs : typeDocs)
29
+ // The documentation is generated from the source itself, the readme is written by hand. With docs.inBuild off,
30
+ // generating it is left to the standalone docs task (gulp docs), so a build never rewrites it.
31
+ if (gulpConfig.get('docs.inBuild') !== false) {
32
+ buildActions.push(docsMethod === 'jsdoc' ? jsdocDocs : typeDocs)
33
+ }
31
34
  } else if (gulpConfig.get('typescript.enabled')) {
32
35
  // For ts usage, we need to run the readme on the dist directly since that is where the .js files are located
33
36
  buildActions.push(compileReadme)
@@ -676,6 +676,29 @@ describe('build', () => {
676
676
  })
677
677
  }, 30000)
678
678
 
679
+ test('with docs.inBuild off, build generates neither the documentation nor the readme', done => {
680
+ const readmePath = gulpConfig.get('readme.to')
681
+ const readmeFile = gulpConfig.get('readme.file')
682
+ fs.rmSync(`${readmePath}/${readmeFile}`, { force: true })
683
+ typeDocs.mockClear()
684
+ jsdocDocs.mockClear()
685
+ gulpConfig.set('browser.enabled', false)
686
+ gulpConfig.set('typescript.enabled', false)
687
+ gulpConfig.set('docs.enabled', true)
688
+ gulpConfig.set('docs.inBuild', false)
689
+ expect.assertions(4)
690
+ build(() => {
691
+ gulpConfig.set('docs.enabled', false)
692
+ gulpConfig.set('docs.inBuild', true)
693
+ expect(jsdocDocs).not.toHaveBeenCalled()
694
+ expect(typeDocs).not.toHaveBeenCalled()
695
+ // The readme is still written by hand while docs.enabled is on
696
+ expect(fs.existsSync(`${readmePath}/${readmeFile}`)).toBe(false)
697
+ expect(testFull).toHaveBeenCalled()
698
+ done()
699
+ })
700
+ }, 30000)
701
+
679
702
  test('docs.method overrides the typescript.enabled inference either way', done => {
680
703
  const srcPath = gulpConfig.get('srcPath')
681
704
  const rootPath = gulpConfig.get('rootPath')
package/gulp.config.mjs CHANGED
@@ -135,6 +135,9 @@ import { fileExists } from 'test-filesystem'
135
135
  * build does this instead of generating the readme from the jsdoc comments of the compiled files.
136
136
  * @property {ArrayableSetting} from - The directory holding the source, each folder in it becomes a module (TypeDoc) or
137
137
  * is scanned recursively (jsdoc). jsdoc also takes a list of directories and files.
138
+ * @property {BooleanSetting} inBuild - Generate the documentation as part of build (the default). Turn it off to only
139
+ * generate it when you run the docs task yourself (gulp docs), for example when docs.to points into another
140
+ * repository and you only want to publish the documentation of a release.
138
141
  * @property {StringSetting} index - The markdown file used as the front page of the documentation.
139
142
  * @property {StringSetting} logLevel - How much TypeDoc reports: Verbose, Info, Warn, Error or None. Not used by jsdoc.
140
143
  * @property {FlagStringSetting} method - 'typedoc' or 'jsdoc'. False (the default) infers it from typescript.enabled -
@@ -216,6 +219,7 @@ const setDefaults = {
216
219
  docs: {
217
220
  enabled: false,
218
221
  from: 'src',
222
+ inBuild: true,
219
223
  index: 'MAIN.md',
220
224
  logLevel: 'Warn',
221
225
  method: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-build-tools",
3
- "version": "6.4.1",
3
+ "version": "6.5.0",
4
4
  "description": "Standardised build process with gulp.",
5
5
  "main": "gulpfile.base.js",
6
6
  "exports": {