js-build-tools 3.0.4 → 4.0.1
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 +166 -426
- package/babel.config.js +1 -1
- package/dist/build.js +33 -34
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +14 -9
- package/dist/bundle.min.js +1 -1
- package/dist/bundleLint.js +15 -11
- package/dist/bundleLint.min.js +1 -1
- package/dist/bundleMinify.js +11 -5
- package/dist/bundleMinify.min.js +1 -1
- package/dist/compileReadme.js +7 -10
- package/dist/compileReadme.min.js +1 -1
- package/dist/copyFonts.js +11 -5
- package/dist/copyFonts.min.js +1 -1
- package/dist/default.js +13 -9
- package/dist/default.min.js +1 -1
- package/dist/dist.js +7 -4
- package/dist/dist.min.js +1 -1
- package/dist/distLint.js +15 -11
- package/dist/distLint.min.js +1 -1
- package/dist/distMinify.js +11 -5
- package/dist/distMinify.min.js +1 -1
- package/dist/images.js +7 -4
- package/dist/images.min.js +1 -1
- package/dist/partials/addToReadme.js +16 -11
- package/dist/partials/beginWatcher.js +11 -7
- package/dist/partials/clean.js +11 -5
- package/dist/partials/copyFor.js +7 -7
- package/dist/partials/distFor.js +21 -11
- package/dist/partials/distForSrc.js +9 -3
- package/dist/partials/distSeries.js +17 -13
- package/dist/partials/imagesFor.js +16 -17
- package/dist/partials/minifyFor.js +12 -11
- package/dist/partials/readmeTemplate.js +13 -9
- package/dist/partials/removeDirectory.js +7 -7
- package/dist/partials/runOnChange.js +18 -16
- package/dist/partials/sassFor.js +19 -12
- package/dist/partials/tsFor.js +17 -14
- package/dist/partials.js +101 -39
- package/dist/partials.min.js +1 -1
- package/dist/sass.js +7 -4
- package/dist/sass.min.js +1 -1
- package/dist/test-helpers/setUp.js +50 -47
- package/dist/testFull.js +12 -7
- package/dist/testFull.min.js +1 -1
- package/dist/testHelpers.js +9 -13
- package/dist/testHelpers.min.js +1 -1
- package/dist/testQuick.js +12 -7
- package/dist/testQuick.min.js +1 -1
- package/dist/typeScript.js +6 -4
- package/dist/typeScript.min.js +1 -1
- package/dist/utilities/dotGet.js +14 -12
- package/dist/utilities/dotNotate.js +10 -8
- package/dist/utilities/dotSet.js +13 -11
- package/dist/utilities/isObject.js +5 -1
- package/dist/utilities/strAfter.js +11 -7
- package/dist/utilities/strBefore.js +11 -7
- package/dist/watchFull.js +7 -7
- package/dist/watchFull.min.js +1 -1
- package/dist/watchTest.js +13 -9
- package/dist/watchTest.min.js +1 -1
- package/functions/{build.js → build.mjs} +14 -16
- package/functions/{build.test.js → build.test.mjs} +9 -8
- package/functions/{bundle.js → bundle.mjs} +5 -7
- package/functions/{bundle.test.js → bundle.test.mjs} +5 -4
- package/functions/{bundleLint.js → bundleLint.mjs} +4 -6
- package/functions/{bundleLint.test.js → bundleLint.test.mjs} +5 -4
- package/functions/bundleMinify.mjs +9 -0
- package/functions/bundleMinify.test.mjs +15 -0
- package/functions/compileReadme.mjs +9 -0
- package/functions/{compileReadme.test.js → compileReadme.test.mjs} +4 -4
- package/functions/copyFonts.mjs +9 -0
- package/functions/{copyFonts.test.js → copyFonts.test.mjs} +4 -3
- package/functions/default.mjs +12 -0
- package/functions/{default.test.js → default.test.mjs} +8 -7
- package/functions/{dist.js → dist.mjs} +2 -4
- package/functions/{dist.test.js → dist.test.mjs} +4 -3
- package/functions/{distLint.js → distLint.mjs} +4 -6
- package/functions/{distLint.test.js → distLint.test.mjs} +5 -4
- package/functions/distMinify.mjs +9 -0
- package/functions/distMinify.test.mjs +15 -0
- package/functions/{images.js → images.mjs} +2 -4
- package/functions/{images.test.js → images.test.mjs} +4 -3
- package/functions/partials/{addToReadme.js → addToReadme.mjs} +5 -7
- package/functions/partials/{addToReadme.test.js → addToReadme.test.mjs} +4 -3
- package/functions/partials/beginWatcher.mjs +9 -0
- package/functions/partials/{beginWatcher.test.js → beginWatcher.test.mjs} +4 -3
- package/functions/partials/clean.mjs +13 -0
- package/functions/partials/{clean.test.js → clean.test.mjs} +4 -3
- package/functions/partials/{copyFor.js → copyFor.mjs} +2 -4
- package/functions/partials/{copyFor.test.js → copyFor.test.mjs} +4 -3
- package/functions/partials/distFor.mjs +22 -0
- package/functions/partials/{distFor.test.js → distFor.test.mjs} +49 -8
- package/functions/partials/{distForSrc.js → distForSrc.mjs} +2 -4
- package/functions/partials/{distForSrc.test.js → distForSrc.test.mjs} +3 -2
- package/functions/partials/{distSeries.js → distSeries.mjs} +6 -8
- package/functions/partials/{distSeries.test.js → distSeries.test.mjs} +7 -6
- package/functions/partials/{imagesFor.js → imagesFor.mjs} +5 -13
- package/functions/partials/{imagesFor.test.js → imagesFor.test.mjs} +4 -3
- package/functions/partials/minifyFor.mjs +15 -0
- package/functions/partials/{minifyFor.test.js → minifyFor.test.mjs} +5 -4
- package/functions/partials/readmeTemplate.mjs +12 -0
- package/functions/partials/{readmeTemplate.test.js → readmeTemplate.test.mjs} +4 -3
- package/functions/partials/{removeDirectory.js → removeDirectory.mjs} +2 -4
- package/functions/partials/{removeDirectory.test.js → removeDirectory.test.mjs} +28 -28
- package/functions/partials/{runOnChange.js → runOnChange.mjs} +6 -8
- package/functions/partials/{runOnChange.test.js → runOnChange.test.mjs} +12 -11
- package/functions/partials/sassFor.mjs +22 -0
- package/functions/partials/{sassFor.test.js → sassFor.test.mjs} +5 -4
- package/functions/partials/{tsFor.js → tsFor.mjs} +4 -6
- package/functions/partials/{tsFor.test.js → tsFor.test.mjs} +5 -4
- package/functions/partials.mjs +23 -0
- package/functions/{partials.test.js → partials.test.mjs} +1 -1
- package/functions/sass.mjs +4 -0
- package/functions/{sass.test.js → sass.test.mjs} +4 -3
- package/functions/test-helpers/{setUp.js → setUp.mjs} +25 -27
- package/functions/test-helpers/setUp.test.mjs +19 -0
- package/functions/{testFull.js → testFull.mjs} +4 -6
- package/functions/testFull.test.mjs +17 -0
- package/functions/{testHelpers.js → testHelpers.mjs} +1 -6
- package/functions/testHelpers.test.mjs +7 -0
- package/functions/{testQuick.js → testQuick.mjs} +4 -6
- package/functions/testQuick.test.mjs +17 -0
- package/functions/{typeScript.js → typeScript.mjs} +2 -4
- package/functions/typeScript.test.mjs +11 -0
- package/functions/utilities/{dotGet.js → dotGet.mjs} +4 -6
- package/functions/utilities/{dotNotate.js → dotNotate.mjs} +2 -4
- package/functions/utilities/{dotSet.js → dotSet.mjs} +4 -6
- package/functions/utilities/{isObject.js → isObject.mjs} +1 -3
- package/functions/utilities/{strAfter.js → strAfter.mjs} +11 -13
- package/functions/utilities/{strBefore.js → strBefore.mjs} +11 -13
- package/functions/{watchFull.js → watchFull.mjs} +2 -4
- package/functions/{watchFull.test.js → watchFull.test.mjs} +8 -7
- package/functions/watchTest.mjs +10 -0
- package/functions/{watchTest.test.js → watchTest.test.mjs} +7 -6
- package/gulp.config.js +20 -19
- package/gulp.config.mjs +252 -0
- package/gulpfile.base.js +20 -20
- package/gulpfile.base.mjs +27 -0
- package/package.json +27 -13
- package/functions/bundleMinify.js +0 -11
- package/functions/bundleMinify.test.js +0 -14
- package/functions/compileReadme.js +0 -11
- package/functions/copyFonts.js +0 -11
- package/functions/default.js +0 -14
- package/functions/distMinify.js +0 -11
- package/functions/distMinify.test.js +0 -14
- package/functions/partials/beginWatcher.js +0 -11
- package/functions/partials/clean.js +0 -15
- package/functions/partials/distFor.js +0 -17
- package/functions/partials/minifyFor.js +0 -15
- package/functions/partials/readmeTemplate.js +0 -14
- package/functions/partials/sassFor.js +0 -21
- package/functions/partials.js +0 -40
- package/functions/sass.js +0 -6
- package/functions/test-helpers/setUp.test.js +0 -18
- package/functions/testFull.test.js +0 -16
- package/functions/testHelpers.test.js +0 -7
- package/functions/testQuick.test.js +0 -16
- package/functions/typeScript.test.js +0 -10
- package/functions/watchTest.js +0 -12
- package/vendor/array-union/index.js +0 -31
- package/vendor/easy-transform-stream/index.js +0 -54
- package/vendor/globby/gitignore.js +0 -96
- package/vendor/globby/index.js +0 -191
- package/vendor/globby/node_modules/slash/index.js +0 -16
- package/vendor/globby/stream-utils.js +0 -58
- package/vendor/globby/to-path.js +0 -20
- package/vendor/gulp-imagemin/index.js +0 -124
- package/vendor/gulp-imagemin/node_modules/chalk/source/index.js +0 -265
- package/vendor/gulp-imagemin/node_modules/chalk/source/utilities.js +0 -36
- package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -217
- package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/supports-color/index.js +0 -154
- package/vendor/gulp-plugin-extras/index.js +0 -42
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/index.js +0 -265
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/utilities.js +0 -36
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -217
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/supports-color/index.js +0 -154
- package/vendor/gulp-plugin-extras/plugin-error.js +0 -145
- package/vendor/ignore/index.js +0 -468
- package/vendor/imagemin/index.js +0 -90
- package/vendor/imagemin-gifsicle/index.js +0 -33
- package/vendor/imagemin-mozjpeg/index.js +0 -100
- package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +0 -260
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/command.js +0 -47
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/error.js +0 -102
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +0 -123
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/promise.js +0 -47
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stdio.js +0 -50
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +0 -124
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/core.js +0 -238
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/main.js +0 -89
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/realtime.js +0 -24
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/signals.js +0 -44
- package/vendor/imagemin-mozjpeg/node_modules/is-stream/index.js +0 -25
- package/vendor/imagemin-mozjpeg/node_modules/mimic-fn/index.js +0 -70
- package/vendor/imagemin-mozjpeg/node_modules/npm-run-path/index.js +0 -52
- package/vendor/imagemin-mozjpeg/node_modules/onetime/index.js +0 -43
- package/vendor/imagemin-mozjpeg/node_modules/path-key/index.js +0 -20
- package/vendor/imagemin-mozjpeg/node_modules/strip-final-newline/index.js +0 -17
- package/vendor/imagemin-optipng/index.js +0 -44
- package/vendor/imagemin-svgo/index.js +0 -27
- package/vendor/is-jpg/index.js +0 -12
- package/vendor/junk/index.js +0 -49
- package/vendor/mozjpeg/index.js +0 -9
- package/vendor/mozjpeg/lib/index.js +0 -18
- package/vendor/mozjpeg/package.json +0 -49
- package/vendor/mozjpeg/vendor/cjpeg +0 -0
- package/vendor/mozjpeg/vendor/source/mozjpeg.tar.gz +0 -0
- package/vendor/p-pipe/index.js +0 -22
- package/vendor/plur/index.js +0 -32
- package/vendor/pretty-bytes/index.js +0 -71
- package/vendor/slash/index.js +0 -12
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import browserify from 'browserify'
|
|
2
|
+
import { dest } from 'gulp'
|
|
3
|
+
import * as gulpConfig from '../gulp.config.mjs'
|
|
4
|
+
import source from 'vinyl-source-stream'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.
|
|
8
8
|
* @memberOf module:js-build-tools
|
|
9
9
|
* @returns {stream.Stream}
|
|
10
10
|
*/
|
|
11
|
-
const bundle = () => browserify(gulpConfig.get('dist.main'))
|
|
11
|
+
export const bundle = () => browserify(gulpConfig.get('dist.main'))
|
|
12
12
|
.bundle()
|
|
13
13
|
.pipe(source(`${gulpConfig.get('browser.name')}.js`))
|
|
14
14
|
.pipe(dest(gulpConfig.get('browser.to')))
|
|
15
|
-
|
|
16
|
-
module.exports = bundle
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from './test-helpers/setUp.mjs'
|
|
3
|
+
import { bundle } from './bundle.mjs'
|
|
4
|
+
import { countMatches } from 'test-filesystem'
|
|
5
|
+
|
|
3
6
|
setUp.setDefaults('test-bundle')
|
|
4
7
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const bundle = require('./bundle')
|
|
6
|
-
const { countMatches } = require('test-filesystem')
|
|
7
8
|
|
|
8
9
|
const file1Contents = 'function file1 () {\n' +
|
|
9
10
|
' console.log(\'Hello from file1\')\n' +
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { dest, src } from 'gulp'
|
|
2
|
+
import * as gulpConfig from '../gulp.config.mjs'
|
|
3
|
+
import standard from 'gulp-standard'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Applies Standard code style linting to bundled file.
|
|
7
7
|
* @memberOf module:js-build-tools
|
|
8
8
|
* @returns {stream.Stream}
|
|
9
9
|
*/
|
|
10
|
-
const bundleLint = () => src(`${gulpConfig.get('browser.to')}/${gulpConfig.get('browser.name')}.js`)
|
|
10
|
+
export const bundleLint = () => src(`${gulpConfig.get('browser.to')}/${gulpConfig.get('browser.name')}.js`)
|
|
11
11
|
.pipe(standard({ fix: true }))
|
|
12
12
|
.pipe(standard.reporter('default', {
|
|
13
13
|
fix: true,
|
|
14
14
|
quiet: true
|
|
15
15
|
}))
|
|
16
16
|
.pipe(dest(gulpConfig.get('browser.to')))
|
|
17
|
-
|
|
18
|
-
module.exports = bundleLint
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from './test-helpers/setUp.mjs'
|
|
3
|
+
import { bundleLint } from './bundleLint.mjs'
|
|
4
|
+
import { countMatches } from 'test-filesystem'
|
|
5
|
+
|
|
3
6
|
setUp.setDefaults('test-bundle-lint')
|
|
4
7
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const bundleLint = require('./bundleLint')
|
|
6
|
-
const { countMatches } = require('test-filesystem')
|
|
7
8
|
|
|
8
9
|
const lintableContents = 'const gulpConfig = require("../gulp.config.js");\n' +
|
|
9
10
|
'const { dest, src } = require("gulp");\n' +
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as gulpConfig from '../gulp.config.mjs'
|
|
2
|
+
import { minifyFor } from './partials/minifyFor.mjs'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates the minified bundle file.
|
|
6
|
+
* @memberOf module:js-build-tools
|
|
7
|
+
* @returns {*}
|
|
8
|
+
*/
|
|
9
|
+
export const bundleMinify = () => minifyFor(`${gulpConfig.get('browser.to')}/${gulpConfig.get('browser.name')}.js`, gulpConfig.get('browser.to'))
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { testHelpers } from './testHelpers.mjs'
|
|
2
|
+
import { bundleMinify } from './bundleMinify.mjs'
|
|
3
|
+
import { minifyFor } from './partials/minifyFor.mjs'
|
|
4
|
+
|
|
5
|
+
const gulpConfig = testHelpers.gulpConfig
|
|
6
|
+
|
|
7
|
+
jest.mock('./partials/minifyFor.mjs', () => ({ minifyFor: jest.fn(() => Promise.resolve(true)) }))
|
|
8
|
+
|
|
9
|
+
describe('bundleMinify', () => {
|
|
10
|
+
test('calls minifyFor with configurations', () => {
|
|
11
|
+
expect.assertions(1)
|
|
12
|
+
bundleMinify()
|
|
13
|
+
expect(minifyFor).toHaveBeenCalledWith(`${gulpConfig.get('browser.to')}/${gulpConfig.get('browser.name')}.js`, gulpConfig.get('browser.to'))
|
|
14
|
+
})
|
|
15
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { addToReadme, readmeTemplate } from './partials.mjs'
|
|
2
|
+
import { series } from '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
|
+
export const compileReadme = series(readmeTemplate, addToReadme)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { compileReadme } from './compileReadme.mjs'
|
|
2
|
+
import { addToReadme, readmeTemplate } from './partials.mjs'
|
|
3
3
|
|
|
4
4
|
const genericFunction = () => Promise.resolve(true)
|
|
5
|
-
jest.mock('./partials/addToReadme', () => jest.fn(genericFunction))
|
|
6
|
-
jest.mock('./partials/readmeTemplate', () => jest.fn(genericFunction))
|
|
5
|
+
jest.mock('./partials/addToReadme.mjs', () => ({ addToReadme: jest.fn(genericFunction) }))
|
|
6
|
+
jest.mock('./partials/readmeTemplate.mjs', () => ({ readmeTemplate: jest.fn(genericFunction) }))
|
|
7
7
|
|
|
8
8
|
describe('compileReadme', () => {
|
|
9
9
|
test('calls readmeTemplate and addToReadme', done => {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { copyFor } from './partials/copyFor.mjs'
|
|
2
|
+
import * as gulpConfig from '../gulp.config.mjs'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Move the font files into the browser directory.
|
|
6
|
+
* @memberOf module:js-build-tools
|
|
7
|
+
* @return {stream.Stream}
|
|
8
|
+
*/
|
|
9
|
+
export const copyFonts = () => copyFor(gulpConfig.get('fonts.from'), gulpConfig.get('fonts.to'))
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from './test-helpers/setUp.mjs'
|
|
3
|
+
import { copyFonts } from './copyFonts.mjs'
|
|
4
|
+
|
|
3
5
|
setUp.setDefaults('test-copy-fonts')
|
|
4
6
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const copyFonts = require('./copyFonts')
|
|
6
7
|
|
|
7
8
|
const fontContent = 'comic sans'
|
|
8
9
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { dist } from './dist.mjs'
|
|
2
|
+
import { bundle } from './bundle.mjs'
|
|
3
|
+
import * as gulpConfig from '../gulp.config.mjs'
|
|
4
|
+
import { series } from '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
|
+
export const defaultCmd = (done = null) => gulpConfig.get('browser.enabled') ? series(dist, bundle)(done) : series(dist)(done)
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { testHelpers } from './testHelpers.mjs'
|
|
2
|
+
import { bundle } from './bundle.mjs'
|
|
3
|
+
import { dist } from './dist.mjs'
|
|
4
|
+
import { defaultCmd } from './default.mjs'
|
|
5
|
+
|
|
6
|
+
const gulpConfig = testHelpers.gulpConfig
|
|
6
7
|
|
|
7
8
|
const genericFunction = () => Promise.resolve(true)
|
|
8
|
-
jest.mock('./bundle', () => jest.fn(genericFunction))
|
|
9
|
-
jest.mock('./dist', () => jest.fn(genericFunction))
|
|
9
|
+
jest.mock('./bundle.mjs', () => ({ bundle: jest.fn(genericFunction) }))
|
|
10
|
+
jest.mock('./dist.mjs', () => ({ dist: jest.fn(genericFunction) }))
|
|
10
11
|
|
|
11
12
|
describe('distMinify', () => {
|
|
12
13
|
test('calls dist for nodeOnly true', done => {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { distFor } from './partials/distFor.mjs'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Simplified distribution tasks which will use arguments from distFor.
|
|
5
5
|
* @memberOf module:js-build-tools
|
|
6
6
|
* @returns {*}
|
|
7
7
|
*/
|
|
8
|
-
const dist = () => distFor()
|
|
9
|
-
|
|
10
|
-
module.exports = dist
|
|
8
|
+
export const dist = () => distFor()
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from './test-helpers/setUp.mjs'
|
|
3
|
+
import { dist } from './dist.mjs'
|
|
4
|
+
|
|
3
5
|
setUp.setDefaults('test-dist')
|
|
4
6
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const dist = require('./dist')
|
|
6
7
|
|
|
7
8
|
const rawContents = 'const distFor = require(\'./distFor.js\')\n' +
|
|
8
9
|
'\n' +
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as gulpConfig from '../gulp.config.mjs'
|
|
2
|
+
import { dest, src } from 'gulp'
|
|
3
|
+
import standard from 'gulp-standard'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Applies Standard code style linting to distribution files.
|
|
7
7
|
* @memberOf module:js-build-tools
|
|
8
8
|
* @returns {*}
|
|
9
9
|
*/
|
|
10
|
-
const distLint = () => src(gulpConfig.get('browser.from'))
|
|
10
|
+
export const distLint = () => src(gulpConfig.get('browser.from'))
|
|
11
11
|
.pipe(standard({ fix: true }))
|
|
12
12
|
.pipe(standard.reporter('default', {
|
|
13
13
|
fix: true,
|
|
14
14
|
quiet: true
|
|
15
15
|
}))
|
|
16
16
|
.pipe(dest(gulpConfig.get('dist.to')))
|
|
17
|
-
|
|
18
|
-
module.exports = distLint
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from './test-helpers/setUp.mjs'
|
|
3
|
+
import { distLint } from './distLint.mjs'
|
|
4
|
+
import { countMatches } from 'test-filesystem'
|
|
5
|
+
|
|
3
6
|
setUp.setDefaults('test-dist-lint')
|
|
4
7
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const distLint = require('./distLint')
|
|
6
|
-
const { countMatches } = require('test-filesystem')
|
|
7
8
|
|
|
8
9
|
const lintableContents = 'const gulpConfig = require("../gulp.config.js");\n' +
|
|
9
10
|
'const { dest, src } = require("gulp");\n' +
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as gulpConfig from '../gulp.config.mjs'
|
|
2
|
+
import { minifyFor } from './partials/minifyFor.mjs'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates minified versions of the dist files.
|
|
6
|
+
* @memberOf module:js-build-tools
|
|
7
|
+
* @returns {*}
|
|
8
|
+
*/
|
|
9
|
+
export const distMinify = () => minifyFor(gulpConfig.get('browser.from'), gulpConfig.get('dist.to'))
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { testHelpers } from './testHelpers.mjs'
|
|
2
|
+
import { distMinify } from './distMinify.mjs'
|
|
3
|
+
import { minifyFor } from './partials/minifyFor.mjs'
|
|
4
|
+
|
|
5
|
+
const gulpConfig = testHelpers.gulpConfig
|
|
6
|
+
|
|
7
|
+
jest.mock('./partials/minifyFor.mjs', () => ({ minifyFor: jest.fn(() => Promise.resolve(true)) }))
|
|
8
|
+
|
|
9
|
+
describe('distMinify', () => {
|
|
10
|
+
test('calls minifyFor with configurations', () => {
|
|
11
|
+
expect.assertions(1)
|
|
12
|
+
distMinify()
|
|
13
|
+
expect(minifyFor).toHaveBeenCalledWith(gulpConfig.get('browser.from'), gulpConfig.get('dist.to'))
|
|
14
|
+
})
|
|
15
|
+
})
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { imagesFor } from './partials/imagesFor.mjs'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Move and optimize the images into the browser folder using configured settings.
|
|
5
5
|
* @memberOf module:js-build-tools
|
|
6
6
|
* @return {stream.Stream}
|
|
7
7
|
*/
|
|
8
|
-
const images = () => imagesFor()
|
|
9
|
-
|
|
10
|
-
module.exports = images
|
|
8
|
+
export const images = () => imagesFor()
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from './test-helpers/setUp.mjs'
|
|
3
|
+
import { images } from './images.mjs'
|
|
4
|
+
|
|
3
5
|
setUp.setDefaults('test-images')
|
|
4
6
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const images = require('./images')
|
|
6
7
|
|
|
7
8
|
const imageContents = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' +
|
|
8
9
|
'<!-- Created with Inkscape (http://www.inkscape.org/) -->\n' +
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
3
|
+
import jsdoc2md from 'jsdoc-to-markdown'
|
|
4
|
+
import { globSync } from 'glob'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Appends all the jsdoc comments to the readme file. Assumes empty or templated file.
|
|
@@ -9,10 +9,8 @@ const { globSync } = require('glob')
|
|
|
9
9
|
* @memberOf module:partials
|
|
10
10
|
* @returns {string|Uint8Array}
|
|
11
11
|
*/
|
|
12
|
-
const addToReadme = () => jsdoc2md
|
|
12
|
+
export const addToReadme = () => jsdoc2md
|
|
13
13
|
.render({ files: globSync(gulpConfig.get('readme.from')) })
|
|
14
14
|
.then(
|
|
15
15
|
readme => fs.appendFileSync(gulpConfig.get('readme.to') + gulpConfig.get('readme.file'), readme, gulpConfig.get('readmeOptions'))
|
|
16
16
|
)
|
|
17
|
-
|
|
18
|
-
module.exports = addToReadme
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
3
|
+
import { addToReadme } from './addToReadme.mjs'
|
|
4
|
+
|
|
3
5
|
setUp.setDefaults('test-add-to-readme')
|
|
4
6
|
const gulpConfig = setUp.gulpConfig
|
|
5
7
|
gulpConfig.set('dist.from', 'test-temp/src/addToReadme.js')
|
|
6
|
-
const addToReadme = require('./addToReadme')
|
|
7
8
|
|
|
8
9
|
const rawContents = '/**\n' +
|
|
9
10
|
' * Say hello with a given name.\n' +
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
2
|
+
import { watch } from '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
|
+
export const beginWatcher = () => watch(gulpConfig.get('test.watch'))
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
2
|
+
import { beginWatcher } from './beginWatcher.mjs'
|
|
3
|
+
import { EventEmitter } from 'node:events'
|
|
4
|
+
|
|
2
5
|
setUp.setDefaults('test-begin-watcher')
|
|
3
6
|
const gulpConfig = setUp.gulpConfig
|
|
4
|
-
const beginWatcher = require('./beginWatcher')
|
|
5
|
-
const { EventEmitter } = require('node:events')
|
|
6
7
|
|
|
7
8
|
beforeEach(setUp.beforeEach)
|
|
8
9
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
2
|
+
import { removeDirectory } from './removeDirectory.mjs'
|
|
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
|
+
export const clean = () => gulpConfig.get('cleanPaths').reduce(
|
|
11
|
+
(promise, path) => promise.then(() => removeDirectory(path)),
|
|
12
|
+
Promise.resolve()
|
|
13
|
+
)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
3
|
+
import { clean } from './clean.mjs'
|
|
4
|
+
|
|
3
5
|
setUp.setDefaults('test-clean')
|
|
4
6
|
const gulpConfig = setUp.gulpConfig
|
|
5
7
|
const srcPath = gulpConfig.get('srcPath')
|
|
6
8
|
gulpConfig.set('cleanPaths', [srcPath])
|
|
7
|
-
const clean = require('./clean')
|
|
8
9
|
|
|
9
10
|
beforeEach(setUp.beforeEach)
|
|
10
11
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { dest, src } from 'gulp'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Copy some files to a different location.
|
|
@@ -7,7 +7,5 @@ const { dest, src } = require('gulp')
|
|
|
7
7
|
* @param {string} destPath
|
|
8
8
|
* @returns {stream.Stream}
|
|
9
9
|
*/
|
|
10
|
-
const copyFor = (srcPath, destPath) => src(srcPath)
|
|
10
|
+
export const copyFor = (srcPath, destPath) => src(srcPath)
|
|
11
11
|
.pipe(dest(destPath))
|
|
12
|
-
|
|
13
|
-
module.exports = copyFor
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
3
|
+
import { copyFor } from './copyFor.mjs'
|
|
4
|
+
|
|
3
5
|
setUp.setDefaults('test-copy-for')
|
|
4
6
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const copyFor = require('./copyFor')
|
|
6
7
|
|
|
7
8
|
const fileContents = 'some file contents'
|
|
8
9
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import babel from 'gulp-babel'
|
|
2
|
+
import { dest, src } from 'gulp'
|
|
3
|
+
import { distForSrc } from './distForSrc.mjs'
|
|
4
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
5
|
+
import through from 'through2'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Build the distribution for a given source pattern.
|
|
9
|
+
* @memberOf module:partials
|
|
10
|
+
* @param {string|array} [srcPath='src/config/path/dist/for']
|
|
11
|
+
* @param {string} [destPath='dist/config/path']
|
|
12
|
+
* @returns {stream.Stream}
|
|
13
|
+
*/
|
|
14
|
+
export const distFor = (srcPath = distForSrc(), destPath = gulpConfig.get('dist.to')) => src(srcPath)
|
|
15
|
+
.pipe(babel())
|
|
16
|
+
.pipe(through.obj(function (file, enc, callback) {
|
|
17
|
+
const regex = /\.mjs(['"]\s*\))/gi
|
|
18
|
+
file.contents = Buffer.from(file.contents.toString().replaceAll(regex, '.js$1'))
|
|
19
|
+
this.push(file)
|
|
20
|
+
callback()
|
|
21
|
+
}))
|
|
22
|
+
.pipe(dest(destPath))
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
3
|
+
import { distFor } from './distFor.mjs'
|
|
4
|
+
import { countMatches, fileExists } from 'test-filesystem'
|
|
5
|
+
import { tsFor } from './tsFor.mjs'
|
|
6
|
+
|
|
3
7
|
setUp.setDefaults('test-dist-for')
|
|
4
8
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const distFor = require('./distFor')
|
|
6
|
-
const { countMatches } = require('test-filesystem')
|
|
7
|
-
const typeScript = require('../typeScript')
|
|
8
9
|
|
|
9
10
|
const rawContents = 'const babel = require(\'gulp-babel\')\n' +
|
|
10
11
|
'const { dest, src } = require(\'gulp\')\n' +
|
|
@@ -59,6 +60,23 @@ const rawTsContents = '// @ts-ignore\n' +
|
|
|
59
60
|
'\n' +
|
|
60
61
|
'export default distFor\n'
|
|
61
62
|
|
|
63
|
+
const rawMjsContents = 'import babel from \'gulp-babel\'\n' +
|
|
64
|
+
'import { dest, src } from \'gulp\'\n' +
|
|
65
|
+
'import { distForSrc } from \'./distForSrc.mjs\'\n' +
|
|
66
|
+
'import * as gulpConfig from \'../../gulp.config.mjs\'\n' +
|
|
67
|
+
'\n' +
|
|
68
|
+
'/**\n' +
|
|
69
|
+
' * Build the distribution for a given source pattern.\n' +
|
|
70
|
+
' * @memberOf module:partials\n' +
|
|
71
|
+
' * @param {string|array} [srcPath=\'src/config/path/dist/for\']\n' +
|
|
72
|
+
' * @param {string} [destPath=\'dist/config/path\']\n' +
|
|
73
|
+
' * @returns {stream.Stream}\n' +
|
|
74
|
+
' */\n' +
|
|
75
|
+
'export const distFor = (srcPath = distForSrc(), destPath = gulpConfig.get(\'dist.to\')) => src(srcPath)\n' +
|
|
76
|
+
' .pipe(babel())\n' +
|
|
77
|
+
' .pipe((result) => console.log(result) || result)\n' +
|
|
78
|
+
' .pipe(dest(destPath))\n'
|
|
79
|
+
|
|
62
80
|
beforeEach(setUp.beforeEach)
|
|
63
81
|
|
|
64
82
|
afterEach(setUp.afterEach)
|
|
@@ -74,7 +92,7 @@ describe('distFor', () => {
|
|
|
74
92
|
const distPath = gulpConfig.get('dist.to')
|
|
75
93
|
distFor(srcFile)
|
|
76
94
|
.on('finish', () => {
|
|
77
|
-
expect(
|
|
95
|
+
expect(fileExists(distPath)).toBeTruthy()
|
|
78
96
|
const babelifiedContents = fs.readFileSync(`${distPath}/distFor.js`).toString()
|
|
79
97
|
expect(countMatches(babelifiedContents, '"use strict"')).toEqual(1)
|
|
80
98
|
/* There used to be a nice check here where `const` and `let` would be swapped to `var`, but that no longer
|
|
@@ -100,10 +118,12 @@ describe('distFor', () => {
|
|
|
100
118
|
const oldContents = fs.readFileSync(srcFile).toString()
|
|
101
119
|
expect(countMatches(oldContents, 'const ')).toEqual(3)
|
|
102
120
|
const distPath = gulpConfig.get('dist.to')
|
|
103
|
-
|
|
121
|
+
const tsFrom = gulpConfig.get('typescript.from')
|
|
122
|
+
const tsTo = gulpConfig.get('typescript.to')
|
|
123
|
+
tsFor(tsFrom, tsTo)(() => {
|
|
104
124
|
distFor()
|
|
105
125
|
.on('finish', () => {
|
|
106
|
-
expect(
|
|
126
|
+
expect(fileExists(distPath)).toBeTruthy()
|
|
107
127
|
const babelifiedContents = fs.readFileSync(`${distPath}/distFor.js`).toString()
|
|
108
128
|
expect(countMatches(babelifiedContents, '"use strict"')).toEqual(1)
|
|
109
129
|
expect(countMatches(babelifiedContents, 'const ')).toEqual(0)
|
|
@@ -118,4 +138,25 @@ describe('distFor', () => {
|
|
|
118
138
|
})
|
|
119
139
|
})
|
|
120
140
|
}, 60000)
|
|
141
|
+
|
|
142
|
+
test('converts .mjs file extension to .js', done => {
|
|
143
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
144
|
+
const srcFile = `${srcPath}/distFor.mjs`
|
|
145
|
+
fs.writeFileSync(srcFile, rawMjsContents)
|
|
146
|
+
// expect.assertions(5)
|
|
147
|
+
const oldContents = fs.readFileSync(srcFile).toString()
|
|
148
|
+
expect(countMatches(oldContents, '.mjs')).toEqual(2)
|
|
149
|
+
const distPath = gulpConfig.get('dist.to')
|
|
150
|
+
distFor(srcFile)
|
|
151
|
+
.on('finish', () => {
|
|
152
|
+
expect(fileExists(distPath)).toBeTruthy()
|
|
153
|
+
const babelifiedContents = fs.readFileSync(`${distPath}/distFor.js`).toString()
|
|
154
|
+
expect(countMatches(babelifiedContents, '.js')).toEqual(3)
|
|
155
|
+
done()
|
|
156
|
+
})
|
|
157
|
+
.on('error', error => {
|
|
158
|
+
console.error('Encountered error', error)
|
|
159
|
+
done()
|
|
160
|
+
})
|
|
161
|
+
}, 5000)
|
|
121
162
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Retrieve the correct distFor search path based on TS Config.
|
|
@@ -6,8 +6,6 @@ const gulpConfig = require('../../gulp.config')
|
|
|
6
6
|
* @param {module:gulpConfig~FlagStringSetting} [useTs='config/for/ts']
|
|
7
7
|
* @returns {string}
|
|
8
8
|
*/
|
|
9
|
-
const distForSrc = (useTs = gulpConfig.get('typescript.enabled')) => useTs
|
|
9
|
+
export const distForSrc = (useTs = gulpConfig.get('typescript.enabled')) => useTs
|
|
10
10
|
? gulpConfig.get('browser.from')
|
|
11
11
|
: gulpConfig.get('dist.from')
|
|
12
|
-
|
|
13
|
-
module.exports = distForSrc
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
2
|
+
import { distForSrc } from './distForSrc.mjs'
|
|
3
|
+
|
|
2
4
|
const gulpConfig = setUp.gulpConfig
|
|
3
|
-
const distForSrc = require('./distForSrc')
|
|
4
5
|
|
|
5
6
|
describe('distForSrc', () => {
|
|
6
7
|
test('typescript.enabled as false returns srcSearch', () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
2
|
+
import { distFor } from './distFor.mjs'
|
|
3
|
+
import { distForSrc } from './distForSrc.mjs'
|
|
4
|
+
import { series } from 'gulp'
|
|
5
|
+
import { tsFor } from './tsFor.mjs'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* When using TypeScript, ensure that we process the ts first then run babel (dist)
|
|
@@ -12,12 +12,10 @@ const tsFor = require('./tsFor')
|
|
|
12
12
|
* @param {string} [tsSearch='ts/search/config/path']
|
|
13
13
|
* @returns {function(null=): stream.Stream}
|
|
14
14
|
*/
|
|
15
|
-
const distSeries = (srcPath = distForSrc(), distFinalPath = gulpConfig.get('dist.to'), tsSearch = gulpConfig.get('typescript.from')) => {
|
|
15
|
+
export const distSeries = (srcPath = distForSrc(), distFinalPath = gulpConfig.get('dist.to'), tsSearch = gulpConfig.get('typescript.from')) => {
|
|
16
16
|
const typescript = tsFor(tsSearch, distFinalPath)
|
|
17
17
|
const dist = () => distFor(srcPath, distFinalPath)
|
|
18
18
|
return gulpConfig.get('typescript.enabled')
|
|
19
19
|
? series(typescript, dist)
|
|
20
20
|
: dist
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
module.exports = distSeries
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
2
|
+
import { distSeries } from './distSeries.mjs'
|
|
3
|
+
import { tsFor } from './tsFor.mjs'
|
|
4
|
+
import { distFor } from './distFor.mjs'
|
|
5
|
+
|
|
2
6
|
const gulpConfig = setUp.gulpConfig
|
|
3
|
-
const distSeries = require('./distSeries')
|
|
4
|
-
const tsFor = require('./tsFor')
|
|
5
|
-
const distFor = require('./distFor')
|
|
6
7
|
|
|
7
8
|
const genericFunction = () => Promise.resolve(true)
|
|
8
9
|
|
|
9
|
-
jest.mock('./distFor', () => jest.fn(genericFunction))
|
|
10
|
-
jest.mock('./tsFor', () => jest.fn(() => genericFunction))
|
|
10
|
+
jest.mock('./distFor.mjs', () => ({ distFor: jest.fn(genericFunction) }))
|
|
11
|
+
jest.mock('./tsFor.mjs', () => ({ tsFor: jest.fn(() => genericFunction) }))
|
|
11
12
|
|
|
12
13
|
describe('distSeries', () => {
|
|
13
14
|
test('when not using ts config only returns runnable distFor', done => {
|