js-build-tools 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/functions/gulpConfigEntries.test.mjs +23 -0
- package/gulp.config.js +4 -255
- package/package.json +4 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { execFileSync } from 'child_process'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import * as esmConfig from '../gulp.config.mjs'
|
|
4
|
+
|
|
5
|
+
const root = path.resolve(__dirname, '..')
|
|
6
|
+
const readFromCjs = (dotPath) => JSON.parse(execFileSync(process.execPath, [
|
|
7
|
+
'-e',
|
|
8
|
+
`console.log(JSON.stringify(require('./gulp.config.js').get(${JSON.stringify(dotPath)})))`
|
|
9
|
+
], { cwd: root }).toString())
|
|
10
|
+
|
|
11
|
+
describe('gulp.config entries', () => {
|
|
12
|
+
test('the CommonJS entry exposes the same configuration as the ESM source', () => {
|
|
13
|
+
for (const dotPath of ['docs', 'browser', 'dist', 'typescript']) {
|
|
14
|
+
expect(readFromCjs(dotPath)).toEqual(JSON.parse(JSON.stringify(esmConfig.get(dotPath))))
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test('the CommonJS entry carries browser.bundles and browser.ignore/exclude', () => {
|
|
19
|
+
for (const dotPath of ['browser.bundles', 'browser.ignore', 'browser.exclude']) {
|
|
20
|
+
expect(readFromCjs(dotPath)).toEqual(JSON.parse(JSON.stringify(esmConfig.get(dotPath))))
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
})
|
package/gulp.config.js
CHANGED
|
@@ -1,255 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* @version 3.0.0
|
|
6
|
-
* @module gulpConfig
|
|
7
|
-
* @memberOf module:js-build-tools
|
|
8
|
-
*/
|
|
9
|
-
const { fileExists } = require('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
|
-
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')
|
|
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
|
-
* All the available configuration setting options for running the build.
|
|
208
|
-
* @memberOf module:gulpConfig` `
|
|
209
|
-
* @type {Configurations}
|
|
210
|
-
*/
|
|
211
|
-
let gulpConfigurations = {}
|
|
212
|
-
if (fileExists(process.cwd() + '/build-tools.config.json')) {
|
|
213
|
-
gulpConfigurations = JSON.parse(readFileSync(process.cwd() + '/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
|
-
}
|
|
221
|
-
|
|
222
|
-
const notation = dotNotate(setDefaults)
|
|
223
|
-
for (let notationKey in notation) {
|
|
224
|
-
const arrayEnding = /(\.\d+)$/
|
|
225
|
-
if (arrayEnding.test(notationKey)) {
|
|
226
|
-
// ends in number a key then it must be an array; use the entire array
|
|
227
|
-
notationKey = notationKey.replace(arrayEnding, '')
|
|
228
|
-
}
|
|
229
|
-
const defaultValue = dotGet(setDefaults, notationKey)
|
|
230
|
-
const existingConfig = dotGet(gulpConfigurations, notationKey, defaultValue)
|
|
231
|
-
dotSet(gulpConfigurations, notationKey, existingConfig)
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Retrieve a value from the configurations, default may be returned.
|
|
236
|
-
* @memberOf module:gulpConfig
|
|
237
|
-
* @param {string|null} path
|
|
238
|
-
* @param {*} defaultValue
|
|
239
|
-
* @returns {*|null}
|
|
240
|
-
*/
|
|
241
|
-
const get = (path = null, defaultValue = null) => dotGet(gulpConfigurations, path, defaultValue)
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Specify a value for the configurations to use.
|
|
245
|
-
* @memberOf module:gulpConfig
|
|
246
|
-
* @param path
|
|
247
|
-
* @param value
|
|
248
|
-
* @returns {*}
|
|
249
|
-
*/
|
|
250
|
-
const set = (path, value) => dotSet(gulpConfigurations, path, value)
|
|
251
|
-
|
|
252
|
-
module.exports = {
|
|
253
|
-
get,
|
|
254
|
-
set
|
|
255
|
-
}
|
|
1
|
+
// gulp.config.mjs is the single source of truth. This CommonJS entry re-exports it, so CommonJS consumers
|
|
2
|
+
// (dist/*.js, jsdoc.base.js, require('js-build-tools/gulp.config')) read exactly the same configuration.
|
|
3
|
+
// Relies on require(esm), which Node 22.12+ supports natively.
|
|
4
|
+
module.exports = require('./gulp.config.mjs')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-build-tools",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "Standardised build process with gulp.",
|
|
5
5
|
"main": "gulpfile.base.js",
|
|
6
6
|
"exports": {
|
|
@@ -108,5 +108,8 @@
|
|
|
108
108
|
"gulp-imagemin": "github:jheagle/gulp-imagemin#common-js-compatibility",
|
|
109
109
|
"typedoc": "^0.28.20",
|
|
110
110
|
"typescript": "^6.0.3"
|
|
111
|
+
},
|
|
112
|
+
"engines": {
|
|
113
|
+
"node": ">=22.12.0"
|
|
111
114
|
}
|
|
112
115
|
}
|