js-build-tools 1.2.1 → 1.2.3
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 +353 -353
- package/dist/addToReadme.js +22 -21
- package/dist/addToReadme.min.js +1 -1
- package/dist/build.js +23 -22
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +15 -16
- package/dist/bundle.min.js +1 -1
- package/dist/bundleLint.js +20 -22
- package/dist/bundleLint.min.js +1 -1
- package/dist/bundleMinify.js +20 -21
- package/dist/bundleMinify.min.js +1 -1
- package/dist/clean.js +8 -10
- package/dist/clean.min.js +1 -1
- package/dist/compileReadme.js +13 -12
- package/dist/compileReadme.min.js +1 -1
- package/dist/default.js +14 -13
- package/dist/default.min.js +1 -1
- package/dist/dist.js +10 -12
- package/dist/dist.min.js +1 -1
- package/dist/distFor.js +21 -20
- package/dist/distFor.min.js +1 -1
- package/dist/distLint.js +20 -21
- package/dist/distLint.min.js +1 -1
- package/dist/distMinify.js +20 -20
- package/dist/distMinify.min.js +1 -1
- package/dist/readmeTemplate.js +15 -16
- package/dist/readmeTemplate.min.js +1 -1
- package/dist/testFull.js +13 -56
- package/dist/testFull.min.js +1 -1
- package/dist/testHelpers.js +175 -176
- package/dist/testHelpers.min.js +1 -1
- package/dist/testQuick.js +15 -58
- package/dist/testQuick.min.js +1 -1
- package/dist/watchFull.js +20 -27
- package/dist/watchFull.min.js +1 -1
- package/dist/watchTest.js +14 -15
- package/dist/watchTest.min.js +1 -1
- package/functions/addToReadme.js +17 -17
- package/functions/build.js +25 -25
- package/functions/bundle.js +15 -15
- package/functions/bundleLint.js +17 -17
- package/functions/bundleMinify.js +15 -15
- package/functions/compileReadme.js +10 -10
- package/functions/default.js +11 -11
- package/functions/dist.js +9 -9
- package/functions/distFor.js +15 -15
- package/functions/distLint.js +17 -17
- package/functions/distMinify.js +15 -15
- package/functions/readmeTemplate.js +13 -13
- package/functions/testFull.js +10 -10
- package/functions/testHelpers.test.js +100 -100
- package/functions/testQuick.js +10 -10
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -1,353 +1,353 @@
|
|
|
1
|
-
# js-build-tools
|
|
2
|
-
Centralize the build process for node.js and JS projects into a single tool suite.
|
|
3
|
-
|
|
4
|
-
### Goals
|
|
5
|
-
Using this tool suite, you can:
|
|
6
|
-
* Create formatted distribution files to be used in a node / commonjs environment.
|
|
7
|
-
* Bundle your distribution files to be used in a browser environment.
|
|
8
|
-
* Run tests and watch for changes.
|
|
9
|
-
* Generate jsdoc readme files.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
In your project's root directory, run: `npm install --save-dev gulp js-build-tools`
|
|
13
|
-
(or `yarn add --dev gulp js-build-tools` if you use Yarn).
|
|
14
|
-
|
|
15
|
-
It is recommended to install gulp with the `-g` flag, so that you can run it with `gulp` instead of `node_modules/.bin/gulp`.
|
|
16
|
-
|
|
17
|
-
## Configuration
|
|
18
|
-
In your project's root directory, create a `build-tools.config.js` file. This can contain any of the following (values provided are the defaults):
|
|
19
|
-
```
|
|
20
|
-
module.exports = {
|
|
21
|
-
// The name to use for the browser-bundled output file (.js will be appended).
|
|
22
|
-
browserName: 'my-package',
|
|
23
|
-
|
|
24
|
-
// The output directory for browser-bundled files.
|
|
25
|
-
browserPath: 'browser',
|
|
26
|
-
|
|
27
|
-
// The name of entry the distribution file.
|
|
28
|
-
distMain: 'dist/main',
|
|
29
|
-
|
|
30
|
-
// The output directory for the distribution files.
|
|
31
|
-
distPath: 'dist',
|
|
32
|
-
|
|
33
|
-
// The search pattern used for retrieving compiled distribution files.
|
|
34
|
-
distSearch: 'dist/**/*.js',
|
|
35
|
-
|
|
36
|
-
// The file which will be pre-fixed to your README.md output.
|
|
37
|
-
readmeTemplate: 'MAIN.md',
|
|
38
|
-
|
|
39
|
-
// The directory where your source files are stored (the files you manually created).
|
|
40
|
-
srcPath: 'src',
|
|
41
|
-
|
|
42
|
-
// The search pattern used for gathering source files for distribution.
|
|
43
|
-
srcSearch: 'src/**/!(*.test).js',
|
|
44
|
-
|
|
45
|
-
// The directory where Jest test files are stored.
|
|
46
|
-
// By default stored as *.test.js adjacent with the files they are testing).
|
|
47
|
-
testPath: 'src',
|
|
48
|
-
|
|
49
|
-
// The search pattern for watching files for changes.
|
|
50
|
-
watchSearch: 'src/**/*.js',
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Create your local gulpfile.js
|
|
55
|
-
In your project's root directory, create a `gulpfile.js` file, in here you can require any of the functions you need. For example:
|
|
56
|
-
```
|
|
57
|
-
// Your local gulpfile.js
|
|
58
|
-
const { build, defaultCmd, readme, testFull, testQuick, watchFull, watchTest } = require('js-build-tools')
|
|
59
|
-
|
|
60
|
-
// Everything you export will be created as a gulp task.
|
|
61
|
-
// You can build your own tasks here as well by using some of the functions `js-build-tools/functions`.
|
|
62
|
-
// You can list your available tasks by running `gulp --tasks`.
|
|
63
|
-
exports.build = build
|
|
64
|
-
exports.default = defaultCmd
|
|
65
|
-
exports.readme = readme
|
|
66
|
-
exports.testFull = testFull
|
|
67
|
-
exports.testQuick = testQuick
|
|
68
|
-
exports.watchFull = watchFull
|
|
69
|
-
exports.watchTest = watchTest
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Verify your tasks are available by running `gulp --tasks`.
|
|
73
|
-
|
|
74
|
-
### Configure Babel
|
|
75
|
-
Depending on how you wrote your test files, Jest may require some Babel configuration.
|
|
76
|
-
Create a `babel.config.js` file in the root directory of your project.
|
|
77
|
-
You can then use the recommended configuration by requiring the babel.config.js file into your own configuration file.
|
|
78
|
-
Example:
|
|
79
|
-
```
|
|
80
|
-
const babelConfig = require('js-build-tools/babel.config')
|
|
81
|
-
// You may add additional configuration here. Example: babelConfig.presets.push('@babel/preset-env')
|
|
82
|
-
module.exports = babelConfig
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Configure Scripts
|
|
86
|
-
In your package.json file, add the following scripts:
|
|
87
|
-
```
|
|
88
|
-
"scripts": {
|
|
89
|
-
"build": "gulp build",
|
|
90
|
-
"dev": "gulp",
|
|
91
|
-
"readme": "gulp readme",
|
|
92
|
-
"test": "gulp testFull",
|
|
93
|
-
"test:quick": "gulp testQuick",
|
|
94
|
-
"watch": "gulp watchFull",
|
|
95
|
-
"watch:test": "gulp watchTest"
|
|
96
|
-
},
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Usage
|
|
100
|
-
Run any of the above commands with `gulp` or `npm run`.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
# Available functions documentation
|
|
104
|
-
|
|
105
|
-
## Constants
|
|
106
|
-
|
|
107
|
-
<dl>
|
|
108
|
-
<dt><a href="#logObject">logObject</a></dt>
|
|
109
|
-
<dd><p>Log out an object in a nicely formatted way.</p>
|
|
110
|
-
</dd>
|
|
111
|
-
<dt><a href="#circularObject">circularObject</a> : <code>Object.<string, (string|Object|Array)></code></dt>
|
|
112
|
-
<dd><p>Multilayered node tree-like structure with parent references</p>
|
|
113
|
-
</dd>
|
|
114
|
-
<dt><a href="#deepReferenceObject">deepReferenceObject</a> : <code>Object.<string, (string|number|Object)></code></dt>
|
|
115
|
-
<dd><p>Sample object with deep references.</p>
|
|
116
|
-
</dd>
|
|
117
|
-
<dt><a href="#linkedList">linkedList</a> : <code>Object.<string, (string|Object)></code></dt>
|
|
118
|
-
<dd><p>Sample LinkedList for testing circular references.</p>
|
|
119
|
-
</dd>
|
|
120
|
-
<dt><a href="#jsonDom">jsonDom</a></dt>
|
|
121
|
-
<dd><p>Sample of jsonDom object containing empty nested array and objects</p>
|
|
122
|
-
</dd>
|
|
123
|
-
<dt><a href="#domItem">domItem</a></dt>
|
|
124
|
-
<dd><p>Sample of domItem child with nested child and optional details</p>
|
|
125
|
-
</dd>
|
|
126
|
-
<dt><a href="#multiReferenceObject">multiReferenceObject</a> : <code>Object.<string, (string|number|Object)></code></dt>
|
|
127
|
-
<dd><p>Sample of object containing multiple references.</p>
|
|
128
|
-
</dd>
|
|
129
|
-
<dt><a href="#nodeTree">nodeTree</a> : <code>Object.<string, (string|Object|Array)></code></dt>
|
|
130
|
-
<dd><p>Sample NodeTree for testing circular references and arrays.</p>
|
|
131
|
-
</dd>
|
|
132
|
-
<dt><a href="#defaultCmd">defaultCmd</a></dt>
|
|
133
|
-
<dd><p>Recommended as the default task, runs the simple dist and bundle tasks.</p>
|
|
134
|
-
</dd>
|
|
135
|
-
<dt><a href="#compileReadme">compileReadme</a></dt>
|
|
136
|
-
<dd><p>Generate the README.md file based off of the template, then append the generated documentation.</p>
|
|
137
|
-
</dd>
|
|
138
|
-
<dt><a href="#build">build</a></dt>
|
|
139
|
-
<dd><p>Runs several processes to build and validate the project.
|
|
140
|
-
Cleans, distributes (lint and minify), bundles (lint and minify), creates the readme, then runs the tests.</p>
|
|
141
|
-
</dd>
|
|
142
|
-
</dl>
|
|
143
|
-
|
|
144
|
-
## Functions
|
|
145
|
-
|
|
146
|
-
<dl>
|
|
147
|
-
<dt><a href="#watchTest">watchTest()</a> ⇒ <code>*</code></dt>
|
|
148
|
-
<dd><p>Watch for changes and run the tests.</p>
|
|
149
|
-
</dd>
|
|
150
|
-
<dt><a href="#watchFull">watchFull()</a> ⇒ <code>*</code></dt>
|
|
151
|
-
<dd><p>Watch for changes and run the distribution for the changed files, then bundle and test the changed files.</p>
|
|
152
|
-
</dd>
|
|
153
|
-
<dt><a href="#testQuick">testQuick()</a> ⇒ <code>Promise.<*></code></dt>
|
|
154
|
-
<dd><p>Run the Jest tests for files which have been modified (based on git status).</p>
|
|
155
|
-
</dd>
|
|
156
|
-
<dt><a href="#testFull">testFull()</a> ⇒ <code>Promise.<*></code></dt>
|
|
157
|
-
<dd><p>Run all tests with jest.</p>
|
|
158
|
-
</dd>
|
|
159
|
-
<dt><a href="#readmeTemplate">readmeTemplate()</a> ⇒ <code>*</code></dt>
|
|
160
|
-
<dd><p>Copy a readme template into the README.md file.</p>
|
|
161
|
-
</dd>
|
|
162
|
-
<dt><a href="#distMinify">distMinify()</a> ⇒ <code>*</code></dt>
|
|
163
|
-
<dd><p>Creates minified versions of the dist files.</p>
|
|
164
|
-
</dd>
|
|
165
|
-
<dt><a href="#distLint">distLint()</a> ⇒ <code>*</code></dt>
|
|
166
|
-
<dd><p>Applies Standard code style linting to distribution files.</p>
|
|
167
|
-
</dd>
|
|
168
|
-
<dt><a href="#distFor">distFor(srcPath, destPath)</a> ⇒ <code>*</code></dt>
|
|
169
|
-
<dd><p>Build the distribution for a given source pattern.</p>
|
|
170
|
-
</dd>
|
|
171
|
-
<dt><a href="#dist">dist()</a> ⇒ <code>*</code></dt>
|
|
172
|
-
<dd><p>Simplified distribution tasks which will use arguments from distFor.</p>
|
|
173
|
-
</dd>
|
|
174
|
-
<dt><a href="#clean">clean()</a> ⇒ <code>Promise.<Array.<string>></code> | <code>*</code></dt>
|
|
175
|
-
<dd><p>Deletes all the distribution and browser files (used before create a new build).</p>
|
|
176
|
-
</dd>
|
|
177
|
-
<dt><a href="#bundleMinify">bundleMinify()</a> ⇒ <code>*</code></dt>
|
|
178
|
-
<dd><p>Creates the minified bundle file.</p>
|
|
179
|
-
</dd>
|
|
180
|
-
<dt><a href="#bundleLint">bundleLint()</a> ⇒ <code>*</code></dt>
|
|
181
|
-
<dd><p>Applies Standard code style linting to bundled file.</p>
|
|
182
|
-
</dd>
|
|
183
|
-
<dt><a href="#bundle">bundle()</a> ⇒ <code>*</code></dt>
|
|
184
|
-
<dd><p>Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.</p>
|
|
185
|
-
</dd>
|
|
186
|
-
<dt><a href="#addToReadme">addToReadme()</a> ⇒ <code>string</code> | <code>Uint8Array</code></dt>
|
|
187
|
-
<dd><p>Appends all the jsdoc comments to the readme file. Assumes empty or templated file.</p>
|
|
188
|
-
</dd>
|
|
189
|
-
</dl>
|
|
190
|
-
|
|
191
|
-
<a name="logObject"></a>
|
|
192
|
-
|
|
193
|
-
## logObject
|
|
194
|
-
Log out an object in a nicely formatted way.
|
|
195
|
-
|
|
196
|
-
**Kind**: global constant
|
|
197
|
-
|
|
198
|
-
| Param | Type | Default |
|
|
199
|
-
| --- | --- | --- |
|
|
200
|
-
| object | <code>Object</code> | |
|
|
201
|
-
| [label] | <code>string</code> | <code>"'logging'"</code> |
|
|
202
|
-
|
|
203
|
-
<a name="circularObject"></a>
|
|
204
|
-
|
|
205
|
-
## circularObject : <code>Object.<string, (string\|Object\|Array)></code>
|
|
206
|
-
Multilayered node tree-like structure with parent references
|
|
207
|
-
|
|
208
|
-
**Kind**: global constant
|
|
209
|
-
<a name="deepReferenceObject"></a>
|
|
210
|
-
|
|
211
|
-
## deepReferenceObject : <code>Object.<string, (string\|number\|Object)></code>
|
|
212
|
-
Sample object with deep references.
|
|
213
|
-
|
|
214
|
-
**Kind**: global constant
|
|
215
|
-
<a name="linkedList"></a>
|
|
216
|
-
|
|
217
|
-
## linkedList : <code>Object.<string, (string\|Object)></code>
|
|
218
|
-
Sample LinkedList for testing circular references.
|
|
219
|
-
|
|
220
|
-
**Kind**: global constant
|
|
221
|
-
<a name="jsonDom"></a>
|
|
222
|
-
|
|
223
|
-
## jsonDom
|
|
224
|
-
Sample of jsonDom object containing empty nested array and objects
|
|
225
|
-
|
|
226
|
-
**Kind**: global constant
|
|
227
|
-
<a name="domItem"></a>
|
|
228
|
-
|
|
229
|
-
## domItem
|
|
230
|
-
Sample of domItem child with nested child and optional details
|
|
231
|
-
|
|
232
|
-
**Kind**: global constant
|
|
233
|
-
<a name="multiReferenceObject"></a>
|
|
234
|
-
|
|
235
|
-
## multiReferenceObject : <code>Object.<string, (string\|number\|Object)></code>
|
|
236
|
-
Sample of object containing multiple references.
|
|
237
|
-
|
|
238
|
-
**Kind**: global constant
|
|
239
|
-
<a name="nodeTree"></a>
|
|
240
|
-
|
|
241
|
-
## nodeTree : <code>Object.<string, (string\|Object\|Array)></code>
|
|
242
|
-
Sample NodeTree for testing circular references and arrays.
|
|
243
|
-
|
|
244
|
-
**Kind**: global constant
|
|
245
|
-
<a name="defaultCmd"></a>
|
|
246
|
-
|
|
247
|
-
## defaultCmd
|
|
248
|
-
Recommended as the default task, runs the simple dist and bundle tasks.
|
|
249
|
-
|
|
250
|
-
**Kind**: global constant
|
|
251
|
-
<a name="compileReadme"></a>
|
|
252
|
-
|
|
253
|
-
## compileReadme
|
|
254
|
-
Generate the README.md file based off of the template, then append the generated documentation.
|
|
255
|
-
|
|
256
|
-
**Kind**: global constant
|
|
257
|
-
<a name="build"></a>
|
|
258
|
-
|
|
259
|
-
## build
|
|
260
|
-
Runs several processes to build and validate the project.
|
|
261
|
-
Cleans, distributes (lint and minify), bundles (lint and minify), creates the readme, then runs the tests.
|
|
262
|
-
|
|
263
|
-
**Kind**: global constant
|
|
264
|
-
<a name="watchTest"></a>
|
|
265
|
-
|
|
266
|
-
## watchTest() ⇒ <code>\*</code>
|
|
267
|
-
Watch for changes and run the tests.
|
|
268
|
-
|
|
269
|
-
**Kind**: global function
|
|
270
|
-
<a name="watchFull"></a>
|
|
271
|
-
|
|
272
|
-
## watchFull() ⇒ <code>\*</code>
|
|
273
|
-
Watch for changes and run the distribution for the changed files, then bundle and test the changed files.
|
|
274
|
-
|
|
275
|
-
**Kind**: global function
|
|
276
|
-
<a name="testQuick"></a>
|
|
277
|
-
|
|
278
|
-
## testQuick() ⇒ <code>Promise.<\*></code>
|
|
279
|
-
Run the Jest tests for files which have been modified (based on git status).
|
|
280
|
-
|
|
281
|
-
**Kind**: global function
|
|
282
|
-
<a name="testFull"></a>
|
|
283
|
-
|
|
284
|
-
## testFull() ⇒ <code>Promise.<\*></code>
|
|
285
|
-
Run all tests with jest.
|
|
286
|
-
|
|
287
|
-
**Kind**: global function
|
|
288
|
-
<a name="readmeTemplate"></a>
|
|
289
|
-
|
|
290
|
-
## readmeTemplate() ⇒ <code>\*</code>
|
|
291
|
-
Copy a readme template into the README.md file.
|
|
292
|
-
|
|
293
|
-
**Kind**: global function
|
|
294
|
-
<a name="distMinify"></a>
|
|
295
|
-
|
|
296
|
-
## distMinify() ⇒ <code>\*</code>
|
|
297
|
-
Creates minified versions of the dist files.
|
|
298
|
-
|
|
299
|
-
**Kind**: global function
|
|
300
|
-
<a name="distLint"></a>
|
|
301
|
-
|
|
302
|
-
## distLint() ⇒ <code>\*</code>
|
|
303
|
-
Applies Standard code style linting to distribution files.
|
|
304
|
-
|
|
305
|
-
**Kind**: global function
|
|
306
|
-
<a name="distFor"></a>
|
|
307
|
-
|
|
308
|
-
## distFor(srcPath, destPath) ⇒ <code>\*</code>
|
|
309
|
-
Build the distribution for a given source pattern.
|
|
310
|
-
|
|
311
|
-
**Kind**: global function
|
|
312
|
-
|
|
313
|
-
| Param | Type |
|
|
314
|
-
| --- | --- |
|
|
315
|
-
| srcPath | <code>string</code> \| <code>array</code> |
|
|
316
|
-
| destPath | <code>string</code> |
|
|
317
|
-
|
|
318
|
-
<a name="dist"></a>
|
|
319
|
-
|
|
320
|
-
## dist() ⇒ <code>\*</code>
|
|
321
|
-
Simplified distribution tasks which will use arguments from distFor.
|
|
322
|
-
|
|
323
|
-
**Kind**: global function
|
|
324
|
-
<a name="clean"></a>
|
|
325
|
-
|
|
326
|
-
## clean() ⇒ <code>Promise.<Array.<string>></code> \| <code>\*</code>
|
|
327
|
-
Deletes all the distribution and browser files (used before create a new build).
|
|
328
|
-
|
|
329
|
-
**Kind**: global function
|
|
330
|
-
<a name="bundleMinify"></a>
|
|
331
|
-
|
|
332
|
-
## bundleMinify() ⇒ <code>\*</code>
|
|
333
|
-
Creates the minified bundle file.
|
|
334
|
-
|
|
335
|
-
**Kind**: global function
|
|
336
|
-
<a name="bundleLint"></a>
|
|
337
|
-
|
|
338
|
-
## bundleLint() ⇒ <code>\*</code>
|
|
339
|
-
Applies Standard code style linting to bundled file.
|
|
340
|
-
|
|
341
|
-
**Kind**: global function
|
|
342
|
-
<a name="bundle"></a>
|
|
343
|
-
|
|
344
|
-
## bundle() ⇒ <code>\*</code>
|
|
345
|
-
Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.
|
|
346
|
-
|
|
347
|
-
**Kind**: global function
|
|
348
|
-
<a name="addToReadme"></a>
|
|
349
|
-
|
|
350
|
-
## addToReadme() ⇒ <code>string</code> \| <code>Uint8Array</code>
|
|
351
|
-
Appends all the jsdoc comments to the readme file. Assumes empty or templated file.
|
|
352
|
-
|
|
353
|
-
**Kind**: global function
|
|
1
|
+
# js-build-tools
|
|
2
|
+
Centralize the build process for node.js and JS projects into a single tool suite.
|
|
3
|
+
|
|
4
|
+
### Goals
|
|
5
|
+
Using this tool suite, you can:
|
|
6
|
+
* Create formatted distribution files to be used in a node / commonjs environment.
|
|
7
|
+
* Bundle your distribution files to be used in a browser environment.
|
|
8
|
+
* Run tests and watch for changes.
|
|
9
|
+
* Generate jsdoc readme files.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
In your project's root directory, run: `npm install --save-dev gulp js-build-tools`
|
|
13
|
+
(or `yarn add --dev gulp js-build-tools` if you use Yarn).
|
|
14
|
+
|
|
15
|
+
It is recommended to install gulp with the `-g` flag, so that you can run it with `gulp` instead of `node_modules/.bin/gulp`.
|
|
16
|
+
|
|
17
|
+
## Configuration
|
|
18
|
+
In your project's root directory, create a `build-tools.config.js` file. This can contain any of the following (values provided are the defaults):
|
|
19
|
+
```
|
|
20
|
+
module.exports = {
|
|
21
|
+
// The name to use for the browser-bundled output file (.js will be appended).
|
|
22
|
+
browserName: 'my-package',
|
|
23
|
+
|
|
24
|
+
// The output directory for browser-bundled files.
|
|
25
|
+
browserPath: 'browser',
|
|
26
|
+
|
|
27
|
+
// The name of entry the distribution file.
|
|
28
|
+
distMain: 'dist/main',
|
|
29
|
+
|
|
30
|
+
// The output directory for the distribution files.
|
|
31
|
+
distPath: 'dist',
|
|
32
|
+
|
|
33
|
+
// The search pattern used for retrieving compiled distribution files.
|
|
34
|
+
distSearch: 'dist/**/*.js',
|
|
35
|
+
|
|
36
|
+
// The file which will be pre-fixed to your README.md output.
|
|
37
|
+
readmeTemplate: 'MAIN.md',
|
|
38
|
+
|
|
39
|
+
// The directory where your source files are stored (the files you manually created).
|
|
40
|
+
srcPath: 'src',
|
|
41
|
+
|
|
42
|
+
// The search pattern used for gathering source files for distribution.
|
|
43
|
+
srcSearch: 'src/**/!(*.test).js',
|
|
44
|
+
|
|
45
|
+
// The directory where Jest test files are stored.
|
|
46
|
+
// By default stored as *.test.js adjacent with the files they are testing).
|
|
47
|
+
testPath: 'src',
|
|
48
|
+
|
|
49
|
+
// The search pattern for watching files for changes.
|
|
50
|
+
watchSearch: 'src/**/*.js',
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Create your local gulpfile.js
|
|
55
|
+
In your project's root directory, create a `gulpfile.js` file, in here you can require any of the functions you need. For example:
|
|
56
|
+
```
|
|
57
|
+
// Your local gulpfile.js
|
|
58
|
+
const { build, defaultCmd, readme, testFull, testQuick, watchFull, watchTest } = require('js-build-tools')
|
|
59
|
+
|
|
60
|
+
// Everything you export will be created as a gulp task.
|
|
61
|
+
// You can build your own tasks here as well by using some of the functions `js-build-tools/functions`.
|
|
62
|
+
// You can list your available tasks by running `gulp --tasks`.
|
|
63
|
+
exports.build = build
|
|
64
|
+
exports.default = defaultCmd
|
|
65
|
+
exports.readme = readme
|
|
66
|
+
exports.testFull = testFull
|
|
67
|
+
exports.testQuick = testQuick
|
|
68
|
+
exports.watchFull = watchFull
|
|
69
|
+
exports.watchTest = watchTest
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Verify your tasks are available by running `gulp --tasks`.
|
|
73
|
+
|
|
74
|
+
### Configure Babel
|
|
75
|
+
Depending on how you wrote your test files, Jest may require some Babel configuration.
|
|
76
|
+
Create a `babel.config.js` file in the root directory of your project.
|
|
77
|
+
You can then use the recommended configuration by requiring the babel.config.js file into your own configuration file.
|
|
78
|
+
Example:
|
|
79
|
+
```
|
|
80
|
+
const babelConfig = require('js-build-tools/babel.config')
|
|
81
|
+
// You may add additional configuration here. Example: babelConfig.presets.push('@babel/preset-env')
|
|
82
|
+
module.exports = babelConfig
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Configure Scripts
|
|
86
|
+
In your package.json file, add the following scripts:
|
|
87
|
+
```
|
|
88
|
+
"scripts": {
|
|
89
|
+
"build": "gulp build",
|
|
90
|
+
"dev": "gulp",
|
|
91
|
+
"readme": "gulp readme",
|
|
92
|
+
"test": "gulp testFull",
|
|
93
|
+
"test:quick": "gulp testQuick",
|
|
94
|
+
"watch": "gulp watchFull",
|
|
95
|
+
"watch:test": "gulp watchTest"
|
|
96
|
+
},
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Usage
|
|
100
|
+
Run any of the above commands with `gulp` or `npm run`.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# Available functions documentation
|
|
104
|
+
|
|
105
|
+
## Constants
|
|
106
|
+
|
|
107
|
+
<dl>
|
|
108
|
+
<dt><a href="#logObject">logObject</a></dt>
|
|
109
|
+
<dd><p>Log out an object in a nicely formatted way.</p>
|
|
110
|
+
</dd>
|
|
111
|
+
<dt><a href="#circularObject">circularObject</a> : <code>Object.<string, (string|Object|Array)></code></dt>
|
|
112
|
+
<dd><p>Multilayered node tree-like structure with parent references</p>
|
|
113
|
+
</dd>
|
|
114
|
+
<dt><a href="#deepReferenceObject">deepReferenceObject</a> : <code>Object.<string, (string|number|Object)></code></dt>
|
|
115
|
+
<dd><p>Sample object with deep references.</p>
|
|
116
|
+
</dd>
|
|
117
|
+
<dt><a href="#linkedList">linkedList</a> : <code>Object.<string, (string|Object)></code></dt>
|
|
118
|
+
<dd><p>Sample LinkedList for testing circular references.</p>
|
|
119
|
+
</dd>
|
|
120
|
+
<dt><a href="#jsonDom">jsonDom</a></dt>
|
|
121
|
+
<dd><p>Sample of jsonDom object containing empty nested array and objects</p>
|
|
122
|
+
</dd>
|
|
123
|
+
<dt><a href="#domItem">domItem</a></dt>
|
|
124
|
+
<dd><p>Sample of domItem child with nested child and optional details</p>
|
|
125
|
+
</dd>
|
|
126
|
+
<dt><a href="#multiReferenceObject">multiReferenceObject</a> : <code>Object.<string, (string|number|Object)></code></dt>
|
|
127
|
+
<dd><p>Sample of object containing multiple references.</p>
|
|
128
|
+
</dd>
|
|
129
|
+
<dt><a href="#nodeTree">nodeTree</a> : <code>Object.<string, (string|Object|Array)></code></dt>
|
|
130
|
+
<dd><p>Sample NodeTree for testing circular references and arrays.</p>
|
|
131
|
+
</dd>
|
|
132
|
+
<dt><a href="#defaultCmd">defaultCmd</a></dt>
|
|
133
|
+
<dd><p>Recommended as the default task, runs the simple dist and bundle tasks.</p>
|
|
134
|
+
</dd>
|
|
135
|
+
<dt><a href="#compileReadme">compileReadme</a></dt>
|
|
136
|
+
<dd><p>Generate the README.md file based off of the template, then append the generated documentation.</p>
|
|
137
|
+
</dd>
|
|
138
|
+
<dt><a href="#build">build</a></dt>
|
|
139
|
+
<dd><p>Runs several processes to build and validate the project.
|
|
140
|
+
Cleans, distributes (lint and minify), bundles (lint and minify), creates the readme, then runs the tests.</p>
|
|
141
|
+
</dd>
|
|
142
|
+
</dl>
|
|
143
|
+
|
|
144
|
+
## Functions
|
|
145
|
+
|
|
146
|
+
<dl>
|
|
147
|
+
<dt><a href="#watchTest">watchTest()</a> ⇒ <code>*</code></dt>
|
|
148
|
+
<dd><p>Watch for changes and run the tests.</p>
|
|
149
|
+
</dd>
|
|
150
|
+
<dt><a href="#watchFull">watchFull()</a> ⇒ <code>*</code></dt>
|
|
151
|
+
<dd><p>Watch for changes and run the distribution for the changed files, then bundle and test the changed files.</p>
|
|
152
|
+
</dd>
|
|
153
|
+
<dt><a href="#testQuick">testQuick()</a> ⇒ <code>Promise.<*></code></dt>
|
|
154
|
+
<dd><p>Run the Jest tests for files which have been modified (based on git status).</p>
|
|
155
|
+
</dd>
|
|
156
|
+
<dt><a href="#testFull">testFull()</a> ⇒ <code>Promise.<*></code></dt>
|
|
157
|
+
<dd><p>Run all tests with jest.</p>
|
|
158
|
+
</dd>
|
|
159
|
+
<dt><a href="#readmeTemplate">readmeTemplate()</a> ⇒ <code>*</code></dt>
|
|
160
|
+
<dd><p>Copy a readme template into the README.md file.</p>
|
|
161
|
+
</dd>
|
|
162
|
+
<dt><a href="#distMinify">distMinify()</a> ⇒ <code>*</code></dt>
|
|
163
|
+
<dd><p>Creates minified versions of the dist files.</p>
|
|
164
|
+
</dd>
|
|
165
|
+
<dt><a href="#distLint">distLint()</a> ⇒ <code>*</code></dt>
|
|
166
|
+
<dd><p>Applies Standard code style linting to distribution files.</p>
|
|
167
|
+
</dd>
|
|
168
|
+
<dt><a href="#distFor">distFor(srcPath, destPath)</a> ⇒ <code>*</code></dt>
|
|
169
|
+
<dd><p>Build the distribution for a given source pattern.</p>
|
|
170
|
+
</dd>
|
|
171
|
+
<dt><a href="#dist">dist()</a> ⇒ <code>*</code></dt>
|
|
172
|
+
<dd><p>Simplified distribution tasks which will use arguments from distFor.</p>
|
|
173
|
+
</dd>
|
|
174
|
+
<dt><a href="#clean">clean()</a> ⇒ <code>Promise.<Array.<string>></code> | <code>*</code></dt>
|
|
175
|
+
<dd><p>Deletes all the distribution and browser files (used before create a new build).</p>
|
|
176
|
+
</dd>
|
|
177
|
+
<dt><a href="#bundleMinify">bundleMinify()</a> ⇒ <code>*</code></dt>
|
|
178
|
+
<dd><p>Creates the minified bundle file.</p>
|
|
179
|
+
</dd>
|
|
180
|
+
<dt><a href="#bundleLint">bundleLint()</a> ⇒ <code>*</code></dt>
|
|
181
|
+
<dd><p>Applies Standard code style linting to bundled file.</p>
|
|
182
|
+
</dd>
|
|
183
|
+
<dt><a href="#bundle">bundle()</a> ⇒ <code>*</code></dt>
|
|
184
|
+
<dd><p>Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.</p>
|
|
185
|
+
</dd>
|
|
186
|
+
<dt><a href="#addToReadme">addToReadme()</a> ⇒ <code>string</code> | <code>Uint8Array</code></dt>
|
|
187
|
+
<dd><p>Appends all the jsdoc comments to the readme file. Assumes empty or templated file.</p>
|
|
188
|
+
</dd>
|
|
189
|
+
</dl>
|
|
190
|
+
|
|
191
|
+
<a name="logObject"></a>
|
|
192
|
+
|
|
193
|
+
## logObject
|
|
194
|
+
Log out an object in a nicely formatted way.
|
|
195
|
+
|
|
196
|
+
**Kind**: global constant
|
|
197
|
+
|
|
198
|
+
| Param | Type | Default |
|
|
199
|
+
| --- | --- | --- |
|
|
200
|
+
| object | <code>Object</code> | |
|
|
201
|
+
| [label] | <code>string</code> | <code>"'logging'"</code> |
|
|
202
|
+
|
|
203
|
+
<a name="circularObject"></a>
|
|
204
|
+
|
|
205
|
+
## circularObject : <code>Object.<string, (string\|Object\|Array)></code>
|
|
206
|
+
Multilayered node tree-like structure with parent references
|
|
207
|
+
|
|
208
|
+
**Kind**: global constant
|
|
209
|
+
<a name="deepReferenceObject"></a>
|
|
210
|
+
|
|
211
|
+
## deepReferenceObject : <code>Object.<string, (string\|number\|Object)></code>
|
|
212
|
+
Sample object with deep references.
|
|
213
|
+
|
|
214
|
+
**Kind**: global constant
|
|
215
|
+
<a name="linkedList"></a>
|
|
216
|
+
|
|
217
|
+
## linkedList : <code>Object.<string, (string\|Object)></code>
|
|
218
|
+
Sample LinkedList for testing circular references.
|
|
219
|
+
|
|
220
|
+
**Kind**: global constant
|
|
221
|
+
<a name="jsonDom"></a>
|
|
222
|
+
|
|
223
|
+
## jsonDom
|
|
224
|
+
Sample of jsonDom object containing empty nested array and objects
|
|
225
|
+
|
|
226
|
+
**Kind**: global constant
|
|
227
|
+
<a name="domItem"></a>
|
|
228
|
+
|
|
229
|
+
## domItem
|
|
230
|
+
Sample of domItem child with nested child and optional details
|
|
231
|
+
|
|
232
|
+
**Kind**: global constant
|
|
233
|
+
<a name="multiReferenceObject"></a>
|
|
234
|
+
|
|
235
|
+
## multiReferenceObject : <code>Object.<string, (string\|number\|Object)></code>
|
|
236
|
+
Sample of object containing multiple references.
|
|
237
|
+
|
|
238
|
+
**Kind**: global constant
|
|
239
|
+
<a name="nodeTree"></a>
|
|
240
|
+
|
|
241
|
+
## nodeTree : <code>Object.<string, (string\|Object\|Array)></code>
|
|
242
|
+
Sample NodeTree for testing circular references and arrays.
|
|
243
|
+
|
|
244
|
+
**Kind**: global constant
|
|
245
|
+
<a name="defaultCmd"></a>
|
|
246
|
+
|
|
247
|
+
## defaultCmd
|
|
248
|
+
Recommended as the default task, runs the simple dist and bundle tasks.
|
|
249
|
+
|
|
250
|
+
**Kind**: global constant
|
|
251
|
+
<a name="compileReadme"></a>
|
|
252
|
+
|
|
253
|
+
## compileReadme
|
|
254
|
+
Generate the README.md file based off of the template, then append the generated documentation.
|
|
255
|
+
|
|
256
|
+
**Kind**: global constant
|
|
257
|
+
<a name="build"></a>
|
|
258
|
+
|
|
259
|
+
## build
|
|
260
|
+
Runs several processes to build and validate the project.
|
|
261
|
+
Cleans, distributes (lint and minify), bundles (lint and minify), creates the readme, then runs the tests.
|
|
262
|
+
|
|
263
|
+
**Kind**: global constant
|
|
264
|
+
<a name="watchTest"></a>
|
|
265
|
+
|
|
266
|
+
## watchTest() ⇒ <code>\*</code>
|
|
267
|
+
Watch for changes and run the tests.
|
|
268
|
+
|
|
269
|
+
**Kind**: global function
|
|
270
|
+
<a name="watchFull"></a>
|
|
271
|
+
|
|
272
|
+
## watchFull() ⇒ <code>\*</code>
|
|
273
|
+
Watch for changes and run the distribution for the changed files, then bundle and test the changed files.
|
|
274
|
+
|
|
275
|
+
**Kind**: global function
|
|
276
|
+
<a name="testQuick"></a>
|
|
277
|
+
|
|
278
|
+
## testQuick() ⇒ <code>Promise.<\*></code>
|
|
279
|
+
Run the Jest tests for files which have been modified (based on git status).
|
|
280
|
+
|
|
281
|
+
**Kind**: global function
|
|
282
|
+
<a name="testFull"></a>
|
|
283
|
+
|
|
284
|
+
## testFull() ⇒ <code>Promise.<\*></code>
|
|
285
|
+
Run all tests with jest.
|
|
286
|
+
|
|
287
|
+
**Kind**: global function
|
|
288
|
+
<a name="readmeTemplate"></a>
|
|
289
|
+
|
|
290
|
+
## readmeTemplate() ⇒ <code>\*</code>
|
|
291
|
+
Copy a readme template into the README.md file.
|
|
292
|
+
|
|
293
|
+
**Kind**: global function
|
|
294
|
+
<a name="distMinify"></a>
|
|
295
|
+
|
|
296
|
+
## distMinify() ⇒ <code>\*</code>
|
|
297
|
+
Creates minified versions of the dist files.
|
|
298
|
+
|
|
299
|
+
**Kind**: global function
|
|
300
|
+
<a name="distLint"></a>
|
|
301
|
+
|
|
302
|
+
## distLint() ⇒ <code>\*</code>
|
|
303
|
+
Applies Standard code style linting to distribution files.
|
|
304
|
+
|
|
305
|
+
**Kind**: global function
|
|
306
|
+
<a name="distFor"></a>
|
|
307
|
+
|
|
308
|
+
## distFor(srcPath, destPath) ⇒ <code>\*</code>
|
|
309
|
+
Build the distribution for a given source pattern.
|
|
310
|
+
|
|
311
|
+
**Kind**: global function
|
|
312
|
+
|
|
313
|
+
| Param | Type |
|
|
314
|
+
| --- | --- |
|
|
315
|
+
| srcPath | <code>string</code> \| <code>array</code> |
|
|
316
|
+
| destPath | <code>string</code> |
|
|
317
|
+
|
|
318
|
+
<a name="dist"></a>
|
|
319
|
+
|
|
320
|
+
## dist() ⇒ <code>\*</code>
|
|
321
|
+
Simplified distribution tasks which will use arguments from distFor.
|
|
322
|
+
|
|
323
|
+
**Kind**: global function
|
|
324
|
+
<a name="clean"></a>
|
|
325
|
+
|
|
326
|
+
## clean() ⇒ <code>Promise.<Array.<string>></code> \| <code>\*</code>
|
|
327
|
+
Deletes all the distribution and browser files (used before create a new build).
|
|
328
|
+
|
|
329
|
+
**Kind**: global function
|
|
330
|
+
<a name="bundleMinify"></a>
|
|
331
|
+
|
|
332
|
+
## bundleMinify() ⇒ <code>\*</code>
|
|
333
|
+
Creates the minified bundle file.
|
|
334
|
+
|
|
335
|
+
**Kind**: global function
|
|
336
|
+
<a name="bundleLint"></a>
|
|
337
|
+
|
|
338
|
+
## bundleLint() ⇒ <code>\*</code>
|
|
339
|
+
Applies Standard code style linting to bundled file.
|
|
340
|
+
|
|
341
|
+
**Kind**: global function
|
|
342
|
+
<a name="bundle"></a>
|
|
343
|
+
|
|
344
|
+
## bundle() ⇒ <code>\*</code>
|
|
345
|
+
Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.
|
|
346
|
+
|
|
347
|
+
**Kind**: global function
|
|
348
|
+
<a name="addToReadme"></a>
|
|
349
|
+
|
|
350
|
+
## addToReadme() ⇒ <code>string</code> \| <code>Uint8Array</code>
|
|
351
|
+
Appends all the jsdoc comments to the readme file. Assumes empty or templated file.
|
|
352
|
+
|
|
353
|
+
**Kind**: global function
|