js-build-tools 2.2.11 → 2.3.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 +71 -0
- package/dist/build.js +48 -41
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +7 -8
- package/dist/bundle.min.js +1 -1
- package/dist/bundleLint.js +12 -14
- package/dist/bundleLint.min.js +1 -1
- package/dist/bundleMinify.js +3 -6
- package/dist/bundleMinify.min.js +1 -1
- package/dist/compileReadme.js +8 -6
- package/dist/compileReadme.min.js +1 -1
- package/dist/default.js +8 -7
- package/dist/default.min.js +1 -1
- package/dist/dist.js +2 -4
- package/dist/dist.min.js +1 -1
- package/dist/distLint.js +12 -13
- package/dist/distLint.min.js +1 -1
- package/dist/distMinify.js +3 -5
- package/dist/distMinify.min.js +1 -1
- package/dist/partials/addToReadme.js +9 -12
- package/dist/partials/beginWatcher.js +5 -6
- package/dist/partials/clean.js +3 -12
- package/dist/partials/distFor.js +10 -9
- package/dist/partials/distForSrc.js +3 -3
- package/dist/partials/distSeries.js +13 -14
- package/dist/partials/minifyFor.js +11 -11
- package/dist/partials/readmeTemplate.js +7 -8
- package/dist/partials/removeDirectory.js +7 -16
- package/dist/partials/runOnChange.js +17 -21
- package/dist/partials/sassFor.js +28 -0
- package/dist/partials/tsFor.js +14 -17
- package/dist/partials.js +30 -28
- package/dist/partials.min.js +1 -1
- package/dist/sass.js +7 -0
- package/dist/sass.min.js +1 -0
- package/dist/test-helpers/circularObject.js +1 -1
- package/dist/test-helpers/countMatches.js +1 -5
- package/dist/test-helpers/deepReferenceObject.js +1 -1
- package/dist/test-helpers/domItem.js +1 -1
- package/dist/test-helpers/jsonDom.js +1 -1
- package/dist/test-helpers/linkedList.js +1 -1
- package/dist/test-helpers/logObject.js +4 -7
- package/dist/test-helpers/multiReferenceObject.js +1 -1
- package/dist/test-helpers/nodeTree.js +1 -1
- package/dist/test-helpers/setUp.js +56 -96
- package/dist/testFull.js +6 -5
- package/dist/testFull.min.js +1 -1
- package/dist/testHelpers.js +10 -10
- package/dist/testHelpers.min.js +1 -1
- package/dist/testQuick.js +6 -5
- package/dist/testQuick.min.js +1 -1
- package/dist/typeScript.js +2 -2
- package/dist/typeScript.min.js +1 -1
- package/dist/watchFull.js +5 -6
- package/dist/watchFull.min.js +1 -1
- package/dist/watchTest.js +8 -9
- package/dist/watchTest.min.js +1 -1
- package/functions/build.js +5 -0
- package/functions/build.test.js +87 -11
- package/functions/partials/distFor.test.js +7 -7
- package/functions/partials/sassFor.js +22 -0
- package/functions/partials/sassFor.test.js +62 -0
- package/functions/partials.js +2 -0
- package/functions/partials.test.js +1 -1
- package/functions/sass.js +6 -0
- package/functions/sass.test.js +30 -0
- package/functions/test-helpers/setUp.js +4 -0
- package/gulp.config.js +4 -0
- package/gulpfile.base.js +2 -0
- package/package.json +9 -6
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
series
|
|
8
|
-
|
|
3
|
+
const gulpConfig = require('../../gulp.config');
|
|
4
|
+
const distFor = require('./distFor');
|
|
5
|
+
const distForSrc = require('./distForSrc');
|
|
6
|
+
const {
|
|
7
|
+
series
|
|
8
|
+
} = require('gulp');
|
|
9
|
+
const tsFor = require('./tsFor');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* When using TypeScript, ensure that we process the ts first then run babel (dist)
|
|
@@ -16,14 +17,12 @@ var tsFor = require('./tsFor');
|
|
|
16
17
|
* @param {string} [tsSearch='ts/search/config/path']
|
|
17
18
|
* @returns {function(null=): stream.Stream}
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return distFor(srcPath, distFinalPath);
|
|
26
|
-
};
|
|
20
|
+
const distSeries = function () {
|
|
21
|
+
let srcPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : distForSrc();
|
|
22
|
+
let distFinalPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gulpConfig.get('distPath');
|
|
23
|
+
let tsSearch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : gulpConfig.get('tsSearch');
|
|
24
|
+
const typescript = tsFor(tsSearch, distFinalPath);
|
|
25
|
+
const dist = () => distFor(srcPath, distFinalPath);
|
|
27
26
|
return gulpConfig.get('useTsConfig') ? series(typescript, dist) : dist;
|
|
28
27
|
};
|
|
29
28
|
module.exports = distSeries;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
dest
|
|
5
|
-
src
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const {
|
|
4
|
+
dest,
|
|
5
|
+
src
|
|
6
|
+
} = require('gulp');
|
|
7
|
+
const {
|
|
8
|
+
default: uglify
|
|
9
|
+
} = require('gulp-uglify-es');
|
|
10
|
+
const rename = require('gulp-rename');
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Minify files and rename the output with '.min' extension.
|
|
@@ -13,9 +15,7 @@ var rename = require('gulp-rename');
|
|
|
13
15
|
* @memberOf module:partials
|
|
14
16
|
* @returns {*}
|
|
15
17
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})).pipe(dest(destination));
|
|
20
|
-
};
|
|
18
|
+
const minifyFor = (srcSearch, destination) => src(srcSearch).pipe(uglify()).pipe(rename({
|
|
19
|
+
extname: '.min.js'
|
|
20
|
+
})).pipe(dest(destination));
|
|
21
21
|
module.exports = minifyFor;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
dest
|
|
5
|
-
src
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const {
|
|
4
|
+
dest,
|
|
5
|
+
src
|
|
6
|
+
} = require('gulp');
|
|
7
|
+
const gulpConfig = require('../../gulp.config.js');
|
|
8
|
+
const rename = require('gulp-rename');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Copy a readme template into the README.md file.
|
|
@@ -12,7 +13,5 @@ var rename = require('gulp-rename');
|
|
|
12
13
|
* @memberOf module:partials
|
|
13
14
|
* @returns {*}
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
-
return src(gulpConfig.get('readmeTemplate')).pipe(rename(gulpConfig.get('readmeFile'))).pipe(dest(gulpConfig.get('readmePath')));
|
|
17
|
-
};
|
|
16
|
+
const readmeTemplate = () => src(gulpConfig.get('readmeTemplate')).pipe(rename(gulpConfig.get('readmeFile'))).pipe(dest(gulpConfig.get('readmePath')));
|
|
18
17
|
module.exports = readmeTemplate;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exists = _require.exists;
|
|
3
|
+
const {
|
|
4
|
+
rm,
|
|
5
|
+
exists
|
|
6
|
+
} = require('fs');
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Return a promise to be completed once the specified directory is deleted.
|
|
@@ -13,15 +12,7 @@ var _require = require('fs'),
|
|
|
13
12
|
* @param {string} dirPath
|
|
14
13
|
* @returns {Promise<*>}
|
|
15
14
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return doesExist ? rm(dirPath, {
|
|
20
|
-
recursive: true
|
|
21
|
-
}, function (error) {
|
|
22
|
-
return error ? reject(error) : resolve(dirPath);
|
|
23
|
-
}) : resolve(dirPath);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
};
|
|
15
|
+
const removeDirectory = dirPath => new Promise((resolve, reject) => exists(dirPath, doesExist => doesExist ? rm(dirPath, {
|
|
16
|
+
recursive: true
|
|
17
|
+
}, error => error ? reject(error) : resolve(dirPath)) : resolve(dirPath)));
|
|
27
18
|
module.exports = removeDirectory;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require(
|
|
4
|
-
require(
|
|
5
|
-
require(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _require = require('gulp'),
|
|
12
|
-
parallel = _require.parallel,
|
|
13
|
-
series = _require.series;
|
|
14
|
-
var testQuick = require('../testQuick');
|
|
3
|
+
const gulpConfig = require('../../gulp.config.js');
|
|
4
|
+
const bundle = require('../bundle');
|
|
5
|
+
const distSeries = require('./distSeries');
|
|
6
|
+
const {
|
|
7
|
+
parallel,
|
|
8
|
+
series
|
|
9
|
+
} = require('gulp');
|
|
10
|
+
const testQuick = require('../testQuick');
|
|
15
11
|
|
|
16
12
|
/**
|
|
17
13
|
* Run this function when the watched files are modified.
|
|
@@ -39,10 +35,10 @@ var testQuick = require('../testQuick');
|
|
|
39
35
|
* @param {string} path
|
|
40
36
|
* @returns {stream.Stream}
|
|
41
37
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
const runOnChange = path => {
|
|
39
|
+
const useTs = gulpConfig.get('useTsConfig');
|
|
40
|
+
const distPath = gulpConfig.get('distPath');
|
|
41
|
+
const srcPath = gulpConfig.get('srcPath');
|
|
46
42
|
/**
|
|
47
43
|
* 1. The original path comes in from src and is a .ts
|
|
48
44
|
* 2. Discover the outgoing dist path where that file should go
|
|
@@ -51,13 +47,13 @@ var runOnChange = function runOnChange(path) {
|
|
|
51
47
|
* 5. Use the dist path found previously in #2
|
|
52
48
|
* 6. Use the full dist path and the dist outgoing path in distFor
|
|
53
49
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
const pathRegex = new RegExp(`^${srcPath}(.*\\/)(.+)\\.(js|ts)$`, 'i');
|
|
51
|
+
const distPathResult = path.replace(pathRegex, `${distPath}$1`);
|
|
52
|
+
let distSrcPath = path;
|
|
57
53
|
if (useTs) {
|
|
58
|
-
distSrcPath = path.replace(pathRegex,
|
|
54
|
+
distSrcPath = path.replace(pathRegex, `${distPath}$1$2.js`);
|
|
59
55
|
}
|
|
60
|
-
|
|
56
|
+
const runSeries = distSeries(distSrcPath, distPathResult, path);
|
|
61
57
|
return gulpConfig.get('nodeOnly') ? series(testQuick, runSeries)() : parallel(testQuick, series(runSeries, bundle))();
|
|
62
58
|
};
|
|
63
59
|
module.exports = runOnChange;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
dest,
|
|
5
|
+
src
|
|
6
|
+
} = require('gulp');
|
|
7
|
+
const gulpConfig = require('../../gulp.config.js');
|
|
8
|
+
const cssnano = require('gulp-cssnano');
|
|
9
|
+
const rename = require('gulp-rename');
|
|
10
|
+
const sass = require('gulp-sass')(require('sass'));
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Build the CSS for a given source pattern.
|
|
14
|
+
* @function
|
|
15
|
+
* @memberOf module:partials
|
|
16
|
+
* @param {string|array} [srcSearch='src/config/path/sass/for']
|
|
17
|
+
* @param {string} [cssPath='css/config/path']
|
|
18
|
+
* @returns {stream.Stream}
|
|
19
|
+
*/
|
|
20
|
+
const sassFor = function () {
|
|
21
|
+
let srcSearch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gulpConfig.get('sassSearch');
|
|
22
|
+
let cssPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gulpConfig.get('cssPath');
|
|
23
|
+
return src(srcSearch).pipe(sass().on('error', sass.logError)) // Passes it through a gulp-sass, log errors to console
|
|
24
|
+
.pipe(dest(cssPath)).pipe(cssnano()).pipe(rename({
|
|
25
|
+
extname: '.min.css'
|
|
26
|
+
})).pipe(dest(cssPath));
|
|
27
|
+
};
|
|
28
|
+
module.exports = sassFor;
|
package/dist/partials/tsFor.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
dest
|
|
5
|
-
parallel
|
|
6
|
-
src
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const {
|
|
4
|
+
dest,
|
|
5
|
+
parallel,
|
|
6
|
+
src
|
|
7
|
+
} = require('gulp');
|
|
8
|
+
const gulpConfig = require('../../gulp.config.js');
|
|
9
|
+
const ts = require('gulp-typescript');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Starting at the source directory, find all the ts files and convert them into the distribution directory.
|
|
@@ -16,17 +17,13 @@ var ts = require('gulp-typescript');
|
|
|
16
17
|
* @returns {Function}
|
|
17
18
|
* @see `https://www.typescriptlang.org/docs/handbook/gulp.html` for more info
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
var compileJS = function compileJS() {
|
|
28
|
-
return src(srcPath).pipe(tsProject()).js.pipe(dest(distPath));
|
|
29
|
-
};
|
|
20
|
+
const tsFor = function () {
|
|
21
|
+
let srcPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gulpConfig.get('tsSearch');
|
|
22
|
+
let distPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gulpConfig.get('distPath');
|
|
23
|
+
const declarationProject = ts.createProject(gulpConfig.get('useTsConfig'));
|
|
24
|
+
const tsProject = ts.createProject(gulpConfig.get('useTsConfig'));
|
|
25
|
+
const makeDeclarations = () => src(srcPath).pipe(declarationProject()).dts.pipe(dest(distPath));
|
|
26
|
+
const compileJS = () => src(srcPath).pipe(tsProject()).js.pipe(dest(distPath));
|
|
30
27
|
return parallel(makeDeclarations, compileJS);
|
|
31
28
|
};
|
|
32
29
|
module.exports = tsFor;
|
package/dist/partials.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
3
|
/**
|
|
4
4
|
* Micro-functions used as components for the main gulp functions.
|
|
5
5
|
* @file
|
|
@@ -7,29 +7,31 @@
|
|
|
7
7
|
* @version 2.0.0
|
|
8
8
|
* @module partials
|
|
9
9
|
* @memberOf module:js-build-tools
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const addToReadme = require('./partials/addToReadme')
|
|
13
|
+
const beginWatcher = require('./partials/beginWatcher')
|
|
14
|
+
const clean = require('./partials/clean')
|
|
15
|
+
const distFor = require('./partials/distFor')
|
|
16
|
+
const distForSrc = require('./partials/distForSrc')
|
|
17
|
+
const distSeries = require('./partials/distSeries')
|
|
18
|
+
const minifyFor = require('./partials/minifyFor')
|
|
19
|
+
const readmeTemplate = require('./partials/readmeTemplate')
|
|
20
|
+
const removeDirectory = require('./partials/removeDirectory')
|
|
21
|
+
const runOnChange = require('./partials/runOnChange')
|
|
22
|
+
const sassFor = require('./partials/sassFor')
|
|
23
|
+
const tsFor = require('./partials/tsFor')
|
|
24
|
+
module.exports = {
|
|
25
|
+
addToReadme,
|
|
26
|
+
beginWatcher,
|
|
27
|
+
clean,
|
|
28
|
+
distFor,
|
|
29
|
+
distForSrc,
|
|
30
|
+
distSeries,
|
|
31
|
+
minifyFor,
|
|
32
|
+
readmeTemplate,
|
|
33
|
+
removeDirectory,
|
|
34
|
+
runOnChange,
|
|
35
|
+
sassFor,
|
|
36
|
+
tsFor
|
|
37
|
+
}
|
package/dist/partials.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const addToReadme=require("./partials/addToReadme"),beginWatcher=require("./partials/beginWatcher"),clean=require("./partials/clean"),distFor=require("./partials/distFor"),distForSrc=require("./partials/distForSrc"),distSeries=require("./partials/distSeries"),minifyFor=require("./partials/minifyFor"),readmeTemplate=require("./partials/readmeTemplate"),removeDirectory=require("./partials/removeDirectory"),runOnChange=require("./partials/runOnChange"),sassFor=require("./partials/sassFor"),tsFor=require("./partials/tsFor");module.exports={addToReadme:addToReadme,beginWatcher:beginWatcher,clean:clean,distFor:distFor,distForSrc:distForSrc,distSeries:distSeries,minifyFor:minifyFor,readmeTemplate:readmeTemplate,removeDirectory:removeDirectory,runOnChange:runOnChange,sassFor:sassFor,tsFor:tsFor};
|
package/dist/sass.js
ADDED
package/dist/sass.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const sassFor=require("./partials/sassFor"),sass=()=>sassFor();module.exports=sass;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
4
|
-
require("core-js/modules/es.string.split.js");
|
|
5
3
|
/**
|
|
6
4
|
* Simple way to count string occurrences for testing.
|
|
7
5
|
* @function
|
|
@@ -10,7 +8,5 @@ require("core-js/modules/es.string.split.js");
|
|
|
10
8
|
* @param {string} search
|
|
11
9
|
* @returns {number}
|
|
12
10
|
*/
|
|
13
|
-
|
|
14
|
-
return content.split(search).length - 1;
|
|
15
|
-
};
|
|
11
|
+
const countMatches = (content, search) => content.split(search).length - 1;
|
|
16
12
|
module.exports = countMatches;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.json.stringify.js");
|
|
4
3
|
/**
|
|
5
4
|
* Log out an object in a nicely formatted way.
|
|
6
5
|
* @function
|
|
@@ -10,12 +9,10 @@ require("core-js/modules/es.json.stringify.js");
|
|
|
10
9
|
* @param {string} [outputType=log]
|
|
11
10
|
* @returns {string|undefined}
|
|
12
11
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return "'".concat(label, "' | ") + JSON.stringify(object);
|
|
18
|
-
} : console[outputType];
|
|
12
|
+
const logObject = function (object) {
|
|
13
|
+
let label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'logging';
|
|
14
|
+
let outputType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'log';
|
|
15
|
+
const logger = outputType === 'string' ? (label, object) => `'${label}' | ` + JSON.stringify(object) : console[outputType];
|
|
19
16
|
if (typeof require === 'undefined' || outputType === 'string') {
|
|
20
17
|
return logger(label, object);
|
|
21
18
|
}
|