@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.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Private Functions:
10
10
  * . _help displays the help message,
11
- * . _clean removes the previous production folder,
11
+ * . _clean removes the previous production build,
12
12
  * . _doskeleton creates the production folder and copies files,
13
13
  *
14
14
  *
@@ -87,15 +87,15 @@ function _help() {
87
87
  }
88
88
 
89
89
  /**
90
- * Removes the previous production folder,
90
+ * Removes the previous production build.
91
91
  *
92
- * @function ()
92
+ * @function ([arg1])
93
93
  * @private
94
- * @param {} -,
94
+ * @param {Function} the function to call at the completion,
95
95
  * @returns {Object} returns a promise,
96
96
  * @since 0.0.0
97
97
  */
98
- function _clean() {
98
+ function _clean(done) {
99
99
  const d1 = new Date();
100
100
  process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
101
101
 
@@ -106,6 +106,7 @@ function _clean() {
106
106
  const d2 = new Date() - d1;
107
107
  process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
108
108
  resolve();
109
+ if (done) done();
109
110
  });
110
111
  });
111
112
  }
@@ -121,7 +122,7 @@ function _clean() {
121
122
  */
122
123
  function _doskeleton(done) {
123
124
  const d1 = new Date();
124
- process.stdout.write('Starting \'\x1b[36mdoskeleton\x1b[89m\x1b[0m\'...\n');
125
+ process.stdout.write('Starting \'\x1b[36mdo:skeleton\x1b[89m\x1b[0m\'...\n');
125
126
 
126
127
  /**
127
128
  * Wait all processes completed;
@@ -131,7 +132,7 @@ function _doskeleton(done) {
131
132
  pending -= 1;
132
133
  if (!pending) {
133
134
  const d2 = new Date() - d1;
134
- process.stdout.write(`Finished '\x1b[36mdoskeleton\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
135
+ process.stdout.write(`Finished '\x1b[36mdo:skeleton\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
135
136
  done();
136
137
  }
137
138
  }
@@ -147,52 +148,55 @@ function _doskeleton(done) {
147
148
  }
148
149
 
149
150
 
150
- // -- Main ---------------------------------------------------------------------
151
-
152
- /**
153
- * Executes the script.
154
- *
155
- * @function ()
156
- * @public
157
- * @param {} -,
158
- * @returns {} -,
159
- * @since 0.0.0
160
- */
161
- async function run() {
162
- const PENDING = 1;
151
+ // -- Public Static Methods ----------------------------------------------------
163
152
 
164
- if (parsed.help) {
165
- _help();
166
- return;
167
- }
153
+ const Lib = {
168
154
 
169
- if (parsed.version) {
170
- process.stdout.write(`version: ${parsed.version}\n`);
171
- return;
172
- }
155
+ /**
156
+ * Executes the script.
157
+ *
158
+ * @method ()
159
+ * @public
160
+ * @param {} -,
161
+ * @returns {} -,
162
+ * @since 0.0.0
163
+ */
164
+ async run() {
165
+ const PENDING = 1;
166
+
167
+ if (parsed.help) {
168
+ _help();
169
+ return;
170
+ }
173
171
 
174
- const d1 = new Date();
175
- process.stdout.write('Starting \'\x1b[36mbuild:skeleton:prod\x1b[89m\x1b[0m\'...\n');
172
+ if (parsed.version) {
173
+ process.stdout.write(`version: ${parsed.version}\n`);
174
+ return;
175
+ }
176
176
 
177
- let pending = PENDING;
178
- /**
179
- * Executes done until completion.
180
- */
181
- function done() {
182
- pending -= 1;
183
- if (!pending) {
184
- const d2 = new Date() - d1;
185
- process.stdout.write(`Finished '\x1b[36mbuild:skeleton:prod\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
177
+ const d1 = new Date();
178
+ process.stdout.write('Starting \'\x1b[36mbuild:skeleton:prod\x1b[89m\x1b[0m\'...\n');
179
+
180
+ let pending = PENDING;
181
+ /**
182
+ * Executes done until completion.
183
+ */
184
+ function done() {
185
+ pending -= 1;
186
+ if (!pending) {
187
+ const d2 = new Date() - d1;
188
+ process.stdout.write(`Finished '\x1b[36mbuild:skeleton:prod\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
189
+ }
186
190
  }
187
- }
188
191
 
189
- await _clean();
190
- _doskeleton(done);
191
- }
192
+ await _clean();
193
+ _doskeleton(done);
194
+ },
195
+ };
192
196
 
193
197
 
194
- // Start script.
195
- run();
198
+ // -- Where the script starts --------------------------------------------------
199
+ Lib.run();
196
200
 
197
201
 
198
202
  // -- oOo --
@@ -39,3 +39,6 @@ cd ${NPM}/${name}/${VERSION}
39
39
  tar zcvf ${name}.tgz ${name}/
40
40
  rm -rf ${name}
41
41
  echo 'Done!'
42
+
43
+
44
+ # -- oOo --
package/scripts/config.js CHANGED
@@ -1,3 +1,18 @@
1
+ /** ************************************************************************
2
+ *
3
+ * Configuration file.
4
+ *
5
+ *
6
+ *
7
+ * @namespace -
8
+ * @dependencies none
9
+ * @exports -
10
+ * @author -
11
+ * @since 0.0.0
12
+ * @version -
13
+ * ********************************************************************** */
14
+ /* eslint one-var: 0, semi-style: 0 */
15
+
1
16
  /* eslint one-var: 0, semi-style: 0 */
2
17
 
3
18
  'use strict';
@@ -92,13 +92,13 @@ function _help() {
92
92
  /**
93
93
  * Removes the previous build.
94
94
  *
95
- * @function ()
95
+ * @function ([arg1])
96
96
  * @private
97
- * @param {} -,
97
+ * @param {Function} the function to call at the completion,
98
98
  * @returns {Object} returns a promise,
99
99
  * @since 0.0.0
100
100
  */
101
- function _clean() {
101
+ function _clean(done) {
102
102
  const d1 = new Date();
103
103
  process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
104
104
 
@@ -112,6 +112,7 @@ function _clean() {
112
112
  const d2 = new Date() - d1;
113
113
  process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
114
114
  resolve();
115
+ if (done) done();
115
116
  });
116
117
  });
117
118
  });
