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,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
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe('removeDirectory', () => {
|
|
5
|
-
test('able to delete the remove-directory',
|
|
6
|
-
const dirPath = 'remove-directory'
|
|
7
|
-
fs.mkdirSync(dirPath)
|
|
8
|
-
expect(fs.existsSync(dirPath)).toBeTruthy()
|
|
9
|
-
await removeDirectory(dirPath)
|
|
10
|
-
expect(fs.existsSync(dirPath)).toBeFalsy()
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('able to delete directory with sub-directories',
|
|
14
|
-
const dirPath = 'remove-directory'
|
|
15
|
-
fs.mkdirSync(dirPath)
|
|
16
|
-
const subDir = `${dirPath}/sub`
|
|
17
|
-
fs.mkdirSync(subDir)
|
|
18
|
-
expect(fs.existsSync(subDir)).toBeTruthy()
|
|
19
|
-
await removeDirectory(dirPath)
|
|
20
|
-
expect(fs.existsSync(subDir)).toBeFalsy()
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
test('ends cleanly if directory does not exist',
|
|
24
|
-
const dirPath = 'remove-directory'
|
|
25
|
-
expect(fs.existsSync(dirPath)).toBeFalsy()
|
|
26
|
-
expect(await removeDirectory(dirPath)).toBe(dirPath)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import { removeDirectory } from './removeDirectory.mjs'
|
|
3
|
+
|
|
4
|
+
describe('removeDirectory', () => {
|
|
5
|
+
test('able to delete the remove-directory', async () => {
|
|
6
|
+
const dirPath = 'remove-directory'
|
|
7
|
+
fs.mkdirSync(dirPath)
|
|
8
|
+
expect(fs.existsSync(dirPath)).toBeTruthy()
|
|
9
|
+
await removeDirectory(dirPath)
|
|
10
|
+
expect(fs.existsSync(dirPath)).toBeFalsy()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('able to delete directory with sub-directories', async () => {
|
|
14
|
+
const dirPath = 'remove-directory'
|
|
15
|
+
fs.mkdirSync(dirPath)
|
|
16
|
+
const subDir = `${dirPath}/sub`
|
|
17
|
+
fs.mkdirSync(subDir)
|
|
18
|
+
expect(fs.existsSync(subDir)).toBeTruthy()
|
|
19
|
+
await removeDirectory(dirPath)
|
|
20
|
+
expect(fs.existsSync(subDir)).toBeFalsy()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('ends cleanly if directory does not exist', async () => {
|
|
24
|
+
const dirPath = 'remove-directory'
|
|
25
|
+
expect(fs.existsSync(dirPath)).toBeFalsy()
|
|
26
|
+
expect(await removeDirectory(dirPath)).toBe(dirPath)
|
|
27
|
+
})
|
|
28
|
+
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
2
|
+
import { bundle } from '../bundle.mjs'
|
|
3
|
+
import { distSeries } from './distSeries.mjs'
|
|
4
|
+
import { parallel, series } from 'gulp'
|
|
5
|
+
import { testQuick } from '../testQuick.mjs'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Run this function when the watched files are modified.
|
|
@@ -29,7 +29,7 @@ const testQuick = require('../testQuick')
|
|
|
29
29
|
* @param {string} path
|
|
30
30
|
* @returns {stream.Stream}
|
|
31
31
|
*/
|
|
32
|
-
const runOnChange = path => {
|
|
32
|
+
export const runOnChange = path => {
|
|
33
33
|
const useTs = gulpConfig.get('typescript.enabled')
|
|
34
34
|
const distPath = gulpConfig.get('dist.to')
|
|
35
35
|
const srcPath = gulpConfig.get('srcPath')
|
|
@@ -52,5 +52,3 @@ const runOnChange = path => {
|
|
|
52
52
|
? parallel(testQuick, series(runSeries, bundle))()
|
|
53
53
|
: series(testQuick, runSeries)()
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
module.exports = runOnChange
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
3
|
+
import { bundle } from '../bundle.mjs'
|
|
4
|
+
import { distFor } from './distFor.mjs'
|
|
5
|
+
import { runOnChange } from './runOnChange.mjs'
|
|
6
|
+
import { tsFor } from './tsFor.mjs'
|
|
7
|
+
import { testQuick } from '../testQuick.mjs'
|
|
8
|
+
|
|
3
9
|
setUp.setDefaults('test-run-on-change')
|
|
4
10
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const bundle = require('../bundle')
|
|
6
|
-
const distFor = require('./distFor')
|
|
7
|
-
const runOnChange = require('./runOnChange')
|
|
8
|
-
const tsFor = require('./tsFor')
|
|
9
|
-
const testQuick = require('../testQuick')
|
|
10
11
|
|
|
11
12
|
const genericFunction = () => Promise.resolve(true)
|
|
12
13
|
|
|
13
|
-
jest.mock('../bundle', () => jest.fn(genericFunction))
|
|
14
|
-
jest.mock('./distFor', () => jest.fn(genericFunction))
|
|
15
|
-
jest.mock('./tsFor', () => jest.fn(() => genericFunction))
|
|
16
|
-
jest.mock('../testQuick', () => jest.fn(genericFunction))
|
|
14
|
+
jest.mock('../bundle.mjs', () => ({ bundle: jest.fn(genericFunction) }))
|
|
15
|
+
jest.mock('./distFor.mjs', () => ({ distFor: jest.fn(genericFunction) }))
|
|
16
|
+
jest.mock('./tsFor.mjs', () => ({ tsFor: jest.fn(() => genericFunction) }))
|
|
17
|
+
jest.mock('../testQuick.mjs', () => ({ testQuick: jest.fn(genericFunction) }))
|
|
17
18
|
|
|
18
19
|
const rawContents = 'export function sayHello(name: string) {\n' +
|
|
19
20
|
' return `Hello from ${name}`;\n' +
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { dest, src } from 'gulp'
|
|
2
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
3
|
+
import cssnano from 'gulp-cssnano'
|
|
4
|
+
import rename from 'gulp-rename'
|
|
5
|
+
import * as sass from 'sass'
|
|
6
|
+
import { default as gulpSass } from 'gulp-sass'
|
|
7
|
+
|
|
8
|
+
const runSass = gulpSass(sass)
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Build the CSS for a given source pattern.
|
|
12
|
+
* @memberOf module:partials
|
|
13
|
+
* @param {string|array} [srcSearch='src/config/path/sass/for']
|
|
14
|
+
* @param {string} [cssPath='css/config/path']
|
|
15
|
+
* @returns {stream.Stream}
|
|
16
|
+
*/
|
|
17
|
+
export const sassFor = (srcSearch = gulpConfig.get('sass.from'), cssPath = gulpConfig.get('sass.to')) => src(srcSearch)
|
|
18
|
+
.pipe(runSass().on('error', runSass.logError)) // Passes it through a gulp-sass, log errors to console
|
|
19
|
+
.pipe(dest(cssPath))
|
|
20
|
+
.pipe(cssnano())
|
|
21
|
+
.pipe(rename({ extname: '.min.css' }))
|
|
22
|
+
.pipe(dest(cssPath))
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
3
|
+
import { sassFor } from './sassFor.mjs'
|
|
4
|
+
import { countMatches } from 'test-filesystem'
|
|
5
|
+
|
|
3
6
|
setUp.setDefaults('test-sass-for')
|
|
4
7
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const sassFor = require('./sassFor')
|
|
6
|
-
const { countMatches } = require('test-filesystem')
|
|
7
8
|
|
|
8
9
|
const sassContents = 'html\n' +
|
|
9
10
|
' font-size: 62.5%\n' +
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { dest, parallel, src } from 'gulp'
|
|
2
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
3
|
+
import ts from 'gulp-typescript'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Starting at the source directory, find all the ts files and convert them into the distribution directory.
|
|
@@ -10,12 +10,10 @@ const ts = require('gulp-typescript')
|
|
|
10
10
|
* @returns {Function}
|
|
11
11
|
* @see `https://www.typescriptlang.org/docs/handbook/gulp.html` for more info
|
|
12
12
|
*/
|
|
13
|
-
const tsFor = (srcPath = gulpConfig.get('typescript.from'), distPath = gulpConfig.get('typescript.to')) => {
|
|
13
|
+
export const tsFor = (srcPath = gulpConfig.get('typescript.from'), distPath = gulpConfig.get('typescript.to')) => {
|
|
14
14
|
const declarationProject = ts.createProject(gulpConfig.get('typescript.config'))
|
|
15
15
|
const tsProject = ts.createProject(gulpConfig.get('typescript.config'))
|
|
16
16
|
const makeDeclarations = () => src(srcPath).pipe(declarationProject()).dts.pipe(dest(distPath))
|
|
17
17
|
const compileJS = () => src(srcPath).pipe(tsProject()).js.pipe(dest(distPath))
|
|
18
18
|
return parallel(makeDeclarations, compileJS)
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
module.exports = tsFor
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from '../test-helpers/setUp.mjs'
|
|
3
|
+
import { tsFor } from './tsFor.mjs'
|
|
4
|
+
import { countMatches } from 'test-filesystem'
|
|
5
|
+
|
|
3
6
|
setUp.setDefaults('test-ts-for')
|
|
4
7
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const tsFor = require('./tsFor')
|
|
6
|
-
const { countMatches } = require('test-filesystem')
|
|
7
8
|
|
|
8
9
|
const rawContents = 'export function sayHello(name: string) {\n' +
|
|
9
10
|
' return `Hello from ${name}`;\n' +
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Micro-functions used as components for the main gulp functions.
|
|
3
|
+
* @file
|
|
4
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
5
|
+
* @version 3.0.0
|
|
6
|
+
* @module partials
|
|
7
|
+
* @memberOf module:js-build-tools
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { addToReadme } from './partials/addToReadme.mjs'
|
|
11
|
+
export { beginWatcher } from './partials/beginWatcher.mjs'
|
|
12
|
+
export { clean } from './partials/clean.mjs'
|
|
13
|
+
export { copyFor } from './partials/copyFor.mjs'
|
|
14
|
+
export { distFor } from './partials/distFor.mjs'
|
|
15
|
+
export { distForSrc } from './partials/distForSrc.mjs'
|
|
16
|
+
export { distSeries } from './partials/distSeries.mjs'
|
|
17
|
+
export { imagesFor } from './partials/imagesFor.mjs'
|
|
18
|
+
export { minifyFor } from './partials/minifyFor.mjs'
|
|
19
|
+
export { readmeTemplate } from './partials/readmeTemplate.mjs'
|
|
20
|
+
export { removeDirectory } from './partials/removeDirectory.mjs'
|
|
21
|
+
export { runOnChange } from './partials/runOnChange.mjs'
|
|
22
|
+
export { sassFor } from './partials/sassFor.mjs'
|
|
23
|
+
export { tsFor } from './partials/tsFor.mjs'
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as setUp from './test-helpers/setUp.mjs'
|
|
3
|
+
import { sass } from './sass.mjs'
|
|
4
|
+
|
|
3
5
|
setUp.setDefaults('test-sass')
|
|
4
6
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
const sass = require('./sass')
|
|
6
7
|
|
|
7
8
|
beforeEach(() => setUp.beforeEach().then(
|
|
8
9
|
() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Import the configurations and override some of them to direct to the temp directory.
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import * as gulpConfig from '../../gulp.config.mjs'
|
|
3
|
+
import * as setUp from 'test-filesystem'
|
|
4
4
|
|
|
5
5
|
let tempDir = 'test-temp/'
|
|
6
6
|
let srcPath = `${tempDir}src`
|
|
@@ -10,7 +10,7 @@ let srcPath = `${tempDir}src`
|
|
|
10
10
|
* @memberOf module:testHelpers
|
|
11
11
|
* @param {string} testDir
|
|
12
12
|
*/
|
|
13
|
-
const setDefaults = (testDir = 'test-temp') => {
|
|
13
|
+
export const setDefaults = (testDir = 'test-temp') => {
|
|
14
14
|
tempDir = `${testDir}/`
|
|
15
15
|
srcPath = `${tempDir}src`
|
|
16
16
|
setUp.setDefaults(tempDir)
|
|
@@ -40,28 +40,26 @@ const setDefaults = (testDir = 'test-temp') => {
|
|
|
40
40
|
gulpConfig.set('test.watch', `${srcPath}/**/*.js`)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
export { gulpConfig, setUp }
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*/
|
|
67
|
-
exports.afterEach = setUp.afterEach
|
|
45
|
+
export {
|
|
46
|
+
/**
|
|
47
|
+
* Ensure that the del has completed, recursively attempt to delete and recreate
|
|
48
|
+
* @memberOf module:testHelpers
|
|
49
|
+
* @param {boolean} [exists=true]
|
|
50
|
+
* @returns {Promise<*|void>}
|
|
51
|
+
*/
|
|
52
|
+
createTempDir,
|
|
53
|
+
/**
|
|
54
|
+
* In the Jest.beforeEach function call this one to set up the temp directory.
|
|
55
|
+
* @memberOf module:testHelpers
|
|
56
|
+
* @returns {Promise<*|void>}
|
|
57
|
+
*/
|
|
58
|
+
beforeEach,
|
|
59
|
+
/**
|
|
60
|
+
* In the Jest.afterEach function call this one to clean up and remove the temp directory.
|
|
61
|
+
* @memberOf module:testHelpers
|
|
62
|
+
* @returns {Promise<*>}
|
|
63
|
+
*/
|
|
64
|
+
afterEach
|
|
65
|
+
} from 'test-filesystem'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { afterEach, createTempDir, gulpConfig, setDefaults } from './setUp.mjs'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
|
|
4
|
+
setDefaults()
|
|
5
|
+
|
|
6
|
+
describe('setUp', () => {
|
|
7
|
+
test('able to create the test-temp/src directory', async () => {
|
|
8
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
9
|
+
expect(fs.existsSync(srcPath)).toBeFalsy()
|
|
10
|
+
await createTempDir()
|
|
11
|
+
expect(fs.existsSync(srcPath)).toBeTruthy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test('able to delete the test-temp/src directory', async () => {
|
|
15
|
+
expect(fs.existsSync(gulpConfig.get('srcPath'))).toBeTruthy()
|
|
16
|
+
await afterEach()
|
|
17
|
+
expect(fs.existsSync(gulpConfig.get('srcPath'))).toBeFalsy()
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as gulpConfig from '../gulp.config.mjs'
|
|
2
|
+
import { default as jest } from 'jest'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Run all tests with jest.
|
|
@@ -7,13 +7,11 @@ const { runCLI } = require('jest')
|
|
|
7
7
|
* @memberOf module:js-build-tools
|
|
8
8
|
* @returns {Promise<*>}
|
|
9
9
|
*/
|
|
10
|
-
const testFull = () => {
|
|
10
|
+
export const testFull = () => {
|
|
11
11
|
let testPath = gulpConfig.get('test.path')
|
|
12
12
|
if (!Array.isArray(testPath)) {
|
|
13
13
|
// The testPath must be an array of strings
|
|
14
14
|
testPath = [testPath]
|
|
15
15
|
}
|
|
16
|
-
return runCLI(gulpConfig.get('test.options'), testPath)
|
|
16
|
+
return jest.runCLI(gulpConfig.get('test.options'), testPath)
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
module.exports = testFull
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { testHelpers } from './testHelpers.mjs'
|
|
2
|
+
import { default as jestImport } from 'jest'
|
|
3
|
+
import { testFull } from './testFull.mjs'
|
|
4
|
+
|
|
5
|
+
const gulpConfig = testHelpers.gulpConfig
|
|
6
|
+
|
|
7
|
+
jest.mock('jest', () => ({
|
|
8
|
+
'runCLI': jest.fn(() => Promise.resolve(true))
|
|
9
|
+
}))
|
|
10
|
+
|
|
11
|
+
describe('testFull', () => {
|
|
12
|
+
test('runs the Jest CLI with the configured options', () => {
|
|
13
|
+
expect.assertions(1)
|
|
14
|
+
testFull()
|
|
15
|
+
expect(jestImport.runCLI).toHaveBeenCalledWith(gulpConfig.get('test.options'), [gulpConfig.get('test.path')])
|
|
16
|
+
})
|
|
17
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as gulpConfig from '../gulp.config.mjs'
|
|
2
|
+
import { default as jest } from 'jest'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Run the Jest tests for files which have been modified (based on git status).
|
|
@@ -7,13 +7,11 @@ const { runCLI } = require('jest')
|
|
|
7
7
|
* @memberOf module:js-build-tools
|
|
8
8
|
* @returns {Promise<*>}
|
|
9
9
|
*/
|
|
10
|
-
const testQuick = () => {
|
|
10
|
+
export const testQuick = () => {
|
|
11
11
|
let testPath = gulpConfig.get('test.path')
|
|
12
12
|
if (!Array.isArray(testPath)) {
|
|
13
13
|
// The testPath must be an array of strings
|
|
14
14
|
testPath = [testPath]
|
|
15
15
|
}
|
|
16
|
-
return runCLI({ onlyChanged: true }, testPath)
|
|
16
|
+
return jest.runCLI({ onlyChanged: true }, testPath)
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
module.exports = testQuick
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { testHelpers } from './testHelpers.mjs'
|
|
2
|
+
import { default as jestImport } from 'jest'
|
|
3
|
+
import { testQuick } from './testQuick.mjs'
|
|
4
|
+
|
|
5
|
+
const gulpConfig = testHelpers.gulpConfig
|
|
6
|
+
|
|
7
|
+
jest.mock('jest', () => ({
|
|
8
|
+
'runCLI': jest.fn(() => Promise.resolve(true))
|
|
9
|
+
}))
|
|
10
|
+
|
|
11
|
+
describe('testQuick', () => {
|
|
12
|
+
test('runs the jest CLI with onlyChanged option', () => {
|
|
13
|
+
expect.assertions(1)
|
|
14
|
+
testQuick()
|
|
15
|
+
expect(jestImport.runCLI).toHaveBeenCalledWith({ onlyChanged: true }, [gulpConfig.get('test.path')])
|
|
16
|
+
})
|
|
17
|
+
})
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { tsFor } from './partials/tsFor.mjs'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Simplified typescript task using tsFor.
|
|
5
5
|
* @memberOf module:js-build-tools
|
|
6
6
|
* @returns {Function}
|
|
7
7
|
*/
|
|
8
|
-
const typeScript = tsFor()
|
|
9
|
-
|
|
10
|
-
module.exports = typeScript
|
|
8
|
+
export const typeScript = tsFor()
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { typeScript } from './typeScript.mjs'
|
|
2
|
+
import { tsFor } from './partials/tsFor.mjs'
|
|
3
|
+
|
|
4
|
+
jest.mock('./partials/tsFor.mjs', () => ({ tsFor: jest.fn(() => () => null) }))
|
|
5
|
+
|
|
6
|
+
describe('typeScript', () => {
|
|
7
|
+
test('calls tsFor with no parameters', () => {
|
|
8
|
+
typeScript()
|
|
9
|
+
expect(tsFor).toHaveBeenCalled()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { isObject } from './isObject.mjs'
|
|
2
|
+
import { strAfter } from './strAfter.mjs'
|
|
3
|
+
import { strBefore } from './strBefore.mjs'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Get a nested property value from an object.
|
|
@@ -10,7 +10,7 @@ const strBefore = require('./strBefore')
|
|
|
10
10
|
* @param {string|null} [defaultValue=null] - The default value to return if the property is not found
|
|
11
11
|
* @returns {*} The value of the property
|
|
12
12
|
*/
|
|
13
|
-
const dotGet = (arrayObject, dotNotation, defaultValue = null) => {
|
|
13
|
+
export const dotGet = (arrayObject, dotNotation, defaultValue = null) => {
|
|
14
14
|
let key = strBefore(dotNotation, '.')
|
|
15
15
|
const lastKey = !key
|
|
16
16
|
if (lastKey) {
|
|
@@ -43,5 +43,3 @@ const dotGet = (arrayObject, dotNotation, defaultValue = null) => {
|
|
|
43
43
|
}
|
|
44
44
|
return dotGet(next, strAfter(dotNotation, '.'), defaultValue)
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
module.exports = dotGet
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { isObject } from './isObject.mjs'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Convert an array of keys into a regex, return a function to test if incoming keys match.
|
|
@@ -63,6 +63,4 @@ const performDotNotate = (arrayObject, didRetain, prepend = '', results = {}) =>
|
|
|
63
63
|
* @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
|
|
64
64
|
* @returns {Object<string, *>} The dot-notated object
|
|
65
65
|
*/
|
|
66
|
-
const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects))
|
|
67
|
-
|
|
68
|
-
module.exports = dotNotate
|
|
66
|
+
export const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects))
|