neo.mjs 3.0.3 → 3.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/README.md +0 -2
- package/apps/website/data/blog.json +26 -0
- package/buildScripts/buildAll.mjs +136 -0
- package/buildScripts/buildThemes.mjs +444 -0
- package/buildScripts/{copyFolder.js → copyFolder.mjs} +3 -5
- package/buildScripts/createApp.mjs +288 -0
- package/buildScripts/docs/{jsdocx.js → jsdocx.mjs} +31 -32
- package/buildScripts/webpack/buildMyApps.mjs +125 -0
- package/buildScripts/webpack/buildThreads.mjs +115 -0
- package/buildScripts/webpack/development/{webpack.config.appworker.js → webpack.config.appworker.mjs} +20 -22
- package/buildScripts/webpack/development/webpack.config.main.mjs +24 -0
- package/buildScripts/webpack/development/{webpack.config.myapps.js → webpack.config.myapps.mjs} +15 -15
- package/buildScripts/webpack/development/{webpack.config.worker.js → webpack.config.worker.mjs} +12 -9
- package/buildScripts/webpack/production/{webpack.config.appworker.js → webpack.config.appworker.mjs} +20 -22
- package/buildScripts/webpack/production/webpack.config.main.mjs +23 -0
- package/buildScripts/webpack/production/{webpack.config.myapps.js → webpack.config.myapps.mjs} +15 -15
- package/buildScripts/webpack/production/{webpack.config.worker.js → webpack.config.worker.mjs} +12 -9
- package/buildScripts/webpack/{webpack.server.config.js → webpack.server.config.mjs} +2 -2
- package/docs/app/view/classdetails/MembersList.mjs +7 -13
- package/examples/list/animate/List.mjs +1 -1
- package/examples/list/animate/MainContainer.mjs +44 -5
- package/examples/list/animate/MainStore.mjs +17 -0
- package/package.json +14 -13
- package/resources/scss/src/examples/list/animate/List.scss +0 -1
- package/src/collection/Filter.mjs +7 -2
- package/src/list/Base.mjs +1 -1
- package/src/list/plugin/Animate.mjs +218 -71
- package/src/main/addon/Stylesheet.mjs +35 -2
- package/src/plugin/Base.mjs +5 -1
- package/src/util/Css.mjs +19 -5
- package/buildScripts/buildAll.js +0 -148
- package/buildScripts/buildThemes.js +0 -442
- package/buildScripts/createApp.js +0 -283
- package/buildScripts/webpack/buildMyApps.js +0 -125
- package/buildScripts/webpack/buildThreads.js +0 -112
- package/buildScripts/webpack/development/webpack.config.main.js +0 -21
- package/buildScripts/webpack/index.ejs +0 -25
- package/buildScripts/webpack/production/webpack.config.main.js +0 -20
package/README.md
CHANGED
|
@@ -19,8 +19,6 @@ No need to take care of a workers setup, and the cross channel communication on
|
|
|
19
19
|
<a href="https://youtu.be/aEA5333WiWY"><img height="316px" width="400px" src="https://raw.githubusercontent.com/neomjs/pages/master/resources/images/neo-movie.png"></a>
|
|
20
20
|
</p>
|
|
21
21
|
|
|
22
|
-
<a href="https://itnext.io/the-webworkers-driven-ui-framework-neo-mjs-version-2-release-announcement-b91b476d6f16?source=friends_link&sk=e6eb21f75475f431ad9215d63a44fb53">Version 2 release announcement</a>
|
|
23
|
-
|
|
24
22
|
## Content
|
|
25
23
|
1. <a href="#slack-channel">Slack Channel for questions & feedback</a>
|
|
26
24
|
2. <a href="#architectures">Scalable frontend architectures</a>
|
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"author" : "Tobias Uhlig",
|
|
4
|
+
"authorImage" : "author_TobiasUhlig.jpeg",
|
|
5
|
+
"date" : "Jan 17, 2022",
|
|
6
|
+
"id" : 49,
|
|
7
|
+
"image" : "scaling-your-micro-frontends-off-the-main-thread.png",
|
|
8
|
+
"name" : "Scaling your micro-frontends off the main thread",
|
|
9
|
+
"provider" : "Medium",
|
|
10
|
+
"publisher" : "ITNEXT",
|
|
11
|
+
"selectedInto": [],
|
|
12
|
+
"type" : "Blog Post",
|
|
13
|
+
"url" : "https://itnext.io/scaling-your-micro-frontends-off-the-main-thread-36dedf54c5bf?source=friends_link&sk=04620ee92b04adb4dba22c8ec98d1ef6"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"author" : "Tobias Uhlig",
|
|
17
|
+
"authorImage" : "author_TobiasUhlig.jpeg",
|
|
18
|
+
"date" : "Jan 10, 2022",
|
|
19
|
+
"id" : 48,
|
|
20
|
+
"image" : "intercepting-component-state-to-ensure-smooth-animated-transitions.png",
|
|
21
|
+
"name" : "Intercepting component state to ensure smooth animated transitions",
|
|
22
|
+
"provider" : "Medium",
|
|
23
|
+
"publisher" : "ITNEXT",
|
|
24
|
+
"selectedInto": [],
|
|
25
|
+
"type" : "Blog Post",
|
|
26
|
+
"url" : "https://itnext.io/intercepting-component-state-to-ensure-smooth-animated-transitions-4facd46414dd?source=friends_link&sk=95a0eaef0e0b15dfc12ddd071479c61c"
|
|
27
|
+
},
|
|
2
28
|
{
|
|
3
29
|
"author" : "Tobias Uhlig",
|
|
4
30
|
"authorImage" : "author_TobiasUhlig.jpeg",
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
npmCmd = os.platform().startsWith('win') ? 'npm.cmd' : 'npm', // npm binary based on OS
|
|
14
|
+
requireJson = path => JSON.parse(fs.readFileSync((path))),
|
|
15
|
+
packageJson = requireJson(path.join(__dirname, 'package.json')),
|
|
16
|
+
program = new Command(),
|
|
17
|
+
neoPath = path.resolve(packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/'),
|
|
18
|
+
webpackPath = path.resolve(neoPath, 'buildScripts/webpack'),
|
|
19
|
+
programName = `${packageJson.name} buildAll`,
|
|
20
|
+
questions = [];
|
|
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('-l, --npminstall <value>', '"yes", "no"')
|
|
28
|
+
.option('-f, --framework')
|
|
29
|
+
.option('-n, --noquestions')
|
|
30
|
+
.option('-p, --parsedocs <value>', '"yes", "no"')
|
|
31
|
+
.option('-t, --themes <value>', '"yes", "no"')
|
|
32
|
+
.option('-w, --threads <value>', '"yes", "no"')
|
|
33
|
+
.allowUnknownOption()
|
|
34
|
+
.on('--help', () => {
|
|
35
|
+
console.log('\nIn case you have any issues, please create a ticket here:');
|
|
36
|
+
console.log(chalk.cyan(packageJson.bugs.url));
|
|
37
|
+
})
|
|
38
|
+
.parse(process.argv);
|
|
39
|
+
|
|
40
|
+
const programOpts = program.opts();
|
|
41
|
+
|
|
42
|
+
if (programOpts.info) {
|
|
43
|
+
console.log(chalk.bold('\nEnvironment Info:'));
|
|
44
|
+
console.log(`\n current version of ${packageJson.name}: ${packageJson.version}`);
|
|
45
|
+
console.log(` running from ${__dirname}`);
|
|
46
|
+
|
|
47
|
+
envinfo
|
|
48
|
+
.run({
|
|
49
|
+
System : ['OS', 'CPU'],
|
|
50
|
+
Binaries : ['Node', 'npm', 'Yarn'],
|
|
51
|
+
Browsers : ['Chrome', 'Edge', 'Firefox', 'Safari'],
|
|
52
|
+
npmPackages: ['neo.mjs']
|
|
53
|
+
}, {
|
|
54
|
+
duplicates : true,
|
|
55
|
+
showNotFound: true
|
|
56
|
+
})
|
|
57
|
+
.then(console.log);
|
|
58
|
+
} else {
|
|
59
|
+
console.log(chalk.green(programName));
|
|
60
|
+
|
|
61
|
+
if (!programOpts.noquestions) {
|
|
62
|
+
if (!programOpts.npminstall) {
|
|
63
|
+
questions.push({
|
|
64
|
+
type : 'list',
|
|
65
|
+
name : 'npminstall',
|
|
66
|
+
message: 'Run npm install?:',
|
|
67
|
+
choices: ['yes', 'no'],
|
|
68
|
+
default: 'all'
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!programOpts.env) {
|
|
73
|
+
questions.push({
|
|
74
|
+
type : 'list',
|
|
75
|
+
name : 'env',
|
|
76
|
+
message: 'Please choose the environment:',
|
|
77
|
+
choices: ['all', 'dev', 'prod'],
|
|
78
|
+
default: 'all'
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!programOpts.npminstall) {
|
|
83
|
+
questions.push({
|
|
84
|
+
type : 'list',
|
|
85
|
+
name : 'themes',
|
|
86
|
+
message: 'Build the themes?',
|
|
87
|
+
choices: ['yes', 'no'],
|
|
88
|
+
default: 'yes'
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!programOpts.threads) {
|
|
93
|
+
questions.push({
|
|
94
|
+
type : 'list',
|
|
95
|
+
name : 'threads',
|
|
96
|
+
message: 'Build the threads?',
|
|
97
|
+
choices: ['yes', 'no'],
|
|
98
|
+
default: 'yes'
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!programOpts.parsedocs) {
|
|
103
|
+
questions.push({
|
|
104
|
+
type : 'list',
|
|
105
|
+
name : 'parsedocs',
|
|
106
|
+
message: 'Trigger the jsdocx parsing?',
|
|
107
|
+
choices: ['yes', 'no'],
|
|
108
|
+
default: 'yes'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
inquirer.prompt(questions).then(answers => {
|
|
114
|
+
const env = answers.env || programOpts.env || 'all',
|
|
115
|
+
npminstall = answers.npminstall || programOpts.npminstall || 'yes',
|
|
116
|
+
parsedocs = answers.parsedocs || programOpts.parsedocs || 'yes',
|
|
117
|
+
themes = answers.themes || programOpts.themes || 'yes',
|
|
118
|
+
threads = answers.threads || programOpts.threads || 'yes',
|
|
119
|
+
insideNeo = !!programOpts.framework || false,
|
|
120
|
+
cpArgs = ['-e', env],
|
|
121
|
+
startDate = new Date();
|
|
122
|
+
|
|
123
|
+
programOpts.noquestions && cpArgs.push('-n');
|
|
124
|
+
insideNeo && cpArgs.push('-f');
|
|
125
|
+
|
|
126
|
+
npminstall === 'yes' && spawnSync(npmCmd, ['i'], cpOpts);
|
|
127
|
+
themes === 'yes' && spawnSync('node', [`${neoPath}/buildScripts/buildThemes.mjs`].concat(cpArgs), cpOpts);
|
|
128
|
+
threads === 'yes' && spawnSync('node', [`${webpackPath}/buildThreads.mjs`] .concat(cpArgs), cpOpts);
|
|
129
|
+
parsedocs === 'yes' && spawnSync(npmCmd, ['run', 'generate-docs-json'], cpOpts);
|
|
130
|
+
|
|
131
|
+
const processTime = (Math.round((new Date - startDate) * 100) / 100000).toFixed(2);
|
|
132
|
+
console.log(`\nTotal time for ${programName}: ${processTime}s`);
|
|
133
|
+
|
|
134
|
+
process.exit();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import autoprefixer from 'autoprefixer';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import cssnano from 'cssnano';
|
|
4
|
+
import { Command } from 'commander/esm.mjs';
|
|
5
|
+
import envinfo from 'envinfo';
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
import inquirer from 'inquirer';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import postcss from 'postcss';
|
|
10
|
+
import sass from 'sass';
|
|
11
|
+
|
|
12
|
+
const cwd = process.cwd(),
|
|
13
|
+
requireJson = path => JSON.parse(fs.readFileSync((path))),
|
|
14
|
+
packageJson = requireJson(path.resolve(cwd, 'package.json')),
|
|
15
|
+
neoPath = packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/',
|
|
16
|
+
programName = `${packageJson.name} buildThemes`,
|
|
17
|
+
program = new Command(),
|
|
18
|
+
regexComments = /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,
|
|
19
|
+
regexLineBreak = /(\r\n|\n|\r)/gm,
|
|
20
|
+
regexSassImport = /@import[^'"]+?['"](.+?)['"];?/g,
|
|
21
|
+
scssFolders = fs.readdirSync(path.join(neoPath, '/resources/scss')),
|
|
22
|
+
scssPath = 'resources/scss/',
|
|
23
|
+
themeMapFile = 'resources/theme-map.json',
|
|
24
|
+
themeMapFileNoVars = 'resources/theme-map-no-vars.json',
|
|
25
|
+
themeFolders = [],
|
|
26
|
+
questions = [];
|
|
27
|
+
|
|
28
|
+
scssFolders.forEach(folder => {
|
|
29
|
+
if (folder.includes('theme')) {
|
|
30
|
+
themeFolders.push(folder);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
program
|
|
35
|
+
.name(programName)
|
|
36
|
+
.version(packageJson.version)
|
|
37
|
+
.option('-i, --info', 'print environment debug info')
|
|
38
|
+
.option('-c, --cssVars <value>', '"all", "true", "false"')
|
|
39
|
+
.option('-e, --env <value>', '"all", "dev", "prod"')
|
|
40
|
+
.option('-f, --framework')
|
|
41
|
+
.option('-n, --noquestions')
|
|
42
|
+
.option('-t, --themes <value>', ["all", ...themeFolders].join(", "))
|
|
43
|
+
.allowUnknownOption()
|
|
44
|
+
.on('--help', () => {
|
|
45
|
+
console.log('\nIn case you have any issues, please create a ticket here:');
|
|
46
|
+
console.log(chalk.cyan(packageJson.bugs.url));
|
|
47
|
+
})
|
|
48
|
+
.parse(process.argv);
|
|
49
|
+
|
|
50
|
+
const programOpts = program.opts();
|
|
51
|
+
|
|
52
|
+
if (programOpts.info) {
|
|
53
|
+
console.log(chalk.bold('\nEnvironment Info:'));
|
|
54
|
+
console.log(`\n current version of ${packageJson.name}: ${packageJson.version}`);
|
|
55
|
+
console.log(` running from ${__dirname}`);
|
|
56
|
+
|
|
57
|
+
envinfo
|
|
58
|
+
.run({
|
|
59
|
+
System : ['OS', 'CPU'],
|
|
60
|
+
Binaries : ['Node', 'npm', 'Yarn'],
|
|
61
|
+
Browsers : ['Chrome', 'Edge', 'Firefox', 'Safari'],
|
|
62
|
+
npmPackages : ['neo.mjs'],
|
|
63
|
+
npmGlobalPackages: ['neo-app']
|
|
64
|
+
}, {
|
|
65
|
+
duplicates : true,
|
|
66
|
+
showNotFound: true
|
|
67
|
+
})
|
|
68
|
+
.then(console.log);
|
|
69
|
+
} else {
|
|
70
|
+
console.log(chalk.green(programName));
|
|
71
|
+
|
|
72
|
+
if (!programOpts.noquestions) {
|
|
73
|
+
if (!programOpts.themes) {
|
|
74
|
+
questions.push({
|
|
75
|
+
type : 'list',
|
|
76
|
+
name : 'themes',
|
|
77
|
+
message: 'Please choose the themes to build:',
|
|
78
|
+
choices: ['all', ...themeFolders],
|
|
79
|
+
default: 'all'
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!programOpts.env) {
|
|
84
|
+
questions.push({
|
|
85
|
+
type : 'list',
|
|
86
|
+
name : 'env',
|
|
87
|
+
message: 'Please choose the environment:',
|
|
88
|
+
choices: ['all', 'dev', 'prod'],
|
|
89
|
+
default: 'all'
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!programOpts.cssVars) {
|
|
94
|
+
questions.push({
|
|
95
|
+
type : 'list',
|
|
96
|
+
name : 'cssVars',
|
|
97
|
+
message: 'Build using CSS variables?',
|
|
98
|
+
choices: ['all', 'yes', 'no'],
|
|
99
|
+
default: 'yes'
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
inquirer.prompt(questions).then(answers => {
|
|
105
|
+
const cssVars = answers.cssVars || programOpts.cssVars || 'all',
|
|
106
|
+
env = answers.env || programOpts.env || 'all',
|
|
107
|
+
themes = answers.themes || programOpts.themes || 'all',
|
|
108
|
+
insideNeo = programOpts.framework || false,
|
|
109
|
+
startDate = new Date(),
|
|
110
|
+
fileCount = {development: {vars: 0, noVars: 0}, production: {vars: 0, noVars: 0}},
|
|
111
|
+
totalFiles = {development: {vars: 0, noVars: 0}, production: {vars: 0, noVars: 0}},
|
|
112
|
+
sassThemes = [];
|
|
113
|
+
|
|
114
|
+
let themeMap, themeMapNoVars;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
* @param {Object} file
|
|
119
|
+
* @param {String} target
|
|
120
|
+
* @param {Boolean} useCssVars
|
|
121
|
+
*/
|
|
122
|
+
function addItemToThemeMap(file, target, useCssVars) {
|
|
123
|
+
let classPath = file.className.split('.'),
|
|
124
|
+
fileName = classPath.pop(),
|
|
125
|
+
namespace;
|
|
126
|
+
|
|
127
|
+
classPath = classPath.join('.');
|
|
128
|
+
namespace = ns(classPath, true, useCssVars ? themeMap : themeMapNoVars);
|
|
129
|
+
|
|
130
|
+
if (!namespace[fileName]) {
|
|
131
|
+
namespace[fileName] = [target];
|
|
132
|
+
} else {
|
|
133
|
+
if (!namespace[fileName].includes(target)) {
|
|
134
|
+
namespace[fileName].push(target);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @param {String} p
|
|
142
|
+
* @param {String} mode development or production
|
|
143
|
+
*/
|
|
144
|
+
function buildEnv(p, mode) {
|
|
145
|
+
if (cssVars !== 'no') {
|
|
146
|
+
parseScssFiles(getAllScssFiles(path.join(p, 'src')), mode, 'src', true);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (cssVars !== 'no') {
|
|
150
|
+
themeFolders.forEach(themeFolder => {
|
|
151
|
+
if (themes === 'all' || themes === themeFolder) {
|
|
152
|
+
parseScssFiles(getAllScssFiles(path.join(p, themeFolder)), mode, themeFolder, true);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (cssVars !== 'yes') {
|
|
158
|
+
themeFolders.forEach(themeFolder => {
|
|
159
|
+
if (themes === 'all' || themes === themeFolder) {
|
|
160
|
+
parseScssFiles(getAllScssFiles(path.join(p, 'src')), mode, themeFolder, false);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
*
|
|
168
|
+
* @param {String} dirPath
|
|
169
|
+
* @returns {Object[]}
|
|
170
|
+
*/
|
|
171
|
+
function getAllScssFiles(dirPath) {
|
|
172
|
+
const files = getScssFiles(path.resolve(neoPath, dirPath));
|
|
173
|
+
|
|
174
|
+
if (!insideNeo) {
|
|
175
|
+
files.push(...getScssFiles(path.resolve(cwd, dirPath)));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return files;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
*
|
|
183
|
+
* @param {String} dirPath
|
|
184
|
+
* @param [arrayOfFiles=[]]
|
|
185
|
+
* @param [relativePath='']
|
|
186
|
+
* @returns {Object[]}
|
|
187
|
+
*/
|
|
188
|
+
function getScssFiles(dirPath, arrayOfFiles=[], relativePath='') {
|
|
189
|
+
let files = fs.readdirSync(dirPath),
|
|
190
|
+
className, fileInfo, filePath;
|
|
191
|
+
|
|
192
|
+
files.forEach(file => {
|
|
193
|
+
filePath = path.join(dirPath + '/' + file);
|
|
194
|
+
|
|
195
|
+
if (fs.statSync(filePath).isDirectory()) {
|
|
196
|
+
arrayOfFiles = getScssFiles(filePath, arrayOfFiles, relativePath + '/' + file);
|
|
197
|
+
} else {
|
|
198
|
+
fileInfo = path.parse(file);
|
|
199
|
+
|
|
200
|
+
if (!fileInfo.name.startsWith('_')) {
|
|
201
|
+
className = relativePath === '' ? fileInfo.name : `${relativePath.substring(1)}/${fileInfo.name}`;
|
|
202
|
+
className = className.split('/').join('.');
|
|
203
|
+
|
|
204
|
+
if (className.startsWith('apps.')) {
|
|
205
|
+
className = className.split('.');
|
|
206
|
+
className[0].toLowerCase();
|
|
207
|
+
className = className.join('.');
|
|
208
|
+
} else {
|
|
209
|
+
className = 'Neo.' + className;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
arrayOfFiles.push({
|
|
213
|
+
className : className,
|
|
214
|
+
name : fileInfo.name,
|
|
215
|
+
path : filePath,
|
|
216
|
+
relativePath: relativePath
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
return arrayOfFiles;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
*
|
|
227
|
+
* @param {String} filePath
|
|
228
|
+
* @returns {Object}
|
|
229
|
+
*/
|
|
230
|
+
function getThemeMap(filePath) {
|
|
231
|
+
let themeMapJson = path.resolve(cwd, filePath),
|
|
232
|
+
themeMap;
|
|
233
|
+
|
|
234
|
+
if (fs.existsSync(themeMapJson)) {
|
|
235
|
+
themeMap = requireJson(themeMapJson);
|
|
236
|
+
} else {
|
|
237
|
+
themeMapJson = path.resolve(neoPath, filePath);
|
|
238
|
+
|
|
239
|
+
if (fs.existsSync(themeMapJson)) {
|
|
240
|
+
themeMap = requireJson(themeMapJson);
|
|
241
|
+
} else {
|
|
242
|
+
themeMap = {};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return themeMap;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
*
|
|
251
|
+
* @param {Array|String} names The class name string containing dots or an Array of the string parts
|
|
252
|
+
* @param {Boolean} [create] Set create to true to create empty objects for non existing parts
|
|
253
|
+
* @param {Object} [scope] Set a different starting point as self
|
|
254
|
+
* @returns {Object} reference to the toplevel namespace
|
|
255
|
+
*/
|
|
256
|
+
function ns(names, create, scope) {
|
|
257
|
+
names = Array.isArray(names) ? names : names.split('.');
|
|
258
|
+
|
|
259
|
+
return names.reduce((prev, current) => {
|
|
260
|
+
if (create && !prev[current]) {
|
|
261
|
+
prev[current] = {};
|
|
262
|
+
}
|
|
263
|
+
if (prev) {
|
|
264
|
+
return prev[current];
|
|
265
|
+
}
|
|
266
|
+
}, scope);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
*
|
|
271
|
+
* @param {Object[]} files
|
|
272
|
+
* @param {String} mode development or production
|
|
273
|
+
* @param {String} target src or a theme
|
|
274
|
+
* @param {Boolean} useCssVars
|
|
275
|
+
*/
|
|
276
|
+
function parseScssFiles(files, mode, target, useCssVars) {
|
|
277
|
+
let data = '',
|
|
278
|
+
devMode = mode === 'development',
|
|
279
|
+
mixinPath = path.resolve(neoPath, 'resources/scss/mixins/_all.scss'),
|
|
280
|
+
suffix = useCssVars ? '' : '-no-vars',
|
|
281
|
+
varsFlag = useCssVars ? 'vars' : 'noVars',
|
|
282
|
+
map, neoThemePath, themeBuffer, themePath, workspaceThemePath;
|
|
283
|
+
|
|
284
|
+
totalFiles[mode][varsFlag] += files.length;
|
|
285
|
+
|
|
286
|
+
if (path.sep === '\\') {
|
|
287
|
+
mixinPath = mixinPath.replace(/\\/g, '/');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (target.includes('theme')) {
|
|
291
|
+
themePath = `resources/scss/${target}/_all.scss`;
|
|
292
|
+
neoThemePath = path.resolve(neoPath, themePath);
|
|
293
|
+
|
|
294
|
+
if (!sassThemes[target]) {
|
|
295
|
+
themeBuffer = scssCombine(fs.readFileSync(neoThemePath).toString(), path.dirname(neoThemePath));
|
|
296
|
+
|
|
297
|
+
if (!insideNeo) {
|
|
298
|
+
workspaceThemePath = path.resolve(cwd, themePath);
|
|
299
|
+
themeBuffer += scssCombine(fs.readFileSync(workspaceThemePath).toString(), path.dirname(workspaceThemePath));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
themeBuffer = themeBuffer.replace(regexComments, '');
|
|
303
|
+
themeBuffer = themeBuffer.replace(regexLineBreak, '');
|
|
304
|
+
|
|
305
|
+
sassThemes[target] = themeBuffer;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
data = [
|
|
309
|
+
`@use "sass:map";`,
|
|
310
|
+
`@use "sass:math";`,
|
|
311
|
+
`$neoMap: ();`,
|
|
312
|
+
`$useCssVars: ${useCssVars};`,
|
|
313
|
+
`@import "${mixinPath}";`,
|
|
314
|
+
`$useCssVars: false;`,
|
|
315
|
+
`${sassThemes[target]}`,
|
|
316
|
+
`$useCssVars: ${useCssVars};`
|
|
317
|
+
].join('');
|
|
318
|
+
} else {
|
|
319
|
+
data = [
|
|
320
|
+
`@use "sass:map";`,
|
|
321
|
+
`@use "sass:math";`,
|
|
322
|
+
`$neoMap: ();`,
|
|
323
|
+
`$useCssVars: ${useCssVars};`,
|
|
324
|
+
`@import "${mixinPath}";`
|
|
325
|
+
].join('');
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
files.forEach(file => {
|
|
329
|
+
addItemToThemeMap(file, target, useCssVars);
|
|
330
|
+
|
|
331
|
+
let folderPath = path.resolve(cwd, `dist/${mode}/css${suffix}/${target}/${file.relativePath}`),
|
|
332
|
+
destPath = path.resolve(folderPath, `${file.name}.css`);
|
|
333
|
+
|
|
334
|
+
fs.readFile(file.path).then(content => {
|
|
335
|
+
let result = sass.renderSync({
|
|
336
|
+
data : data + scssCombine(content.toString(), path.resolve(neoPath, scssPath, target, file.relativePath)),
|
|
337
|
+
outFile : destPath,
|
|
338
|
+
sourceMap : devMode,
|
|
339
|
+
sourceMapEmbed: false
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
const plugins = [autoprefixer];
|
|
343
|
+
|
|
344
|
+
if (mode === 'production') {
|
|
345
|
+
plugins.push(cssnano);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
map = result.map?.toString();
|
|
349
|
+
|
|
350
|
+
if (map) {
|
|
351
|
+
// https://github.com/neomjs/neo/issues/1970
|
|
352
|
+
map = JSON.parse(map);
|
|
353
|
+
let len = file.relativePath.split('/').length,
|
|
354
|
+
src = `${target}${file.relativePath}/${file.name}.scss`,
|
|
355
|
+
i = 0;
|
|
356
|
+
|
|
357
|
+
for (; i < len; i++) {
|
|
358
|
+
src = '../' + src;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
map.sources = [src];
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
postcss(plugins).process(result.css, {
|
|
365
|
+
from: file.path,
|
|
366
|
+
to : destPath,
|
|
367
|
+
map : !devMode ? null : {
|
|
368
|
+
prev: map && JSON.stringify(map)
|
|
369
|
+
}
|
|
370
|
+
}).then(result => {
|
|
371
|
+
fs.mkdirpSync(folderPath);
|
|
372
|
+
fileCount[mode][varsFlag]++;
|
|
373
|
+
|
|
374
|
+
const processTime = (Math.round((new Date - startDate) * 100) / 100000).toFixed(2);
|
|
375
|
+
console.log('Writing file:', (fileCount[mode].vars + fileCount[mode].noVars), chalk.blue(`${processTime}s`), destPath);
|
|
376
|
+
fs.writeFileSync(destPath, result.css, () => true);
|
|
377
|
+
|
|
378
|
+
if (result.map) {
|
|
379
|
+
fs.writeFileSync(result.opts.to + '.map', result.map.toString());
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (fileCount[mode][varsFlag] === totalFiles[mode][varsFlag]) {
|
|
383
|
+
fs.writeFileSync(
|
|
384
|
+
path.resolve(cwd, useCssVars ? themeMapFile : themeMapFileNoVars),
|
|
385
|
+
JSON.stringify(useCssVars ? themeMap : themeMapNoVars, null, 0)
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
fs.mkdirpSync(path.join(cwd, '/dist/', mode, '/resources'), {
|
|
389
|
+
recursive: true
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
fs.writeFileSync(
|
|
393
|
+
path.join(cwd, '/dist/', mode, useCssVars ? themeMapFile : themeMapFileNoVars),
|
|
394
|
+
JSON.stringify(useCssVars ? themeMap : themeMapNoVars, null, 0)
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
*
|
|
404
|
+
* @param {String} content
|
|
405
|
+
* @param {String} baseDir
|
|
406
|
+
* @returns {String}
|
|
407
|
+
*/
|
|
408
|
+
function scssCombine (content, baseDir) {
|
|
409
|
+
if (regexSassImport.test(content)) {
|
|
410
|
+
content = content.replace(regexSassImport, (m, capture) => {
|
|
411
|
+
let parse = path.parse(path.resolve(baseDir, capture)),
|
|
412
|
+
file = path.resolve(`${parse.dir}/${parse.name}.scss`);
|
|
413
|
+
|
|
414
|
+
if (!fs.existsSync(file)) {
|
|
415
|
+
file = path.resolve(`${parse.dir}/_${parse.name}.scss`);
|
|
416
|
+
|
|
417
|
+
if (!fs.existsSync(file)) {
|
|
418
|
+
return '';
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return scssCombine(fs.readFileSync(file).toString(), path.dirname(file));
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return content;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (cssVars !== 'no') {themeMap = getThemeMap(themeMapFile);}
|
|
430
|
+
if (cssVars !== 'yes') {themeMapNoVars = getThemeMap(themeMapFileNoVars);}
|
|
431
|
+
|
|
432
|
+
// dist/development
|
|
433
|
+
if (env === 'all' || env === 'dev') {
|
|
434
|
+
console.log(chalk.blue(`${programName} starting dist/development`));
|
|
435
|
+
buildEnv(path.join(scssPath), 'development');
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// dist/production
|
|
439
|
+
if (env === 'all' || env === 'prod') {
|
|
440
|
+
console.log(chalk.blue(`${programName} starting dist/production`));
|
|
441
|
+
buildEnv(path.join(scssPath), 'production');
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { Command } from 'commander/esm.mjs';
|
|
2
|
+
import fs from 'fs-extra';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
fs = require('fs-extra');
|
|
5
|
-
|
|
6
|
-
const program = new commander.Command('copyFolder')
|
|
4
|
+
const program = new Command('copyFolder')
|
|
7
5
|
.version('1.0.0')
|
|
8
6
|
.option('-s, --source <value>', 'path to the source folder')
|
|
9
7
|
.option('-t, --target <value>', 'path to the target folder')
|