js-build-tools 6.1.0 → 6.2.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 (47) hide show
  1. package/README.md +89 -25
  2. package/dist/build.js +68 -63
  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/jsdocDocs.js +15 -0
  12. package/dist/jsdocDocs.min.js +1 -0
  13. package/dist/partials/addToReadme.js +25 -25
  14. package/dist/partials/beginWatcher.js +13 -13
  15. package/dist/partials/clean.js +15 -15
  16. package/dist/partials/copyFor.js +10 -2
  17. package/dist/partials/distFor.js +22 -22
  18. package/dist/partials/distForSrc.js +12 -12
  19. package/dist/partials/distSeries.js +20 -20
  20. package/dist/partials/imagesFor.js +43 -43
  21. package/dist/partials/jsdocDocsFor.js +155 -0
  22. package/dist/partials/neostandardLint.js +121 -121
  23. package/dist/partials/readmeTemplate.js +15 -15
  24. package/dist/partials/runOnChange.js +29 -29
  25. package/dist/partials/sassFor.js +29 -29
  26. package/dist/partials/tsFor.js +71 -71
  27. package/dist/partials/typeDocsFor.js +203 -203
  28. package/dist/sourceLint.js +26 -26
  29. package/dist/test-helpers/neostandardLintWithRealNeostandard.js +49 -49
  30. package/dist/test-helpers/setUp.js +95 -95
  31. package/dist/testFull.js +20 -20
  32. package/dist/testHelpers.js +10 -10
  33. package/dist/testQuick.js +22 -22
  34. package/dist/utilities/dotNotate.js +48 -48
  35. package/dist/utilities/getBundleConfigs.js +28 -28
  36. package/dist/watchTest.js +16 -16
  37. package/functions/build.mjs +7 -2
  38. package/functions/build.test.mjs +50 -1
  39. package/functions/copyFiles.mjs +32 -0
  40. package/functions/copyFiles.test.mjs +78 -0
  41. package/functions/jsdocDocs.mjs +10 -0
  42. package/functions/partials/copyFor.mjs +4 -1
  43. package/functions/partials/jsdocDocsFor.mjs +132 -0
  44. package/functions/partials/jsdocDocsFor.test.mjs +101 -0
  45. package/gulp.config.mjs +28 -5
  46. package/gulpfile.base.mjs +2 -0
  47. package/package.json +11 -1
