neo.mjs 3.0.5 → 3.1.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.
Files changed (34) hide show
  1. package/README.md +0 -2
  2. package/apps/website/data/blog.json +26 -0
  3. package/buildScripts/buildAll.mjs +136 -0
  4. package/buildScripts/buildThemes.mjs +434 -0
  5. package/buildScripts/{copyFolder.js → copyFolder.mjs} +3 -5
  6. package/buildScripts/createApp.mjs +288 -0
  7. package/buildScripts/docs/{jsdocx.js → jsdocx.mjs} +31 -32
  8. package/buildScripts/webpack/buildMyApps.mjs +125 -0
  9. package/buildScripts/webpack/buildThreads.mjs +115 -0
  10. package/buildScripts/webpack/development/{webpack.config.appworker.js → webpack.config.appworker.mjs} +20 -22
  11. package/buildScripts/webpack/development/webpack.config.main.mjs +24 -0
  12. package/buildScripts/webpack/development/{webpack.config.myapps.js → webpack.config.myapps.mjs} +15 -15
  13. package/buildScripts/webpack/development/{webpack.config.worker.js → webpack.config.worker.mjs} +12 -9
  14. package/buildScripts/webpack/production/{webpack.config.appworker.js → webpack.config.appworker.mjs} +20 -22
  15. package/buildScripts/webpack/production/webpack.config.main.mjs +23 -0
  16. package/buildScripts/webpack/production/{webpack.config.myapps.js → webpack.config.myapps.mjs} +15 -15
  17. package/buildScripts/webpack/production/{webpack.config.worker.js → webpack.config.worker.mjs} +12 -9
  18. package/buildScripts/webpack/{webpack.server.config.js → webpack.server.config.mjs} +2 -2
  19. package/docs/app/view/classdetails/MembersList.mjs +7 -13
  20. package/package.json +14 -13
  21. package/src/DefaultConfig.mjs +1 -1
  22. package/src/Neo.mjs +13 -13
  23. package/src/list/plugin/Animate.mjs +59 -11
  24. package/src/main/addon/AmCharts.mjs +2 -2
  25. package/src/manager/DomEvent.mjs +1 -1
  26. package/src/worker/Base.mjs +6 -5
  27. package/buildScripts/buildAll.js +0 -148
  28. package/buildScripts/buildThemes.js +0 -442
  29. package/buildScripts/createApp.js +0 -283
  30. package/buildScripts/webpack/buildMyApps.js +0 -125
  31. package/buildScripts/webpack/buildThreads.js +0 -112
  32. package/buildScripts/webpack/development/webpack.config.main.js +0 -21
  33. package/buildScripts/webpack/index.ejs +0 -25
  34. package/buildScripts/webpack/production/webpack.config.main.js +0 -20
