@mobilabs/es6lib 1.0.15 → 1.1.0

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/.eslintrc CHANGED
@@ -3,7 +3,7 @@
3
3
  * Set JavaScript language options
4
4
  */
5
5
  "parserOptions": {
6
- "sourceType": "script",
6
+ "sourceType": "script"
7
7
  },
8
8
  /**
9
9
  * Set Environnement
@@ -22,13 +22,13 @@
22
22
  "extends": "airbnb-base",
23
23
  // Overwritten airbnb's rules:
24
24
  "rules": {
25
- strict: ["error", "global"],
26
- func-names: ["error", "never"],
27
- space-before-function-paren: ["error", { "anonymous": "never", "named": "never", "asyncArrow": "always" }],
28
- no-plusplus: ["error", { "allowForLoopAfterthoughts": true }],
29
- "no-multi-spaces": [2, { exceptions: { "VariableDeclarator": true } }],
30
- comma-style: ["error", "first", { "exceptions": { "ArrayExpression": true, "ObjectExpression": true } }],
31
- indent: ["error", 2, { "VariableDeclarator": { "const": 2 }, "SwitchCase": 1 }],
32
- no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]
25
+ "strict": ["error", "global"],
26
+ "func-names": ["error", "never"],
27
+ "space-before-function-paren": ["error", { "anonymous": "never", "named": "never", "asyncArrow": "always" }],
28
+ "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
29
+ "no-multi-spaces": [2, { "exceptions": { "VariableDeclarator": true } }],
30
+ "comma-style": ["error", "first", { "exceptions": { "ArrayExpression": true, "ObjectExpression": true } }],
31
+ "indent": ["error", 2, { "VariableDeclarator": { "const": 2 }, "SwitchCase": 1 }],
32
+ "no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 0 }]
33
33
  }
34
34
  }
package/README.md CHANGED
@@ -36,7 +36,7 @@ Then, you just need to create a `package.json` file that contains:
36
36
  "name": "NameOfYourProject",
37
37
  "scripts": {
38
38
  "create": "npm install @mobilabs/es6lib && npm run populate",
39
- "populate": "es6lib populate --name $npm_package_name --author $npm_package_config_name --acronym $npm_package_config_acronym --email $npm_package_config_email --url $npm_package_config_url && npm install && npm run build && npm run test && npm run report"
39
+ "populate": "es6lib populate --name $npm_package_name --author $npm_package_config_name --acronym $npm_package_config_acronym --email $npm_package_config_email --url $npm_package_config_url && npm install && npm run build:dev && npm run test && npm run report"
40
40
  },
41
41
  "config": {
42
42
  "name": "John Doe",
package/_dist/README.md CHANGED
@@ -36,7 +36,7 @@ Then, you just need to create a `package.json` file that contains:
36
36
  "name": "NameOfYourProject",
37
37
  "scripts": {
38
38
  "create": "npm install @mobilabs/es6lib && npm run populate",
39
- "populate": "es6lib populate --name $npm_package_name --author $npm_package_config_name --acronym $npm_package_config_acronym --email $npm_package_config_email --url $npm_package_config_url && npm install && npm run build && npm run test && npm run report"
39
+ "populate": "es6lib populate --name $npm_package_name --author $npm_package_config_name --acronym $npm_package_config_acronym --email $npm_package_config_email --url $npm_package_config_url && npm install && npm run build:dev && npm run test && npm run report"
40
40
  },
41
41
  "config": {
42
42
  "name": "John Doe",
@@ -1,5 +1,5 @@
1
1
  /*! ****************************************************************************
2
- * ES6lib v1.0.15
2
+ * ES6lib v1.1.0
3
3
  *
4
4
  * A template for writing pure ES6 Javascript libraries.
5
5
  * (you can download it from npm or github repositories)
@@ -312,14 +312,14 @@
312
312
  const obj = Object.create(methods);
313
313
  obj._library = {
314
314
  name: 'ES6lib',
315
- version: '1.0.15',
315
+ version: '1.1.0',
316
316
  };
317
317
  return obj;
318
318
  };
319
319
 
320
320
  // Attaches constants to ES6lib that provide name and version of the lib.
321
321
  ES6lib.NAME = 'ES6lib';
322
- ES6lib.VERSION = '1.0.15';
322
+ ES6lib.VERSION = '1.1.0';
323
323
 
324
324
 
325
325
  // -- Private Static Methods -----------------------------------------------
@@ -1,5 +1,5 @@
1
1
  /*! ****************************************************************************
2
- * ES6lib v1.0.15
2
+ * ES6lib v1.1.0
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,n){"use strict";if(typeof define==="function"&&define.amd){define([""],n)}else if(typeof exports==="object"){module.exports=n(t)}else{t.ES6lib=n(t)}})(this,(t=>{"use strict";let n,e;const r={Util:{Public:{}}};(function(){e=function(t,n){const e=Object.keys(n);for(let r=0;r<e.length;r++){t[e[r]]=n[e[r]]}}})();(function(){const t=r.Util.Public;function n(){return"I am a string!"}function i(){return[1,2,3]}e(t,{getString(){return n()},getArray(){return i()}})})();(function(){const e=r.Util.Public;const i=t.ES6lib;let o;n=function(){const t=Object.create(o);t._library={name:"ES6lib",version:"1.0.15"};return t};n.NAME="ES6lib";n.VERSION="1.0.15";n._setTestMode=function(){return[]};n.noConflict=function(){t.ES6lib=i;return this};o={whoami(){return this._library},getString(){return e.getString()},getArray(){return e.getArray()}}})();return n}));
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:"1.1.0"},t},e.NAME="ES6lib",e.VERSION="1.1.0",e._setTestMode=function(){return[]},e.noConflict=function(){return t.ES6lib=r,this},o={whoami(){return this._library},getString:()=>n.getString(),getArray:()=>n.getArray()}}(),e}));
@@ -1,5 +1,5 @@
1
1
  /*! ****************************************************************************
2
- * ES6lib v1.0.15
2
+ * ES6lib v1.1.0
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,n){"use strict";if(typeof define==="function"&&define.amd){define([""],n)}else if(typeof exports==="object"){module.exports=n(t)}else{t.ES6lib=n(t)}})($__ES6GLOB,(t=>{"use strict";let n,e;const r={Util:{Public:{}}};(function(){e=function(t,n){const e=Object.keys(n);for(let r=0;r<e.length;r++){t[e[r]]=n[e[r]]}}})();(function(){const t=r.Util.Public;function n(){return"I am a string!"}function i(){return[1,2,3]}e(t,{getString(){return n()},getArray(){return i()}})})();(function(){const e=r.Util.Public;const i=t.ES6lib;let o;n=function(){const t=Object.create(o);t._library={name:"ES6lib",version:"1.0.15"};return t};n.NAME="ES6lib";n.VERSION="1.0.15";n._setTestMode=function(){return[]};n.noConflict=function(){t.ES6lib=i;return this};o={whoami(){return this._library},getString(){return e.getString()},getArray(){return e.getArray()}}})();return n}));export default $__ES6GLOB.ES6lib;
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:"1.1.0"},t},e.NAME="ES6lib",e.VERSION="1.1.0",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;
@@ -1,5 +1,5 @@
1
1
  /*! ****************************************************************************
2
- * ES6lib v1.0.15
2
+ * ES6lib v1.1.0
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 @@ const $__ES6GLOB = {};
313
313
  const obj = Object.create(methods);
314
314
  obj._library = {
315
315
  name: 'ES6lib',
316
- version: '1.0.15',
316
+ version: '1.1.0',
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 = '1.0.15';
323
+ ES6lib.VERSION = '1.1.0';
324
324
 
325
325
 
326
326
  // -- Private Static Methods -----------------------------------------------
package/bin/es6lib.js CHANGED
@@ -269,7 +269,7 @@ function _addSkeleton(base, app, owner, cright) {
269
269
  * @returns {} -,
270
270
  */