@@ -1,100 +1,100 @@
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
- Object.defineProperty(exports, "afterEach", {
8
- enumerable: true,
9
- get: function () {
10
- return _testFilesystem.afterEach;
11
- }
12
- });
13
- Object.defineProperty(exports, "beforeEach", {
14
- enumerable: true,
15
- get: function () {
16
- return _testFilesystem.beforeEach;
17
- }
18
- });
19
- Object.defineProperty(exports, "countMatches", {
20
- enumerable: true,
21
- get: function () {
22
- return _testFilesystem.countMatches;
23
- }
24
- });
25
- Object.defineProperty(exports, "createTempDir", {
26
- enumerable: true,
27
- get: function () {
28
- return _testFilesystem.createTempDir;
29
- }
30
- });
31
- Object.defineProperty(exports, "fileExists", {
32
- enumerable: true,
33
- get: function () {
34
- return _testFilesystem.fileExists;
35
- }
36
- });
37
- exports.gulpConfig = void 0;
38
- Object.defineProperty(exports, "logObject", {
39
- enumerable: true,
40
- get: function () {
41
- return _testFilesystem.logObject;
42
- }
43
- });
44
- Object.defineProperty(exports, "removeDirectory", {
45
- enumerable: true,
46
- get: function () {
47
- return _testFilesystem.removeDirectory;
48
- }
49
- });
50
- exports.setDefaults = void 0;
51
- var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
52
- exports.gulpConfig = gulpConfig;
53
- var _testFilesystem = require("test-filesystem");
54
- var cache;
55
- 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; }
56
- // Import the configurations and override some of them to direct to the temp directory.
57
-
58
- let tempDir = 'test-temp/';
59
- let srcPath = `${tempDir}src`;
60
-
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
+ Object.defineProperty(exports, "afterEach", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _testFilesystem.afterEach;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "beforeEach", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _testFilesystem.beforeEach;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "countMatches", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _testFilesystem.countMatches;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "createTempDir", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _testFilesystem.createTempDir;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "fileExists", {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _testFilesystem.fileExists;
35
+ }
36
+ });
37
+ exports.gulpConfig = void 0;
38
+ Object.defineProperty(exports, "logObject", {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _testFilesystem.logObject;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, "removeDirectory", {
45
+ enumerable: true,
46
+ get: function () {
47
+ return _testFilesystem.removeDirectory;
48
+ }
49
+ });
50
+ exports.setDefaults = void 0;
51
+ var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
52
+ exports.gulpConfig = gulpConfig;
53
+ var _testFilesystem = require("test-filesystem");
54
+ var cache;
55
+ 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; }
56
+ // Import the configurations and override some of them to direct to the temp directory.
57
+
58
+ let tempDir = 'test-temp/';
59
+ let srcPath = `${tempDir}src`;
60
+
61
61
  /**
62
62
  * Update the gulp configurations with the test data. Set the test directory where temp files will be created for testing.
63
63
  * @memberOf module:testHelpers
64
64
  * @param {string} testDir
65
- */
66
- const setDefaults = (testDir = 'test-temp') => {
67
- tempDir = `${testDir}/`;
68
- srcPath = `${tempDir}src`;
69
- _testFilesystem.setUp.setDefaults(tempDir);
70
- const distPath = `${tempDir}dist`;
71
- const browserPath = `${tempDir}browser`;
72
- const sassPath = `${tempDir}sass`;
73
- gulpConfig.set('browser.from', `${distPath}/**/*.js`);
74
- gulpConfig.set('browser.to', browserPath);
75
- gulpConfig.set('cleanPaths', [distPath, browserPath]);
76
- gulpConfig.set('dist.from', `${srcPath}/**/!(*.test).js`);
77
- gulpConfig.set('dist.main', `${distPath}/main`);
78
- gulpConfig.set('dist.to', distPath);
79
- gulpConfig.set('fonts.from', `${srcPath}/fonts/**/*`);
80
- gulpConfig.set('fonts.to', `${browserPath}/fonts`);
81
- gulpConfig.set('images.from', `${srcPath}/img/**/*.+(png|jpg|jpeg|gif|svg)`);
82
- gulpConfig.set('images.to', `${browserPath}/img`);
83
- gulpConfig.set('readme.template', `${tempDir}MAIN.md`);
84
- gulpConfig.set('readme.to', tempDir);
85
- gulpConfig.set('readme.from', `${srcPath}/**/!(*.test).js`);
86
- // Reset explicitly: gulpConfig is a process-wide singleton seeded once from this real project's own
87
- // build-tools.config.json, so without this, this project's own real readme.fromEsm value (gulp.config.mjs)
88
- // would leak into every test that exercises addToReadme/compileReadme but never sets this path itself -
89
- // doing real file I/O and a real jsdoc-to-markdown parse of this project's own, much larger, config file.
90
- gulpConfig.set('readme.fromEsm', []);
91
- gulpConfig.set('rootPath', tempDir);
92
- gulpConfig.set('sass.from', `${sassPath}/**/*.+(scss|sass)`);
93
- gulpConfig.set('sass.path', sassPath);
94
- gulpConfig.set('sass.to', `${browserPath}/css`);
95
- gulpConfig.set('srcPath', srcPath);
96
- gulpConfig.set('typescript.from', `${srcPath}/**/*.ts`);
97
- gulpConfig.set('typescript.to', distPath);
98
- gulpConfig.set('test.watch', `${srcPath}/**/*.js`);
99
- };
65
+ */
66
+ const setDefaults = (testDir = 'test-temp') => {
67
+ tempDir = `${testDir}/`;
68
+ srcPath = `${tempDir}src`;
69
+ _testFilesystem.setUp.setDefaults(tempDir);
70
+ const distPath = `${tempDir}dist`;
71
+ const browserPath = `${tempDir}browser`;
72
+ const sassPath = `${tempDir}sass`;
73
+ gulpConfig.set('browser.from', `${distPath}/**/*.js`);
74
+ gulpConfig.set('browser.to', browserPath);
75
+ gulpConfig.set('cleanPaths', [distPath, browserPath]);
76
+ gulpConfig.set('dist.from', `${srcPath}/**/!(*.test).js`);
77
+ gulpConfig.set('dist.main', `${distPath}/main`);
78
+ gulpConfig.set('dist.to', distPath);
79
+ gulpConfig.set('fonts.from', `${srcPath}/fonts/**/*`);
80
+ gulpConfig.set('fonts.to', `${browserPath}/fonts`);
81
+ gulpConfig.set('images.from', `${srcPath}/img/**/*.+(png|jpg|jpeg|gif|svg)`);
82
+ gulpConfig.set('images.to', `${browserPath}/img`);
83
+ gulpConfig.set('readme.template', `${tempDir}MAIN.md`);
84
+ gulpConfig.set('readme.to', tempDir);
85
+ gulpConfig.set('readme.from', `${srcPath}/**/!(*.test).js`);
86
+ // Reset explicitly: gulpConfig is a process-wide singleton seeded once from this real project's own
87
+ // build-tools.config.json, so without this, this project's own real readme.fromEsm value (gulp.config.mjs)
88
+ // would leak into every test that exercises addToReadme/compileReadme but never sets this path itself -
89
+ // doing real file I/O and a real jsdoc-to-markdown parse of this project's own, much larger, config file.
90
+ gulpConfig.set('readme.fromEsm', []);
91
+ gulpConfig.set('rootPath', tempDir);
92
+ gulpConfig.set('sass.from', `${sassPath}/**/*.+(scss|sass)`);
93
+ gulpConfig.set('sass.path', sassPath);
94
+ gulpConfig.set('sass.to', `${browserPath}/css`);
95
+ gulpConfig.set('srcPath', srcPath);
96
+ gulpConfig.set('typescript.from', `${srcPath}/**/*.ts`);
97
+ gulpConfig.set('typescript.to', distPath);
98
+ gulpConfig.set('test.watch', `${srcPath}/**/*.js`);
99
+ };
100
100
  exports.setDefaults = setDefaults;
