js-build-tools 3.0.3 → 4.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 (213) hide show
  1. package/README.md +431 -691
  2. package/babel.config.js +1 -1
  3. package/dist/build.js +58 -59
  4. package/dist/build.min.js +1 -1
  5. package/dist/bundle.js +17 -12
  6. package/dist/bundle.min.js +1 -1
  7. package/dist/bundleLint.js +21 -17
  8. package/dist/bundleLint.min.js +1 -1
  9. package/dist/bundleMinify.js +14 -8
  10. package/dist/bundleMinify.min.js +1 -1
  11. package/dist/compileReadme.js +10 -13
  12. package/dist/compileReadme.min.js +1 -1
  13. package/dist/copyFonts.js +14 -8
  14. package/dist/copyFonts.min.js +1 -1
  15. package/dist/default.js +19 -15
  16. package/dist/default.min.js +1 -1
  17. package/dist/dist.js +10 -7
  18. package/dist/dist.min.js +1 -1
  19. package/dist/distLint.js +21 -17
  20. package/dist/distLint.min.js +1 -1
  21. package/dist/distMinify.js +14 -8
  22. package/dist/distMinify.min.js +1 -1
  23. package/dist/images.js +10 -7
  24. package/dist/images.min.js +1 -1
  25. package/dist/partials/addToReadme.js +19 -14
  26. package/dist/partials/beginWatcher.js +14 -10
  27. package/dist/partials/clean.js +17 -11
  28. package/dist/partials/copyFor.js +10 -10
  29. package/dist/partials/distFor.js +27 -17
  30. package/dist/partials/distForSrc.js +16 -10
  31. package/dist/partials/distSeries.js +24 -20
  32. package/dist/partials/imagesFor.js +27 -28
  33. package/dist/partials/minifyFor.js +17 -16
  34. package/dist/partials/readmeTemplate.js +16 -12
  35. package/dist/partials/removeDirectory.js +12 -12
  36. package/dist/partials/runOnChange.js +30 -28
  37. package/dist/partials/sassFor.js +28 -21
  38. package/dist/partials/tsFor.js +24 -21
  39. package/dist/partials.js +103 -41
  40. package/dist/partials.min.js +1 -1
  41. package/dist/sass.js +10 -7
  42. package/dist/sass.min.js +1 -1
  43. package/dist/test-helpers/setUp.js +68 -65
  44. package/dist/testFull.js +22 -17
  45. package/dist/testFull.min.js +1 -1
  46. package/dist/testHelpers.js +11 -15
  47. package/dist/testHelpers.min.js +1 -1
  48. package/dist/testQuick.js +24 -19
  49. package/dist/testQuick.min.js +1 -1
  50. package/dist/typeScript.js +9 -7
  51. package/dist/typeScript.min.js +1 -1
  52. package/dist/utilities/dotGet.js +45 -43
  53. package/dist/utilities/dotNotate.js +53 -51
  54. package/dist/utilities/dotSet.js +39 -37
  55. package/dist/utilities/isObject.js +9 -5
  56. package/dist/utilities/strAfter.js +18 -14
  57. package/dist/utilities/strBefore.js +18 -14
  58. package/dist/watchFull.js +10 -10
  59. package/dist/watchFull.min.js +1 -1
  60. package/dist/watchTest.js +17 -13
  61. package/dist/watchTest.min.js +1 -1
  62. package/functions/{build.js → build.mjs} +14 -16
  63. package/functions/{build.test.js → build.test.mjs} +9 -8
  64. package/functions/{bundle.js → bundle.mjs} +5 -7
  65. package/functions/{bundle.test.js → bundle.test.mjs} +5 -4
  66. package/functions/{bundleLint.js → bundleLint.mjs} +4 -6
  67. package/functions/{bundleLint.test.js → bundleLint.test.mjs} +5 -4
  68. package/functions/bundleMinify.mjs +9 -0
  69. package/functions/bundleMinify.test.mjs +15 -0
  70. package/functions/compileReadme.mjs +9 -0
  71. package/functions/{compileReadme.test.js → compileReadme.test.mjs} +4 -4
  72. package/functions/copyFonts.mjs +9 -0
  73. package/functions/{copyFonts.test.js → copyFonts.test.mjs} +4 -3
  74. package/functions/default.mjs +12 -0
  75. package/functions/{default.test.js → default.test.mjs} +8 -7
  76. package/functions/{dist.js → dist.mjs} +2 -4
  77. package/functions/{dist.test.js → dist.test.mjs} +4 -3
  78. package/functions/{distLint.js → distLint.mjs} +4 -6
  79. package/functions/{distLint.test.js → distLint.test.mjs} +5 -4
  80. package/functions/distMinify.mjs +9 -0
  81. package/functions/distMinify.test.mjs +15 -0
  82. package/functions/{images.js → images.mjs} +2 -4
  83. package/functions/{images.test.js → images.test.mjs} +4 -3
  84. package/functions/partials/{addToReadme.js → addToReadme.mjs} +5 -7
  85. package/functions/partials/{addToReadme.test.js → addToReadme.test.mjs} +4 -3
  86. package/functions/partials/beginWatcher.mjs +9 -0
  87. package/functions/partials/{beginWatcher.test.js → beginWatcher.test.mjs} +4 -3
  88. package/functions/partials/clean.mjs +13 -0
  89. package/functions/partials/{clean.test.js → clean.test.mjs} +4 -3
  90. package/functions/partials/{copyFor.js → copyFor.mjs} +2 -4
  91. package/functions/partials/{copyFor.test.js → copyFor.test.mjs} +4 -3
  92. package/functions/partials/distFor.mjs +22 -0
  93. package/functions/partials/{distFor.test.js → distFor.test.mjs} +49 -8
  94. package/functions/partials/{distForSrc.js → distForSrc.mjs} +2 -4
  95. package/functions/partials/{distForSrc.test.js → distForSrc.test.mjs} +3 -2
  96. package/functions/partials/{distSeries.js → distSeries.mjs} +6 -8
  97. package/functions/partials/{distSeries.test.js → distSeries.test.mjs} +7 -6
  98. package/functions/partials/{imagesFor.js → imagesFor.mjs} +5 -13
  99. package/functions/partials/{imagesFor.test.js → imagesFor.test.mjs} +4 -3
  100. package/functions/partials/minifyFor.mjs +15 -0
  101. package/functions/partials/{minifyFor.test.js → minifyFor.test.mjs} +5 -4
  102. package/functions/partials/readmeTemplate.mjs +12 -0
  103. package/functions/partials/{readmeTemplate.test.js → readmeTemplate.test.mjs} +4 -3
  104. package/functions/partials/{removeDirectory.js → removeDirectory.mjs} +2 -4
  105. package/functions/partials/{removeDirectory.test.js → removeDirectory.test.mjs} +28 -28
  106. package/functions/partials/{runOnChange.js → runOnChange.mjs} +6 -8
  107. package/functions/partials/{runOnChange.test.js → runOnChange.test.mjs} +12 -11
  108. package/functions/partials/sassFor.mjs +22 -0
  109. package/functions/partials/{sassFor.test.js → sassFor.test.mjs} +5 -4
  110. package/functions/partials/{tsFor.js → tsFor.mjs} +4 -6
  111. package/functions/partials/{tsFor.test.js → tsFor.test.mjs} +5 -4
  112. package/functions/partials.mjs +23 -0
  113. package/functions/{partials.test.js → partials.test.mjs} +1 -1
  114. package/functions/sass.mjs +4 -0
  115. package/functions/{sass.test.js → sass.test.mjs} +4 -3
  116. package/functions/test-helpers/{setUp.js → setUp.mjs} +25 -27
  117. package/functions/test-helpers/setUp.test.mjs +19 -0
  118. package/functions/{testFull.js → testFull.mjs} +4 -6
  119. package/functions/testFull.test.mjs +17 -0
  120. package/functions/{testHelpers.js → testHelpers.mjs} +1 -6
  121. package/functions/testHelpers.test.mjs +7 -0
  122. package/functions/{testQuick.js → testQuick.mjs} +4 -6
  123. package/functions/testQuick.test.mjs +17 -0
  124. package/functions/{typeScript.js → typeScript.mjs} +2 -4
  125. package/functions/typeScript.test.mjs +11 -0
  126. package/functions/utilities/{dotGet.js → dotGet.mjs} +4 -6
  127. package/functions/utilities/{dotNotate.js → dotNotate.mjs} +2 -4
  128. package/functions/utilities/{dotSet.js → dotSet.mjs} +4 -6
  129. package/functions/utilities/{isObject.js → isObject.mjs} +1 -3
  130. package/functions/utilities/{strAfter.js → strAfter.mjs} +11 -13
  131. package/functions/utilities/{strBefore.js → strBefore.mjs} +11 -13
  132. package/functions/{watchFull.js → watchFull.mjs} +2 -4
  133. package/functions/{watchFull.test.js → watchFull.test.mjs} +8 -7
  134. package/functions/watchTest.mjs +10 -0
  135. package/functions/{watchTest.test.js → watchTest.test.mjs} +7 -6
  136. package/gulp.config.js +20 -19
  137. package/gulp.config.mjs +252 -0
  138. package/gulpfile.base.js +20 -20
  139. package/gulpfile.base.mjs +27 -0
  140. package/package.json +20 -14
  141. package/functions/bundleMinify.js +0 -11
  142. package/functions/bundleMinify.test.js +0 -14
  143. package/functions/compileReadme.js +0 -11
  144. package/functions/copyFonts.js +0 -11
  145. package/functions/default.js +0 -14
  146. package/functions/distMinify.js +0 -11
  147. package/functions/distMinify.test.js +0 -14
  148. package/functions/partials/beginWatcher.js +0 -11
  149. package/functions/partials/clean.js +0 -15
  150. package/functions/partials/distFor.js +0 -17
  151. package/functions/partials/minifyFor.js +0 -15
  152. package/functions/partials/readmeTemplate.js +0 -14
  153. package/functions/partials/sassFor.js +0 -21
  154. package/functions/partials.js +0 -40
  155. package/functions/sass.js +0 -6
  156. package/functions/test-helpers/setUp.test.js +0 -18
  157. package/functions/testFull.test.js +0 -16
  158. package/functions/testHelpers.test.js +0 -7
  159. package/functions/testQuick.test.js +0 -16
  160. package/functions/typeScript.test.js +0 -10
  161. package/functions/watchTest.js +0 -12
  162. package/vendor/array-union/index.js +0 -31
  163. package/vendor/easy-transform-stream/index.js +0 -54
  164. package/vendor/globby/gitignore.js +0 -96
  165. package/vendor/globby/index.js +0 -191
  166. package/vendor/globby/node_modules/slash/index.js +0 -16
  167. package/vendor/globby/stream-utils.js +0 -58
  168. package/vendor/globby/to-path.js +0 -20
  169. package/vendor/gulp-imagemin/index.js +0 -124
  170. package/vendor/gulp-imagemin/node_modules/chalk/source/index.js +0 -265
  171. package/vendor/gulp-imagemin/node_modules/chalk/source/utilities.js +0 -36
  172. package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -217
  173. package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/supports-color/index.js +0 -154
  174. package/vendor/gulp-plugin-extras/index.js +0 -42
  175. package/vendor/gulp-plugin-extras/node_modules/chalk/source/index.js +0 -265
  176. package/vendor/gulp-plugin-extras/node_modules/chalk/source/utilities.js +0 -36
  177. package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -217
  178. package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/supports-color/index.js +0 -154
  179. package/vendor/gulp-plugin-extras/plugin-error.js +0 -145
  180. package/vendor/ignore/index.js +0 -468
  181. package/vendor/imagemin/index.js +0 -90
  182. package/vendor/imagemin-gifsicle/index.js +0 -33
  183. package/vendor/imagemin-mozjpeg/index.js +0 -100
  184. package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +0 -260
  185. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/command.js +0 -47
  186. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/error.js +0 -102
  187. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +0 -123
  188. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/promise.js +0 -47
  189. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stdio.js +0 -50
  190. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +0 -124
  191. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/core.js +0 -238
  192. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/main.js +0 -89
  193. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/realtime.js +0 -24
  194. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/signals.js +0 -44
  195. package/vendor/imagemin-mozjpeg/node_modules/is-stream/index.js +0 -25
  196. package/vendor/imagemin-mozjpeg/node_modules/mimic-fn/index.js +0 -70
  197. package/vendor/imagemin-mozjpeg/node_modules/npm-run-path/index.js +0 -52
  198. package/vendor/imagemin-mozjpeg/node_modules/onetime/index.js +0 -43
  199. package/vendor/imagemin-mozjpeg/node_modules/path-key/index.js +0 -20
  200. package/vendor/imagemin-mozjpeg/node_modules/strip-final-newline/index.js +0 -17
  201. package/vendor/imagemin-optipng/index.js +0 -44
  202. package/vendor/imagemin-svgo/index.js +0 -27
  203. package/vendor/is-jpg/index.js +0 -12
  204. package/vendor/junk/index.js +0 -49
  205. package/vendor/mozjpeg/index.js +0 -9
  206. package/vendor/mozjpeg/lib/index.js +0 -18
  207. package/vendor/mozjpeg/package.json +0 -49
  208. package/vendor/mozjpeg/vendor/cjpeg +0 -0
  209. package/vendor/mozjpeg/vendor/source/mozjpeg.tar.gz +0 -0
  210. package/vendor/p-pipe/index.js +0 -22
  211. package/vendor/plur/index.js +0 -32
  212. package/vendor/pretty-bytes/index.js +0 -71
  213. package/vendor/slash/index.js +0 -12