271
271
  function _duplicate(source, dest) {
272
- const dupFiles = ['.eslintrc', '.travis.yml'];
272
+ const dupFiles = ['.eslintrc', '.travis.yml', 'rmdstore.sh'];
273
273
 
274
274
  for (let i = 0; i < dupFiles.length; i++) {
275
275
  process.stdout.write(` copied ${dupFiles[i]}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mobilabs/es6lib",
3
- "version": "1.0.15",
3
+ "version": "1.1.0",
4
4
  "description": "A template for writing pure ES6 Javascript libraries",
5
5
  "main": "index.js",
6
6
  "minified": "_dist/lib/es6lib.min.js",
@@ -13,8 +13,8 @@
13
13
  "general": " --- GENERAL ---",
14
14
 
15
15
  "build:js": " --- JAVASCRIPT --- ",
16
- "build:js:dev": "node tasks/makejs.js",
17
- "build:js:prod": "node tasks/makedist.js",
16
+ "build:js:dev": "node tasks/build.js.dev.js $1",
17
+ "build:js:prod": "node tasks/build.js.prod.js $1",
18
18
 
19
19
  "build:css": " --- CSS --- ",
20
20
 
@@ -24,7 +24,8 @@
24
24
  "build:dev": "npm run build:js:dev",
25
25
 
26
26
  "build:production": " --- BUILD (PRODUCTION) --- ",
27
- "prebuild:prod": "npm run build:dev",
27
+ "build:skeleton:prod": "node tasks/build.skeleton.prod.js $1",
28
+ "prebuild:prod": "npm run build:dev && npm run build:skeleton:prod",
28
29
  "build:prod": "npm run build:js:prod",
29
30
 
30
31
  "testing": " --- TESTING --- ",
@@ -43,7 +44,8 @@
43
44
  "watch": "npm run watch:js",
44
45
 
45
46
  "deployment": " --- DEPLOYMENT --- ",
46
- "dep:private": "npm run build:prod && node tasks/makeprivatepackage.js && sh tasks/compress.sh ${npm_package_name} ${npm_package_version} @mobilabs",
47
+ "dep:prod": "rm -rf _dist-$npm_package_version && npm run build:prod && cp -r _dist _dist-$npm_package_version",
48
+ "dep:private": "npm run build:prod && node tasks/dep.private.js && sh tasks/compress.sh ${npm_package_name} ${npm_package_version} @mobilabs",
47
49
 
48
50
  "others": " --- OTHERS ---",
49
51
  "prepare": "husky install",
package/rmdstore.sh ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ # Find '.DS_Store'
4
+ find . -type f -name '.DS_Store'
5
+
6
+ if [[ $1 = '-del' ]]; then
7
+ echo 'Deleting ...'
8
+ find . -type f -name '.DS_Store' -delete
9
+ fi
@@ -1,10 +1,38 @@
1
- /* eslint one-var: 0, import/no-extraneous-dependencies: 0, semi-style: 0,
2
- object-curly-newline: 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
+ * . _delgeneric 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 */
3
30
 
4
31
  'use strict';
5
32
 
6
33
  // -- Vendor Modules
7
- const fs = require('fs')
34
+ const fs = require('fs')
35
+ , nopt = require('nopt')
8
36
  ;
9
37
 
10
38
 
@@ -15,7 +43,17 @@ const pack = require('../package.json')
15
43
 
16
44
 
17
45
  // -- Local Constants
18
- const destination = config.libdir
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
19
57
  , { ES6GLOB } = config
20
58
  , source = config.src
21
59
  , { libname } = config
@@ -30,16 +68,47 @@ const destination = config.libdir
30
68
  // -- Local Variables
31
69
 
32
70
 
33
- // -- Private Tasks
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
+ process.exit(0);
97
+ }
34
98
 
35
99
  /**
36
- * Removes the previous version.
100
+ * Removes the previous build.
101
+ *
102
+ * @function ()
103
+ * @private
104
+ * @param {} -,
105
+ * @returns {} -,
106
+ * @since 0.0.0
37
107
  */
38
- function clean() {
108
+ function _clean() {
39
109
  const d1 = new Date();
40
110
  process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
41
111
 
42
-
43
112
  fs.rmSync(destination, { force: true, recursive: true });
44
113
  fs.mkdirSync(destination, { recursive: true });
45
114
 
@@ -47,11 +116,16 @@ function clean() {
47
116
  process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
48
117
  }
49
118
 
50
-
51
119
  /**
52
- * Creates the content.
120
+ * Creates the content of the library.
121
+ *
122
+ * @function (arg1)
123
+ * @private
124
+ * @param {} -,
125
+ * @returns {} -,
126
+ * @since 0.0.0
53
127
  */
54
- function docore() {
128
+ function _docore() {
55
129
  const d1 = new Date();
56
130
  process.stdout.write('Starting \'\x1b[36mdocore\x1b[89m\x1b[0m\'...\n');
57
131
 
@@ -80,11 +154,16 @@ function docore() {
80
154
  process.stdout.write(`Finished '\x1b[36mdocore\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
81
155
  }
82
156
 
83
-
84
157
  /**
85
- * Create the UMD Module.
158
+ * Creates the UMD Module.
159
+ *
160
+ * @function ()
161
+ * @private
162
+ * @param {} -,
163
+ * @returns {} -,
164
+ * @since 0.0.0
86
165
  */
87
- function doumdlib() {
166
+ function _doumdlib() {
88
167
  const d1 = new Date();
89
168
  process.stdout.write('Starting \'\x1b[36mdoumdlib\x1b[89m\x1b[0m\'...\n');
90
169
 
@@ -108,11 +187,16 @@ function doumdlib() {
108
187
  process.stdout.write(`Finished '\x1b[36mdoumdlib\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
109
188
  }
110
189
 
111
-
112
190
  /**
113
191
  * Creates the ES6 module.
192
+ *
193
+ * @function ()
194
+ * @private
195
+ * @param {} -,
196
+ * @returns {} -,
197
+ * @since 0.0.0
114
198
  */
115
- function domodule() {
199
+ function _domodule() {
116
200
  const d1 = new Date();
117
201
  process.stdout.write('Starting \'\x1b[36mdomodule\x1b[89m\x1b[0m\'...\n');
118
202
 
@@ -139,11 +223,16 @@ function domodule() {
139
223
  process.stdout.write(`Finished '\x1b[36mdomodule\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
140
224
  }
141
225
 
142
-
143
226
  /**
144
227
  * Removes the temp file(s).
228
+ *
229
+ * @function ()
230
+ * @private
231
+ * @param {} -,
232
+ * @returns {} -,
233
+ * @since 0.0.0
145
234
  */
146
- function delcore() {
235
+ function _delcore() {
147
236
  const d1 = new Date();
148
237
  process.stdout.write('Starting \'\x1b[36mdelcore\x1b[89m\x1b[0m\'...\n');
149
238
  fs.unlinkSync(`${destination}/core.js`);
@@ -153,17 +242,44 @@ function delcore() {
153
242
  }
154
243
 
155
244
 
156
- // -- Public Task(s)
157
- const d1 = new Date();
158
- process.stdout.write('Starting \'\x1b[36mbuild:js:dev\x1b[89m\x1b[0m\'...\n');
159
- clean();
160
- docore();
161
- doumdlib();
162
- domodule();
163
- delcore();
245
+ // -- Main ---------------------------------------------------------------------
246
+
247
+ /**
248
+ * Executes the script.
249
+ *
250
+ * @function ()
251
+ * @puublic
252
+ * @param {} -,
253
+ * @returns {} -,
254
+ * @since 0.0.0
255
+ */
256
+ async function run() {
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:dev\x1b[89m\x1b[0m\'...\n');
269
+
270
+ _clean();
271
+ _docore();
272
+ _doumdlib();
273
+ _domodule();
274
+ _delcore();
275
+
276
+ const d2 = new Date() - d1;
277
+ process.stdout.write(`Finished '\x1b[36mbuild:js:dev\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
278
+ }
279
+
164
280
 
165
- const d2 = new Date() - d1;
166
- process.stdout.write(`Finished '\x1b[36mbuild:js:dev\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
281
+ // Start script.
282
+ run();
167
283
 
168
284
 
169
285
  // -- oOo --
@@ -0,0 +1,286 @@
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
+ process.exit(0);
93
+ }
94
+
95
+ /**
96
+ * Removes the previous js production build.
97
+ *
98
+ * @function ()
99
+ * @private
100
+ * @param {} -,
101
+ * @returns {} -,
102
+ * @since 0.0.0
103
+ */
104
+ function _clean() {
105
+ const d1 = new Date();
106
+ process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
107
+
108
+ fs.rmSync(`${dist}/lib`, { force: true, recursive: true });
109
+ fs.mkdirSync(`${dist}/lib`, { recursive: true });
110
+
111
+ const d2 = new Date() - d1;
112
+ process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
113
+ }
114
+
115
+ /**
116
+ * Builds the js production file.
117
+ *
118
+ * @function (arg1)
119
+ * @private
120
+ * @param {Function} the function to call at the completion,
121
+ * @returns {} -,
122
+ * @since 0.0.0
123
+ */
124
+ function _copydev(done) {
125
+ const d1 = new Date();
126
+ process.stdout.write('Starting \'\x1b[36mcopydev\x1b[89m\x1b[0m\'...\n');
127
+
128
+ fs.readFile(`${libdir}/${name}.js`, 'utf8', (err1, data) => {
129
+ if (err1) throw new Error(err1);
130
+
131
+ let content = license;
132
+ content += data;
133
+ fs.writeFile(`${dist}/lib/${name}.js`, content, { encoding: 'utf8' }, (err2) => {
134
+ if (err2) throw new Error(err2);
135
+
136
+ const d2 = new Date() - d1;
137
+ process.stdout.write(`Finished '\x1b[36mcopydev\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
138
+ done();
139
+ });
140
+ });
141
+ }
142
+
143
+ /**
144
+ * Builds the ES6 module production file.
145
+ *
146
+ * @function (arg1)
147
+ * @private
148
+ * @param {Function} the function to call at the completion,
149
+ * @returns {} -,
150
+ * @since 0.0.0
151
+ */
152
+ function _copydevm(done) {
153
+ const d1 = new Date();
154
+ process.stdout.write('Starting \'\x1b[36mcopydevm\x1b[89m\x1b[0m\'...\n');
155
+
156
+ fs.readFile(`${libdir}/${name}.mjs`, 'utf8', (err1, data) => {
157
+ if (err1) throw new Error(err1);
158
+
159
+ let content = license;
160
+ content += data;
161
+ fs.writeFile(`${dist}/lib/${name}.mjs`, content, { encoding: 'utf8' }, (err2) => {
162
+ if (err2) throw new Error(err2);
163
+
164
+ const d2 = new Date() - d1;
165
+ process.stdout.write(`Finished '\x1b[36mcopydevm\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
166
+ done();
167
+ });
168
+ });
169
+ }
170
+
171
+ /**
172
+ * Builds and minifies the js production file.
173
+ *
174
+ * @function (arg1)
175
+ * @private
176
+ * @param {Function} the function to call at the completion,
177
+ * @returns {} -,
178
+ * @since 0.0.0
179
+ */
180
+ function _makeminified(done) {
181
+ const d1 = new Date();
182
+ process.stdout.write('Starting \'\x1b[36mmakeminified\x1b[89m\x1b[0m\'...\n');
183
+
184
+ fs.readFile(`${libdir}/${name}.js`, 'utf8', (err1, data) => {
185
+ if (err1) throw new Error(err1);
186
+
187
+ let content = license;
188
+ content += data.replace(/\/\*! \*\*\*/g, '/** ***');
189
+
190
+ minify(content, {})
191
+ .then((result) => {
192
+ fs.writeFile(`${dist}/lib/${name}.min.js`, result.code, { encoding: 'utf8' }, (err2) => {
193
+ if (err2) throw new Error(err2);
194
+
195
+ const d2 = new Date() - d1;
196
+ process.stdout.write(`Finished '\x1b[36mmakeminified\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
197
+ done();
198
+ });
199
+ });
200
+ });
201
+ }
202
+
203
+ /**
204
+ * Builds and minifies the ES6 module production file.
205
+ *
206
+ * @function (arg1)
207
+ * @private
208
+ * @param {Function} the function to call at the completion,
209
+ * @returns {} -,
210
+ * @since 0.0.0
211
+ */
212
+ function _makeminifiedm(done) {
213
+ const d1 = new Date();
214
+ process.stdout.write('Starting \'\x1b[36mmakeminified\x1b[89m\x1b[0m\'...\n');
215
+
216
+ fs.readFile(`${libdir}/${name}.mjs`, 'utf8', (err1, data) => {
217
+ if (err1) throw new Error(err1);
218
+
219
+ let content = license;
220
+ content += data.replace(/\/\*! \*\*\*/g, '/** ***');
221
+
222
+ minify(content, {})
223
+ .then((result) => {
224
+ fs.writeFile(`${dist}/lib/${name}.min.mjs`, result.code, { encoding: 'utf8' }, (err2) => {
225
+ if (err2) throw new Error(err2);
226
+
227
+ const d2 = new Date() - d1;
228
+ process.stdout.write(`Finished '\x1b[36mmakeminified\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
229
+ done();
230
+ });
231
+ });
232
+ });
233
+ }
234
+
235
+
236
+ // -- Main ---------------------------------------------------------------------
237
+
238
+ /**
239
+ * Executes the script.
240
+ *
241
+ * @function ()
242
+ * @puublic
243
+ * @param {} -,
244
+ * @returns {} -,
245
+ * @since 0.0.0
246
+ */
247
+ function run() {
248
+ const PENDING = 4;
249
+
250
+ if (parsed.help) {
251
+ _help();
252
+ }
253
+
254
+ if (parsed.version) {
255
+ process.stdout.write(`version: ${parsed.version}\n`);
256
+ return;
257
+ }
258
+
259
+ const d1 = new Date();
260
+ process.stdout.write('Starting \'\x1b[36mbuild:js:prod\x1b[89m\x1b[0m\'...\n');
261
+
262
+ let pending = PENDING;
263
+ /**
264
+ * Executes done until completion.
265
+ */
266
+ function done() {
267
+ pending -= 1;
268
+ if (!pending) {
269
+ const d2 = new Date() - d1;
270
+ process.stdout.write(`Finished '\x1b[36mbuild:js:prod\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
271
+ }
272
+ }
273
+
274
+ _clean();
275
+ _copydev(done);
276
+ _copydevm(done);
277
+ _makeminified(done);
278
+ _makeminifiedm(done);
279
+ }
280
+
281
+
282
+ // Start script.
283
+ run();
284
+
285
+
286
+ // -- oOo --
@@ -0,0 +1,183 @@
1
+ #!/usr/bin/env node
2
+ /* *****************************************************************************
3
+ *
4
+ * Creates the production folder.
5
+ *
6
+ * build:skeleton:prod.js script creates the productiion folder and copies the
7
+ * files defined in config.js.
8
+ *
9
+ * Private Functions:
10
+ * . _help displays the help message,
11
+ * . _clean removes the previous production folder,
12
+ * . _doskeleton creates the production folder and copies files,
13
+ *
14
+ *
15
+ * Public Static Methods:
16
+ * . run executes the script,
17
+ *
18
+ *
19
+ * @namespace -
20
+ * @dependencies none
21
+ * @exports -
22
+ * @author -
23
+ * @since 0.0.0
24
+ * @version -
25
+ * ************************************************************************** */
26
+ /* eslint one-var: 0, semi-style: 0, no-underscore-dangle: 0,
27
+ import/no-extraneous-dependencies: 0 */
28
+
29
+ 'use strict';
30
+
31
+ // -- Vendor Modules
32
+ const fs = require('fs')
33
+ , path = require('path')
34
+ , nopt = require('nopt')
35
+ ;
36
+
37
+
38
+ // -- Local Modules
39
+ const config = require('./config')
40
+ ;
41
+
42
+
43
+ // -- Local Constants
44
+ const VERSION = '0.0.0-alpha.0'
45
+ , opts = {
46
+ help: [Boolean, false],
47
+ version: [String, null],
48
+ }
49
+ , shortOpts = {
50
+ h: ['--help'],
51
+ v: ['--version', VERSION],
52
+ }
53
+ , parsed = nopt(opts, shortOpts, process.argv, 2)
54
+ , { dist } = config
55
+ , { webfiles } = config
56
+ ;
57
+
58
+
59
+ // -- Local Variables
60
+
61
+
62
+ // -- Private Functions --------------------------------------------------------
63
+
64
+ /**
65
+ * Dispays the help message.
66
+ *
67
+ * @function ()
68
+ * @private
69
+ * @param {} -,
70
+ * @returns {} -,
71
+ * @since 0.0.0
72
+ */
73
+ function _help() {
74
+ const message = ['',
75
+ 'Usage: command [options]',
76
+ '',
77
+ ' creates the production folder and copies the files defined in config.js',
78
+ '',
79
+ 'Options:',
80
+ '',
81
+ '-h, --help output usage information',
82
+ '-v, --version output the version number',
83
+ '',
84
+ ].join('\n');
85
+
86
+ process.stdout.write(`${message}\n`);
87
+ process.exit(0);
88
+ }
89
+
90
+ /**
91
+ * Removes the previous production folder,
92
+ *
93
+ * @function ()
94
+ * @private
95
+ * @param {} -,
96
+ * @returns {} -,
97
+ * @since 0.0.0
98
+ */
99
+ function _clean() {
100
+ const d1 = new Date();
101
+ process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
102
+
103
+ fs.rmSync(dist, { force: true, recursive: true });
104
+
105
+ const d2 = new Date() - d1;
106
+ process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
107
+ }
108
+
109
+ /**
110
+ * Creates the production folder and copies files.
111
+ *
112
+ * @function (arg1)
113
+ * @private
114
+ * @param {Function} the function to call at the completion,
115
+ * @returns {} -,
116
+ * @since 0.0.0
117
+ */
118
+ function _doskeleton(done) {
119
+ const d1 = new Date();
120
+ process.stdout.write('Starting \'\x1b[36mdoskeleton\x1b[89m\x1b[0m\'...\n');
121
+
122
+ let filename;
123
+ for (let i = 0; i < webfiles.length; i++) {
124
+ filename = path.basename(webfiles[i]);
125
+ fs.cp(webfiles[i], `${dist}/${filename}`, (err) => {
126
+ if (err) throw new Error(err);
127
+
128
+ const d2 = new Date() - d1;
129
+ process.stdout.write(`Finished '\x1b[36mdoskeleton\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
130
+ done();
131
+ });
132
+ }
133
+ }
134
+
135
+
136
+ // -- Main ---------------------------------------------------------------------
137
+
138
+ /**
139
+ * Executes the script.
140
+ *
141
+ * @function ()
142
+ * @puublic
143
+ * @param {} -,
144
+ * @returns {} -,
145
+ * @since 0.0.0
146
+ */
147
+ function run() {
148
+ const PENDING = 1;
149
+
150
+ if (parsed.help) {
151
+ _help();
152
+ }
153
+
154
+ if (parsed.version) {
155
+ process.stdout.write(`version: ${parsed.version}\n`);
156
+ return;
157
+ }
158
+
159
+ const d1 = new Date();
160
+ process.stdout.write('Starting \'\x1b[36mbuild:skeleton:prod\x1b[89m\x1b[0m\'...\n');
161
+
162
+ let pending = PENDING;
163
+ /**
164
+ * Executes done until completion.
165
+ */
166
+ function done() {
167
+ pending -= 1;
168
+ if (!pending) {
169
+ const d2 = new Date() - d1;
170
+ process.stdout.write(`Finished '\x1b[36mbuild:skeleton:prod\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
171
+ }
172
+ }
173
+
174
+ _clean();
175
+ _doskeleton(done);
176
+ }
177
+
178
+
179
+ // Start script.
180
+ run();
181
+
182
+
183
+ // -- oOo --
package/tasks/makedist.js DELETED
@@ -1,154 +0,0 @@
1
- /* eslint one-var: 0, import/no-extraneous-dependencies: 0, semi-style: 0,
2
- object-curly-newline: 0 */
3
-
4
- 'use strict';
5
-
6
- // -- Vendor Modules
7
- const fs = require('fs')
8
- , path = require('path')
9
- , { minify } = require('terser')
10
- ;
11
-
12
-
13
- // -- Local Modules
14
- const config = require('./config')
15
- ;
16
-
17
-
18
- // -- Local Constants
19
- const { dist } = config
20
- , { webfiles } = config
21
- , { libdir } = config
22
- , { name } = config
23
- , { license } = config
24
- ;
25
-
26
-
27
- // -- Local Variables
28
-
29
-
30
- // -- Private Tasks
31
-
32
- /**
33
- * Removes the previous version.
34
- */
35
- function deldist() {
36
- const d1 = new Date();
37
- process.stdout.write('Starting \'\x1b[36mdeldist\x1b[89m\x1b[0m\'...\n');
38
-
39
-
40
- fs.rmSync(dist, { force: true, recursive: true });
41
- fs.mkdirSync(`${dist}/lib`, { recursive: true });
42
-
43
- const d2 = new Date() - d1;
44
- process.stdout.write(`Finished '\x1b[36mdeldist\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
45
- }
46
-
47
-
48
- /**
49
- * Copies README and LICENSE.
50
- */
51
- function doskeleton() {
52
- const d1 = new Date();
53
- process.stdout.write('Starting \'\x1b[36mdoskeleton\x1b[89m\x1b[0m\'...\n');
54
-
55
- let filename;
56
- for (let i = 0; i < webfiles.length; i++) {
57
- filename = path.basename(webfiles[i]);
58
- fs.copyFileSync(webfiles[i], `${dist}/${filename}`);
59
- }
60
-
61
-
62
- const d2 = new Date() - d1;
63
- process.stdout.write(`Finished '\x1b[36mdoskeleton\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
64
- }
65
-
66
-
67
- /**
68
- * Copies the development version.
69
- */
70
- function copydev() {
71
- const d1 = new Date();
72
- process.stdout.write('Starting \'\x1b[36mcopydev\x1b[89m\x1b[0m\'...\n');
73
-
74
- let f = license;
75
- f += fs.readFileSync(`${libdir}/${name}.js`, 'utf-8');
76
- fs.writeFileSync(`${dist}/lib/${name}.js`, f);
77
-
78
- const d2 = new Date() - d1;
79
- process.stdout.write(`Finished '\x1b[36mcopydev\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
80
- }
81
-
82
-
83
- /**
84
- * Copies the module development version.
85
- */
86
- function copydevm() {
87
- const d1 = new Date();
88
- process.stdout.write('Starting \'\x1b[36mcopydevm\x1b[89m\x1b[0m\'...\n');
89
-
90
- let f = license;
91
- f += fs.readFileSync(`${libdir}/${name}.mjs`, 'utf-8');
92
- fs.writeFileSync(`${dist}/lib/${name}.mjs`, f);
93
-
94
- const d2 = new Date() - d1;
95
- process.stdout.write(`Finished '\x1b[36mcopydevm\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
96
- }
97
-
98
-
99
- /**
100
- * Creates the minified version.
101
- */
102
- function makeminified() {
103
- const d1 = new Date();
104
- process.stdout.write('Starting \'\x1b[36mmakeminified\x1b[89m\x1b[0m\'...\n');
105
-
106
- let f;
107
- f = fs.readFileSync(`${libdir}/${name}.js`, 'utf-8');
108
- f = f.replace(/\/\*! \*\*\*/g, '/** ***');
109
- minify(f, { compress: false, mangle: true })
110
- .then((result) => {
111
- fs.writeFileSync(`${dist}/lib/${name}.min.js`, `${license}!${result.code}`);
112
-
113
- const d2 = new Date() - d1;
114
- process.stdout.write(`Finished '\x1b[36mmakeminified\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
115
- });
116
- }
117
-
118
-
119
- /**
120
- * Creates the module minified version.
121
- */
122
- function makeminifiedm() {
123
- const d1 = new Date();
124
- process.stdout.write('Starting \'\x1b[36mmakeminifiedm\x1b[89m\x1b[0m\'...\n');
125
-
126
- let f;
127
- f = fs.readFileSync(`${libdir}/${name}.mjs`, 'utf-8');
128
- f = f.replace(/\/\*! \*\*\*/g, '/** ***');
129
- minify(f, { compress: false, mangle: true })
130
- .then((result) => {
131
- fs.writeFileSync(`${dist}/lib/${name}.min.mjs`, `${license}!${result.code}`);
132
-
133
- const d2 = new Date() - d1;
134
- process.stdout.write(`Finished '\x1b[36mmakeminifiedm\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
135
- });
136
- }
137
-
138
-
139
- // -- Public Task(s):
140
-
141
- const d1 = new Date();
142
- process.stdout.write('Starting \'\x1b[36mbuild:js:prod\x1b[89m\x1b[0m\'...\n');
143
- deldist();
144
- doskeleton();
145
- copydev();
146
- copydevm();
147
- makeminified();
148
- makeminifiedm();
149
-
150
- const d2 = new Date() - d1;
151
- process.stdout.write(`Finished '\x1b[36mbuild:js:prod\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
152
-
153
-
154
- // -- oOo --
File without changes