js-build-tools 6.0.0 → 6.1.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 (52) hide show
  1. package/README.md +45 -2
  2. package/dist/build.js +63 -62
  3. package/dist/build.min.js +1 -1
  4. package/dist/bundle.js +40 -39
  5. package/dist/bundle.min.js +1 -1
  6. package/dist/bundleMinify.js +18 -17
  7. package/dist/bundleMinify.min.js +1 -1
  8. package/dist/copyFonts.js +13 -12
  9. package/dist/copyFonts.min.js +1 -1
  10. package/dist/default.js +15 -14
  11. package/dist/default.min.js +1 -1
  12. package/dist/distMinify.js +13 -12
  13. package/dist/distMinify.min.js +1 -1
  14. package/dist/partials/addToReadme.js +25 -24
  15. package/dist/partials/beginWatcher.js +13 -12
  16. package/dist/partials/clean.js +15 -14
  17. package/dist/partials/distFor.js +22 -21
  18. package/dist/partials/distForSrc.js +12 -11
  19. package/dist/partials/distSeries.js +20 -19
  20. package/dist/partials/imagesFor.js +43 -42
  21. package/dist/partials/neostandardLint.js +130 -111
  22. package/dist/partials/readmeTemplate.js +15 -14
  23. package/dist/partials/runOnChange.js +29 -28
  24. package/dist/partials/sassFor.js +29 -28
  25. package/dist/partials/tsFor.js +71 -70
  26. package/dist/partials/typeDocsFor.js +203 -202
  27. package/dist/sourceLint.js +26 -24
  28. package/dist/sourceLint.min.js +1 -1
  29. package/dist/test-helpers/neostandardLintWithRealNeostandard.js +49 -47
  30. package/dist/test-helpers/setUp.js +95 -94
  31. package/dist/testFull.js +20 -19
  32. package/dist/testFull.min.js +1 -1
  33. package/dist/testHelpers.js +11 -10
  34. package/dist/testHelpers.min.js +1 -1
  35. package/dist/testQuick.js +22 -21
  36. package/dist/testQuick.min.js +1 -1
  37. package/dist/utilities/dotNotate.js +48 -46
  38. package/dist/utilities/getBundleConfigs.js +28 -27
  39. package/dist/watchTest.js +16 -15
  40. package/dist/watchTest.min.js +1 -1
  41. package/functions/bundle.mjs +2 -2
  42. package/functions/partials/addToReadme.mjs +1 -1
  43. package/functions/partials/neostandardLint.mjs +19 -7
  44. package/functions/partials/neostandardLint.test.mjs +9 -1
  45. package/functions/sourceLint.mjs +1 -1
  46. package/functions/sourceLint.test.mjs +24 -0
  47. package/functions/test-helpers/neostandardLintWithRealNeostandard.mjs +7 -5
  48. package/functions/utilities/dotNotate.mjs +3 -1
  49. package/functions/utilities/dotNotate.test.mjs +34 -0
  50. package/functions/utilities/getBundleConfigs.mjs +1 -1
  51. package/gulp.config.mjs +14 -0
  52. package/package.json +1 -1
