@mobilabs/es6lib 2.1.0 → 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/.github/workflows/ci.yml +1 -1
- package/_dist/lib/es6lib.js +3 -3
- package/_dist/lib/es6lib.min.js +2 -2
- package/_dist/lib/es6lib.min.mjs +2 -2
- package/_dist/lib/es6lib.mjs +3 -3
- package/bin/es6lib.js +5 -5
- package/package.json +1 -1
- package/scripts/_build.template.js +247 -0
- package/scripts/build.js.dev.js +284 -0
- package/scripts/build.js.prod.js +294 -0
- package/scripts/build.skeleton.prod.js +198 -0
- package/scripts/compress.sh +41 -0
- package/scripts/config.js +80 -0
- package/scripts/dep.npm.private.sh +42 -0
- package/scripts/dep.private.js +232 -0
package/.github/workflows/ci.yml
CHANGED
package/_dist/lib/es6lib.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! ****************************************************************************
|
|
2
|
-
* ES6lib v2.1.
|
|
2
|
+
* ES6lib v2.1.1
|
|
3
3
|
*
|
|
4
4
|
* A template for writing pure ES6 Javascript libraries.
|
|
5
5
|
* (you can download it from npm or github repositories)
|
|
@@ -313,14 +313,14 @@
|
|
|
313
313
|
const obj = Object.create(methods);
|
|
314
314
|
obj._library = {
|
|
315
315
|
name: 'ES6lib',
|
|
316
|
-
version: '2.1.
|
|
316
|
+
version: '2.1.1',
|
|
317
317
|
};
|
|
318
318
|
return obj;
|
|
319
319
|
};
|
|
320
320
|
|
|
321
321
|
// Attaches constants to ES6lib that provide name and version of the lib.
|
|
322
322
|
ES6lib.NAME = 'ES6lib';
|
|
323
|
-
ES6lib.VERSION = '2.1.
|
|
323
|
+
ES6lib.VERSION = '2.1.1';
|
|
324
324
|
|
|
325
325
|
|
|
326
326
|
// -- Private Static Methods -----------------------------------------------
|
package/_dist/lib/es6lib.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! ****************************************************************************
|
|
2
|
-
* ES6lib v2.1.
|
|
2
|
+
* ES6lib v2.1.1
|
|
3
3
|
*
|
|
4
4
|
* A template for writing pure ES6 Javascript libraries.
|
|
5
5
|
* (you can download it from npm or github repositories)
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* at: http://www.opensource.org/licenses/mit-license.php).
|
|
9
9
|
* Built from {{boiler:name}} v{{boiler:name:version}}.
|
|
10
10
|
* ************************************************************************** */
|
|
11
|
-
!function(t,e){"use strict";"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?module.exports=e(t):t.ES6lib=e(t)}(this,(t=>{"use strict";let e,n;const i={Public:{}};return n=function(t,e){const n=Object.keys(e);for(let i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(){const t=i.Public;n(t,{getString:()=>"I am a string!",getArray:()=>[1,2,3]})}(),function(){const n=i.Public,r=t.ES6lib;let o;e=function(){const t=Object.create(o);return t._library={name:"ES6lib",version:"2.1.
|
|
11
|
+
!function(t,e){"use strict";"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?module.exports=e(t):t.ES6lib=e(t)}(this,(t=>{"use strict";let e,n;const i={Public:{}};return n=function(t,e){const n=Object.keys(e);for(let i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(){const t=i.Public;n(t,{getString:()=>"I am a string!",getArray:()=>[1,2,3]})}(),function(){const n=i.Public,r=t.ES6lib;let o;e=function(){const t=Object.create(o);return t._library={name:"ES6lib",version:"2.1.1"},t},e.NAME="ES6lib",e.VERSION="2.1.1",e._setTestMode=function(){return[]},e.noConflict=function(){return t.ES6lib=r,this},o={whoami(){return this._library},getString:()=>n.getString(),getArray:()=>n.getArray()}}(),e}));
|
package/_dist/lib/es6lib.min.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! ****************************************************************************
|
|
2
|
-
* ES6lib v2.1.
|
|
2
|
+
* ES6lib v2.1.1
|
|
3
3
|
*
|
|
4
4
|
* A template for writing pure ES6 Javascript libraries.
|
|
5
5
|
* (you can download it from npm or github repositories)
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* at: http://www.opensource.org/licenses/mit-license.php).
|
|
9
9
|
* Built from {{boiler:name}} v{{boiler:name:version}}.
|
|
10
10
|
* ************************************************************************** */
|
|
11
|
-
const $__ES6GLOB={};!function(t,e){"use strict";"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?module.exports=e(t):t.ES6lib=e(t)}($__ES6GLOB,(t=>{"use strict";let e,n;const i={Public:{}};return n=function(t,e){const n=Object.keys(e);for(let i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(){const t=i.Public;n(t,{getString:()=>"I am a string!",getArray:()=>[1,2,3]})}(),function(){const n=i.Public,r=t.ES6lib;let o;e=function(){const t=Object.create(o);return t._library={name:"ES6lib",version:"2.1.
|
|
11
|
+
const $__ES6GLOB={};!function(t,e){"use strict";"function"==typeof define&&define.amd?define([""],e):"object"==typeof exports?module.exports=e(t):t.ES6lib=e(t)}($__ES6GLOB,(t=>{"use strict";let e,n;const i={Public:{}};return n=function(t,e){const n=Object.keys(e);for(let i=0;i<n.length;i++)t[n[i]]=e[n[i]]},function(){const t=i.Public;n(t,{getString:()=>"I am a string!",getArray:()=>[1,2,3]})}(),function(){const n=i.Public,r=t.ES6lib;let o;e=function(){const t=Object.create(o);return t._library={name:"ES6lib",version:"2.1.1"},t},e.NAME="ES6lib",e.VERSION="2.1.1",e._setTestMode=function(){return[]},e.noConflict=function(){return t.ES6lib=r,this},o={whoami(){return this._library},getString:()=>n.getString(),getArray:()=>n.getArray()}}(),e}));export default $__ES6GLOB.ES6lib;
|
package/_dist/lib/es6lib.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! ****************************************************************************
|
|
2
|
-
* ES6lib v2.1.
|
|
2
|
+
* ES6lib v2.1.1
|
|
3
3
|
*
|
|
4
4
|
* A template for writing pure ES6 Javascript libraries.
|
|
5
5
|
* (you can download it from npm or github repositories)
|
|
@@ -314,14 +314,14 @@ const $__ES6GLOB = {};
|
|
|
314
314
|
const obj = Object.create(methods);
|
|
315
315
|
obj._library = {
|
|
316
316
|
name: 'ES6lib',
|
|
317
|
-
version: '2.1.
|
|
317
|
+
version: '2.1.1',
|
|
318
318
|
};
|
|
319
319
|
return obj;
|
|
320
320
|
};
|
|
321
321
|
|
|
322
322
|
// Attaches constants to ES6lib that provide name and version of the lib.
|
|
323
323
|
ES6lib.NAME = 'ES6lib';
|
|
324
|
-
ES6lib.VERSION = '2.1.
|
|
324
|
+
ES6lib.VERSION = '2.1.1';
|
|
325
325
|
|
|
326
326
|
|
|
327
327
|
// -- Private Static Methods -----------------------------------------------
|
package/bin/es6lib.js
CHANGED
|
@@ -49,7 +49,7 @@ const defBoilerLib = 'ES6lib'
|
|
|
49
49
|
, { version } = require('../package.json')
|
|
50
50
|
, src = 'src'
|
|
51
51
|
, test = 'test'
|
|
52
|
-
,
|
|
52
|
+
, scripts = 'scripts'
|
|
53
53
|
, husky = '.husky'
|
|
54
54
|
, docs = 'docs'
|
|
55
55
|
// Command line Options
|
|
@@ -376,7 +376,7 @@ function _addSrc(source, dest, folder, app, boilerlib) {
|
|
|
376
376
|
}
|
|
377
377
|
|
|
378
378
|
/**
|
|
379
|
-
* Adds the
|
|
379
|
+
* Adds the script files.
|
|
380
380
|
*
|
|
381
381
|
* @function (arg1, arg2, arg3, arg4, arg5)
|
|
382
382
|
* @private
|
|
@@ -387,7 +387,7 @@ function _addSrc(source, dest, folder, app, boilerlib) {
|
|
|
387
387
|
* @param {String} the name of the boilerplate,
|
|
388
388
|
* @returns {} -,
|
|
389
389
|
*/
|
|
390
|
-
function
|
|
390
|
+
function _addScripts(source, dest, folder, app, boilerlib) {
|
|
391
391
|
const exclude = []
|
|
392
392
|
, boiler = '{{boiler:name}}'
|
|
393
393
|
, ver = '{{boiler:name:version}}'
|
|
@@ -529,8 +529,8 @@ function _populate(options) {
|
|
|
529
529
|
// Copy the src files:
|
|
530
530
|
_addSrc(baseboiler, baseapp, src, app, boilerlib);
|
|
531
531
|
|
|
532
|
-
// Add
|
|
533
|
-
|
|
532
|
+
// Add scripts:
|
|
533
|
+
_addScripts(baseboiler, baseapp, scripts, app, boilerlib);
|
|
534
534
|
|
|
535
535
|
// Copy Test Files:
|
|
536
536
|
_addTest(baseboiler, baseapp, test, app, boilerlib);
|
package/package.json
CHANGED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* *****************************************************************************
|
|
3
|
+
*
|
|
4
|
+
* Does ...
|
|
5
|
+
*
|
|
6
|
+
* build:template script is a framework to build npm build scripts;
|
|
7
|
+
*
|
|
8
|
+
* Private Functions:
|
|
9
|
+
* . _help displays the help message,
|
|
10
|
+
* . _clean removes the previous build,
|
|
11
|
+
* . _dosomething creates something,
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* Public Static Methods:
|
|
15
|
+
* . run executes the script,
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* @namespace -
|
|
19
|
+
* @dependencies none
|
|
20
|
+
* @exports -
|
|
21
|
+
* @author -
|
|
22
|
+
* @since 0.0.0
|
|
23
|
+
* @version -
|
|
24
|
+
* ************************************************************************** */
|
|
25
|
+
/* eslint one-var: 0, semi-style: 0, no-underscore-dangle: 0,
|
|
26
|
+
import/no-extraneous-dependencies: 0 */
|
|
27
|
+
|
|
28
|
+
'use strict';
|
|
29
|
+
|
|
30
|
+
// -- Vendor Modules
|
|
31
|
+
const fs = require('fs')
|
|
32
|
+
, nopt = require('nopt')
|
|
33
|
+
;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// -- Local Modules
|
|
37
|
+
const config = require('./config')
|
|
38
|
+
;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// -- Local Constants
|
|
42
|
+
const VERSION = '0.0.0-alpha.0'
|
|
43
|
+
, opts = {
|
|
44
|
+
help: [Boolean, false],
|
|
45
|
+
version: [String, null],
|
|
46
|
+
}
|
|
47
|
+
, shortOpts = {
|
|
48
|
+
h: ['--help'],
|
|
49
|
+
v: ['--version', VERSION],
|
|
50
|
+
}
|
|
51
|
+
, parsed = nopt(opts, shortOpts, process.argv, 2)
|
|
52
|
+
, destination = config.libdir
|
|
53
|
+
;
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// -- Local Variables
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// -- Private Functions --------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Dispays the help message.
|
|
63
|
+
*
|
|
64
|
+
* @function ()
|
|
65
|
+
* @private
|
|
66
|
+
* @param {} -,
|
|
67
|
+
* @returns {} -,
|
|
68
|
+
* @since 0.0.0
|
|
69
|
+
*/
|
|
70
|
+
function _help() {
|
|
71
|
+
const message = ['',
|
|
72
|
+
'Usage: command [options]',
|
|
73
|
+
'',
|
|
74
|
+
' creates something from something',
|
|
75
|
+
'',
|
|
76
|
+
'Options:',
|
|
77
|
+
'',
|
|
78
|
+
'-h, --help output usage information',
|
|
79
|
+
'-v, --version output the version number',
|
|
80
|
+
'',
|
|
81
|
+
].join('\n');
|
|
82
|
+
|
|
83
|
+
process.stdout.write(`${message}\n`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Removes the previous build.
|
|
88
|
+
*
|
|
89
|
+
* @function ()
|
|
90
|
+
* @private
|
|
91
|
+
* @param {} -,
|
|
92
|
+
* @returns {Object} returns a promise,
|
|
93
|
+
* @since 0.0.0
|
|
94
|
+
*/
|
|
95
|
+
function _clean() {
|
|
96
|
+
const d1 = new Date();
|
|
97
|
+
process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
|
|
98
|
+
|
|
99
|
+
return new Promise((resolve) => {
|
|
100
|
+
fs.rm(destination, { force: true, recursive: true }, (err1) => {
|
|
101
|
+
if (err1) throw new Error(err1);
|
|
102
|
+
|
|
103
|
+
fs.mkdir(destination, { recursive: true }, (err2) => {
|
|
104
|
+
if (err2) throw new Error(err2);
|
|
105
|
+
|
|
106
|
+
const d2 = new Date() - d1;
|
|
107
|
+
process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
108
|
+
resolve();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Creates something else.
|
|
116
|
+
*
|
|
117
|
+
* @function (arg1)
|
|
118
|
+
* @private
|
|
119
|
+
* @param {Function} the function to call at the completion,
|
|
120
|
+
* @returns {} -,
|
|
121
|
+
* @since 0.0.0
|
|
122
|
+
*/
|
|
123
|
+
function _doparallel1(done) {
|
|
124
|
+
const d1 = new Date();
|
|
125
|
+
process.stdout.write('Starting \'\x1b[36mdoparallel1\x1b[89m\x1b[0m\'...\n');
|
|
126
|
+
|
|
127
|
+
fs.writeFile(`${destination}/generic1.js`, 'bla bla', { encoding: 'utf8' }, (err) => {
|
|
128
|
+
if (err) throw new Error(err);
|
|
129
|
+
|
|
130
|
+
const d2 = new Date() - d1;
|
|
131
|
+
process.stdout.write(`Finished '\x1b[36mdodoparallel1\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
132
|
+
done();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Creates something else.
|
|
138
|
+
*
|
|
139
|
+
* @function (arg1)
|
|
140
|
+
* @private
|
|
141
|
+
* @param {Function} the function to call at the completion,
|
|
142
|
+
* @returns {} -,
|
|
143
|
+
* @since 0.0.0
|
|
144
|
+
*/
|
|
145
|
+
function _doparallel2(done) {
|
|
146
|
+
const d1 = new Date();
|
|
147
|
+
process.stdout.write('Starting \'\x1b[36mdoparallel2\x1b[89m\x1b[0m\'...\n');
|
|
148
|
+
|
|
149
|
+
fs.writeFile(`${destination}/generic2.js`, 'bla bla', { encoding: 'utf8' }, (err) => {
|
|
150
|
+
if (err) throw new Error(err);
|
|
151
|
+
|
|
152
|
+
const d2 = new Date() - d1;
|
|
153
|
+
process.stdout.write(`Finished '\x1b[36mdodoparallel2\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
154
|
+
done();
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Removes the temp file(s).
|
|
160
|
+
*
|
|
161
|
+
* @function (arg1)
|
|
162
|
+
* @private
|
|
163
|
+
* @param {Function} the function to call at the completion,
|
|
164
|
+
* @returns {} -,
|
|
165
|
+
* @since 0.0.0
|
|
166
|
+
*/
|
|
167
|
+
function _delgeneric(done) {
|
|
168
|
+
const d1 = new Date();
|
|
169
|
+
process.stdout.write('Starting \'\x1b[36mdelgeneric\x1b[89m\x1b[0m\'...\n');
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Wait all the processes are completed.
|
|
173
|
+
*/
|
|
174
|
+
let pending = 2;
|
|
175
|
+
function _next() {
|
|
176
|
+
pending -= 1;
|
|
177
|
+
if (!pending) {
|
|
178
|
+
const d2 = new Date() - d1;
|
|
179
|
+
process.stdout.write(`Finished '\x1b[36mdelgeneric\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
180
|
+
done();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
fs.unlink(`${destination}/generic1.js`, (err) => {
|
|
185
|
+
if (err) throw new Error(err);
|
|
186
|
+
_next();
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
fs.unlink(`${destination}/generic2.js`, (err) => {
|
|
190
|
+
if (err) throw new Error(err);
|
|
191
|
+
_next();
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
// -- Main ---------------------------------------------------------------------
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Executes the script.
|
|
200
|
+
*
|
|
201
|
+
* @function ()
|
|
202
|
+
* @public
|
|
203
|
+
* @param {} -,
|
|
204
|
+
* @returns {} -,
|
|
205
|
+
* @since 0.0.0
|
|
206
|
+
*/
|
|
207
|
+
async function run() {
|
|
208
|
+
const PENDING = 2;
|
|
209
|
+
|
|
210
|
+
if (parsed.help) {
|
|
211
|
+
_help();
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (parsed.version) {
|
|
216
|
+
process.stdout.write(`version: ${parsed.version}\n`);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const d1 = new Date();
|
|
221
|
+
process.stdout.write('Starting \'\x1b[36mbuild:xxx:yyy\x1b[89m\x1b[0m\'...\n');
|
|
222
|
+
|
|
223
|
+
let pending = PENDING;
|
|
224
|
+
/**
|
|
225
|
+
* Executes done until completion.
|
|
226
|
+
*/
|
|
227
|
+
function done() {
|
|
228
|
+
pending -= 1;
|
|
229
|
+
if (!pending) {
|
|
230
|
+
_delgeneric(() => {
|
|
231
|
+
const d2 = new Date() - d1;
|
|
232
|
+
process.stdout.write(`Finished '\x1b[36mbuild:xxx:yyy\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
await _clean();
|
|
238
|
+
_doparallel1(done);
|
|
239
|
+
_doparallel2(done);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
// Start script.
|
|
244
|
+
run();
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
// -- oOo --
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* *****************************************************************************
|
|
3
|
+
*
|
|
4
|
+
* Creates the JS bundle.
|
|
5
|
+
*
|
|
6
|
+
* build:js.dev script creates the JS bundle from ./public/src/main.js by importing
|
|
7
|
+
* all the linked src files;
|
|
8
|
+
*
|
|
9
|
+
* Private Functions:
|
|
10
|
+
* . _help displays the help message,
|
|
11
|
+
* . _clean removes the previous build,
|
|
12
|
+
* . _docore creates the content of the library,
|
|
13
|
+
* . _doumdlib creates the UMD Module,
|
|
14
|
+
* . _domodule creates the ES6 module,
|
|
15
|
+
* . _delcore removes the temp file(s),
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* Public Static Methods:
|
|
19
|
+
* . run executes the script,
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
* @namespace -
|
|
23
|
+
* @dependencies none
|
|
24
|
+
* @exports -
|
|
25
|
+
* @author -
|
|
26
|
+
* @since 0.0.0
|
|
27
|
+
* @version -
|
|
28
|
+
* ************************************************************************** */
|
|
29
|
+
/* eslint one-var: 0, semi-style: 0, no-underscore-dangle: 0 */
|
|
30
|
+
|
|
31
|
+
'use strict';
|
|
32
|
+
|
|
33
|
+
// -- Vendor Modules
|
|
34
|
+
const fs = require('fs')
|
|
35
|
+
, nopt = require('nopt')
|
|
36
|
+
;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
// -- Local Modules
|
|
40
|
+
const pack = require('../package.json')
|
|
41
|
+
, config = require('./config')
|
|
42
|
+
;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// -- Local Constants
|
|
46
|
+
const VERSION = '0.0.0-alpha.0'
|
|
47
|
+
, opts = {
|
|
48
|
+
help: [Boolean, false],
|
|
49
|
+
version: [String, null],
|
|
50
|
+
}
|
|
51
|
+
, shortOpts = {
|
|
52
|
+
h: ['--help'],
|
|
53
|
+
v: ['--version', VERSION],
|
|
54
|
+
}
|
|
55
|
+
, parsed = nopt(opts, shortOpts, process.argv, 2)
|
|
56
|
+
, destination = config.libdir
|
|
57
|
+
, { ES6GLOB } = config
|
|
58
|
+
, source = config.src
|
|
59
|
+
, { libname } = config
|
|
60
|
+
, { name } = config
|
|
61
|
+
, head = source[0]
|
|
62
|
+
, core = source.slice(1, -1)
|
|
63
|
+
, foot = source[source.length - 1]
|
|
64
|
+
, { version } = pack
|
|
65
|
+
;
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// -- Local Variables
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
// -- Private Functions --------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Dispays the help message.
|
|
75
|
+
*
|
|
76
|
+
* @function ()
|
|
77
|
+
* @private
|
|
78
|
+
* @param {} -,
|
|
79
|
+
* @returns {} -,
|
|
80
|
+
* @since 0.0.0
|
|
81
|
+
*/
|
|
82
|
+
function _help() {
|
|
83
|
+
const message = ['',
|
|
84
|
+
'Usage: command [options]',
|
|
85
|
+
'',
|
|
86
|
+
' creates the js bundle from ./public/src/main.js',
|
|
87
|
+
'',
|
|
88
|
+
'Options:',
|
|
89
|
+
'',
|
|
90
|
+
'-h, --help output usage information',
|
|
91
|
+
'-v, --version output the version number',
|
|
92
|
+
'',
|
|
93
|
+
].join('\n');
|
|
94
|
+
|
|
95
|
+
process.stdout.write(`${message}\n`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Removes the previous build.
|
|
100
|
+
*
|
|
101
|
+
* @function ()
|
|
102
|
+
* @private
|
|
103
|
+
* @param {} -,
|
|
104
|
+
* @returns {} -,
|
|
105
|
+
* @since 0.0.0
|
|
106
|
+
*/
|
|
107
|
+
function _clean() {
|
|
108
|
+
const d1 = new Date();
|
|
109
|
+
process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
|
|
110
|
+
|
|
111
|
+
fs.rmSync(destination, { force: true, recursive: true });
|
|
112
|
+
fs.mkdirSync(destination, { recursive: true });
|
|
113
|
+
|
|
114
|
+
const d2 = new Date() - d1;
|
|
115
|
+
process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Creates the content of the library.
|
|
120
|
+
*
|
|
121
|
+
* @function ()
|
|
122
|
+
* @private
|
|
123
|
+
* @param {} -,
|
|
124
|
+
* @returns {} -,
|
|
125
|
+
* @since 0.0.0
|
|
126
|
+
*/
|
|
127
|
+
function _docore() {
|
|
128
|
+
const d1 = new Date();
|
|
129
|
+
process.stdout.write('Starting \'\x1b[36mdocore\x1b[89m\x1b[0m\'...\n');
|
|
130
|
+
|
|
131
|
+
let src = '';
|
|
132
|
+
for (let i = 0; i < core.length; i++) {
|
|
133
|
+
src += fs.readFileSync(core[i]);
|
|
134
|
+
if (i < core.length - 1) {
|
|
135
|
+
src += '\n';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
src = src
|
|
140
|
+
.replace(/{{lib:name}}/g, libname)
|
|
141
|
+
.replace(/{{lib:version}}/g, version)
|
|
142
|
+
// remove the extra global and 'use strict':
|
|
143
|
+
.replace(/\/\* global[\w$_\s,]+\*\//g, '/* - */')
|
|
144
|
+
.replace(/\n'use strict';\n/g, '')
|
|
145
|
+
// indent the first line with 2 spaces:
|
|
146
|
+
.replace(/^/g, ' ')
|
|
147
|
+
// indent each other lines with 2 spaces:
|
|
148
|
+
.replace(/\n/g, '\n ')
|
|
149
|
+
;
|
|
150
|
+
|
|
151
|
+
fs.writeFileSync(`${destination}/core.js`, src);
|
|
152
|
+
const d2 = new Date() - d1;
|
|
153
|
+
process.stdout.write(`Finished '\x1b[36mdocore\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Creates the UMD Module.
|
|
158
|
+
*
|
|
159
|
+
* @function ()
|
|
160
|
+
* @private
|
|
161
|
+
* @param {} -,
|
|
162
|
+
* @returns {} -,
|
|
163
|
+
* @since 0.0.0
|
|
164
|
+
*/
|
|
165
|
+
function _doumdlib() {
|
|
166
|
+
const d1 = new Date();
|
|
167
|
+
process.stdout.write('Starting \'\x1b[36mdoumdlib\x1b[89m\x1b[0m\'...\n');
|
|
168
|
+
|
|
169
|
+
let src = '';
|
|
170
|
+
src = fs.readFileSync(head);
|
|
171
|
+
src += '\n';
|
|
172
|
+
src += fs.readFileSync(`${destination}/core.js`);
|
|
173
|
+
src += '\n';
|
|
174
|
+
src += fs.readFileSync(foot);
|
|
175
|
+
|
|
176
|
+
src = src
|
|
177
|
+
.replace('{{lib:es6:define}}\n', '')
|
|
178
|
+
.replace('{{lib:es6:link}}', 'this')
|
|
179
|
+
.replace('{{lib:es6:export}}\n', '')
|
|
180
|
+
// fix the blanck lines we indented too:
|
|
181
|
+
.replace(/\s{2}\n/g, '\n')
|
|
182
|
+
;
|
|
183
|
+
|
|
184
|
+
fs.writeFileSync(`${destination}/${name}.js`, src);
|
|
185
|
+
const d2 = new Date() - d1;
|
|
186
|
+
process.stdout.write(`Finished '\x1b[36mdoumdlib\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Creates the ES6 module.
|
|
191
|
+
*
|
|
192
|
+
* @function ()
|
|
193
|
+
* @private
|
|
194
|
+
* @param {} -,
|
|
195
|
+
* @returns {} -,
|
|
196
|
+
* @since 0.0.0
|
|
197
|
+
*/
|
|
198
|
+
function _domodule() {
|
|
199
|
+
const d1 = new Date();
|
|
200
|
+
process.stdout.write('Starting \'\x1b[36mdomodule\x1b[89m\x1b[0m\'...\n');
|
|
201
|
+
|
|
202
|
+
let exportM = '\n// -- Export\n';
|
|
203
|
+
exportM += `export default ${ES6GLOB}.${libname};`;
|
|
204
|
+
|
|
205
|
+
let src = '';
|
|
206
|
+
src = fs.readFileSync(head);
|
|
207
|
+
src += '\n';
|
|
208
|
+
src += fs.readFileSync(`${destination}/core.js`);
|
|
209
|
+
src += '\n';
|
|
210
|
+
src += fs.readFileSync(foot);
|
|
211
|
+
|
|
212
|
+
src = src
|
|
213
|
+
.replace('{{lib:es6:define}}', `const ${ES6GLOB} = {};`)
|
|
214
|
+
.replace('{{lib:es6:link}}', ES6GLOB)
|
|
215
|
+
.replace('{{lib:es6:export}}', exportM)
|
|
216
|
+
// fix the blanck lines we indented too:
|
|
217
|
+
.replace(/\s{2}\n/g, '\n')
|
|
218
|
+
;
|
|
219
|
+
|
|
220
|
+
fs.writeFileSync(`${destination}/${name}.mjs`, src);
|
|
221
|
+
const d2 = new Date() - d1;
|
|
222
|
+
process.stdout.write(`Finished '\x1b[36mdomodule\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Removes the temp file(s).
|
|
227
|
+
*
|
|
228
|
+
* @function ()
|
|
229
|
+
* @private
|
|
230
|
+
* @param {} -,
|
|
231
|
+
* @returns {} -,
|
|
232
|
+
* @since 0.0.0
|
|
233
|
+
*/
|
|
234
|
+
function _delcore() {
|
|
235
|
+
const d1 = new Date();
|
|
236
|
+
process.stdout.write('Starting \'\x1b[36mdelcore\x1b[89m\x1b[0m\'...\n');
|
|
237
|
+
fs.unlinkSync(`${destination}/core.js`);
|
|
238
|
+
|
|
239
|
+
const d2 = new Date() - d1;
|
|
240
|
+
process.stdout.write(`Finished '\x1b[36mdelcore\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
// -- Main ---------------------------------------------------------------------
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Executes the script.
|
|
248
|
+
*
|
|
249
|
+
* @function ()
|
|
250
|
+
* @public
|
|
251
|
+
* @param {} -,
|
|
252
|
+
* @returns {} -,
|
|
253
|
+
* @since 0.0.0
|
|
254
|
+
*/
|
|
255
|
+
function run() {
|
|
256
|
+
if (parsed.help) {
|
|
257
|
+
_help();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (parsed.version) {
|
|
262
|
+
process.stdout.write(`version: ${parsed.version}\n`);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const d1 = new Date();
|
|
267
|
+
process.stdout.write('Starting \'\x1b[36mbuild:js:dev\x1b[89m\x1b[0m\'...\n');
|
|
268
|
+
|
|
269
|
+
_clean();
|
|
270
|
+
_docore();
|
|
271
|
+
_doumdlib();
|
|
272
|
+
_domodule();
|
|
273
|
+
_delcore();
|
|
274
|
+
|
|
275
|
+
const d2 = new Date() - d1;
|
|
276
|
+
process.stdout.write(`Finished '\x1b[36mbuild:js:dev\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
// Start script.
|
|
281
|
+
run();
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
// -- oOo --
|