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.
- package/README.md +431 -691
- package/babel.config.js +1 -1
- package/dist/build.js +58 -59
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +17 -12
- package/dist/bundle.min.js +1 -1
- package/dist/bundleLint.js +21 -17
- package/dist/bundleLint.min.js +1 -1
- package/dist/bundleMinify.js +14 -8
- package/dist/bundleMinify.min.js +1 -1
- package/dist/compileReadme.js +10 -13
- package/dist/compileReadme.min.js +1 -1
- package/dist/copyFonts.js +14 -8
- package/dist/copyFonts.min.js +1 -1
- package/dist/default.js +19 -15
- package/dist/default.min.js +1 -1
- package/dist/dist.js +10 -7
- package/dist/dist.min.js +1 -1
- package/dist/distLint.js +21 -17
- package/dist/distLint.min.js +1 -1
- package/dist/distMinify.js +14 -8
- package/dist/distMinify.min.js +1 -1
- package/dist/images.js +10 -7
- package/dist/images.min.js +1 -1
- package/dist/partials/addToReadme.js +19 -14
- package/dist/partials/beginWatcher.js +14 -10
- package/dist/partials/clean.js +17 -11
- package/dist/partials/copyFor.js +10 -10
- package/dist/partials/distFor.js +27 -17
- package/dist/partials/distForSrc.js +16 -10
- package/dist/partials/distSeries.js +24 -20
- package/dist/partials/imagesFor.js +27 -28
- package/dist/partials/minifyFor.js +17 -16
- package/dist/partials/readmeTemplate.js +16 -12
- package/dist/partials/removeDirectory.js +12 -12
- package/dist/partials/runOnChange.js +30 -28
- package/dist/partials/sassFor.js +28 -21
- package/dist/partials/tsFor.js +24 -21
- package/dist/partials.js +103 -41
- package/dist/partials.min.js +1 -1
- package/dist/sass.js +10 -7
- package/dist/sass.min.js +1 -1
- package/dist/test-helpers/setUp.js +68 -65
- package/dist/testFull.js +22 -17
- package/dist/testFull.min.js +1 -1
- package/dist/testHelpers.js +11 -15
- package/dist/testHelpers.min.js +1 -1
- package/dist/testQuick.js +24 -19
- package/dist/testQuick.min.js +1 -1
- package/dist/typeScript.js +9 -7
- package/dist/typeScript.min.js +1 -1
- package/dist/utilities/dotGet.js +45 -43
- package/dist/utilities/dotNotate.js +53 -51
- package/dist/utilities/dotSet.js +39 -37
- package/dist/utilities/isObject.js +9 -5
- package/dist/utilities/strAfter.js +18 -14
- package/dist/utilities/strBefore.js +18 -14
- package/dist/watchFull.js +10 -10
- package/dist/watchFull.min.js +1 -1
- package/dist/watchTest.js +17 -13
- 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 +20 -14
- 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,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 => {
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let imagemin = (content) => content
|
|
6
|
-
try {
|
|
7
|
-
imagemin = require('../../vendor/gulp-imagemin').default
|
|
8
|
-
} catch (e) {
|
|
9
|
-
// It didn't get created yet
|
|
10
|
-
}
|
|
1
|
+
import cache from 'gulp-cache'
|
|
2
|
+
import { dest, src } from 'gulp'
|
|
3
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
4
|
+
import imagemin from 'gulp-imagemin'
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
7
|
* Move and optimize images into the browser directory.
|
|
@@ -16,7 +10,7 @@ try {
|
|
|
16
10
|
* @param {string} [imageDest=dest/image/folder]
|
|
17
11
|
* @return {stream.Stream}
|
|
18
12
|
*/
|
|
19
|
-
const imagesFor = (imageSrc = gulpConfig.get('images.from'), imageDest = gulpConfig.get('images.to')) =>
|
|
13
|
+
export const imagesFor = (imageSrc = gulpConfig.get('images.from'), imageDest = gulpConfig.get('images.to')) =>
|
|
20
14
|
src(imageSrc)
|
|
21
15
|
.pipe(
|
|
22
16
|
// Caching images that ran through imagemin
|
|
@@ -29,5 +23,3 @@ const imagesFor = (imageSrc = gulpConfig.get('images.from'), imageDest = gulpCon
|
|
|
29
23
|
)
|
|
30
24
|
)
|
|
31
25
|
.pipe(dest(imageDest))
|
|
32
|
-
|
|
33
|
-
module.exports = imagesFor
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
3
|
+
import { imagesFor } from './imagesFor.mjs'
|
|
4
|
+
|
|
3
5
|
setUp.setDefaults('test-images-for')
|
|
4
6
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const imagesFor = require('./imagesFor.js')
|
|
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' +
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { dest, src } from 'gulp'
|
|
2
|
+
import { default as gulpUglify } from 'gulp-uglify-es'
|
|
3
|
+
import rename from 'gulp-rename'
|
|
4
|
+
|
|
5
|
+
const uglify = gulpUglify.hasOwnProperty('default') ? gulpUglify.default : gulpUglify
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Minify files and rename the output with '.min' extension.
|
|
9
|
+
* @memberOf module:partials
|
|
10
|
+
* @returns {*}
|
|
11
|
+
*/
|
|
12
|
+
export const minifyFor = (srcSearch, destination) => src(srcSearch)
|
|
13
|
+
.pipe(uglify())
|
|
14
|
+
.pipe(rename({ extname: '.min.js' }))
|
|
15
|
+
.pipe(dest(destination))
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
3
|
+
import { minifyFor } from './minifyFor.mjs'
|
|
4
|
+
import { countMatches } from 'test-filesystem'
|
|
5
|
+
|
|
3
6
|
setUp.setDefaults('test-minify-for')
|
|
4
7
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const minifyFor = require('./minifyFor')
|
|
6
|
-
const { countMatches } = require('test-filesystem')
|
|
7
8
|
|
|
8
9
|
const rawContents = 'const { dest, src } = require(\'gulp\')\n' +
|
|
9
10
|
'const { default: uglify } = require(\'gulp-uglify-es\')\n' +
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { dest, src } from 'gulp'
|
|
2
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
3
|
+
import rename from 'gulp-rename'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copy a readme template into the README.md file.
|
|
7
|
+
* @memberOf module:partials
|
|
8
|
+
* @returns {*}
|
|
9
|
+
*/
|
|
10
|
+
export const readmeTemplate = () => src(gulpConfig.get('readme.template'))
|
|
11
|
+
.pipe(rename(gulpConfig.get('readme.file')))
|
|
12
|
+
.pipe(dest(gulpConfig.get('readme.to')))
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
3
|
+
import { readmeTemplate } from './readmeTemplate.mjs'
|
|
4
|
+
|
|
3
5
|
setUp.setDefaults('test-readme-template')
|
|
4
6
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const readmeTemplate = require('./readmeTemplate')
|
|
6
7
|
|
|
7
8
|
const mainMd = 'MAIN.md'
|
|
8
9
|
const mainTestPath = gulpConfig.get('readme.template')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { rm, exists } from 'fs'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Return a promise to be completed once the specified directory is deleted.
|
|
@@ -6,7 +6,7 @@ const { rm, exists } = require('fs')
|
|
|
6
6
|
* @param {string} dirPath
|
|
7
7
|
* @returns {Promise<*>}
|
|
8
8
|
*/
|
|
9
|
-
const removeDirectory = dirPath => new Promise(
|
|
9
|
+
export const removeDirectory = dirPath => new Promise(
|
|
10
10
|
(resolve, reject) => exists(
|
|
11
11
|
dirPath,
|
|
12
12
|
doesExist => doesExist
|
|
@@ -18,5 +18,3 @@ const removeDirectory = dirPath => new Promise(
|
|
|
18
18
|
: resolve(dirPath)
|
|
19
19
|
)
|
|
20
20
|
)
|
|
21
|
-
|
|
22
|
-
module.exports = removeDirectory
|