@@ -1,16 +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.runOnChange = void 0;
8
- var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
9
- var _bundle = require("../bundle.js");
10
- var _distSeries = require("./distSeries.js");
11
- var _gulp = require("gulp");
12
- var _testQuick = require("../testQuick.js");
13
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
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.runOnChange = void 0;
8
+ var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
9
+ var _bundle = require("../bundle.js");
10
+ var _distSeries = require("./distSeries.js");
11
+ var _gulp = require("gulp");
12
+ var _testQuick = require("../testQuick.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; }
14
15
  /**
15
16
  * Run this function when the watched files are modified.
16
17
  * 1. Find the sub-folders within src path
@@ -35,11 +36,11 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
35
36
  * @memberOf module:partials
36
37
  * @param {string} path
37
38
  * @returns {stream.Stream}
38
- */
39
- const runOnChange = path => {
40
- const useTs = gulpConfig.get('typescript.enabled');
41
- const distPath = gulpConfig.get('dist.to');
42
- const srcPath = gulpConfig.get('srcPath');
39
+ */
40
+ const runOnChange = path => {
41
+ const useTs = gulpConfig.get('typescript.enabled');
42
+ const distPath = gulpConfig.get('dist.to');
43
+ const srcPath = gulpConfig.get('srcPath');
43
44
  /**
44
45
  * 1. The original path comes in from src and is a .ts
45
46
  * 2. Discover the outgoing dist path where that file should go
@@ -47,14 +48,14 @@ const runOnChange = path => {
47
48
  * 4. Take the original path, convert to full file path in dist
48
49
  * 5. Use the dist path found previously in #2
49
50
  * 6. Use the full dist path and the dist outgoing path in distFor
50
- */
51
- const pathRegex = new RegExp(`^${srcPath}(.*\\/)(.+)\\.(js|ts)$`, 'i');
52
- const distPathResult = path.replace(pathRegex, `${distPath}$1`);
53
- let distSrcPath = path;
54
- if (useTs) {
55
- distSrcPath = path.replace(pathRegex, `${distPath}$1$2.js`);
56
- }
57
- const runSeries = (0, _distSeries.distSeries)(distSrcPath, distPathResult, path);
58
- return gulpConfig.get('browser.enabled') ? (0, _gulp.parallel)(_testQuick.testQuick, (0, _gulp.series)(runSeries, _bundle.bundle))() : (0, _gulp.series)(_testQuick.testQuick, runSeries)();
59
- };
51
+ */
52
+ const pathRegex = new RegExp(`^${srcPath}(.*\\/)(.+)\\.(js|ts)$`, 'i');
53
+ const distPathResult = path.replace(pathRegex, `${distPath}$1`);
54
+ let distSrcPath = path;
55
+ if (useTs) {
56
+ distSrcPath = path.replace(pathRegex, `${distPath}$1$2.js`);
57
+ }
58
+ const runSeries = (0, _distSeries.distSeries)(distSrcPath, distPathResult, path);
59
+ return gulpConfig.get('browser.enabled') ? (0, _gulp.parallel)(_testQuick.testQuick, (0, _gulp.series)(runSeries, _bundle.bundle))() : (0, _gulp.series)(_testQuick.testQuick, runSeries)();
60
+ };
60
61
  exports.runOnChange = runOnChange;
@@ -1,35 +1,36 @@
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.sassFor = void 0;
8
- var _gulp = require("gulp");
9
- var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
10
- var _autoprefixer = _interopRequireDefault(require("autoprefixer"));
11
- var _cssnano = _interopRequireDefault(require("cssnano"));
12
- var _gulpPostcss = _interopRequireDefault(require("gulp-postcss"));
13
- var _gulpRename = _interopRequireDefault(require("gulp-rename"));
14
- var sass = _interopRequireWildcard(require("sass"));
15
- var _gulpSass = _interopRequireDefault(require("gulp-sass"));
16
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
18
- const runSass = (0, _gulpSass.default)(sass);
19
-
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.sassFor = void 0;
8
+ var _gulp = require("gulp");
9
+ var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
10
+ var _autoprefixer = _interopRequireDefault(require("autoprefixer"));
11
+ var _cssnano = _interopRequireDefault(require("cssnano"));
12
+ var _gulpPostcss = _interopRequireDefault(require("gulp-postcss"));
13
+ var _gulpRename = _interopRequireDefault(require("gulp-rename"));
14
+ var sass = _interopRequireWildcard(require("sass"));
15
+ var _gulpSass = _interopRequireDefault(require("gulp-sass"));
16
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ var cache;
18
+ 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; }
19
+ const runSass = (0, _gulpSass.default)(sass);
20
+
20
21
  /**
21
22
  * Build the CSS for a given source pattern.
22
23
  * @memberOf module:partials
23
24
  * @param {string|array} [srcSearch='src/config/path/sass/for']
24
25
  * @param {string} [cssPath='css/config/path']
25
26
  * @returns {stream.Stream}
26
- */
27
- const sassFor = (srcSearch = gulpConfig.get('sass.from'), cssPath = gulpConfig.get('sass.to')) => (0, _gulp.src)(srcSearch).pipe(runSass().on('error', runSass.logError)) // Passes it through a gulp-sass, log errors to console
28
- .pipe((0, _gulp.dest)(cssPath))
29
- // add: false - the old gulp-cssnano only ever removed obsolete vendor prefixes, never added any; keep that.
30
- .pipe((0, _gulpPostcss.default)([(0, _autoprefixer.default)({
31
- add: false
32
- }), (0, _cssnano.default)()])).pipe((0, _gulpRename.default)({
33
- extname: '.min.css'
34
- })).pipe((0, _gulp.dest)(cssPath));
27
+ */
28
+ const sassFor = (srcSearch = gulpConfig.get('sass.from'), cssPath = gulpConfig.get('sass.to')) => (0, _gulp.src)(srcSearch).pipe(runSass().on('error', runSass.logError)) // Passes it through a gulp-sass, log errors to console
29
+ .pipe((0, _gulp.dest)(cssPath))
30
+ // add: false - the old gulp-cssnano only ever removed obsolete vendor prefixes, never added any; keep that.
31
+ .pipe((0, _gulpPostcss.default)([(0, _autoprefixer.default)({
32
+ add: false
33
+ }), (0, _cssnano.default)()])).pipe((0, _gulpRename.default)({
34
+ extname: '.min.css'
35
+ })).pipe((0, _gulp.dest)(cssPath));
35
36
  exports.sassFor = sassFor;
