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,117 +1,77 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require(
|
|
4
|
-
|
|
5
|
-
require(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
require(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
require("core-js/modules/esnext.iterator.constructor.js");
|
|
13
|
-
require("core-js/modules/esnext.iterator.for-each.js");
|
|
14
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
15
|
-
require("core-js/modules/es.array.reverse.js");
|
|
16
|
-
require("core-js/modules/es.array.slice.js");
|
|
17
|
-
require("core-js/modules/es.object.to-string.js");
|
|
18
|
-
require("core-js/modules/es.promise.js");
|
|
19
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
20
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
21
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
22
|
-
var fs = require('fs');
|
|
23
|
-
// Import the configurations and override some of them in order to direct to the temp directory.
|
|
24
|
-
var gulpConfig = require('../../gulp.config.js');
|
|
25
|
-
var _require = require('../partials'),
|
|
26
|
-
removeDirectory = _require.removeDirectory;
|
|
27
|
-
var tempDir = 'test-temp/';
|
|
28
|
-
var srcPath = "".concat(tempDir, "src");
|
|
29
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
// Import the configurations and override some of them in order to direct to the temp directory.
|
|
5
|
+
const gulpConfig = require('../../gulp.config.js');
|
|
6
|
+
const {
|
|
7
|
+
removeDirectory
|
|
8
|
+
} = require('../partials');
|
|
9
|
+
let tempDir = 'test-temp/';
|
|
10
|
+
let srcPath = `${tempDir}src`;
|
|
11
|
+
|
|
30
12
|
/**
|
|
31
13
|
* Update the gulp configurations with the test data. Set the test directory where temp files will be created for testing.
|
|
32
14
|
* @function
|
|
33
15
|
* @memberOf module:testHelpers
|
|
34
16
|
* @param {string} testDir
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
tempDir =
|
|
39
|
-
srcPath =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
gulpConfig.set('
|
|
44
|
-
gulpConfig.set('
|
|
45
|
-
gulpConfig.set('
|
|
46
|
-
gulpConfig.set('
|
|
47
|
-
gulpConfig.set('
|
|
48
|
-
gulpConfig.set('
|
|
49
|
-
gulpConfig.set('
|
|
50
|
-
gulpConfig.set('
|
|
51
|
-
gulpConfig.set('
|
|
52
|
-
gulpConfig.set('
|
|
53
|
-
gulpConfig.set('
|
|
54
|
-
gulpConfig.set('
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
17
|
+
*/
|
|
18
|
+
const setDefaults = function () {
|
|
19
|
+
let testDir = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'test-temp';
|
|
20
|
+
tempDir = `${testDir}/`;
|
|
21
|
+
srcPath = `${tempDir}src`;
|
|
22
|
+
const distPath = `${tempDir}dist`;
|
|
23
|
+
const browserPath = `${tempDir}browser`;
|
|
24
|
+
const sassPath = `${tempDir}sass`;
|
|
25
|
+
gulpConfig.set('browserPath', browserPath);
|
|
26
|
+
gulpConfig.set('cleanPaths', [distPath, browserPath]);
|
|
27
|
+
gulpConfig.set('cssPath', `${browserPath}/css`);
|
|
28
|
+
gulpConfig.set('distMain', `${distPath}/main`);
|
|
29
|
+
gulpConfig.set('distPath', distPath);
|
|
30
|
+
gulpConfig.set('distSearch', `${distPath}/**/*.js`);
|
|
31
|
+
gulpConfig.set('readmeTemplate', `${tempDir}MAIN.md`);
|
|
32
|
+
gulpConfig.set('readmePath', tempDir);
|
|
33
|
+
gulpConfig.set('readmeSearch', `${srcPath}/**/!(*.test).js`);
|
|
34
|
+
gulpConfig.set('rootPath', tempDir);
|
|
35
|
+
gulpConfig.set('sassPath', sassPath);
|
|
36
|
+
gulpConfig.set('sassSearch', `${sassPath}/**/*.+(scss|sass)`);
|
|
37
|
+
gulpConfig.set('srcPath', srcPath);
|
|
38
|
+
gulpConfig.set('srcSearch', `${srcPath}/**/!(*.test).js`);
|
|
39
|
+
gulpConfig.set('tsSearch', `${srcPath}/**/*.ts`);
|
|
40
|
+
gulpConfig.set('watchSearch', `${srcPath}/**/*.js`);
|
|
41
|
+
};
|
|
42
|
+
exports.setDefaults = setDefaults;
|
|
43
|
+
exports.gulpConfig = gulpConfig;
|
|
44
|
+
|
|
59
45
|
/**
|
|
60
46
|
* Ensure that the del has completed, recursively attempt to delete and recreate
|
|
61
47
|
* @function
|
|
62
48
|
* @memberOf module:testHelpers
|
|
63
49
|
* @param {boolean} [exists=true]
|
|
64
50
|
* @returns {Promise<*|void>}
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
return _context.abrupt("return", removeDirectory(tempDir).then(function (removedDir) {
|
|
79
|
-
return createTempDir(fs.existsSync(removedDir));
|
|
80
|
-
}).catch(function (error) {
|
|
81
|
-
return console.error('Error: ', error);
|
|
82
|
-
}));
|
|
83
|
-
case 3:
|
|
84
|
-
return _context.abrupt("return", fs.mkdirSync(srcPath, {
|
|
85
|
-
recursive: true
|
|
86
|
-
}));
|
|
87
|
-
case 4:
|
|
88
|
-
case "end":
|
|
89
|
-
return _context.stop();
|
|
90
|
-
}
|
|
91
|
-
}, _callee);
|
|
92
|
-
}));
|
|
93
|
-
return function createTempDir() {
|
|
94
|
-
return _ref.apply(this, arguments);
|
|
95
|
-
};
|
|
96
|
-
}();
|
|
97
|
-
exports.createTempDir = createTempDir;
|
|
98
|
-
|
|
51
|
+
*/
|
|
52
|
+
const createTempDir = async function () {
|
|
53
|
+
let exists = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
54
|
+
if (exists) {
|
|
55
|
+
return removeDirectory(tempDir).then(removedDir => createTempDir(fs.existsSync(removedDir))).catch(error => console.error('Error: ', error));
|
|
56
|
+
}
|
|
57
|
+
return fs.mkdirSync(srcPath, {
|
|
58
|
+
recursive: true
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
exports.createTempDir = createTempDir;
|
|
62
|
+
|
|
99
63
|
/**
|
|
100
64
|
* In the Jest.beforeEach function call this one to set up the temp directory.
|
|
101
65
|
* @function
|
|
102
66
|
* @memberOf module:testHelpers
|
|
103
67
|
* @returns {Promise<*|void>}
|
|
104
|
-
*/
|
|
105
|
-
exports.beforeEach =
|
|
106
|
-
|
|
107
|
-
};
|
|
108
|
-
|
|
68
|
+
*/
|
|
69
|
+
exports.beforeEach = () => createTempDir();
|
|
70
|
+
|
|
109
71
|
/**
|
|
110
72
|
* In the Jest.afterEach function call this one to clean up and remove the temp directory.
|
|
111
73
|
* @function
|
|
112
74
|
* @memberOf module:testHelpers
|
|
113
75
|
* @returns {Promise<*>}
|
|
114
|
-
*/
|
|
115
|
-
exports.afterEach =
|
|
116
|
-
return removeDirectory(tempDir);
|
|
117
|
-
};
|
|
76
|
+
*/
|
|
77
|
+
exports.afterEach = () => removeDirectory(tempDir);
|
package/dist/testFull.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const gulpConfig = require('../gulp.config.js')
|
|
4
|
+
const {
|
|
5
|
+
runCLI
|
|
6
|
+
} = require('jest')
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Run all tests with jest.
|
|
@@ -11,8 +12,8 @@ var runCLI = _require.runCLI
|
|
|
11
12
|
* @memberOf module:js-build-tools
|
|
12
13
|
* @returns {Promise<*>}
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const testFull = () => {
|
|
16
|
+
let testPath = gulpConfig.get('testPath')
|
|
16
17
|
if (!Array.isArray(testPath)) {
|
|
17
18
|
// The testPath must be an array of strings
|
|
18
19
|
testPath = [testPath]
|
package/dist/testFull.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const gulpConfig=require("../gulp.config.js"),{runCLI:runCLI}=require("jest"),testFull=()=>{let t=gulpConfig.get("testPath");return Array.isArray(t)||(t=[t]),runCLI(gulpConfig.get("testOptions"),t)};module.exports=testFull;
|
package/dist/testHelpers.js
CHANGED
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
* @memberOf module:js-build-tools
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
const circularObject = require('./test-helpers/circularObject')
|
|
13
|
+
const countMatches = require('./test-helpers/countMatches')
|
|
14
|
+
const deepReferenceObject = require('./test-helpers/deepReferenceObject')
|
|
15
|
+
const domItem = require('./test-helpers/domItem')
|
|
16
|
+
const jsonDom = require('./test-helpers/jsonDom')
|
|
17
|
+
const linkedList = require('./test-helpers/linkedList')
|
|
18
|
+
const logObject = require('./test-helpers/logObject')
|
|
19
|
+
const multiReferenceObject = require('./test-helpers/multiReferenceObject')
|
|
20
|
+
const nodeTree = require('./test-helpers/nodeTree')
|
|
21
|
+
const setUp = require('./test-helpers/setUp')
|
|
22
22
|
module.exports = {
|
|
23
23
|
circularObject,
|
|
24
24
|
countMatches,
|
package/dist/testHelpers.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const circularObject=require("./test-helpers/circularObject"),countMatches=require("./test-helpers/countMatches"),deepReferenceObject=require("./test-helpers/deepReferenceObject"),domItem=require("./test-helpers/domItem"),jsonDom=require("./test-helpers/jsonDom"),linkedList=require("./test-helpers/linkedList"),logObject=require("./test-helpers/logObject"),multiReferenceObject=require("./test-helpers/multiReferenceObject"),nodeTree=require("./test-helpers/nodeTree"),setUp=require("./test-helpers/setUp");module.exports={circularObject:circularObject,countMatches:countMatches,deepReferenceObject:deepReferenceObject,domItem:domItem,jsonDom:jsonDom,linkedList:linkedList,logObject:logObject,multiReferenceObject:multiReferenceObject,nodeTree:nodeTree,setUp:setUp};
|
package/dist/testQuick.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const gulpConfig = require('../gulp.config.js')
|
|
4
|
+
const {
|
|
5
|
+
runCLI
|
|
6
|
+
} = require('jest')
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Run the Jest tests for files which have been modified (based on git status).
|
|
@@ -11,8 +12,8 @@ var runCLI = _require.runCLI
|
|
|
11
12
|
* @memberOf module:js-build-tools
|
|
12
13
|
* @returns {Promise<*>}
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const testQuick = () => {
|
|
16
|
+
let testPath = gulpConfig.get('testPath')
|
|
16
17
|
if (!Array.isArray(testPath)) {
|
|
17
18
|
// The testPath must be an array of strings
|
|
18
19
|
testPath = [testPath]
|
package/dist/testQuick.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const gulpConfig=require("../gulp.config.js"),{runCLI:runCLI}=require("jest"),testQuick=()=>{let e=gulpConfig.get("testPath");return Array.isArray(e)||(e=[e]),runCLI({onlyChanged:!0},e)};module.exports=testQuick;
|
package/dist/typeScript.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const tsFor = require('./partials/tsFor')
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Simplified typescript task using tsFor.
|
|
@@ -8,5 +8,5 @@ var tsFor = require('./partials/tsFor')
|
|
|
8
8
|
* @memberOf module:js-build-tools
|
|
9
9
|
* @returns {Function}
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
const typeScript = tsFor()
|
|
12
12
|
module.exports = typeScript
|
package/dist/typeScript.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const tsFor=require("./partials/tsFor"),typeScript=tsFor();module.exports=typeScript;
|
package/dist/watchFull.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const {
|
|
4
|
+
beginWatcher,
|
|
5
|
+
runOnChange
|
|
6
|
+
} = require('./partials')
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Watch for changes and run the distribution for the changed files, then bundle and test the changed files.
|
|
@@ -10,7 +11,5 @@ var runOnChange = _require.runOnChange
|
|
|
10
11
|
* @memberOf module:js-build-tools
|
|
11
12
|
* @returns {FSWatcher}
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
-
return beginWatcher().on('change', runOnChange)
|
|
15
|
-
}
|
|
14
|
+
const watchFull = () => beginWatcher().on('change', runOnChange)
|
|
16
15
|
module.exports = watchFull
|
package/dist/watchFull.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const{beginWatcher:beginWatcher,runOnChange:runOnChange}=require("./partials"),watchFull=()=>beginWatcher().on("change",runOnChange);module.exports=watchFull;
|
package/dist/watchTest.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const gulpConfig = require('../gulp.config.js')
|
|
4
|
+
const {
|
|
5
|
+
watch
|
|
6
|
+
} = require('gulp')
|
|
7
|
+
const testQuick = require('./testQuick')
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Watch for changes and run the tests.
|
|
@@ -11,9 +12,7 @@ var testQuick = require('./testQuick')
|
|
|
11
12
|
* @memberOf module:js-build-tools
|
|
12
13
|
* @returns {*}
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, testQuick)
|
|
18
|
-
}
|
|
15
|
+
const watchTest = () => watch(gulpConfig.get('watchSearch'), {
|
|
16
|
+
ignoreInitial: false
|
|
17
|
+
}, testQuick)
|
|
19
18
|
module.exports = watchTest
|
package/dist/watchTest.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const gulpConfig=require("../gulp.config.js"),{watch:watch}=require("gulp"),testQuick=require("./testQuick"),watchTest=()=>watch(gulpConfig.get("watchSearch"),{ignoreInitial:!1},testQuick);module.exports=watchTest;
|
package/functions/build.js
CHANGED
|
@@ -7,6 +7,7 @@ const distLint = require('./distLint')
|
|
|
7
7
|
const distMinify = require('./distMinify')
|
|
8
8
|
const { parallel, series } = require('gulp')
|
|
9
9
|
const gulpConfig = require('../gulp.config.js')
|
|
10
|
+
const sass = require('./sass.js')
|
|
10
11
|
const testFull = require('./testFull')
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -36,6 +37,10 @@ const build = (done = null) => {
|
|
|
36
37
|
runActions.push(compileReadme)
|
|
37
38
|
}
|
|
38
39
|
runActions.push(testFull)
|
|
40
|
+
if (gulpConfig.get('useSass')) {
|
|
41
|
+
// Since we didn't run this in series after dist because of typescript, we need to run it now. Potentially faster here.
|
|
42
|
+
runActions.push(sass)
|
|
43
|
+
}
|
|
39
44
|
return parallel(
|
|
40
45
|
...runActions
|
|
41
46
|
)(done)
|
package/functions/build.test.js
CHANGED
|
@@ -4,6 +4,7 @@ setUp.setDefaults('test-build')
|
|
|
4
4
|
const gulpConfig = setUp.gulpConfig
|
|
5
5
|
const build = require('./build')
|
|
6
6
|
const clean = require('./partials/clean')
|
|
7
|
+
const sass = require('./sass')
|
|
7
8
|
const testFull = require('./testFull')
|
|
8
9
|
const { countMatches } = require('./testHelpers')
|
|
9
10
|
|
|
@@ -78,6 +79,27 @@ const tsConfigContents = '{\n' +
|
|
|
78
79
|
' }\n' +
|
|
79
80
|
'}'
|
|
80
81
|
|
|
82
|
+
const sassContents = 'html\n' +
|
|
83
|
+
' font-size: 62.5%\n' +
|
|
84
|
+
' color: #444\n' +
|
|
85
|
+
' font-size: 1em\n' +
|
|
86
|
+
' line-height: 1.4\n' +
|
|
87
|
+
' background-color: #fff\n' +
|
|
88
|
+
'\n' +
|
|
89
|
+
'html, body\n' +
|
|
90
|
+
' width: 100%\n' +
|
|
91
|
+
' height: 100%\n' +
|
|
92
|
+
' margin: 0\n' +
|
|
93
|
+
' padding: 0\n' +
|
|
94
|
+
' position: absolute\n' +
|
|
95
|
+
' text-align: center\n' +
|
|
96
|
+
'\n' +
|
|
97
|
+
'a\n' +
|
|
98
|
+
' outline: none\n' +
|
|
99
|
+
' text-decoration: none'
|
|
100
|
+
|
|
101
|
+
const sassPath = gulpConfig.get('sassPath')
|
|
102
|
+
|
|
81
103
|
beforeEach(
|
|
82
104
|
() => setUp.beforeEach()
|
|
83
105
|
.then(
|
|
@@ -86,6 +108,7 @@ beforeEach(
|
|
|
86
108
|
const readmePath = gulpConfig.get('readmePath')
|
|
87
109
|
const sourcesPath = `${srcPath}/sources`
|
|
88
110
|
await fs.mkdirSync(sourcesPath)
|
|
111
|
+
await fs.mkdirSync(sassPath, { recursive: true })
|
|
89
112
|
return fs.writeFileSync(`${readmePath}/MAIN.md`, mainMd)
|
|
90
113
|
}
|
|
91
114
|
)
|
|
@@ -105,7 +128,7 @@ describe('build', () => {
|
|
|
105
128
|
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
106
129
|
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
107
130
|
gulpConfig.set('nodeOnly', true)
|
|
108
|
-
expect.assertions(
|
|
131
|
+
expect.assertions(13)
|
|
109
132
|
build(() => {
|
|
110
133
|
// Called 'clean'
|
|
111
134
|
expect(clean).toHaveBeenCalled()
|
|
@@ -122,17 +145,10 @@ describe('build', () => {
|
|
|
122
145
|
expect(fs.existsSync(`${distSourcesPath}/file1.min.js`)).toBeTruthy()
|
|
123
146
|
const babelifiedFile1 = fs.readFileSync(`${distSourcesPath}/file1.js`).toString()
|
|
124
147
|
expect(countMatches(babelifiedFile1, '\'use strict\'')).toEqual(1)
|
|
125
|
-
expect(countMatches(babelifiedFile1, 'const ')).toEqual(0)
|
|
126
|
-
expect(countMatches(babelifiedFile1, 'var ')).toEqual(1)
|
|
127
|
-
expect(countMatches(babelifiedFile1, 'function ')).toEqual(1)
|
|
128
|
-
expect(countMatches(babelifiedFile1, 'return ')).toEqual(1)
|
|
129
148
|
|
|
130
149
|
expect(fs.existsSync(`${distSourcesPath}/file2.min.js`)).toBeTruthy()
|
|
131
150
|
const babelifiedFile2 = fs.readFileSync(`${distSourcesPath}/file2.js`).toString()
|
|
132
151
|
expect(countMatches(babelifiedFile2, '\'use strict\'')).toEqual(1)
|
|
133
|
-
expect(countMatches(babelifiedFile2, 'const ')).toEqual(0)
|
|
134
|
-
expect(countMatches(babelifiedFile2, 'var ')).toEqual(2)
|
|
135
|
-
expect(countMatches(babelifiedFile2, 'function ')).toEqual(1)
|
|
136
152
|
|
|
137
153
|
// Generated README.md (compileReadme)
|
|
138
154
|
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
@@ -180,8 +196,60 @@ describe('build', () => {
|
|
|
180
196
|
// Minify the browser files (bundleMinify)
|
|
181
197
|
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
182
198
|
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
183
|
-
expect(countMatches(bundledContents, 'file1')).toEqual(
|
|
184
|
-
expect(countMatches(bundledContents, 'file2')).toEqual(
|
|
199
|
+
expect(countMatches(bundledContents, 'file1')).toEqual(7)
|
|
200
|
+
expect(countMatches(bundledContents, 'file2')).toEqual(7)
|
|
201
|
+
|
|
202
|
+
// Generated README.md (compileReadme)
|
|
203
|
+
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
204
|
+
expect(countMatches(readmeContents, mainMd)).toEqual(1)
|
|
205
|
+
expect(countMatches(readmeContents, 'test-build')).toEqual(4)
|
|
206
|
+
expect(countMatches(readmeContents, 'file1')).toEqual(4)
|
|
207
|
+
expect(countMatches(readmeContents, 'file2')).toEqual(4)
|
|
208
|
+
|
|
209
|
+
// Ran 'testFull'
|
|
210
|
+
expect(testFull).toHaveBeenCalled()
|
|
211
|
+
done()
|
|
212
|
+
})
|
|
213
|
+
}, 30000)
|
|
214
|
+
|
|
215
|
+
test('when nodeOnly false and useSass true: calls clean, distSeries, distLint, distMinify, bundle, bundleLint, bundleMinify, compileReadme, testFull, sass', done => {
|
|
216
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
217
|
+
const sourcesPath = `${srcPath}/sources`
|
|
218
|
+
const distPath = gulpConfig.get('distPath')
|
|
219
|
+
const browserFile = gulpConfig.get('browserName')
|
|
220
|
+
const browserPath = gulpConfig.get('browserPath')
|
|
221
|
+
const bundledFile = `${browserPath}/${browserFile}.js`
|
|
222
|
+
const readmePath = gulpConfig.get('readmePath')
|
|
223
|
+
const readmeFile = gulpConfig.get('readmeFile')
|
|
224
|
+
const sassFile = `${sassPath}/sassFor.sass`
|
|
225
|
+
fs.writeFileSync(sassFile, sassContents)
|
|
226
|
+
fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
|
|
227
|
+
fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
|
|
228
|
+
fs.writeFileSync(`${srcPath}/main.js`, mainFileContents)
|
|
229
|
+
gulpConfig.set('nodeOnly', false)
|
|
230
|
+
gulpConfig.set('useSass', true)
|
|
231
|
+
expect.assertions(16)
|
|
232
|
+
build(() => {
|
|
233
|
+
// Called 'clean'
|
|
234
|
+
expect(clean).toHaveBeenCalled()
|
|
235
|
+
|
|
236
|
+
// Created dist directory (distSeries)
|
|
237
|
+
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
238
|
+
|
|
239
|
+
// Minify the dist files (distMinify)
|
|
240
|
+
expect(fs.existsSync(`${distPath}/main.min.js`)).toBeTruthy()
|
|
241
|
+
const babelifiedMain = fs.readFileSync(`${distPath}/main.js`).toString()
|
|
242
|
+
// Used single quotes because of distLint
|
|
243
|
+
expect(countMatches(babelifiedMain, '\'use strict\'')).toEqual(1)
|
|
244
|
+
|
|
245
|
+
// Created browser directory (bundle)
|
|
246
|
+
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
247
|
+
|
|
248
|
+
// Minify the browser files (bundleMinify)
|
|
249
|
+
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
250
|
+
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
251
|
+
expect(countMatches(bundledContents, 'file1')).toEqual(7)
|
|
252
|
+
expect(countMatches(bundledContents, 'file2')).toEqual(7)
|
|
185
253
|
|
|
186
254
|
// Generated README.md (compileReadme)
|
|
187
255
|
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
@@ -192,6 +260,14 @@ describe('build', () => {
|
|
|
192
260
|
|
|
193
261
|
// Ran 'testFull'
|
|
194
262
|
expect(testFull).toHaveBeenCalled()
|
|
263
|
+
|
|
264
|
+
// Ran 'sass'
|
|
265
|
+
const cssPath = gulpConfig.get('cssPath')
|
|
266
|
+
const cssContents = fs.readFileSync(`${cssPath}/sassFor.css`).toString()
|
|
267
|
+
expect(countMatches(cssContents, ';')).toEqual(13)
|
|
268
|
+
expect(countMatches(cssContents, '{')).toEqual(3)
|
|
269
|
+
expect(countMatches(cssContents, '}')).toEqual(3)
|
|
270
|
+
|
|
195
271
|
done()
|
|
196
272
|
})
|
|
197
273
|
}, 30000)
|
|
@@ -272,7 +348,7 @@ describe('build', () => {
|
|
|
272
348
|
// Minify the browser files (bundleMinify)
|
|
273
349
|
expect(fs.existsSync(`${browserPath}/${browserFile}.min.js`)).toBeTruthy()
|
|
274
350
|
const bundledContents = fs.readFileSync(bundledFile).toString()
|
|
275
|
-
expect(countMatches(bundledContents, 'main')).toEqual(
|
|
351
|
+
expect(countMatches(bundledContents, 'main')).toEqual(2)
|
|
276
352
|
|
|
277
353
|
// Generated README.md (compileReadme)
|
|
278
354
|
const readmeContents = fs.readFileSync(`${readmePath}/${readmeFile}`).toString()
|
|
@@ -68,7 +68,7 @@ describe('distFor', () => {
|
|
|
68
68
|
const srcPath = gulpConfig.get('srcPath')
|
|
69
69
|
const srcFile = `${srcPath}/distFor.js`
|
|
70
70
|
fs.writeFileSync(srcFile, rawContents)
|
|
71
|
-
expect.assertions(
|
|
71
|
+
expect.assertions(5)
|
|
72
72
|
const oldContents = fs.readFileSync(srcFile).toString()
|
|
73
73
|
expect(countMatches(oldContents, 'const ')).toEqual(7)
|
|
74
74
|
const distPath = gulpConfig.get('distPath')
|
|
@@ -77,11 +77,11 @@ describe('distFor', () => {
|
|
|
77
77
|
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
78
78
|
const babelifiedContents = fs.readFileSync(`${distPath}/distFor.js`).toString()
|
|
79
79
|
expect(countMatches(babelifiedContents, '"use strict"')).toEqual(1)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
/* There used to be a nice check here where `const` and `let` would be swapped to `var`, but that no longer
|
|
81
|
+
happens.
|
|
82
|
+
It would be nice if it still happened, but due to 'browserlist' supposedly, most browsers support
|
|
83
|
+
`const` and `let` now.
|
|
84
|
+
*/
|
|
85
85
|
expect(countMatches(babelifiedContents, 'function')).toEqual(1)
|
|
86
86
|
expect(countMatches(babelifiedContents, 'arguments')).toEqual(6)
|
|
87
87
|
done()
|
|
@@ -90,7 +90,7 @@ describe('distFor', () => {
|
|
|
90
90
|
console.error('Encountered error', error)
|
|
91
91
|
done()
|
|
92
92
|
})
|
|
93
|
-
},
|
|
93
|
+
}, 5000)
|
|
94
94
|
|
|
95
95
|
test('can process typescript before babel', done => {
|
|
96
96
|
const srcPath = gulpConfig.get('srcPath')
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { dest, src } = require('gulp')
|
|
2
|
+
const gulpConfig = require('../../gulp.config.js')
|
|
3
|
+
const cssnano = require('gulp-cssnano')
|
|
4
|
+
const rename = require('gulp-rename')
|
|
5
|
+
const sass = require('gulp-sass')(require('sass'))
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Build the CSS for a given source pattern.
|
|
9
|
+
* @function
|
|
10
|
+
* @memberOf module:partials
|
|
11
|
+
* @param {string|array} [srcSearch='src/config/path/sass/for']
|
|
12
|
+
* @param {string} [cssPath='css/config/path']
|
|
13
|
+
* @returns {stream.Stream}
|
|
14
|
+
*/
|
|
15
|
+
const sassFor = (srcSearch = gulpConfig.get('sassSearch'), cssPath = gulpConfig.get('cssPath')) => src(srcSearch)
|
|
16
|
+
.pipe(sass().on('error', sass.logError)) // Passes it through a gulp-sass, log errors to console
|
|
17
|
+
.pipe(dest(cssPath))
|
|
18
|
+
.pipe(cssnano())
|
|
19
|
+
.pipe(rename({ extname: '.min.css' }))
|
|
20
|
+
.pipe(dest(cssPath))
|
|
21
|
+
|
|
22
|
+
module.exports = sassFor
|