@mobilabs/es6lib 2.1.3 → 2.2.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/_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/_old_build.js.dev.js +284 -0
- package/scripts/_old_build.js.prod.js +294 -0
- package/scripts/build.js.dev.js +133 -97
- package/scripts/build.js.prod.js +85 -59
- package/test/index.html +6 -18
package/_dist/lib/es6lib.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! ****************************************************************************
|
|
2
|
-
* ES6lib v2.1
|
|
2
|
+
* ES6lib v2.2.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.2.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.2.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.2.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.2.1"},t},e.NAME="ES6lib",e.VERSION="2.2.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.2.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.2.1"},t},e.NAME="ES6lib",e.VERSION="2.2.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.2.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.2.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.2.1';
|
|
325
325
|
|
|
326
326
|
|
|
327
327
|
// -- Private Static Methods -----------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobilabs/es6lib",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "A template for writing pure ES6 Javascript libraries",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"minified": "_dist/lib/es6lib.min.js",
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"general": " --- GENERAL ---",
|
|
14
14
|
|
|
15
|
-
"build:js": " --- JAVASCRIPT --- ",
|
|
15
|
+
"build:js": " --- BUILDING JAVASCRIPT --- ",
|
|
16
16
|
"build:js:dev": "node scripts/build.js.dev.js $1",
|
|
17
17
|
"build:js:prod": "node scripts/build.js.prod.js $1",
|
|
18
18
|
|
|
19
|
-
"build:css": " --- CSS --- ",
|
|
19
|
+
"build:css": " --- BUILDING CSS --- ",
|
|
20
20
|
|
|
21
|
-
"build:generic": " ---
|
|
21
|
+
"build:generic": " --- BUILDING (GENERIC) --- ",
|
|
22
22
|
|
|
23
|
-
"build:development": " ---
|
|
23
|
+
"build:development": " --- BUILDING (DEVELOPMENT) --- ",
|
|
24
24
|
"build:dev": "npm run build:js:dev",
|
|
25
25
|
|
|
26
|
-
"build:production": " ---
|
|
26
|
+
"build:production": " --- BUILDING (PRODUCTION) --- ",
|
|
27
27
|
"build:skeleton:prod": "node scripts/build.skeleton.prod.js $1",
|
|
28
28
|
"prebuild:prod": "npm run build:dev && npm run build:skeleton:prod",
|
|
29
29
|
"build:prod": "npm run build:js:prod",
|
|
@@ -42,14 +42,13 @@
|
|
|
42
42
|
"watch:js": "nodemon --watch './src/**/*.js' --exec npm run build:dev",
|
|
43
43
|
"watch": "npm run watch:js",
|
|
44
44
|
|
|
45
|
-
"deployment": " ---
|
|
45
|
+
"deployment": " --- DEPLOYING --- ",
|
|
46
46
|
"dep:prod": "rm -rf _dist-$npm_package_version && npm run build:prod && cp -r _dist _dist-$npm_package_version",
|
|
47
47
|
"dep:private:package": "npm run build:prod && node scripts/dep.private.js && sh scripts/compress.sh ${npm_package_name} ${npm_package_version} @mobilabs",
|
|
48
|
-
"dep:npm:private:package": "npm pack && sh scripts/dep.npm.private.sh ${npm_package_name} ${npm_package_version} @mobilabs",
|
|
48
|
+
"dep:npm:private:package": "npm run build:prod && npm pack && sh scripts/dep.npm.private.sh ${npm_package_name} ${npm_package_version} @mobilabs",
|
|
49
49
|
|
|
50
50
|
"others": " --- OTHERS ---",
|
|
51
|
-
"prepare": "husky install"
|
|
52
|
-
"doc": ""
|
|
51
|
+
"prepare": "husky install"
|
|
53
52
|
},
|
|
54
53
|
"repository": {
|
|
55
54
|
"type": "git",
|
|
@@ -85,6 +84,7 @@
|
|
|
85
84
|
"eslint": "^8.56.0",
|
|
86
85
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
87
86
|
"eslint-plugin-import": "^2.29.1",
|
|
87
|
+
"http-server": "^14.1.1",
|
|
88
88
|
"husky": "^8.0.3",
|
|
89
89
|
"mocha": "^10.2.0",
|
|
90
90
|
"nodemon": "^3.0.2",
|
|
@@ -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 --
|
|
@@ -0,0 +1,294 @@
|
|
|
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 --
|
package/scripts/build.js.dev.js
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* Private Functions:
|
|
10
10
|
* . _help displays the help message,
|
|
11
11
|
* . _clean removes the previous build,
|
|
12
|
-
* .
|
|
13
|
-
* .
|
|
14
|
-
* .
|
|
15
|
-
* .
|
|
12
|
+
* . _doES6 creates the ES6 module,
|
|
13
|
+
* . _doUMD creates the UMD library,
|
|
14
|
+
* . _doLib creates one UMD/ES6 library,
|
|
15
|
+
* . _doLibs creates all UMD/ES6 libraries,
|
|
16
16
|
*
|
|
17
17
|
*
|
|
18
18
|
* Public Static Methods:
|
|
@@ -55,12 +55,9 @@ const VERSION = '0.0.0-alpha.0'
|
|
|
55
55
|
, parsed = nopt(opts, shortOpts, process.argv, 2)
|
|
56
56
|
, destination = config.libdir
|
|
57
57
|
, { ES6GLOB } = config
|
|
58
|
-
,
|
|
58
|
+
, { src } = config
|
|
59
59
|
, { libname } = config
|
|
60
60
|
, { name } = config
|
|
61
|
-
, head = source[0]
|
|
62
|
-
, core = source.slice(1, -1)
|
|
63
|
-
, foot = source[source.length - 1]
|
|
64
61
|
, { version } = pack
|
|
65
62
|
;
|
|
66
63
|
|
|
@@ -98,82 +95,96 @@ function _help() {
|
|
|
98
95
|
/**
|
|
99
96
|
* Removes the previous build.
|
|
100
97
|
*
|
|
101
|
-
* @function ()
|
|
98
|
+
* @function (arg1)
|
|
102
99
|
* @private
|
|
103
|
-
* @param {}
|
|
100
|
+
* @param {Function} the function to call at the completion,
|
|
104
101
|
* @returns {} -,
|
|
105
102
|
* @since 0.0.0
|
|
106
103
|
*/
|
|
107
|
-
function _clean() {
|
|
104
|
+
function _clean(done) {
|
|
108
105
|
const d1 = new Date();
|
|
109
106
|
process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
|
|
110
107
|
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
return new Promise((resolve) => {
|
|
109
|
+
fs.rm(destination, { force: true, recursive: true }, (err1) => {
|
|
110
|
+
if (err1) throw new Error(err1);
|
|
113
111
|
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
fs.mkdir(destination, { recursive: true }, (err2) => {
|
|
113
|
+
if (err2) throw new Error(err2);
|
|
114
|
+
|
|
115
|
+
const d2 = new Date() - d1;
|
|
116
|
+
process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
117
|
+
resolve();
|
|
118
|
+
if (done) done();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
/**
|
|
119
|
-
* Creates the
|
|
125
|
+
* Creates the ES6 module.
|
|
120
126
|
*
|
|
121
|
-
* @function ()
|
|
127
|
+
* @function (arg1, arg2, arg3, arg4)
|
|
122
128
|
* @private
|
|
123
|
-
* @param {}
|
|
129
|
+
* @param {String} the header of the library,
|
|
130
|
+
* @param {String} the content of the library,
|
|
131
|
+
* @param {String} the footer of the library,
|
|
132
|
+
* @param {Function} the function to call at the completion,
|
|
124
133
|
* @returns {} -,
|
|
125
134
|
* @since 0.0.0
|
|
126
135
|
*/
|
|
127
|
-
function
|
|
136
|
+
function _doES6(head, core, foot, done) {
|
|
128
137
|
const d1 = new Date();
|
|
129
|
-
process.stdout.write('Starting \'\x1b[
|
|
138
|
+
process.stdout.write('Starting \'\x1b[36mdo:es6\x1b[89m\x1b[0m\'...\n');
|
|
130
139
|
|
|
131
|
-
let
|
|
132
|
-
|
|
133
|
-
src += fs.readFileSync(core[i]);
|
|
134
|
-
if (i < core.length - 1) {
|
|
135
|
-
src += '\n';
|
|
136
|
-
}
|
|
137
|
-
}
|
|
140
|
+
let exportM = '\n// -- Export\n';
|
|
141
|
+
exportM += `export default ${ES6GLOB}.${libname};`;
|
|
138
142
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
.replace(
|
|
147
|
-
|
|
148
|
-
.replace(
|
|
143
|
+
let lib = head;
|
|
144
|
+
lib += '\n';
|
|
145
|
+
lib += core;
|
|
146
|
+
lib += '\n';
|
|
147
|
+
lib += foot;
|
|
148
|
+
|
|
149
|
+
lib = lib
|
|
150
|
+
.replace('{{lib:es6:define}}', `const ${ES6GLOB} = {};`)
|
|
151
|
+
.replace('{{lib:es6:link}}', ES6GLOB)
|
|
152
|
+
.replace('{{lib:es6:export}}', exportM)
|
|
153
|
+
// fix the blanck lines we indented too:
|
|
154
|
+
.replace(/\s{2}\n/g, '\n')
|
|
149
155
|
;
|
|
150
156
|
|
|
151
|
-
fs.
|
|
152
|
-
|
|
153
|
-
|
|
157
|
+
fs.writeFile(`${destination}/${name}.mjs`, lib, { encoding: 'utf8' }, (err) => {
|
|
158
|
+
if (err) throw new Error(err);
|
|
159
|
+
const d2 = new Date() - d1;
|
|
160
|
+
process.stdout.write(`Finished '\x1b[36mdo:es6\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
161
|
+
done();
|
|
162
|
+
});
|
|
154
163
|
}
|
|
155
164
|
|
|
156
165
|
/**
|
|
157
|
-
* Creates the UMD
|
|
166
|
+
* Creates the UMD library.
|
|
158
167
|
*
|
|
159
|
-
* @function ()
|
|
168
|
+
* @function (arg1, arg2, arg3, arg4)
|
|
160
169
|
* @private
|
|
161
|
-
* @param {}
|
|
170
|
+
* @param {String} the header of the library,
|
|
171
|
+
* @param {String} the content of the library,
|
|
172
|
+
* @param {String} the footer of the library,
|
|
173
|
+
* @param {Function} the function to call at the completion,
|
|
162
174
|
* @returns {} -,
|
|
163
175
|
* @since 0.0.0
|
|
164
176
|
*/
|
|
165
|
-
function
|
|
177
|
+
function _doUMD(head, core, foot, done) {
|
|
166
178
|
const d1 = new Date();
|
|
167
|
-
process.stdout.write(
|
|
179
|
+
process.stdout.write("Starting '\x1b[36mdo:umd\x1b[89m\x1b[0m'...\n");
|
|
168
180
|
|
|
169
|
-
let
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
src += fs.readFileSync(foot);
|
|
181
|
+
let lib = head;
|
|
182
|
+
lib += '\n';
|
|
183
|
+
lib += core;
|
|
184
|
+
lib += '\n';
|
|
185
|
+
lib += foot;
|
|
175
186
|
|
|
176
|
-
|
|
187
|
+
lib = lib
|
|
177
188
|
.replace('{{lib:es6:define}}\n', '')
|
|
178
189
|
.replace('{{lib:es6:link}}', 'this')
|
|
179
190
|
.replace('{{lib:es6:export}}\n', '')
|
|
@@ -181,63 +192,90 @@ function _doumdlib() {
|
|
|
181
192
|
.replace(/\s{2}\n/g, '\n')
|
|
182
193
|
;
|
|
183
194
|
|
|
184
|
-
fs.
|
|
185
|
-
|
|
186
|
-
|
|
195
|
+
fs.writeFile(`${destination}/${name}.js`, lib, { encoding: 'utf8' }, (err) => {
|
|
196
|
+
if (err) throw new Error(err);
|
|
197
|
+
const d2 = new Date() - d1;
|
|
198
|
+
process.stdout.write(`Finished '\x1b[36mdo:umd\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
199
|
+
done();
|
|
200
|
+
});
|
|
187
201
|
}
|
|
188
202
|
|
|
189
203
|
/**
|
|
190
|
-
* Creates
|
|
204
|
+
* Creates one UMD/ES6 library.
|
|
191
205
|
*
|
|
192
|
-
* @function ()
|
|
206
|
+
* @function (arg1, arg2)
|
|
193
207
|
* @private
|
|
194
|
-
* @param {}
|
|
208
|
+
* @param {Array} the files defining the library,
|
|
209
|
+
* @param {Function} the function to call at the completion,
|
|
195
210
|
* @returns {} -,
|
|
196
211
|
* @since 0.0.0
|
|
197
212
|
*/
|
|
198
|
-
function
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
exportM += `export default ${ES6GLOB}.${libname};`;
|
|
213
|
+
function _doLib(source, done) {
|
|
214
|
+
const head = fs.readFileSync(source[0])
|
|
215
|
+
, core = source.slice(1, -1)
|
|
216
|
+
, foot = fs.readFileSync(source[source.length - 1])
|
|
217
|
+
;
|
|
204
218
|
|
|
205
|
-
let
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
219
|
+
let content = '';
|
|
220
|
+
for (let i = 0; i < core.length; i++) {
|
|
221
|
+
content += fs.readFileSync(core[i]);
|
|
222
|
+
if (i < core.length - 1) {
|
|
223
|
+
content += '\n';
|
|
224
|
+
}
|
|
225
|
+
}
|
|
211
226
|
|
|
212
|
-
|
|
213
|
-
.replace(
|
|
214
|
-
.replace(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
.replace(/\
|
|
227
|
+
content = content
|
|
228
|
+
.replace(/{{lib:name}}/g, libname)
|
|
229
|
+
.replace(/{{lib:version}}/g, version)
|
|
230
|
+
// remove the extra global and 'use strict':
|
|
231
|
+
.replace(/\/\* global[\w$_\s,]+\*\//g, '/* - */')
|
|
232
|
+
.replace(/\n'use strict';\n/g, '')
|
|
233
|
+
// indent the first line with 2 spaces:
|
|
234
|
+
.replace(/^/g, ' ')
|
|
235
|
+
// indent each other lines with 2 spaces:
|
|
236
|
+
.replace(/\n/g, '\n ')
|
|
218
237
|
;
|
|
219
|
-
|
|
220
|
-
fs.writeFileSync(`${destination}/${name}.
|
|
221
|
-
|
|
222
|
-
|
|
238
|
+
// For testing purpose:
|
|
239
|
+
// fs.writeFileSync(`${destination}/${name}-${suffix}-core.js`, src);
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Waits until completion.
|
|
243
|
+
*/
|
|
244
|
+
let count = 2;
|
|
245
|
+
function _next() {
|
|
246
|
+
count -= 1;
|
|
247
|
+
if (!count) {
|
|
248
|
+
done();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
_doUMD(head, content, foot, _next);
|
|
252
|
+
_doES6(head, content, foot, _next);
|
|
223
253
|
}
|
|
224
254
|
|
|
225
255
|
/**
|
|
226
|
-
*
|
|
256
|
+
* Creates all UMD/ES6 libraries.
|
|
227
257
|
*
|
|
228
|
-
* @function ()
|
|
258
|
+
* @function (arg1)
|
|
229
259
|
* @private
|
|
230
|
-
* @param {}
|
|
260
|
+
* @param {Function} the function to call at the completion,
|
|
231
261
|
* @returns {} -,
|
|
232
262
|
* @since 0.0.0
|
|
233
263
|
*/
|
|
234
|
-
function
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
264
|
+
function _doLibs(done) {
|
|
265
|
+
let pending = 1;
|
|
266
|
+
/**
|
|
267
|
+
* Waits until completion.
|
|
268
|
+
*/
|
|
269
|
+
function _next() {
|
|
270
|
+
pending -= 1;
|
|
271
|
+
if (!pending) {
|
|
272
|
+
done();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
238
275
|
|
|
239
|
-
|
|
240
|
-
|
|
276
|
+
_doLib(src, () => {
|
|
277
|
+
_next();
|
|
278
|
+
});
|
|
241
279
|
}
|
|
242
280
|
|
|
243
281
|
|
|
@@ -266,14 +304,12 @@ function run() {
|
|
|
266
304
|
const d1 = new Date();
|
|
267
305
|
process.stdout.write('Starting \'\x1b[36mbuild:js:dev\x1b[89m\x1b[0m\'...\n');
|
|
268
306
|
|
|
269
|
-
_clean()
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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`);
|
|
307
|
+
_clean(() => {
|
|
308
|
+
_doLibs(() => {
|
|
309
|
+
const d2 = new Date() - d1;
|
|
310
|
+
process.stdout.write(`Finished '\x1b[36mbuild:js:dev\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
311
|
+
});
|
|
312
|
+
});
|
|
277
313
|
}
|
|
278
314
|
|
|
279
315
|
|
package/scripts/build.js.prod.js
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
* Private Functions:
|
|
10
10
|
* . _help displays the help message,
|
|
11
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
12
|
* . _makeminifiedm builds and minifies the ES6 module production file,
|
|
13
|
+
* . _makeminified builds and minifies the js production file,
|
|
14
|
+
* . _copydevm builds the ES6 module production file,
|
|
15
|
+
* . _copydev builds the js production file,
|
|
16
|
+
* . _doLibs builds the js production libraries,
|
|
16
17
|
*
|
|
17
18
|
*
|
|
18
19
|
* Public Static Methods:
|
|
@@ -94,13 +95,13 @@ function _help() {
|
|
|
94
95
|
/**
|
|
95
96
|
* Removes the previous js production build.
|
|
96
97
|
*
|
|
97
|
-
* @function ()
|
|
98
|
+
* @function (arg1)
|
|
98
99
|
* @private
|
|
99
|
-
* @param {}
|
|
100
|
-
* @returns {}
|
|
100
|
+
* @param {Function} the function to call at the completion,
|
|
101
|
+
* @returns {} -,
|
|
101
102
|
* @since 0.0.0
|
|
102
103
|
*/
|
|
103
|
-
function _clean() {
|
|
104
|
+
function _clean(done) {
|
|
104
105
|
const d1 = new Date();
|
|
105
106
|
process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
|
|
106
107
|
|
|
@@ -114,13 +115,14 @@ function _clean() {
|
|
|
114
115
|
const d2 = new Date() - d1;
|
|
115
116
|
process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
116
117
|
resolve();
|
|
118
|
+
if (done) done();
|
|
117
119
|
});
|
|
118
120
|
});
|
|
119
121
|
});
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
/**
|
|
123
|
-
* Builds the
|
|
125
|
+
* Builds and minifies the ES6 module production file.
|
|
124
126
|
*
|
|
125
127
|
* @function (arg1)
|
|
126
128
|
* @private
|
|
@@ -128,22 +130,58 @@ function _clean() {
|
|
|
128
130
|
* @returns {} -,
|
|
129
131
|
* @since 0.0.0
|
|
130
132
|
*/
|
|
131
|
-
function
|
|
133
|
+
function _makeminifiedm(done) {
|
|
134
|
+
const d1 = new Date();
|
|
135
|
+
process.stdout.write('Starting \'\x1b[36mmake:minified:es6\x1b[89m\x1b[0m\'...\n');
|
|
136
|
+
|
|
137
|
+
fs.readFile(`${libdir}/${name}.mjs`, 'utf8', (err1, data) => {
|
|
138
|
+
if (err1) throw new Error(err1);
|
|
139
|
+
|
|
140
|
+
let content = license;
|
|
141
|
+
content += data.replace(/\/\*! \*\*\*/g, '/** ***');
|
|
142
|
+
|
|
143
|
+
minify(content, {})
|
|
144
|
+
.then((result) => {
|
|
145
|
+
fs.writeFile(`${dist}/lib/${name}.min.mjs`, result.code, { encoding: 'utf8' }, (err2) => {
|
|
146
|
+
if (err2) throw new Error(err2);
|
|
147
|
+
|
|
148
|
+
const d2 = new Date() - d1;
|
|
149
|
+
process.stdout.write(`Finished '\x1b[36mmake:minified:es6\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
150
|
+
done();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Builds and minifies the js production file.
|
|
158
|
+
*
|
|
159
|
+
* @function (arg1)
|
|
160
|
+
* @private
|
|
161
|
+
* @param {Function} the function to call at the completion,
|
|
162
|
+
* @returns {} -,
|
|
163
|
+
* @since 0.0.0
|
|
164
|
+
*/
|
|
165
|
+
function _makeminified(done) {
|
|
132
166
|
const d1 = new Date();
|
|
133
|
-
process.stdout.write('Starting \'\x1b[
|
|
167
|
+
process.stdout.write('Starting \'\x1b[36mmake:minified:umd\x1b[89m\x1b[0m\'...\n');
|
|
134
168
|
|
|
135
169
|
fs.readFile(`${libdir}/${name}.js`, 'utf8', (err1, data) => {
|
|
136
170
|
if (err1) throw new Error(err1);
|
|
137
171
|
|
|
138
172
|
let content = license;
|
|
139
|
-
content += data;
|
|
140
|
-
fs.writeFile(`${dist}/lib/${name}.js`, content, { encoding: 'utf8' }, (err2) => {
|
|
141
|
-
if (err2) throw new Error(err2);
|
|
173
|
+
content += data.replace(/\/\*! \*\*\*/g, '/** ***');
|
|
142
174
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
175
|
+
minify(content, {})
|
|
176
|
+
.then((result) => {
|
|
177
|
+
fs.writeFile(`${dist}/lib/${name}.min.js`, result.code, { encoding: 'utf8' }, (err2) => {
|
|
178
|
+
if (err2) throw new Error(err2);
|
|
179
|
+
|
|
180
|
+
const d2 = new Date() - d1;
|
|
181
|
+
process.stdout.write(`Finished '\x1b[36mmake:minified:umd\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
182
|
+
done();
|
|
183
|
+
});
|
|
184
|
+
});
|
|
147
185
|
});
|
|
148
186
|
}
|
|
149
187
|
|
|
@@ -158,7 +196,7 @@ function _copydev(done) {
|
|
|
158
196
|
*/
|
|
159
197
|
function _copydevm(done) {
|
|
160
198
|
const d1 = new Date();
|
|
161
|
-
process.stdout.write(
|
|
199
|
+
process.stdout.write("Starting '\x1b[36mcopy:es6\x1b[89m\x1b[0m'...\n");
|
|
162
200
|
|
|
163
201
|
fs.readFile(`${libdir}/${name}.mjs`, 'utf8', (err1, data) => {
|
|
164
202
|
if (err1) throw new Error(err1);
|
|
@@ -169,14 +207,14 @@ function _copydevm(done) {
|
|
|
169
207
|
if (err2) throw new Error(err2);
|
|
170
208
|
|
|
171
209
|
const d2 = new Date() - d1;
|
|
172
|
-
process.stdout.write(`Finished '\x1b[
|
|
210
|
+
process.stdout.write(`Finished '\x1b[36mcopy:es6\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
173
211
|
done();
|
|
174
212
|
});
|
|
175
213
|
});
|
|
176
214
|
}
|
|
177
215
|
|
|
178
216
|
/**
|
|
179
|
-
* Builds
|
|
217
|
+
* Builds the js production file.
|
|
180
218
|
*
|
|
181
219
|
* @function (arg1)
|
|
182
220
|
* @private
|
|
@@ -184,31 +222,27 @@ function _copydevm(done) {
|
|
|
184
222
|
* @returns {} -,
|
|
185
223
|
* @since 0.0.0
|
|
186
224
|
*/
|
|
187
|
-
function
|
|
225
|
+
function _copydev(done) {
|
|
188
226
|
const d1 = new Date();
|
|
189
|
-
process.stdout.write(
|
|
227
|
+
process.stdout.write("Starting '\x1b[36mcopy:umd\x1b[89m\x1b[0m'...\n");
|
|
190
228
|
|
|
191
229
|
fs.readFile(`${libdir}/${name}.js`, 'utf8', (err1, data) => {
|
|
192
230
|
if (err1) throw new Error(err1);
|
|
193
231
|
|
|
194
232
|
let content = license;
|
|
195
|
-
content += data
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
.then((result) => {
|
|
199
|
-
fs.writeFile(`${dist}/lib/${name}.min.js`, result.code, { encoding: 'utf8' }, (err2) => {
|
|
200
|
-
if (err2) throw new Error(err2);
|
|
233
|
+
content += data;
|
|
234
|
+
fs.writeFile(`${dist}/lib/${name}.js`, content, { encoding: 'utf8' }, (err2) => {
|
|
235
|
+
if (err2) throw new Error(err2);
|
|
201
236
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
});
|
|
237
|
+
const d2 = new Date() - d1;
|
|
238
|
+
process.stdout.write(`Finished '\x1b[36mcopy:umd\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
|
|
239
|
+
done();
|
|
240
|
+
});
|
|
207
241
|
});
|
|
208
242
|
}
|
|
209
243
|
|
|
210
244
|
/**
|
|
211
|
-
* Builds
|
|
245
|
+
* Builds the js production libraries.
|
|
212
246
|
*
|
|
213
247
|
* @function (arg1)
|
|
214
248
|
* @private
|
|
@@ -216,27 +250,22 @@ function _makeminified(done) {
|
|
|
216
250
|
* @returns {} -,
|
|
217
251
|
* @since 0.0.0
|
|
218
252
|
*/
|
|
219
|
-
function
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
.then((result) => {
|
|
231
|
-
fs.writeFile(`${dist}/lib/${name}.min.mjs`, result.code, { encoding: 'utf8' }, (err2) => {
|
|
232
|
-
if (err2) throw new Error(err2);
|
|
253
|
+
function _doLibs(done) {
|
|
254
|
+
let pending = 4;
|
|
255
|
+
/**
|
|
256
|
+
* Executes done until completion.
|
|
257
|
+
*/
|
|
258
|
+
function _next() {
|
|
259
|
+
pending -= 1;
|
|
260
|
+
if (!pending) {
|
|
261
|
+
done();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
233
264
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
});
|
|
239
|
-
});
|
|
265
|
+
_copydev(_next);
|
|
266
|
+
_copydevm(_next);
|
|
267
|
+
_makeminified(_next);
|
|
268
|
+
_makeminifiedm(_next);
|
|
240
269
|
}
|
|
241
270
|
|
|
242
271
|
|
|
@@ -252,7 +281,7 @@ function _makeminifiedm(done) {
|
|
|
252
281
|
* @since 0.0.0
|
|
253
282
|
*/
|
|
254
283
|
async function run() {
|
|
255
|
-
const PENDING =
|
|
284
|
+
const PENDING = 1;
|
|
256
285
|
|
|
257
286
|
if (parsed.help) {
|
|
258
287
|
_help();
|
|
@@ -280,10 +309,7 @@ async function run() {
|
|
|
280
309
|
}
|
|
281
310
|
|
|
282
311
|
await _clean();
|
|
283
|
-
|
|
284
|
-
_copydevm(done);
|
|
285
|
-
_makeminified(done);
|
|
286
|
-
_makeminifiedm(done);
|
|
312
|
+
_doLibs(done);
|
|
287
313
|
}
|
|
288
314
|
|
|
289
315
|
|
package/test/index.html
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
<!-- x -->
|
|
2
1
|
<!doctype html>
|
|
3
2
|
<html class="no-js" lang="">
|
|
4
3
|
<head>
|
|
5
4
|
<meta charset="utf-8">
|
|
6
|
-
<title>View ES6lib</title>
|
|
7
|
-
<meta name="description" content="{{app:description}}">
|
|
8
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
9
|
-
|
|
6
|
+
<title>View ES6lib</title>
|
|
10
7
|
<link rel="stylesheet" href="">
|
|
11
|
-
<meta name="
|
|
8
|
+
<meta name="description" content="">
|
|
9
|
+
<meta name="theme-color" content="#fafafa">
|
|
10
|
+
|
|
12
11
|
<style>
|
|
13
12
|
/* - */
|
|
14
13
|
</style>
|
|
15
|
-
|
|
16
|
-
<!-- <script src='./lib/view.js'></script> -->
|
|
17
14
|
<script>
|
|
18
15
|
document.addEventListener('DOMContentLoaded', () => {
|
|
19
|
-
/* global
|
|
16
|
+
/* global ... */
|
|
20
17
|
'use strict';
|
|
21
18
|
//
|
|
22
19
|
});
|
|
@@ -24,16 +21,8 @@
|
|
|
24
21
|
</head>
|
|
25
22
|
|
|
26
23
|
<body>
|
|
27
|
-
<!--[if IE]>
|
|
28
|
-
<p class="browserupgrade">You are using an <strong>outdated and unsupported</strong> browser. Please <a href="https://browsehappy.com/">upgrade your browser</a> to benefit of all the features of this web App.</p>
|
|
29
|
-
<![endif]-->
|
|
30
|
-
|
|
31
24
|
<!-- Warning message if Javascript isn't enabled -->
|
|
32
|
-
<noscript>
|
|
33
|
-
<p style="text-align:center;padding-top:3em;">
|
|
34
|
-
We are sorry, but this website doesn't work properly without JavaScript enabled!
|
|
35
|
-
</p>
|
|
36
|
-
</noscript>
|
|
25
|
+
<noscript><p style="text-align:center;padding-top:3em;">We are sorry, but this website doesn't work properly without JavaScript enabled!</p></noscript>
|
|
37
26
|
|
|
38
27
|
<!-- Add your site or application content here -->
|
|
39
28
|
<div id="app"></div>
|
|
@@ -53,7 +42,6 @@
|
|
|
53
42
|
el.append(`Es6lib v${ES6lib.VERSION}`);
|
|
54
43
|
el.append(` ... ${lib.getString()}`);
|
|
55
44
|
el.append(` ... ${lib.getArray()}`);
|
|
56
|
-
|
|
57
45
|
</script>
|
|
58
46
|
</body>
|
|
59
47
|
</html>
|