@@ -0,0 +1,10 @@
1
+ import * as gulpConfig from '../gulp.config.mjs'
2
+ import { watch } from 'gulp'
3
+ import { testQuick } from './testQuick.mjs'
4
+
5
+ /**
6
+ * Watch for changes and run the tests.
7
+ * @memberOf module:js-build-tools
8
+ * @returns {*}
9
+ */
10
+ export const watchTest = () => watch(gulpConfig.get('test.watch'), { ignoreInitial: false }, testQuick)
@@ -1,13 +1,14 @@
1
- const setUp = require('./test-helpers/setUp')
1
+ import * as setUp from './test-helpers/setUp.mjs'
2
+ import { watchTest } from './watchTest.mjs'
3
+ import { EventEmitter } from 'node:events'
4
+ import fs from 'fs'
5
+ import { testQuick } from './testQuick.mjs'
6
+
2
7
  setUp.setDefaults('test-watch-test')
3
8
  const gulpConfig = setUp.gulpConfig
4
9
  gulpConfig.set('test.watch', 'test-begin-watcher/*.js')
5
- const watchTest = require('./watchTest')
6
- const { EventEmitter } = require('node:events')
7
- const fs = require('fs')
8
- const testQuick = require('./testQuick')
9
10
 
10
- jest.mock('./testQuick', () => jest.fn(() => Promise.resolve(true)))
11
+ jest.mock('./testQuick.mjs', () => ({ testQuick: jest.fn(() => Promise.resolve(true)) }))
11
12
 
