js-build-tools 1.2.3 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +573 -250
- package/dist/build.js +27 -20
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +16 -13
- package/dist/bundle.min.js +1 -1
- package/dist/bundleLint.js +22 -18
- package/dist/bundleLint.min.js +1 -1
- package/dist/bundleMinify.js +13 -17
- package/dist/bundleMinify.min.js +1 -1
- package/dist/compileReadme.js +13 -11
- package/dist/compileReadme.min.js +1 -1
- package/dist/default.js +17 -12
- package/dist/default.min.js +1 -1
- package/dist/dist.js +11 -7
- package/dist/dist.min.js +1 -1
- package/dist/distLint.js +20 -17
- package/dist/distLint.min.js +1 -1
- package/dist/distMinify.js +12 -17
- package/dist/distMinify.min.js +1 -1
- package/dist/partials/addToReadme.js +25 -0
- package/dist/partials/beginWatcher.js +16 -0
- package/dist/partials/clean.js +21 -0
- package/dist/partials/distFor.js +23 -0
- package/dist/partials/distForSrc.js +16 -0
- package/dist/partials/distSeries.js +31 -0
- package/dist/partials/minifyFor.js +21 -0
- package/dist/partials/readmeTemplate.js +18 -0
- package/dist/partials/runOnChange.js +63 -0
- package/dist/partials/tsFor.js +24 -0
- package/dist/partials.js +33 -0
- package/dist/partials.min.js +1 -0
- package/dist/test-helpers/circularObject.js +50 -0
- package/dist/test-helpers/countMatches.js +16 -0
- package/dist/test-helpers/deepReferenceObject.js +20 -0
- package/dist/test-helpers/domItem.js +33 -0
- package/dist/test-helpers/jsonDom.js +20 -0
- package/dist/test-helpers/linkedList.js +23 -0
- package/dist/test-helpers/logObject.js +24 -0
- package/dist/test-helpers/multiReferenceObject.js +20 -0
- package/dist/test-helpers/nodeTree.js +28 -0
- package/dist/test-helpers/setUp.js +127 -0
- package/dist/testFull.js +21 -10
- package/dist/testFull.min.js +1 -1
- package/dist/testHelpers.js +33 -198
- package/dist/testHelpers.min.js +1 -1
- package/dist/testQuick.js +23 -12
- package/dist/testQuick.min.js +1 -1
- package/dist/typeScript.js +14 -0
- package/dist/typeScript.min.js +1 -0
- package/dist/watchFull.js +14 -21
- package/dist/watchFull.min.js +1 -1
- package/dist/watchTest.js +16 -14
- package/dist/watchTest.min.js +1 -1
- package/functions/build.js +8 -5
- package/functions/build.test.js +59 -0
- package/functions/bundle.js +6 -4
- package/functions/bundle.test.js +68 -0
- package/functions/bundleLint.js +5 -3
- package/functions/bundleLint.test.js +61 -0
- package/functions/bundleMinify.js +4 -7
- package/functions/bundleMinify.test.js +14 -0
- package/functions/compileReadme.js +3 -2
- package/functions/compileReadme.test.js +18 -0
- package/functions/default.js +5 -2
- package/functions/default.test.js +32 -0
- package/functions/dist.js +3 -1
- package/functions/dist.test.js +43 -0
- package/functions/distLint.js +4 -2
- package/functions/distLint.test.js +58 -0
- package/functions/distMinify.js +4 -7
- package/functions/distMinify.test.js +14 -0
- package/functions/partials/addToReadme.js +20 -0
- package/functions/partials/addToReadme.test.js +28 -0
- package/functions/partials/beginWatcher.js +12 -0
- package/functions/partials/beginWatcher.test.js +18 -0
- package/functions/partials/clean.js +14 -0
- package/functions/partials/clean.test.js +20 -0
- package/functions/partials/distFor.js +18 -0
- package/functions/partials/distFor.test.js +125 -0
- package/functions/partials/distForSrc.js +14 -0
- package/functions/partials/distForSrc.test.js +17 -0
- package/functions/partials/distSeries.js +21 -0
- package/functions/partials/distSeries.test.js +33 -0
- package/functions/partials/minifyFor.js +16 -0
- package/functions/partials/minifyFor.test.js +48 -0
- package/functions/partials/readmeTemplate.js +15 -0
- package/functions/partials/readmeTemplate.test.js +33 -0
- package/functions/partials/runOnChange.js +57 -0
- package/functions/partials/runOnChange.test.js +93 -0
- package/functions/partials/tsFor.js +21 -0
- package/functions/partials/tsFor.test.js +44 -0
- package/functions/partials.js +32 -0
- package/functions/partials.test.js +7 -0
- package/functions/test-helpers/circularObject.js +28 -0
- package/functions/test-helpers/circularObject.test.js +14 -0
- package/functions/test-helpers/countMatches.js +11 -0
- package/functions/test-helpers/countMatches.test.js +9 -0
- package/functions/test-helpers/deepReferenceObject.js +25 -0
- package/functions/test-helpers/deepReferenceObject.test.js +7 -0
- package/functions/test-helpers/domItem.js +31 -0
- package/functions/test-helpers/domItem.test.js +12 -0
- package/functions/test-helpers/jsonDom.js +16 -0
- package/functions/test-helpers/jsonDom.test.js +12 -0
- package/functions/test-helpers/linkedList.js +10 -0
- package/functions/test-helpers/linkedList.test.js +22 -0
- package/functions/test-helpers/logObject.js +18 -0
- package/functions/test-helpers/logObject.test.js +20 -0
- package/functions/test-helpers/multiReferenceObject.js +25 -0
- package/functions/test-helpers/multiReferenceObject.test.js +14 -0
- package/functions/test-helpers/nodeTree.js +11 -0
- package/functions/test-helpers/nodeTree.test.js +18 -0
- package/functions/test-helpers/setUp.js +67 -0
- package/functions/test-helpers/setUp.test.js +18 -0
- package/functions/testFull.js +13 -3
- package/functions/testFull.test.js +16 -0
- package/functions/testHelpers.js +27 -137
- package/functions/testHelpers.test.js +3 -96
- package/functions/testQuick.js +12 -2
- package/functions/testQuick.test.js +16 -0
- package/functions/typeScript.js +11 -0
- package/functions/typeScript.test.js +10 -0
- package/functions/watchFull.js +6 -12
- package/functions/watchFull.test.js +40 -0
- package/functions/watchTest.js +4 -2
- package/functions/watchTest.test.js +48 -0
- package/gulp.config.js +161 -16
- package/gulpfile.base.js +9 -0
- package/package.json +2 -1
- package/dist/addToReadme.js +0 -22
- package/dist/addToReadme.min.js +0 -1
- package/dist/clean.js +0 -11
- package/dist/clean.min.js +0 -1
- package/dist/distFor.js +0 -21
- package/dist/distFor.min.js +0 -1
- package/dist/readmeTemplate.js +0 -15
- package/dist/readmeTemplate.min.js +0 -1
- package/functions/addToReadme.js +0 -17
- package/functions/clean.js +0 -10
- package/functions/distFor.js +0 -15
- package/functions/readmeTemplate.js +0 -13
package/dist/testHelpers.js
CHANGED
|
@@ -1,198 +1,33 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
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
|
+
}
|
package/dist/testHelpers.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
var gulpConfig = require('../gulp.config.js')
|
|
4
|
+
var _require = require('jest')
|
|
5
|
+
var runCLI = _require.runCLI
|
|
6
|
+
|
|
8
7
|
/**
|
|
9
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']
|
|
10
13
|
* @returns {Promise<*>}
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
package/dist/testQuick.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
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('
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
* @
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return
|
|
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
|
package/dist/watchFull.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
*/
|
|
14
|
+
var watchTest = function watchTest () {
|
|
15
|
+
return watch(gulpConfig.get('watchSearch'), {
|
|
16
|
+
ignoreInitial: false
|
|
17
|
+
}, testQuick)
|
|
18
|
+
}
|
|
19
|
+
module.exports = watchTest
|
package/dist/watchTest.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
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;
|
package/functions/build.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const bundle = require('./bundle')
|
|
2
2
|
const bundleLint = require('./bundleLint')
|
|
3
3
|
const bundleMinify = require('./bundleMinify')
|
|
4
|
-
const clean = require('./
|
|
4
|
+
const { clean, distSeries } = require('./partials')
|
|
5
5
|
const compileReadme = require('./compileReadme')
|
|
6
6
|
const dist = require('./dist')
|
|
7
7
|
const distLint = require('./distLint')
|
|
@@ -13,13 +13,16 @@ const testFull = require('./testFull')
|
|
|
13
13
|
/**
|
|
14
14
|
* Runs several processes to build and validate the project.
|
|
15
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}
|
|
16
19
|
*/
|
|
17
|
-
const build = parallel(
|
|
18
|
-
gulpConfig.nodeOnly
|
|
20
|
+
const build = (done = null) => parallel(
|
|
21
|
+
gulpConfig.get('nodeOnly')
|
|
19
22
|
? series(clean, dist, parallel(distLint, distMinify))
|
|
20
|
-
: series(clean,
|
|
23
|
+
: series(clean, distSeries, parallel(distLint, distMinify), bundle, parallel(bundleLint, bundleMinify)),
|
|
21
24
|
compileReadme,
|
|
22
25
|
testFull
|
|
23
|
-
)
|
|
26
|
+
)(done)
|
|
24
27
|
|
|
25
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
|
+
})
|
package/functions/bundle.js
CHANGED
|
@@ -5,11 +5,13 @@ const source = require('vinyl-source-stream')
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.
|
|
8
|
-
* @
|
|
8
|
+
* @function
|
|
9
|
+
* @memberOf module:js-build-tools
|
|
10
|
+
* @returns {stream.Stream}
|
|
9
11
|
*/
|
|
10
|
-
const bundle = () => browserify(gulpConfig.distMain)
|
|
12
|
+
const bundle = () => browserify(gulpConfig.get('distMain'))
|
|
11
13
|
.bundle()
|
|
12
|
-
.pipe(source(`${gulpConfig.browserName}.js`))
|
|
13
|
-
.pipe(dest(gulpConfig.browserPath))
|
|
14
|
+
.pipe(source(`${gulpConfig.get('browserName')}.js`))
|
|
15
|
+
.pipe(dest(gulpConfig.get('browserPath')))
|
|
14
16
|
|
|
15
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
|
+
})
|
package/functions/bundleLint.js
CHANGED
|
@@ -4,14 +4,16 @@ const standard = require('gulp-standard')
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Applies Standard code style linting to bundled file.
|
|
7
|
-
* @
|
|
7
|
+
* @function
|
|
8
|
+
* @memberOf module:js-build-tools
|
|
9
|
+
* @returns {stream.Stream}
|
|
8
10
|
*/
|
|
9
|
-
const bundleLint = () => src(`${gulpConfig.browserPath}/${gulpConfig.browserName}.js`)
|
|
11
|
+
const bundleLint = () => src(`${gulpConfig.get('browserPath')}/${gulpConfig.get('browserName')}.js`)
|
|
10
12
|
.pipe(standard({ fix: true }))
|
|
11
13
|
.pipe(standard.reporter('default', {
|
|
12
14
|
fix: true,
|
|
13
15
|
quiet: true
|
|
14
16
|
}))
|
|
15
|
-
.pipe(dest(gulpConfig.browserPath))
|
|
17
|
+
.pipe(dest(gulpConfig.get('browserPath')))
|
|
16
18
|
|
|
17
19
|
module.exports = bundleLint
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const setUp = require('./test-helpers/setUp')
|
|
3
|
+
setUp.setDefaults('test-bundle-lint')
|
|
4
|
+
const gulpConfig = setUp.gulpConfig
|
|
5
|
+
const bundleLint = require('./bundleLint')
|
|
6
|
+
const { countMatches } = require('./testHelpers')
|
|
7
|
+
|
|
8
|
+
const lintableContents = 'const gulpConfig = require("../gulp.config.js");\n' +
|
|
9
|
+
'const { dest, src } = require("gulp");\n' +
|
|
10
|
+
'const standard = require("gulp-standard");\n' +
|
|
11
|
+
'\n' +
|
|
12
|
+
'/**\n' +
|
|
13
|
+
' * Applies Standard code style linting to distribution files.\n' +
|
|
14
|
+
' * @returns {*}\n' +
|
|
15
|
+
' */\n' +
|
|
16
|
+
'const bundleLint = () => src(`${gulpConfig.get(\"browserPath\")}/${gulpConfig.get(\"browserName\")}.js`)\n' +
|
|
17
|
+
' .pipe(standard({ fix: true }))\n' +
|
|
18
|
+
' .pipe(standard.reporter("default", {\n' +
|
|
19
|
+
' fix: true,\n' +
|
|
20
|
+
' quiet: true\n' +
|
|
21
|
+
' }))\n' +
|
|
22
|
+
' .pipe(dest(gulpConfig.get("browserPath")));\n' +
|
|
23
|
+
'\n' +
|
|
24
|
+
'module.exports = bundleLint;'
|
|
25
|
+
|
|
26
|
+
beforeEach(
|
|
27
|
+
() => setUp.beforeEach()
|
|
28
|
+
.then(
|
|
29
|
+
async () => {
|
|
30
|
+
const browserPath = gulpConfig.get('browserPath')
|
|
31
|
+
const browserName = gulpConfig.get('browserName')
|
|
32
|
+
await fs.mkdirSync(browserPath)
|
|
33
|
+
return fs.writeFileSync(`${browserPath}/${browserName}.js`, lintableContents)
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
afterEach(setUp.afterEach)
|
|
39
|
+
|
|
40
|
+
describe('bundleLint', () => {
|
|
41
|
+
test('copies the src directory and babelifies it into the dist directory', done => {
|
|
42
|
+
const browserPath = gulpConfig.get('browserPath')
|
|
43
|
+
const browserName = gulpConfig.get('browserName')
|
|
44
|
+
const fullPath = `${browserPath}/${browserName}.js`
|
|
45
|
+
const oldContents = fs.readFileSync(fullPath).toString()
|
|
46
|
+
expect.assertions(4)
|
|
47
|
+
expect(countMatches(oldContents, '"')).toEqual(14)
|
|
48
|
+
expect(countMatches(oldContents, ';')).toEqual(5)
|
|
49
|
+
bundleLint()
|
|
50
|
+
.on('finish', () => {
|
|
51
|
+
const lintedContents = fs.readFileSync(fullPath).toString()
|
|
52
|
+
expect(countMatches(lintedContents, '"')).toEqual(0)
|
|
53
|
+
expect(countMatches(lintedContents, ';')).toEqual(0)
|
|
54
|
+
done()
|
|
55
|
+
})
|
|
56
|
+
.on('error', error => {
|
|
57
|
+
console.error('Encountered error', error)
|
|
58
|
+
done()
|
|
59
|
+
})
|
|
60
|
+
}, 10000)
|
|
61
|
+
})
|