package/dist/testFull.js CHANGED
@@ -1,26 +1,26 @@
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.testFull = void 0;
8
- var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
9
- var _jest = require("jest");
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.testFull = void 0;
8
+ var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
9
+ var _jest = require("jest");
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
  * Run all tests with jest.
14
14
  * Configure where tests are located by using 'testPath'.
15
15
  * @memberOf module:js-build-tools
16
16
  * @returns {Promise<*>}
17
- */
18
- const testFull = () => {
19
- let testPath = gulpConfig.get('test.path');
20
- if (!Array.isArray(testPath)) {
21
- // The testPath must be an array of strings
22
- testPath = [testPath];
23
- }
24
- return (0, _jest.runCLI)(gulpConfig.get('test.options'), testPath);
25
- };
17
+ */
18
+ const testFull = () => {
19
+ let testPath = gulpConfig.get('test.path');
20
+ if (!Array.isArray(testPath)) {
21
+ // The testPath must be an array of strings
22
+ testPath = [testPath];
23
+ }
24
+ return (0, _jest.runCLI)(gulpConfig.get('test.options'), testPath);
25
+ };
26
26
  exports.testFull = testFull;
@@ -1,11 +1,11 @@
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.testHelpers = void 0;
8
- var _testHelpers = _interopRequireWildcard(require("./test-helpers/setUp.js"));
9
- exports.testHelpers = _testHelpers;
10
- var cache;
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.testHelpers = void 0;
8
+ var _testHelpers = _interopRequireWildcard(require("./test-helpers/setUp.js"));
9
+ exports.testHelpers = _testHelpers;
10
+ var cache;
11
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; }
package/dist/testQuick.js CHANGED
@@ -1,28 +1,28 @@
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.testQuick = void 0;
8
- var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
9
- var _jest = require("jest");
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.testQuick = void 0;
8
+ var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
9
+ var _jest = require("jest");
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
  * Run the Jest tests for files which have been modified (based on git status).
