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.
Files changed (199) 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 +12 -13
  5. package/dist/bundle.min.js +1 -1
  6. package/dist/bundleLint.js +17 -18
  7. package/dist/bundleLint.min.js +1 -1
  8. package/dist/bundleMinify.js +8 -9
  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 +0 -1
  15. package/dist/distLint.js +17 -18
  16. package/dist/distLint.min.js +1 -1
  17. package/dist/distMinify.js +8 -9
  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 +13 -14
  22. package/dist/partials/beginWatcher.js +9 -10
  23. package/dist/partials/clean.js +0 -1
  24. package/dist/partials/copyFor.js +16 -0
  25. package/dist/partials/distFor.js +16 -17
  26. package/dist/partials/distForSrc.js +9 -10
  27. package/dist/partials/distSeries.js +19 -20
  28. package/dist/partials/imagesFor.js +34 -0
  29. package/dist/partials/minifyFor.js +0 -1
  30. package/dist/partials/readmeTemplate.js +11 -12
  31. package/dist/partials/removeDirectory.js +5 -6
  32. package/dist/partials/runOnChange.js +27 -27
  33. package/dist/partials/sassFor.js +2 -3
  34. package/dist/partials/tsFor.js +20 -21
  35. package/dist/partials.js +5 -1
  36. package/dist/partials.min.js +1 -1
  37. package/dist/sass.js +7 -7
  38. package/dist/test-helpers/setUp.js +31 -39
  39. package/dist/testFull.js +17 -18
  40. package/dist/testFull.min.js +1 -1
  41. package/dist/testHelpers.js +10 -28
  42. package/dist/testHelpers.min.js +1 -1
  43. package/dist/testQuick.js +19 -20
  44. package/dist/testQuick.min.js +1 -1
  45. package/dist/typeScript.js +0 -1
  46. package/dist/utilities/dotGet.js +50 -0
  47. package/dist/utilities/dotNotate.js +77 -0
  48. package/dist/utilities/dotSet.js +44 -0
  49. package/dist/utilities/isObject.js +10 -0
  50. package/dist/watchFull.js +0 -1
  51. package/dist/watchTest.js +13 -14
  52. package/dist/watchTest.min.js +1 -1
  53. package/functions/build.js +15 -5
  54. package/functions/build.test.js +278 -42
  55. package/functions/bundle.js +3 -4
  56. package/functions/bundle.test.js +6 -6
  57. package/functions/bundleLint.js +2 -3
  58. package/functions/bundleLint.test.js +5 -5
  59. package/functions/bundleMinify.js +1 -2
  60. package/functions/bundleMinify.test.js +1 -1
  61. package/functions/copyFonts.js +11 -0
  62. package/functions/copyFonts.test.js +31 -0
  63. package/functions/default.js +1 -1
  64. package/functions/default.test.js +2 -2
  65. package/functions/dist.js +0 -1
  66. package/functions/dist.test.js +1 -1
  67. package/functions/distLint.js +2 -3
  68. package/functions/distLint.test.js +3 -3
  69. package/functions/distMinify.js +1 -2
  70. package/functions/distMinify.test.js +1 -1
  71. package/functions/images.js +10 -0
  72. package/functions/images.test.js +138 -0
  73. package/functions/partials/addToReadme.js +2 -3
  74. package/functions/partials/addToReadme.test.js +2 -2
  75. package/functions/partials/beginWatcher.js +1 -2
  76. package/functions/partials/beginWatcher.test.js +1 -1
  77. package/functions/partials/clean.js +0 -1
  78. package/functions/partials/copyFor.js +13 -0
  79. package/functions/partials/copyFor.test.js +34 -0
  80. package/functions/partials/distFor.js +1 -2
  81. package/functions/partials/distFor.test.js +4 -4
  82. package/functions/partials/distForSrc.js +3 -4
  83. package/functions/partials/distForSrc.test.js +6 -6
  84. package/functions/partials/distSeries.js +2 -3
  85. package/functions/partials/distSeries.test.js +5 -5
  86. package/functions/partials/imagesFor.js +33 -0
  87. package/functions/partials/imagesFor.test.js +143 -0
  88. package/functions/partials/minifyFor.js +0 -1
  89. package/functions/partials/minifyFor.test.js +1 -1
  90. package/functions/partials/readmeTemplate.js +3 -4
  91. package/functions/partials/readmeTemplate.test.js +2 -2
  92. package/functions/partials/removeDirectory.js +22 -23
  93. package/functions/partials/runOnChange.js +5 -6
  94. package/functions/partials/runOnChange.test.js +9 -9
  95. package/functions/partials/sassFor.js +1 -2
  96. package/functions/partials/sassFor.test.js +3 -3
  97. package/functions/partials/tsFor.js +3 -4
  98. package/functions/partials/tsFor.test.js +2 -2
  99. package/functions/partials.js +5 -1
  100. package/functions/partials.test.js +1 -1
  101. package/functions/sass.test.js +2 -2
  102. package/functions/test-helpers/setUp.js +24 -32
  103. package/functions/testFull.js +2 -3
  104. package/functions/testFull.test.js +1 -1
  105. package/functions/testHelpers.js +3 -20
  106. package/functions/testHelpers.test.js +1 -1
  107. package/functions/testQuick.js +1 -2
  108. package/functions/testQuick.test.js +1 -1
  109. package/functions/typeScript.js +0 -1
  110. package/functions/typeScript.test.js +0 -2
  111. package/functions/utilities/dotGet.js +47 -0
  112. package/functions/utilities/dotNotate.js +68 -0
  113. package/functions/utilities/dotSet.js +41 -0
  114. package/functions/utilities/isObject.js +9 -0
  115. package/functions/watchFull.js +0 -1
  116. package/functions/watchFull.test.js +1 -1
  117. package/functions/watchTest.js +1 -2
  118. package/functions/watchTest.test.js +1 -1
  119. package/gulp.config.js +153 -79
  120. package/gulpfile.base.js +5 -1
  121. package/jsdoc.base.js +1 -1
  122. package/package.json +13 -9
  123. package/vendor/array-union/index.js +31 -0
  124. package/vendor/easy-transform-stream/index.js +58 -0
  125. package/vendor/globby/gitignore.js +100 -0
  126. package/vendor/globby/index.js +195 -0
  127. package/vendor/globby/node_modules/slash/index.js +16 -0
  128. package/vendor/globby/stream-utils.js +58 -0
  129. package/vendor/globby/to-path.js +20 -0
  130. package/vendor/gulp-imagemin/index.js +128 -0
  131. package/vendor/gulp-imagemin/node_modules/chalk/source/index.js +265 -0
  132. package/vendor/gulp-imagemin/node_modules/chalk/source/utilities.js +36 -0
  133. package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
  134. package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
  135. package/vendor/gulp-plugin-extras/index.js +46 -0
  136. package/vendor/gulp-plugin-extras/node_modules/chalk/source/index.js +265 -0
  137. package/vendor/gulp-plugin-extras/node_modules/chalk/source/utilities.js +36 -0
  138. package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
  139. package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
  140. package/vendor/gulp-plugin-extras/plugin-error.js +145 -0
  141. package/vendor/ignore/index.js +468 -0
  142. package/vendor/imagemin/index.js +94 -0
  143. package/vendor/imagemin-gifsicle/index.js +37 -0
  144. package/vendor/imagemin-mozjpeg/index.js +104 -0
  145. package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +264 -0
  146. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/command.js +47 -0
  147. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/error.js +102 -0
  148. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +123 -0
  149. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/promise.js +47 -0
  150. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stdio.js +50 -0
  151. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +128 -0
  152. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/core.js +238 -0
  153. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/main.js +89 -0
  154. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/realtime.js +24 -0
  155. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/signals.js +44 -0
  156. package/vendor/imagemin-mozjpeg/node_modules/is-stream/index.js +25 -0
  157. package/vendor/imagemin-mozjpeg/node_modules/mimic-fn/index.js +70 -0
  158. package/vendor/imagemin-mozjpeg/node_modules/npm-run-path/index.js +52 -0
  159. package/vendor/imagemin-mozjpeg/node_modules/onetime/index.js +43 -0
  160. package/vendor/imagemin-mozjpeg/node_modules/path-key/index.js +20 -0
  161. package/vendor/imagemin-mozjpeg/node_modules/strip-final-newline/index.js +17 -0
  162. package/vendor/imagemin-optipng/index.js +44 -0
  163. package/vendor/imagemin-svgo/index.js +27 -0
  164. package/vendor/is-jpg/index.js +12 -0
  165. package/vendor/junk/index.js +49 -0
  166. package/vendor/mozjpeg/index.js +9 -0
  167. package/vendor/mozjpeg/lib/index.js +18 -0
  168. package/vendor/mozjpeg/package.json +50 -0
  169. package/vendor/p-pipe/index.js +26 -0
  170. package/vendor/plur/index.js +32 -0
  171. package/vendor/pretty-bytes/index.js +71 -0
  172. package/vendor/slash/index.js +12 -0
  173. package/dist/test-helpers/circularObject.js +0 -50
  174. package/dist/test-helpers/countMatches.js +0 -12
  175. package/dist/test-helpers/deepReferenceObject.js +0 -20
  176. package/dist/test-helpers/domItem.js +0 -33
  177. package/dist/test-helpers/jsonDom.js +0 -20
  178. package/dist/test-helpers/linkedList.js +0 -23
  179. package/dist/test-helpers/logObject.js +0 -21
  180. package/dist/test-helpers/multiReferenceObject.js +0 -20
  181. package/dist/test-helpers/nodeTree.js +0 -28
  182. package/functions/test-helpers/circularObject.js +0 -28
  183. package/functions/test-helpers/circularObject.test.js +0 -14
  184. package/functions/test-helpers/countMatches.js +0 -11
  185. package/functions/test-helpers/countMatches.test.js +0 -9
  186. package/functions/test-helpers/deepReferenceObject.js +0 -25
  187. package/functions/test-helpers/deepReferenceObject.test.js +0 -7
  188. package/functions/test-helpers/domItem.js +0 -31
  189. package/functions/test-helpers/domItem.test.js +0 -12
  190. package/functions/test-helpers/jsonDom.js +0 -16
  191. package/functions/test-helpers/jsonDom.test.js +0 -12
  192. package/functions/test-helpers/linkedList.js +0 -10
  193. package/functions/test-helpers/linkedList.test.js +0 -22
  194. package/functions/test-helpers/logObject.js +0 -18
  195. package/functions/test-helpers/logObject.test.js +0 -20
  196. package/functions/test-helpers/multiReferenceObject.js +0 -25
  197. package/functions/test-helpers/multiReferenceObject.test.js +0 -14
  198. package/functions/test-helpers/nodeTree.js +0 -11
  199. package/functions/test-helpers/nodeTree.test.js +0 -18