@@ -0,0 +1,288 @@
1
+ import chalk from 'chalk';
2
+ import { spawnSync } from 'child_process';
3
+ import { Command } from 'commander/esm.mjs';
4
+ import envinfo from 'envinfo';
5
+ import fs from 'fs-extra';
6
+ import inquirer from 'inquirer';
7
+ import os from 'os';
8
+ import path from 'path';
9
+
10
+ const __dirname = path.resolve(),
11
+ cwd = process.cwd(),
12
+ requireJson = path => JSON.parse(fs.readFileSync((path))),
13
+ packageJson = requireJson(path.join(__dirname, 'package.json')),
14
+ insideNeo = packageJson.name === 'neo.mjs',
15
+ neoPath = insideNeo ? './' : './node_modules/neo.mjs/',
16
+ addonChoices = fs.readdirSync(path.join(neoPath, '/src/main/addon')).map(item => item.slice(0, -4)),
17
+ program = new Command(),
18
+ programName = `${packageJson.name} create-app`,
19
+ questions = [],
20
+ scssFolders = fs.readdirSync(path.join(neoPath, '/resources/scss')),
21
+ themeFolders = [];
22
+
23
+ scssFolders.forEach(folder => {
24
+ if (folder.includes('theme')) {
25
+ themeFolders.push(`neo-${folder}`);
26
+ }
27
+ });
28
+
29
+ program
30
+ .name(programName)
31
+ .version(packageJson.version)
32
+ .option('-i, --info', 'print environment debug info')
33
+ .option('-a, --appName <value>')
34
+ .option('-m, --mainThreadAddons <value>', `Comma separated list of:\n${addonChoices.join(', ')}\nDefaults to DragDrop, Stylesheet`)
35
+ .option('-t, --themes <value>', ['all', ...themeFolders, 'none'].join(", "))
36
+ .option('-u, --useSharedWorkers <value>', '"yes", "no"')
37
+ .allowUnknownOption()
38
+ .on('--help', () => {
39
+ console.log('\nIn case you have any issues, please create a ticket here:');
40
+ console.log(chalk.cyan(process.env.npm_package_bugs_url));
41
+ })
42
+ .parse(process.argv);
43
+
44
+ const programOpts = program.opts();
45
+
46
+ if (programOpts.info) {
47
+ console.log(chalk.bold('\nEnvironment Info:'));
48
+ console.log(`\n current version of ${packageJson.name}: ${packageJson.version}`);
49
+ console.log(` running from ${__dirname}`);
50
+
51
+ envinfo
52
+ .run({
53
+ System : ['OS', 'CPU'],
54
+ Binaries : ['Node', 'npm', 'Yarn'],
55
+ Browsers : ['Chrome', 'Edge', 'Firefox', 'Safari'],
56
+ npmPackages: ['neo.mjs']
57
+ }, {
58
+ duplicates : true,
59
+ showNotFound: true
60
+ })
61
+ .then(console.log);
62
+ } else {
63
+ console.log(chalk.green(programName));
64
+
65
+ if (programOpts.mainThreadAddons) {
66
+ programOpts.mainThreadAddons = programOpts.mainThreadAddons.split(',');
67
+ }
68
+
69
+ if (!programOpts.appName) {
70
+ questions.push({
71
+ type : 'input',
72
+ name : 'appName',
73
+ message: 'Please choose a name for your neo app:',
74
+ default: 'MyApp'
75
+ });
76
+ }
77
+
78
+ if (!programOpts.themes) {
79
+ questions.push({
80
+ type : 'list',
81
+ name : 'themes',
82
+ message: 'Please choose a theme for your neo app:',
83
+ choices: ['all', ...themeFolders, 'none'],
84
+ default: 'all'
85
+ });
86
+ }
87
+
88
+ if (!programOpts.mainThreadAddons) {
89
+ questions.push({
90
+ type : 'checkbox',
91
+ name : 'mainThreadAddons',
92
+ message: 'Please choose your main thread addons:',
93
+ choices: addonChoices,
94
+ default: ['DragDrop', 'Stylesheet']
95
+ });
96
+ }
97
+
98
+ if (!programOpts.useSharedWorkers) {
99
+ questions.push({
100
+ type : 'list',
101
+ name : 'useSharedWorkers',
102
+ message: 'Do you want to use SharedWorkers? Pick yes for multiple main threads (Browser Windows):',
103
+ choices: ['yes', 'no'],
104
+ default: 'no'
105
+ });
106
+ }
107
+
108
+ inquirer.prompt(questions).then(answers => {
109
+ let appName = programOpts.appName || answers.appName,
110
+ mainThreadAddons = programOpts.mainThreadAddons || answers.mainThreadAddons,
111
+ themes = programOpts.themes || answers.themes,
112
+ useSharedWorkers = programOpts.useSharedWorkers || answers.useSharedWorkers,
113
+ lAppName = appName.toLowerCase(),
114
+ appPath = 'apps/' + lAppName + '/',
115
+ dir = 'apps/' + lAppName,
116
+ folder = path.resolve(cwd, dir),
117
+ startDate = new Date();
118
+
119
+ if (!Array.isArray(themes)) {
120
+ themes = [themes];
121
+ }
122
+
123
+ if (themes.length > 0 && !themes.includes('none') && !mainThreadAddons.includes('Stylesheet')) {
124
+ console.error('ERROR! The Stylesheet mainThreadAddon is mandatory in case you are using themes');
125
+ console.log('Exiting with error.');
126
+ process.exit(1);
127
+ }
128
+
129
+ fs.mkdir(path.join(folder, '/view'), { recursive: true }, (err) => {
130
+ if (err) {
131
+ throw err;
132
+ }
133
+
134
+ const appContent = [
135
+ "import MainContainer from './view/MainContainer.mjs';",
136
+ "",
137
+ "const onStart = () => Neo.app({",
138
+ " mainView: MainContainer,",
139
+ " name : '" + appName + "'",
140
+ "});",
141
+ "",
142
+ "export {onStart as onStart};"
143
+ ].join(os.EOL);
144
+
145
+ fs.writeFileSync(folder + '/app.mjs', appContent);
146
+
147
+ const indexContent = [
148
+ "<!DOCTYPE HTML>",
149
+ "<html>",
150
+ "<head>",
151
+ ' <meta name="viewport" content="width=device-width, initial-scale=1">',
152
+ ' <meta charset="UTF-8">',
153
+ " <title>" + appName + "</title>",
154
+ "</head>",
155
+ "<body>",
156
+ ' <script src="../../src/MicroLoader.mjs" type="module"></script>',
157
+ "</body>",
158
+ "</html>",
159
+ ];
160
+
161
+ fs.writeFileSync(path.join(folder, 'index.html'), indexContent.join(os.EOL));
162
+
163
+ let neoConfig = {
164
+ appPath : `${insideNeo ? '' : '../../'}${appPath}app.mjs`,
165
+ basePath : '../../',
166
+ environment: 'development',
167
+ mainPath : './Main.mjs'
168
+ };
169
+
170
+ if (!(mainThreadAddons.includes('DragDrop') && mainThreadAddons.includes('Stylesheet') && mainThreadAddons.length === 2)) {
171
+ neoConfig.mainThreadAddons = mainThreadAddons;
172
+ }
173
+
174
+ if (!themes.includes('all')) { // default value
175
+ if (themes.includes('none')) {
176
+ neoConfig.themes = [];
177
+ } else {
178
+ neoConfig.themes = themes;
179
+ }
180
+ }
181
+
182
+ if (useSharedWorkers !== 'no') {
183
+ neoConfig.useSharedWorkers = true;
184
+ }
185
+
186
+ if (!insideNeo) {
187
+ neoConfig.workerBasePath = '../../node_modules/neo.mjs/src/worker/';
188
+ }
189
+
190
+ let configs = Object.entries(neoConfig).sort((a, b) => a[0].localeCompare(b[0]));
191
+ neoConfig = {};
192
+
193
+ configs.forEach(([key, value]) => {
194
+ neoConfig[key] = value;
195
+ });
196
+
197
+ fs.writeFileSync(path.join(folder, 'neo-config.json'), JSON.stringify(neoConfig, null, 4));
198
+
199
+ const mainContainerContent = [
200
+ "import Component from '../../../" + (insideNeo ? '' : 'node_modules/neo.mjs/') + "src/component/Base.mjs';",
201
+ "import TabContainer from '../../../" + (insideNeo ? '' : 'node_modules/neo.mjs/') + "src/tab/Container.mjs';",
202
+ "import Viewport from '../../../" + (insideNeo ? '' : 'node_modules/neo.mjs/') + "src/container/Viewport.mjs';",
203
+ "",
204
+ "/**",
205
+ " * @class " + appName + ".view.MainContainer",
206
+ " * @extends Neo.container.Viewport",
207
+ " */",
208
+ "class MainContainer extends Viewport {",
209
+ " static getConfig() {return {",
210
+ " className: '" + appName + ".view.MainContainer',",
211
+ " autoMount: true,",
212
+ " layout : {ntype: 'fit'},",
213
+ "",
214
+ " items: [{",
215
+ " module: TabContainer,",
216
+ " height: 300,",
217
+ " width : 500,",
218
+ " style : {flex: 'none', margin: '20px'},",
219
+ "",
220
+ " itemDefaults: {",
221
+ " module: Component,",
222
+ " cls : ['neo-examples-tab-component'],",
223
+ " style : {padding: '20px'},",
224
+ " },",
225
+ "",
226
+ " items: [{",
227
+ " tabButtonConfig: {",
228
+ " iconCls: 'fa fa-home',",
229
+ " text : 'Tab 1'",
230
+ " },",
231
+ " vdom: {innerHTML: 'Welcome to your new Neo App.'}",
232
+ " }, {",
233
+ " tabButtonConfig: {",
234
+ " iconCls: 'fa fa-play-circle',",
235
+ " text : 'Tab 2'",
236
+ " },",
237
+ " vdom: {innerHTML: 'Have fun creating something awesome!'}",
238
+ " }]",
239
+ " }]",
240
+ " }}",
241
+ "}",
242
+ "",
243
+ "Neo.applyClassConfig(MainContainer);",
244
+ "",
245
+ "export {MainContainer as default};"
246
+ ].join(os.EOL);
247
+
248
+ fs.writeFileSync(path.join(folder + '/view/MainContainer.mjs'), mainContainerContent);
249
+
250
+ let appJsonPath = path.resolve(cwd, 'buildScripts/myApps.json'),
251
+ appJson;
252
+
253
+ if (fs.existsSync(appJsonPath)) {
254
+ appJson = requireJson(appJsonPath);
255
+ } else {
256
+ appJsonPath = path.resolve(__dirname, 'buildScripts/webpack/json/myApps.json');
257
+
258
+ if (fs.existsSync(appJsonPath)) {
259
+ appJson = requireJson(appJsonPath);
260
+ } else {
261
+ appJson = requireJson(path.resolve(__dirname, 'buildScripts/webpack/json/myApps.template.json'));
262
+ }
263
+ }
264
+
265
+ if (!appJson.apps.includes(appName)) {
266
+ appJson.apps.push(appName);
267
+ appJson.apps.sort();
268
+ }
269
+
270
+ fs.writeFileSync(appJsonPath, JSON.stringify(appJson, null, 4));
271
+
272
+ if (mainThreadAddons.includes('HighlightJS')) {
273
+ spawnSync('node', [
274
+ './buildScripts/copyFolder.mjs',
275
+ '-s',
276
+ path.resolve(neoPath, 'docs/resources'),
277
+ '-t',
278
+ path.resolve(folder, 'resources'),
279
+ ], { env: process.env, cwd: process.cwd(), stdio: 'inherit' });
280
+ }
281
+
282
+ const processTime = (Math.round((new Date - startDate) * 100) / 100000).toFixed(2);
283
+ console.log(`\nTotal time for ${programName}: ${processTime}s`);
284
+
285
+ process.exit();
286
+ });
287
+ });
288
+ }
@@ -1,9 +1,12 @@
1
- const fs = require('fs-extra'),
2
- jsdocx = require('neo-jsdoc-x'),
3
- path = require('path'),
1
+ import fs from 'fs-extra';
2
+ import helper from 'neo-jsdoc-x/src/lib/helper.js';
3
+ import jsdocx from 'neo-jsdoc-x';
4
+ import path from 'path';
5
+
6
+ const __dirname = path.resolve(),
4
7
  cwd = process.cwd(),
