js-build-tools 1.2.3 → 2.1.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.
Files changed (140) hide show
  1. package/README.md +573 -250
  2. package/dist/build.js +22 -15
  3. package/dist/build.min.js +1 -1
  4. package/dist/bundle.js +11 -8
  5. package/dist/bundle.min.js +1 -1
  6. package/dist/bundleLint.js +17 -13
  7. package/dist/bundleLint.min.js +1 -1
  8. package/dist/bundleMinify.js +8 -12
  9. package/dist/bundleMinify.min.js +1 -1
  10. package/dist/compileReadme.js +8 -6
  11. package/dist/compileReadme.min.js +1 -1
  12. package/dist/default.js +12 -7
  13. package/dist/default.min.js +1 -1
  14. package/dist/dist.js +6 -2
  15. package/dist/dist.min.js +1 -1
  16. package/dist/distLint.js +15 -12
  17. package/dist/distLint.min.js +1 -1
  18. package/dist/distMinify.js +7 -12
  19. package/dist/distMinify.min.js +1 -1
  20. package/dist/partials/addToReadme.js +25 -0
  21. package/dist/partials/beginWatcher.js +16 -0
  22. package/dist/partials/clean.js +21 -0
  23. package/dist/partials/distFor.js +23 -0
  24. package/dist/partials/distForSrc.js +16 -0
  25. package/dist/partials/distSeries.js +31 -0
  26. package/dist/partials/minifyFor.js +21 -0
  27. package/dist/partials/readmeTemplate.js +18 -0
  28. package/dist/partials/runOnChange.js +63 -0
  29. package/dist/partials/tsFor.js +24 -0
  30. package/dist/partials.js +33 -0
  31. package/dist/partials.min.js +1 -0
  32. package/dist/test-helpers/circularObject.js +50 -0
  33. package/dist/test-helpers/countMatches.js +16 -0
  34. package/dist/test-helpers/deepReferenceObject.js +20 -0
  35. package/dist/test-helpers/domItem.js +33 -0
  36. package/dist/test-helpers/jsonDom.js +20 -0
  37. package/dist/test-helpers/linkedList.js +23 -0
  38. package/dist/test-helpers/logObject.js +24 -0
  39. package/dist/test-helpers/multiReferenceObject.js +20 -0
  40. package/dist/test-helpers/nodeTree.js +28 -0
  41. package/dist/test-helpers/setUp.js +127 -0
  42. package/dist/testFull.js +16 -5
  43. package/dist/testFull.min.js +1 -1
  44. package/dist/testHelpers.js +29 -194
  45. package/dist/testHelpers.min.js +1 -1
  46. package/dist/testQuick.js +18 -7
  47. package/dist/testQuick.min.js +1 -1
  48. package/dist/typeScript.js +14 -0
  49. package/dist/typeScript.min.js +1 -0
  50. package/dist/watchFull.js +9 -16
  51. package/dist/watchFull.min.js +1 -1
  52. package/dist/watchTest.js +11 -9
  53. package/dist/watchTest.min.js +1 -1
  54. package/functions/build.js +8 -5
  55. package/functions/build.test.js +59 -0
  56. package/functions/bundle.js +6 -4
  57. package/functions/bundle.test.js +68 -0
  58. package/functions/bundleLint.js +5 -3
  59. package/functions/bundleLint.test.js +61 -0
  60. package/functions/bundleMinify.js +4 -7
  61. package/functions/bundleMinify.test.js +14 -0
  62. package/functions/compileReadme.js +3 -2
  63. package/functions/compileReadme.test.js +18 -0
  64. package/functions/default.js +5 -2
  65. package/functions/default.test.js +32 -0
  66. package/functions/dist.js +3 -1
  67. package/functions/dist.test.js +43 -0
  68. package/functions/distLint.js +4 -2
  69. package/functions/distLint.test.js +58 -0
  70. package/functions/distMinify.js +4 -7
  71. package/functions/distMinify.test.js +14 -0
  72. package/functions/partials/addToReadme.js +20 -0
  73. package/functions/partials/addToReadme.test.js +28 -0
  74. package/functions/partials/beginWatcher.js +12 -0
  75. package/functions/partials/beginWatcher.test.js +18 -0
  76. package/functions/partials/clean.js +14 -0
  77. package/functions/partials/clean.test.js +20 -0
  78. package/functions/partials/distFor.js +18 -0
  79. package/functions/partials/distFor.test.js +125 -0
  80. package/functions/partials/distForSrc.js +14 -0
  81. package/functions/partials/distForSrc.test.js +17 -0
  82. package/functions/partials/distSeries.js +21 -0
  83. package/functions/partials/distSeries.test.js +33 -0
  84. package/functions/partials/minifyFor.js +16 -0
  85. package/functions/partials/minifyFor.test.js +48 -0
  86. package/functions/partials/readmeTemplate.js +15 -0
  87. package/functions/partials/readmeTemplate.test.js +33 -0
  88. package/functions/partials/runOnChange.js +57 -0
  89. package/functions/partials/runOnChange.test.js +93 -0
  90. package/functions/partials/tsFor.js +21 -0
  91. package/functions/partials/tsFor.test.js +44 -0
  92. package/functions/partials.js +32 -0
  93. package/functions/partials.test.js +7 -0
  94. package/functions/test-helpers/circularObject.js +28 -0
  95. package/functions/test-helpers/circularObject.test.js +14 -0
  96. package/functions/test-helpers/countMatches.js +11 -0
  97. package/functions/test-helpers/countMatches.test.js +9 -0
  98. package/functions/test-helpers/deepReferenceObject.js +25 -0
  99. package/functions/test-helpers/deepReferenceObject.test.js +7 -0
  100. package/functions/test-helpers/domItem.js +31 -0
  101. package/functions/test-helpers/domItem.test.js +12 -0
  102. package/functions/test-helpers/jsonDom.js +16 -0
  103. package/functions/test-helpers/jsonDom.test.js +12 -0
  104. package/functions/test-helpers/linkedList.js +10 -0
  105. package/functions/test-helpers/linkedList.test.js +22 -0
  106. package/functions/test-helpers/logObject.js +18 -0
  107. package/functions/test-helpers/logObject.test.js +20 -0
  108. package/functions/test-helpers/multiReferenceObject.js +25 -0
  109. package/functions/test-helpers/multiReferenceObject.test.js +14 -0
  110. package/functions/test-helpers/nodeTree.js +11 -0
  111. package/functions/test-helpers/nodeTree.test.js +18 -0
  112. package/functions/test-helpers/setUp.js +67 -0
  113. package/functions/test-helpers/setUp.test.js +18 -0
  114. package/functions/testFull.js +13 -3
  115. package/functions/testFull.test.js +16 -0
  116. package/functions/testHelpers.js +27 -137
  117. package/functions/testHelpers.test.js +3 -96
  118. package/functions/testQuick.js +12 -2
  119. package/functions/testQuick.test.js +16 -0
  120. package/functions/typeScript.js +11 -0
  121. package/functions/typeScript.test.js +10 -0
  122. package/functions/watchFull.js +6 -12
  123. package/functions/watchFull.test.js +40 -0
  124. package/functions/watchTest.js +4 -2
  125. package/functions/watchTest.test.js +48 -0
  126. package/gulp.config.js +161 -16
  127. package/gulpfile.base.js +9 -0
  128. package/package.json +1 -1
  129. package/dist/addToReadme.js +0 -22
  130. package/dist/addToReadme.min.js +0 -1
  131. package/dist/clean.js +0 -11
  132. package/dist/clean.min.js +0 -1
  133. package/dist/distFor.js +0 -21
  134. package/dist/distFor.min.js +0 -1
  135. package/dist/readmeTemplate.js +0 -15
  136. package/dist/readmeTemplate.min.js +0 -1
  137. package/functions/addToReadme.js +0 -17
  138. package/functions/clean.js +0 -10
  139. package/functions/distFor.js +0 -15
  140. package/functions/readmeTemplate.js +0 -13
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Multilayered node tree-like structure with parent references
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|Object|Array>}
7
+ */
8
+ var circularObject = {
9
+ name: 'root',
10
+ parent: {},
11
+ body: {},
12
+ head: {},
13
+ children: []
14
+ };
15
+ circularObject.children = [{
16
+ name: 'body',
17
+ parent: {},
18
+ children: []
19
+ }, {
20
+ name: 'head',
21
+ parent: {},
22
+ children: []
23
+ }];
24
+ circularObject.body = circularObject.children[0];
25
+ circularObject.head = circularObject.children[1];
26
+ circularObject.body.parent = circularObject;
27
+ circularObject.head.parent = circularObject;
28
+ circularObject.body.children = [{
29
+ name: 'body child one',
30
+ parent: {},
31
+ children: []
32
+ }, {
33
+ name: 'body child two',
34
+ parent: {},
35
+ children: []
36
+ }];
37
+ circularObject.body.children[0].parent = circularObject.body;
38
+ circularObject.body.children[1].parent = circularObject.body;
39
+ circularObject.head.children = [{
40
+ name: 'head child one',
41
+ parent: {},
42
+ children: []
43
+ }, {
44
+ name: 'head child two',
45
+ parent: {},
46
+ children: []
47
+ }];
48
+ circularObject.head.children[0].parent = circularObject.head;
49
+ circularObject.head.children[1].parent = circularObject.head;
50
+ module.exports = circularObject;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.regexp.exec.js");
4
+ require("core-js/modules/es.string.split.js");
5
+ /**
6
+ * Simple way to count string occurrences for testing.
7
+ * @function
8
+ * @memberOf module:testHelpers
9
+ * @param {string} content
10
+ * @param {string} search
11
+ * @returns {number}
12
+ */
13
+ var countMatches = function countMatches(content, search) {
14
+ return content.split(search).length - 1;
15
+ };
16
+ module.exports = countMatches;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample object with deep references.
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|number|Object>}
7
+ */
8
+ var deepReferenceObject = {
9
+ object1: {
10
+ name: 'someName',
11
+ object2: {
12
+ age: 12,
13
+ array1: ['someString', 'anotherString']
14
+ },
15
+ array2: [89, 32]
16
+ },
17
+ title: 'Some Title',
18
+ item: 45
19
+ };
20
+ module.exports = deepReferenceObject;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample of domItem child with nested child and optional details
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|number|Array|Object>}
7
+ */
8
+ var domItem = [{
9
+ attributes: {
10
+ className: 'row',
11
+ style: {}
12
+ },
13
+ axis: 'y',
14
+ children: [{
15
+ attributes: {
16
+ style: {}
17
+ },
18
+ axis: 'x',
19
+ children: [],
20
+ element: {},
21
+ eventListeners: {},
22
+ hasShip: false,
23
+ isHit: false,
24
+ parentItem: {},
25
+ point: {},
26
+ tagName: 'div'
27
+ }],
28
+ element: null,
29
+ eventListeners: {},
30
+ parentItem: {},
31
+ tagName: 'div'
32
+ }];
33
+ module.exports = domItem;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample of jsonDom object containing empty nested array and objects
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|number|Array|Object>}
7
+ */
8
+ var jsonDom = {
9
+ tagName: 'div',
10
+ attributes: {
11
+ style: {},
12
+ className: 'column'
13
+ },
14
+ element: null,
15
+ eventListeners: {},
16
+ parentItem: {},
17
+ children: [],
18
+ axis: 'x'
19
+ };
20
+ module.exports = jsonDom;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample LinkedList for testing circular references.
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|Object>}
7
+ */
8
+ var linkedList = {
9
+ name: 'one',
10
+ prev: null,
11
+ next: null
12
+ };
13
+ linkedList.next = {
14
+ name: 'two',
15
+ prev: linkedList,
16
+ next: null
17
+ };
18
+ linkedList.next.next = {
19
+ name: 'three',
20
+ prev: linkedList.next,
21
+ next: null
22
+ };
23
+ module.exports = linkedList;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.json.stringify.js");
4
+ /**
5
+ * Log out an object in a nicely formatted way.
6
+ * @function
7
+ * @memberOf module:testHelpers
8
+ * @param {Object} object
9
+ * @param {string} [label=logging]
10
+ * @param {string} [outputType=log]
11
+ * @returns {string|undefined}
12
+ */
13
+ var logObject = function logObject(object) {
14
+ var label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'logging';
15
+ var outputType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'log';
16
+ var logger = outputType === 'string' ? function (label, object) {
17
+ return "'".concat(label, "' | ") + JSON.stringify(object);
18
+ } : console[outputType];
19
+ if (typeof require === 'undefined' || outputType === 'string') {
20
+ return logger(label, object);
21
+ }
22
+ return logger(label, require('util').inspect(object, false, null, true));
23
+ };
24
+ module.exports = logObject;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample of object containing multiple references.
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|number|Object>}
7
+ */
8
+ var multiReferenceObject = {
9
+ object1: {
10
+ name: 'someName'
11
+ },
12
+ object2: {
13
+ age: 12
14
+ },
15
+ array1: ['someString', 'anotherString'],
16
+ array2: [89, 32],
17
+ title: 'Some Title',
18
+ item: 45
19
+ };
20
+ module.exports = multiReferenceObject;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample NodeTree for testing circular references and arrays.
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|Object|Array>}
7
+ */
8
+ var nodeTree = {
9
+ name: 'one',
10
+ parent: null,
11
+ children: []
12
+ };
13
+ nodeTree.children[0] = {
14
+ name: 'child one',
15
+ parent: nodeTree,
16
+ children: []
17
+ };
18
+ nodeTree.children[1] = {
19
+ name: 'child two',
20
+ parent: nodeTree,
21
+ children: []
22
+ };
23
+ nodeTree.children[0].children[0] = {
24
+ name: 'grandchild one',
25
+ parent: nodeTree.children[0],
26
+ children: []
27
+ };
28
+ module.exports = nodeTree;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ require("core-js/modules/es.object.define-property.js");
5
+ require("core-js/modules/es.symbol.js");
6
+ require("core-js/modules/es.symbol.description.js");
7
+ require("core-js/modules/es.symbol.iterator.js");
8
+ require("core-js/modules/es.array.iterator.js");
9
+ require("core-js/modules/es.string.iterator.js");
10
+ require("core-js/modules/web.dom-collections.iterator.js");
11
+ require("core-js/modules/es.symbol.async-iterator.js");
12
+ require("core-js/modules/es.symbol.to-string-tag.js");
13
+ require("core-js/modules/es.json.to-string-tag.js");
14
+ require("core-js/modules/es.math.to-string-tag.js");
15
+ require("core-js/modules/es.object.get-prototype-of.js");
16
+ require("core-js/modules/esnext.async-iterator.for-each.js");
17
+ require("core-js/modules/esnext.iterator.constructor.js");
18
+ require("core-js/modules/esnext.iterator.for-each.js");
19
+ require("core-js/modules/web.dom-collections.for-each.js");
20
+ require("core-js/modules/es.object.set-prototype-of.js");
21
+ require("core-js/modules/es.array.slice.js");
22
+ require("core-js/modules/es.object.to-string.js");
23
+ require("core-js/modules/es.promise.js");
24
+ 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; }
25
+ 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); } }
26
+ 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); }); }; }
27
+ var fs = require('fs');
28
+ var del = require('del');
29
+ // Import the configurations and override some of them in order to direct to the temp directory.
30
+ var gulpConfig = require('../../gulp.config.js');
31
+ var tempDir = 'test-temp/';
32
+ var srcPath = "".concat(tempDir, "src");
33
+
34
+ /**
35
+ * Update the gulp configurations with the test data. Set the test directory where temp files will be created for testing.
36
+ * @function
37
+ * @memberOf module:testHelpers
38
+ * @param {string} testDir
39
+ */
40
+ var setDefaults = function setDefaults() {
41
+ var testDir = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'test-temp';
42
+ tempDir = "".concat(testDir, "/");
43
+ srcPath = "".concat(tempDir, "src");
44
+ gulpConfig.set('browserPath', "".concat(tempDir, "browser"));
45
+ gulpConfig.set('distMain', "".concat(tempDir, "dist/main"));
46
+ gulpConfig.set('distPath', "".concat(tempDir, "dist"));
47
+ gulpConfig.set('distSearch', "".concat(tempDir, "dist/**/*.js"));
48
+ gulpConfig.set('readmeTemplate', "".concat(tempDir, "MAIN.md"));
49
+ gulpConfig.set('readmePath', tempDir);
50
+ gulpConfig.set('rootPath', tempDir);
51
+ gulpConfig.set('srcPath', srcPath);
52
+ gulpConfig.set('srcSearch', "".concat(tempDir, "src/**/!(*.test).js"));
53
+ gulpConfig.set('tsSearch', "".concat(tempDir, "src/**/*.ts"));
54
+ gulpConfig.set('watchSearch', "".concat(tempDir, "src/**/*.js"));
55
+ };
56
+ exports.setDefaults = setDefaults;
57
+ exports.gulpConfig = gulpConfig;
58
+
59
+ /**
60
+ * Ensure that the del has completed, recursively attempt to delete and recreate
61
+ * @function
62
+ * @memberOf module:testHelpers
63
+ * @param {boolean} [exists=true]
64
+ * @returns {Promise<*|void>}
65
+ */
66
+ var createTempDir = /*#__PURE__*/function () {
67
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
68
+ var exists,
69
+ _args = arguments;
70
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
71
+ while (1) switch (_context.prev = _context.next) {
72
+ case 0:
73
+ exists = _args.length > 0 && _args[0] !== undefined ? _args[0] : true;
74
+ if (!exists) {
75
+ _context.next = 3;
76
+ break;
77
+ }
78
+ return _context.abrupt("return", del(tempDir).then(function () {
79
+ return createTempDir(fs.existsSync(tempDir));
80
+ }));
81
+ case 3:
82
+ _context.next = 5;
83
+ return fs.mkdirSync(tempDir);
84
+ case 5:
85
+ return _context.abrupt("return", fs.mkdirSync(srcPath));
86
+ case 6:
87
+ case "end":
88
+ return _context.stop();
89
+ }
90
+ }, _callee);
91
+ }));
92
+ return function createTempDir() {
93
+ return _ref.apply(this, arguments);
94
+ };
95
+ }();
96
+ exports.createTempDir = createTempDir;
97
+
98
+ /**
99
+ * In the Jest.beforeEach function call this one to set up the temp directory.
100
+ * @function
101
+ * @memberOf module:testHelpers
102
+ * @returns {Promise<*|void>}
103
+ */
104
+ exports.beforeEach = function () {
105
+ return createTempDir();
106
+ };
107
+
108
+ /**
109
+ * In the Jest.afterEach function call this one to clean up and remove the temp directory.
110
+ * @function
111
+ * @memberOf module:testHelpers
112
+ * @returns {Promise<*>}
113
+ */
114
+ exports.afterEach = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
115
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
116
+ while (1) switch (_context2.prev = _context2.next) {
117
+ case 0:
118
+ _context2.next = 2;
119
+ return del(tempDir);
120
+ case 2:
121
+ return _context2.abrupt("return", _context2.sent);
122
+ case 3:
123
+ case "end":
124
+ return _context2.stop();
125
+ }
126
+ }, _callee2);
127
+ }));
package/dist/testFull.js CHANGED
@@ -1,13 +1,24 @@
1
1
  'use strict'