12
13
  const rawContents = 'const gulpConfig = require(\'../gulp.config.js\')\n' +
13
14
  'const { watch } = require(\'gulp\')\n' +
package/gulp.config.js CHANGED
@@ -6,6 +6,7 @@
6
6
  * @module gulpConfig
7
7
  * @memberOf module:js-build-tools
8
8
  */
9
+ const { fileExists } = require('test-filesystem')
9
10
 
10
11
  /**
11
12
  * A setting that may be an array of strings or a string only.
@@ -137,25 +138,10 @@
137
138
  * @property {TsConfig} typescript - Compile from typescript configuration.
138
139
  */
139
140
 
140
- const dotGet = require('./functions/utilities/dotGet')
141
- const dotSet = require('./functions/utilities/dotSet')
142
- const dotNotate = require('./functions/utilities/dotNotate')
143
- /**
144
- * All the available configuration setting options for running the build.
145
- * @memberOf module:gulpConfig` `
146
- * @type {Configurations}
147
- */
148
- let gulpConfigurations = {}
149
- try {
150
- gulpConfigurations = require('../../build-tools.config.js')
151
- } catch (isUndefined) {
152
- try {
153
- // Missing main project config, using default path
154
- gulpConfigurations = require('./build-tools.config.js')
155
- } catch (stillUndefined) {
156
- console.warn('Missing config path, ensure you have a build-tools.config.js file in you project root')
157
- }
158
- }
141
+ const { dotGet } = require('./dist/utilities/dotGet')
142
+ const { dotSet } = require('./dist/utilities/dotSet')
143
+ const { dotNotate } = require('./dist/utilities/dotNotate')
144
+ const { readFileSync } = require('fs')
159
145
 
