js-build-tools 1.2.2 → 2.1.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/README.md +590 -267
- package/dist/build.js +30 -23
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +18 -15
- package/dist/bundle.min.js +1 -1
- package/dist/bundleLint.js +24 -20
- package/dist/bundleLint.min.js +1 -1
- package/dist/bundleMinify.js +16 -20
- package/dist/bundleMinify.min.js +1 -1
- package/dist/compileReadme.js +15 -13
- package/dist/compileReadme.min.js +1 -1
- package/dist/default.js +19 -14
- package/dist/default.min.js +1 -1
- package/dist/dist.js +14 -10
- package/dist/dist.min.js +1 -1
- package/dist/distLint.js +23 -20
- package/dist/distLint.min.js +1 -1
- package/dist/distMinify.js +15 -20
- package/dist/distMinify.min.js +1 -1
- package/dist/partials/addToReadme.js +25 -0
- package/dist/partials/beginWatcher.js +16 -0
- package/dist/partials/clean.js +21 -0
- package/dist/partials/distFor.js +23 -0
- package/dist/partials/distForSrc.js +16 -0
- package/dist/partials/distSeries.js +31 -0
- package/dist/partials/minifyFor.js +21 -0
- package/dist/partials/readmeTemplate.js +18 -0
- package/dist/partials/runOnChange.js +63 -0
- package/dist/partials/tsFor.js +24 -0
- package/dist/partials.js +33 -0
- package/dist/partials.min.js +1 -0
- package/dist/test-helpers/circularObject.js +50 -0
- package/dist/test-helpers/countMatches.js +16 -0
- package/dist/test-helpers/deepReferenceObject.js +20 -0
- package/dist/test-helpers/domItem.js +33 -0
- package/dist/test-helpers/jsonDom.js +20 -0
- package/dist/test-helpers/linkedList.js +23 -0
- package/dist/test-helpers/logObject.js +24 -0
- package/dist/test-helpers/multiReferenceObject.js +20 -0
- package/dist/test-helpers/nodeTree.js +28 -0
- package/dist/test-helpers/setUp.js +127 -0
- package/dist/testFull.js +24 -13
- package/dist/testFull.min.js +1 -1
- package/dist/testHelpers.js +33 -198
- package/dist/testHelpers.min.js +1 -1
- package/dist/testQuick.js +26 -15
- package/dist/testQuick.min.js +1 -1
- package/dist/typeScript.js +14 -0
- package/dist/typeScript.min.js +1 -0
- package/dist/watchFull.js +14 -21
- package/dist/watchFull.min.js +1 -1
- package/dist/watchTest.js +16 -14
- package/dist/watchTest.min.js +1 -1
- package/functions/build.js +28 -25
- package/functions/build.test.js +59 -0
- package/functions/bundle.js +17 -15
- package/functions/bundle.test.js +68 -0
- package/functions/bundleLint.js +19 -17
- package/functions/bundleLint.test.js +61 -0
- package/functions/bundleMinify.js +12 -15
- package/functions/bundleMinify.test.js +14 -0
- package/functions/compileReadme.js +11 -10
- package/functions/compileReadme.test.js +18 -0
- package/functions/default.js +14 -11
- package/functions/default.test.js +32 -0
- package/functions/dist.js +11 -9
- package/functions/dist.test.js +43 -0
- package/functions/distLint.js +19 -17
- package/functions/distLint.test.js +58 -0
- package/functions/distMinify.js +12 -15
- package/functions/distMinify.test.js +14 -0
- package/functions/partials/addToReadme.js +20 -0
- package/functions/partials/addToReadme.test.js +28 -0
- package/functions/partials/beginWatcher.js +12 -0
- package/functions/partials/beginWatcher.test.js +18 -0
- package/functions/partials/clean.js +14 -0
- package/functions/partials/clean.test.js +20 -0
- package/functions/partials/distFor.js +18 -0
- package/functions/partials/distFor.test.js +125 -0
- package/functions/partials/distForSrc.js +14 -0
- package/functions/partials/distForSrc.test.js +17 -0
- package/functions/partials/distSeries.js +21 -0
- package/functions/partials/distSeries.test.js +33 -0
- package/functions/partials/minifyFor.js +16 -0
- package/functions/partials/minifyFor.test.js +48 -0
- package/functions/partials/readmeTemplate.js +15 -0
- package/functions/partials/readmeTemplate.test.js +33 -0
- package/functions/partials/runOnChange.js +57 -0
- package/functions/partials/runOnChange.test.js +93 -0
- package/functions/partials/tsFor.js +21 -0
- package/functions/partials/tsFor.test.js +44 -0
- package/functions/partials.js +32 -0
- package/functions/partials.test.js +7 -0
- package/functions/test-helpers/circularObject.js +28 -0
- package/functions/test-helpers/circularObject.test.js +14 -0
- package/functions/test-helpers/countMatches.js +11 -0
- package/functions/test-helpers/countMatches.test.js +9 -0
- package/functions/test-helpers/deepReferenceObject.js +25 -0
- package/functions/test-helpers/deepReferenceObject.test.js +7 -0
- package/functions/test-helpers/domItem.js +31 -0
- package/functions/test-helpers/domItem.test.js +12 -0
- package/functions/test-helpers/jsonDom.js +16 -0
- package/functions/test-helpers/jsonDom.test.js +12 -0
- package/functions/test-helpers/linkedList.js +10 -0
- package/functions/test-helpers/linkedList.test.js +22 -0
- package/functions/test-helpers/logObject.js +18 -0
- package/functions/test-helpers/logObject.test.js +20 -0
- package/functions/test-helpers/multiReferenceObject.js +25 -0
- package/functions/test-helpers/multiReferenceObject.test.js +14 -0
- package/functions/test-helpers/nodeTree.js +11 -0
- package/functions/test-helpers/nodeTree.test.js +18 -0
- package/functions/test-helpers/setUp.js +67 -0
- package/functions/test-helpers/setUp.test.js +18 -0
- package/functions/testFull.js +20 -10
- package/functions/testFull.test.js +16 -0
- package/functions/testHelpers.js +27 -137
- package/functions/testHelpers.test.js +7 -100
- package/functions/testQuick.js +20 -10
- package/functions/testQuick.test.js +16 -0
- package/functions/typeScript.js +11 -0
- package/functions/typeScript.test.js +10 -0
- package/functions/watchFull.js +6 -12
- package/functions/watchFull.test.js +40 -0
- package/functions/watchTest.js +4 -2
- package/functions/watchTest.test.js +48 -0
- package/gulp.config.js +161 -16
- package/gulpfile.base.js +9 -0
- package/package.json +11 -11
- package/dist/addToReadme.js +0 -22
- package/dist/addToReadme.min.js +0 -1
- package/dist/clean.js +0 -11
- package/dist/clean.min.js +0 -1
- package/dist/distFor.js +0 -21
- package/dist/distFor.min.js +0 -1
- package/dist/readmeTemplate.js +0 -15
- package/dist/readmeTemplate.min.js +0 -1
- package/functions/addToReadme.js +0 -17
- package/functions/clean.js +0 -10
- package/functions/distFor.js +0 -15
- package/functions/readmeTemplate.js +0 -13
package/functions/testQuick.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
const gulpConfig = require('../gulp.config.js')
|
|
2
|
-
const { runCLI
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Run the Jest tests for files which have been modified (based on git status).
|
|
6
|
-
* @
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
const gulpConfig = require('../gulp.config.js')
|
|
2
|
+
const { runCLI } = require('jest')
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Run the Jest tests for files which have been modified (based on git status).
|
|
6
|
+
* @function
|
|
7
|
+
* @memberOf module:js-build-tools
|
|
8
|
+
* @param {function} [done=null]
|
|
9
|
+
* @param {Array.<string>|string} [testPath='path/config/test/files']
|
|
10
|
+
* @returns {Promise<*>}
|
|
11
|
+
*/
|
|
12
|
+
const testQuick = (done = null, testPath = gulpConfig.get('testPath')) => {
|
|
13
|
+
if (!Array.isArray(testPath)) {
|
|
14
|
+
// The testPath must be an array of strings
|
|
15
|
+
testPath = [testPath]
|
|
16
|
+
}
|
|
17
|
+
return runCLI({ onlyChanged: true }, testPath)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = testQuick
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { setUp } = require('./testHelpers')
|
|
2
|
+
const gulpConfig = setUp.gulpConfig
|
|
3
|
+
const { runCLI } = require('jest')
|
|
4
|
+
const testQuick = require('./testQuick')
|
|
5
|
+
|
|
6
|
+
jest.mock('jest', () => ({
|
|
7
|
+
'runCLI': jest.fn(() => Promise.resolve(true))
|
|
8
|
+
}))
|
|
9
|
+
|
|
10
|
+
describe('testQuick', () => {
|
|
11
|
+
test('runs the jest CLI with onlyChanged option', () => {
|
|
12
|
+
expect.assertions(1)
|
|
13
|
+
testQuick()
|
|
14
|
+
expect(runCLI).toHaveBeenCalledWith({ onlyChanged: true }, [gulpConfig.get('testPath')])
|
|
15
|
+
})
|
|
16
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const typeScript = require('./typeScript')
|
|
2
|
+
const tsFor = require('./partials/tsFor')
|
|
3
|
+
jest.mock('./partials/tsFor', () => jest.fn())
|
|
4
|
+
|
|
5
|
+
describe('typeScript', () => {
|
|
6
|
+
test('calls tsFor with no parameters', () => {
|
|
7
|
+
typeScript()
|
|
8
|
+
expect(tsFor).toHaveBeenCalled()
|
|
9
|
+
})
|
|
10
|
+
})
|
package/functions/watchFull.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
const
|
|
2
|
-
const distFor = require('./distFor')
|
|
3
|
-
const gulpConfig = require('../gulp.config.js')
|
|
4
|
-
const { parallel, series, watch } = require('gulp')
|
|
5
|
-
const testQuick = require('./testQuick')
|
|
1
|
+
const { beginWatcher, runOnChange } = require('./partials')
|
|
6
2
|
|
|
7
3
|
/**
|
|
8
4
|
* Watch for changes and run the distribution for the changed files, then bundle and test the changed files.
|
|
9
|
-
* @
|
|
5
|
+
* @function
|
|
6
|
+
* @memberOf module:js-build-tools
|
|
7
|
+
* @returns {FSWatcher}
|
|
10
8
|
*/
|
|
11
|
-
const watchFull = () =>
|
|
12
|
-
.on('change',
|
|
13
|
-
const pathRegex = new RegExp(`^${gulpConfig.srcPath}(.*\\/).+\\.js$`, 'i')
|
|
14
|
-
const distForPath = () => distFor(path, path.replace(pathRegex, `${gulpConfig.distPath}$1`))
|
|
15
|
-
return parallel(testQuick, series(distForPath, bundle))()
|
|
16
|
-
})
|
|
9
|
+
const watchFull = () => beginWatcher()
|
|
10
|
+
.on('change', runOnChange)
|
|
17
11
|
|
|
18
12
|
module.exports = watchFull
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const setUp = require('./test-helpers/setUp')
|
|
3
|
+
setUp.setDefaults('test-watch-full')
|
|
4
|
+
const gulpConfig = setUp.gulpConfig
|
|
5
|
+
const watchFull = require('./watchFull')
|
|
6
|
+
const beginWatcher = require('./partials/beginWatcher')
|
|
7
|
+
const runOnChange = require('./partials/runOnChange')
|
|
8
|
+
|
|
9
|
+
jest.mock('./partials/beginWatcher', () => jest.fn(() => ({ on: (event, fn) => fn() })))
|
|
10
|
+
jest.mock('./partials/runOnChange', () => jest.fn())
|
|
11
|
+
|
|
12
|
+
const rawContents = 'const { beginWatcher, runOnChange } = require(\'./partials\')\n' +
|
|
13
|
+
'\n' +
|
|
14
|
+
'/**\n' +
|
|
15
|
+
' * Watch for changes and run the distribution for the changed files, then bundle and test the changed files.\n' +
|
|
16
|
+
' * @function\n' +
|
|
17
|
+
' * @memberOf module:js-build-tools\n' +
|
|
18
|
+
' * @returns {FSWatcher}\n' +
|
|
19
|
+
' */\n' +
|
|
20
|
+
'const watchFull = () => beginWatcher()\n' +
|
|
21
|
+
' .on(\'change\', runOnChange)\n' +
|
|
22
|
+
'\n' +
|
|
23
|
+
'module.exports = watchFull\n'
|
|
24
|
+
|
|
25
|
+
beforeEach(setUp.beforeEach)
|
|
26
|
+
|
|
27
|
+
afterEach(setUp.afterEach)
|
|
28
|
+
|
|
29
|
+
describe('watchFull', () => {
|
|
30
|
+
test('should call beginWatcher and runOnChange for change event', () => {
|
|
31
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
32
|
+
gulpConfig.set('watchSearch', `${srcPath}/*.js`)
|
|
33
|
+
const srcFile = `${srcPath}/watchFull.js`
|
|
34
|
+
fs.writeFileSync(srcFile, rawContents)
|
|
35
|
+
expect.assertions(2)
|
|
36
|
+
watchFull()
|
|
37
|
+
expect(beginWatcher).toHaveBeenCalled()
|
|
38
|
+
expect(runOnChange).toHaveBeenCalled()
|
|
39
|
+
})
|
|
40
|
+
})
|
package/functions/watchTest.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
const gulpConfig = require('../gulp.config.js')
|
|
2
|
-
const {
|
|
2
|
+
const { watch } = require('gulp')
|
|
3
3
|
const testQuick = require('./testQuick')
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Watch for changes and run the tests.
|
|
7
|
+
* @function
|
|
8
|
+
* @memberOf module:js-build-tools
|
|
7
9
|
* @returns {*}
|
|
8
10
|
*/
|
|
9
|
-
const watchTest = () => watch(gulpConfig.watchSearch, { ignoreInitial: false },
|
|
11
|
+
const watchTest = () => watch(gulpConfig.get('watchSearch'), { ignoreInitial: false }, testQuick)
|
|
10
12
|
|
|
11
13
|
module.exports = watchTest
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const setUp = require('./test-helpers/setUp')
|
|
2
|
+
setUp.setDefaults('test-watch-test')
|
|
3
|
+
const gulpConfig = setUp.gulpConfig
|
|
4
|
+
gulpConfig.set('watchSearch', '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
|
+
jest.mock('./testQuick', () => jest.fn(() => Promise.resolve(true)))
|
|
11
|
+
|
|
12
|
+
const rawContents = 'const gulpConfig = require(\'../gulp.config.js\')\n' +
|
|
13
|
+
'const { watch } = require(\'gulp\')\n' +
|
|
14
|
+
'const testQuick = require(\'./testQuick\')\n' +
|
|
15
|
+
'\n' +
|
|
16
|
+
'/**\n' +
|
|
17
|
+
' * Watch for changes and run the tests.\n' +
|
|
18
|
+
' * @function\n' +
|
|
19
|
+
' * @memberOf module:js-build-tools\n' +
|
|
20
|
+
' * @returns {*}\n' +
|
|
21
|
+
' */\n' +
|
|
22
|
+
'const watchTest = () => watch(gulpConfig.get(\'watchSearch\'), { ignoreInitial: false }, testQuick)\n' +
|
|
23
|
+
'\n' +
|
|
24
|
+
'module.exports = watchTest\n'
|
|
25
|
+
|
|
26
|
+
const filePath = gulpConfig.get('srcPath') + '/watchTest.js'
|
|
27
|
+
|
|
28
|
+
beforeEach(() => setUp.beforeEach()
|
|
29
|
+
.then(
|
|
30
|
+
() => fs.writeFileSync(filePath, rawContents)
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
afterEach(setUp.afterEach)
|
|
35
|
+
|
|
36
|
+
describe('watchTest', () => {
|
|
37
|
+
test('returns instance of EventEmitter / FSWatcher and calls testQuick on change', done => {
|
|
38
|
+
expect.assertions(2)
|
|
39
|
+
const fsWatcher = watchTest()
|
|
40
|
+
expect(fsWatcher).toBeInstanceOf(EventEmitter)
|
|
41
|
+
fsWatcher.emit('change')
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
expect(testQuick).toHaveBeenCalled()
|
|
44
|
+
done()
|
|
45
|
+
}, 500)
|
|
46
|
+
fsWatcher.close()
|
|
47
|
+
})
|
|
48
|
+
})
|
package/gulp.config.js
CHANGED
|
@@ -1,30 +1,175 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Modify these configurations to match your project specifications.
|
|
3
|
+
* @file
|
|
4
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
5
|
+
* @version 2.0.0
|
|
6
|
+
* @module gulpConfig
|
|
7
|
+
* @memberOf module:js-build-tools
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Retrieve a value from an object with the path (key), return a given default if the key is not found.
|
|
12
|
+
* @memberOf module:gulpConfig
|
|
13
|
+
* @param {Object<string, *>} [config=[]]
|
|
14
|
+
* @param {string|null} [path=null]
|
|
15
|
+
* @param {*} [defaultValue=null]
|
|
16
|
+
* @returns {*|null}
|
|
17
|
+
*/
|
|
18
|
+
const defaultConfig = (config = {}, path = null, defaultValue = null) => {
|
|
19
|
+
if (!path) {
|
|
20
|
+
return config
|
|
21
|
+
}
|
|
2
22
|
if (typeof config[path] === 'undefined') {
|
|
3
23
|
return defaultValue
|
|
4
24
|
}
|
|
5
25
|
return config[path]
|
|
6
26
|
}
|
|
7
|
-
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A setting that may be an array of strings or a string only.
|
|
30
|
+
* @typedef {Array<string>|string} module:gulpConfig~ArrayableSetting
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A setting that may be true or false.
|
|
35
|
+
* @typedef {boolean} module:gulpConfig~BooleanSetting
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A setting that may be flag 'false' or provide a StringSetting
|
|
40
|
+
* @typedef {false|StringSetting} module:gulpConfig~FlagStringSetting
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* An object of boolean settings used as flags.
|
|
45
|
+
* @typedef {Object<string, BooleanSetting>} module:gulpConfig~FlagsSetting
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Configure cli options for running Jest.
|
|
50
|
+
* @typedef {FlagsSetting} module:gulpConfig~JestTestFlags
|
|
51
|
+
* @property {BooleanSetting} clearCache
|
|
52
|
+
* @property {BooleanSetting} debug
|
|
53
|
+
* @property {BooleanSetting} ignoreProjects:
|
|
54
|
+
* @property {BooleanSetting} json
|
|
55
|
+
* @property {BooleanSetting} selectProjects
|
|
56
|
+
* @property {BooleanSetting} showConfig
|
|
57
|
+
* @property {BooleanSetting} useStderr
|
|
58
|
+
* @property {BooleanSetting} watch
|
|
59
|
+
* @property {BooleanSetting} watchAll
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* A setting that may only be a string.
|
|
64
|
+
* @typedef {string} module:gulpConfig~StringSetting
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Any single configuration option is a Setting.
|
|
69
|
+
* @typedef {ArrayableSetting|BooleanSetting|FlagsSetting|StringSetting} Setting
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A set of Configurations options defined by Settings.
|
|
74
|
+
* @typedef {Object<string, Setting>} module:gulpConfig~Configurations
|
|
75
|
+
* @property {StringSetting} browserName
|
|
76
|
+
* @property {StringSetting} browserPath
|
|
77
|
+
* @property {StringSetting} distMain
|
|
78
|
+
* @property {StringSetting} distPath
|
|
79
|
+
* @property {ArrayableSetting} distSearch
|
|
80
|
+
* @property {BooleanSetting} nodeOnly
|
|
81
|
+
* @property {StringSetting} readmeTemplate
|
|
82
|
+
* @property {ArrayableSetting} readmeOptions
|
|
83
|
+
* @property {StringSetting} readmeFile
|
|
84
|
+
* @property {StringSetting} readmePath
|
|
85
|
+
* @property {ArrayableSetting} readmeSearch
|
|
86
|
+
* @property {StringSetting} rootPath
|
|
87
|
+
* @property {StringSetting} srcPath
|
|
88
|
+
* @property {ArrayableSetting} srcSearch
|
|
89
|
+
* @property {JestTestFlags} testOptions
|
|
90
|
+
* @property {ArrayableSetting} testPath
|
|
91
|
+
* @property {FlagStringSetting} useTsConfig
|
|
92
|
+
* @property {ArrayableSetting} watchSearch
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* All the available configuration setting options for running the build.
|
|
97
|
+
* @memberOf module:gulpConfig` `
|
|
98
|
+
* @type {Configurations}
|
|
99
|
+
*/
|
|
100
|
+
let gulpConfigurations = {}
|
|
8
101
|
try {
|
|
9
|
-
|
|
102
|
+
gulpConfigurations = require('../../build-tools.config.js')
|
|
10
103
|
} catch (isUndefined) {
|
|
11
104
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
105
|
+
// Missing main project config, using default path
|
|
106
|
+
gulpConfigurations = require('./build-tools.config.js')
|
|
14
107
|
} catch (stillUndefined) {
|
|
15
108
|
console.warn('Missing config path, ensure you have a build-tools.config.js file in you project root')
|
|
16
109
|
}
|
|
17
110
|
}
|
|
111
|
+
|
|
112
|
+
const setDefaults = {
|
|
113
|
+
browserName: 'default',
|
|
114
|
+
browserPath: 'browser',
|
|
115
|
+
distMain: 'dist/main',
|
|
116
|
+
distPath: 'dist',
|
|
117
|
+
distSearch: 'dist/**/*.js',
|
|
118
|
+
nodeOnly: false,
|
|
119
|
+
readmeTemplate: 'MAIN.md',
|
|
120
|
+
readmeOptions: 'utf8',
|
|
121
|
+
readmeFile: 'README.md',
|
|
122
|
+
readmePath: './',
|
|
123
|
+
readmeSearch: 'src/**/!(*.test).js',
|
|
124
|
+
rootPath: './',
|
|
125
|
+
srcPath: 'src',
|
|
126
|
+
srcSearch: 'src/**/!(*.test).js',
|
|
127
|
+
testOptions: {
|
|
128
|
+
clearCache: false,
|
|
129
|
+
debug: false,
|
|
130
|
+
ignoreProjects: false,
|
|
131
|
+
json: false,
|
|
132
|
+
selectProjects: false,
|
|
133
|
+
showConfig: false,
|
|
134
|
+
useStderr: false,
|
|
135
|
+
watch: false,
|
|
136
|
+
watchAll: false,
|
|
137
|
+
},
|
|
138
|
+
testPath: ['src'],
|
|
139
|
+
tsSearch: 'src/**/*.ts',
|
|
140
|
+
useTsConfig: false,
|
|
141
|
+
watchSearch: 'src/**/*.js'
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
Object.keys(setDefaults).forEach(parentKey => {
|
|
145
|
+
gulpConfigurations[parentKey] = defaultConfig(gulpConfigurations, parentKey, setDefaults[parentKey])
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Retrieve a value from teh configurations, default may be returned.
|
|
150
|
+
* @function
|
|
151
|
+
* @memberOf module:gulpConfig
|
|
152
|
+
* @param {string|null} path
|
|
153
|
+
* @param {*} defaultValue
|
|
154
|
+
* @returns {*|null}
|
|
155
|
+
*/
|
|
156
|
+
const get = (path = null, defaultValue = null) => defaultConfig(gulpConfigurations, path, defaultValue)
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Specify a value for the configurations to use.
|
|
160
|
+
* @function
|
|
161
|
+
* @memberOf module:gulpConfig
|
|
162
|
+
* @param path
|
|
163
|
+
* @param value
|
|
164
|
+
* @returns {*}
|
|
165
|
+
*/
|
|
166
|
+
const set = (path, value) => {
|
|
167
|
+
gulpConfigurations[path] = value
|
|
168
|
+
return value
|
|
169
|
+
}
|
|
170
|
+
|
|
18
171
|
module.exports = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
distPath: defaultConfig(parentConfig, 'distPath', 'dist'),
|
|
23
|
-
distSearch: defaultConfig(parentConfig, 'distSearch', 'dist/**/*.js'),
|
|
24
|
-
nodeOnly: defaultConfig(parentConfig, 'nodeOnly', false),
|
|
25
|
-
readmeTemplate: defaultConfig(parentConfig, 'readmeTemplate', 'MAIN.md'),
|
|
26
|
-
srcPath: defaultConfig(parentConfig, 'srcPath', 'src'),
|
|
27
|
-
srcSearch: defaultConfig(parentConfig, 'srcSearch', 'src/**/!(*.test).js'),
|
|
28
|
-
testPath: defaultConfig(parentConfig, 'testPath', ['src']),
|
|
29
|
-
watchSearch: defaultConfig(parentConfig, 'watchSearch', 'src/**/*.js'),
|
|
172
|
+
defaultConfig,
|
|
173
|
+
get,
|
|
174
|
+
set
|
|
30
175
|
}
|
package/gulpfile.base.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export these functions to your own project in order to customize your build pipeline.
|
|
3
|
+
* @file
|
|
4
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
5
|
+
* @version 2.0.0
|
|
6
|
+
* @module js-build-tools
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const gulpConfig = require('./gulp.config.js')
|
|
1
10
|
const build = require('./functions/build.js')
|
|
2
11
|
const compileReadme = require('./functions/compileReadme.js')
|
|
3
12
|
const defaultCmd = require('./functions/default.js')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-build-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Standardised build process with gulp.",
|
|
5
5
|
"main": "gulpfile.base.js",
|
|
6
6
|
"scripts": {
|
|
@@ -33,25 +33,25 @@
|
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@babel/core": "^7.22.
|
|
37
|
-
"@babel/plugin-proposal-throw-expressions": "^7.
|
|
38
|
-
"@babel/preset-env": "^7.22.
|
|
39
|
-
"@babel/runtime-corejs3": "^7.22.
|
|
40
|
-
"babel-jest": "^29.
|
|
36
|
+
"@babel/core": "^7.22.15",
|
|
37
|
+
"@babel/plugin-proposal-throw-expressions": "^7.22.5",
|
|
38
|
+
"@babel/preset-env": "^7.22.15",
|
|
39
|
+
"@babel/runtime-corejs3": "^7.22.15",
|
|
40
|
+
"babel-jest": "^29.6.4",
|
|
41
41
|
"browserify": "^17.0.0",
|
|
42
|
-
"core-js": "^3.
|
|
42
|
+
"core-js": "^3.32.1",
|
|
43
43
|
"del": "^6.1.1",
|
|
44
44
|
"fs": "^0.0.1-security",
|
|
45
|
-
"glob": "^10.
|
|
45
|
+
"glob": "^10.3.4",
|
|
46
46
|
"gulp": "^4.0.2",
|
|
47
47
|
"gulp-babel": "^8.0.0",
|
|
48
48
|
"gulp-rename": "^2.0.0",
|
|
49
49
|
"gulp-standard": "^14.0.0",
|
|
50
50
|
"gulp-uglify-es": "^3.0.0",
|
|
51
|
-
"jest": "^29.
|
|
52
|
-
"jest-environment-jsdom": "^29.
|
|
51
|
+
"jest": "^29.6.4",
|
|
52
|
+
"jest-environment-jsdom": "^29.6.4",
|
|
53
53
|
"jsdoc-to-markdown": "^8.0.0",
|
|
54
|
-
"regenerator-runtime": "^0.
|
|
54
|
+
"regenerator-runtime": "^0.14.0",
|
|
55
55
|
"vinyl-source-stream": "^2.0.0"
|
|
56
56
|
},
|
|
57
57
|
"files": [
|
package/dist/addToReadme.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const gulpConfig = require('../gulp.config.js')
|
|
5
|
-
const jsdoc2md = require('jsdoc-to-markdown')
|
|
6
|
-
const {
|
|
7
|
-
globSync
|
|
8
|
-
} = require('glob')
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Appends all the jsdoc comments to the readme file. Assumes empty or templated file.
|
|
12
|
-
* @returns {string|Uint8Array}
|
|
13
|
-
*/
|
|
14
|
-
const addToReadme = done => {
|
|
15
|
-
const files = globSync(gulpConfig.srcSearch)
|
|
16
|
-
const readme = jsdoc2md.renderSync({
|
|
17
|
-
files: files
|
|
18
|
-
})
|
|
19
|
-
fs.appendFileSync('README.md', readme, 'utf8')
|
|
20
|
-
done()
|
|
21
|
-
}
|
|
22
|
-
module.exports = addToReadme
|
package/dist/addToReadme.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const fs=require("fs"),gulpConfig=require("../gulp.config.js"),jsdoc2md=require("jsdoc-to-markdown"),{globSync:globSync}=require("glob"),addToReadme=e=>{const o=globSync(gulpConfig.srcSearch),d=jsdoc2md.renderSync({files:o});fs.appendFileSync("README.md",d,"utf8"),e()};module.exports=addToReadme;
|
package/dist/clean.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const del = require('del')
|
|
4
|
-
const gulpConfig = require('../gulp.config.js')
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Deletes all the distribution and browser files (used before create a new build).
|
|
8
|
-
* @returns {Promise<string[]> | *}
|
|
9
|
-
*/
|
|
10
|
-
const clean = () => del([gulpConfig.distPath, gulpConfig.browserPath])
|
|
11
|
-
module.exports = clean
|
package/dist/clean.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const del=require("del"),gulpConfig=require("../gulp.config.js"),clean=()=>del([gulpConfig.distPath,gulpConfig.browserPath]);module.exports=clean;
|
package/dist/distFor.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const babel = require('gulp-babel')
|
|
4
|
-
const {
|
|
5
|
-
dest,
|
|
6
|
-
src
|
|
7
|
-
} = require('gulp')
|
|
8
|
-
const gulpConfig = require('../gulp.config.js')
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Build the distribution for a given source pattern.
|
|
12
|
-
* @param {string|array} srcPath
|
|
13
|
-
* @param {string} destPath
|
|
14
|
-
* @returns {*}
|
|
15
|
-
*/
|
|
16
|
-
const distFor = function () {
|
|
17
|
-
const srcPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gulpConfig.srcSearch
|
|
18
|
-
const destPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gulpConfig.distPath
|
|
19
|
-
return src(srcPath).pipe(babel()).pipe(dest(destPath))
|
|
20
|
-
}
|
|
21
|
-
module.exports = distFor
|
package/dist/distFor.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const babel=require("gulp-babel"),{dest:dest,src:src}=require("gulp"),gulpConfig=require("../gulp.config.js"),distFor=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:gulpConfig.srcSearch,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:gulpConfig.distPath;return src(e).pipe(babel()).pipe(dest(r))};module.exports=distFor;
|
package/dist/readmeTemplate.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
dest,
|
|
5
|
-
src
|
|
6
|
-
} = require('gulp')
|
|
7
|
-
const gulpConfig = require('../gulp.config.js')
|
|
8
|
-
const rename = require('gulp-rename')
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Copy a readme template into the README.md file.
|
|
12
|
-
* @returns {*}
|
|
13
|
-
*/
|
|
14
|
-
const readmeTemplate = () => src(gulpConfig.readmeTemplate).pipe(rename('README.md')).pipe(dest('.'))
|
|
15
|
-
module.exports = readmeTemplate
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const{dest:dest,src:src}=require("gulp"),gulpConfig=require("../gulp.config.js"),rename=require("gulp-rename"),readmeTemplate=()=>src(gulpConfig.readmeTemplate).pipe(rename("README.md")).pipe(dest("."));module.exports=readmeTemplate;
|
package/functions/addToReadme.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const gulpConfig = require('../gulp.config.js')
|
|
3
|
-
const jsdoc2md = require('jsdoc-to-markdown')
|
|
4
|
-
const { globSync } = require('glob')
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Appends all the jsdoc comments to the readme file. Assumes empty or templated file.
|
|
8
|
-
* @returns {string|Uint8Array}
|
|
9
|
-
*/
|
|
10
|
-
const addToReadme = done => {
|
|
11
|
-
const files = globSync(gulpConfig.srcSearch)
|
|
12
|
-
const readme = jsdoc2md.renderSync({ files: files })
|
|
13
|
-
fs.appendFileSync('README.md', readme, 'utf8')
|
|
14
|
-
done()
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
module.exports = addToReadme
|
package/functions/clean.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const del = require('del')
|
|
2
|
-
const gulpConfig = require('../gulp.config.js')
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Deletes all the distribution and browser files (used before create a new build).
|
|
6
|
-
* @returns {Promise<string[]> | *}
|
|
7
|
-
*/
|
|
8
|
-
const clean = () => del([gulpConfig.distPath, gulpConfig.browserPath])
|
|
9
|
-
|
|
10
|
-
module.exports = clean
|
package/functions/distFor.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const babel = require('gulp-babel')
|
|
2
|
-
const { dest, src } = require('gulp')
|
|
3
|
-
const gulpConfig = require('../gulp.config.js')
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Build the distribution for a given source pattern.
|
|
7
|
-
* @param {string|array} srcPath
|
|
8
|
-
* @param {string} destPath
|
|
9
|
-
* @returns {*}
|
|
10
|
-
*/
|
|
11
|
-
const distFor = (srcPath = gulpConfig.srcSearch, destPath = gulpConfig.distPath) => src(srcPath)
|
|
12
|
-
.pipe(babel())
|
|
13
|
-
.pipe(dest(destPath))
|
|
14
|
-
|
|
15
|
-
module.exports = distFor
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const { dest, src } = require('gulp')
|
|
2
|
-
const gulpConfig = require('../gulp.config.js')
|
|
3
|
-
const rename = require('gulp-rename')
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Copy a readme template into the README.md file.
|
|
7
|
-
* @returns {*}
|
|
8
|
-
*/
|
|
9
|
-
const readmeTemplate = () => src(gulpConfig.readmeTemplate)
|
|
10
|
-
.pipe(rename('README.md'))
|
|
11
|
-
.pipe(dest('.'))
|
|
12
|
-
|
|
13
|
-
module.exports = readmeTemplate
|