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
@@ -1,77 +1,69 @@
1
1
  "use strict";
2
2
 
3
- const fs = require('fs');
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
- removeDirectory
8
- } = require('../partials');
6
+ setUp
7
+ } = require('test-filesystem');
9
8
  let tempDir = 'test-temp/';
10
- let srcPath = `${tempDir}src`;
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 = `${testDir}/`;
21
- srcPath = `${tempDir}src`;
22
- const distPath = `${tempDir}dist`;
23
- const browserPath = `${tempDir}browser`;
24
- const sassPath = `${tempDir}sass`;
25
- gulpConfig.set('browserPath', browserPath);
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('cssPath', `${browserPath}/css`);
28
- gulpConfig.set('distMain', `${distPath}/main`);
29
- gulpConfig.set('distPath', distPath);
30
- gulpConfig.set('distSearch', `${distPath}/**/*.js`);
31
- gulpConfig.set('readmeTemplate', `${tempDir}MAIN.md`);
32
- gulpConfig.set('readmePath', tempDir);
33
- gulpConfig.set('readmeSearch', `${srcPath}/**/!(*.test).js`);
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('sassPath', sassPath);
36
- gulpConfig.set('sassSearch', `${sassPath}/**/*.+(scss|sass)`);
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('srcSearch', `${srcPath}/**/!(*.test).js`);
39
- gulpConfig.set('tsSearch', `${srcPath}/**/*.ts`);
40
- gulpConfig.set('watchSearch', `${srcPath}/**/*.js`);
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
- const createTempDir = async function () {
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 = () => createTempDir();
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 = () => removeDirectory(tempDir);
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('testPath')
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('testOptions'), testPath)
20
+ return runCLI(gulpConfig.get('test.options'), testPath)
22
21
  }
23
22
  module.exports = testFull
@@ -1 +1 @@
1
- "use strict";const gulpConfig=require("../gulp.config.js"),{runCLI:runCLI}=require("jest"),testFull=()=>{let t=gulpConfig.get("testPath");return Array.isArray(t)||(t=[t]),runCLI(gulpConfig.get("testOptions"),t)};module.exports=testFull;
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;
@@ -1,33 +1,15 @@
1
1
  'use strict'
2
2
 
3
3
  /**
4
- * An assortment of objects that can be used in tests and some functions to help debug and write tests.
4
+ * Export the setUp helper.
5
5
  * @file
6
6
  * @author Joshua Heagle <joshuaheagle@gmail.com>
7
- * @version 2.0.0
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
  }
@@ -1 +1 @@
1
- "use strict";const circularObject=require("./test-helpers/circularObject"),countMatches=require("./test-helpers/countMatches"),deepReferenceObject=require("./test-helpers/deepReferenceObject"),domItem=require("./test-helpers/domItem"),jsonDom=require("./test-helpers/jsonDom"),linkedList=require("./test-helpers/linkedList"),logObject=require("./test-helpers/logObject"),multiReferenceObject=require("./test-helpers/multiReferenceObject"),nodeTree=require("./test-helpers/nodeTree"),setUp=require("./test-helpers/setUp");module.exports={circularObject:circularObject,countMatches:countMatches,deepReferenceObject:deepReferenceObject,domItem:domItem,jsonDom:jsonDom,linkedList:linkedList,logObject:logObject,multiReferenceObject:multiReferenceObject,nodeTree:nodeTree,setUp:setUp};
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('testPath')
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]
@@ -1 +1 @@
1
- "use strict";const gulpConfig=require("../gulp.config.js"),{runCLI:runCLI}=require("jest"),testQuick=()=>{let e=gulpConfig.get("testPath");return Array.isArray(e)||(e=[e]),runCLI({onlyChanged:!0},e)};module.exports=testQuick;
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;
@@ -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('watchSearch'), {
14
+ const watchTest = () => watch(gulpConfig.get('test.watch'), {
16
15
  ignoreInitial: false
17
16
  }, testQuick)
18
17
  module.exports = watchTest
@@ -1 +1 @@
1
- "use strict";const gulpConfig=require("../gulp.config.js"),{watch:watch}=require("gulp"),testQuick=require("./testQuick"),watchTest=()=>watch(gulpConfig.get("watchSearch"),{ignoreInitial:!1},testQuick);module.exports=watchTest;
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;
@@ -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('useTsConfig')) {
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 (!gulpConfig.get('nodeOnly')) {
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('useTsConfig')) {
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('useSass')) {
41
- // Since we didn't run this in series after dist because of typescript, we need to run it now. Potentially faster here.
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(