@@ -1,27 +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.tsFor = exports.loadTypescript = void 0;
8
- var _gulp = require("gulp");
9
- var _nodePath = _interopRequireDefault(require("node:path"));
10
- var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
11
- var _loadPeer = require("./loadPeer.js");
12
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- // gulp-ts-compile ships ESM-only (no CJS build - see its own package.json), see importModule for how it is imported.
15
- const importGulpTsCompile = () => (0, _loadPeer.importModule)('gulp-ts-compile');
16
-
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.tsFor = exports.loadTypescript = void 0;
8
+ var _gulp = require("gulp");
9
+ var _nodePath = _interopRequireDefault(require("node:path"));
10
+ var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
11
+ var _loadPeer = require("./loadPeer.js");
12
+ var cache;
13
+ function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ // gulp-ts-compile ships ESM-only (no CJS build - see its own package.json), see importModule for how it is imported.
16
+ const importGulpTsCompile = () => (0, _loadPeer.importModule)('gulp-ts-compile');
17
+
17
18
  /**
18
19
  * Wrap a stream in a promise that resolves once it finishes writing.
19
20
  * @memberOf module:partials
20
21
  * @param {import('node:stream').Stream} stream
21
22
  * @returns {Promise<void>}
22
- */
23
- const installHint = 'Install it in your project with: npm install --save-dev typescript';
24
-
23
+ */
24
+ const installHint = 'Install it in your project with: npm install --save-dev typescript';
25
+
25
26
  /**
26
27
  * Load the project's own copy of TypeScript (an optional peer dependency, only needed when the typescript task is
27
28
  * enabled) from the project being built, so projects which do not use TypeScript never need it installed.
@@ -29,18 +30,18 @@ const installHint = 'Install it in your project with: npm install --save-dev typ
29
30
  * @param {string} [projectPath=process.cwd()] The folder of the project (which has the package.json) being built.
30
31
  * @returns {Object} The TypeScript compiler API module.
31
32
  * @throws {Error} With install instructions when typescript is not installed.
32
- */
33
- const loadTypescript = (projectPath = process.cwd()) => (0, _loadPeer.requirePeer)('typescript', {
34
- task: 'typescript',
35
- installHint,
36
- projectPath
37
- });
38
- exports.loadTypescript = loadTypescript;
39
- const streamToPromise = stream => new Promise((resolve, reject) => {
40
- stream.on('finish', resolve);
41
- stream.on('error', reject);
42
- });
43
-
33
+ */
34
+ const loadTypescript = (projectPath = process.cwd()) => (0, _loadPeer.requirePeer)('typescript', {
35
+ task: 'typescript',
36
+ installHint,
37
+ projectPath
38
+ });
39
+ exports.loadTypescript = loadTypescript;
40
+ const streamToPromise = stream => new Promise((resolve, reject) => {
41
+ stream.on('finish', resolve);
42
+ stream.on('error', reject);
43
+ });
44
+
44
45
  /**
45
46
  * Read a tsconfig.json file into real typescript.CompilerOptions values, using only TypeScript's stable, current,
46
47
  * public config-reading API (the same one `tsc --project` itself uses internally) - never
@@ -49,13 +50,13 @@ const streamToPromise = stream => new Promise((resolve, reject) => {
49
50
  * @memberOf module:partials
50
51
  * @param {string} configPath - Path to a tsconfig.json file.
51
52
  * @returns {import('typescript').CompilerOptions}
52
- */
53
- const readCompilerOptions = (ts, configPath) => {
54
- const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
55
- const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, _nodePath.default.dirname(configPath));
56
- return parsedConfig.options;
57
- };
58
-
53
+ */
54
+ const readCompilerOptions = (ts, configPath) => {
55
+ const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
56
+ const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, _nodePath.default.dirname(configPath));
57
+ return parsedConfig.options;
58
+ };
59
+
59
60
  /**
60
61
  * Starting at the source directory, find all the ts files and convert them into the distribution directory.
61
62
  * @memberOf module:partials
@@ -68,36 +69,36 @@ const readCompilerOptions = (ts, configPath) => {
68
69
  * suite already covers real TypeScript-compile correctness - this function's own tests only need to verify its
69
70
  * config resolution and stream wiring.
70
71
  * @returns {Function}
71
- */
72
- const tsFor = (srcPath = gulpConfig.get('typescript.from'), distPath = gulpConfig.get('typescript.to'), loadTsCompile = () => importGulpTsCompile().then(({
73
- default: tsCompile
74
- }) => tsCompile)) => {
75
- if (gulpConfig.get('typescript.enabled') === false) {
76
- return () => {};
77
- }
78
- const ts = loadTypescript();
79
- const configPath = gulpConfig.get('typescript.config');
80
- // When no tsconfig.json is configured, target/module are pinned explicitly rather than left for TypeScript's
81
- // own compiler defaults - those defaults have already shifted once across a TypeScript version bump in this
82
- // project's own history (silently changing whether output keeps `const`/`let` or downlevels to `var`), and
83
- // pinning them keeps this task's output stable across future TypeScript upgrades too. ES5/CommonJS matches
84
- // what the downstream babel/browserify bundling pipeline has always assumed it receives.
85
- const compilerOptions = configPath ? readCompilerOptions(ts, configPath) : {
86
- declaration: true,
87
- target: ts.ScriptTarget.ES5,
88
- module: ts.ModuleKind.CommonJS,
89
- esModuleInterop: false
90
- };
91
- // Accepts gulp's own callback-style task convention (an optional `done`, called once finished) rather than
92
- // just returning a Promise, since callers may invoke the returned function directly with a callback instead
93
- // of relying on gulp's own runner to observe a returned Promise.
94
- return done => {
95
- const compile = async () => {
96
- const tsCompile = await loadTsCompile();
97
- const tsResult = (0, _gulp.src)(srcPath).pipe(tsCompile(compilerOptions));
98
- await Promise.all([streamToPromise(tsResult.dts.pipe((0, _gulp.dest)(distPath))), streamToPromise(tsResult.js.pipe((0, _gulp.dest)(distPath)))]);
99
- };
100
- return typeof done === 'function' ? compile().then(() => done(), done) : compile();
101
- };
102
- };
72
+ */
73
+ const tsFor = (srcPath = gulpConfig.get('typescript.from'), distPath = gulpConfig.get('typescript.to'), loadTsCompile = () => importGulpTsCompile().then(({
74
+ default: tsCompile
75
+ }) => tsCompile)) => {
76
+ if (gulpConfig.get('typescript.enabled') === false) {
77
+ return () => {};
78
+ }
79
+ const ts = loadTypescript();
80
+ const configPath = gulpConfig.get('typescript.config');
81
+ // When no tsconfig.json is configured, target/module are pinned explicitly rather than left for TypeScript's
82
+ // own compiler defaults - those defaults have already shifted once across a TypeScript version bump in this
83
+ // project's own history (silently changing whether output keeps `const`/`let` or downlevels to `var`), and
84
+ // pinning them keeps this task's output stable across future TypeScript upgrades too. ES5/CommonJS matches
85
+ // what the downstream babel/browserify bundling pipeline has always assumed it receives.
86
+ const compilerOptions = configPath ? readCompilerOptions(ts, configPath) : {
87
+ declaration: true,
88
+ target: ts.ScriptTarget.ES5,
89
+ module: ts.ModuleKind.CommonJS,
90
+ esModuleInterop: false
91
+ };
92
+ // Accepts gulp's own callback-style task convention (an optional `done`, called once finished) rather than
93
+ // just returning a Promise, since callers may invoke the returned function directly with a callback instead
94
+ // of relying on gulp's own runner to observe a returned Promise.
95
+ return done => {
96
+ const compile = async () => {
97
+ const tsCompile = await loadTsCompile();
98
+ const tsResult = (0, _gulp.src)(srcPath).pipe(tsCompile(compilerOptions));
99
+ await Promise.all([streamToPromise(tsResult.dts.pipe((0, _gulp.dest)(distPath))), streamToPromise(tsResult.js.pipe((0, _gulp.dest)(distPath)))]);
100
+ };
101
+ return typeof done === 'function' ? compile().then(() => done(), done) : compile();
102
+ };
103
+ };
103
104
  exports.tsFor = tsFor;