@@ -1,14 +1,15 @@
1
- "use strict";
2
-
3
- const gulpConfig = require('../../gulp.config.js');
4
- const bundle = require('../bundle');
5
- const distSeries = require('./distSeries');
6
- const {
7
- parallel,
8
- series
9
- } = require('gulp');
10
- const testQuick = require('../testQuick');
11
-
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.string.replace.js");
4
+ const gulpConfig = require('../../gulp.config.js');
5
+ const bundle = require('../bundle');
6
+ const distSeries = require('./distSeries');
7
+ const {
8
+ parallel,
9
+ series
10
+ } = require('gulp');
11
+ const testQuick = require('../testQuick');
12
+
12
13
  /**
13
14
  * Run this function when the watched files are modified.
14
15
  * 1. Find the sub-folders within src path
@@ -30,15 +31,14 @@ const testQuick = require('../testQuick');
30
31
  *
31
32
  * // The resulting replaced path for the destination folder
32
33
  * distPathResult = 'dist/some/path/'
33
- * @function
34
34
  * @memberOf module:partials
35
35
  * @param {string} path
36
36
  * @returns {stream.Stream}
37
- */
38
- const runOnChange = path => {
39
- const useTs = gulpConfig.get('useTsConfig');
40
- const distPath = gulpConfig.get('distPath');
41
- const srcPath = gulpConfig.get('srcPath');
37
+ */
38
+ const runOnChange = path => {
39
+ const useTs = gulpConfig.get('typescript.enabled');
40
+ const distPath = gulpConfig.get('dist.to');
41
+ const srcPath = gulpConfig.get('srcPath');
42
42
  /**
43
43
  * 1. The original path comes in from src and is a .ts
44
44
  * 2. Discover the outgoing dist path where that file should go
@@ -46,14 +46,14 @@ const runOnChange = path => {
46
46
  * 4. Take the original path, convert to full file path in dist
47
47
  * 5. Use the dist path found previously in #2
48
48
  * 6. Use the full dist path and the dist outgoing path in distFor
49
- */
50
- const pathRegex = new RegExp(`^${srcPath}(.*\\/)(.+)\\.(js|ts)$`, 'i');
51
- const distPathResult = path.replace(pathRegex, `${distPath}$1`);
52
- let distSrcPath = path;
53
- if (useTs) {
54
- distSrcPath = path.replace(pathRegex, `${distPath}$1$2.js`);
55
- }
56
- const runSeries = distSeries(distSrcPath, distPathResult, path);
57
- return gulpConfig.get('nodeOnly') ? series(testQuick, runSeries)() : parallel(testQuick, series(runSeries, bundle))();
58
- };
49
+ */
50
+ const pathRegex = new RegExp("^".concat(srcPath, "(.*\\/)(.+)\\.(js|ts)$"), 'i');
51
+ const distPathResult = path.replace(pathRegex, "".concat(distPath, "$1"));
52
+ let distSrcPath = path;
53
+ if (useTs) {
54
+ distSrcPath = path.replace(pathRegex, "".concat(distPath, "$1$2.js"));
55
+ }
56
+ const runSeries = distSeries(distSrcPath, distPathResult, path);
57
+ return gulpConfig.get('browser.enabled') ? parallel(testQuick, series(runSeries, bundle))() : series(testQuick, runSeries)();
58
+ };
59
59
  module.exports = runOnChange;
