js-build-tools 2.3.1 → 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 +12 -13
- package/dist/bundle.min.js +1 -1
- package/dist/bundleLint.js +17 -18
- package/dist/bundleLint.min.js +1 -1
- package/dist/bundleMinify.js +8 -9
- 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 +0 -1
- package/dist/distLint.js +17 -18
- package/dist/distLint.min.js +1 -1
- package/dist/distMinify.js +8 -9
- 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 +13 -14
- package/dist/partials/beginWatcher.js +9 -10
- package/dist/partials/clean.js +0 -1
- package/dist/partials/copyFor.js +16 -0
- package/dist/partials/distFor.js +16 -17
- package/dist/partials/distForSrc.js +9 -10
- package/dist/partials/distSeries.js +19 -20
- package/dist/partials/imagesFor.js +34 -0
- package/dist/partials/minifyFor.js +0 -1
- package/dist/partials/readmeTemplate.js +11 -12
- package/dist/partials/removeDirectory.js +5 -6
- package/dist/partials/runOnChange.js +27 -27
- package/dist/partials/sassFor.js +2 -3
- package/dist/partials/tsFor.js +20 -21
- package/dist/partials.js +5 -1
- package/dist/partials.min.js +1 -1
- package/dist/sass.js +7 -7
- package/dist/test-helpers/setUp.js +31 -39
- package/dist/testFull.js +17 -18
- package/dist/testFull.min.js +1 -1
- package/dist/testHelpers.js +10 -28
- package/dist/testHelpers.min.js +1 -1
- package/dist/testQuick.js +19 -20
- package/dist/testQuick.min.js +1 -1
- package/dist/typeScript.js +0 -1
- 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 +0 -1
- package/dist/watchTest.js +13 -14
- 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 +22 -23
- 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
package/functions/testQuick.js
CHANGED
|
@@ -4,12 +4,11 @@ const { runCLI } = require('jest')
|
|
|
4
4
|
/**
|
|
5
5
|
* Run the Jest tests for files which have been modified (based on git status).
|
|
6
6
|
* Configure where tests are located by using 'testPath'.
|
|
7
|
-
* @function
|
|
8
7
|
* @memberOf module:js-build-tools
|
|
9
8
|
* @returns {Promise<*>}
|
|
10
9
|
*/
|
|
11
10
|
const testQuick = () => {
|
|
12
|
-
let testPath = gulpConfig.get('
|
|
11
|
+
let testPath = gulpConfig.get('test.path')
|
|
13
12
|
if (!Array.isArray(testPath)) {
|
|
14
13
|
// The testPath must be an array of strings
|
|
15
14
|
testPath = [testPath]
|
|
@@ -11,6 +11,6 @@ describe('testQuick', () => {
|
|
|
11
11
|
test('runs the jest CLI with onlyChanged option', () => {
|
|
12
12
|
expect.assertions(1)
|
|
13
13
|
testQuick()
|
|
14
|
-
expect(runCLI).toHaveBeenCalledWith({ onlyChanged: true }, [gulpConfig.get('
|
|
14
|
+
expect(runCLI).toHaveBeenCalledWith({ onlyChanged: true }, [gulpConfig.get('test.path')])
|
|
15
15
|
})
|
|
16
16
|
})
|
package/functions/typeScript.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
const typeScript = require('./typeScript')
|
|
2
2
|
const tsFor = require('./partials/tsFor')
|
|
3
|
-
const { logObject } = require('./testHelpers')
|
|
4
3
|
jest.mock('./partials/tsFor', () => jest.fn(() => () => null))
|
|
5
4
|
|
|
6
5
|
describe('typeScript', () => {
|
|
7
6
|
test('calls tsFor with no parameters', () => {
|
|
8
|
-
logObject(typeScript, 'typescript')
|
|
9
7
|
typeScript()
|
|
10
8
|
expect(tsFor).toHaveBeenCalled()
|
|
11
9
|
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const isObject = require('./isObject')
|
|
2
|
+
const strAfter = require('common-exports/dist/utilities/strAfter').default
|
|
3
|
+
const strBefore = require('common-exports/dist/utilities/strBefore').default
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get a nested property value from an object.
|
|
7
|
+
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotGet.ts Sí, funciona}
|
|
8
|
+
* @param {Object} arrayObject - The array or object to get the property from
|
|
9
|
+
* @param {string} dotNotation - The path to the property
|
|
10
|
+
* @param {string|null} [defaultValue=null] - The default value to return if the property is not found
|
|
11
|
+
* @returns {*} The value of the property
|
|
12
|
+
*/
|
|
13
|
+
const dotGet = (arrayObject, dotNotation, defaultValue = null) => {
|
|
14
|
+
let key = strBefore(dotNotation, '.')
|
|
15
|
+
const lastKey = !key
|
|
16
|
+
if (lastKey) {
|
|
17
|
+
key = dotNotation
|
|
18
|
+
}
|
|
19
|
+
if (key === '*') {
|
|
20
|
+
const result = []
|
|
21
|
+
for (let wildKey in arrayObject) {
|
|
22
|
+
const wildValue = arrayObject[wildKey]
|
|
23
|
+
if (lastKey) {
|
|
24
|
+
result[wildKey] = wildValue
|
|
25
|
+
continue
|
|
26
|
+
}
|
|
27
|
+
if (!isObject(wildValue)) {
|
|
28
|
+
continue
|
|
29
|
+
}
|
|
30
|
+
result[wildKey] = dotGet(wildValue, strAfter(dotNotation, '.'), defaultValue)
|
|
31
|
+
}
|
|
32
|
+
return result
|
|
33
|
+
}
|
|
34
|
+
if (lastKey) {
|
|
35
|
+
return arrayObject[dotNotation] ?? defaultValue
|
|
36
|
+
}
|
|
37
|
+
if (typeof arrayObject[key] === 'undefined') {
|
|
38
|
+
return defaultValue
|
|
39
|
+
}
|
|
40
|
+
const next = arrayObject[key]
|
|
41
|
+
if (!isObject(next)) {
|
|
42
|
+
return defaultValue
|
|
43
|
+
}
|
|
44
|
+
return dotGet(next, strAfter(dotNotation, '.'), defaultValue)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = dotGet
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const isObject = require('./isObject')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Convert an array of keys into a regex, return a function to test if incoming keys match.
|
|
5
|
+
* @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
|
|
6
|
+
* @returns {Function} The dot-notated array
|
|
7
|
+
*/
|
|
8
|
+
const handleRetainObjects = (retainObjects = []) => {
|
|
9
|
+
if (!retainObjects.length) {
|
|
10
|
+
/**
|
|
11
|
+
* Bypass the test function if there are no retainObjects.
|
|
12
|
+
* @returns {false}
|
|
13
|
+
*/
|
|
14
|
+
return (currentKey, value, results) => false
|
|
15
|
+
}
|
|
16
|
+
retainObjects = retainObjects.map(key => key.replace('\.', '\\.'))
|
|
17
|
+
const retainRegex = new RegExp(`(${retainObjects.join('|')})$`)
|
|
18
|
+
/**
|
|
19
|
+
* Test if a key should be retained as an object.
|
|
20
|
+
* @param {string} currentKey - The key to test
|
|
21
|
+
* @param {*} value - The value of the key
|
|
22
|
+
* @param {Object} results - The result object to add to
|
|
23
|
+
* @returns {boolean}
|
|
24
|
+
*/
|
|
25
|
+
return (currentKey, value, results) => {
|
|
26
|
+
if (!currentKey.match(retainRegex)) {
|
|
27
|
+
return false
|
|
28
|
+
}
|
|
29
|
+
results[currentKey] = value
|
|
30
|
+
return true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The underlying logic function for converting arrays to dot-notation.
|
|
36
|
+
* @param {Object} arrayObject - The array or object to dot-notate
|
|
37
|
+
* @param {Function} didRetain - The test function to see if a key should be retained
|
|
38
|
+
* @param {string} [prepend=''] - The path for the property being processed
|
|
39
|
+
* @param {Object<string, *>} [results={}] - The final notated object to return
|
|
40
|
+
* @returns {Object<string, *>} The dot-notated object
|
|
41
|
+
*/
|
|
42
|
+
const performDotNotate = (arrayObject, didRetain, prepend = '', results = {}) => {
|
|
43
|
+
for (let key in arrayObject) {
|
|
44
|
+
const value = arrayObject[key]
|
|
45
|
+
const currentKey = `${prepend}${key}`
|
|
46
|
+
if (didRetain(currentKey, value, results)) {
|
|
47
|
+
continue
|
|
48
|
+
}
|
|
49
|
+
if (isObject(value)) {
|
|
50
|
+
performDotNotate(value, didRetain, `${currentKey}.`, results)
|
|
51
|
+
continue
|
|
52
|
+
}
|
|
53
|
+
results[currentKey] = value
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return results
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Convert an array or object to a single dimensional associative array with dot notation.
|
|
61
|
+
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotNotate.ts Sí, funciona}
|
|
62
|
+
* @param {Object} arrayObject - The array or object to dot-notate
|
|
63
|
+
* @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
|
|
64
|
+
* @returns {Object<string, *>} The dot-notated object
|
|
65
|
+
*/
|
|
66
|
+
const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects))
|
|
67
|
+
|
|
68
|
+
module.exports = dotNotate
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const isObject = require('./isObject')
|
|
2
|
+
const strAfter = require('common-exports/dist/utilities/strAfter').default
|
|
3
|
+
const strBefore = require('common-exports/dist/utilities/strBefore').default
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Set a nested property value an object.
|
|
7
|
+
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotSet.ts Sí, funciona}
|
|
8
|
+
* @param {Object} arrayObject - The array or object to set the property on
|
|
9
|
+
* @param {string} dotNotation - The path for the property
|
|
10
|
+
* @param {*} value - The default value to return if the property is not found
|
|
11
|
+
* @returns {Object} The modified object
|
|
12
|
+
*/
|
|
13
|
+
const dotSet = (arrayObject, dotNotation, value = null) => {
|
|
14
|
+
let key = strBefore(dotNotation, '.')
|
|
15
|
+
const lastKey = !key
|
|
16
|
+
if (lastKey) {
|
|
17
|
+
key = dotNotation
|
|
18
|
+
}
|
|
19
|
+
if (key === '*') {
|
|
20
|
+
for (let wildKey in arrayObject) {
|
|
21
|
+
if (lastKey) {
|
|
22
|
+
arrayObject[wildKey] = value
|
|
23
|
+
continue
|
|
24
|
+
}
|
|
25
|
+
if (!isObject(arrayObject[wildKey])) {
|
|
26
|
+
continue
|
|
27
|
+
}
|
|
28
|
+
dotSet(arrayObject[wildKey], strAfter(dotNotation, '.'), value)
|
|
29
|
+
}
|
|
30
|
+
return arrayObject
|
|
31
|
+
}
|
|
32
|
+
if (lastKey) {
|
|
33
|
+
arrayObject[dotNotation] = value
|
|
34
|
+
return arrayObject
|
|
35
|
+
}
|
|
36
|
+
const next = arrayObject[key] ?? []
|
|
37
|
+
arrayObject[key] = dotSet(next, strAfter(dotNotation, '.'), value)
|
|
38
|
+
return arrayObject
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = dotSet
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the provided thing is an object / array.
|
|
3
|
+
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/isObject.ts Sí, funciona}
|
|
4
|
+
* @param {*} object
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
const isObject = (object) => typeof object === 'object' && object !== null
|
|
8
|
+
|
|
9
|
+
module.exports = isObject
|
package/functions/watchFull.js
CHANGED
|
@@ -29,7 +29,7 @@ afterEach(setUp.afterEach)
|
|
|
29
29
|
describe('watchFull', () => {
|
|
30
30
|
test('should call beginWatcher and runOnChange for change event', () => {
|
|
31
31
|
const srcPath = gulpConfig.get('srcPath')
|
|
32
|
-
gulpConfig.set('
|
|
32
|
+
gulpConfig.set('test.watch', `${srcPath}/*.js`)
|
|
33
33
|
const srcFile = `${srcPath}/watchFull.js`
|
|
34
34
|
fs.writeFileSync(srcFile, rawContents)
|
|
35
35
|
expect.assertions(2)
|
package/functions/watchTest.js
CHANGED
|
@@ -4,10 +4,9 @@ const testQuick = require('./testQuick')
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Watch for changes and run the tests.
|
|
7
|
-
* @function
|
|
8
7
|
* @memberOf module:js-build-tools
|
|
9
8
|
* @returns {*}
|
|
10
9
|
*/
|
|
11
|
-
const watchTest = () => watch(gulpConfig.get('
|
|
10
|
+
const watchTest = () => watch(gulpConfig.get('test.watch'), { ignoreInitial: false }, testQuick)
|
|
12
11
|
|
|
13
12
|
module.exports = watchTest
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const setUp = require('./test-helpers/setUp')
|
|
2
2
|
setUp.setDefaults('test-watch-test')
|
|
3
3
|
const gulpConfig = setUp.gulpConfig
|
|
4
|
-
gulpConfig.set('
|
|
4
|
+
gulpConfig.set('test.watch', 'test-begin-watcher/*.js')
|
|
5
5
|
const watchTest = require('./watchTest')
|
|
6
6
|
const { EventEmitter } = require('node:events')
|
|
7
7
|
const fs = require('fs')
|
package/gulp.config.js
CHANGED
|
@@ -2,29 +2,11 @@
|
|
|
2
2
|
* Modify these configurations to match your project specifications.
|
|
3
3
|
* @file
|
|
4
4
|
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
5
|
-
* @version
|
|
5
|
+
* @version 3.0.0
|
|
6
6
|
* @module gulpConfig
|
|
7
7
|
* @memberOf module:js-build-tools
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* Retrieve a value from an object with the path (key), return a given default if the key is not found.
|
|
12
|
-
* @memberOf module:gulpConfig
|
|
13
|
-
* @param {Object<string, *>} [config=[]]
|
|
14
|
-
* @param {string|null} [path=null]
|
|
15
|
-
* @param {*} [defaultValue=null]
|
|
16
|
-
* @returns {*|null}
|
|
17
|
-
*/
|
|
18
|
-
const defaultConfig = (config = {}, path = null, defaultValue = null) => {
|
|
19
|
-
if (!path) {
|
|
20
|
-
return config
|
|
21
|
-
}
|
|
22
|
-
if (typeof config[path] === 'undefined') {
|
|
23
|
-
return defaultValue
|
|
24
|
-
}
|
|
25
|
-
return config[path]
|
|
26
|
-
}
|
|
27
|
-
|
|
28
10
|
/**
|
|
29
11
|
* A setting that may be an array of strings or a string only.
|
|
30
12
|
* @typedef {Array<string>|string} module:gulpConfig~ArrayableSetting
|
|
@@ -69,29 +51,95 @@ const defaultConfig = (config = {}, path = null, defaultValue = null) => {
|
|
|
69
51
|
* @typedef {ArrayableSetting|BooleanSetting|FlagsSetting|StringSetting} Setting
|
|
70
52
|
*/
|
|
71
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Configurations for building the browser files.
|
|
56
|
+
* @typedef {Object<string, Setting>} module:gulpConfig~BrowserConfig
|
|
57
|
+
* @property {BooleanSetting} enabled - 'true' to generate browser bundled files; 'false' for node environment only
|
|
58
|
+
* @property {StringSetting} from - The name to use for the browser-bundled output file (.js will be appended).
|
|
59
|
+
* @property {StringSetting} name - The search pattern used for retrieving compiled distribution files.
|
|
60
|
+
* @property {StringSetting} to - The output directory for browser-bundled files.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Configurations for building the node distribution files.
|
|
65
|
+
* @typedef {Object<string, Setting>} module:gulpConfig~DistConfig
|
|
66
|
+
* @property {StringSetting} from - The search pattern used for gathering source files for distribution.
|
|
67
|
+
* @property {StringSetting} main - Name of the entry the distribution file.
|
|
68
|
+
* @property {StringSetting} to - The output directory for the distribution files.
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Configurations for copying the font files.
|
|
73
|
+
* @typedef {Object<string, Setting>} module:gulpConfig~FontConfig
|
|
74
|
+
* @property {BooleanSetting} enabled - Toggle copy directory of fonts on.
|
|
75
|
+
* @property {StringSetting} from - Path to search for fonts.
|
|
76
|
+
* @property {StringSetting} to - Path to output fonts.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Configurations to minify and copy the images.
|
|
81
|
+
* @typedef {Object<string, Setting>} module:gulpConfig~ImageConfig
|
|
82
|
+
* @property {BooleanSetting} enabled - Toggle image minify and copy process.
|
|
83
|
+
* @property {StringSetting} from - Path to search for images.
|
|
84
|
+
* @property {StringSetting} to - Path to output images.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Configurations to compile and generate the Readme file.
|
|
89
|
+
* @typedef {Object<string, Setting>} module:gulpConfig~ReadmeConfig
|
|
90
|
+
* @property {StringSetting} file - The name of the output documentation markdown file.
|
|
91
|
+
* @property {StringSetting} from - Location of files to use for compiling documentation into the readme.
|
|
92
|
+
* @property {ArrayableSetting} options - Options for formatting the output readme.
|
|
93
|
+
* @property {StringSetting} template - The file which will be pre-fixed to your README.md output.
|
|
94
|
+
* @property {StringSetting} to - The directory to output the readme file in.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Configurations to compile and copy the sass files into css.
|
|
99
|
+
* @typedef {Object<string, Setting>} module:gulpConfig~SassConfig
|
|
100
|
+
* @property {BooleanSetting} enabled - Toggle SASS to CSS process on.
|
|
101
|
+
* @property {StringSetting} from - The pattern for finding all sass files.
|
|
102
|
+
* @property {StringSetting} path - The directory were sass files will be stored.
|
|
103
|
+
* @property {StringSetting} to - The destination path for where generated CSS (from SASS files) should go.
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Configurations for running the test suite.
|
|
108
|
+
* @typedef {Object<string, Setting>} module:gulpConfig~TestConfig
|
|
109
|
+
* @property {JestTestFlags} options - Additional flags for programmatically running Jest Cli.
|
|
110
|
+
* @property {ArrayableSetting} path - The directory where Jest test files are stored.
|
|
111
|
+
* By default, stored as *.test.js adjacent to the files they are testing.
|
|
112
|
+
* @property {ArrayableSetting} watch - The search pattern for watching files for changes.
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Configurations for compiling typescript into JS files.
|
|
117
|
+
* @typedef {Object<string, Setting>} module:gulpConfig~TsConfig
|
|
118
|
+
* @property {FlagStringSetting} config - The path the tsconfig file for running typescript or false if no ts file given.
|
|
119
|
+
* @property {BooleanSetting} enabled - Toggle usage of typescript parsing.
|
|
120
|
+
* @property {StringSetting} from - Pattern for finding the TypeScript files.
|
|
121
|
+
* @property {StringSetting} to - Directory where parsed typescript files go.
|
|
122
|
+
*/
|
|
123
|
+
|
|
72
124
|
/**
|
|
73
125
|
* A set of Configurations options defined by Settings.
|
|
74
126
|
* @typedef {Object<string, Setting>} module:gulpConfig~Configurations
|
|
75
|
-
* @property {
|
|
76
|
-
* @property {
|
|
77
|
-
* @property {
|
|
78
|
-
* @property {
|
|
79
|
-
* @property {
|
|
80
|
-
* @property {
|
|
81
|
-
* @property {StringSetting}
|
|
82
|
-
* @property {
|
|
83
|
-
* @property {StringSetting}
|
|
84
|
-
* @property {
|
|
85
|
-
* @property {
|
|
86
|
-
* @property {StringSetting} rootPath
|
|
87
|
-
* @property {StringSetting} srcPath
|
|
88
|
-
* @property {ArrayableSetting} srcSearch
|
|
89
|
-
* @property {JestTestFlags} testOptions
|
|
90
|
-
* @property {ArrayableSetting} testPath
|
|
91
|
-
* @property {FlagStringSetting} useTsConfig
|
|
92
|
-
* @property {ArrayableSetting} watchSearch
|
|
127
|
+
* @property {BrowserConfig} browser - Browser bundling configuration group.
|
|
128
|
+
* @property {ArrayableSetting} cleanPaths - The paths for directories to delete before build.
|
|
129
|
+
* @property {DistConfig} dist - Distribution file generation configuration group.
|
|
130
|
+
* @property {FontConfig} fonts - Fonts copy configuration group.
|
|
131
|
+
* @property {ImageConfig} images - Minify and copy the images configuration.
|
|
132
|
+
* @property {ReadmeConfig} readme - Build readme files configuration.
|
|
133
|
+
* @property {StringSetting} rootPath - Base directory of the project.
|
|
134
|
+
* @property {SassConfig} sass - Compile CSS from SASS configuration.
|
|
135
|
+
* @property {StringSetting} srcPath - The directory where your source files are stored (the files you manually created).
|
|
136
|
+
* @property {TestConfig} test - Run test suite configuration.
|
|
137
|
+
* @property {TsConfig} typescript - Compile from typescript configuration.
|
|
93
138
|
*/
|
|
94
139
|
|
|
140
|
+
const dotGet = require('./functions/utilities/dotGet')
|
|
141
|
+
const dotSet = require('./functions/utilities/dotSet')
|
|
142
|
+
const dotNotate = require('./functions/utilities/dotNotate')
|
|
95
143
|
/**
|
|
96
144
|
* All the available configuration setting options for running the build.
|
|
97
145
|
* @memberOf module:gulpConfig` `
|
|
@@ -110,71 +158,97 @@ try {
|
|
|
110
158
|
}
|
|
111
159
|
|
|
112
160
|
const setDefaults = {
|
|
113
|
-
|
|
114
|
-
|
|
161
|
+
browser: {
|
|
162
|
+
enabled: true,
|
|
163
|
+
from: 'dist/**/*.js',
|
|
164
|
+
name: 'default',
|
|
165
|
+
to: 'browser',
|
|
166
|
+
},
|
|
115
167
|
cleanPaths: ['dist', 'browser'],
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
168
|
+
dist: {
|
|
169
|
+
from: 'src/**/!(*.test).js',
|
|
170
|
+
main: 'dist/main',
|
|
171
|
+
to: 'dist',
|
|
172
|
+
},
|
|
173
|
+
fonts: {
|
|
174
|
+
enabled: false,
|
|
175
|
+
from: 'src/fonts/**/*',
|
|
176
|
+
to: 'browser/fonts',
|
|
177
|
+
},
|
|
178
|
+
images: {
|
|
179
|
+
enabled: false,
|
|
180
|
+
from: 'src/img/**/*.+(png|jpg|jpeg|gif|svg)',
|
|
181
|
+
to: 'browser/img',
|
|
182
|
+
},
|
|
183
|
+
readme: {
|
|
184
|
+
file: 'README.md',
|
|
185
|
+
from: 'src/**/!(*.test).js',
|
|
186
|
+
options: 'utf8',
|
|
187
|
+
template: 'MAIN.md',
|
|
188
|
+
to: './'
|
|
189
|
+
},
|
|
126
190
|
rootPath: './',
|
|
127
|
-
|
|
128
|
-
|
|
191
|
+
sass: {
|
|
192
|
+
enabled: false,
|
|
193
|
+
from: 'sass/**/*.+(scss|sass)',
|
|
194
|
+
path: 'sass',
|
|
195
|
+
to: 'browser/css',
|
|
196
|
+
},
|
|
129
197
|
srcPath: 'src',
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
198
|
+
test: {
|
|
199
|
+
options: {
|
|
200
|
+
clearCache: false,
|
|
201
|
+
debug: false,
|
|
202
|
+
ignoreProjects: false,
|
|
203
|
+
json: false,
|
|
204
|
+
selectProjects: false,
|
|
205
|
+
showConfig: false,
|
|
206
|
+
useStderr: false,
|
|
207
|
+
watch: false,
|
|
208
|
+
watchAll: false,
|
|
209
|
+
},
|
|
210
|
+
path: ['src'],
|
|
211
|
+
watch: 'src/**/*.js'
|
|
212
|
+
},
|
|
213
|
+
typescript: {
|
|
214
|
+
config: false,
|
|
215
|
+
enabled: false,
|
|
216
|
+
from: 'src/**/*.ts',
|
|
217
|
+
to: 'dist',
|
|
141
218
|
},
|
|
142
|
-
testPath: ['src'],
|
|
143
|
-
tsSearch: 'src/**/*.ts',
|
|
144
|
-
useSass: false,
|
|
145
|
-
useTsConfig: false,
|
|
146
|
-
watchSearch: 'src/**/*.js'
|
|
147
219
|
}
|
|
148
220
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
221
|
+
const notation = dotNotate(setDefaults)
|
|
222
|
+
for (let notationKey in notation) {
|
|
223
|
+
const arrayEnding = /(\.\d+)$/
|
|
224
|
+
if (arrayEnding.test(notationKey)) {
|
|
225
|
+
// ends in number a key then it must be an array; use the entire array
|
|
226
|
+
notationKey = notationKey.replace(arrayEnding, '')
|
|
227
|
+
}
|
|
228
|
+
const defaultValue = dotGet(setDefaults, notationKey)
|
|
229
|
+
const existingConfig = dotGet(gulpConfigurations, notationKey, defaultValue)
|
|
230
|
+
dotSet(gulpConfigurations, notationKey, existingConfig)
|
|
231
|
+
}
|
|
152
232
|
|
|
153
233
|
/**
|
|
154
|
-
* Retrieve a value from
|
|
155
|
-
* @function
|
|
234
|
+
* Retrieve a value from the configurations, default may be returned.
|
|
156
235
|
* @memberOf module:gulpConfig
|
|
157
236
|
* @param {string|null} path
|
|
158
237
|
* @param {*} defaultValue
|
|
159
238
|
* @returns {*|null}
|
|
160
239
|
*/
|
|
161
|
-
const get = (path = null, defaultValue = null) =>
|
|
240
|
+
const get = (path = null, defaultValue = null) => dotGet(gulpConfigurations, path, defaultValue)
|
|
162
241
|
|
|
163
242
|
/**
|
|
164
243
|
* Specify a value for the configurations to use.
|
|
165
|
-
* @function
|
|
166
244
|
* @memberOf module:gulpConfig
|
|
167
245
|
* @param path
|
|
168
246
|
* @param value
|
|
169
247
|
* @returns {*}
|
|
170
248
|
*/
|
|
171
|
-
const set = (path, value) =>
|
|
172
|
-
gulpConfigurations[path] = value
|
|
173
|
-
return value
|
|
174
|
-
}
|
|
249
|
+
const set = (path, value) => dotSet(gulpConfigurations, path, value)
|
|
175
250
|
|
|
176
251
|
module.exports = {
|
|
177
|
-
defaultConfig,
|
|
178
252
|
get,
|
|
179
253
|
set
|
|
180
254
|
}
|
package/gulpfile.base.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Export these functions to your own project in order to customize your build pipeline.
|
|
3
3
|
* @file
|
|
4
4
|
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
5
|
-
* @version
|
|
5
|
+
* @version 3.0.0
|
|
6
6
|
* @module js-build-tools
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -11,11 +11,13 @@ const bundle = require('./functions/bundle.js')
|
|
|
11
11
|
const bundleLint = require('./functions/bundleLint.js')
|
|
12
12
|
const bundleMinify = require('./functions/bundleMinify.js')
|
|
13
13
|
const compileReadme = require('./functions/compileReadme.js')
|
|
14
|
+
const copyFonts = require('./functions/copyFonts.js')
|
|
14
15
|
const defaultCmd = require('./functions/default.js')
|
|
15
16
|
const dist = require('./functions/dist.js')
|
|
16
17
|
const distLint = require('./functions/distLint.js')
|
|
17
18
|
const distMinify = require('./functions/distMinify.js')
|
|
18
19
|
const gulpConfig = require('./gulp.config.js')
|
|
20
|
+
const images = require('./functions/images.js')
|
|
19
21
|
const partials = require('./functions/partials.js')
|
|
20
22
|
const sass = require('./functions/sass.js')
|
|
21
23
|
const testFull = require('./functions/testFull.js')
|
|
@@ -30,11 +32,13 @@ module.exports = {
|
|
|
30
32
|
bundle,
|
|
31
33
|
bundleLint,
|
|
32
34
|
bundleMinify,
|
|
35
|
+
copyFonts,
|
|
33
36
|
defaultCmd,
|
|
34
37
|
dist,
|
|
35
38
|
distLint,
|
|
36
39
|
distMinify,
|
|
37
40
|
gulpConfig,
|
|
41
|
+
images,
|
|
38
42
|
partials,
|
|
39
43
|
readme: compileReadme,
|
|
40
44
|
sass,
|
package/jsdoc.base.js
CHANGED
|
@@ -3,7 +3,7 @@ const gulpConfig = require('./gulp.config.js')
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
plugins: ['plugins/markdown'],
|
|
5
5
|
source: {
|
|
6
|
-
include: gulpConfig.get('
|
|
6
|
+
include: [gulpConfig.get('dist.to')],
|
|
7
7
|
includePattern: '.+\\.js(doc|x)?$',
|
|
8
8
|
excludePattern: '((^|\\/|\\\\)_|.+\\.test\\..*)'
|
|
9
9
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-build-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Standardised build process with gulp.",
|
|
5
5
|
"main": "gulpfile.base.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"dev": "gulp",
|
|
9
9
|
"htmldocs": "jsdoc -R MAIN.md -c ./.jsdoc.conf.js -d docs",
|
|
10
10
|
"readme": "gulp readme",
|
|
11
|
-
"resolutions": "npx npm-force-resolutions",
|
|
12
11
|
"test": "gulp testFull",
|
|
13
12
|
"test:quick": "gulp testQuick",
|
|
14
13
|
"watch": "gulp watchFull",
|
|
@@ -33,19 +32,22 @@
|
|
|
33
32
|
]
|
|
34
33
|
},
|
|
35
34
|
"dependencies": {
|
|
36
|
-
"@babel/core": "^7.23.
|
|
35
|
+
"@babel/core": "^7.23.9",
|
|
37
36
|
"@babel/plugin-proposal-throw-expressions": "^7.23.3",
|
|
38
|
-
"@babel/preset-env": "^7.23.
|
|
37
|
+
"@babel/preset-env": "^7.23.9",
|
|
39
38
|
"@babel/preset-typescript": "^7.23.3",
|
|
40
|
-
"@babel/runtime-corejs3": "^7.23.
|
|
39
|
+
"@babel/runtime-corejs3": "^7.23.9",
|
|
41
40
|
"babel-jest": "^29.7.0",
|
|
42
41
|
"browserify": "^17.0.0",
|
|
43
|
-
"
|
|
42
|
+
"common-exports": "^1.0.1",
|
|
43
|
+
"core-js": "^3.35.1",
|
|
44
44
|
"fs": "^0.0.1-security",
|
|
45
45
|
"glob": "^10.3.10",
|
|
46
46
|
"gulp": "^4.0.2",
|
|
47
47
|
"gulp-babel": "^8.0.0",
|
|
48
|
+
"gulp-cache": "^1.1.3",
|
|
48
49
|
"gulp-cssnano": "^2.1.3",
|
|
50
|
+
"gulp-imagemin": "^9.0.0",
|
|
49
51
|
"gulp-rename": "^2.0.0",
|
|
50
52
|
"gulp-sass": "^5.1.0",
|
|
51
53
|
"gulp-standard": "^14.0.0",
|
|
@@ -53,9 +55,10 @@
|
|
|
53
55
|
"gulp-uglify-es": "^3.0.0",
|
|
54
56
|
"jest": "^29.7.0",
|
|
55
57
|
"jest-environment-jsdom": "^29.7.0",
|
|
56
|
-
"jsdoc-to-markdown": "^8.0.
|
|
58
|
+
"jsdoc-to-markdown": "^8.0.1",
|
|
57
59
|
"regenerator-runtime": "^0.14.1",
|
|
58
|
-
"sass": "^1.
|
|
60
|
+
"sass": "^1.70.0",
|
|
61
|
+
"test-filesystem": "^1.2.0",
|
|
59
62
|
"vinyl-source-stream": "^2.0.0"
|
|
60
63
|
},
|
|
61
64
|
"files": [
|
|
@@ -64,7 +67,8 @@
|
|
|
64
67
|
"functions",
|
|
65
68
|
"gulpfile.base.js",
|
|
66
69
|
"gulp.config.js",
|
|
67
|
-
"jsdoc.base.js"
|
|
70
|
+
"jsdoc.base.js",
|
|
71
|
+
"vendor"
|
|
68
72
|
],
|
|
69
73
|
"funding": "https://www.paypal.com/donate/?business=LRYR6SZRWKXVY&no_recurring=0&item_name=Let%27s+build+together+today+to+simplify+our+jobs+tomorrow.¤cy_code=CAD"
|
|
70
74
|
}
|