14
14
  * Configure where tests are located by using 'testPath'.
15
15
  * @memberOf module:js-build-tools
16
16
  * @returns {Promise<*>}
17
- */
18
- const testQuick = () => {
19
- let testPath = gulpConfig.get('test.path');
20
- if (!Array.isArray(testPath)) {
21
- // The testPath must be an array of strings
22
- testPath = [testPath];
23
- }
24
- return (0, _jest.runCLI)({
25
- onlyChanged: true
26
- }, testPath);
27
- };
17
+ */
18
+ const testQuick = () => {
19
+ let testPath = gulpConfig.get('test.path');
20
+ if (!Array.isArray(testPath)) {
21
+ // The testPath must be an array of strings
22
+ testPath = [testPath];
23
+ }
24
+ return (0, _jest.runCLI)({
25
+ onlyChanged: true
26
+ }, testPath);
27
+ };
28
28
  exports.testQuick = testQuick;
@@ -1,43 +1,43 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.dotNotate = void 0;
7
- require("core-js/modules/esnext.iterator.constructor.js");
8
- require("core-js/modules/esnext.iterator.map.js");
9
- var _isObject = require("./isObject.js");
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.dotNotate = void 0;
7
+ require("core-js/modules/esnext.iterator.constructor.js");
8
+ require("core-js/modules/esnext.iterator.map.js");
9
+ var _isObject = require("./isObject.js");
10
10
  /**
11
11
  * Convert an array of keys into a regex, return a function to test if incoming keys match.
12
12
  * @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
13
13
  * @returns {Function} The dot-notated array
14
- */
15
- const handleRetainObjects = (retainObjects = []) => {
16
- if (!retainObjects.length) {
14
+ */
15
+ const handleRetainObjects = (retainObjects = []) => {
16
+ if (!retainObjects.length) {
17
17
  /**
18
18
  * Bypass the test function if there are no retainObjects.
19
19
  * @returns {false}
20
- */
21
- return (currentKey, value, results) => false;
22
- }
23
- retainObjects = retainObjects.map(key => key.replace('\.', '\\.'));
24
- const retainRegex = new RegExp(`(${retainObjects.join('|')})$`);
20
+ */
21
+ return (currentKey, value, results) => false;
22
+ }
23
+ retainObjects = retainObjects.map(key => key.replace('\.', '\\.'));
24
+ const retainRegex = new RegExp(`(${retainObjects.join('|')})$`);
25
25
  /**
26
26
  * Test if a key should be retained as an object.
27
27
  * @param {string} currentKey - The key to test
28
28
  * @param {*} value - The value of the key
29
29
  * @param {Object} results - The result object to add to
30
30
  * @returns {boolean}
31
- */
32
- return (currentKey, value, results) => {
33
- if (!currentKey.match(retainRegex)) {
34
- return false;
35
- }
36
- results[currentKey] = value;
37
- return true;
38
- };
39
- };
40
-
31
+ */
32
+ return (currentKey, value, results) => {
33
+ if (!currentKey.match(retainRegex)) {
34
+ return false;
35
+ }
36
+ results[currentKey] = value;
37
+ return true;
38
+ };
39
+ };
40
+
41
41
  /**
42
42
  * The underlying logic function for converting arrays to dot-notation.
43
43
  * @param {Object} arrayObject - The array or object to dot-notate
@@ -45,31 +45,31 @@ const handleRetainObjects = (retainObjects = []) => {
45
45
  * @param {string} [prepend=''] - The path for the property being processed
46
46
  * @param {Object<string, *>} [results={}] - The final notated object to return
47
47
  * @returns {Object<string, *>} The dot-notated object
48
- */
49
- const performDotNotate = (arrayObject, didRetain, prepend = '', results = {}) => {
50
- for (let key in arrayObject) {
51
- const value = arrayObject[key];
52
- const currentKey = `${prepend}${key}`;
53
- if (didRetain(currentKey, value, results)) {
54
- continue;
55
- }
56
- // An empty object/array has no keys to flatten into - recursing into one would silently drop currentKey
57
- // from the result entirely, rather than keeping it as the empty value it actually is. Treat it as a leaf.
58
- if ((0, _isObject.isObject)(value) && Object.keys(value).length) {
59
- performDotNotate(value, didRetain, `${currentKey}.`, results);
60
- continue;
61
- }
62
- results[currentKey] = value;
63
- }
64
- return results;
65
- };
66
-
48
+ */
49
+ const performDotNotate = (arrayObject, didRetain, prepend = '', results = {}) => {
50
+ for (let key in arrayObject) {
51
+ const value = arrayObject[key];
52
+ const currentKey = `${prepend}${key}`;
53
+ if (didRetain(currentKey, value, results)) {
54
+ continue;
55
+ }
56
+ // An empty object/array has no keys to flatten into - recursing into one would silently drop currentKey
57
+ // from the result entirely, rather than keeping it as the empty value it actually is. Treat it as a leaf.
58
+ if ((0, _isObject.isObject)(value) && Object.keys(value).length) {
59
+ performDotNotate(value, didRetain, `${currentKey}.`, results);
60
+ continue;
61
+ }
62
+ results[currentKey] = value;
63
+ }
64
+ return results;
65
+ };
66
+
67
67
  /**
68
68
  * Convert an array or object to a single dimensional associative array with dot notation.
69
69
  * Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotNotate.ts Sí, funciona}
70
70
  * @param {Object} arrayObject - The array or object to dot-notate
71
71
  * @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
72
72
  * @returns {Object<string, *>} The dot-notated object
73
- */
74
- const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects));
73
+ */
74
+ const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects));
75
75
  exports.dotNotate = dotNotate;
