js-build-tools 1.2.2 → 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 +590 -267
  2. package/dist/build.js +30 -23
  3. package/dist/build.min.js +1 -1
  4. package/dist/bundle.js +18 -15
  5. package/dist/bundle.min.js +1 -1
  6. package/dist/bundleLint.js +24 -20
  7. package/dist/bundleLint.min.js +1 -1
  8. package/dist/bundleMinify.js +16 -20
  9. package/dist/bundleMinify.min.js +1 -1
  10. package/dist/compileReadme.js +15 -13
  11. package/dist/compileReadme.min.js +1 -1
  12. package/dist/default.js +19 -14
  13. package/dist/default.min.js +1 -1
  14. package/dist/dist.js +14 -10
  15. package/dist/dist.min.js +1 -1
  16. package/dist/distLint.js +23 -20
  17. package/dist/distLint.min.js +1 -1
  18. package/dist/distMinify.js +15 -20
  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 +24 -13
  43. package/dist/testFull.min.js +1 -1
  44. package/dist/testHelpers.js +33 -198
  45. package/dist/testHelpers.min.js +1 -1
  46. package/dist/testQuick.js +26 -15
  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 +14 -21
  51. package/dist/watchFull.min.js +1 -1
  52. package/dist/watchTest.js +16 -14
  53. package/dist/watchTest.min.js +1 -1
  54. package/functions/build.js +28 -25
  55. package/functions/build.test.js +59 -0
  56. package/functions/bundle.js +17 -15
  57. package/functions/bundle.test.js +68 -0
  58. package/functions/bundleLint.js +19 -17
  59. package/functions/bundleLint.test.js +61 -0
  60. package/functions/bundleMinify.js +12 -15
  61. package/functions/bundleMinify.test.js +14 -0
  62. package/functions/compileReadme.js +11 -10
  63. package/functions/compileReadme.test.js +18 -0
  64. package/functions/default.js +14 -11
  65. package/functions/default.test.js +32 -0
  66. package/functions/dist.js +11 -9
  67. package/functions/dist.test.js +43 -0
  68. package/functions/distLint.js +19 -17
  69. package/functions/distLint.test.js +58 -0
  70. package/functions/distMinify.js +12 -15
  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 +20 -10
  115. package/functions/testFull.test.js +16 -0
  116. package/functions/testHelpers.js +27 -137
  117. package/functions/testHelpers.test.js +7 -100
  118. package/functions/testQuick.js +20 -10
  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 +11 -11
  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
