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.
Files changed (198) hide show
  1. package/README.md +334 -205
  2. package/dist/build.js +16 -5
  3. package/dist/build.min.js +1 -1
  4. package/dist/bundle.js +1 -2
  5. package/dist/bundle.min.js +1 -1
  6. package/dist/bundleLint.js +2 -3
  7. package/dist/bundleLint.min.js +1 -1
  8. package/dist/bundleMinify.js +1 -2
  9. package/dist/bundleMinify.min.js +1 -1
  10. package/dist/copyFonts.js +12 -0
  11. package/dist/copyFonts.min.js +1 -0
  12. package/dist/default.js +15 -15
  13. package/dist/default.min.js +1 -1
  14. package/dist/dist.js +7 -8
  15. package/dist/distLint.js +2 -3
  16. package/dist/distLint.min.js +1 -1
  17. package/dist/distMinify.js +1 -2
  18. package/dist/distMinify.min.js +1 -1
  19. package/dist/images.js +11 -0
  20. package/dist/images.min.js +1 -0
  21. package/dist/partials/addToReadme.js +2 -3
  22. package/dist/partials/beginWatcher.js +1 -2
  23. package/dist/partials/clean.js +10 -11
  24. package/dist/partials/copyFor.js +16 -0
  25. package/dist/partials/distFor.js +1 -2
  26. package/dist/partials/distForSrc.js +2 -3
  27. package/dist/partials/distSeries.js +3 -4
  28. package/dist/partials/imagesFor.js +34 -0
  29. package/dist/partials/minifyFor.js +15 -16
  30. package/dist/partials/readmeTemplate.js +1 -2
  31. package/dist/partials/removeDirectory.js +11 -12
  32. package/dist/partials/runOnChange.js +7 -7
  33. package/dist/partials/sassFor.js +2 -3
  34. package/dist/partials/tsFor.js +4 -5
  35. package/dist/partials.js +5 -1
  36. package/dist/partials.min.js +1 -1
  37. package/dist/test-helpers/setUp.js +31 -39
  38. package/dist/testFull.js +2 -3
  39. package/dist/testFull.min.js +1 -1
  40. package/dist/testHelpers.js +2 -20
  41. package/dist/testHelpers.min.js +1 -1
  42. package/dist/testQuick.js +1 -2
  43. package/dist/testQuick.min.js +1 -1
  44. package/dist/typeScript.js +7 -8
  45. package/dist/utilities/dotGet.js +50 -0
  46. package/dist/utilities/dotNotate.js +77 -0
  47. package/dist/utilities/dotSet.js +44 -0
  48. package/dist/utilities/isObject.js +10 -0
  49. package/dist/watchFull.js +10 -11
  50. package/dist/watchTest.js +1 -2
  51. package/dist/watchTest.min.js +1 -1
  52. package/functions/build.js +15 -5
  53. package/functions/build.test.js +278 -42
  54. package/functions/bundle.js +3 -4
  55. package/functions/bundle.test.js +6 -6
  56. package/functions/bundleLint.js +2 -3
  57. package/functions/bundleLint.test.js +5 -5
  58. package/functions/bundleMinify.js +1 -2
  59. package/functions/bundleMinify.test.js +1 -1
  60. package/functions/copyFonts.js +11 -0
  61. package/functions/copyFonts.test.js +31 -0
  62. package/functions/default.js +1 -1
  63. package/functions/default.test.js +2 -2
  64. package/functions/dist.js +0 -1
  65. package/functions/dist.test.js +1 -1
  66. package/functions/distLint.js +2 -3
  67. package/functions/distLint.test.js +3 -3
  68. package/functions/distMinify.js +1 -2
  69. package/functions/distMinify.test.js +1 -1
  70. package/functions/images.js +10 -0
  71. package/functions/images.test.js +138 -0
  72. package/functions/partials/addToReadme.js +2 -3
  73. package/functions/partials/addToReadme.test.js +2 -2
  74. package/functions/partials/beginWatcher.js +1 -2
  75. package/functions/partials/beginWatcher.test.js +1 -1
  76. package/functions/partials/clean.js +0 -1
  77. package/functions/partials/copyFor.js +13 -0
  78. package/functions/partials/copyFor.test.js +34 -0
  79. package/functions/partials/distFor.js +1 -2
  80. package/functions/partials/distFor.test.js +4 -4
  81. package/functions/partials/distForSrc.js +3 -4
  82. package/functions/partials/distForSrc.test.js +6 -6
  83. package/functions/partials/distSeries.js +2 -3
  84. package/functions/partials/distSeries.test.js +5 -5
  85. package/functions/partials/imagesFor.js +33 -0
  86. package/functions/partials/imagesFor.test.js +143 -0
  87. package/functions/partials/minifyFor.js +0 -1
  88. package/functions/partials/minifyFor.test.js +1 -1
  89. package/functions/partials/readmeTemplate.js +3 -4
  90. package/functions/partials/readmeTemplate.test.js +2 -2
  91. package/functions/partials/removeDirectory.js +0 -1
  92. package/functions/partials/runOnChange.js +5 -6
  93. package/functions/partials/runOnChange.test.js +9 -9
  94. package/functions/partials/sassFor.js +1 -2
  95. package/functions/partials/sassFor.test.js +3 -3
  96. package/functions/partials/tsFor.js +3 -4
  97. package/functions/partials/tsFor.test.js +2 -2
  98. package/functions/partials.js +5 -1
  99. package/functions/partials.test.js +1 -1
  100. package/functions/sass.test.js +2 -2
  101. package/functions/test-helpers/setUp.js +24 -32
  102. package/functions/testFull.js +2 -3
  103. package/functions/testFull.test.js +1 -1
  104. package/functions/testHelpers.js +3 -20
  105. package/functions/testHelpers.test.js +1 -1
  106. package/functions/testQuick.js +1 -2
  107. package/functions/testQuick.test.js +1 -1
  108. package/functions/typeScript.js +0 -1
  109. package/functions/typeScript.test.js +0 -2
  110. package/functions/utilities/dotGet.js +47 -0
  111. package/functions/utilities/dotNotate.js +68 -0
  112. package/functions/utilities/dotSet.js +41 -0
  113. package/functions/utilities/isObject.js +9 -0
  114. package/functions/watchFull.js +0 -1
  115. package/functions/watchFull.test.js +1 -1
  116. package/functions/watchTest.js +1 -2
  117. package/functions/watchTest.test.js +1 -1
  118. package/gulp.config.js +153 -79
  119. package/gulpfile.base.js +5 -1
  120. package/jsdoc.base.js +1 -1
  121. package/package.json +13 -9
  122. package/vendor/array-union/index.js +31 -0
  123. package/vendor/easy-transform-stream/index.js +58 -0
  124. package/vendor/globby/gitignore.js +100 -0
  125. package/vendor/globby/index.js +195 -0
  126. package/vendor/globby/node_modules/slash/index.js +16 -0
  127. package/vendor/globby/stream-utils.js +58 -0
  128. package/vendor/globby/to-path.js +20 -0
  129. package/vendor/gulp-imagemin/index.js +128 -0
  130. package/vendor/gulp-imagemin/node_modules/chalk/source/index.js +265 -0
  131. package/vendor/gulp-imagemin/node_modules/chalk/source/utilities.js +36 -0
  132. package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
  133. package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
  134. package/vendor/gulp-plugin-extras/index.js +46 -0
  135. package/vendor/gulp-plugin-extras/node_modules/chalk/source/index.js +265 -0
  136. package/vendor/gulp-plugin-extras/node_modules/chalk/source/utilities.js +36 -0
  137. package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
  138. package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
  139. package/vendor/gulp-plugin-extras/plugin-error.js +145 -0
  140. package/vendor/ignore/index.js +468 -0
  141. package/vendor/imagemin/index.js +94 -0
  142. package/vendor/imagemin-gifsicle/index.js +37 -0
  143. package/vendor/imagemin-mozjpeg/index.js +104 -0
  144. package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +264 -0
  145. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/command.js +47 -0
  146. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/error.js +102 -0
  147. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +123 -0
  148. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/promise.js +47 -0
  149. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stdio.js +50 -0
  150. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +128 -0
  151. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/core.js +238 -0
  152. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/main.js +89 -0
  153. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/realtime.js +24 -0
  154. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/signals.js +44 -0
  155. package/vendor/imagemin-mozjpeg/node_modules/is-stream/index.js +25 -0
  156. package/vendor/imagemin-mozjpeg/node_modules/mimic-fn/index.js +70 -0
  157. package/vendor/imagemin-mozjpeg/node_modules/npm-run-path/index.js +52 -0
  158. package/vendor/imagemin-mozjpeg/node_modules/onetime/index.js +43 -0
  159. package/vendor/imagemin-mozjpeg/node_modules/path-key/index.js +20 -0
  160. package/vendor/imagemin-mozjpeg/node_modules/strip-final-newline/index.js +17 -0
  161. package/vendor/imagemin-optipng/index.js +44 -0
  162. package/vendor/imagemin-svgo/index.js +27 -0
  163. package/vendor/is-jpg/index.js +12 -0
  164. package/vendor/junk/index.js +49 -0
  165. package/vendor/mozjpeg/index.js +9 -0
  166. package/vendor/mozjpeg/lib/index.js +18 -0
  167. package/vendor/mozjpeg/package.json +50 -0
  168. package/vendor/p-pipe/index.js +26 -0
  169. package/vendor/plur/index.js +32 -0
  170. package/vendor/pretty-bytes/index.js +71 -0
  171. package/vendor/slash/index.js +12 -0
  172. package/dist/test-helpers/circularObject.js +0 -50
  173. package/dist/test-helpers/countMatches.js +0 -12
  174. package/dist/test-helpers/deepReferenceObject.js +0 -20
  175. package/dist/test-helpers/domItem.js +0 -33
  176. package/dist/test-helpers/jsonDom.js +0 -20
  177. package/dist/test-helpers/linkedList.js +0 -23
  178. package/dist/test-helpers/logObject.js +0 -21
  179. package/dist/test-helpers/multiReferenceObject.js +0 -20
  180. package/dist/test-helpers/nodeTree.js +0 -28
  181. package/functions/test-helpers/circularObject.js +0 -28
  182. package/functions/test-helpers/circularObject.test.js +0 -14
  183. package/functions/test-helpers/countMatches.js +0 -11
  184. package/functions/test-helpers/countMatches.test.js +0 -9
  185. package/functions/test-helpers/deepReferenceObject.js +0 -25
  186. package/functions/test-helpers/deepReferenceObject.test.js +0 -7
  187. package/functions/test-helpers/domItem.js +0 -31
  188. package/functions/test-helpers/domItem.test.js +0 -12
  189. package/functions/test-helpers/jsonDom.js +0 -16
  190. package/functions/test-helpers/jsonDom.test.js +0 -12
  191. package/functions/test-helpers/linkedList.js +0 -10
  192. package/functions/test-helpers/linkedList.test.js +0 -22
  193. package/functions/test-helpers/logObject.js +0 -18
  194. package/functions/test-helpers/logObject.test.js +0 -20
  195. package/functions/test-helpers/multiReferenceObject.js +0 -25
  196. package/functions/test-helpers/multiReferenceObject.test.js +0 -14
  197. package/functions/test-helpers/nodeTree.js +0 -11
  198. package/functions/test-helpers/nodeTree.test.js +0 -18