@@ -1,15 +1,15 @@
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.getBundleConfigs = 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 cache;
12
- 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.getBundleConfigs = 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 cache;
12
+ 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; }
13
13
  /**
14
14
  * Build the full list of bundles to produce for this project: the primary bundle (browser.name /
15
15
  * dist.main / browser.ignore / browser.exclude, exactly as before browser.bundles existed) plus
@@ -18,20 +18,20 @@ function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e;
18
18
  * specify what's actually different about it.
19
19
  * @memberOf module:utilities
20
20
  * @returns {Array<{name: string, main: string, ignore: Array, exclude: Array}>}
21
- */
22
- const getBundleConfigs = () => {
23
- const primary = {
24
- name: gulpConfig.get('browser.name'),
25
- main: gulpConfig.get('dist.main'),
26
- ignore: gulpConfig.get('browser.ignore'),
27
- exclude: gulpConfig.get('browser.exclude')
28
- };
29
- const additional = gulpConfig.get('browser.bundles');
30
- return [primary, ...additional.map(bundleConfig => ({
31
- name: bundleConfig.name,
32
- main: bundleConfig.main || primary.main,
33
- ignore: bundleConfig.ignore || primary.ignore,
34
- exclude: bundleConfig.exclude || primary.exclude
35
- }))];
36
- };
21
+ */
22
+ const getBundleConfigs = () => {
23
+ const primary = {
24
+ name: gulpConfig.get('browser.name'),
25
+ main: gulpConfig.get('dist.main'),
26
+ ignore: gulpConfig.get('browser.ignore'),
27
+ exclude: gulpConfig.get('browser.exclude')
28
+ };
29
+ const additional = gulpConfig.get('browser.bundles');
30
+ return [primary, ...additional.map(bundleConfig => ({
31
+ name: bundleConfig.name,
32
+ main: bundleConfig.main || primary.main,
33
+ ignore: bundleConfig.ignore || primary.ignore,
34
+ exclude: bundleConfig.exclude || primary.exclude
35
+ }))];
36
+ };
37
37
  exports.getBundleConfigs = getBundleConfigs;
