js-build-tools 4.1.1 → 5.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 (67) hide show
  1. package/README.md +274 -267
  2. package/babel.config.js +18 -1
  3. package/dist/build.js +58 -56
  4. package/dist/build.min.js +1 -1
  5. package/dist/bundle.js +16 -16
  6. package/dist/bundleLint.js +16 -20
  7. package/dist/bundleLint.min.js +1 -1
  8. package/dist/bundleMinify.js +13 -13
  9. package/dist/compileReadme.js +10 -10
  10. package/dist/copyFonts.js +13 -13
  11. package/dist/default.js +15 -15
  12. package/dist/dist.js +10 -10
  13. package/dist/distLint.js +16 -20
  14. package/dist/distLint.min.js +1 -1
  15. package/dist/distMinify.js +13 -13
  16. package/dist/images.js +10 -10
  17. package/dist/partials/addToReadme.js +17 -17
  18. package/dist/partials/beginWatcher.js +12 -12
  19. package/dist/partials/clean.js +14 -14
  20. package/dist/partials/copyFor.js +12 -9
  21. package/dist/partials/distFor.js +21 -21
  22. package/dist/partials/distForSrc.js +11 -11
  23. package/dist/partials/distSeries.js +19 -19
  24. package/dist/partials/imagesFor.js +56 -21
  25. package/dist/partials/minifyFor.js +16 -16
  26. package/dist/partials/readmeTemplate.js +14 -14
  27. package/dist/partials/removeDirectory.js +37 -13
  28. package/dist/partials/runOnChange.js +28 -28
  29. package/dist/partials/sassFor.js +28 -22
  30. package/dist/partials/standardLint.js +96 -0
  31. package/dist/partials.js +110 -103
  32. package/dist/partials.min.js +1 -1
  33. package/dist/sass.js +10 -10
  34. package/dist/test-helpers/setUp.js +89 -89
  35. package/dist/test-helpers/standardLintWithRealStandard.js +28 -0
  36. package/dist/testFull.js +3 -3
  37. package/dist/testHelpers.js +10 -10
  38. package/dist/testQuick.js +3 -3
  39. package/dist/typeScript.js +9 -9
  40. package/dist/utilities/dotGet.js +46 -46
  41. package/dist/utilities/dotNotate.js +46 -46
  42. package/dist/utilities/dotSet.js +37 -37
  43. package/dist/utilities/isObject.js +8 -8
  44. package/dist/utilities/strAfter.js +11 -11
  45. package/dist/utilities/strBefore.js +11 -11
  46. package/dist/watchFull.js +10 -10
  47. package/dist/watchTest.js +16 -16
  48. package/functions/build.mjs +6 -3
  49. package/functions/build.test.mjs +31 -0
  50. package/functions/bundleLint.mjs +2 -6
  51. package/functions/bundleLint.test.mjs +3 -0
  52. package/functions/distLint.mjs +2 -6
  53. package/functions/distLint.test.mjs +3 -0
  54. package/functions/partials/copyFor.mjs +2 -1
  55. package/functions/partials/copyFor.test.mjs +18 -0
  56. package/functions/partials/imagesFor.mjs +35 -3
  57. package/functions/partials/imagesFor.test.mjs +83 -1
  58. package/functions/partials/removeDirectory.mjs +28 -14
  59. package/functions/partials/removeDirectory.test.mjs +44 -0
  60. package/functions/partials/sassFor.mjs +5 -2
  61. package/functions/partials/sassFor.test.mjs +22 -4
  62. package/functions/partials/standardLint.mjs +80 -0
  63. package/functions/partials/standardLint.test.mjs +99 -0
  64. package/functions/partials.mjs +1 -0
  65. package/functions/partials.test.mjs +1 -1
  66. package/functions/test-helpers/standardLintWithRealStandard.mjs +21 -0
  67. package/package.json +15 -4