@@ -11,15 +11,14 @@ const sass = require('gulp-sass')(require('sass'));
11
11
 
12
12
  /**
13
13
  * Build the CSS for a given source pattern.
14
- * @function
15
14
  * @memberOf module:partials
16
15
  * @param {string|array} [srcSearch='src/config/path/sass/for']
17
16
  * @param {string} [cssPath='css/config/path']
18
17
  * @returns {stream.Stream}
19
18
  */
20
19
  const sassFor = function () {
21
- let srcSearch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gulpConfig.get('sassSearch');
22
- let cssPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gulpConfig.get('cssPath');
20
+ let srcSearch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gulpConfig.get('sass.from');
21
+ let cssPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gulpConfig.get('sass.to');
23
22
  return src(srcSearch).pipe(sass().on('error', sass.logError)) // Passes it through a gulp-sass, log errors to console
24
23
  .pipe(dest(cssPath)).pipe(cssnano()).pipe(rename({
25
24
  extname: '.min.css'
@@ -1,29 +1,28 @@
1
- "use strict";
2
-
3
- const {
4
- dest,
5
- parallel,
6
- src
7
- } = require('gulp');
8
- const gulpConfig = require('../../gulp.config.js');
9
- const ts = require('gulp-typescript');
10
-
1
+ "use strict";
2
+
3
+ const {
4
+ dest,
5
+ parallel,
6
+ src
7
+ } = require('gulp');
8
+ const gulpConfig = require('../../gulp.config.js');
9
+ const ts = require('gulp-typescript');
10
+
11
11
  /**
12
12
  * Starting at the source directory, find all the ts files and convert them into the distribution directory.
13
- * @function
14
13
  * @memberOf module:partials
15
14
  * @param {string|array} [srcPath='']
16
15
  * @param {string} [distPath='']
17
16
  * @returns {Function}
18
17
  * @see `https://www.typescriptlang.org/docs/handbook/gulp.html` for more info
19
- */
20
- const tsFor = function () {
21
- let srcPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gulpConfig.get('tsSearch');
22
- let distPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gulpConfig.get('distPath');
23
- const declarationProject = ts.createProject(gulpConfig.get('useTsConfig'));
24
- const tsProject = ts.createProject(gulpConfig.get('useTsConfig'));
25
- const makeDeclarations = () => src(srcPath).pipe(declarationProject()).dts.pipe(dest(distPath));
26
- const compileJS = () => src(srcPath).pipe(tsProject()).js.pipe(dest(distPath));
27
- return parallel(makeDeclarations, compileJS);
28
- };
18
+ */
19
+ const tsFor = function () {
20
+ let srcPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gulpConfig.get('typescript.from');
21
+ let distPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gulpConfig.get('typescript.to');
22
+ const declarationProject = ts.createProject(gulpConfig.get('typescript.config'));
23
+ const tsProject = ts.createProject(gulpConfig.get('typescript.config'));
24
+ const makeDeclarations = () => src(srcPath).pipe(declarationProject()).dts.pipe(dest(distPath));
25
+ const compileJS = () => src(srcPath).pipe(tsProject()).js.pipe(dest(distPath));
26
+ return parallel(makeDeclarations, compileJS);
27
+ };
29
28
  module.exports = tsFor;
package/dist/partials.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * Micro-functions used as components for the main gulp functions.
5
5
  * @file
6
6
  * @author Joshua Heagle <joshuaheagle@gmail.com>
7
- * @version 2.0.0
7
+ * @version 3.0.0
8
8
  * @module partials
9
9
  * @memberOf module:js-build-tools
10
10
  */
@@ -12,9 +12,11 @@
12
12
  const addToReadme = require('./partials/addToReadme')
13
13
  const beginWatcher = require('./partials/beginWatcher')
14
14
  const clean = require('./partials/clean')
15
+ const copyFor = require('./partials/copyFor')
15
16
  const distFor = require('./partials/distFor')
16
17
  const distForSrc = require('./partials/distForSrc')
17
18
  const distSeries = require('./partials/distSeries')
19
+ const imagesFor = require('./partials/imagesFor.js')
18
20
  const minifyFor = require('./partials/minifyFor')
19
21
  const readmeTemplate = require('./partials/readmeTemplate')
20
22
  const removeDirectory = require('./partials/removeDirectory')
@@ -25,9 +27,11 @@ module.exports = {
25
27
  addToReadme,
26
28
  beginWatcher,
27
29
  clean,
30
+ copyFor,
28
31
  distFor,
29
32
  distForSrc,
30
33
  distSeries,
34
+ imagesFor,
31
35
  minifyFor,
32
36
  readmeTemplate,
33
37
  removeDirectory,
@@ -1 +1 @@
1
- "use strict";const addToReadme=require("./partials/addToReadme"),beginWatcher=require("./partials/beginWatcher"),clean=require("./partials/clean"),distFor=require("./partials/distFor"),distForSrc=require("./partials/distForSrc"),distSeries=require("./partials/distSeries"),minifyFor=require("./partials/minifyFor"),readmeTemplate=require("./partials/readmeTemplate"),removeDirectory=require("./partials/removeDirectory"),runOnChange=require("./partials/runOnChange"),sassFor=require("./partials/sassFor"),tsFor=require("./partials/tsFor");module.exports={addToReadme:addToReadme,beginWatcher:beginWatcher,clean:clean,distFor:distFor,distForSrc:distForSrc,distSeries:distSeries,minifyFor:minifyFor,readmeTemplate:readmeTemplate,removeDirectory:removeDirectory,runOnChange:runOnChange,sassFor:sassFor,tsFor:tsFor};
1
+ "use strict";const addToReadme=require("./partials/addToReadme"),beginWatcher=require("./partials/beginWatcher"),clean=require("./partials/clean"),copyFor=require("./partials/copyFor"),distFor=require("./partials/distFor"),distForSrc=require("./partials/distForSrc"),distSeries=require("./partials/distSeries"),imagesFor=require("./partials/imagesFor.js"),minifyFor=require("./partials/minifyFor"),readmeTemplate=require("./partials/readmeTemplate"),removeDirectory=require("./partials/removeDirectory"),runOnChange=require("./partials/runOnChange"),sassFor=require("./partials/sassFor"),tsFor=require("./partials/tsFor");module.exports={addToReadme:addToReadme,beginWatcher:beginWatcher,clean:clean,copyFor:copyFor,distFor:distFor,distForSrc:distForSrc,distSeries:distSeries,imagesFor:imagesFor,minifyFor:minifyFor,readmeTemplate:readmeTemplate,removeDirectory:removeDirectory,runOnChange:runOnChange,sassFor:sassFor,tsFor:tsFor};
package/dist/sass.js CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict'
2
-
3
- const sassFor = require('./partials/sassFor')
4
-
5
- // Compile sass into CSS & auto-inject into browsers
6
- const sass = () => sassFor()
7
- module.exports = sass
1
+ 'use strict'
2
+
3
+ const sassFor = require('./partials/sassFor')
4
+
5
+ // Compile sass into CSS & auto-inject into browsers
6
+ const sass = () => sassFor()
7
+ module.exports = sass
@@ -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
@@ -1,23 +1,22 @@
1
- 'use strict'
2
-
3
- const gulpConfig = require('../gulp.config.js')
4
- const {
5
- runCLI
6
- } = require('jest')
7
-
1
+ 'use strict'
2
+
3
+ const gulpConfig = require('../gulp.config.js')
4
+ const {
5
+ runCLI
6
+ } = require('jest')
7
+
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
- */
15
- const testFull = () => {
16
- let testPath = gulpConfig.get('testPath')
17
- if (!Array.isArray(testPath)) {
18
- // The testPath must be an array of strings
19
- testPath = [testPath]
20
- }
21
- return runCLI(gulpConfig.get('testOptions'), testPath)
22
- }
23
- module.exports = testFull
13
+ */
14
+ const testFull = () => {
15
+ let testPath = gulpConfig.get('test.path')
16
+ if (!Array.isArray(testPath)) {
17
+ // The testPath must be an array of strings
18
+ testPath = [testPath]
19
+ }
20
+ return runCLI(gulpConfig.get('test.options'), testPath)
21
+ }
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
- 'use strict'
2
-
1
+ 'use strict'
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
- */
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
- const setUp = require('./test-helpers/setUp')
22
- module.exports = {
23
- circularObject,
24
- countMatches,
25
- deepReferenceObject,
26
- domItem,
27
- jsonDom,
28
- linkedList,
29
- logObject,
30
- multiReferenceObject,
31
- nodeTree,
32
- setUp
33
- }
10
+ */
11
+
12
+ const setUp = require('./test-helpers/setUp')
13
+ module.exports = {
14
+ setUp
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
@@ -1,25 +1,24 @@
1
- 'use strict'
2
-
3
- const gulpConfig = require('../gulp.config.js')
4
- const {
5
- runCLI
6
- } = require('jest')
7
-
1
+ 'use strict'
2
+
3
+ const gulpConfig = require('../gulp.config.js')
4
+ const {
5
+ runCLI
6
+ } = require('jest')
7
+
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
- */
15
- const testQuick = () => {
16
- let testPath = gulpConfig.get('testPath')
17
- if (!Array.isArray(testPath)) {
18
- // The testPath must be an array of strings
19
- testPath = [testPath]
20
- }
21
- return runCLI({
22
- onlyChanged: true
23
- }, testPath)
24
- }
25
- module.exports = testQuick
13
+ */
14
+ const testQuick = () => {
15
+ let testPath = gulpConfig.get('test.path')
16
+ if (!Array.isArray(testPath)) {
17
+ // The testPath must be an array of strings
18
+ testPath = [testPath]
19
+ }
20
+ return runCLI({
21
+ onlyChanged: true
22
+ }, testPath)
23
+ }
24
+ module.exports = testQuick
@@ -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;
@@ -4,7 +4,6 @@ const tsFor = require('./partials/tsFor')
4
4
 
5
5
  /**
6
6
  * Simplified typescript task using tsFor.
7
- * @function
8
7
  * @memberOf module:js-build-tools
9
8
  * @returns {Function}
10
9
  */
@@ -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;