package/dist/watchTest.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.watchTest = void 0;
8
- var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
9
- var _gulp = require("gulp");
10
- var _testQuick = require("./testQuick.js");
11
- var cache;
12
- 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.watchTest = void 0;
8
+ var gulpConfig = _interopRequireWildcard(require("../gulp.config.js"));
9
+ var _gulp = require("gulp");
10
+ var _testQuick = require("./testQuick.js");
11
+ var cache;
12
+ 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; }
13
13
  /**
14
14
  * Watch for changes and run the tests.
15
15
  * @memberOf module:js-build-tools
16
16
  * @returns {*}
17
- */
18
- const watchTest = () => (0, _gulp.watch)(gulpConfig.get('test.watch'), {
19
- ignoreInitial: false
20
- }, _testQuick.testQuick);
17
+ */
18
+ const watchTest = () => (0, _gulp.watch)(gulpConfig.get('test.watch'), {
19
+ ignoreInitial: false
20
+ }, _testQuick.testQuick);
21
21
  exports.watchTest = watchTest;
@@ -3,6 +3,7 @@ import { bundleMinify } from './bundleMinify.mjs'
3
3
  import { clean, distSeries } from './partials.mjs'
4
4
  import { compileReadme } from './compileReadme.mjs'
5
5
  import { typeDocs } from './typeDocs.mjs'
6
+ import { jsdocDocs } from './jsdocDocs.mjs'
6
7
  import { distMinify } from './distMinify.mjs'
7
8
  import { sourceLint } from './sourceLint.mjs'
8
9
  import { parallel, series } from 'gulp'