@@ -2,7 +2,6 @@ const tsFor = require('./partials/tsFor')
2
2
 
3
3
  /**
4
4
  * Simplified typescript task using tsFor.
5
- * @function
6
5
  * @memberOf module:js-build-tools
7
6
  * @returns {Function}
8
7
  */
@@ -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
@@ -2,7 +2,6 @@ const { beginWatcher, runOnChange } = require('./partials')
2
2
 
3
3
  /**
4
4
  * Watch for changes and run the distribution for the changed files, then bundle and test the changed files.
5
- * @function
6
5
  * @memberOf module:js-build-tools
7
6
  * @returns {FSWatcher}
8
7
  */
@@ -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('watchSearch', `${srcPath}/*.js`)
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)
@@ -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('watchSearch'), { ignoreInitial: false }, testQuick)
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('watchSearch', 'test-begin-watcher/*.js')
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 2.0.0
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 {StringSetting} browserName
76
- * @property {StringSetting} browserPath
77
- * @property {StringSetting} distMain
78
- * @property {StringSetting} distPath
79
- * @property {ArrayableSetting} distSearch
80
- * @property {BooleanSetting} nodeOnly
81
- * @property {StringSetting} readmeTemplate
82
- * @property {ArrayableSetting} readmeOptions
83
- * @property {StringSetting} readmeFile
84
- * @property {StringSetting} readmePath
85
- * @property {ArrayableSetting} readmeSearch
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
- browserName: 'default',
114
- browserPath: 'browser',
161
+ browser: {
162
+ enabled: true,
163
+ from: 'dist/**/*.js',
164
+ name: 'default',
165
+ to: 'browser',
166
+ },
115
167
  cleanPaths: ['dist', 'browser'],