@@ -155,7 +156,7 @@ function _copyindex(done) {
155
156
  */
156
157
  function _copypackagejson(done) {
157
158
  const d1 = new Date();
158
- process.stdout.write('Starting \'\x1b[36mcopypackagejson\x1b[89m\x1b[0m\'...\n');
159
+ process.stdout.write('Starting \'\x1b[36mcopy:package:json\x1b[89m\x1b[0m\'...\n');
159
160
 
160
161
  fs.readFile('./package.json', 'utf8', (err1, data) => {
161
162
  if (err1) throw new Error(err1);
@@ -173,60 +174,63 @@ function _copypackagejson(done) {
173
174
  if (err2) throw new Error(err2);
174
175
 
175
176
  const d2 = new Date() - d1;
176
- process.stdout.write(`Finished '\x1b[36mcopypackagejson\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
177
+ process.stdout.write(`Finished '\x1b[36mcopy:package:json\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
177
178
  done();
178
179
  });
179
180
  });
180
181
  }
181
182
 
182
183
 
183
- // -- Main ---------------------------------------------------------------------
184
+ // -- Public Static Methods ----------------------------------------------------
184
185
 
185
- /**
186
- * Executes the script.
187
- *
188
- * @function ()
189
- * @public
190
- * @param {} -,
191
- * @returns {} -,
192
- * @since 0.0.0
193
- */
194
- async function run() {
195
- const PENDING = 2;
186
+ const Lib = {
196
187
 
197
- if (parsed.help) {
198
- _help();
199
- return;
200
- }
188
+ /**
189
+ * Executes the script.
190
+ *
191
+ * @method ()
192
+ * @public
193
+ * @param {} -,
194
+ * @returns {} -,
195
+ * @since 0.0.0
196
+ */
197
+ async run() {
198
+ const PENDING = 2;
199
+
200
+ if (parsed.help) {
201
+ _help();
202
+ return;
203
+ }
201
204
 
202
- if (parsed.version) {
203
- process.stdout.write(`version: ${parsed.version}\n`);
204
- return;
205
- }
205
+ if (parsed.version) {
206
+ process.stdout.write(`version: ${parsed.version}\n`);
207
+ return;
208
+ }
206
209
 
207
- const d1 = new Date();
208
- process.stdout.write('Starting \'\x1b[36mdep:private\x1b[89m\x1b[0m\'...\n');
210
+ const d1 = new Date();
211
+ process.stdout.write('Starting \'\x1b[36mdep:private\x1b[89m\x1b[0m\'...\n');
209
212
 
210
- let pending = PENDING;
211
- /**
212
- * Executes done until completion.
213
- */
214
- function done() {
215
- pending -= 1;
216
- if (!pending) {
217
- const d2 = new Date() - d1;
218
- process.stdout.write(`Finished '\x1b[36mdep:private\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
213
+ let pending = PENDING;
214
+ /**
215
+ * Executes done until completion.
216
+ */
217
+ function done() {
218
+ pending -= 1;
219
+ if (!pending) {
220
+ const d2 = new Date() - d1;
221
+ process.stdout.write(`Finished '\x1b[36mdep:private\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
222
+ }
219
223
  }
220
- }
221
224
 
222
- await _clean();
223
- _copyindex(done);
224
- _copypackagejson(done);
225
- }
225
+ await _clean();
226
+ _copyindex(done);
227
+ _copypackagejson(done);
228
+ },
229
+ };
226
230
 
227
231
 
228
- // Start script.
229
- run();
232
+ // -- Where the script starts --------------------------------------------------
233
+ Lib.run();
230
234
 
231
235
 
232
236
  // -- oOo --
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="theme-color" content="#2196f3">
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 Pixi */
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>
@@ -50,10 +39,9 @@
50
39
  console.log(lib.getArray());
51
40
 
52
41
  const el = document.getElementById('app');
53
- el.append(`Es6lib v${ES6lib.VERSION}`);
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>
@@ -133,3 +133,6 @@ module.exports = function(ES6lib, libname, version) {
133
133
  });
134
134
  });
135
135
  };
136
+
137
+
138
+ // - oOo --
@@ -174,3 +174,6 @@ module.exports = function(ES6lib, libname, version) {
174
174
  });
175
175
  });
176
176
  };
177
+
178
+
179
+ // - oOo --
@@ -210,3 +210,6 @@ module.exports = function(ES6lib, libname, version, type) {
210
210
  });
211
211
  });
212
212
  };
213
+
214
+
215
+ // - oOo --
package/test/main.js CHANGED
@@ -25,3 +25,6 @@ const libname = 'ES6lib';
25
25
  describe('Test ES6lib:', () => {
26
26
  testlib(ES6lib, libname, pack.version, 'without new');
27
27
  });
28
+
29
+
30
+ // - oOo --
@@ -1,284 +0,0 @@
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 --