@mobilabs/es6lib 2.2.0 → 2.2.2
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/_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/package.json +10 -10
- package/scripts/_build.template.js +55 -51
- package/scripts/build.js.dev.js +34 -31
- package/scripts/build.js.prod.js +95 -92
- package/scripts/build.skeleton.prod.js +49 -45
- package/scripts/compress.sh +3 -0
- package/scripts/config.js +15 -0
- package/scripts/dep.private.js +47 -43
- package/test/index.html +7 -19
- package/test/int/libbasic.js +3 -0
- package/test/int/libfunctional.js +3 -0
- package/test/int/libprototypal.js +3 -0
- package/test/main.js +3 -0
- package/scripts/_old_build.js.dev.js +0 -284
- package/scripts/_old_build.js.prod.js +0 -294
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/* *****************************************************************************
|
|
3
|
-
*
|
|
4
|
-
* Creates the production JS files.
|
|
5
|
-
*
|
|
6
|
-
* build:js:prod.js script minifies JS files and copies them in the
|
|
7
|
-
* production folder.
|
|
8
|
-
*
|
|
9
|
-
* Private Functions:
|
|
10
|
-
* . _help displays the help message,
|
|
11
|
-
* . _clean removes the previous js production files,
|
|
12
|
-
* . _copydev builds the js production file,
|
|
13
|
-
* . _copydevm builds the ES6 module production file,
|
|
14
|
-
* . _makeminified builds and minifies the js production file,
|
|
15
|
-
* . _makeminifiedm builds and minifies the ES6 module production file,
|
|
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
|
-
import/no-extraneous-dependencies: 0 */
|
|
31
|
-
|
|
32
|
-
'use strict';
|
|
33
|
-
|
|
34
|
-
// -- Vendor Modules
|
|
35
|
-
const fs = require('fs')
|
|
36
|
-
, nopt = require('nopt')
|
|
37
|
-
, { minify } = require('terser')
|
|
38
|
-
;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// -- Local Modules
|
|
42
|
-
const config = require('./config')
|
|
43
|
-
;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// -- Local Constants
|
|
47
|
-
const VERSION = '0.0.0-alpha.0'
|
|
48
|
-
, opts = {
|
|
49
|
-
help: [Boolean, false],
|
|
50
|
-
version: [String, null],
|
|
51
|
-
}
|
|
52
|
-
, shortOpts = {
|
|
53
|
-
h: ['--help'],
|
|
54
|
-
v: ['--version', VERSION],
|
|
55
|
-
}
|
|
56
|
-
, parsed = nopt(opts, shortOpts, process.argv, 2)
|
|
57
|
-
, { dist } = config
|
|
58
|
-
, { libdir } = config
|
|
59
|
-
, { name } = config
|
|
60
|
-
, { license } = config
|
|
61
|
-
;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// -- Local Variables
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// -- Private Functions --------------------------------------------------------
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Dispays the help message.
|
|
71
|
-
*
|
|
72
|
-
* @function ()
|
|
73
|
-
* @private
|
|
74
|
-
* @param {} -,
|
|
75
|
-
* @returns {} -,
|
|
76
|
-
* @since 0.0.0
|
|
77
|
-
*/
|
|
78
|
-
function _help() {
|
|
79
|
-
const message = ['',
|
|
80
|
-
'Usage: command [options]',
|
|
81
|
-
'',
|
|
82
|
-
' creates the js production files',
|
|
83
|
-
'',
|
|
84
|
-
'Options:',
|
|
85
|
-
'',
|
|
86
|
-
'-h, --help output usage information',
|
|
87
|
-
'-v, --version output the version number',
|
|
88
|
-
'',
|
|
89
|
-
].join('\n');
|
|
90
|
-
|
|
91
|
-
process.stdout.write(`${message}\n`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Removes the previous js production build.
|
|
96
|
-
*
|
|
97
|
-
* @function ()
|
|
98
|
-
* @private
|
|
99
|
-
* @param {} -,
|
|
100
|
-
* @returns {} -,
|
|
101
|
-
* @since 0.0.0
|
|
102
|
-
*/
|
|
103
|
-
function _clean() {
|
|
104
|
-
const d1 = new Date();
|
|
105
|
-
process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
|
|
106
|
-
|
|
107
|
-
return new Promise((resolve) => {
|
|
108
|
-
fs.rm(`${dist}/lib`, { force: true, recursive: true }, (err1) => {
|
|
109
|
-
if (err1) throw new Error(err1);
|
|
110
|
-
|
|
111
|
-
fs.mkdir(`${dist}/lib`, { recursive: true }, (err2) => {
|
|
112
|
-
if (err2) throw new Error(err2);
|
|
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
|
-
resolve();
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Builds the js production file.
|
|
124
|
-
*
|
|
125
|
-
* @function (arg1)
|
|
126
|
-
* @private
|
|
127
|
-
* @param {Function} the function to call at the completion,
|
|
128
|
-
* @returns {} -,
|
|
129
|
-
* @since 0.0.0
|
|
130
|
-
*/
|
|
131
|
-
function _copydev(done) {
|
|
132
|
-
const d1 = new Date();
|
|
133
|
-
process.stdout.write('Starting \'\x1b[36mcopydev\x1b[89m\x1b[0m\'...\n');
|
|
134
|
-
|
|
135
|
-
fs.readFile(`${libdir}/${name}.js`, 'utf8', (err1, data) => {
|
|
136
|
-
if (err1) throw new Error(err1);
|
|
137
|
-
|
|
138
|
-
let content = license;
|
|
139
|
-
content += data;
|
|
140
|
-
fs.writeFile(`${dist}/lib/${name}.js`, content, { encoding: 'utf8' }, (err2) => {
|
|
141
|
-
if (err2) throw new Error(err2);
|
|
142
|
-
|
|
143
|
-
const d2 = new Date() - d1;
|
|
144
|
-
process.stdout.write(`Finished '\x1b[36mcopydev\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
145
|
-
done();
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Builds the ES6 module production file.
|
|
152
|
-
*
|
|
153
|
-
* @function (arg1)
|
|
154
|
-
* @private
|
|
155
|
-
* @param {Function} the function to call at the completion,
|
|
156
|
-
* @returns {} -,
|
|
157
|
-
* @since 0.0.0
|
|
158
|
-
*/
|
|
159
|
-
function _copydevm(done) {
|
|
160
|
-
const d1 = new Date();
|
|
161
|
-
process.stdout.write('Starting \'\x1b[36mcopydevm\x1b[89m\x1b[0m\'...\n');
|
|
162
|
-
|
|
163
|
-
fs.readFile(`${libdir}/${name}.mjs`, 'utf8', (err1, data) => {
|
|
164
|
-
if (err1) throw new Error(err1);
|
|
165
|
-
|
|
166
|
-
let content = license;
|
|
167
|
-
content += data;
|
|
168
|
-
fs.writeFile(`${dist}/lib/${name}.mjs`, content, { encoding: 'utf8' }, (err2) => {
|
|
169
|
-
if (err2) throw new Error(err2);
|
|
170
|
-
|
|
171
|
-
const d2 = new Date() - d1;
|
|
172
|
-
process.stdout.write(`Finished '\x1b[36mcopydevm\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
173
|
-
done();
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Builds and minifies the js production file.
|
|
180
|
-
*
|
|
181
|
-
* @function (arg1)
|
|
182
|
-
* @private
|
|
183
|
-
* @param {Function} the function to call at the completion,
|
|
184
|
-
* @returns {} -,
|
|
185
|
-
* @since 0.0.0
|
|
186
|
-
*/
|
|
187
|
-
function _makeminified(done) {
|
|
188
|
-
const d1 = new Date();
|
|
189
|
-
process.stdout.write('Starting \'\x1b[36mmakeminified\x1b[89m\x1b[0m\'...\n');
|
|
190
|
-
|
|
191
|
-
fs.readFile(`${libdir}/${name}.js`, 'utf8', (err1, data) => {
|
|
192
|
-
if (err1) throw new Error(err1);
|
|
193
|
-
|
|
194
|
-
let content = license;
|
|
195
|
-
content += data.replace(/\/\*! \*\*\*/g, '/** ***');
|
|
196
|
-
|
|
197
|
-
minify(content, {})
|
|
198
|
-
.then((result) => {
|
|
199
|
-
fs.writeFile(`${dist}/lib/${name}.min.js`, result.code, { encoding: 'utf8' }, (err2) => {
|
|
200
|
-
if (err2) throw new Error(err2);
|
|
201
|
-
|
|
202
|
-
const d2 = new Date() - d1;
|
|
203
|
-
process.stdout.write(`Finished '\x1b[36mmakeminified\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
204
|
-
done();
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Builds and minifies the ES6 module production file.
|
|
212
|
-
*
|
|
213
|
-
* @function (arg1)
|
|
214
|
-
* @private
|
|
215
|
-
* @param {Function} the function to call at the completion,
|
|
216
|
-
* @returns {} -,
|
|
217
|
-
* @since 0.0.0
|
|
218
|
-
*/
|
|
219
|
-
function _makeminifiedm(done) {
|
|
220
|
-
const d1 = new Date();
|
|
221
|
-
process.stdout.write('Starting \'\x1b[36mmakeminified\x1b[89m\x1b[0m\'...\n');
|
|
222
|
-
|
|
223
|
-
fs.readFile(`${libdir}/${name}.mjs`, 'utf8', (err1, data) => {
|
|
224
|
-
if (err1) throw new Error(err1);
|
|
225
|
-
|
|
226
|
-
let content = license;
|
|
227
|
-
content += data.replace(/\/\*! \*\*\*/g, '/** ***');
|
|
228
|
-
|
|
229
|
-
minify(content, {})
|
|
230
|
-
.then((result) => {
|
|
231
|
-
fs.writeFile(`${dist}/lib/${name}.min.mjs`, result.code, { encoding: 'utf8' }, (err2) => {
|
|
232
|
-
if (err2) throw new Error(err2);
|
|
233
|
-
|
|
234
|
-
const d2 = new Date() - d1;
|
|
235
|
-
process.stdout.write(`Finished '\x1b[36mmakeminified\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
236
|
-
done();
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
// -- Main ---------------------------------------------------------------------
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Executes the script.
|
|
247
|
-
*
|
|
248
|
-
* @function ()
|
|
249
|
-
* @public
|
|
250
|
-
* @param {} -,
|
|
251
|
-
* @returns {} -,
|
|
252
|
-
* @since 0.0.0
|
|
253
|
-
*/
|
|
254
|
-
async function run() {
|
|
255
|
-
const PENDING = 4;
|
|
256
|
-
|
|
257
|
-
if (parsed.help) {
|
|
258
|
-
_help();
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (parsed.version) {
|
|
263
|
-
process.stdout.write(`version: ${parsed.version}\n`);
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const d1 = new Date();
|
|
268
|
-
process.stdout.write('Starting \'\x1b[36mbuild:js:prod\x1b[89m\x1b[0m\'...\n');
|
|
269
|
-
|
|
270
|
-
let pending = PENDING;
|
|
271
|
-
/**
|
|
272
|
-
* Executes done until completion.
|
|
273
|
-
*/
|
|
274
|
-
function done() {
|
|
275
|
-
pending -= 1;
|
|
276
|
-
if (!pending) {
|
|
277
|
-
const d2 = new Date() - d1;
|
|
278
|
-
process.stdout.write(`Finished '\x1b[36mbuild:js:prod\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
await _clean();
|
|
283
|
-
_copydev(done);
|
|
284
|
-
_copydevm(done);
|
|
285
|
-
_makeminified(done);
|
|
286
|
-
_makeminifiedm(done);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
// Start script.
|
|
291
|
-
run();
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
// -- oOo --
|