@mobilabs/es6lib 1.0.14 → 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.
@@ -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/compress.sh CHANGED
File without changes
package/tasks/config.js CHANGED
@@ -58,6 +58,12 @@ module.exports = {
58
58
  ],
59
59
  /* eslint-enable no-multi-spaces */
60
60
 
61
+ webfiles: [
62
+ // These are the files to copy to the root path of the web app,
63
+ './README.md',
64
+ './LICENSE.md',
65
+ ],
66
+
61
67
  get license() {
62
68
  return ['/*! ****************************************************************************',
63
69
  ` * ${libname} v${pack.version}`,
@@ -0,0 +1,99 @@
1
+ /* eslint one-var: 0, import/no-extraneous-dependencies: 0, semi-style: 0 */
2
+
3
+ 'use strict';
4
+
5
+ // -- Vendor Modules
6
+ const fs = require('fs')
7
+ , path = require('path')
8
+ ;
9
+
10
+
11
+ // -- Local Modules
12
+ const config = require('./config')
13
+ ;
14
+
15
+
16
+ // -- Local Constants
17
+ const tmppriv = './private_repo/tmp'
18
+ , { name } = config
19
+ , { index } = config
20
+ , { distlink } = config
21
+ ;
22
+
23
+
24
+ // -- Local Variables
25
+
26
+
27
+ // -- Private Tasks
28
+
29
+ /**
30
+ * Removes the previous version.
31
+ */
32
+ function clear() {
33
+ const d1 = new Date();
34
+ process.stdout.write('Starting \'\x1b[36mclear\x1b[89m\x1b[0m\'...\n');
35
+
36
+
37
+ fs.rmSync(tmppriv, { force: true, recursive: true });
38
+ fs.mkdirSync(tmppriv, { recursive: true });
39
+
40
+ const d2 = new Date() - d1;
41
+ process.stdout.write(`Finished '\x1b[36mclear\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
42
+ }
43
+
44
+
45
+ /**
46
+ * Copies the modified index.
47
+ */
48
+ function copyindex() {
49
+ const d1 = new Date();
50
+ process.stdout.write('Starting \'\x1b[36mcopyindex\x1b[89m\x1b[0m\'...\n');
51
+
52
+ let f = fs.readFileSync(index, 'utf-8');
53
+ f = f.replace(`./lib/${name}`, distlink);
54
+
55
+ const filename = path.basename(index);
56
+ fs.writeFileSync(`${tmppriv}/${filename}`, f);
57
+ const d2 = new Date() - d1;
58
+ process.stdout.write(`Finished '\x1b[36mcopyindex\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
59
+ }
60
+
61
+
62
+ /**
63
+ * Copies the modified package.json
64
+ */
65
+ function copypackagejson() {
66
+ const d1 = new Date();
67
+ process.stdout.write('Starting \'\x1b[36mcopypackagejson\x1b[89m\x1b[0m\'...\n');
68
+
69
+ const json = fs.readFileSync('./package.json', 'utf8');
70
+ const obj = JSON.parse(json);
71
+
72
+ obj.main = distlink;
73
+ obj.bin = {};
74
+ obj.scripts = {};
75
+ obj.dependencies = {};
76
+ obj.devDependencies = {};
77
+ obj.private = true;
78
+ obj.husky = {};
79
+
80
+ fs.writeFileSync(`${tmppriv}/package.json`, JSON.stringify(obj, null, 2), 'utf8');
81
+
82
+ const d2 = new Date() - d1;
83
+ process.stdout.write(`Finished '\x1b[36mcopypackagejson\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
84
+ }
85
+
86
+
87
+ // -- Public Task(s)
88
+ const d1 = new Date();
89
+ process.stdout.write('Starting \'\x1b[36mdep:private\x1b[89m\x1b[0m\'...\n');
90
+
91
+ clear();
92
+ copyindex();
93
+ copypackagejson();
94
+
95
+ const d2 = new Date() - d1;
96
+ process.stdout.write(`Finished '\x1b[36mdep:private\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
97
+
98
+
99
+ // -- oOo --
@@ -0,0 +1,59 @@
1
+ <!-- x -->
2
+ <!doctype html>
3
+ <html class="no-js" lang="">
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <title>View ES6lib</title>
7
+ <meta name="description" content="{{app:description}}">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+
10
+ <link rel="stylesheet" href="">
11
+ <meta name="theme-color" content="#2196f3">
12
+ <style>
13
+ /* - */
14
+ </style>
15
+
16
+ <!-- <script src='./lib/view.js'></script> -->
17
+ <script>
18
+ document.addEventListener('DOMContentLoaded', () => {
19
+ /* global Pixi */
20
+ 'use strict';
21
+ //
22
+ });
23
+ </script>
24
+ </head>
25
+
26
+ <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
+ <!-- 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>
37
+
38
+ <!-- Add your site or application content here -->
39
+ <div id="app"></div>
40
+
41
+ <!-- Add your scripts here -->
42
+ <script type="module">
43
+ import ES6lib from '../lib/es6lib.mjs';
44
+
45
+ console.log(ES6lib.VERSION);
46
+ console.log(Object.keys(ES6lib));
47
+
48
+ const lib = ES6lib();
49
+ console.log(lib.getString());
50
+ console.log(lib.getArray());
51
+
52
+ const el = document.getElementById('app');
53
+ el.append(`Es6lib $v${ES6lib.VERSION}`);
54
+ el.append(` ... ${lib.getString()}`);
55
+ el.append(` ... ${lib.getArray()}`);
56
+
57
+ </script>
58
+ </body>
59
+ </html>
package/gulpfile.js DELETED
@@ -1,67 +0,0 @@
1
- /* eslint one-var: 0, semi-style: 0 */
2
-
3
- 'use strict';
4
-
5
- // -- Vendor Modules
6
- const { watch, series } = require('gulp')
7
- , connect = require('gulp-connect')
8
- , open = require('open')
9
- ;
10
-
11
-
12
- // -- Local Modules
13
-
14
-
15
- // -- Local Constants
16
- const filesToWatch = ['src/**/*.js', 'src/_header', 'src/_footer']
17
- ;
18
-
19
-
20
- // -- Local Variables
21
-
22
-
23
- // -- Gulp Private Tasks
24
- const build = require('./tasks/makejs')
25
- , makedist = require('./tasks/makedist')
26
- , makeprivate = require('./tasks/makeprivatepackage')
27
- ;
28
-
29
-
30
- // -- Gulp watch
31
- function fwatch() {
32
- watch(filesToWatch, series(build));
33
- }
34
-
35
- // -- Gulp connect dev
36
- function devserver(done) {
37
- connect.server({
38
- host: '0.0.0.0', // (allows remote access)
39
- root: './',
40
- port: 8888,
41
- livereload: true,
42
- });
43
- open('http://localhost:8888/');
44
- done();
45
- }
46
-
47
- // -- Gulp connect prod
48
- function appserver(done) {
49
- connect.server({
50
- host: '0.0.0.0', // (allows remote access)
51
- root: './_dist',
52
- port: 8889,
53
- livereload: true,
54
- });
55
- open('http://localhost:8889/');
56
- done();
57
- }
58
-
59
-
60
- // Gulp Public Tasks:
61
- exports.build = build;
62
- exports.watch = fwatch;
63
- exports.rundev = devserver;
64
- exports.makedist = makedist;
65
- exports.runapp = appserver;
66
- exports.makeprivate = makeprivate;
67
- exports.default = series(build, makedist, makeprivate);
package/tasks/makedist.js DELETED
@@ -1,91 +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 { src, dest, series, parallel } = require('gulp')
8
- , del = require('del')
9
- , concat = require('gulp-concat')
10
- , header = require('gulp-header')
11
- , replace = require('gulp-replace')
12
- , uglify = require('gulp-uglify-es').default
13
- ;
14
-
15
-
16
- // -- Local Modules
17
- const config = require('./config')
18
- ;
19
-
20
-
21
- // -- Local Constants
22
- const { dist } = config
23
- , { libdir } = config
24
- , { name } = config
25
- , { license } = config
26
- ;
27
-
28
-
29
- // -- Local Variables
30
-
31
-
32
- // -- Gulp Private Tasks
33
-
34
- // Removes the previous dist.
35
- function deldist(done) {
36
- del.sync(dist);
37
- done();
38
- }
39
-
40
- // Copies README and LICENSE.
41
- function doskeleton() {
42
- return src(['README.md', 'LICENSE.md'])
43
- .pipe(dest(dist))
44
- ;
45
- }
46
-
47
- // Copies the development version.
48
- function copydev() {
49
- return src(`${libdir}/${name}.js`)
50
- .pipe(header(license))
51
- .pipe(dest(`${dist}/lib`))
52
- ;
53
- }
54
-
55
- // Copies the module development version.
56
- function copydevm() {
57
- return src(`${libdir}/${name}.mjs`)
58
- .pipe(header(license))
59
- .pipe(dest(`${dist}/lib`))
60
- ;
61
- }
62
-
63
- // Creates the minified version.
64
- function makeminified() {
65
- return src(`${libdir}/${name}.js`)
66
- .pipe(replace('/*! ***', '/** ***'))
67
- .pipe(uglify())
68
- .pipe(header(license))
69
- .pipe(concat(`${name}.min.js`))
70
- .pipe(dest(`${dist}/lib`))
71
- ;
72
- }
73
-
74
- // Creates the module minified version.
75
- function makeminifiedm() {
76
- return src(`${libdir}/${name}.mjs`)
77
- .pipe(replace('/*! ***', '/** ***'))
78
- .pipe(uglify())
79
- .pipe(header(license))
80
- .pipe(concat(`${name}.min.mjs`))
81
- .pipe(dest(`${dist}/lib`))
82
- ;
83
- }
84
-
85
-
86
- // -- Gulp Public Task(s):
87
-
88
- module.exports = series(
89
- deldist,
90
- parallel(doskeleton, copydev, copydevm, makeminified, makeminifiedm),
91
- );
package/tasks/makejs.js DELETED
@@ -1,103 +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 { src, dest, series, parallel } = require('gulp')
8
- , del = require('del')
9
- , concat = require('gulp-concat')
10
- , replace = require('gulp-replace')
11
- ;
12
-
13
-
14
- // -- Local Modules
15
- const pack = require('../package.json')
16
- , config = require('./config')
17
- ;
18
-
19
-
20
- // -- Local Constants
21
- const destination = config.libdir
22
- , { ES6GLOB } = config
23
- , source = config.src
24
- , { libname } = config
25
- , { name } = config
26
- , head = source[0]
27
- , core = source.slice(1, -1)
28
- , foot = source[source.length - 1]
29
- , { version } = pack
30
- ;
31
-
32
-
33
- // -- Local Variables
34
-
35
-
36
- // -- Gulp Private Tasks
37
-
38
- // Removes the previous version.
39
- function clean(done) {
40
- del.sync(destination);
41
- done();
42
- }
43
-
44
- // Creates the content.
45
- function docore() {
46
- return src(core)
47
- .pipe(replace('{{lib:name}}', libname))
48
- .pipe(replace('{{lib:version}}', version))
49
- // remove the extra global and 'use strict':
50
- .pipe(replace(/\/\* global[\w$_\s,]+\*\//g, '/* - */'))
51
- .pipe(replace(/\n'use strict';\n/, ''))
52
- // indent the first line with 2 spaces:
53
- .pipe(replace(/^/g, ' '))
54
- // indent each other lines with 2 spaces:
55
- .pipe(replace(/\n/g, '\n '))
56
- .pipe(concat('core.js'))
57
- .pipe(dest(destination))
58
- ;
59
- }
60
-
61
- // Create the UMD Module.
62
- function doumdlib() {
63
- return src([head, `${destination}/core.js`, foot])
64
- .pipe(replace('{{lib:es6:define}}\n', ''))
65
- .pipe(replace('{{lib:es6:link}}', 'this'))
66
- .pipe(replace('{{lib:es6:export}}\n', ''))
67
- .pipe(concat(`${name}.js`))
68
- // fix the blanck lines we indented too:
69
- .pipe(replace(/\s{2}\n/g, '\n'))
70
- .pipe(dest(destination))
71
- ;
72
- }
73
-
74
- // Creates the ES6 module.
75
- function domodule() {
76
- let exportM = '\n// -- Export\n';
77
- exportM += `export default ${ES6GLOB}.${libname};`;
78
-
79
- return src([head, `${destination}/core.js`, foot])
80
- .pipe(replace('{{lib:es6:define}}', `const ${ES6GLOB} = {};`))
81
- .pipe(replace('{{lib:es6:link}}', ES6GLOB))
82
- .pipe(replace('{{lib:es6:export}}', exportM))
83
- .pipe(concat(`${name}.mjs`))
84
- // fix the blanck lines we indented too:
85
- .pipe(replace(/\s{2}\n/g, '\n'))
86
- .pipe(dest(destination))
87
- ;
88
- }
89
-
90
- // Removes the temp file(s).
91
- function delcore(done) {
92
- del.sync(`${destination}/core.js`);
93
- done();
94
- }
95
-
96
-
97
- // -- Gulp Public Task(s)
98
- module.exports = series(
99
- clean,
100
- docore,
101
- parallel(doumdlib, domodule),
102
- delcore,
103
- );
@@ -1,71 +0,0 @@
1
- /* eslint one-var: 0, import/no-extraneous-dependencies: 0, semi-style: 0 */
2
-
3
- 'use strict';
4
-
5
- // -- Vendor Modules
6
- const { src, dest, series } = require('gulp')
7
- , fs = require('fs')
8
- , del = require('del')
9
- , replace = require('gulp-replace')
10
- ;
11
-
12
-
13
- // -- Local Modules
14
- const config = require('./config')
15
- ;
16
-
17
-
18
- // -- Local Constants
19
- const tmppriv = './private_repo/tmp'
20
- , { name } = config
21
- , { index } = config
22
- , { distlink } = config
23
- ;
24
-
25
-
26
- // -- Local Variables
27
-
28
-
29
- // -- Gulp Private Tasks
30
-
31
- // Removes the previous version.
32
- function clear(done) {
33
- del.sync(tmppriv);
34
- done();
35
- }
36
-
37
- // Copies the modified index.
38
- function copyindex() {
39
- return src(index)
40
- .pipe(replace(`./lib/${name}`, distlink))
41
- .pipe(dest(tmppriv))
42
- ;
43
- }
44
-
45
- // Copies the modified package.json
46
- function copypackagejson(done) {
47
- fs.readFile('./package.json', 'utf8', (error, data) => {
48
- if (error) { throw error; }
49
- const obj = JSON.parse(data);
50
- obj.main = distlink;
51
- obj.bin = {};
52
- obj.scripts = {};
53
- obj.dependencies = {};
54
- obj.devDependencies = {};
55
- obj.private = true;
56
- obj.husky = {};
57
-
58
- // Write the updated package.json:
59
- fs.writeFile(`${tmppriv}/package.json`, JSON.stringify(obj, null, 2), 'utf8', (err) => {
60
- if (err) {
61
- throw err;
62
- }
63
- done();
64
- });
65
- });
66
- }
67
-
68
-
69
- // -- Gulp Public Task(s)
70
-
71
- module.exports = series(clear, copyindex, copypackagejson);