160
146
  const setDefaults = {
161
147
  browser: {
@@ -217,6 +203,21 @@ const setDefaults = {
217
203
  to: 'dist',
218
204
  },
219
205
  }
206
+ /**
207
+ * All the available configuration setting options for running the build.
208
+ * @memberOf module:gulpConfig` `
209
+ * @type {Configurations}
210
+ */
211
+ let gulpConfigurations = {}
212
+ if (fileExists('../../build-tools.config.json')) {
213
+ gulpConfigurations = JSON.parse(readFileSync('../../build-tools.config.json').toString())
214
+ } else {
215
+ if (fileExists('./build-tools.config.json')) {
216
+ gulpConfigurations = JSON.parse(readFileSync('./build-tools.config.json').toString())
217
+ } else {
218
+ console.warn('Missing config path, ensure you have a build-tools.config.js file in you project root')
219
+ }
220
+ }
220
221
 
221
222
  const notation = dotNotate(setDefaults)
222
223
  for (let notationKey in notation) {
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Modify these configurations to match your project specifications.
3
+ * @file
4
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
5
+ * @version 3.0.0
6
+ * @module gulpConfig
7
+ * @memberOf module:js-build-tools
8
+ */
9
+ import { fileExists } from 'test-filesystem'
10
+
11
+ /**
12
+ * A setting that may be an array of strings or a string only.
13
+ * @typedef {Array<string>|string} module:gulpConfig~ArrayableSetting
14
+ */
15
+
16
+ /**
17
+ * A setting that may be true or false.
18
+ * @typedef {boolean} module:gulpConfig~BooleanSetting
19
+ */
20
+
21
+ /**
22
+ * A setting that may be flag 'false' or provide a StringSetting
23
+ * @typedef {false|StringSetting} module:gulpConfig~FlagStringSetting
24
+ */
25
+
26
+ /**
27
+ * An object of boolean settings used as flags.
28
+ * @typedef {Object<string, BooleanSetting>} module:gulpConfig~FlagsSetting
29
+ */
30
+
31
+ /**
32
+ * Configure cli options for running Jest.
33
+ * @typedef {FlagsSetting} module:gulpConfig~JestTestFlags
34
+ * @property {BooleanSetting} clearCache
35
+ * @property {BooleanSetting} debug
36
+ * @property {BooleanSetting} ignoreProjects:
37
+ * @property {BooleanSetting} json
38
+ * @property {BooleanSetting} selectProjects
39
+ * @property {BooleanSetting} showConfig
40
+ * @property {BooleanSetting} useStderr
41
+ * @property {BooleanSetting} watch
42
+ * @property {BooleanSetting} watchAll
43
+ */
44
+
45
+ /**
46
+ * A setting that may only be a string.
47
+ * @typedef {string} module:gulpConfig~StringSetting
48
+ */
49
+
50
+ /**
51
+ * Any single configuration option is a Setting.
52
+ * @typedef {ArrayableSetting|BooleanSetting|FlagsSetting|StringSetting} Setting
53
+ */
54
+
55
+ /**
56
+ * Configurations for building the browser files.
57
+ * @typedef {Object<string, Setting>} module:gulpConfig~BrowserConfig
58
+ * @property {BooleanSetting} enabled - 'true' to generate browser bundled files; 'false' for node environment only
59
+ * @property {StringSetting} from - The name to use for the browser-bundled output file (.js will be appended).
60
+ * @property {StringSetting} name - The search pattern used for retrieving compiled distribution files.
61
+ * @property {StringSetting} to - The output directory for browser-bundled files.
62
+ */
63
+
64
+ /**
65
+ * Configurations for building the node distribution files.
66
+ * @typedef {Object<string, Setting>} module:gulpConfig~DistConfig
67
+ * @property {StringSetting} from - The search pattern used for gathering source files for distribution.
68
+ * @property {StringSetting} main - Name of the entry the distribution file.
69
+ * @property {StringSetting} to - The output directory for the distribution files.
70
+ */
71
+
72
+ /**
73
+ * Configurations for copying the font files.
74
+ * @typedef {Object<string, Setting>} module:gulpConfig~FontConfig
75
+ * @property {BooleanSetting} enabled - Toggle copy directory of fonts on.
76
+ * @property {StringSetting} from - Path to search for fonts.
77
+ * @property {StringSetting} to - Path to output fonts.
78
+ */
79
+
80
+ /**
81
+ * Configurations to minify and copy the images.
82
+ * @typedef {Object<string, Setting>} module:gulpConfig~ImageConfig
83
+ * @property {BooleanSetting} enabled - Toggle image minify and copy process.
84
+ * @property {StringSetting} from - Path to search for images.
85
+ * @property {StringSetting} to - Path to output images.
86
+ */
87
+
88
+ /**
89
+ * Configurations to compile and generate the Readme file.
90
+ * @typedef {Object<string, Setting>} module:gulpConfig~ReadmeConfig
91
+ * @property {StringSetting} file - The name of the output documentation markdown file.
92
+ * @property {StringSetting} from - Location of files to use for compiling documentation into the readme.
93
+ * @property {ArrayableSetting} options - Options for formatting the output readme.
94
+ * @property {StringSetting} template - The file which will be pre-fixed to your README.md output.
95
+ * @property {StringSetting} to - The directory to output the readme file in.
96
+ */
97
+
98
+ /**
99
+ * Configurations to compile and copy the sass files into css.
100
+ * @typedef {Object<string, Setting>} module:gulpConfig~SassConfig
101
+ * @property {BooleanSetting} enabled - Toggle SASS to CSS process on.
102
+ * @property {StringSetting} from - The pattern for finding all sass files.
103
+ * @property {StringSetting} path - The directory were sass files will be stored.
104
+ * @property {StringSetting} to - The destination path for where generated CSS (from SASS files) should go.
105
+ */
106
+
107
+ /**
108
+ * Configurations for running the test suite.
109
+ * @typedef {Object<string, Setting>} module:gulpConfig~TestConfig
110
+ * @property {JestTestFlags} options - Additional flags for programmatically running Jest Cli.
111
+ * @property {ArrayableSetting} path - The directory where Jest test files are stored.
112
+ * By default, stored as *.test.js adjacent to the files they are testing.
113
+ * @property {ArrayableSetting} watch - The search pattern for watching files for changes.
114
+ */
115
+
116
+ /**
117
+ * Configurations for compiling typescript into JS files.
118
+ * @typedef {Object<string, Setting>} module:gulpConfig~TsConfig
119
+ * @property {FlagStringSetting} config - The path the tsconfig file for running typescript or false if no ts file given.
120
+ * @property {BooleanSetting} enabled - Toggle usage of typescript parsing.
121
+ * @property {StringSetting} from - Pattern for finding the TypeScript files.
122
+ * @property {StringSetting} to - Directory where parsed typescript files go.
123
+ */
124
+
125
+ /**
126
+ * A set of Configurations options defined by Settings.
127
+ * @typedef {Object<string, Setting>} module:gulpConfig~Configurations
128
+ * @property {BrowserConfig} browser - Browser bundling configuration group.
129
+ * @property {ArrayableSetting} cleanPaths - The paths for directories to delete before build.
130
+ * @property {DistConfig} dist - Distribution file generation configuration group.
131
+ * @property {FontConfig} fonts - Fonts copy configuration group.
132
+ * @property {ImageConfig} images - Minify and copy the images configuration.
133
+ * @property {ReadmeConfig} readme - Build readme files configuration.
134
+ * @property {StringSetting} rootPath - Base directory of the project.
135
+ * @property {SassConfig} sass - Compile CSS from SASS configuration.
136
+ * @property {StringSetting} srcPath - The directory where your source files are stored (the files you manually created).
137
+ * @property {TestConfig} test - Run test suite configuration.
138
+ * @property {TsConfig} typescript - Compile from typescript configuration.
139
+ */
140
+
141
+ import { dotGet } from './functions/utilities/dotGet.mjs'
142
+ import { dotSet } from './functions/utilities/dotSet.mjs'
143
+ import { dotNotate } from './functions/utilities/dotNotate.mjs'
144
+ import { readFileSync } from 'fs'
145
+
146
+ const setDefaults = {
147
+ browser: {
148
+ enabled: true,
149
+ from: 'dist/**/*.js',
150
+ name: 'default',
151
+ to: 'browser',
152
+ },
153
+ cleanPaths: ['dist', 'browser'],
154
+ dist: {
155
+ from: 'src/**/!(*.test).js',
156
+ main: 'dist/main',
157
+ to: 'dist',
158
+ },
159
+ fonts: {
160
+ enabled: false,
161
+ from: 'src/fonts/**/*',
162
+ to: 'browser/fonts',
163
+ },
164
+ images: {
165
+ enabled: false,
166
+ from: 'src/img/**/*.+(png|jpg|jpeg|gif|svg)',
167
+ to: 'browser/img',
168
+ },
169
+ readme: {
170
+ file: 'README.md',
171
+ from: 'src/**/!(*.test).js',
172
+ options: 'utf8',
173
+ template: 'MAIN.md',
174
+ to: './'
175
+ },
176
+ rootPath: './',
177
+ sass: {
178
+ enabled: false,
179
+ from: 'sass/**/*.+(scss|sass)',
180
+ path: 'sass',
181
+ to: 'browser/css',
182
+ },
183
+ srcPath: 'src',
184
+ test: {
185
+ options: {
186
+ clearCache: false,
187
+ debug: false,
188
+ ignoreProjects: false,
189
+ json: false,
190
+ selectProjects: false,
191
+ showConfig: false,
192
+ useStderr: false,
193
+ watch: false,
194
+ watchAll: false,
195
+ },
196
+ path: ['src'],
197
+ watch: 'src/**/*.js'
198
+ },
199
+ typescript: {
200
+ config: false,
201
+ enabled: false,
202
+ from: 'src/**/*.ts',
203
+ to: 'dist',
204
+ },
205
+ }
206
+
207
+ /**
208
+ * All the available configuration setting options for running the build.
209
+ * @memberOf module:gulpConfig` `
210
+ * @type {Configurations}
211
+ */
212
+ let gulpConfigurations = null
213
+
214
+ if (fileExists('../../build-tools.config.json')) {
215
+ gulpConfigurations = JSON.parse(readFileSync('../../build-tools.config.json').toString())
216
+ } else {
217
+ if (fileExists('./build-tools.config.json')) {
218
+ gulpConfigurations = JSON.parse(readFileSync('./build-tools.config.json').toString())
219
+ } else {
220
+ console.warn('Missing config path, ensure you have a build-tools.config.js file in you project root')
221
+ }
222
+ }
223
+
224
+ const notation = dotNotate(setDefaults)
225
+ for (let notationKey in notation) {
226
+ const arrayEnding = /(\.\d+)$/
227
+ if (arrayEnding.test(notationKey)) {
228
+ // ends in number a key then it must be an array; use the entire array
229
+ notationKey = notationKey.replace(arrayEnding, '')
230
+ }
231
+ const defaultValue = dotGet(setDefaults, notationKey)
232
+ const existingConfig = dotGet(gulpConfigurations, notationKey, defaultValue)
233
+ dotSet(gulpConfigurations, notationKey, existingConfig)
234
+ }
235
+
236
+ /**
237
+ * Retrieve a value from the configurations, default may be returned.
238
+ * @memberOf module:gulpConfig
239
+ * @param {string|null} path
240
+ * @param {*} defaultValue
241
+ * @returns {*|null}
242
+ */
243
+ export const get = (path = null, defaultValue = null) => dotGet(gulpConfigurations, path, defaultValue)
244
+
245
+ /**
246
+ * Specify a value for the configurations to use.
247
+ * @memberOf module:gulpConfig
248
+ * @param path
249
+ * @param value
250
+ * @returns {*}
251
+ */
252
+ export const set = (path, value) => dotSet(gulpConfigurations, path, value)
package/gulpfile.base.js CHANGED
@@ -1,31 +1,31 @@
1
1
  /**
2
- * Export these functions to your own project in order to customize your build pipeline.
2
+ * Export these functions to your own project to customize your build pipeline.
3
3
  * @file
4
4
  * @author Joshua Heagle <joshuaheagle@gmail.com>
5
5
  * @version 3.0.0
6
6
  * @module js-build-tools
7
7
  */
8
8
 
9
- const build = require('./functions/build.js')
10
- const bundle = require('./functions/bundle.js')
11
- const bundleLint = require('./functions/bundleLint.js')
12
- const bundleMinify = require('./functions/bundleMinify.js')
13
- const compileReadme = require('./functions/compileReadme.js')
14
- const copyFonts = require('./functions/copyFonts.js')
15
- const defaultCmd = require('./functions/default.js')
16
- const dist = require('./functions/dist.js')
17
- const distLint = require('./functions/distLint.js')
18
- const distMinify = require('./functions/distMinify.js')
9
+ const build = require('./dist/build.js')
10
+ const bundle = require('./dist/bundle.js')
11
+ const bundleLint = require('./dist/bundleLint.js')
12
+ const bundleMinify = require('./dist/bundleMinify.js')
13
+ const compileReadme = require('./dist/compileReadme.js')
14
+ const copyFonts = require('./dist/copyFonts.js')
15
+ const defaultCmd = require('./dist/default.js')
16
+ const dist = require('./dist/dist.js')
17
+ const distLint = require('./dist/distLint.js')
18
+ const distMinify = require('./dist/distMinify.js')
19
19
  const gulpConfig = require('./gulp.config.js')
20
- const images = require('./functions/images.js')
21
- const partials = require('./functions/partials.js')
22
- const sass = require('./functions/sass.js')
23
- const testFull = require('./functions/testFull.js')
24
- const testHelpers = require('./functions/testHelpers.js')
25
- const testQuick = require('./functions/testQuick.js')
26
- const typescript = require('./functions/typeScript')
27
- const watchFull = require('./functions/watchFull.js')
28
- const watchTest = require('./functions/watchTest.js')
20
+ const images = require('./dist/images.js')
21
+ const partials = require('./dist/partials.js')
22
+ const sass = require('./dist/sass.js')
23
+ const testFull = require('./dist/testFull.js')
24
+ const testHelpers = require('./dist/testHelpers.js')
25
+ const testQuick = require('./dist/testQuick.js')
26
+ const typescript = require('./dist/typeScript')
27
+ const watchFull = require('./dist/watchFull.js')
28
+ const watchTest = require('./dist/watchTest.js')
29
29
 
30
30
  module.exports = {
31
31
  build,
@@ -0,0 +1,27 @@
1
+ /**
2
+ * import these functions to your own project to customize your build pipeline.
3
+ * @file
4
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
5
+ * @version 3.0.0
6
+ * @module js-build-tools
7
+ */
8
+ export { build } from './functions/build.mjs'
9
+ export { bundle } from './functions/bundle.mjs'
10
+ export { bundleLint } from './functions/bundleLint.mjs'
11
+ export { bundleMinify } from './functions/bundleMinify.mjs'
12
+ export { compileReadme as readme } from './functions/compileReadme.mjs'
13
+ export { copyFonts } from './functions/copyFonts.mjs'
14
+ export { defaultCmd } from './functions/default.mjs'
15
+ export { dist } from './functions/dist.mjs'
16
+ export { distLint } from './functions/distLint.mjs'
17
+ export { distMinify } from './functions/distMinify.mjs'
18
+ export * as gulpConfig from './gulp.config.mjs'
19
+ export { images } from './functions/images.mjs'
20
+ export * as partials from './functions/partials.mjs'
21
+ export { sass } from './functions/sass.mjs'
22
+ export { testFull } from './functions/testFull.mjs'
23
+ export * as testHelpers from './functions/testHelpers.mjs'
24
+ export { testQuick } from './functions/testQuick.mjs'
25
+ export { typeScript as typescript } from './functions/typeScript.mjs'
26
+ export { watchFull } from './functions/watchFull.mjs'
27
+ export { watchTest } from './functions/watchTest.mjs'
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "js-build-tools",
3
- "version": "3.0.3",
3
+ "version": "4.0.0",
4
4
  "description": "Standardised build process with gulp.",
5
5
  "main": "gulpfile.base.js",
6
+ "exports": {
7
+ "import": "./gulpfile.base.mjs",
8
+ "require": "./gulpfile.base.js"
9
+ },
6
10
  "scripts": {
7
11
  "build": "gulp build",
8
12
  "dev": "gulp",
@@ -32,22 +36,21 @@
32
36
  ]
33
37
  },
34
38
  "dependencies": {
35
- "@babel/core": "^7.24.0",
36
- "@babel/plugin-proposal-throw-expressions": "^7.23.3",
37
- "@babel/preset-env": "^7.24.0",
38
- "@babel/preset-typescript": "^7.23.3",
39
- "@babel/runtime-corejs3": "^7.24.0",
39
+ "@babel/core": "^7.24.6",
40
+ "@babel/plugin-transform-modules-commonjs": "^7.24.6",
41
+ "@babel/preset-env": "^7.24.6",
42
+ "@babel/preset-typescript": "^7.24.6",
43
+ "@babel/runtime-corejs3": "^7.24.6",
40
44
  "babel-jest": "^29.7.0",
41
45
  "browserify": "^17.0.0",
42
- "common-exports": "^1.2.3",
43
- "core-js": "^3.36.0",
46
+ "core-js": "^3.37.1",
44
47
  "fs": "^0.0.1-security",
45
- "glob": "^10.3.10",
46
- "gulp": "^4.0.2",
48
+ "glob": "^10.4.1",
49
+ "gulp": "^5.0.0",
47
50
  "gulp-babel": "^8.0.0",
48
51
  "gulp-cache": "^1.1.3",
49
52
  "gulp-cssnano": "^2.1.3",
50
- "gulp-imagemin": "^9.0.0",
53
+ "gulp-imagemin": "github:jheagle/gulp-imagemin#common-js-compatibility",
51
54
  "gulp-rename": "^2.0.0",
52
55
  "gulp-sass": "^5.1.0",
53
56
  "gulp-standard": "^14.0.0",
@@ -57,7 +60,9 @@
57
60
  "jest-environment-jsdom": "^29.7.0",
58
61
  "jsdoc-to-markdown": "^8.0.1",
59
62
  "regenerator-runtime": "^0.14.1",
60
- "sass": "^1.71.1",
63
+ "sass": "^1.77.4",
64
+ "test-filesystem": "^1.3.5",
65
+ "through2": "^4.0.2",
61
66
  "vinyl-source-stream": "^2.0.0"
62
67
  },
63
68
  "files": [
@@ -65,9 +70,10 @@
65
70
  "dist",
66
71
  "functions",
67
72
  "gulpfile.base.js",
73
+ "gulpfile.base.mjs",
68
74
  "gulp.config.js",
69
- "jsdoc.base.js",
70
- "vendor"
75
+ "gulp.config.mjs",
76
+ "jsdoc.base.js"
71
77
  ],
72
78
  "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"
73
79
  }
@@ -1,11 +0,0 @@
1
- const gulpConfig = require('../gulp.config.js')
2
- const minifyFor = require('./partials/minifyFor')
3
-
4
- /**
5
- * Creates the minified bundle file.
6
- * @memberOf module:js-build-tools
7
- * @returns {*}
8
- */
9
- const bundleMinify = () => minifyFor(`${gulpConfig.get('browser.to')}/${gulpConfig.get('browser.name')}.js`, gulpConfig.get('browser.to'))
10
-
11
- module.exports = bundleMinify
@@ -1,14 +0,0 @@
1
- const { setUp } = require('./testHelpers')
2
- const gulpConfig = setUp.gulpConfig
3
- const bundleMinify = require('./bundleMinify')
4
- const minifyFor = require('./partials/minifyFor')
5
-
6
- jest.mock('./partials/minifyFor', () => jest.fn(() => Promise.resolve(true)))
7
-
8
- describe('bundleMinify', () => {
9
- test('calls minifyFor with configurations', () => {
10
- expect.assertions(1)
11
- bundleMinify()
12
- expect(minifyFor).toHaveBeenCalledWith(`${gulpConfig.get('browser.to')}/${gulpConfig.get('browser.name')}.js`, gulpConfig.get('browser.to'))
13
- })
14
- })
@@ -1,11 +0,0 @@
1
- const { addToReadme, readmeTemplate } = require('./partials')
2
- const { series } = require('gulp')
3
-
4
- /**
5
- * Generate the README.md file based off of the template, then append the generated documentation.
6
- * @memberOf module:js-build-tools
7
- * @returns {stream.Stream}
8
- */
9
- const compileReadme = series(readmeTemplate, addToReadme)
10
-
11
- module.exports = compileReadme
@@ -1,11 +0,0 @@
1
- const copyFor = require('./partials/copyFor.js')
2
- const gulpConfig = require('../gulp.config.js')
3
-
4
- /**
5
- * Move the font files into the browser directory.
6
- * @memberOf module:js-build-tools
7
- * @return {stream.Stream}
8
- */
9
- const copyFonts = () => copyFor(gulpConfig.get('fonts.from'), gulpConfig.get('fonts.to'))
10
-
11
- module.exports = copyFonts
@@ -1,14 +0,0 @@
1
- const dist = require('./dist')
2
- const bundle = require('./bundle')
3
- const gulpConfig = require('../gulp.config')
4
- const { series } = require('gulp')
5
-
6
- /**
7
- * Recommended as the default task, runs the simple dist and bundle tasks.
8
- * @memberOf module:js-build-tools
9
- * @param {function} [done=null]
10
- * @returns {stream.Stream}
11
- */
12
- const defaultCmd = (done = null) => gulpConfig.get('browser.enabled') ? series(dist, bundle)(done) : series(dist)(done)
13
-
14
- module.exports = defaultCmd
@@ -1,11 +0,0 @@
1
- const gulpConfig = require('../gulp.config.js')
2
- const minifyFor = require('./partials/minifyFor')
3
-
4
- /**
5
- * Creates minified versions of the dist files.
6
- * @memberOf module:js-build-tools
7
- * @returns {*}
8
- */
9
- const distMinify = () => minifyFor(gulpConfig.get('browser.from'), gulpConfig.get('dist.to'))
10
-
11
- module.exports = distMinify
@@ -1,14 +0,0 @@
1
- const { setUp } = require('./testHelpers')
2
- const gulpConfig = setUp.gulpConfig
3
- const distMinify = require('./distMinify')
4
- const minifyFor = require('./partials/minifyFor')
5
-
6
- jest.mock('./partials/minifyFor', () => jest.fn(() => Promise.resolve(true)))
7
-
8
- describe('distMinify', () => {
9
- test('calls minifyFor with configurations', () => {
10
- expect.assertions(1)
11
- distMinify()
12
- expect(minifyFor).toHaveBeenCalledWith(gulpConfig.get('browser.from'), gulpConfig.get('dist.to'))
13
- })
14
- })
@@ -1,11 +0,0 @@
1
- const gulpConfig = require('../../gulp.config.js')
2
- const { watch } = require('gulp')
3
-
4
- /**
5
- * Create a chokidar instance which watches and triggers change when the globed files are modified.
6
- * @memberOf module:partials
7
- * @returns {FSWatcher}
8
- */
9
- const beginWatcher = () => watch(gulpConfig.get('test.watch'))
10
-
11
- module.exports = beginWatcher
@@ -1,15 +0,0 @@
1
- const gulpConfig = require('../../gulp.config.js')
2
- const removeDirectory = require('./removeDirectory')
3
-
4
- /**
5
- * Deletes all the distribution and browser files (used before create a new build).
6
- * Configure array of directories to remove with 'cleanPaths'.
7
- * @memberOf module:partials
8
- * @returns {Promise<string[]> | *}
9
- */
10
- const clean = () => gulpConfig.get('cleanPaths').reduce(
11
- (promise, path) => promise.then(() => removeDirectory(path)),
12
- Promise.resolve()
13
- )
14
-
15
- module.exports = clean
@@ -1,17 +0,0 @@
1
- const babel = require('gulp-babel')
2
- const { dest, src } = require('gulp')
3
- const distForSrc = require('./distForSrc')
4
- const gulpConfig = require('../../gulp.config.js')
5
-
6
- /**
7
- * Build the distribution for a given source pattern.
8
- * @memberOf module:partials
9
- * @param {string|array} [srcPath='src/config/path/dist/for']
10
- * @param {string} [destPath='dist/config/path']
11
- * @returns {stream.Stream}
12
- */
13
- const distFor = (srcPath = distForSrc(), destPath = gulpConfig.get('dist.to')) => src(srcPath)
14
- .pipe(babel())
15
- .pipe(dest(destPath))
16
-
17
- module.exports = distFor
@@ -1,15 +0,0 @@
1
- const { dest, src } = require('gulp')
2
- const { default: uglify } = require('gulp-uglify-es')
3
- const rename = require('gulp-rename')
4
-
5
- /**
6
- * Minify files and rename the output with '.min' extension.
7
- * @memberOf module:partials
8
- * @returns {*}
9
- */
10
- const minifyFor = (srcSearch, destination) => src(srcSearch)
11
- .pipe(uglify())
12
- .pipe(rename({ extname: '.min.js' }))
13
- .pipe(dest(destination))
14
-
15
- module.exports = minifyFor