neo.mjs 4.3.19 → 4.3.21
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/buildScripts/buildThemes.mjs +33 -14
- package/package.json +1 -1
@@ -13,14 +13,15 @@ const __dirname = path.resolve(),
|
|
13
13
|
cwd = process.cwd(),
|
14
14
|
requireJson = path => JSON.parse(fs.readFileSync((path))),
|
15
15
|
packageJson = requireJson(path.resolve(cwd, 'package.json')),
|
16
|
-
neoPath = packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/',
|
16
|
+
neoPath = path.resolve(packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/'),
|
17
|
+
insideNeo = packageJson.name === 'neo.mjs',
|
17
18
|
programName = `${packageJson.name} buildThemes`,
|
18
19
|
program = new Command(),
|
19
20
|
regexComments = /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,
|
20
21
|
regexLineBreak = /(\r\n|\n|\r)/gm,
|
21
22
|
regexSassImport = /@import[^'"]+?['"](.+?)['"];?/g,
|
22
|
-
scssFolders = fs.readdirSync(path.join(neoPath, '/resources/scss')),
|
23
23
|
scssPath = 'resources/scss/',
|
24
|
+
scssFolders = fs.readdirSync(path.resolve(scssPath)),
|
24
25
|
themeMapFile = 'resources/theme-map.json',
|
25
26
|
themeMapFileNoVars = 'resources/theme-map-no-vars.json',
|
26
27
|
themeFolders = [],
|
@@ -165,10 +166,19 @@ if (programOpts.info) {
|
|
165
166
|
* @returns {Object[]}
|
166
167
|
*/
|
167
168
|
function getAllScssFiles(dirPath) {
|
168
|
-
|
169
|
+
let files = [],
|
170
|
+
scssPath = path.resolve(neoPath, dirPath);
|
171
|
+
|
172
|
+
if (fs.existsSync(scssPath)) {
|
173
|
+
files.push(...getScssFiles(scssPath));
|
174
|
+
}
|
169
175
|
|
170
176
|
if (!insideNeo) {
|
171
|
-
|
177
|
+
scssPath = path.resolve(cwd, dirPath);
|
178
|
+
|
179
|
+
if (fs.existsSync(scssPath)) {
|
180
|
+
files.push(...getScssFiles(scssPath));
|
181
|
+
}
|
172
182
|
}
|
173
183
|
|
174
184
|
return files;
|
@@ -266,12 +276,13 @@ if (programOpts.info) {
|
|
266
276
|
* @param {Boolean} useCssVars
|
267
277
|
*/
|
268
278
|
function parseScssFiles(files, mode, target, useCssVars) {
|
269
|
-
let data
|
270
|
-
devMode
|
271
|
-
mixinPath
|
272
|
-
suffix
|
273
|
-
|
274
|
-
|
279
|
+
let data = '',
|
280
|
+
devMode = mode === 'development',
|
281
|
+
mixinPath = path.resolve(neoPath, 'resources/scss/mixins/_all.scss'),
|
282
|
+
suffix = useCssVars ? '' : '-no-vars',
|
283
|
+
themeBuffer = '',
|
284
|
+
varsFlag = useCssVars ? 'vars' : 'noVars',
|
285
|
+
dirName, map, neoThemePath, themePath, workspaceThemePath;
|
275
286
|
|
276
287
|
totalFiles[mode][varsFlag] += files.length;
|
277
288
|
|
@@ -284,7 +295,11 @@ if (programOpts.info) {
|
|
284
295
|
neoThemePath = path.resolve(neoPath, themePath);
|
285
296
|
|
286
297
|
if (!sassThemes[target]) {
|
287
|
-
|
298
|
+
dirName = path.dirname(neoThemePath);
|
299
|
+
|
300
|
+
if (fs.existsSync(dirName)) {
|
301
|
+
themeBuffer += scssCombine(fs.readFileSync(neoThemePath).toString(), dirName);
|
302
|
+
}
|
288
303
|
|
289
304
|
if (!insideNeo) {
|
290
305
|
workspaceThemePath = path.resolve(cwd, themePath);
|
@@ -325,7 +340,7 @@ if (programOpts.info) {
|
|
325
340
|
|
326
341
|
fs.readFile(file.path).then(content => {
|
327
342
|
let result = sass.renderSync({
|
328
|
-
data : data + scssCombine(content.toString(), path.
|
343
|
+
data : data + scssCombine(content.toString(), path.join(neoPath, scssPath, target, file.relativePath)),
|
329
344
|
outFile : destPath,
|
330
345
|
sourceMap : devMode,
|
331
346
|
sourceMapEmbed: false
|
@@ -399,8 +414,12 @@ if (programOpts.info) {
|
|
399
414
|
function scssCombine (content, baseDir) {
|
400
415
|
if (regexSassImport.test(content)) {
|
401
416
|
content = content.replace(regexSassImport, (m, capture) => {
|
402
|
-
|
403
|
-
|
417
|
+
if (!insideNeo && capture.startsWith('../')) {
|
418
|
+
capture = '../../' + capture;
|
419
|
+
}
|
420
|
+
|
421
|
+
let parse = path.parse(path.join(baseDir, capture)),
|
422
|
+
file = path.join(`${parse.dir}/${parse.name}.scss`);
|
404
423
|
|
405
424
|
if (!fs.existsSync(file)) {
|
406
425
|
file = path.resolve(`${parse.dir}/_${parse.name}.scss`);
|