js-build-tools 5.7.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.
- package/README.md +46 -3
- package/dist/build.js +40 -38
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +24 -23
- package/dist/bundle.min.js +1 -1
- package/dist/bundleMinify.js +14 -13
- package/dist/bundleMinify.min.js +1 -1
- package/dist/compileReadme.js +7 -7
- package/dist/copyFonts.js +14 -13
- package/dist/copyFonts.min.js +1 -1
- package/dist/default.js +16 -15
- package/dist/default.min.js +1 -1
- package/dist/dist.js +7 -7
- package/dist/distMinify.js +14 -13
- package/dist/distMinify.min.js +1 -1
- package/dist/images.js +7 -7
- package/dist/partials/addToReadme.js +3 -2
- package/dist/partials/beginWatcher.js +13 -12
- package/dist/partials/clean.js +15 -14
- package/dist/partials/distFor.js +22 -21
- package/dist/partials/distForSrc.js +12 -11
- package/dist/partials/distSeries.js +20 -19
- package/dist/partials/imagesFor.js +2 -1
- package/dist/partials/loadPeer.js +70 -70
- package/dist/partials/neostandardLint.js +163 -0
- package/dist/partials/readmeTemplate.js +15 -14
- package/dist/partials/runOnChange.js +29 -28
- package/dist/partials/sassFor.js +29 -28
- package/dist/partials/tsFor.js +2 -1
- package/dist/partials/typeDocsFor.js +2 -1
- package/dist/partials.js +136 -136
- package/dist/partials.min.js +1 -1
- package/dist/sass.js +7 -7
- package/dist/sourceLint.js +35 -0
- package/dist/sourceLint.min.js +1 -0
- package/dist/test-helpers/neostandardLintWithRealNeostandard.js +50 -0
- package/dist/test-helpers/setUp.js +2 -1
- package/dist/testFull.js +21 -20
- package/dist/testFull.min.js +1 -1
- package/dist/testHelpers.js +11 -10
- package/dist/testHelpers.min.js +1 -1
- package/dist/testQuick.js +23 -22
- package/dist/testQuick.min.js +1 -1
- package/dist/typeDocs.js +9 -9
- package/dist/typeScript.js +6 -6
- package/dist/utilities/convertMjsFilesForDocs.js +36 -36
- package/dist/utilities/dotNotate.js +48 -46
- package/dist/utilities/esmNamedExportsToCjs.js +18 -18
- package/dist/utilities/getBundleConfigs.js +3 -2
- package/dist/watchFull.js +7 -7
- package/dist/watchTest.js +17 -16
- package/dist/watchTest.min.js +1 -1
- package/functions/build.mjs +9 -8
- package/functions/build.test.mjs +18 -25
- package/functions/bundle.mjs +2 -2
- package/functions/partials/addToReadme.mjs +1 -1
- package/functions/partials/neostandardLint.mjs +130 -0
- package/functions/partials/neostandardLint.test.mjs +117 -0
- package/functions/partials.mjs +1 -1
- package/functions/sourceLint.mjs +24 -0
- package/functions/sourceLint.test.mjs +97 -0
- package/functions/test-helpers/neostandardLintWithRealNeostandard.mjs +40 -0
- package/functions/utilities/dotNotate.mjs +3 -1
- package/functions/utilities/dotNotate.test.mjs +34 -0
- package/functions/utilities/getBundleConfigs.mjs +1 -1
- package/gulp.config.mjs +14 -0
- package/gulpfile.base.js +2 -4
- package/gulpfile.base.mjs +1 -2
- package/package.json +7 -6
- package/dist/bundleLint.js +0 -28
- package/dist/bundleLint.min.js +0 -1
- package/dist/distLint.js +0 -20
- package/dist/distLint.min.js +0 -1
- package/dist/partials/standardLint.js +0 -94
- package/dist/test-helpers/standardLintWithRealStandard.js +0 -28
- package/functions/bundleLint.mjs +0 -18
- package/functions/bundleLint.test.mjs +0 -85
- package/functions/distLint.mjs +0 -12
- package/functions/distLint.test.mjs +0 -62
- package/functions/partials/standardLint.mjs +0 -78
- package/functions/partials/standardLint.test.mjs +0 -99
- package/functions/test-helpers/standardLintWithRealStandard.mjs +0 -21
package/dist/partials/clean.js
CHANGED
|
@@ -1,20 +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.clean = void 0;
|
|
8
|
-
require("core-js/modules/esnext.iterator.constructor.js");
|
|
9
|
-
require("core-js/modules/esnext.iterator.reduce.js");
|
|
10
|
-
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
11
|
-
var _removeDirectory = require("./removeDirectory.js");
|
|
12
|
-
|
|
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.clean = void 0;
|
|
8
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
9
|
+
require("core-js/modules/esnext.iterator.reduce.js");
|
|
10
|
+
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
11
|
+
var _removeDirectory = require("./removeDirectory.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; }
|
|
13
14
|
/**
|
|
14
15
|
* Deletes all the distribution and browser files (used before create a new build).
|
|
15
16
|
* Configure array of directories to remove with 'cleanPaths'.
|
|
16
17
|
* @memberOf module:partials
|
|
17
18
|
* @returns {Promise<string[]> | *}
|
|
18
|
-
*/
|
|
19
|
-
const clean = () => gulpConfig.get('cleanPaths').reduce((promise, path) => promise.then(() => (0, _removeDirectory.removeDirectory)(path)), Promise.resolve());
|
|
19
|
+
*/
|
|
20
|
+
const clean = () => gulpConfig.get('cleanPaths').reduce((promise, path) => promise.then(() => (0, _removeDirectory.removeDirectory)(path)), Promise.resolve());
|
|
20
21
|
exports.clean = clean;
|
package/dist/partials/distFor.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
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
|
-
|
|
14
|
-
function
|
|
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
|
+
var cache;
|
|
14
|
+
function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
16
|
/**
|
|
16
17
|
* Build the distribution for a given source pattern.
|
|
17
18
|
* @memberOf module:partials
|
|
18
19
|
* @param {string|array} [srcPath='src/config/path/dist/for']
|
|
19
20
|
* @param {string} [destPath='dist/config/path']
|
|
20
21
|
* @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));
|
|
22
|
+
*/
|
|
23
|
+
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) {
|
|
24
|
+
const regex = /\.mjs(['"]\s*\))/gi;
|
|
25
|
+
file.contents = Buffer.from(file.contents.toString().replaceAll(regex, '.js$1'));
|
|
26
|
+
this.push(file);
|
|
27
|
+
callback();
|
|
28
|
+
})).pipe((0, _gulp.dest)(destPath));
|
|
28
29
|
exports.distFor = distFor;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.distForSrc = void 0;
|
|
8
|
-
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
9
|
-
|
|
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
|
+
var cache;
|
|
10
|
+
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; }
|
|
10
11
|
/**
|
|
11
12
|
* Retrieve the correct distFor search path based on TS Config.
|
|
12
13
|
* @memberOf module:partials
|
|
13
14
|
* @param {module:gulpConfig~FlagStringSetting} [useTs='config/for/ts']
|
|
14
15
|
* @returns {string}
|
|
15
|
-
*/
|
|
16
|
-
const distForSrc = (useTs = gulpConfig.get('typescript.enabled')) => useTs ? gulpConfig.get('browser.from') : gulpConfig.get('dist.from');
|
|
16
|
+
*/
|
|
17
|
+
const distForSrc = (useTs = gulpConfig.get('typescript.enabled')) => useTs ? gulpConfig.get('browser.from') : gulpConfig.get('dist.from');
|
|
17
18
|
exports.distForSrc = distForSrc;
|
|
@@ -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.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
|
-
|
|
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
|
+
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
|
* When using TypeScript, ensure that we process the ts first then run babel (dist)
|
|
16
17
|
* @memberOf module:partials
|
|
@@ -18,10 +19,10 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
18
19
|
* @param {string} [distFinalPath='dist/config/path']
|
|
19
20
|
* @param {string} [tsSearch='ts/search/config/path']
|
|
20
21
|
* @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
|
-
};
|
|
22
|
+
*/
|
|
23
|
+
const distSeries = (srcPath = (0, _distForSrc.distForSrc)(), distFinalPath = gulpConfig.get('dist.to'), tsSearch = gulpConfig.get('typescript.from')) => {
|
|
24
|
+
const typescript = (0, _tsFor.tsFor)(tsSearch, distFinalPath);
|
|
25
|
+
const dist = () => (0, _distFor.distFor)(srcPath, distFinalPath);
|
|
26
|
+
return gulpConfig.get('typescript.enabled') ? (0, _gulp.series)(typescript, dist) : dist;
|
|
27
|
+
};
|
|
27
28
|
exports.distSeries = distSeries;
|
|
@@ -10,7 +10,8 @@ var _loadPeer = require("./loadPeer.js");
|
|
|
10
10
|
var _gulp = require("gulp");
|
|
11
11
|
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
12
12
|
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
13
|
-
|
|
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
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
16
|
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
|
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.requirePeer = exports.importPeer = exports.importModule = void 0;
|
|
7
|
-
require("core-js/modules/es.array.includes.js");
|
|
8
|
-
var _nodeModule = require("node:module");
|
|
9
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
-
var _nodeUrl = require("node:url");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
// Several dependencies ship ESM-only (standard, gulp-ts-compile, typedoc), but this package also publishes a CommonJS
|
|
13
|
-
// build (dist/*.js) whose babel transform would turn even a dynamic import() into a require() that cannot load an ES
|
|
14
|
-
// module. Hiding the import() inside a Function constructor keeps it a genuine dynamic import that works from either
|
|
15
|
-
// build, because babel cannot see (and so cannot rewrite) an import expression which only exists as a runtime string.
|
|
16
|
-
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.requirePeer = exports.importPeer = exports.importModule = void 0;
|
|
7
|
+
require("core-js/modules/es.array.includes.js");
|
|
8
|
+
var _nodeModule = require("node:module");
|
|
9
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
+
var _nodeUrl = require("node:url");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
// Several dependencies ship ESM-only (standard, gulp-ts-compile, typedoc), but this package also publishes a CommonJS
|
|
13
|
+
// build (dist/*.js) whose babel transform would turn even a dynamic import() into a require() that cannot load an ES
|
|
14
|
+
// module. Hiding the import() inside a Function constructor keeps it a genuine dynamic import that works from either
|
|
15
|
+
// build, because babel cannot see (and so cannot rewrite) an import expression which only exists as a runtime string.
|
|
16
|
+
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
17
|
+
|
|
18
18
|
/**
|
|
19
19
|
* Import an ES module (or any module) with a real dynamic import(), whichever build (ESM or CommonJS) this runs from.
|
|
20
20
|
* @memberOf module:partials
|
|
21
21
|
* @param {string} specifier - The package name, or the URL of a file.
|
|
22
22
|
* @returns {Promise<Object>} The module namespace.
|
|
23
|
-
*/
|
|
24
|
-
const importModule = specifier => dynamicImport(specifier);
|
|
25
|
-
exports.importModule = importModule;
|
|
26
|
-
const isMissing = (error, name) => error.code === 'MODULE_NOT_FOUND' && error.message.includes(`'${name}'`);
|
|
27
|
-
const notInstalled = (name, {
|
|
28
|
-
task,
|
|
29
|
-
installHint
|
|
30
|
-
}) => new Error(`The ${task} task needs the optional peer dependency ${name}, which is not installed. ${installHint}`);
|
|
31
|
-
|
|
23
|
+
*/
|
|
24
|
+
const importModule = specifier => dynamicImport(specifier);
|
|
25
|
+
exports.importModule = importModule;
|
|
26
|
+
const isMissing = (error, name) => error.code === 'MODULE_NOT_FOUND' && error.message.includes(`'${name}'`);
|
|
27
|
+
const notInstalled = (name, {
|
|
28
|
+
task,
|
|
29
|
+
installHint
|
|
30
|
+
}) => new Error(`The ${task} task needs the optional peer dependency ${name}, which is not installed. ${installHint}`);
|
|
31
|
+
|
|
32
32
|
/**
|
|
33
33
|
* Load an optional peer dependency (one which is only needed once a task runs, so projects which never use that task
|
|
34
34
|
* do not have to install it) with require(), from the project being built rather than from this package. When it is
|
|
@@ -42,29 +42,29 @@ const notInstalled = (name, {
|
|
|
42
42
|
* @param {string} [options.projectPath=process.cwd()] - The folder of the project (which has the package.json) being built.
|
|
43
43
|
* @returns {*} Whatever the package exports.
|
|
44
44
|
* @throws {Error} With install instructions when the package is not installed.
|
|
45
|
-
*/
|
|
46
|
-
const requirePeer = (name, {
|
|
47
|
-
task,
|
|
48
|
-
installHint,
|
|
49
|
-
esmOnlyMessage,
|
|
50
|
-
projectPath = process.cwd()
|
|
51
|
-
}) => {
|
|
52
|
-
try {
|
|
53
|
-
return (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json'))(name);
|
|
54
|
-
} catch (error) {
|
|
55
|
-
if (isMissing(error, name)) {
|
|
56
|
-
throw notInstalled(name, {
|
|
57
|
-
task,
|
|
58
|
-
installHint
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
if (error.code === 'ERR_REQUIRE_ESM' && esmOnlyMessage) {
|
|
62
|
-
throw new Error(esmOnlyMessage);
|
|
63
|
-
}
|
|
64
|
-
throw error;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
45
|
+
*/
|
|
46
|
+
const requirePeer = (name, {
|
|
47
|
+
task,
|
|
48
|
+
installHint,
|
|
49
|
+
esmOnlyMessage,
|
|
50
|
+
projectPath = process.cwd()
|
|
51
|
+
}) => {
|
|
52
|
+
try {
|
|
53
|
+
return (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json'))(name);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (isMissing(error, name)) {
|
|
56
|
+
throw notInstalled(name, {
|
|
57
|
+
task,
|
|
58
|
+
installHint
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (error.code === 'ERR_REQUIRE_ESM' && esmOnlyMessage) {
|
|
62
|
+
throw new Error(esmOnlyMessage);
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
68
|
/**
|
|
69
69
|
* Import an optional peer dependency which ships ESM-only, from the project being built. See {@link requirePeer}.
|
|
70
70
|
* @memberOf module:partials
|
|
@@ -75,25 +75,25 @@ const requirePeer = (name, {
|
|
|
75
75
|
* @param {string} [options.projectPath=process.cwd()] - The folder of the project (which has the package.json) being built.
|
|
76
76
|
* @returns {Promise<Object>} The module namespace.
|
|
77
77
|
* @throws {Error} With install instructions when the package is not installed.
|
|
78
|
-
*/
|
|
79
|
-
exports.requirePeer = requirePeer;
|
|
80
|
-
const importPeer = async (name, {
|
|
81
|
-
task,
|
|
82
|
-
installHint,
|
|
83
|
-
projectPath = process.cwd()
|
|
84
|
-
}) => {
|
|
85
|
-
let resolved;
|
|
86
|
-
try {
|
|
87
|
-
resolved = (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json')).resolve(name);
|
|
88
|
-
} catch (error) {
|
|
89
|
-
if (isMissing(error, name)) {
|
|
90
|
-
throw notInstalled(name, {
|
|
91
|
-
task,
|
|
92
|
-
installHint
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
return importModule((0, _nodeUrl.pathToFileURL)(resolved).href);
|
|
98
|
-
};
|
|
78
|
+
*/
|
|
79
|
+
exports.requirePeer = requirePeer;
|
|
80
|
+
const importPeer = async (name, {
|
|
81
|
+
task,
|
|
82
|
+
installHint,
|
|
83
|
+
projectPath = process.cwd()
|
|
84
|
+
}) => {
|
|
85
|
+
let resolved;
|
|
86
|
+
try {
|
|
87
|
+
resolved = (0, _nodeModule.createRequire)(_nodePath.default.join(projectPath, 'package.json')).resolve(name);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (isMissing(error, name)) {
|
|
90
|
+
throw notInstalled(name, {
|
|
91
|
+
task,
|
|
92
|
+
installHint
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
return importModule((0, _nodeUrl.pathToFileURL)(resolved).href);
|
|
98
|
+
};
|
|
99
99
|
exports.importPeer = importPeer;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.neostandardLint = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
9
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
10
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
11
|
+
var _through = _interopRequireDefault(require("through2"));
|
|
12
|
+
var _eslint = require("eslint");
|
|
13
|
+
var _loadPeer = require("./loadPeer.js");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
// neostandard (js-build-tools' chosen style - a maintained, TypeScript-aware successor to `standard`, see
|
|
16
|
+
// https://github.com/neostandard/neostandard) ships ESM-only, see importModule for how it is imported.
|
|
17
|
+
const importNeostandard = () => (0, _loadPeer.importModule)('neostandard');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Read the `env` a project already declared for Standard (the `standard` field in its package.json), so a project
|
|
21
|
+
* migrating from `standard` keeps its globals (jest, browser, ...) without touching package.json.
|
|
22
|
+
* @param {string} cwd
|
|
23
|
+
* @returns {Array<string>}
|
|
24
|
+
*/
|
|
25
|
+
const readEnv = cwd => {
|
|
26
|
+
try {
|
|
27
|
+
return JSON.parse(_nodeFs.default.readFileSync(_nodePath.default.join(cwd, 'package.json'), 'utf8')).standard?.env ?? [];
|
|
28
|
+
} catch {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Build an ESLint instance configured with neostandard, honoring the project's own package.json `standard.env`,
|
|
35
|
+
* plus an optional layer of rule overrides (see gulp.config.mjs's `lint.rules`) for a rule that is wrong for this
|
|
36
|
+
* project specifically rather than something to fix in its code - for example a test fixture whose content
|
|
37
|
+
* neostandard mistakes for a real syntax problem. Scoped to the same files neostandard itself lints (its own
|
|
38
|
+
* `defaultFilePatterns.all`), per neostandard's own guidance: an unscoped rule-tweak layer would otherwise apply
|
|
39
|
+
* to every lintable file, including ones from an unrelated plugin this project never defined.
|
|
40
|
+
* @param {Object} options
|
|
41
|
+
* @param {string} options.cwd
|
|
42
|
+
* @param {boolean} options.ts
|
|
43
|
+
* @param {boolean} options.fix
|
|
44
|
+
* @param {Object<string, *>} [options.rules={}]
|
|
45
|
+
* @returns {Promise<import('eslint').ESLint>}
|
|
46
|
+
*/
|
|
47
|
+
const buildEslint = async ({
|
|
48
|
+
cwd,
|
|
49
|
+
ts,
|
|
50
|
+
fix,
|
|
51
|
+
rules = {}
|
|
52
|
+
}) => {
|
|
53
|
+
const {
|
|
54
|
+
neostandard,
|
|
55
|
+
defaultFilePatterns
|
|
56
|
+
} = await importNeostandard();
|
|
57
|
+
const baseConfig = neostandard({
|
|
58
|
+
ts,
|
|
59
|
+
env: readEnv(cwd)
|
|
60
|
+
});
|
|
61
|
+
if (Object.keys(rules).length) {
|
|
62
|
+
baseConfig.push({
|
|
63
|
+
files: defaultFilePatterns.all,
|
|
64
|
+
rules
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return new _eslint.ESLint({
|
|
68
|
+
cwd,
|
|
69
|
+
fix,
|
|
70
|
+
overrideConfigFile: true,
|
|
71
|
+
baseConfig
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Print a file's lint messages, if it has any.
|
|
77
|
+
* @memberOf module:partials
|
|
78
|
+
* @param {import('vinyl')} file
|
|
79
|
+
* @param {{messages: Array<{line: number, column: number, message: string}>, errorCount: number, warningCount: number}} result
|
|
80
|
+
* @returns {undefined}
|
|
81
|
+
*/
|
|
82
|
+
const printFileReport = (file, result) => {
|
|
83
|
+
if (!result.messages.length) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
console.log(_nodePath.default.relative(file.cwd, file.path));
|
|
87
|
+
result.messages.forEach(({
|
|
88
|
+
line,
|
|
89
|
+
column,
|
|
90
|
+
message
|
|
91
|
+
}) => console.log(`line ${line}:${column}\t${message}`));
|
|
92
|
+
console.log(`✖ ${result.errorCount} error\t⚠ ${result.warningCount} warning\n`);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Lint every file streaming through with neostandard and, unless `fix` is false, apply the automatic fixes to the
|
|
97
|
+
* file's contents so a following `dest()` writes the fixed version. Remaining problems are printed along with a
|
|
98
|
+
* summary once the stream ends; they never fail the build.
|
|
99
|
+
*
|
|
100
|
+
* One ESLint instance is built from the first file's own cwd and reused for the rest of the stream, since every
|
|
101
|
+
* file in a given lint pass shares the same project (and so the same config).
|
|
102
|
+
* @memberOf module:partials
|
|
103
|
+
* @param {Object} [options={}]
|
|
104
|
+
* @param {boolean} [options.fix=true] - Apply neostandard's automatic fixes to the file contents.
|
|
105
|
+
* @param {boolean} [options.ts=false] - Lint `.ts` files too, with type-aware rules (see neostandard's `ts` option).
|
|
106
|
+
* @param {Object<string, *>} [options.rules={}] - ESLint rule overrides layered on top of neostandard's own rules
|
|
107
|
+
* (see gulp.config.mjs's `lint.rules`).
|
|
108
|
+
* @param {function(Object): Promise<{lintText: Function}>} [loadEslint] - Resolves an ESLint-shaped linter. Real
|
|
109
|
+
* callers should never need to pass this - it exists so tests can supply a stand-in, since this project's
|
|
110
|
+
* CommonJS-transform-based Jest setup cannot execute a real dynamic import() of neostandard (ESM-only).
|
|
111
|
+
* @returns {import('stream').Transform}
|
|
112
|
+
*/
|
|
113
|
+
const neostandardLint = ({
|
|
114
|
+
fix = true,
|
|
115
|
+
ts = false,
|
|
116
|
+
rules = {}
|
|
117
|
+
} = {}, loadEslint = buildEslint) => {
|
|
118
|
+
const totals = {
|
|
119
|
+
errors: 0,
|
|
120
|
+
warnings: 0
|
|
121
|
+
};
|
|
122
|
+
let eslintPromise = null;
|
|
123
|
+
return _through.default.obj(function (file, enc, callback) {
|
|
124
|
+
if (file.isNull()) {
|
|
125
|
+
callback(null, file);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (file.isStream()) {
|
|
129
|
+
callback(new Error('neostandardLint: streaming file contents are not supported.'));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (!eslintPromise) {
|
|
133
|
+
eslintPromise = loadEslint({
|
|
134
|
+
cwd: file.cwd,
|
|
135
|
+
ts,
|
|
136
|
+
fix,
|
|
137
|
+
rules
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
eslintPromise.then(eslint => eslint.lintText(file.contents.toString(), {
|
|
141
|
+
filePath: file.path
|
|
142
|
+
})).then(results => {
|
|
143
|
+
// No result at all means the file is ignored by the project's ESLint configuration.
|
|
144
|
+
const [result] = results;
|
|
145
|
+
if (result) {
|
|
146
|
+
if (typeof result.output === 'string') {
|
|
147
|
+
file.contents = Buffer.from(result.output);
|
|
148
|
+
}
|
|
149
|
+
totals.errors += result.errorCount;
|
|
150
|
+
totals.warnings += result.warningCount;
|
|
151
|
+
printFileReport(file, result);
|
|
152
|
+
}
|
|
153
|
+
callback(null, file);
|
|
154
|
+
}, callback);
|
|
155
|
+
}, function (callback) {
|
|
156
|
+
console.log('neostandard linter results');
|
|
157
|
+
console.log('======================================');
|
|
158
|
+
console.log(`✖ Errors total: ${totals.errors}`);
|
|
159
|
+
console.log(`⚠ Warnings total: ${totals.warnings}\n`);
|
|
160
|
+
callback();
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
exports.neostandardLint = neostandardLint;
|
|
@@ -1,19 +1,20 @@
|
|
|
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
|
-
|
|
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
|
+
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; }
|
|
13
14
|
/**
|
|
14
15
|
* Copy a readme template into the README.md file.
|
|
15
16
|
* @memberOf module:partials
|
|
16
17
|
* @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')));
|
|
18
|
+
*/
|
|
19
|
+
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
20
|
exports.readmeTemplate = readmeTemplate;
|
|
@@ -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
|
-
|
|
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;
|