js-build-tools 5.0.0 → 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.
- package/babel.config.js +18 -1
- package/dist/partials/addToReadme.js +17 -17
- package/dist/partials/beginWatcher.js +12 -12
- package/dist/partials/clean.js +14 -14
- package/dist/partials/distFor.js +21 -21
- package/dist/partials/distForSrc.js +11 -11
- package/dist/partials/distSeries.js +19 -19
- package/dist/partials/minifyFor.js +16 -16
- package/dist/partials/readmeTemplate.js +14 -14
- package/dist/partials/runOnChange.js +28 -28
- package/dist/partials/sassFor.js +28 -28
- package/dist/partials/tsFor.js +67 -67
- package/dist/test-helpers/setUp.js +89 -89
- package/dist/utilities/dotGet.js +46 -46
- package/dist/utilities/dotNotate.js +46 -46
- package/dist/utilities/dotSet.js +37 -37
- package/dist/utilities/isObject.js +8 -8
- package/dist/utilities/strAfter.js +11 -11
- package/dist/utilities/strBefore.js +11 -11
- package/package.json +1 -1
package/babel.config.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
// Explicit targets so the compiled output does not change as browserslist / caniuse-lite data moves (the same query
|
|
2
|
+
// resolved to different browsers on different installs). These are the versions that .browserslistrc
|
|
3
|
+
// ("last 2 versions, > 0.25%, not dead") resolved to when they were pinned (2026-09); raise them deliberately.
|
|
4
|
+
// .browserslistrc is still used by autoprefixer in the sass task.
|
|
5
|
+
const targets = {
|
|
6
|
+
android: '150',
|
|
7
|
+
chrome: '109',
|
|
8
|
+
edge: '149',
|
|
9
|
+
firefox: '121',
|
|
10
|
+
ios: '16.6',
|
|
11
|
+
opera: '127',
|
|
12
|
+
opera_mobile: '80',
|
|
13
|
+
safari: '18.5',
|
|
14
|
+
samsung: '29'
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
module.exports = {
|
|
2
18
|
plugins: [
|
|
3
19
|
'@babel/plugin-transform-modules-commonjs'
|
|
@@ -5,7 +21,8 @@ module.exports = {
|
|
|
5
21
|
presets: [
|
|
6
22
|
['@babel/preset-env', {
|
|
7
23
|
useBuiltIns: 'usage',
|
|
8
|
-
corejs: { version: '3.6', proposals: true }
|
|
24
|
+
corejs: { version: '3.6', proposals: true },
|
|
25
|
+
targets
|
|
9
26
|
}]
|
|
10
27
|
]
|
|
11
28
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
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.addToReadme = void 0;
|
|
8
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
-
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
10
|
-
var _jsdocToMarkdown = _interopRequireDefault(require("jsdoc-to-markdown"));
|
|
11
|
-
var _glob = require("glob");
|
|
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.addToReadme = void 0;
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
10
|
+
var _jsdocToMarkdown = _interopRequireDefault(require("jsdoc-to-markdown"));
|
|
11
|
+
var _glob = require("glob");
|
|
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
14
|
/**
|
|
15
15
|
* Appends all the jsdoc comments to the readme file. Assumes empty or templated file.
|
|
16
16
|
* Configure this with 'readmeSearch', 'readmePath', 'readmeFile', and 'readmeOptions'.
|
|
17
17
|
* @memberOf module:partials
|
|
18
18
|
* @returns {string|Uint8Array}
|
|
19
|
-
*/
|
|
20
|
-
const addToReadme = () => _jsdocToMarkdown.default.render({
|
|
21
|
-
files: (0, _glob.globSync)(gulpConfig.get('readme.from'))
|
|
22
|
-
}).then(readme => _fs.default.appendFileSync(gulpConfig.get('readme.to') + gulpConfig.get('readme.file'), readme, gulpConfig.get('readmeOptions')));
|
|
19
|
+
*/
|
|
20
|
+
const addToReadme = () => _jsdocToMarkdown.default.render({
|
|
21
|
+
files: (0, _glob.globSync)(gulpConfig.get('readme.from'))
|
|
22
|
+
}).then(readme => _fs.default.appendFileSync(gulpConfig.get('readme.to') + gulpConfig.get('readme.file'), readme, gulpConfig.get('readmeOptions')));
|
|
23
23
|
exports.addToReadme = addToReadme;
|
|
@@ -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.beginWatcher = void 0;
|
|
8
|
-
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
9
|
-
var _gulp = require("gulp");
|
|
10
|
-
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.beginWatcher = void 0;
|
|
8
|
+
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
9
|
+
var _gulp = require("gulp");
|
|
10
|
+
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); }
|
|
11
11
|
/**
|
|
12
12
|
* Create a chokidar instance which watches and triggers change when the globed files are modified.
|
|
13
13
|
* @memberOf module:partials
|
|
14
14
|
* @returns {FSWatcher}
|
|
15
|
-
*/
|
|
16
|
-
const beginWatcher = () => (0, _gulp.watch)(gulpConfig.get('test.watch'));
|
|
15
|
+
*/
|
|
16
|
+
const beginWatcher = () => (0, _gulp.watch)(gulpConfig.get('test.watch'));
|
|
17
17
|
exports.beginWatcher = beginWatcher;
|
package/dist/partials/clean.js
CHANGED
|
@@ -1,20 +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.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
|
-
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.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
|
+
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
|
* Deletes all the distribution and browser files (used before create a new build).
|
|
15
15
|
* Configure array of directories to remove with 'cleanPaths'.
|
|
16
16
|
* @memberOf module:partials
|
|
17
17
|
* @returns {Promise<string[]> | *}
|
|
18
|
-
*/
|
|
19
|
-
const clean = () => gulpConfig.get('cleanPaths').reduce((promise, path) => promise.then(() => (0, _removeDirectory.removeDirectory)(path)), Promise.resolve());
|
|
18
|
+
*/
|
|
19
|
+
const clean = () => gulpConfig.get('cleanPaths').reduce((promise, path) => promise.then(() => (0, _removeDirectory.removeDirectory)(path)), Promise.resolve());
|
|
20
20
|
exports.clean = clean;
|
package/dist/partials/distFor.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.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,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,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;
|
package/dist/partials/sassFor.js
CHANGED
|
@@ -1,35 +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 _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
|
+
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
|
+
|
|
20
20
|
/**
|
|
21
21
|
* Build the CSS for a given source pattern.
|
|
22
22
|
* @memberOf module:partials
|
|
23
23
|
* @param {string|array} [srcSearch='src/config/path/sass/for']
|
|
24
24
|
* @param {string} [cssPath='css/config/path']
|
|
25
25
|
* @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));
|
|
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));
|
|
35
35
|
exports.sassFor = sassFor;
|
package/dist/partials/tsFor.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
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 = void 0;
|
|
8
|
-
var _gulp = require("gulp");
|
|
9
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
-
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
11
|
-
var _typescript = _interopRequireDefault(require("typescript"));
|
|
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) since it's meant to be consumed by
|
|
15
|
-
// gulpfiles running under a real ESM loader, same as this project's own gulpfile.mjs does. This project also
|
|
16
|
-
// compiles itself to a CommonJS build (dist/*.js, this file's own compiled counterpart) for consumers using
|
|
17
|
-
// require() though, and even a dynamic `import()` gets downleveled by babel's CommonJS transform into a
|
|
18
|
-
// require() call - which can't load a real ES module. Hiding the import() call inside a Function constructor is
|
|
19
|
-
// the standard escape hatch: babel can't see (and so can't rewrite) an import expression that only exists as a
|
|
20
|
-
// runtime-evaluated string, so it survives as a genuine dynamic import, capable of loading gulp-ts-compile from
|
|
21
|
-
// either build.
|
|
22
|
-
const importGulpTsCompile = new Function('return import(\'gulp-ts-compile\')');
|
|
23
|
-
|
|
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 = void 0;
|
|
8
|
+
var _gulp = require("gulp");
|
|
9
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
+
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
11
|
+
var _typescript = _interopRequireDefault(require("typescript"));
|
|
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) since it's meant to be consumed by
|
|
15
|
+
// gulpfiles running under a real ESM loader, same as this project's own gulpfile.mjs does. This project also
|
|
16
|
+
// compiles itself to a CommonJS build (dist/*.js, this file's own compiled counterpart) for consumers using
|
|
17
|
+
// require() though, and even a dynamic `import()` gets downleveled by babel's CommonJS transform into a
|
|
18
|
+
// require() call - which can't load a real ES module. Hiding the import() call inside a Function constructor is
|
|
19
|
+
// the standard escape hatch: babel can't see (and so can't rewrite) an import expression that only exists as a
|
|
20
|
+
// runtime-evaluated string, so it survives as a genuine dynamic import, capable of loading gulp-ts-compile from
|
|
21
|
+
// either build.
|
|
22
|
+
const importGulpTsCompile = new Function('return import(\'gulp-ts-compile\')');
|
|
23
|
+
|
|
24
24
|
/**
|
|
25
25
|
* Wrap a stream in a promise that resolves once it finishes writing.
|
|
26
26
|
* @memberOf module:partials
|
|
27
27
|
* @param {import('node:stream').Stream} stream
|
|
28
28
|
* @returns {Promise<void>}
|
|
29
|
-
*/
|
|
30
|
-
const streamToPromise = stream => new Promise((resolve, reject) => {
|
|
31
|
-
stream.on('finish', resolve);
|
|
32
|
-
stream.on('error', reject);
|
|
33
|
-
});
|
|
34
|
-
|
|
29
|
+
*/
|
|
30
|
+
const streamToPromise = stream => new Promise((resolve, reject) => {
|
|
31
|
+
stream.on('finish', resolve);
|
|
32
|
+
stream.on('error', reject);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
35
|
/**
|
|
36
36
|
* Read a tsconfig.json file into real typescript.CompilerOptions values, using only TypeScript's stable, current,
|
|
37
37
|
* public config-reading API (the same one `tsc --project` itself uses internally) - never
|
|
@@ -40,13 +40,13 @@ const streamToPromise = stream => new Promise((resolve, reject) => {
|
|
|
40
40
|
* @memberOf module:partials
|
|
41
41
|
* @param {string} configPath - Path to a tsconfig.json file.
|
|
42
42
|
* @returns {import('typescript').CompilerOptions}
|
|
43
|
-
*/
|
|
44
|
-
const readCompilerOptions = configPath => {
|
|
45
|
-
const configFile = _typescript.default.readConfigFile(configPath, _typescript.default.sys.readFile);
|
|
46
|
-
const parsedConfig = _typescript.default.parseJsonConfigFileContent(configFile.config, _typescript.default.sys, _nodePath.default.dirname(configPath));
|
|
47
|
-
return parsedConfig.options;
|
|
48
|
-
};
|
|
49
|
-
|
|
43
|
+
*/
|
|
44
|
+
const readCompilerOptions = configPath => {
|
|
45
|
+
const configFile = _typescript.default.readConfigFile(configPath, _typescript.default.sys.readFile);
|
|
46
|
+
const parsedConfig = _typescript.default.parseJsonConfigFileContent(configFile.config, _typescript.default.sys, _nodePath.default.dirname(configPath));
|
|
47
|
+
return parsedConfig.options;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
50
|
/**
|
|
51
51
|
* Starting at the source directory, find all the ts files and convert them into the distribution directory.
|
|
52
52
|
* @memberOf module:partials
|
|
@@ -59,35 +59,35 @@ const readCompilerOptions = configPath => {
|
|
|
59
59
|
* suite already covers real TypeScript-compile correctness - this function's own tests only need to verify its
|
|
60
60
|
* config resolution and stream wiring.
|
|
61
61
|
* @returns {Function}
|
|
62
|
-
*/
|
|
63
|
-
const tsFor = (srcPath = gulpConfig.get('typescript.from'), distPath = gulpConfig.get('typescript.to'), loadTsCompile = () => importGulpTsCompile().then(({
|
|
64
|
-
default: tsCompile
|
|
65
|
-
}) => tsCompile)) => {
|
|
66
|
-
if (gulpConfig.get('typescript.enabled') === false) {
|
|
67
|
-
return () => {};
|
|
68
|
-
}
|
|
69
|
-
const configPath = gulpConfig.get('typescript.config');
|
|
70
|
-
// When no tsconfig.json is configured, target/module are pinned explicitly rather than left for TypeScript's
|
|
71
|
-
// own compiler defaults - those defaults have already shifted once across a TypeScript version bump in this
|
|
72
|
-
// project's own history (silently changing whether output keeps `const`/`let` or downlevels to `var`), and
|
|
73
|
-
// pinning them keeps this task's output stable across future TypeScript upgrades too. ES5/CommonJS matches
|
|
74
|
-
// what the downstream babel/browserify bundling pipeline has always assumed it receives.
|
|
75
|
-
const compilerOptions = configPath ? readCompilerOptions(configPath) : {
|
|
76
|
-
declaration: true,
|
|
77
|
-
target: _typescript.default.ScriptTarget.ES5,
|
|
78
|
-
module: _typescript.default.ModuleKind.CommonJS,
|
|
79
|
-
esModuleInterop: false
|
|
80
|
-
};
|
|
81
|
-
// Accepts gulp's own callback-style task convention (an optional `done`, called once finished) rather than
|
|
82
|
-
// just returning a Promise, since callers may invoke the returned function directly with a callback instead
|
|
83
|
-
// of relying on gulp's own runner to observe a returned Promise.
|
|
84
|
-
return done => {
|
|
85
|
-
const compile = async () => {
|
|
86
|
-
const tsCompile = await loadTsCompile();
|
|
87
|
-
const tsResult = (0, _gulp.src)(srcPath).pipe(tsCompile(compilerOptions));
|
|
88
|
-
await Promise.all([streamToPromise(tsResult.dts.pipe((0, _gulp.dest)(distPath))), streamToPromise(tsResult.js.pipe((0, _gulp.dest)(distPath)))]);
|
|
89
|
-
};
|
|
90
|
-
return typeof done === 'function' ? compile().then(() => done(), done) : compile();
|
|
91
|
-
};
|
|
92
|
-
};
|
|
62
|
+
*/
|
|
63
|
+
const tsFor = (srcPath = gulpConfig.get('typescript.from'), distPath = gulpConfig.get('typescript.to'), loadTsCompile = () => importGulpTsCompile().then(({
|
|
64
|
+
default: tsCompile
|
|
65
|
+
}) => tsCompile)) => {
|
|
66
|
+
if (gulpConfig.get('typescript.enabled') === false) {
|
|
67
|
+
return () => {};
|
|
68
|
+
}
|
|
69
|
+
const configPath = gulpConfig.get('typescript.config');
|
|
70
|
+
// When no tsconfig.json is configured, target/module are pinned explicitly rather than left for TypeScript's
|
|
71
|
+
// own compiler defaults - those defaults have already shifted once across a TypeScript version bump in this
|
|
72
|
+
// project's own history (silently changing whether output keeps `const`/`let` or downlevels to `var`), and
|
|
73
|
+
// pinning them keeps this task's output stable across future TypeScript upgrades too. ES5/CommonJS matches
|
|
74
|
+
// what the downstream babel/browserify bundling pipeline has always assumed it receives.
|
|
75
|
+
const compilerOptions = configPath ? readCompilerOptions(configPath) : {
|
|
76
|
+
declaration: true,
|
|
77
|
+
target: _typescript.default.ScriptTarget.ES5,
|
|
78
|
+
module: _typescript.default.ModuleKind.CommonJS,
|
|
79
|
+
esModuleInterop: false
|
|
80
|
+
};
|
|
81
|
+
// Accepts gulp's own callback-style task convention (an optional `done`, called once finished) rather than
|
|
82
|
+
// just returning a Promise, since callers may invoke the returned function directly with a callback instead
|
|
83
|
+
// of relying on gulp's own runner to observe a returned Promise.
|
|
84
|
+
return done => {
|
|
85
|
+
const compile = async () => {
|
|
86
|
+
const tsCompile = await loadTsCompile();
|
|
87
|
+
const tsResult = (0, _gulp.src)(srcPath).pipe(tsCompile(compilerOptions));
|
|
88
|
+
await Promise.all([streamToPromise(tsResult.dts.pipe((0, _gulp.dest)(distPath))), streamToPromise(tsResult.js.pipe((0, _gulp.dest)(distPath)))]);
|
|
89
|
+
};
|
|
90
|
+
return typeof done === 'function' ? compile().then(() => done(), done) : compile();
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
93
|
exports.tsFor = tsFor;
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(exports, "afterEach", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _testFilesystem.afterEach;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "beforeEach", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _testFilesystem.beforeEach;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "countMatches", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _testFilesystem.countMatches;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, "createTempDir", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _testFilesystem.createTempDir;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports, "fileExists", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () {
|
|
34
|
-
return _testFilesystem.fileExists;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
exports.gulpConfig = void 0;
|
|
38
|
-
Object.defineProperty(exports, "logObject", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return _testFilesystem.logObject;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
Object.defineProperty(exports, "removeDirectory", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
get: function () {
|
|
47
|
-
return _testFilesystem.removeDirectory;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
exports.setDefaults = void 0;
|
|
51
|
-
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
52
|
-
exports.gulpConfig = gulpConfig;
|
|
53
|
-
var _testFilesystem = require("test-filesystem");
|
|
54
|
-
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); }
|
|
55
|
-
// Import the configurations and override some of them to direct to the temp directory.
|
|
56
|
-
|
|
57
|
-
let tempDir = 'test-temp/';
|
|
58
|
-
let srcPath = `${tempDir}src`;
|
|
59
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/esnext.weak-map.delete-all.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "afterEach", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _testFilesystem.afterEach;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "beforeEach", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _testFilesystem.beforeEach;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "countMatches", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _testFilesystem.countMatches;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "createTempDir", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _testFilesystem.createTempDir;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "fileExists", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return _testFilesystem.fileExists;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
exports.gulpConfig = void 0;
|
|
38
|
+
Object.defineProperty(exports, "logObject", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _testFilesystem.logObject;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "removeDirectory", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return _testFilesystem.removeDirectory;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
exports.setDefaults = void 0;
|
|
51
|
+
var gulpConfig = _interopRequireWildcard(require("../../gulp.config.js"));
|
|
52
|
+
exports.gulpConfig = gulpConfig;
|
|
53
|
+
var _testFilesystem = require("test-filesystem");
|
|
54
|
+
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); }
|
|
55
|
+
// Import the configurations and override some of them to direct to the temp directory.
|
|
56
|
+
|
|
57
|
+
let tempDir = 'test-temp/';
|
|
58
|
+
let srcPath = `${tempDir}src`;
|
|
59
|
+
|
|
60
60
|
/**
|
|
61
61
|
* Update the gulp configurations with the test data. Set the test directory where temp files will be created for testing.
|
|
62
62
|
* @memberOf module:testHelpers
|
|
63
63
|
* @param {string} testDir
|
|
64
|
-
*/
|
|
65
|
-
const setDefaults = (testDir = 'test-temp') => {
|
|
66
|
-
tempDir = `${testDir}/`;
|
|
67
|
-
srcPath = `${tempDir}src`;
|
|
68
|
-
_testFilesystem.setUp.setDefaults(tempDir);
|
|
69
|
-
const distPath = `${tempDir}dist`;
|
|
70
|
-
const browserPath = `${tempDir}browser`;
|
|
71
|
-
const sassPath = `${tempDir}sass`;
|
|
72
|
-
gulpConfig.set('browser.from', `${distPath}/**/*.js`);
|
|
73
|
-
gulpConfig.set('browser.to', browserPath);
|
|
74
|
-
gulpConfig.set('cleanPaths', [distPath, browserPath]);
|
|
75
|
-
gulpConfig.set('dist.from', `${srcPath}/**/!(*.test).js`);
|
|
76
|
-
gulpConfig.set('dist.main', `${distPath}/main`);
|
|
77
|
-
gulpConfig.set('dist.to', distPath);
|
|
78
|
-
gulpConfig.set('fonts.from', `${srcPath}/fonts/**/*`);
|
|
79
|
-
gulpConfig.set('fonts.to', `${browserPath}/fonts`);
|
|
80
|
-
gulpConfig.set('images.from', `${srcPath}/img/**/*.+(png|jpg|jpeg|gif|svg)`);
|
|
81
|
-
gulpConfig.set('images.to', `${browserPath}/img`);
|
|
82
|
-
gulpConfig.set('readme.template', `${tempDir}MAIN.md`);
|
|
83
|
-
gulpConfig.set('readme.to', tempDir);
|
|
84
|
-
gulpConfig.set('readme.from', `${srcPath}/**/!(*.test).js`);
|
|
85
|
-
gulpConfig.set('rootPath', tempDir);
|
|
86
|
-
gulpConfig.set('sass.from', `${sassPath}/**/*.+(scss|sass)`);
|
|
87
|
-
gulpConfig.set('sass.path', sassPath);
|
|
88
|
-
gulpConfig.set('sass.to', `${browserPath}/css`);
|
|
89
|
-
gulpConfig.set('srcPath', srcPath);
|
|
90
|
-
gulpConfig.set('typescript.from', `${srcPath}/**/*.ts`);
|
|
91
|
-
gulpConfig.set('typescript.to', distPath);
|
|
92
|
-
gulpConfig.set('test.watch', `${srcPath}/**/*.js`);
|
|
93
|
-
};
|
|
64
|
+
*/
|
|
65
|
+
const setDefaults = (testDir = 'test-temp') => {
|
|
66
|
+
tempDir = `${testDir}/`;
|
|
67
|
+
srcPath = `${tempDir}src`;
|
|
68
|
+
_testFilesystem.setUp.setDefaults(tempDir);
|
|
69
|
+
const distPath = `${tempDir}dist`;
|
|
70
|
+
const browserPath = `${tempDir}browser`;
|
|
71
|
+
const sassPath = `${tempDir}sass`;
|
|
72
|
+
gulpConfig.set('browser.from', `${distPath}/**/*.js`);
|
|
73
|
+
gulpConfig.set('browser.to', browserPath);
|
|
74
|
+
gulpConfig.set('cleanPaths', [distPath, browserPath]);
|
|
75
|
+
gulpConfig.set('dist.from', `${srcPath}/**/!(*.test).js`);
|
|
76
|
+
gulpConfig.set('dist.main', `${distPath}/main`);
|
|
77
|
+
gulpConfig.set('dist.to', distPath);
|
|
78
|
+
gulpConfig.set('fonts.from', `${srcPath}/fonts/**/*`);
|
|
79
|
+
gulpConfig.set('fonts.to', `${browserPath}/fonts`);
|
|
80
|
+
gulpConfig.set('images.from', `${srcPath}/img/**/*.+(png|jpg|jpeg|gif|svg)`);
|
|
81
|
+
gulpConfig.set('images.to', `${browserPath}/img`);
|
|
82
|
+
gulpConfig.set('readme.template', `${tempDir}MAIN.md`);
|
|
83
|
+
gulpConfig.set('readme.to', tempDir);
|
|
84
|
+
gulpConfig.set('readme.from', `${srcPath}/**/!(*.test).js`);
|
|
85
|
+
gulpConfig.set('rootPath', tempDir);
|
|
86
|
+
gulpConfig.set('sass.from', `${sassPath}/**/*.+(scss|sass)`);
|
|
87
|
+
gulpConfig.set('sass.path', sassPath);
|
|
88
|
+
gulpConfig.set('sass.to', `${browserPath}/css`);
|
|
89
|
+
gulpConfig.set('srcPath', srcPath);
|
|
90
|
+
gulpConfig.set('typescript.from', `${srcPath}/**/*.ts`);
|
|
91
|
+
gulpConfig.set('typescript.to', distPath);
|
|
92
|
+
gulpConfig.set('test.watch', `${srcPath}/**/*.js`);
|
|
93
|
+
};
|
|
94
94
|
exports.setDefaults = setDefaults;
|
package/dist/utilities/dotGet.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.dotGet = void 0;
|
|
7
|
-
var _isObject = require("./isObject.js");
|
|
8
|
-
var _strAfter = require("./strAfter.js");
|
|
9
|
-
var _strBefore = require("./strBefore.js");
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dotGet = void 0;
|
|
7
|
+
var _isObject = require("./isObject.js");
|
|
8
|
+
var _strAfter = require("./strAfter.js");
|
|
9
|
+
var _strBefore = require("./strBefore.js");
|
|
10
10
|
/**
|
|
11
11
|
* Get a nested property value from an object.
|
|
12
12
|
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotGet.ts Sí, funciona}
|
|
@@ -14,41 +14,41 @@ var _strBefore = require("./strBefore.js");
|
|
|
14
14
|
* @param {string} [dotNotation=''] - The path to the property
|
|
15
15
|
* @param {string|null} [defaultValue=null] - The default value to return if the property is not found
|
|
16
16
|
* @returns {*} The value of the property
|
|
17
|
-
*/
|
|
18
|
-
const dotGet = (arrayObject = {}, dotNotation = '', defaultValue = null) => {
|
|
19
|
-
if (!dotNotation) {
|
|
20
|
-
return arrayObject;
|
|
21
|
-
}
|
|
22
|
-
let key = (0, _strBefore.strBefore)(dotNotation, '.');
|
|
23
|
-
const lastKey = !key;
|
|
24
|
-
if (lastKey) {
|
|
25
|
-
key = dotNotation;
|
|
26
|
-
}
|
|
27
|
-
if (key === '*') {
|
|
28
|
-
const result = [];
|
|
29
|
-
for (let wildKey in arrayObject) {
|
|
30
|
-
const wildValue = arrayObject[wildKey];
|
|
31
|
-
if (lastKey) {
|
|
32
|
-
result[wildKey] = wildValue;
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (!(0, _isObject.isObject)(wildValue)) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
result[wildKey] = dotGet(wildValue, (0, _strAfter.strAfter)(dotNotation, '.'), defaultValue);
|
|
39
|
-
}
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
if (lastKey) {
|
|
43
|
-
return arrayObject[dotNotation] ?? defaultValue;
|
|
44
|
-
}
|
|
45
|
-
if (typeof arrayObject[key] === 'undefined') {
|
|
46
|
-
return defaultValue;
|
|
47
|
-
}
|
|
48
|
-
const next = arrayObject[key];
|
|
49
|
-
if (!(0, _isObject.isObject)(next)) {
|
|
50
|
-
return defaultValue;
|
|
51
|
-
}
|
|
52
|
-
return dotGet(next, (0, _strAfter.strAfter)(dotNotation, '.'), defaultValue);
|
|
53
|
-
};
|
|
17
|
+
*/
|
|
18
|
+
const dotGet = (arrayObject = {}, dotNotation = '', defaultValue = null) => {
|
|
19
|
+
if (!dotNotation) {
|
|
20
|
+
return arrayObject;
|
|
21
|
+
}
|
|
22
|
+
let key = (0, _strBefore.strBefore)(dotNotation, '.');
|
|
23
|
+
const lastKey = !key;
|
|
24
|
+
if (lastKey) {
|
|
25
|
+
key = dotNotation;
|
|
26
|
+
}
|
|
27
|
+
if (key === '*') {
|
|
28
|
+
const result = [];
|
|
29
|
+
for (let wildKey in arrayObject) {
|
|
30
|
+
const wildValue = arrayObject[wildKey];
|
|
31
|
+
if (lastKey) {
|
|
32
|
+
result[wildKey] = wildValue;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (!(0, _isObject.isObject)(wildValue)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
result[wildKey] = dotGet(wildValue, (0, _strAfter.strAfter)(dotNotation, '.'), defaultValue);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
if (lastKey) {
|
|
43
|
+
return arrayObject[dotNotation] ?? defaultValue;
|
|
44
|
+
}
|
|
45
|
+
if (typeof arrayObject[key] === 'undefined') {
|
|
46
|
+
return defaultValue;
|
|
47
|
+
}
|
|
48
|
+
const next = arrayObject[key];
|
|
49
|
+
if (!(0, _isObject.isObject)(next)) {
|
|
50
|
+
return defaultValue;
|
|
51
|
+
}
|
|
52
|
+
return dotGet(next, (0, _strAfter.strAfter)(dotNotation, '.'), defaultValue);
|
|
53
|
+
};
|
|
54
54
|
exports.dotGet = dotGet;
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.dotNotate = void 0;
|
|
7
|
-
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
-
require("core-js/modules/esnext.iterator.map.js");
|
|
9
|
-
var _isObject = require("./isObject.js");
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dotNotate = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
9
|
+
var _isObject = require("./isObject.js");
|
|
10
10
|
/**
|
|
11
11
|
* Convert an array of keys into a regex, return a function to test if incoming keys match.
|
|
12
12
|
* @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
|
|
13
13
|
* @returns {Function} The dot-notated array
|
|
14
|
-
*/
|
|
15
|
-
const handleRetainObjects = (retainObjects = []) => {
|
|
16
|
-
if (!retainObjects.length) {
|
|
14
|
+
*/
|
|
15
|
+
const handleRetainObjects = (retainObjects = []) => {
|
|
16
|
+
if (!retainObjects.length) {
|
|
17
17
|
/**
|
|
18
18
|
* Bypass the test function if there are no retainObjects.
|
|
19
19
|
* @returns {false}
|
|
20
|
-
*/
|
|
21
|
-
return (currentKey, value, results) => false;
|
|
22
|
-
}
|
|
23
|
-
retainObjects = retainObjects.map(key => key.replace('\.', '\\.'));
|
|
24
|
-
const retainRegex = new RegExp(`(${retainObjects.join('|')})$`);
|
|
20
|
+
*/
|
|
21
|
+
return (currentKey, value, results) => false;
|
|
22
|
+
}
|
|
23
|
+
retainObjects = retainObjects.map(key => key.replace('\.', '\\.'));
|
|
24
|
+
const retainRegex = new RegExp(`(${retainObjects.join('|')})$`);
|
|
25
25
|
/**
|
|
26
26
|
* Test if a key should be retained as an object.
|
|
27
27
|
* @param {string} currentKey - The key to test
|
|
28
28
|
* @param {*} value - The value of the key
|
|
29
29
|
* @param {Object} results - The result object to add to
|
|
30
30
|
* @returns {boolean}
|
|
31
|
-
*/
|
|
32
|
-
return (currentKey, value, results) => {
|
|
33
|
-
if (!currentKey.match(retainRegex)) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
results[currentKey] = value;
|
|
37
|
-
return true;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
31
|
+
*/
|
|
32
|
+
return (currentKey, value, results) => {
|
|
33
|
+
if (!currentKey.match(retainRegex)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
results[currentKey] = value;
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
41
|
/**
|
|
42
42
|
* The underlying logic function for converting arrays to dot-notation.
|
|
43
43
|
* @param {Object} arrayObject - The array or object to dot-notate
|
|
@@ -45,29 +45,29 @@ const handleRetainObjects = (retainObjects = []) => {
|
|
|
45
45
|
* @param {string} [prepend=''] - The path for the property being processed
|
|
46
46
|
* @param {Object<string, *>} [results={}] - The final notated object to return
|
|
47
47
|
* @returns {Object<string, *>} The dot-notated object
|
|
48
|
-
*/
|
|
49
|
-
const performDotNotate = (arrayObject, didRetain, prepend = '', results = {}) => {
|
|
50
|
-
for (let key in arrayObject) {
|
|
51
|
-
const value = arrayObject[key];
|
|
52
|
-
const currentKey = `${prepend}${key}`;
|
|
53
|
-
if (didRetain(currentKey, value, results)) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if ((0, _isObject.isObject)(value)) {
|
|
57
|
-
performDotNotate(value, didRetain, `${currentKey}.`, results);
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
results[currentKey] = value;
|
|
61
|
-
}
|
|
62
|
-
return results;
|
|
63
|
-
};
|
|
64
|
-
|
|
48
|
+
*/
|
|
49
|
+
const performDotNotate = (arrayObject, didRetain, prepend = '', results = {}) => {
|
|
50
|
+
for (let key in arrayObject) {
|
|
51
|
+
const value = arrayObject[key];
|
|
52
|
+
const currentKey = `${prepend}${key}`;
|
|
53
|
+
if (didRetain(currentKey, value, results)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if ((0, _isObject.isObject)(value)) {
|
|
57
|
+
performDotNotate(value, didRetain, `${currentKey}.`, results);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
results[currentKey] = value;
|
|
61
|
+
}
|
|
62
|
+
return results;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
65
|
/**
|
|
66
66
|
* Convert an array or object to a single dimensional associative array with dot notation.
|
|
67
67
|
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotNotate.ts Sí, funciona}
|
|
68
68
|
* @param {Object} arrayObject - The array or object to dot-notate
|
|
69
69
|
* @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
|
|
70
70
|
* @returns {Object<string, *>} The dot-notated object
|
|
71
|
-
*/
|
|
72
|
-
const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects));
|
|
71
|
+
*/
|
|
72
|
+
const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects));
|
|
73
73
|
exports.dotNotate = dotNotate;
|
package/dist/utilities/dotSet.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.dotSet = void 0;
|
|
7
|
-
var _isObject = require("./isObject.js");
|
|
8
|
-
var _strAfter = require("./strAfter.js");
|
|
9
|
-
var _strBefore = require("./strBefore.js");
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dotSet = void 0;
|
|
7
|
+
var _isObject = require("./isObject.js");
|
|
8
|
+
var _strAfter = require("./strAfter.js");
|
|
9
|
+
var _strBefore = require("./strBefore.js");
|
|
10
10
|
/**
|
|
11
11
|
* Set a nested property value an object.
|
|
12
12
|
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotSet.ts Sí, funciona}
|
|
@@ -14,32 +14,32 @@ var _strBefore = require("./strBefore.js");
|
|
|
14
14
|
* @param {string} dotNotation - The path for the property
|
|
15
15
|
* @param {*} value - The default value to return if the property is not found
|
|
16
16
|
* @returns {Object} The modified object
|
|
17
|
-
*/
|
|
18
|
-
const dotSet = (arrayObject, dotNotation, value = null) => {
|
|
19
|
-
let key = (0, _strBefore.strBefore)(dotNotation, '.');
|
|
20
|
-
const lastKey = !key;
|
|
21
|
-
if (lastKey) {
|
|
22
|
-
key = dotNotation;
|
|
23
|
-
}
|
|
24
|
-
if (key === '*') {
|
|
25
|
-
for (let wildKey in arrayObject) {
|
|
26
|
-
if (lastKey) {
|
|
27
|
-
arrayObject[wildKey] = value;
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (!(0, _isObject.isObject)(arrayObject[wildKey])) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
dotSet(arrayObject[wildKey], (0, _strAfter.strAfter)(dotNotation, '.'), value);
|
|
34
|
-
}
|
|
35
|
-
return arrayObject;
|
|
36
|
-
}
|
|
37
|
-
if (lastKey) {
|
|
38
|
-
arrayObject[dotNotation] = value;
|
|
39
|
-
return arrayObject;
|
|
40
|
-
}
|
|
41
|
-
const next = arrayObject[key] ?? [];
|
|
42
|
-
arrayObject[key] = dotSet(next, (0, _strAfter.strAfter)(dotNotation, '.'), value);
|
|
43
|
-
return arrayObject;
|
|
44
|
-
};
|
|
17
|
+
*/
|
|
18
|
+
const dotSet = (arrayObject, dotNotation, value = null) => {
|
|
19
|
+
let key = (0, _strBefore.strBefore)(dotNotation, '.');
|
|
20
|
+
const lastKey = !key;
|
|
21
|
+
if (lastKey) {
|
|
22
|
+
key = dotNotation;
|
|
23
|
+
}
|
|
24
|
+
if (key === '*') {
|
|
25
|
+
for (let wildKey in arrayObject) {
|
|
26
|
+
if (lastKey) {
|
|
27
|
+
arrayObject[wildKey] = value;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (!(0, _isObject.isObject)(arrayObject[wildKey])) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
dotSet(arrayObject[wildKey], (0, _strAfter.strAfter)(dotNotation, '.'), value);
|
|
34
|
+
}
|
|
35
|
+
return arrayObject;
|
|
36
|
+
}
|
|
37
|
+
if (lastKey) {
|
|
38
|
+
arrayObject[dotNotation] = value;
|
|
39
|
+
return arrayObject;
|
|
40
|
+
}
|
|
41
|
+
const next = arrayObject[key] ?? [];
|
|
42
|
+
arrayObject[key] = dotSet(next, (0, _strAfter.strAfter)(dotNotation, '.'), value);
|
|
43
|
+
return arrayObject;
|
|
44
|
+
};
|
|
45
45
|
exports.dotSet = dotSet;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isObject = void 0;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isObject = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Check if the provided thing is an object / array.
|
|
9
9
|
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/isObject.ts Sí, funciona}
|
|
10
10
|
* @param {*} object
|
|
11
11
|
* @returns {boolean}
|
|
12
|
-
*/
|
|
13
|
-
const isObject = object => typeof object === 'object' && object !== null;
|
|
12
|
+
*/
|
|
13
|
+
const isObject = object => typeof object === 'object' && object !== null;
|
|
14
14
|
exports.isObject = isObject;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.strAfter = void 0;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.strAfter = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Retrieve the string part after the search match.
|
|
9
9
|
* Original source from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/strings/strAfter.ts Sí, funciona}
|
|
10
10
|
* @param {string} str
|
|
11
11
|
* @param {string} search
|
|
12
12
|
* @returns {string}
|
|
13
|
-
*/
|
|
14
|
-
const strAfter = (str, search) => {
|
|
15
|
-
const index = str.indexOf(search);
|
|
16
|
-
return index === -1 ? '' : str.substring(index + search.length);
|
|
17
|
-
};
|
|
13
|
+
*/
|
|
14
|
+
const strAfter = (str, search) => {
|
|
15
|
+
const index = str.indexOf(search);
|
|
16
|
+
return index === -1 ? '' : str.substring(index + search.length);
|
|
17
|
+
};
|
|
18
18
|
exports.strAfter = strAfter;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.strBefore = void 0;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.strBefore = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Retrieve the string part before the search match.
|
|
9
9
|
* Original source from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/strings/strBefore.ts Sí, funciona}
|
|
10
10
|
* @param {string} str
|
|
11
11
|
* @param {string} search
|
|
12
12
|
* @returns {string}
|
|
13
|
-
*/
|
|
14
|
-
const strBefore = (str, search) => {
|
|
15
|
-
const index = str.indexOf(search);
|
|
16
|
-
return index === -1 ? '' : str.slice(0, index);
|
|
17
|
-
};
|
|
13
|
+
*/
|
|
14
|
+
const strBefore = (str, search) => {
|
|
15
|
+
const index = str.indexOf(search);
|
|
16
|
+
return index === -1 ? '' : str.slice(0, index);
|
|
17
|
+
};
|
|
18
18
|
exports.strBefore = strBefore;
|