@@ -22,9 +23,13 @@ import { testFull } from './testFull.mjs'
22
23
  export const build = (done = null) => {
23
24
  const buildActions = [distSeries(), distMinify]
24
25
  const generateDocs = gulpConfig.get('docs.enabled')
26
+ // docs.method picks the engine explicitly; left unset (false, the default), it's inferred from
27
+ // typescript.enabled - every existing TypeScript project's config, which never sets method, keeps producing
28
+ // TypeDoc output exactly as it always has.
29
+ const docsMethod = gulpConfig.get('docs.method') || (gulpConfig.get('typescript.enabled') ? 'typedoc' : 'jsdoc')
25
30
  if (generateDocs) {
26
- // The documentation is generated from the TypeScript source itself, the readme is written by hand
27
- buildActions.push(typeDocs)
31
+ // The documentation is generated from the source itself, the readme is written by hand
32
+ buildActions.push(docsMethod === 'jsdoc' ? jsdocDocs : typeDocs)
28
33
  } else if (gulpConfig.get('typescript.enabled')) {
29
34
  // For ts usage, we need to run the readme on the dist directly since that is where the .js files are located
30
35
  buildActions.push(compileReadme)
@@ -4,6 +4,7 @@ import { build } from './build.mjs'
4
4
  import { clean } from './partials/clean.mjs'
5
5
  import { testFull } from './testFull.mjs'
6
6
  import { typeDocs } from './typeDocs.mjs'
7
+ import { jsdocDocs } from './jsdocDocs.mjs'
7
8
  import { countMatches } from 'test-filesystem'
8
9
 
9
10
  // Run the real neostandard (in a subprocess) - Jest's CommonJS transform can't load the ESM-only package itself.
@@ -16,8 +17,11 @@ const genericFunction = () => Promise.resolve(true)
16
17
 
17
18
  jest.mock('./partials/clean.mjs', () => ({ clean: jest.fn(genericFunction) }))
18
19
  jest.mock('./testFull.mjs', () => ({ testFull: jest.fn(genericFunction) }))
19
- // The documentation is generated by TypeDoc, whose own tests cover that (see typeDocsFor.test.mjs)
20
+ // The documentation is generated by TypeDoc or jsdoc, whose own tests cover that (see typeDocsFor.test.mjs /
21
+ // jsdocDocsFor.test.mjs) - jsdocDocs in particular shells out to a real CLI, far too slow for a build.mjs unit
22
+ // test to actually run.
20
23
  jest.mock('./typeDocs.mjs', () => ({ typeDocs: jest.fn(genericFunction) }))
24
+ jest.mock('./jsdocDocs.mjs', () => ({ jsdocDocs: jest.fn(genericFunction) }))
21
25
  // tsFor's real implementation loads gulp-ts-compile (a genuine ESM-only package) via a dynamic import() hidden
22
26
  // from babel's static analysis - necessary for production correctness (see tsFor.mjs's own comments), but this
23
27
  // project's current CommonJS-transform-based Jest setup can't execute a real dynamic import at all: it doesn't
@@ -638,6 +642,7 @@ describe('build', () => {
638
642
  expect.assertions(3)
639
643
  build(() => {
640
644
  gulpConfig.set('docs.enabled', false)
645
+ gulpConfig.set('typescript.enabled', false)
641
646
  expect(typeDocs).toHaveBeenCalledTimes(1)
642
647
  // The readme is not generated, it is written by hand
643
648
  expect(fs.existsSync(`${readmePath}/${readmeFile}`)).toBe(false)
@@ -646,6 +651,50 @@ describe('build', () => {
646
651
  })
647
652
  }, 30000)
648
653
 
654
+ test('when docs.enabled is set without typescript.enabled: generates the documentation with jsdoc, inferred from docs.method being unset', done => {
655
+ const readmePath = gulpConfig.get('readme.to')
656
+ const readmeFile = gulpConfig.get('readme.file')
657
+ fs.rmSync(`${readmePath}/${readmeFile}`, { force: true })
658
+ jsdocDocs.mockClear()
659
+ gulpConfig.set('browser.enabled', false)
660
+ gulpConfig.set('typescript.enabled', false)
661
+ gulpConfig.set('docs.enabled', true)
662
+ expect.assertions(3)
663
+ build(() => {
664
+ gulpConfig.set('docs.enabled', false)
665
+ expect(jsdocDocs).toHaveBeenCalledTimes(1)
666
+ // The readme is not generated, it is written by hand - same as the TypeDoc path above
667
+ expect(fs.existsSync(`${readmePath}/${readmeFile}`)).toBe(false)
668
+ expect(testFull).toHaveBeenCalled()
669
+ done()
670
+ })
671
+ }, 30000)
672
+
673
+ test('docs.method overrides the typescript.enabled inference either way', done => {
674
+ const srcPath = gulpConfig.get('srcPath')
675
+ const rootPath = gulpConfig.get('rootPath')
676
+ const tsConfig = `${rootPath}/tsconfig.json`
677
+ fs.writeFileSync(`${srcPath}/main.ts`, mainTypescript)
678
+ fs.writeFileSync(tsConfig, tsConfigContents)
679
+ typeDocs.mockClear()
680
+ jsdocDocs.mockClear()
681
+ gulpConfig.set('browser.enabled', false)
682
+ gulpConfig.set('typescript.config', tsConfig)
683
+ gulpConfig.set('typescript.enabled', true)
684
+ gulpConfig.set('docs.enabled', true)
685
+ // typescript.enabled is true, which would normally infer 'typedoc' - method forces 'jsdoc' instead.
686
+ gulpConfig.set('docs.method', 'jsdoc')
687
+ expect.assertions(2)
688
+ build(() => {
689
+ gulpConfig.set('docs.enabled', false)
690
+ gulpConfig.set('docs.method', false)
691
+ gulpConfig.set('typescript.enabled', false)
692
+ expect(jsdocDocs).toHaveBeenCalledTimes(1)
693
+ expect(typeDocs).not.toHaveBeenCalled()
694
+ done()
695
+ })
696
+ }, 30000)
697
+
649
698
  test('finishes clean before starting the tasks that write into the output folders', done => {
650
699
  const srcPath = gulpConfig.get('srcPath')
651
700
  const sourcesPath = `${srcPath}/sources`