116
- cssPath: 'browser/css',
117
- distMain: 'dist/main',
118
- distPath: 'dist',
119
- distSearch: 'dist/**/*.js',
120
- nodeOnly: false,
121
- readmeTemplate: 'MAIN.md',
122
- readmeOptions: 'utf8',
123
- readmeFile: 'README.md',
124
- readmePath: './',
125
- readmeSearch: 'src/**/!(*.test).js',
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
- sassPath: 'sass',
128
- sassSearch: 'sass/**/*.+(scss|sass)',
191
+ sass: {
192
+ enabled: false,
193
+ from: 'sass/**/*.+(scss|sass)',
194
+ path: 'sass',
195
+ to: 'browser/css',
196
+ },
129
197
  srcPath: 'src',
130
- srcSearch: 'src/**/!(*.test).js',
131
- testOptions: {
132
- clearCache: false,
133
- debug: false,
134
- ignoreProjects: false,
135
- json: false,
136
- selectProjects: false,
137
- showConfig: false,
138
- useStderr: false,
139
- watch: false,
140
- watchAll: false,
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
- Object.keys(setDefaults).forEach(parentKey => {
150
- gulpConfigurations[parentKey] = defaultConfig(gulpConfigurations, parentKey, setDefaults[parentKey])
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 teh configurations, default may be returned.
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) => defaultConfig(gulpConfigurations, path, defaultValue)
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 2.0.0
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('distPath'),
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": "2.4.0",
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.7",
35
+ "@babel/core": "^7.23.9",
37
36
  "@babel/plugin-proposal-throw-expressions": "^7.23.3",
38
- "@babel/preset-env": "^7.23.7",
37
+ "@babel/preset-env": "^7.23.9",
39
38
  "@babel/preset-typescript": "^7.23.3",
40
- "@babel/runtime-corejs3": "^7.23.7",
39
+ "@babel/runtime-corejs3": "^7.23.9",
41
40
  "babel-jest": "^29.7.0",
42
41
  "browserify": "^17.0.0",
43
- "core-js": "^3.35.0",
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.0",
58
+ "jsdoc-to-markdown": "^8.0.1",
57
59
  "regenerator-runtime": "^0.14.1",
58
- "sass": "^1.69.7",
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.&currency_code=CAD"
70
74
  }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ require("core-js/modules/es.array.unscopables.flat.js");
8
+ require("core-js/modules/esnext.set.add-all.js");
9
+ require("core-js/modules/esnext.set.delete-all.js");
10
+ require("core-js/modules/esnext.set.difference.js");
11
+ require("core-js/modules/esnext.set.every.js");
12
+ require("core-js/modules/esnext.set.filter.js");
13
+ require("core-js/modules/esnext.set.find.js");
14
+ require("core-js/modules/esnext.set.intersection.js");
15
+ require("core-js/modules/esnext.set.is-disjoint-from.js");
16
+ require("core-js/modules/esnext.set.is-subset-of.js");
17
+ require("core-js/modules/esnext.set.is-superset-of.js");
18
+ require("core-js/modules/esnext.set.join.js");
19
+ require("core-js/modules/esnext.set.map.js");
20
+ require("core-js/modules/esnext.set.reduce.js");
21
+ require("core-js/modules/esnext.set.some.js");
22
+ require("core-js/modules/esnext.set.symmetric-difference.js");
23
+ require("core-js/modules/esnext.set.union.js");
24
+ require("core-js/modules/web.dom-collections.iterator.js");
25
+ const arrayUnion = function () {
26
+ for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) {
27
+ arguments_[_key] = arguments[_key];
28
+ }
29
+ return [...new Set(arguments_.flat())];
30
+ };
31
+ var _default = exports.default = arrayUnion;