js-build-tools 2.4.0 → 3.0.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 +334 -205
- package/dist/build.js +16 -5
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +1 -2
- package/dist/bundle.min.js +1 -1
- package/dist/bundleLint.js +2 -3
- package/dist/bundleLint.min.js +1 -1
- package/dist/bundleMinify.js +1 -2
- package/dist/bundleMinify.min.js +1 -1
- package/dist/copyFonts.js +12 -0
- package/dist/copyFonts.min.js +1 -0
- package/dist/default.js +15 -15
- package/dist/default.min.js +1 -1
- package/dist/dist.js +7 -8
- package/dist/distLint.js +2 -3
- package/dist/distLint.min.js +1 -1
- package/dist/distMinify.js +1 -2
- package/dist/distMinify.min.js +1 -1
- package/dist/images.js +11 -0
- package/dist/images.min.js +1 -0
- package/dist/partials/addToReadme.js +2 -3
- package/dist/partials/beginWatcher.js +1 -2
- package/dist/partials/clean.js +10 -11
- package/dist/partials/copyFor.js +16 -0
- package/dist/partials/distFor.js +1 -2
- package/dist/partials/distForSrc.js +2 -3
- package/dist/partials/distSeries.js +3 -4
- package/dist/partials/imagesFor.js +34 -0
- package/dist/partials/minifyFor.js +15 -16
- package/dist/partials/readmeTemplate.js +1 -2
- package/dist/partials/removeDirectory.js +11 -12
- package/dist/partials/runOnChange.js +7 -7
- package/dist/partials/sassFor.js +2 -3
- package/dist/partials/tsFor.js +4 -5
- package/dist/partials.js +5 -1
- package/dist/partials.min.js +1 -1
- package/dist/test-helpers/setUp.js +31 -39
- package/dist/testFull.js +2 -3
- package/dist/testFull.min.js +1 -1
- package/dist/testHelpers.js +2 -20
- package/dist/testHelpers.min.js +1 -1
- package/dist/testQuick.js +1 -2
- package/dist/testQuick.min.js +1 -1
- package/dist/typeScript.js +7 -8
- package/dist/utilities/dotGet.js +50 -0
- package/dist/utilities/dotNotate.js +77 -0
- package/dist/utilities/dotSet.js +44 -0
- package/dist/utilities/isObject.js +10 -0
- package/dist/watchFull.js +10 -11
- package/dist/watchTest.js +1 -2
- package/dist/watchTest.min.js +1 -1
- package/functions/build.js +15 -5
- package/functions/build.test.js +278 -42
- package/functions/bundle.js +3 -4
- package/functions/bundle.test.js +6 -6
- package/functions/bundleLint.js +2 -3
- package/functions/bundleLint.test.js +5 -5
- package/functions/bundleMinify.js +1 -2
- package/functions/bundleMinify.test.js +1 -1
- package/functions/copyFonts.js +11 -0
- package/functions/copyFonts.test.js +31 -0
- package/functions/default.js +1 -1
- package/functions/default.test.js +2 -2
- package/functions/dist.js +0 -1
- package/functions/dist.test.js +1 -1
- package/functions/distLint.js +2 -3
- package/functions/distLint.test.js +3 -3
- package/functions/distMinify.js +1 -2
- package/functions/distMinify.test.js +1 -1
- package/functions/images.js +10 -0
- package/functions/images.test.js +138 -0
- package/functions/partials/addToReadme.js +2 -3
- package/functions/partials/addToReadme.test.js +2 -2
- package/functions/partials/beginWatcher.js +1 -2
- package/functions/partials/beginWatcher.test.js +1 -1
- package/functions/partials/clean.js +0 -1
- package/functions/partials/copyFor.js +13 -0
- package/functions/partials/copyFor.test.js +34 -0
- package/functions/partials/distFor.js +1 -2
- package/functions/partials/distFor.test.js +4 -4
- package/functions/partials/distForSrc.js +3 -4
- package/functions/partials/distForSrc.test.js +6 -6
- package/functions/partials/distSeries.js +2 -3
- package/functions/partials/distSeries.test.js +5 -5
- package/functions/partials/imagesFor.js +33 -0
- package/functions/partials/imagesFor.test.js +143 -0
- package/functions/partials/minifyFor.js +0 -1
- package/functions/partials/minifyFor.test.js +1 -1
- package/functions/partials/readmeTemplate.js +3 -4
- package/functions/partials/readmeTemplate.test.js +2 -2
- package/functions/partials/removeDirectory.js +0 -1
- package/functions/partials/runOnChange.js +5 -6
- package/functions/partials/runOnChange.test.js +9 -9
- package/functions/partials/sassFor.js +1 -2
- package/functions/partials/sassFor.test.js +3 -3
- package/functions/partials/tsFor.js +3 -4
- package/functions/partials/tsFor.test.js +2 -2
- package/functions/partials.js +5 -1
- package/functions/partials.test.js +1 -1
- package/functions/sass.test.js +2 -2
- package/functions/test-helpers/setUp.js +24 -32
- package/functions/testFull.js +2 -3
- package/functions/testFull.test.js +1 -1
- package/functions/testHelpers.js +3 -20
- package/functions/testHelpers.test.js +1 -1
- package/functions/testQuick.js +1 -2
- package/functions/testQuick.test.js +1 -1
- package/functions/typeScript.js +0 -1
- package/functions/typeScript.test.js +0 -2
- package/functions/utilities/dotGet.js +47 -0
- package/functions/utilities/dotNotate.js +68 -0
- package/functions/utilities/dotSet.js +41 -0
- package/functions/utilities/isObject.js +9 -0
- package/functions/watchFull.js +0 -1
- package/functions/watchFull.test.js +1 -1
- package/functions/watchTest.js +1 -2
- package/functions/watchTest.test.js +1 -1
- package/gulp.config.js +153 -79
- package/gulpfile.base.js +5 -1
- package/jsdoc.base.js +1 -1
- package/package.json +13 -9
- package/vendor/array-union/index.js +31 -0
- package/vendor/easy-transform-stream/index.js +58 -0
- package/vendor/globby/gitignore.js +100 -0
- package/vendor/globby/index.js +195 -0
- package/vendor/globby/node_modules/slash/index.js +16 -0
- package/vendor/globby/stream-utils.js +58 -0
- package/vendor/globby/to-path.js +20 -0
- package/vendor/gulp-imagemin/index.js +128 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/index.js +265 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/utilities.js +36 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
- package/vendor/gulp-plugin-extras/index.js +46 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/index.js +265 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/utilities.js +36 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
- package/vendor/gulp-plugin-extras/plugin-error.js +145 -0
- package/vendor/ignore/index.js +468 -0
- package/vendor/imagemin/index.js +94 -0
- package/vendor/imagemin-gifsicle/index.js +37 -0
- package/vendor/imagemin-mozjpeg/index.js +104 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +264 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/command.js +47 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/error.js +102 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +123 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/promise.js +47 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stdio.js +50 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +128 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/core.js +238 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/main.js +89 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/realtime.js +24 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/signals.js +44 -0
- package/vendor/imagemin-mozjpeg/node_modules/is-stream/index.js +25 -0
- package/vendor/imagemin-mozjpeg/node_modules/mimic-fn/index.js +70 -0
- package/vendor/imagemin-mozjpeg/node_modules/npm-run-path/index.js +52 -0
- package/vendor/imagemin-mozjpeg/node_modules/onetime/index.js +43 -0
- package/vendor/imagemin-mozjpeg/node_modules/path-key/index.js +20 -0
- package/vendor/imagemin-mozjpeg/node_modules/strip-final-newline/index.js +17 -0
- package/vendor/imagemin-optipng/index.js +44 -0
- package/vendor/imagemin-svgo/index.js +27 -0
- package/vendor/is-jpg/index.js +12 -0
- package/vendor/junk/index.js +49 -0
- package/vendor/mozjpeg/index.js +9 -0
- package/vendor/mozjpeg/lib/index.js +18 -0
- package/vendor/mozjpeg/package.json +50 -0
- package/vendor/p-pipe/index.js +26 -0
- package/vendor/plur/index.js +32 -0
- package/vendor/pretty-bytes/index.js +71 -0
- package/vendor/slash/index.js +12 -0
- package/dist/test-helpers/circularObject.js +0 -50
- package/dist/test-helpers/countMatches.js +0 -12
- package/dist/test-helpers/deepReferenceObject.js +0 -20
- package/dist/test-helpers/domItem.js +0 -33
- package/dist/test-helpers/jsonDom.js +0 -20
- package/dist/test-helpers/linkedList.js +0 -23
- package/dist/test-helpers/logObject.js +0 -21
- package/dist/test-helpers/multiReferenceObject.js +0 -20
- package/dist/test-helpers/nodeTree.js +0 -28
- package/functions/test-helpers/circularObject.js +0 -28
- package/functions/test-helpers/circularObject.test.js +0 -14
- package/functions/test-helpers/countMatches.js +0 -11
- package/functions/test-helpers/countMatches.test.js +0 -9
- package/functions/test-helpers/deepReferenceObject.js +0 -25
- package/functions/test-helpers/deepReferenceObject.test.js +0 -7
- package/functions/test-helpers/domItem.js +0 -31
- package/functions/test-helpers/domItem.test.js +0 -12
- package/functions/test-helpers/jsonDom.js +0 -16
- package/functions/test-helpers/jsonDom.test.js +0 -12
- package/functions/test-helpers/linkedList.js +0 -10
- package/functions/test-helpers/linkedList.test.js +0 -22
- package/functions/test-helpers/logObject.js +0 -18
- package/functions/test-helpers/logObject.test.js +0 -20
- package/functions/test-helpers/multiReferenceObject.js +0 -25
- package/functions/test-helpers/multiReferenceObject.test.js +0 -14
- package/functions/test-helpers/nodeTree.js +0 -11
- package/functions/test-helpers/nodeTree.test.js +0 -18
|
@@ -1,77 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
// Import the configurations and override some of them in order to direct to the temp directory.
|
|
3
|
+
// Import the configurations and override some of them to direct to the temp directory.
|
|
5
4
|
const gulpConfig = require('../../gulp.config.js');
|
|
6
5
|
const {
|
|
7
|
-
|
|
8
|
-
} = require('
|
|
6
|
+
setUp
|
|
7
|
+
} = require('test-filesystem');
|
|
9
8
|
let tempDir = 'test-temp/';
|
|
10
|
-
let srcPath =
|
|
9
|
+
let srcPath = "".concat(tempDir, "src");
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Update the gulp configurations with the test data. Set the test directory where temp files will be created for testing.
|
|
14
|
-
* @function
|
|
15
13
|
* @memberOf module:testHelpers
|
|
16
14
|
* @param {string} testDir
|
|
17
15
|
*/
|
|
18
16
|
const setDefaults = function () {
|
|
19
17
|
let testDir = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'test-temp';
|
|
20
|
-
tempDir =
|
|
21
|
-
srcPath =
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
18
|
+
tempDir = "".concat(testDir, "/");
|
|
19
|
+
srcPath = "".concat(tempDir, "src");
|
|
20
|
+
setUp.setDefaults(tempDir);
|
|
21
|
+
const distPath = "".concat(tempDir, "dist");
|
|
22
|
+
const browserPath = "".concat(tempDir, "browser");
|
|
23
|
+
const sassPath = "".concat(tempDir, "sass");
|
|
24
|
+
gulpConfig.set('browser.from', "".concat(distPath, "/**/*.js"));
|
|
25
|
+
gulpConfig.set('browser.to', browserPath);
|
|
26
26
|
gulpConfig.set('cleanPaths', [distPath, browserPath]);
|
|
27
|
-
gulpConfig.set('
|
|
28
|
-
gulpConfig.set('
|
|
29
|
-
gulpConfig.set('
|
|
30
|
-
gulpConfig.set('
|
|
31
|
-
gulpConfig.set('
|
|
32
|
-
gulpConfig.set('
|
|
33
|
-
gulpConfig.set('
|
|
27
|
+
gulpConfig.set('dist.from', "".concat(srcPath, "/**/!(*.test).js"));
|
|
28
|
+
gulpConfig.set('dist.main', "".concat(distPath, "/main"));
|
|
29
|
+
gulpConfig.set('dist.to', distPath);
|
|
30
|
+
gulpConfig.set('fonts.from', "".concat(srcPath, "/fonts/**/*"));
|
|
31
|
+
gulpConfig.set('fonts.to', "".concat(browserPath, "/fonts"));
|
|
32
|
+
gulpConfig.set('images.from', "".concat(srcPath, "/img/**/*.+(png|jpg|jpeg|gif|svg)"));
|
|
33
|
+
gulpConfig.set('images.to', "".concat(browserPath, "/img"));
|
|
34
|
+
gulpConfig.set('readme.template', "".concat(tempDir, "MAIN.md"));
|
|
35
|
+
gulpConfig.set('readme.to', tempDir);
|
|
36
|
+
gulpConfig.set('readme.from', "".concat(srcPath, "/**/!(*.test).js"));
|
|
34
37
|
gulpConfig.set('rootPath', tempDir);
|
|
35
|
-
gulpConfig.set('
|
|
36
|
-
gulpConfig.set('
|
|
38
|
+
gulpConfig.set('sass.from', "".concat(sassPath, "/**/*.+(scss|sass)"));
|
|
39
|
+
gulpConfig.set('sass.path', sassPath);
|
|
40
|
+
gulpConfig.set('sass.to', "".concat(browserPath, "/css"));
|
|
37
41
|
gulpConfig.set('srcPath', srcPath);
|
|
38
|
-
gulpConfig.set('
|
|
39
|
-
gulpConfig.set('
|
|
40
|
-
gulpConfig.set('
|
|
42
|
+
gulpConfig.set('typescript.from', "".concat(srcPath, "/**/*.ts"));
|
|
43
|
+
gulpConfig.set('typescript.to', distPath);
|
|
44
|
+
gulpConfig.set('test.watch', "".concat(srcPath, "/**/*.js"));
|
|
41
45
|
};
|
|
42
46
|
exports.setDefaults = setDefaults;
|
|
43
47
|
exports.gulpConfig = gulpConfig;
|
|
44
48
|
|
|
45
49
|
/**
|
|
46
50
|
* Ensure that the del has completed, recursively attempt to delete and recreate
|
|
47
|
-
* @function
|
|
48
51
|
* @memberOf module:testHelpers
|
|
49
52
|
* @param {boolean} [exists=true]
|
|
50
53
|
* @returns {Promise<*|void>}
|
|
51
54
|
*/
|
|
52
|
-
|
|
53
|
-
let exists = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
54
|
-
if (exists) {
|
|
55
|
-
return removeDirectory(tempDir).then(removedDir => createTempDir(fs.existsSync(removedDir))).catch(error => console.error('Error: ', error));
|
|
56
|
-
}
|
|
57
|
-
return fs.mkdirSync(srcPath, {
|
|
58
|
-
recursive: true
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
exports.createTempDir = createTempDir;
|
|
55
|
+
exports.createTempDir = setUp.createTempDir;
|
|
62
56
|
|
|
63
57
|
/**
|
|
64
58
|
* In the Jest.beforeEach function call this one to set up the temp directory.
|
|
65
|
-
* @function
|
|
66
59
|
* @memberOf module:testHelpers
|
|
67
60
|
* @returns {Promise<*|void>}
|
|
68
61
|
*/
|
|
69
|
-
exports.beforeEach =
|
|
62
|
+
exports.beforeEach = setUp.beforeEach;
|
|
70
63
|
|
|
71
64
|
/**
|
|
72
65
|
* In the Jest.afterEach function call this one to clean up and remove the temp directory.
|
|
73
|
-
* @function
|
|
74
66
|
* @memberOf module:testHelpers
|
|
75
67
|
* @returns {Promise<*>}
|
|
76
68
|
*/
|
|
77
|
-
exports.afterEach =
|
|
69
|
+
exports.afterEach = setUp.afterEach;
|
package/dist/testFull.js
CHANGED
|
@@ -8,16 +8,15 @@ const {
|
|
|
8
8
|
/**
|
|
9
9
|
* Run all tests with jest.
|
|
10
10
|
* Configure where tests are located by using 'testPath'.
|
|
11
|
-
* @function
|
|
12
11
|
* @memberOf module:js-build-tools
|
|
13
12
|
* @returns {Promise<*>}
|
|
14
13
|
*/
|
|
15
14
|
const testFull = () => {
|
|
16
|
-
let testPath = gulpConfig.get('
|
|
15
|
+
let testPath = gulpConfig.get('test.path')
|
|
17
16
|
if (!Array.isArray(testPath)) {
|
|
18
17
|
// The testPath must be an array of strings
|
|
19
18
|
testPath = [testPath]
|
|
20
19
|
}
|
|
21
|
-
return runCLI(gulpConfig.get('
|
|
20
|
+
return runCLI(gulpConfig.get('test.options'), testPath)
|
|
22
21
|
}
|
|
23
22
|
module.exports = testFull
|
package/dist/testFull.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const gulpConfig=require("../gulp.config.js"),{runCLI:runCLI}=require("jest"),testFull=()=>{let t=gulpConfig.get("
|
|
1
|
+
"use strict";const gulpConfig=require("../gulp.config.js"),{runCLI:runCLI}=require("jest"),testFull=()=>{let t=gulpConfig.get("test.path");return Array.isArray(t)||(t=[t]),runCLI(gulpConfig.get("test.options"),t)};module.exports=testFull;
|
package/dist/testHelpers.js
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Export the setUp helper.
|
|
5
5
|
* @file
|
|
6
6
|
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
7
|
-
* @version
|
|
7
|
+
* @version 3.0.0
|
|
8
8
|
* @module testHelpers
|
|
9
9
|
* @memberOf module:js-build-tools
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
const circularObject = require('./test-helpers/circularObject')
|
|
13
|
-
const countMatches = require('./test-helpers/countMatches')
|
|
14
|
-
const deepReferenceObject = require('./test-helpers/deepReferenceObject')
|
|
15
|
-
const domItem = require('./test-helpers/domItem')
|
|
16
|
-
const jsonDom = require('./test-helpers/jsonDom')
|
|
17
|
-
const linkedList = require('./test-helpers/linkedList')
|
|
18
|
-
const logObject = require('./test-helpers/logObject')
|
|
19
|
-
const multiReferenceObject = require('./test-helpers/multiReferenceObject')
|
|
20
|
-
const nodeTree = require('./test-helpers/nodeTree')
|
|
21
12
|
const setUp = require('./test-helpers/setUp')
|
|
22
13
|
module.exports = {
|
|
23
|
-
circularObject,
|
|
24
|
-
countMatches,
|
|
25
|
-
deepReferenceObject,
|
|
26
|
-
domItem,
|
|
27
|
-
jsonDom,
|
|
28
|
-
linkedList,
|
|
29
|
-
logObject,
|
|
30
|
-
multiReferenceObject,
|
|
31
|
-
nodeTree,
|
|
32
14
|
setUp
|
|
33
15
|
}
|
package/dist/testHelpers.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const setUp=require("./test-helpers/setUp");module.exports={setUp:setUp};
|
package/dist/testQuick.js
CHANGED
|
@@ -8,12 +8,11 @@ const {
|
|
|
8
8
|
/**
|
|
9
9
|
* Run the Jest tests for files which have been modified (based on git status).
|
|
10
10
|
* Configure where tests are located by using 'testPath'.
|
|
11
|
-
* @function
|
|
12
11
|
* @memberOf module:js-build-tools
|
|
13
12
|
* @returns {Promise<*>}
|
|
14
13
|
*/
|
|
15
14
|
const testQuick = () => {
|
|
16
|
-
let testPath = gulpConfig.get('
|
|
15
|
+
let testPath = gulpConfig.get('test.path')
|
|
17
16
|
if (!Array.isArray(testPath)) {
|
|
18
17
|
// The testPath must be an array of strings
|
|
19
18
|
testPath = [testPath]
|
package/dist/testQuick.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const gulpConfig=require("../gulp.config.js"),{runCLI:runCLI}=require("jest"),testQuick=()=>{let e=gulpConfig.get("
|
|
1
|
+
"use strict";const gulpConfig=require("../gulp.config.js"),{runCLI:runCLI}=require("jest"),testQuick=()=>{let e=gulpConfig.get("test.path");return Array.isArray(e)||(e=[e]),runCLI({onlyChanged:!0},e)};module.exports=testQuick;
|
package/dist/typeScript.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const tsFor = require('./partials/tsFor')
|
|
4
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const tsFor = require('./partials/tsFor')
|
|
4
|
+
|
|
5
5
|
/**
|
|
6
6
|
* Simplified typescript task using tsFor.
|
|
7
|
-
* @function
|
|
8
7
|
* @memberOf module:js-build-tools
|
|
9
8
|
* @returns {Function}
|
|
10
|
-
*/
|
|
11
|
-
const typeScript = tsFor()
|
|
12
|
-
module.exports = typeScript
|
|
9
|
+
*/
|
|
10
|
+
const typeScript = tsFor()
|
|
11
|
+
module.exports = typeScript
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const isObject = require('./isObject');
|
|
4
|
+
const strAfter = require('common-exports/dist/utilities/strAfter').default;
|
|
5
|
+
const strBefore = require('common-exports/dist/utilities/strBefore').default;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get a nested property value from an object.
|
|
9
|
+
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotGet.ts Sí, funciona}
|
|
10
|
+
* @param {Object} arrayObject - The array or object to get the property from
|
|
11
|
+
* @param {string} dotNotation - The path to the property
|
|
12
|
+
* @param {string|null} [defaultValue=null] - The default value to return if the property is not found
|
|
13
|
+
* @returns {*} The value of the property
|
|
14
|
+
*/
|
|
15
|
+
const dotGet = function (arrayObject, dotNotation) {
|
|
16
|
+
let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
17
|
+
let key = strBefore(dotNotation, '.');
|
|
18
|
+
const lastKey = !key;
|
|
19
|
+
if (lastKey) {
|
|
20
|
+
key = dotNotation;
|
|
21
|
+
}
|
|
22
|
+
if (key === '*') {
|
|
23
|
+
const result = [];
|
|
24
|
+
for (let wildKey in arrayObject) {
|
|
25
|
+
const wildValue = arrayObject[wildKey];
|
|
26
|
+
if (lastKey) {
|
|
27
|
+
result[wildKey] = wildValue;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (!isObject(wildValue)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
result[wildKey] = dotGet(wildValue, strAfter(dotNotation, '.'), defaultValue);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
if (lastKey) {
|
|
38
|
+
var _arrayObject$dotNotat;
|
|
39
|
+
return (_arrayObject$dotNotat = arrayObject[dotNotation]) !== null && _arrayObject$dotNotat !== void 0 ? _arrayObject$dotNotat : defaultValue;
|
|
40
|
+
}
|
|
41
|
+
if (typeof arrayObject[key] === 'undefined') {
|
|
42
|
+
return defaultValue;
|
|
43
|
+
}
|
|
44
|
+
const next = arrayObject[key];
|
|
45
|
+
if (!isObject(next)) {
|
|
46
|
+
return defaultValue;
|
|
47
|
+
}
|
|
48
|
+
return dotGet(next, strAfter(dotNotation, '.'), defaultValue);
|
|
49
|
+
};
|
|
50
|
+
module.exports = dotGet;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.string.replace.js");
|
|
4
|
+
require("core-js/modules/esnext.async-iterator.map.js");
|
|
5
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
6
|
+
const isObject = require('./isObject');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Convert an array of keys into a regex, return a function to test if incoming keys match.
|
|
10
|
+
* @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
|
|
11
|
+
* @returns {Function} The dot-notated array
|
|
12
|
+
*/
|
|
13
|
+
const handleRetainObjects = function () {
|
|
14
|
+
let retainObjects = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
15
|
+
if (!retainObjects.length) {
|
|
16
|
+
/**
|
|
17
|
+
* Bypass the test function if there are no retainObjects.
|
|
18
|
+
* @returns {false}
|
|
19
|
+
*/
|
|
20
|
+
return (currentKey, value, results) => false;
|
|
21
|
+
}
|
|
22
|
+
retainObjects = retainObjects.map(key => key.replace('\.', '\\.'));
|
|
23
|
+
const retainRegex = new RegExp("(".concat(retainObjects.join('|'), ")$"));
|
|
24
|
+
/**
|
|
25
|
+
* Test if a key should be retained as an object.
|
|
26
|
+
* @param {string} currentKey - The key to test
|
|
27
|
+
* @param {*} value - The value of the key
|
|
28
|
+
* @param {Object} results - The result object to add to
|
|
29
|
+
* @returns {boolean}
|
|
30
|
+
*/
|
|
31
|
+
return (currentKey, value, results) => {
|
|
32
|
+
if (!currentKey.match(retainRegex)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
results[currentKey] = value;
|
|
36
|
+
return true;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The underlying logic function for converting arrays to dot-notation.
|
|
42
|
+
* @param {Object} arrayObject - The array or object to dot-notate
|
|
43
|
+
* @param {Function} didRetain - The test function to see if a key should be retained
|
|
44
|
+
* @param {string} [prepend=''] - The path for the property being processed
|
|
45
|
+
* @param {Object<string, *>} [results={}] - The final notated object to return
|
|
46
|
+
* @returns {Object<string, *>} The dot-notated object
|
|
47
|
+
*/
|
|
48
|
+
const performDotNotate = function (arrayObject, didRetain) {
|
|
49
|
+
let prepend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
50
|
+
let results = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
51
|
+
for (let key in arrayObject) {
|
|
52
|
+
const value = arrayObject[key];
|
|
53
|
+
const currentKey = "".concat(prepend).concat(key);
|
|
54
|
+
if (didRetain(currentKey, value, results)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (isObject(value)) {
|
|
58
|
+
performDotNotate(value, didRetain, "".concat(currentKey, "."), results);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
results[currentKey] = value;
|
|
62
|
+
}
|
|
63
|
+
return results;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Convert an array or object to a single dimensional associative array with dot notation.
|
|
68
|
+
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotNotate.ts Sí, funciona}
|
|
69
|
+
* @param {Object} arrayObject - The array or object to dot-notate
|
|
70
|
+
* @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
|
|
71
|
+
* @returns {Object<string, *>} The dot-notated object
|
|
72
|
+
*/
|
|
73
|
+
const dotNotate = function (arrayObject) {
|
|
74
|
+
let retainObjects = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
75
|
+
return performDotNotate(arrayObject, handleRetainObjects(retainObjects));
|
|
76
|
+
};
|
|
77
|
+
module.exports = dotNotate;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const isObject = require('./isObject');
|
|
4
|
+
const strAfter = require('common-exports/dist/utilities/strAfter').default;
|
|
5
|
+
const strBefore = require('common-exports/dist/utilities/strBefore').default;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Set a nested property value an object.
|
|
9
|
+
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotSet.ts Sí, funciona}
|
|
10
|
+
* @param {Object} arrayObject - The array or object to set the property on
|
|
11
|
+
* @param {string} dotNotation - The path for the property
|
|
12
|
+
* @param {*} value - The default value to return if the property is not found
|
|
13
|
+
* @returns {Object} The modified object
|
|
14
|
+
*/
|
|
15
|
+
const dotSet = function (arrayObject, dotNotation) {
|
|
16
|
+
var _arrayObject$key;
|
|
17
|
+
let value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
18
|
+
let key = strBefore(dotNotation, '.');
|
|
19
|
+
const lastKey = !key;
|
|
20
|
+
if (lastKey) {
|
|
21
|
+
key = dotNotation;
|
|
22
|
+
}
|
|
23
|
+
if (key === '*') {
|
|
24
|
+
for (let wildKey in arrayObject) {
|
|
25
|
+
if (lastKey) {
|
|
26
|
+
arrayObject[wildKey] = value;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (!isObject(arrayObject[wildKey])) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
dotSet(arrayObject[wildKey], strAfter(dotNotation, '.'), value);
|
|
33
|
+
}
|
|
34
|
+
return arrayObject;
|
|
35
|
+
}
|
|
36
|
+
if (lastKey) {
|
|
37
|
+
arrayObject[dotNotation] = value;
|
|
38
|
+
return arrayObject;
|
|
39
|
+
}
|
|
40
|
+
const next = (_arrayObject$key = arrayObject[key]) !== null && _arrayObject$key !== void 0 ? _arrayObject$key : [];
|
|
41
|
+
arrayObject[key] = dotSet(next, strAfter(dotNotation, '.'), value);
|
|
42
|
+
return arrayObject;
|
|
43
|
+
};
|
|
44
|
+
module.exports = dotSet;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Check if the provided thing is an object / array.
|
|
5
|
+
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/isObject.ts Sí, funciona}
|
|
6
|
+
* @param {*} object
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
const isObject = object => typeof object === 'object' && object !== null;
|
|
10
|
+
module.exports = isObject;
|
package/dist/watchFull.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
beginWatcher,
|
|
5
|
-
runOnChange
|
|
6
|
-
} = require('./partials')
|
|
7
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
beginWatcher,
|
|
5
|
+
runOnChange
|
|
6
|
+
} = require('./partials')
|
|
7
|
+
|
|
8
8
|
/**
|
|
9
9
|
* Watch for changes and run the distribution for the changed files, then bundle and test the changed files.
|
|
10
|
-
* @function
|
|
11
10
|
* @memberOf module:js-build-tools
|
|
12
11
|
* @returns {FSWatcher}
|
|
13
|
-
*/
|
|
14
|
-
const watchFull = () => beginWatcher().on('change', runOnChange)
|
|
15
|
-
module.exports = watchFull
|
|
12
|
+
*/
|
|
13
|
+
const watchFull = () => beginWatcher().on('change', runOnChange)
|
|
14
|
+
module.exports = watchFull
|
package/dist/watchTest.js
CHANGED
|
@@ -8,11 +8,10 @@ const testQuick = require('./testQuick')
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Watch for changes and run the tests.
|
|
11
|
-
* @function
|
|
12
11
|
* @memberOf module:js-build-tools
|
|
13
12
|
* @returns {*}
|
|
14
13
|
*/
|
|
15
|
-
const watchTest = () => watch(gulpConfig.get('
|
|
14
|
+
const watchTest = () => watch(gulpConfig.get('test.watch'), {
|
|
16
15
|
ignoreInitial: false
|
|
17
16
|
}, testQuick)
|
|
18
17
|
module.exports = watchTest
|
package/dist/watchTest.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const gulpConfig=require("../gulp.config.js"),{watch:watch}=require("gulp"),testQuick=require("./testQuick"),watchTest=()=>watch(gulpConfig.get("
|
|
1
|
+
"use strict";const gulpConfig=require("../gulp.config.js"),{watch:watch}=require("gulp"),testQuick=require("./testQuick"),watchTest=()=>watch(gulpConfig.get("test.watch"),{ignoreInitial:!1},testQuick);module.exports=watchTest;
|
package/functions/build.js
CHANGED
|
@@ -7,6 +7,8 @@ const distLint = require('./distLint')
|
|
|
7
7
|
const distMinify = require('./distMinify')
|
|
8
8
|
const { parallel, series } = require('gulp')
|
|
9
9
|
const gulpConfig = require('../gulp.config.js')
|
|
10
|
+
const copyFonts = require('./copyFonts.js')
|
|
11
|
+
const images = require('./images.js')
|
|
10
12
|
const sass = require('./sass.js')
|
|
11
13
|
const testFull = require('./testFull')
|
|
12
14
|
|
|
@@ -20,11 +22,11 @@ const build = (done = null) => {
|
|
|
20
22
|
const distLintMinify = parallel(distLint, distMinify)
|
|
21
23
|
const bundleLintMinify = parallel(bundleLint, bundleMinify)
|
|
22
24
|
const buildActions = [clean, distSeries(), distLintMinify]
|
|
23
|
-
if (gulpConfig.get('
|
|
25
|
+
if (gulpConfig.get('typescript.enabled')) {
|
|
24
26
|
// For ts usage, we need to run the readme on the dist directly since that is where the .js files are located
|
|
25
27
|
buildActions.push(compileReadme)
|
|
26
28
|
}
|
|
27
|
-
if (
|
|
29
|
+
if (gulpConfig.get('browser.enabled')) {
|
|
28
30
|
// If not 'nodeOnly' then we also want to bundle for browser after we complete the dist directory
|
|
29
31
|
buildActions.push(bundle)
|
|
30
32
|
buildActions.push(bundleLintMinify)
|
|
@@ -32,13 +34,21 @@ const build = (done = null) => {
|
|
|
32
34
|
const runActions = [
|
|
33
35
|
series(...buildActions),
|
|
34
36
|
]
|
|
35
|
-
if (!gulpConfig.get('
|
|
37
|
+
if (!gulpConfig.get('typescript.enabled')) {
|
|
36
38
|
// Since we didn't run this in series after dist because of typescript, we need to run it now. Potentially faster here.
|
|
37
39
|
runActions.push(compileReadme)
|
|
38
40
|
}
|
|
39
41
|
runActions.push(testFull)
|
|
40
|
-
if (gulpConfig.get('
|
|
41
|
-
//
|
|
42
|
+
if (gulpConfig.get('fonts.enabled')) {
|
|
43
|
+
// Conditionally add Fonts process
|
|
44
|
+
runActions.push(copyFonts)
|
|
45
|
+
}
|
|
46
|
+
if (gulpConfig.get('images.enabled')) {
|
|
47
|
+
// Conditionally add Images process
|
|
48
|
+
runActions.push(images)
|
|
49
|
+
}
|
|
50
|
+
if (gulpConfig.get('sass.enabled')) {
|
|
51
|
+
// Conditionally add SASS process
|
|
42
52
|
runActions.push(sass)
|
|
43
53
|
}
|
|
44
54
|
return parallel(
|