2
2
 
3
- const gulpConfig = require('../gulp.config.js')
4
- const {
5
- runCLI: jest
6
- } = require('jest')
3
+ var gulpConfig = require('../gulp.config.js')
4
+ var _require = require('jest')
5
+ var runCLI = _require.runCLI
7
6
 
8
7
  /**
9
8
  * Run all tests with jest.
9
+ * @function
10
+ * @memberOf module:js-build-tools
11
+ * @param {function} [done=null]
12
+ * @param {Array.<string>|string} [testPath='path/config/test/files']
10
13
  * @returns {Promise<*>}
11
14
  */
12
- const testFull = async () => await jest({}, gulpConfig.testPath)
15
+ var testFull = function testFull () {
16
+ var done = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null
17
+ var testPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gulpConfig.get('testPath')
18
+ if (!Array.isArray(testPath)) {
19
+ // The testPath must be an array of strings
20
+ testPath = [testPath]
21
+ }
22
+ return runCLI(gulpConfig.get('testOptions'), testPath)
23
+ }
13
24
  module.exports = testFull
@@ -1 +1 @@
1
- "use strict";const gulpConfig=require("../gulp.config.js"),{runCLI:jest}=require("jest"),testFull=async()=>await jest({},gulpConfig.testPath);module.exports=testFull;
1
+ "use strict";var gulpConfig=require("../gulp.config.js"),_require=require("jest"),runCLI=_require.runCLI,testFull=function(){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:gulpConfig.get("testPath");return Array.isArray(r)||(r=[r]),runCLI(gulpConfig.get("testOptions"),r)};module.exports=testFull;
@@ -1,198 +1,33 @@
1
1
  'use strict'
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.nodeTree = exports.multiReferenceObject = exports.logObject = exports.linkedList = exports.jsonDom = exports.domItem = exports.deepReferenceObject = exports.circularObject = void 0
7
3
  /**
8
- * Log out an object in a nicely formatted way.
9
- * @param {Object} object
10
- * @param {string} [label='logging']
11
- */
12
- const logObject = function (object) {
13
- const label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'logging'
14
- if (typeof require === 'undefined') {
15
- console.log(label, object)
16
- return
17
- }
18
- console.log(label, require('util').inspect(object, false, null, true))
19
- }
20
-
21
- /**
22
- * Multilayered node tree-like structure with parent references
23
- * @type {Object.<string, string|Object|Array>}
24
- */
25
- exports.logObject = logObject
26
- const circularObject = {
27
- name: 'root',
28
- parent: {},
29
- body: {},
30
- head: {},
31
- children: []
32
- }
33
- exports.circularObject = circularObject
34
- circularObject.children = [{
35
- name: 'body',
36
- parent: {},
37
- children: []
38
- }, {
39
- name: 'head',
40
- parent: {},
41
- children: []
42
- }]
43
- circularObject.body = circularObject.children[0]
44
- circularObject.head = circularObject.children[1]
45
- circularObject.body.parent = circularObject
46
- circularObject.head.parent = circularObject
47
- circularObject.body.children = [{
48
- name: 'body child one',
49
- parent: {},
50
- children: []
51
- }, {
52
- name: 'body child two',
53
- parent: {},
54
- children: []
55
- }]
56
- circularObject.body.children[0].parent = circularObject.body
57
- circularObject.body.children[1].parent = circularObject.body
58
- circularObject.head.children = [{
59
- name: 'head child one',
60
- parent: {},
61
- children: []
62
- }, {
63
- name: 'head child two',
64
- parent: {},
65
- children: []
66
- }]
67
- circularObject.head.children[0].parent = circularObject.head
68
- circularObject.head.children[1].parent = circularObject.head
69
-
70
- /**
71
- * Sample object with deep references.
72
- * @type {Object.<string, string|number|Object>}
73
- */
74
- const deepReferenceObject = {
75
- object1: {
76
- name: 'someName',
77
- object2: {
78
- age: 12,
79
- array1: ['someString', 'anotherString']
80
- },
81
- array2: [89, 32]
82
- },
83
- title: 'Some Title',
84
- item: 45
85
- }
86
-
87
- /**
88
- * Sample LinkedList for testing circular references.
89
- * @type {Object.<string, string|Object>}
90
- */
91
- exports.deepReferenceObject = deepReferenceObject
92
- const linkedList = {
93
- name: 'one',
94
- prev: null,
95
- next: null
96
- }
97
- exports.linkedList = linkedList
98
- linkedList.next = {
99
- name: 'two',
100
- prev: linkedList,
101
- next: null
102
- }
103
- linkedList.next.next = {
104
- name: 'three',
105
- prev: linkedList.next,
106
- next: null
107
- }
108
-
109
- /**
110
- * Sample of jsonDom object containing empty nested array and objects
111
- */
112
- const jsonDom = {
113
- tagName: 'div',
114
- attributes: {
115
- style: {},
116
- className: 'column'
117
- },
118
- element: null,
119
- eventListeners: {},
120
- parentItem: {},
121
- children: [],
122
- axis: 'x'
123
- }
124
-
125
- /**
126
- * Sample of domItem child with nested child and optional details
127
- */
128
- exports.jsonDom = jsonDom
129
- const domItem = [{
130
- attributes: {
131
- className: 'row',
132
- style: {}
133
- },
134
- axis: 'y',
135
- children: [{
136
- attributes: {
137
- style: {}
138
- },
139
- axis: 'x',
140
- children: [],
141
- element: {},
142
- eventListeners: {},
143
- hasShip: false,
144
- isHit: false,
145
- parentItem: {},
146
- point: {},
147
- tagName: 'div'
148
- }],
149
- element: null,
150
- eventListeners: {},
151
- parentItem: {},
152
- tagName: 'div'
153
- }]
154
-
155
- /**
156
- * Sample of object containing multiple references.
157
- * @type {Object.<string, string|number|Object>}
158
- */
159
- exports.domItem = domItem
160
- const multiReferenceObject = {
161
- object1: {
162
- name: 'someName'
163
- },
164
- object2: {
165
- age: 12
166
- },
167
- array1: ['someString', 'anotherString'],
168
- array2: [89, 32],
169
- title: 'Some Title',
170
- item: 45
171
- }
172
-
173
- /**
174
- * Sample NodeTree for testing circular references and arrays.
175
- * @type {Object.<string, string|Object|Array>}
176
- */
177
- exports.multiReferenceObject = multiReferenceObject
178
- const nodeTree = {
179
- name: 'one',
180
- parent: null,
181
- children: []
182
- }
183
- exports.nodeTree = nodeTree
184
- nodeTree.children[0] = {
185
- name: 'child one',
186
- parent: nodeTree,
187
- children: []
188
- }
189
- nodeTree.children[1] = {
190
- name: 'child two',
191
- parent: nodeTree,
192
- children: []
193
- }
194
- nodeTree.children[0].children[0] = {
195
- name: 'grandchild one',
196
- parent: nodeTree.children[0],
197
- children: []
4
+ * An assortment of objects that can be used in tests and some functions to help debug and write tests.
5
+ * @file
6
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
7
+ * @version 2.0.0
8
+ * @module testHelpers
9
+ * @memberOf module:js-build-tools
10
+ */
11
+
12
+ var circularObject = require('./test-helpers/circularObject')
13
+ var countMatches = require('./test-helpers/countMatches')
14
+ var deepReferenceObject = require('./test-helpers/deepReferenceObject')
15
+ var domItem = require('./test-helpers/domItem')
16
+ var jsonDom = require('./test-helpers/jsonDom')
17
+ var linkedList = require('./test-helpers/linkedList')
18
+ var logObject = require('./test-helpers/logObject')
19
+ var multiReferenceObject = require('./test-helpers/multiReferenceObject')
20
+ var nodeTree = require('./test-helpers/nodeTree')
21
+ var setUp = require('./test-helpers/setUp')
22
+ module.exports = {
23
+ circularObject: circularObject,
24
+ countMatches: countMatches,
25
+ deepReferenceObject: deepReferenceObject,
26
+ domItem: domItem,
27
+ jsonDom: jsonDom,
28
+ linkedList: linkedList,
29
+ logObject: logObject,
30
+ multiReferenceObject: multiReferenceObject,
31
+ nodeTree: nodeTree,
32
+ setUp: setUp
198
33
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.nodeTree=exports.multiReferenceObject=exports.logObject=exports.linkedList=exports.jsonDom=exports.domItem=exports.deepReferenceObject=exports.circularObject=void 0;const logObject=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"logging";"undefined"!=typeof require?console.log(t,require("util").inspect(e,!1,null,!0)):console.log(t,e)};exports.logObject=logObject;const circularObject={name:"root",parent:{},body:{},head:{},children:[]};exports.circularObject=circularObject,circularObject.children=[{name:"body",parent:{},children:[]},{name:"head",parent:{},children:[]}],circularObject.body=circularObject.children[0],circularObject.head=circularObject.children[1],circularObject.body.parent=circularObject,circularObject.head.parent=circularObject,circularObject.body.children=[{name:"body child one",parent:{},children:[]},{name:"body child two",parent:{},children:[]}],circularObject.body.children[0].parent=circularObject.body,circularObject.body.children[1].parent=circularObject.body,circularObject.head.children=[{name:"head child one",parent:{},children:[]},{name:"head child two",parent:{},children:[]}],circularObject.head.children[0].parent=circularObject.head,circularObject.head.children[1].parent=circularObject.head;const deepReferenceObject={object1:{name:"someName",object2:{age:12,array1:["someString","anotherString"]},array2:[89,32]},title:"Some Title",item:45};exports.deepReferenceObject=deepReferenceObject;const linkedList={name:"one",prev:null,next:null};exports.linkedList=linkedList,linkedList.next={name:"two",prev:linkedList,next:null},linkedList.next.next={name:"three",prev:linkedList.next,next:null};const jsonDom={tagName:"div",attributes:{style:{},className:"column"},element:null,eventListeners:{},parentItem:{},children:[],axis:"x"};exports.jsonDom=jsonDom;const domItem=[{attributes:{className:"row",style:{}},axis:"y",children:[{attributes:{style:{}},axis:"x",children:[],element:{},eventListeners:{},hasShip:!1,isHit:!1,parentItem:{},point:{},tagName:"div"}],element:null,eventListeners:{},parentItem:{},tagName:"div"}];exports.domItem=domItem;const multiReferenceObject={object1:{name:"someName"},object2:{age:12},array1:["someString","anotherString"],array2:[89,32],title:"Some Title",item:45};exports.multiReferenceObject=multiReferenceObject;const nodeTree={name:"one",parent:null,children:[]};exports.nodeTree=nodeTree,nodeTree.children[0]={name:"child one",parent:nodeTree,children:[]},nodeTree.children[1]={name:"child two",parent:nodeTree,children:[]},nodeTree.children[0].children[0]={name:"grandchild one",parent:nodeTree.children[0],children:[]};
1
+ "use strict";var 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};