5
- helper = require(path.join(cwd, 'node_modules/neo-jsdoc-x/src/lib/helper.js')),
6
- packageJson = require(path.resolve(process.cwd(), 'package.json')),
8
+ requireJson = path => JSON.parse(fs.readFileSync((path))),
9
+ packageJson = requireJson(path.resolve(cwd, 'package.json')),
7
10
  insideNeo = packageJson.name === 'neo.mjs',
8
11
  neoPath = insideNeo ? '' : 'node_modules/neo.mjs/',
9
12
  appNames = [],
@@ -20,25 +23,23 @@ let appJsonPath = path.resolve(cwd, 'buildScripts/myApps.json'),
20
23
  appJson;
21
24
 
22
25
  if (fs.existsSync(appJsonPath)) {
23
- appJson = require(appJsonPath);
26
+ appJson = requireJson(appJsonPath);
24
27
  } else {
25
- appJsonPath = path.resolve(__dirname, '../webpack/json/myApps.json');
28
+ appJsonPath = path.resolve(__dirname, 'buildScripts/webpack/json/myApps.json');
26
29
 
27
30
  if (fs.existsSync(appJsonPath)) {
28
- appJson = require(appJsonPath);
31
+ appJson = requireJson(appJsonPath);
29
32
  } else {
30
- appJson = require(path.resolve(__dirname, '../webpack/json/myApps.template.json'));
33
+ appJson = requireJson(path.resolve(__dirname, 'buildScripts/webpack/json/myApps.template.json'));
31
34
  }
32
35
  }