@@ -1,198 +1,33 @@
1
- 'use strict'
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
- /**
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: []
198
- }
1
+ 'use strict'
2
+
3
+ /**
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
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};
package/dist/testQuick.js CHANGED
@@ -1,15 +1,26 @@
1
- 'use strict'
2
-
3
- const gulpConfig = require('../gulp.config.js')
4
- const {
5
- runCLI: jest
6
- } = require('jest')
7
-
8
- /**
9
- * Run the Jest tests for files which have been modified (based on git status).
10
- * @returns {Promise<*>}
11
- */
12
- const testQuick = async () => await jest({
13
- onlyChanged: true
14
- }, gulpConfig.testPath)
15
- module.exports = testQuick
1
+ 'use strict'
2
+
3
+ var gulpConfig = require('../gulp.config.js')
4
+ var _require = require('jest')
5
+ var runCLI = _require.runCLI
6
+
7
+ /**
8
+ * Run the Jest tests for files which have been modified (based on git status).
9
+ * @function
10
+ * @memberOf module:js-build-tools
11
+ * @param {function} [done=null]
12
+ * @param {Array.<string>|string} [testPath='path/config/test/files']
13
+ * @returns {Promise<*>}
14
+ */
15
+ var testQuick = function testQuick () {
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({
23
+ onlyChanged: true
24
+ }, testPath)
25
+ }
26
+ module.exports = testQuick
@@ -1 +1 @@
1
- "use strict";const gulpConfig=require("../gulp.config.js"),{runCLI:jest}=require("jest"),testQuick=async()=>await jest({onlyChanged:!0},gulpConfig.testPath);module.exports=testQuick;
1
+ "use strict";var gulpConfig=require("../gulp.config.js"),_require=require("jest"),runCLI=_require.runCLI,testQuick=function(){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:gulpConfig.get("testPath");return Array.isArray(r)||(r=[r]),runCLI({onlyChanged:!0},r)};module.exports=testQuick;
@@ -0,0 +1,14 @@
1
+ 'use strict'
2
+
3
+ var tsFor = require('./partials/tsFor')
4
+
5
+ /**
6
+ * Simplified typescript task using tsFor.
7
+ * @function
8
+ * @memberOf module:js-build-tools
9
+ * @returns {stream.Stream}
10
+ */
11
+ var typeScript = function typeScript () {
12
+ return tsFor()
13
+ }
14
+ module.exports = typeScript
@@ -0,0 +1 @@
1
+ "use strict";var tsFor=require("./partials/tsFor"),typeScript=function(){return tsFor()};module.exports=typeScript;
package/dist/watchFull.js CHANGED
@@ -1,23 +1,16 @@
1
- 'use strict'
2
-
3
- require('core-js/modules/es.string.replace.js')
4
- const bundle = require('./bundle')
5
- const distFor = require('./distFor')
6
- const gulpConfig = require('../gulp.config.js')
7
- const {
8
- parallel,
9
- series,
10
- watch
11
- } = require('gulp')
12
- const testQuick = require('./testQuick')
13
-
1
+ 'use strict'
2
+
3
+ var _require = require('./partials')
4
+ var beginWatcher = _require.beginWatcher
5
+ var runOnChange = _require.runOnChange
6
+
14
7
  /**
15
8
  * Watch for changes and run the distribution for the changed files, then bundle and test the changed files.
16
- * @returns {*}
17
- */
18
- const watchFull = () => watch(gulpConfig.watchSearch).on('change', path => {
19
- const pathRegex = new RegExp('^'.concat(gulpConfig.srcPath, '(.*\\/).+\\.js$'), 'i')
20
- const distForPath = () => distFor(path, path.replace(pathRegex, ''.concat(gulpConfig.distPath, '$1')))
21
- return parallel(testQuick, series(distForPath, bundle))()
22
- })
23
- module.exports = watchFull
9
+ * @function
10
+ * @memberOf module:js-build-tools
11
+ * @returns {FSWatcher}
12
+ */
13
+ var watchFull = function watchFull () {
14
+ return beginWatcher().on('change', runOnChange)
15
+ }
16
+ module.exports = watchFull
@@ -1 +1 @@
1
- "use strict";require("core-js/modules/es.string.replace.js");const bundle=require("./bundle"),distFor=require("./distFor"),gulpConfig=require("../gulp.config.js"),{parallel:parallel,series:series,watch:watch}=require("gulp"),testQuick=require("./testQuick"),watchFull=()=>watch(gulpConfig.watchSearch).on("change",(e=>{const r=new RegExp("^".concat(gulpConfig.srcPath,"(.*\\/).+\\.js$"),"i");return parallel(testQuick,series((()=>distFor(e,e.replace(r,"".concat(gulpConfig.distPath,"$1")))),bundle))()}));module.exports=watchFull;
1
+ "use strict";var _require=require("./partials"),beginWatcher=_require.beginWatcher,runOnChange=_require.runOnChange,watchFull=function(){return beginWatcher().on("change",runOnChange)};module.exports=watchFull;
package/dist/watchTest.js CHANGED
@@ -1,17 +1,19 @@
1
- 'use strict'
2
-
3
- const gulpConfig = require('../gulp.config.js')
4
- const {
5
- series,
6
- watch
7
- } = require('gulp')
8
- const testQuick = require('./testQuick')
9
-
1
+ 'use strict'
2
+
3
+ var gulpConfig = require('../gulp.config.js')
4
+ var _require = require('gulp')
5
+ var watch = _require.watch
6
+ var testQuick = require('./testQuick')
7
+
10
8
  /**
11
9
  * Watch for changes and run the tests.
10
+ * @function
11
+ * @memberOf module:js-build-tools
12
12
  * @returns {*}
13
- */
14
- const watchTest = () => watch(gulpConfig.watchSearch, {
15
- ignoreInitial: false
16
- }, series(testQuick))
17
- module.exports = watchTest
13
+ */
14
+ var watchTest = function watchTest () {
15
+ return watch(gulpConfig.get('watchSearch'), {
16
+ ignoreInitial: false
17
+ }, testQuick)
18
+ }
19
+ module.exports = watchTest
@@ -1 +1 @@
1
- "use strict";const gulpConfig=require("../gulp.config.js"),{series:series,watch:watch}=require("gulp"),testQuick=require("./testQuick"),watchTest=()=>watch(gulpConfig.watchSearch,{ignoreInitial:!1},series(testQuick));module.exports=watchTest;
1
+ "use strict";var gulpConfig=require("../gulp.config.js"),_require=require("gulp"),watch=_require.watch,testQuick=require("./testQuick"),watchTest=function(){return watch(gulpConfig.get("watchSearch"),{ignoreInitial:!1},testQuick)};module.exports=watchTest;
@@ -1,25 +1,28 @@
1
- const bundle = require('./bundle')
2
- const bundleLint = require('./bundleLint')
3
- const bundleMinify = require('./bundleMinify')
4
- const clean = require('./clean')
5
- const compileReadme = require('./compileReadme')
6
- const dist = require('./dist')
7
- const distLint = require('./distLint')
8
- const distMinify = require('./distMinify')
9
- const { parallel, series } = require('gulp')
10
- const gulpConfig = require('../gulp.config.js')
11
- const testFull = require('./testFull')
12
-
13
- /**
14
- * Runs several processes to build and validate the project.
15
- * Cleans, distributes (lint and minify), bundles (lint and minify), creates the readme, then runs the tests.
16
- */
17
- const build = parallel(
18
- gulpConfig.nodeOnly
19
- ? series(clean, dist, parallel(distLint, distMinify))
20
- : series(clean, dist, parallel(distLint, distMinify), bundle, parallel(bundleLint, bundleMinify)),
21
- compileReadme,
22
- testFull
23
- )
24
-
25
- module.exports = build
1
+ const bundle = require('./bundle')
2
+ const bundleLint = require('./bundleLint')
3
+ const bundleMinify = require('./bundleMinify')
4
+ const { clean, distSeries } = require('./partials')
5
+ const compileReadme = require('./compileReadme')
6
+ const dist = require('./dist')
7
+ const distLint = require('./distLint')
8
+ const distMinify = require('./distMinify')
9
+ const { parallel, series } = require('gulp')
10
+ const gulpConfig = require('../gulp.config.js')
11
+ const testFull = require('./testFull')
12
+
13
+ /**
14
+ * Runs several processes to build and validate the project.
15
+ * Cleans, distributes (lint and minify), bundles (lint and minify), creates the readme, then runs the tests.
16
+ * @memberOf module:js-build-tools
17
+ * @param {function} [done=null]
18
+ * @returns {stream.Stream}
19
+ */
20
+ const build = (done = null) => parallel(
21
+ gulpConfig.get('nodeOnly')
22
+ ? series(clean, dist, parallel(distLint, distMinify))
23
+ : series(clean, distSeries, parallel(distLint, distMinify), bundle, parallel(bundleLint, bundleMinify)),
24
+ compileReadme,
25
+ testFull
26
+ )(done)
27
+
28
+ module.exports = build
@@ -0,0 +1,59 @@
1
+ const { setUp } = require('./testHelpers')
2
+ const gulpConfig = setUp.gulpConfig
3
+ const build = require('./build')
4
+ const bundle = require('./bundle')
5
+ const bundleLint = require('./bundleLint')
6
+ const bundleMinify = require('./bundleMinify')
7
+ const { clean, distSeries } = require('./partials')
8
+ const compileReadme = require('./compileReadme')
9
+ const dist = require('./dist')
10
+ const distLint = require('./distLint')
11
+ const distMinify = require('./distMinify')
12
+ const testFull = require('./testFull')
13
+
14
+ const genericFunction = () => Promise.resolve(true)
15
+ jest.mock('./bundle', () => jest.fn(genericFunction))
16
+ jest.mock('./bundleLint', () => jest.fn(genericFunction))
17
+ jest.mock('./bundleMinify', () => jest.fn(genericFunction))
18
+ jest.mock('./partials/clean', () => jest.fn(genericFunction))
19
+ jest.mock('./compileReadme', () => jest.fn(genericFunction))
20
+ jest.mock('./dist', () => jest.fn(genericFunction))
21
+ jest.mock('./distLint', () => jest.fn(genericFunction))
22
+ jest.mock('./distMinify', () => jest.fn(genericFunction))
23
+ jest.mock('./partials/distSeries', () => jest.fn(genericFunction))
24
+ jest.mock('./testFull', () => jest.fn(genericFunction))
25
+
26
+ describe('build', () => {
27
+ test('when nodeOnly true: calls clean, dist, distLint, distMinify, compileReadme, testFull', done => {
28
+ gulpConfig.set('nodeOnly', true)
29
+ expect.assertions(6)
30
+ build()
31
+ setTimeout(() => {
32
+ expect(clean).toHaveBeenCalled()
33
+ expect(dist).toHaveBeenCalled()
34
+ expect(distLint).toHaveBeenCalled()
35
+ expect(distMinify).toHaveBeenCalled()
36
+ expect(compileReadme).toHaveBeenCalled()
37
+ expect(testFull).toHaveBeenCalled()
38
+ done()
39
+ }, 500)
40
+ })
41
+
42
+ test('when nodeOnly false: calls clean, distSeries, distLint, distMinify, bundle, bundleLint, bundleMinify, compileReadme, testFull', done => {
43
+ gulpConfig.set('nodeOnly', false)
44
+ expect.assertions(9)
45
+ build()
46
+ setTimeout(() => {
47
+ expect(clean).toHaveBeenCalled()
48
+ expect(distSeries).toHaveBeenCalled()
49
+ expect(distLint).toHaveBeenCalled()
50
+ expect(distMinify).toHaveBeenCalled()
51
+ expect(bundle).toHaveBeenCalled()
52
+ expect(bundleLint).toHaveBeenCalled()
53
+ expect(bundleMinify).toHaveBeenCalled()
54
+ expect(compileReadme).toHaveBeenCalled()
55
+ expect(testFull).toHaveBeenCalled()
56
+ done()
57
+ }, 500)
58
+ })
59
+ })
@@ -1,15 +1,17 @@
1
- const browserify = require('browserify')
2
- const { dest } = require('gulp')
3
- const gulpConfig = require('../gulp.config.js')
4
- const source = require('vinyl-source-stream')
5
-
6
- /**
7
- * Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.
8
- * @returns {*}
9
- */
10
- const bundle = () => browserify(gulpConfig.distMain)
11
- .bundle()
12
- .pipe(source(`${gulpConfig.browserName}.js`))
13
- .pipe(dest(gulpConfig.browserPath))
14
-
15
- module.exports = bundle
1
+ const browserify = require('browserify')
2
+ const { dest } = require('gulp')
3
+ const gulpConfig = require('../gulp.config.js')
4
+ const source = require('vinyl-source-stream')
5
+
6
+ /**
7
+ * Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.
8
+ * @function
9
+ * @memberOf module:js-build-tools
10
+ * @returns {stream.Stream}
11
+ */
12
+ const bundle = () => browserify(gulpConfig.get('distMain'))
13
+ .bundle()
14
+ .pipe(source(`${gulpConfig.get('browserName')}.js`))
15
+ .pipe(dest(gulpConfig.get('browserPath')))
16
+
17
+ module.exports = bundle
@@ -0,0 +1,68 @@
1
+ const fs = require('fs')
2
+ const setUp = require('./test-helpers/setUp')
3
+ setUp.setDefaults('test-bundle')
4
+ const gulpConfig = setUp.gulpConfig
5
+ const bundle = require('./bundle')
6
+ const { countMatches } = require('./testHelpers')
7
+
8
+ const file1Contents = 'function file1 () {\n' +
9
+ ' console.log(\'Hello from file1\')\n' +
10
+ '}\n' +
11
+ '\n' +
12
+ 'module.exports = file1\n'
13
+ const file2Contents = 'function file2 () {\n' +
14
+ ' console.log(\'Good-bye from file2\')\n' +
15
+ '}\n' +
16
+ '\n' +
17
+ 'module.exports = file2\n'
18
+ const mainFileContents = 'const file1 = require(\'./sources/file1\')\n' +
19
+ 'const file2 = require(\'./sources/file2\')\n' +
20
+ '\n' +
21
+ 'module.exports = {\n' +
22
+ ' file1,\n' +
23
+ ' file2,\n' +
24
+ '}\n'
25
+
26
+ beforeEach(
27
+ () => setUp.beforeEach()
28
+ .then(
29
+ async () => {
30
+ const distPath = gulpConfig.get('distPath')
31
+ const mainFile = gulpConfig.get('distMain')
32
+ const sourcesPath = `${distPath}/sources`
33
+ await fs.mkdirSync(distPath)
34
+ await fs.mkdirSync(sourcesPath)
35
+ await fs.writeFileSync(`${sourcesPath}/file1.js`, file1Contents)
36
+ await fs.writeFileSync(`${sourcesPath}/file2.js`, file2Contents)
37
+ return fs.writeFileSync(`${mainFile}.js`, mainFileContents)
38
+ }
39
+ )
40
+ )
41
+
42
+ afterEach(setUp.afterEach)
43
+
44
+ describe('bundle', () => {
45
+ test('copies all the dist contents into a single file for browsers', done => {
46
+ const distPath = gulpConfig.get('distPath')
47
+ const destFile = `${gulpConfig.get('browserName')}.js`
48
+ const destPath = gulpConfig.get('browserPath')
49
+ const bundledFile = `${destPath}/${destFile}`
50
+ const sourcesPath = `${distPath}/sources`
51
+ const file1Path = `${sourcesPath}/file1.js`
52
+ const file2Path = `${sourcesPath}/file2.js`
53
+ const oldFile1Contents = fs.readFileSync(file1Path).toString()
54
+ const oldFile2Contents = fs.readFileSync(file2Path).toString()
55
+ expect.assertions(2)
56
+ bundle()
57
+ .on('finish', () => {
58
+ const bundledContents = fs.readFileSync(bundledFile).toString()
59
+ expect(countMatches(bundledContents, oldFile1Contents)).toEqual(1)
60
+ expect(countMatches(bundledContents, oldFile2Contents)).toEqual(1)
61
+ done()
62
+ })
63
+ .on('error', error => {
64
+ console.error('Encountered error', error)
65
+ done()
66
+ })
67
+ }, 500)
68
+ })
@@ -1,17 +1,19 @@
1
- const { dest, src } = require('gulp')
2
- const gulpConfig = require('../gulp.config.js')
3
- const standard = require('gulp-standard')
4
-
5
- /**
6
- * Applies Standard code style linting to bundled file.
7
- * @returns {*}
8
- */
9
- const bundleLint = () => src(`${gulpConfig.browserPath}/${gulpConfig.browserName}.js`)
10
- .pipe(standard({ fix: true }))
11
- .pipe(standard.reporter('default', {
12
- fix: true,
13
- quiet: true
14
- }))
15
- .pipe(dest(gulpConfig.browserPath))
16
-
17
- module.exports = bundleLint
1
+ const { dest, src } = require('gulp')
2
+ const gulpConfig = require('../gulp.config.js')
3
+ const standard = require('gulp-standard')
4
+
5
+ /**
6
+ * Applies Standard code style linting to bundled file.
7
+ * @function
8
+ * @memberOf module:js-build-tools
9
+ * @returns {stream.Stream}
10
+ */
11
+ const bundleLint = () => src(`${gulpConfig.get('browserPath')}/${gulpConfig.get('browserName')}.js`)
12
+ .pipe(standard({ fix: true }))
13
+ .pipe(standard.reporter('default', {
14
+ fix: true,
15
+ quiet: true
16
+ }))
17
+ .pipe(dest(gulpConfig.get('browserPath')))
18
+
19
+ module.exports = bundleLint