@@ -1,16 +1,19 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.copyFor = void 0;
7
- var _gulp = require("gulp");
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.copyFor = void 0;
7
+ var _gulp = require("gulp");
8
8
  /**
9
9
  * Copy some files to a different location.
10
10
  * @memberOf module:partials
11
11
  * @param {string|array} srcPath
12
12
  * @param {string} destPath
13
13
  * @returns {stream.Stream}
14
- */
15
- const copyFor = (srcPath, destPath) => (0, _gulp.src)(srcPath).pipe((0, _gulp.dest)(destPath));
14
+ */
15
+ // encoding: false copies the bytes untouched - Gulp 5's default utf8 handling corrupts binary files such as fonts.
16
+ const copyFor = (srcPath, destPath) => (0, _gulp.src)(srcPath, {
17
+ encoding: false
18
+ }).pipe((0, _gulp.dest)(destPath));
16
19
  exports.copyFor = copyFor;
@@ -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.distFor = void 0;
8
- var _gulpBabel = _interopRequireDefault(require("gulp-babel"));
9
- var _gulp = require("gulp");
10
- var _distForSrc = require("./distForSrc.js");
11
- var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
12
- var _through = _interopRequireDefault(require("through2"));
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); }
14
- 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.distFor = void 0;
8
+ var _gulpBabel = _interopRequireDefault(require("gulp-babel"));
9
+ var _gulp = require("gulp");
10
+ var _distForSrc = require("./distForSrc.js");
11
+ var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
12
+ var _through = _interopRequireDefault(require("through2"));
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); }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
15
  /**
16
16
  * Build the distribution for a given source pattern.
17
17
  * @memberOf module:partials
18
18
  * @param {string|array} [srcPath='src/config/path/dist/for']
19
19
  * @param {string} [destPath='dist/config/path']
20
20
  * @returns {stream.Stream}
21
- */
22
- const distFor = (srcPath = (0, _distForSrc.distForSrc)(), destPath = gulpConfig.get('dist.to')) => (0, _gulp.src)(srcPath).pipe((0, _gulpBabel.default)()).pipe(_through.default.obj(function (file, enc, callback) {
23
- const regex = /\.mjs(['"]\s*\))/gi;
24
- file.contents = Buffer.from(file.contents.toString().replaceAll(regex, '.js$1'));
25
- this.push(file);
26
- callback();
27
- })).pipe((0, _gulp.dest)(destPath));
21
+ */
22
+ const distFor = (srcPath = (0, _distForSrc.distForSrc)(), destPath = gulpConfig.get('dist.to')) => (0, _gulp.src)(srcPath).pipe((0, _gulpBabel.default)()).pipe(_through.default.obj(function (file, enc, callback) {
23
+ const regex = /\.mjs(['"]\s*\))/gi;
24
+ file.contents = Buffer.from(file.contents.toString().replaceAll(regex, '.js$1'));
25
+ this.push(file);
26
+ callback();
27
+ })).pipe((0, _gulp.dest)(destPath));
28
28
  exports.distFor = distFor;
@@ -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.distForSrc = void 0;
8
- var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
9
- 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.distForSrc = void 0;
8
+ var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
9
+ 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); }
10
10
  /**
11
11
  * Retrieve the correct distFor search path based on TS Config.
12
12
  * @memberOf module:partials
13
13
  * @param {module:gulpConfig~FlagStringSetting} [useTs='config/for/ts']
14
14
  * @returns {string}
15
- */
16
- const distForSrc = (useTs = gulpConfig.get('typescript.enabled')) => useTs ? gulpConfig.get('browser.from') : gulpConfig.get('dist.from');
15
+ */
16
+ const distForSrc = (useTs = gulpConfig.get('typescript.enabled')) => useTs ? gulpConfig.get('browser.from') : gulpConfig.get('dist.from');
17
17
  exports.distForSrc = distForSrc;
@@ -1,16 +1,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.distSeries = void 0;
8
- var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
9
- var _distFor = require("./distFor.js");
10
- var _distForSrc = require("./distForSrc.js");
11
- var _gulp = require("gulp");
12
- var _tsFor = require("./tsFor.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.distSeries = void 0;
8
+ var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
9
+ var _distFor = require("./distFor.js");
10
+ var _distForSrc = require("./distForSrc.js");
11
+ var _gulp = require("gulp");
12
+ var _tsFor = require("./tsFor.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); }
14
14
  /**
15
15
  * When using TypeScript, ensure that we process the ts first then run babel (dist)
16
16
  * @memberOf module:partials
@@ -18,10 +18,10 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
18
18
  * @param {string} [distFinalPath='dist/config/path']
19
19
  * @param {string} [tsSearch='ts/search/config/path']
20
20
  * @returns {function(null=): stream.Stream}
21
- */
22
- const distSeries = (srcPath = (0, _distForSrc.distForSrc)(), distFinalPath = gulpConfig.get('dist.to'), tsSearch = gulpConfig.get('typescript.from')) => {
23
- const typescript = (0, _tsFor.tsFor)(tsSearch, distFinalPath);
24
- const dist = () => (0, _distFor.distFor)(srcPath, distFinalPath);
25
- return gulpConfig.get('typescript.enabled') ? (0, _gulp.series)(typescript, dist) : dist;
26
- };
21
+ */
22
+ const distSeries = (srcPath = (0, _distForSrc.distForSrc)(), distFinalPath = gulpConfig.get('dist.to'), tsSearch = gulpConfig.get('typescript.from')) => {
23
+ const typescript = (0, _tsFor.tsFor)(tsSearch, distFinalPath);
24
+ const dist = () => (0, _distFor.distFor)(srcPath, distFinalPath);
25
+ return gulpConfig.get('typescript.enabled') ? (0, _gulp.series)(typescript, dist) : dist;
26
+ };
27
27
  exports.distSeries = distSeries;
@@ -1,28 +1,63 @@
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.imagesFor = void 0;
8
- var _gulpCache = _interopRequireDefault(require("gulp-cache"));
9
- var _gulp = require("gulp");
10
- var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
11
- var _gulpImagemin = _interopRequireDefault(require("gulp-imagemin"));
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 }; }
1
+ "use strict";
2
+
3
+ require("core-js/modules/esnext.weak-map.delete-all.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.loadImagemin = exports.imagesFor = void 0;
8
+ var _gulpCache = _interopRequireDefault(require("gulp-cache"));
9
+ var _nodeModule = require("node:module");
10
+ var _gulp = require("gulp");
11
+ var _nodePath = _interopRequireDefault(require("node:path"));
12
+ var gulpConfig = _interopRequireWildcard(require("../../gulp.config.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); }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ const installHint = 'Add it to your project with: npm install --save-dev github:jheagle/gulp-imagemin#common-js-compatibility ' + '(the CommonJS-compatible fork - upstream gulp-imagemin is ESM-only and cannot be require()d by this package\'s CommonJS build).';
16
+
17
+ /**
18
+ * Load `gulp-imagemin`, an optional peer dependency: image optimization is off by default and its binary-download
19
+ * dependency chain is heavy, so it is only required once the images task actually runs, and it is resolved from the
20
+ * consuming project's own directory rather than from this package.
21
+ * @memberOf module:partials
22
+ * @param {string} [projectPath=process.cwd()] - The project directory to resolve `gulp-imagemin` from.
23
+ * @returns {Function} The gulp-imagemin plugin factory.
24
+ * @throws {Error} With install instructions when gulp-imagemin is missing or is the ESM-only upstream release.
25
+ */
26
+ const loadImagemin = (projectPath = process.cwd()) => {
27
+ let loaded;
28
+ try {
29
+ loaded = (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json'))('gulp-imagemin');
30
+ } catch (error) {
31
+ if (error.code === 'MODULE_NOT_FOUND' && /Cannot find module 'gulp-imagemin'/.test(error.message)) {
32
+ throw new Error(`The images task needs the optional peer dependency gulp-imagemin, which is not installed. ${installHint}`);
33
+ }
34
+ if (error.code === 'ERR_REQUIRE_ESM') {
35
+ throw new Error(`gulp-imagemin could not be loaded because it is ESM-only. ${installHint}`);
36
+ }
37
+ throw error;
38
+ }
39
+ return loaded && (loaded.__esModule || loaded.default) ? loaded.default : loaded;
40
+ };
41
+
14
42
  /**
15
43
  * Move and optimize images into the browser directory.
16
44
  * @memberOf module:partials
17
45
  * @param {string|array} [imageSrc=src/images/pattern]
18
46
  * @param {string} [imageDest=dest/image/folder]
19
47
  * @return {stream.Stream}
20
- */
21
- const imagesFor = (imageSrc = gulpConfig.get('images.from'), imageDest = gulpConfig.get('images.to')) => (0, _gulp.src)(imageSrc).pipe(
22
- // Caching images that ran through imagemin
23
- (0, _gulpCache.default)((0, _gulpImagemin.default)({
24
- interlaced: true,
25
- silent: true,
26
- verbose: false
27
- }))).pipe((0, _gulp.dest)(imageDest));
48
+ */
49
+ exports.loadImagemin = loadImagemin;
50
+ const imagesFor = (imageSrc = gulpConfig.get('images.from'), imageDest = gulpConfig.get('images.to')) => {
51
+ const imagemin = loadImagemin();
52
+ // Gulp 5 reads files as utf8 text unless told otherwise, which corrupts binary images (and makes gulp-cache drop them).
53
+ return (0, _gulp.src)(imageSrc, {
54
+ encoding: false
55
+ }).pipe(
56
+ // Caching images that ran through imagemin
57
+ (0, _gulpCache.default)(imagemin({
58
+ interlaced: true,
59
+ silent: true,
60
+ verbose: false
61
+ }))).pipe((0, _gulp.dest)(imageDest));
62
+ };
28
63
  exports.imagesFor = imagesFor;
@@ -1,21 +1,21 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.minifyFor = void 0;
7
- var _gulp = require("gulp");
8
- var _gulpUglifyEs = _interopRequireDefault(require("gulp-uglify-es"));
9
- var _gulpRename = _interopRequireDefault(require("gulp-rename"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const uglify = _gulpUglifyEs.default.hasOwnProperty('default') ? _gulpUglifyEs.default.default : _gulpUglifyEs.default;
12
-
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.minifyFor = void 0;
7
+ var _gulp = require("gulp");
8
+ var _gulpUglifyEs = _interopRequireDefault(require("gulp-uglify-es"));
9
+ var _gulpRename = _interopRequireDefault(require("gulp-rename"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const uglify = _gulpUglifyEs.default.hasOwnProperty('default') ? _gulpUglifyEs.default.default : _gulpUglifyEs.default;
12
+
13
13
  /**
14
14
  * Minify files and rename the output with '.min' extension.
15
15
  * @memberOf module:partials
16
16
  * @returns {*}
17
- */
18
- const minifyFor = (srcSearch, destination) => (0, _gulp.src)(srcSearch).pipe(uglify()).pipe((0, _gulpRename.default)({
19
- extname: '.min.js'
20
- })).pipe((0, _gulp.dest)(destination));
17
+ */
18
+ const minifyFor = (srcSearch, destination) => (0, _gulp.src)(srcSearch).pipe(uglify()).pipe((0, _gulpRename.default)({
19
+ extname: '.min.js'
20
+ })).pipe((0, _gulp.dest)(destination));
21
21
  exports.minifyFor = minifyFor;
@@ -1,19 +1,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.readmeTemplate = void 0;
8
- var _gulp = require("gulp");
9
- var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
10
- var _gulpRename = _interopRequireDefault(require("gulp-rename"));
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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); }
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.readmeTemplate = void 0;
8
+ var _gulp = require("gulp");
9
+ var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
10
+ var _gulpRename = _interopRequireDefault(require("gulp-rename"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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
13
  /**
14
14
  * Copy a readme template into the README.md file.
15
15
  * @memberOf module:partials
16
16
  * @returns {*}
17
- */
18
- const readmeTemplate = () => (0, _gulp.src)(gulpConfig.get('readme.template')).pipe((0, _gulpRename.default)(gulpConfig.get('readme.file'))).pipe((0, _gulp.dest)(gulpConfig.get('readme.to')));
17
+ */
18
+ const readmeTemplate = () => (0, _gulp.src)(gulpConfig.get('readme.template')).pipe((0, _gulpRename.default)(gulpConfig.get('readme.file'))).pipe((0, _gulp.dest)(gulpConfig.get('readme.to')));
19
19
  exports.readmeTemplate = readmeTemplate;
@@ -1,17 +1,41 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.removeDirectory = void 0;
7
- var _fs = require("fs");
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.removeDirectory = void 0;
7
+ var _promises = require("node:fs/promises");
8
+ var _promises2 = require("node:timers/promises");
9
+ const attempts = 4;
10
+ const exists = dirPath => (0, _promises.access)(dirPath).then(() => true, () => false);
11
+
8
12
  /**
9
- * Return a promise to be completed once the specified directory is deleted.
13
+ * Delete a directory and everything in it, resolving only once it is really gone.
14
+ *
15
+ * A single rm can leave a directory behind - most often when something is still writing into it (a build task, a
16
+ * watcher, a dev server) or has it briefly locked (EBUSY/EPERM/ENOTEMPTY) - which silently leaves stale output for
17
+ * the next build. So: Node's own retry-with-back-off handles the transient errors, then the directory is checked and
18
+ * removed again if it was recreated, and a clear error is raised rather than carrying on with stale output.
10
19
  * @memberOf module:partials
11
20
  * @param {string} dirPath
12
- * @returns {Promise<*>}
13
- */
14
- const removeDirectory = dirPath => new Promise((resolve, reject) => (0, _fs.exists)(dirPath, doesExist => doesExist ? (0, _fs.rm)(dirPath, {
15
- recursive: true
16
- }, error => error ? reject(error) : resolve(dirPath)) : resolve(dirPath)));
21
+ * @returns {Promise<string>} Resolves with dirPath once the directory no longer exists (or already didn't).
22
+ * @throws {Error} If the directory still exists after several attempts.
23
+ */
24
+ const removeDirectory = async dirPath => {
25
+ for (let attempt = 1; attempt <= attempts; attempt++) {
26
+ await (0, _promises.rm)(dirPath, {
27
+ recursive: true,
28
+ force: true,
29
+ maxRetries: 5,
30
+ retryDelay: 100
31
+ });
32
+ if (!(await exists(dirPath))) {
33
+ return dirPath;
34
+ }
35
+ if (attempt < attempts) {
36
+ await (0, _promises2.setTimeout)(200 * attempt);
37
+ }
38
+ }
39
+ throw new Error(`Unable to remove "${dirPath}" - it was recreated or is locked. Stop anything that has it open or is writing ` + 'into it (watchers, dev servers, editors, other build tasks) and try again.');
40
+ };
17
41
  exports.removeDirectory = removeDirectory;
@@ -1,16 +1,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.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
+ 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); }
14
14
  /**
15
15
  * Run this function when the watched files are modified.
16
16
  * 1. Find the sub-folders within src path
@@ -35,11 +35,11 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
35
35
  * @memberOf module:partials
36
36
  * @param {string} path
37
37
  * @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');
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');
43
43
  /**
44
44
  * 1. The original path comes in from src and is a .ts
45
45
  * 2. Discover the outgoing dist path where that file should go
@@ -47,14 +47,14 @@ const runOnChange = path => {
47
47
  * 4. Take the original path, convert to full file path in dist
48
48
  * 5. Use the dist path found previously in #2
49
49
  * 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
- };
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
+ };
60
60
  exports.runOnChange = runOnChange;
@@ -1,29 +1,35 @@
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 _gulpCssnano = _interopRequireDefault(require("gulp-cssnano"));
11
- var _gulpRename = _interopRequireDefault(require("gulp-rename"));
12
- var sass = _interopRequireWildcard(require("sass"));
13
- var _gulpSass = _interopRequireDefault(require("gulp-sass"));
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- 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); }
16
- const runSass = (0, _gulpSass.default)(sass);
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.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
+
18
20
  /**
19
21
  * Build the CSS for a given source pattern.
20
22
  * @memberOf module:partials
21
23
  * @param {string|array} [srcSearch='src/config/path/sass/for']
22
24
  * @param {string} [cssPath='css/config/path']
23
25
  * @returns {stream.Stream}
24
- */
25
- 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
26
- .pipe((0, _gulp.dest)(cssPath)).pipe((0, _gulpCssnano.default)()).pipe((0, _gulpRename.default)({
27
- extname: '.min.css'
28
- })).pipe((0, _gulp.dest)(cssPath));
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));
29
35
  exports.sassFor = sassFor;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.standardLint = void 0;
7
+ require("core-js/modules/esnext.iterator.constructor.js");
8
+ require("core-js/modules/esnext.iterator.for-each.js");
9
+ var _nodePath = _interopRequireDefault(require("node:path"));
10
+ var _through = _interopRequireDefault(require("through2"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ // `standard` (17+) ships ESM-only, but this package also publishes a CommonJS build (dist/*.js) whose babel
13
+ // transform would turn even a dynamic import() into a require() that cannot load an ES module. Hiding the import()
14
+ // inside a Function constructor keeps it a genuine dynamic import that works from either build (same escape hatch
15
+ // as tsFor.mjs uses for gulp-ts-compile).
16
+ const importStandard = new Function('return import(\'standard\')');
17
+
18
+ /**
19
+ * Print a file's lint messages, if it has any.
20
+ * @memberOf module:partials
21
+ * @param {import('vinyl')} file
22
+ * @param {{messages: Array<{line: number, column: number, message: string}>, errorCount: number, warningCount: number}} result
23
+ * @returns {undefined}
24
+ */
25
+ const printFileReport = (file, result) => {
26
+ if (!result.messages.length) {
27
+ return;
28
+ }
29
+ console.log(_nodePath.default.relative(file.cwd, file.path));
30
+ result.messages.forEach(({
31
+ line,
32
+ column,
33
+ message
34
+ }) => console.log(`line ${line}:${column}\t${message}`));
35
+ console.log(`✖ ${result.errorCount} error\t⚠ ${result.warningCount} warning\n`);
36
+ };
37
+
38
+ /**
39
+ * Lint every file streaming through with JavaScript Standard Style and, unless `fix` is false, apply the automatic
40
+ * fixes to the file's contents so a following `dest()` writes the fixed version. Remaining problems are printed
41
+ * along with a summary once the stream ends; they never fail the build.
42
+ *
43
+ * Project-level Standard configuration (the `standard` field in package.json: ignore, env, globals, ...) is honored
44
+ * because the file's own path and cwd are handed to Standard.
45
+ * @memberOf module:partials
46
+ * @param {Object} [options={}]
47
+ * @param {boolean} [options.fix=true] - Apply Standard's automatic fixes to the file contents.
48
+ * @param {function(): Promise<{lintText: Function}>} [loadStandard] - Resolves the `standard` module. Real callers
49
+ * should never need to pass this - it exists so tests can supply a stand-in, since this project's
50
+ * CommonJS-transform-based Jest setup cannot execute a real dynamic import() of an ES module.
51
+ * @returns {import('stream').Transform}
52
+ */
53
+ const standardLint = ({
54
+ fix = true
55
+ } = {}, loadStandard = () => importStandard().then(({
56
+ default: standard
57
+ }) => standard)) => {
58
+ const totals = {
59
+ errors: 0,
60
+ warnings: 0
61
+ };
62
+ return _through.default.obj(function (file, enc, callback) {
63
+ if (file.isNull()) {
64
+ callback(null, file);
65
+ return;
66
+ }
67
+ if (file.isStream()) {
68
+ callback(new Error('standardLint: streaming file contents are not supported.'));
69
+ return;
70
+ }
71
+ loadStandard().then(standard => standard.lintText(file.contents.toString(), {
72
+ filename: file.path,
73
+ cwd: file.cwd,
74
+ fix
75
+ })).then(results => {
76
+ // No result at all means the file is ignored by the project's Standard configuration.
77
+ const [result] = results;
78
+ if (result) {
79
+ if (typeof result.output === 'string') {
80
+ file.contents = Buffer.from(result.output);
81
+ }
82
+ totals.errors += result.errorCount;
83
+ totals.warnings += result.warningCount;
84
+ printFileReport(file, result);
85
+ }
86
+ callback(null, file);
87
+ }, callback);
88
+ }, function (callback) {
89
+ console.log('Standard linter results');
90
+ console.log('======================================');
91
+ console.log(`✖ Errors total: ${totals.errors}`);
92
+ console.log(`⚠ Warnings total: ${totals.warnings}\n`);
93
+ callback();
94
+ });
95
+ };
96
+ exports.standardLint = standardLint;