33
36
 
34
- if (appJson) {
35
- appJson.apps.forEach(key => {
36
- if (key !== 'Docs') { // the docs app is automatically included
37
- appNames.push(key);
38
- options.files.push(`apps/${key.toLowerCase()}/**/*.mjs`);
39
- }
40
- });
41
- }
37
+ appJson?.apps.forEach(key => {
38
+ if (key !== 'Docs') { // the docs app is automatically included
39
+ appNames.push(key);
40
+ options.files.push(`apps/${key.toLowerCase()}/**/*.mjs`);
41
+ }
42
+ });
42
43
 
43
44
  function ns(names, create) {
44
45
  names = Array.isArray(names) ? names : names.split('.');
@@ -50,7 +51,7 @@ function ns(names, create) {
50
51
  if (prev) {
51
52
  return prev[current];
52
53
  }
53
- }, this);
54
+ }, globalThis);
54
55
  }
55
56
 
56
57
  const neoStructure = [{
@@ -199,15 +200,15 @@ function generateStructure(target, parentId, docs) {
199
200
  // console.log(srcPath);
200
201
 
201
202
  neoStructure.push({
202
- className: className,
203
+ className,
203
204
  collapsed: appNames.includes(key) || key === 'Docs',
204
- id : id,
205
- isLeaf : isLeaf,
205
+ id,
206
+ isLeaf,
206
207
  name : key,
207
- path : path,
208
- parentId : parentId,
209
- singleton: singleton,
210
- srcPath : srcPath
208
+ path,
209
+ parentId,
210
+ singleton,
211
+ srcPath
211
212
  });
212
213
 
213
214
  generateStructure(target + '.' + key, id, docs);
@@ -326,13 +327,11 @@ jsdocx.parse(options)
326
327
  item.description = item.description.replace(/\n/g, "<br />");
327
328
  }
328
329
 
329
- if (item.params) {
330
- item.params.forEach(param => {
331
- if (param.description) {
332
- param.description = param.description.replace(/\n/g, "<br />");
333
- }
334
- });
335
- }
330
+ item.params?.forEach(param => {
331
+ if (param.description) {
332
+ param.description = param.description.replace(/\n/g, "<br />");
333
+ }
334
+ });
336
335
 
337
336
  if (item.kind === 'member') {
338
337
  if (item.comment) {
@@ -0,0 +1,125 @@
1
+ import chalk from 'chalk';
2
+ import { spawnSync } from 'child_process';
3
+ import { Command } from 'commander/esm.mjs';
4
+ import envinfo from 'envinfo';
5
+ import fs from 'fs-extra';
6
+ import inquirer from 'inquirer';
7
+ import os from 'os';
8
+ import path from 'path';
9
+
10
+ const __dirname = path.resolve(),
11
+ cwd = process.cwd(),
12
+ cpOpts = {env: process.env, cwd: cwd, stdio: 'inherit', shell: true},
13
+ requireJson = path => JSON.parse(fs.readFileSync((path))),
14
+ packageJson = requireJson(path.resolve(cwd, 'package.json')),
15
+ program = new Command(),
16
+ configPath = path.resolve(cwd, 'buildScripts/myApps.json'),
17
+ neoPath = packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/',
18
+ webpackPath = path.resolve(neoPath, 'buildScripts/webpack'),
19
+ programName = `${packageJson.name} buildMyApps`,
20
+ questions = [];
21
+
22
+ let webpack = './node_modules/.bin/webpack',
23
+ config;
24
+
25
+ if (fs.existsSync(configPath)) {
26
+ config = requireJson(configPath);
27
+ } else {
28
+ const myAppsPath = path.resolve(neoPath, 'buildScripts/webpack/json/myApps.json');
29
+
30
+ if (fs.existsSync(myAppsPath)) {
31
+ config = requireJson(myAppsPath);
32
+ } else {
33
+ config = requireJson(path.resolve(neoPath, 'buildScripts/webpack/json/myApps.template.json'));
34
+ }
35
+ }
36
+
37
+ let index = config.apps.indexOf('Docs');
38
+
39
+ index > -1 && config.apps.splice(index, 1);
40
+
41
+ program
42
+ .name(programName)
43
+ .version(packageJson.version)
44
+ .option('-i, --info', 'print environment debug info')
45
+ .option('-a, --apps <value>', ['all'].concat(config.apps).map(e => `"${e}"`).join(', '))
46
+ .option('-e, --env <value>', '"all", "dev", "prod"')
47
+ .option('-f, --framework')
48
+ .option('-n, --noquestions')
49
+ .allowUnknownOption()
50
+ .on('--help', () => {
51
+ console.log('\nIn case you have any issues, please create a ticket here:');
52
+ console.log(chalk.cyan(packageJson.bugs.url));
53
+ })
54
+ .parse(process.argv);
55
+
56
+ const programOpts = program.opts();
57
+
58
+ if (programOpts.info) {
59
+ console.log(chalk.bold('\nEnvironment Info:'));
60
+ console.log(`\n current version of ${packageJson.name}: ${packageJson.version}`);
61
+ console.log(` running from ${__dirname}`);
62
+
63
+ envinfo
64
+ .run({
65
+ System : ['OS', 'CPU'],
66
+ Binaries : ['Node', 'npm', 'Yarn'],
67
+ Browsers : ['Chrome', 'Edge', 'Firefox', 'Safari'],
68
+ npmPackages: ['neo.mjs']
69
+ }, {
70
+ duplicates : true,
71
+ showNotFound: true
72
+ })
73
+ .then(console.log);
74
+ } else {
75
+ console.log(chalk.green(programName));
76
+
77
+ if (!programOpts.noquestions) {
78
+ if (!programOpts.env) {
79
+ questions.push({
80
+ type : 'list',
81
+ name : 'env',
82
+ message: 'Please choose the environment:',
83
+ choices: ['all', 'dev', 'prod'],
84
+ default: 'all'
85
+ });
86
+ }
87
+
88
+ if (!programOpts.apps && config.apps.length > 1) {
89
+ questions.push({
90
+ type : 'checkbox',
91
+ name : 'apps',
92
+ message: 'Please choose which apps you want to build:',
93
+ choices: config.apps
94
+ });
95
+ }
96
+ }
97
+
98
+ inquirer.prompt(questions).then(answers => {
99
+ const apps = (answers.apps.length > 0 ? answers.apps : null) || programOpts.apps || ['all'],
100
+ env = answers.env || programOpts.env || ['all'],
101
+ insideNeo = !!programOpts.framework || false,
102
+ startDate = new Date();
103
+
104
+ if (os.platform().startsWith('win')) {
105
+ webpack = path.resolve(webpack).replace(/\\/g,'/');
106
+ }
107
+
108
+ // dist/development
109
+ if (env === 'all' || env === 'dev') {
110
+ console.log(chalk.blue(`${programName} starting dist/development`));
111
+ spawnSync(webpack, ['--config', `${webpackPath}/development/webpack.config.myapps.mjs`, `--env apps=${apps}`, `--env insideNeo=${insideNeo}`], cpOpts);
112
+ }
113
+
114
+ // dist/production
115
+ if (env === 'all' || env === 'prod') {
116
+ console.log(chalk.blue(`${programName} starting dist/production`));
117
+ spawnSync(webpack, ['--config', `${webpackPath}/production/webpack.config.myapps.mjs`, `--env apps=${apps}`, `--env insideNeo=${insideNeo}`], cpOpts);
118
+ }
119
+
120
+ const processTime = (Math.round((new Date - startDate) * 100) / 100000).toFixed(2);
121
+ console.log(`\nTotal time for ${programName}: ${processTime}s`);
122
+
123
+ process.exit();
124
+ });
125
+ }
@@ -0,0 +1,115 @@
1
+ import chalk from 'chalk';
2
+ import { spawnSync } from 'child_process';
3
+ import { Command } from 'commander/esm.mjs';
4
+ import envinfo from 'envinfo';
5
+ import fs from 'fs-extra';
6
+ import inquirer from 'inquirer';
7
+ import path from 'path';
8
+
9
+ const __dirname = path.resolve(),
10
+ cwd = process.cwd(),
11
+ cpOpts = {env: process.env, cwd: cwd, stdio: 'inherit', shell: true},
12
+ requireJson = path => JSON.parse(fs.readFileSync((path))),
13
+ packageJson = requireJson(path.resolve(cwd, 'package.json')),
14
+ neoPath = packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/',
15
+ program = new Command(),
16
+ webpackPath = path.resolve(neoPath, 'buildScripts/webpack'),
17
+ programName = `${packageJson.name} buildThreads`,
18
+ questions = [];
19
+
20
+ let webpack = './node_modules/.bin/webpack';
21
+
22
+ program
23
+ .name(programName)
24
+ .version(packageJson.version)
25
+ .option('-i, --info', 'print environment debug info')
26
+ .option('-e, --env <value>', '"all", "dev", "prod"')
27
+ .option('-f, --framework')
28
+ .option('-n, --noquestions')
29
+ .option('-t, --threads <value>', '"all", "app", "data", "main", "vdom"')
30
+ .allowUnknownOption()
31
+ .on('--help', () => {
32
+ console.log('\nIn case you have any issues, please create a ticket here:');
33
+ console.log(chalk.cyan(packageJson.bugs.url));
34
+ })
35
+ .parse(process.argv);
36
+
37
+ const programOpts = program.opts();
38
+
39
+ if (programOpts.info) {
40
+ console.log(chalk.bold('\nEnvironment Info:'));
41
+ console.log(`\n current version of ${packageJson.name}: ${packageJson.version}`);
42
+ console.log(` running from ${__dirname}`);
43
+
44
+ envinfo
45
+ .run({
46
+ System : ['OS', 'CPU'],
47
+ Binaries : ['Node', 'npm', 'Yarn'],
48
+ Browsers : ['Chrome', 'Edge', 'Firefox', 'Safari'],
49
+ npmPackages: ['neo.mjs']
50
+ }, {
51
+ duplicates : true,
52
+ showNotFound: true
53
+ })
54
+ .then(console.log);
55
+ } else {
56
+ console.log(chalk.green(programName));
57
+
58
+ if (!programOpts.noquestions) {
59
+ if (!programOpts.threads) {
60
+ questions.push({
61
+ type : 'list',
62
+ name : 'threads',
63
+ message: 'Please choose the threads to build:',
64
+ choices: ['all', 'app', 'canvas', 'data', 'main', 'vdom'],
65
+ default: 'all'
66
+ });
67
+ }
68
+
69
+ if (!programOpts.env) {
70
+ questions.push({
71
+ type : 'list',
72
+ name : 'env',
73
+ message: 'Please choose the environment:',
74
+ choices: ['all', 'dev', 'prod'],
75
+ default: 'all'
76
+ });
77
+ }
78
+ }
79
+
80
+ inquirer.prompt(questions).then(answers => {
81
+ const env = answers.env || programOpts.env || 'all',
82
+ threads = answers.threads || programOpts.threads || 'all',
83
+ insideNeo = programOpts.framework || false,
84
+ startDate = new Date();
85
+
86
+ if (path.sep === '\\') {
87
+ webpack = path.resolve(webpack).replace(/\\/g,'/');
88
+ }
89
+
90
+ function parseThreads(tPath) {
91
+ (threads === 'all' || threads === 'main') && spawnSync(webpack, ['--config', `${tPath}.main.mjs`], cpOpts);
92
+ (threads === 'all' || threads === 'app') && spawnSync(webpack, ['--config', `${tPath}.appworker.mjs`, `--env insideNeo=${insideNeo}`], cpOpts);
93
+ (threads === 'all' || threads === 'canvas') && spawnSync(webpack, ['--config', `${tPath}.worker.mjs`, `--env insideNeo=${insideNeo} worker=canvas`], cpOpts);
94
+ (threads === 'all' || threads === 'data') && spawnSync(webpack, ['--config', `${tPath}.worker.mjs`, `--env insideNeo=${insideNeo} worker=data`], cpOpts);
95
+ (threads === 'all' || threads === 'vdom') && spawnSync(webpack, ['--config', `${tPath}.worker.mjs`, `--env insideNeo=${insideNeo} worker=vdom`], cpOpts);
96
+ }
97
+
98
+ // dist/development
99
+ if (env === 'all' || env === 'dev') {
100
+ console.log(chalk.blue(`${programName} starting dist/development`));
101
+ parseThreads(`${webpackPath}/development/webpack.config`);
102
+ }
103
+
104
+ // dist/production
105
+ if (env === 'all' || env === 'prod') {
106
+ console.log(chalk.blue(`${programName} starting dist/production`));
107
+ parseThreads(`${webpackPath}/production/webpack.config`);
108
+ }
109
+
110
+ const processTime = (Math.round((new Date - startDate) * 100) / 100000).toFixed(2);
111
+ console.log(`\nTotal time for ${programName}: ${processTime}s`);
112
+
113
+ process.exit();
114
+ });
115
+ }