sdc-build-wp 4.2.0 → 4.3.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 +1 -0
- package/index.js +15 -129
- package/lib/components/base.js +13 -2
- package/lib/components/blocks.js +16 -2
- package/lib/components/fonts.js +5 -0
- package/lib/components/images.js +14 -1
- package/lib/components/php.js +19 -3
- package/lib/components/scripts.js +13 -3
- package/lib/components/server.js +9 -1
- package/lib/components/style.js +18 -9
- package/lib/project.js +1 -0
- package/lib/utils.js +22 -0
- package/package.json +2 -2
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -1,150 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import path from 'path';
|
|
3
2
|
import parseArgs from 'minimist';
|
|
4
3
|
const argv = parseArgs(process.argv.slice(2));
|
|
5
|
-
import { glob } from 'node:fs/promises';
|
|
6
4
|
import { promises as fs } from 'fs';
|
|
7
5
|
import { Tail } from 'tail';
|
|
8
6
|
import project from './lib/project.js';
|
|
9
|
-
import * as utils from './lib/utils.js';
|
|
10
7
|
import log from './lib/logging.js';
|
|
11
|
-
import * as
|
|
8
|
+
import * as LibComponents from './lib/components/index.js';
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
project.components = {
|
|
11
|
+
style: new LibComponents.style(),
|
|
12
|
+
scripts: new LibComponents.scripts(),
|
|
13
|
+
blocks: new LibComponents.blocks(),
|
|
14
|
+
images: new LibComponents.images(),
|
|
15
|
+
fonts: new LibComponents.fonts(),
|
|
16
|
+
php: new LibComponents.php(),
|
|
17
|
+
server: new LibComponents.server()
|
|
18
|
+
};
|
|
20
19
|
|
|
21
|
-
let builds = argv.builds ? argv.builds.split(',') : [
|
|
22
|
-
'sass',
|
|
23
|
-
'js',
|
|
24
|
-
'blocks',
|
|
25
|
-
'images',
|
|
26
|
-
'fonts',
|
|
27
|
-
'php'
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
for (const [name, files] of Object.entries(project.package.sdc.entries)) {
|
|
31
|
-
project.entries[name] = [];
|
|
32
|
-
files.forEach(function(file) {
|
|
33
|
-
project.entries[name].push(project.path + file);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
for (const [name, files] of Object.entries(project.entries)) {
|
|
38
|
-
files.forEach(function(file) {
|
|
39
|
-
switch (path.parse(file).ext) {
|
|
40
|
-
case '.scss':
|
|
41
|
-
if (builds.includes('sass')) {
|
|
42
|
-
project.files.sass.push({
|
|
43
|
-
'name': name,
|
|
44
|
-
'file': file
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
case '.js':
|
|
49
|
-
if (builds.includes('js')) {
|
|
50
|
-
project.files.js.push({
|
|
51
|
-
'name': name,
|
|
52
|
-
'file': file
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
20
|
+
let builds = argv.builds ? argv.builds.split(',') : Object.keys(project.components).map(key => project.components[key].slug);
|
|
59
21
|
|
|
60
22
|
(async() => {
|
|
61
23
|
|
|
62
24
|
let initialBuildTimerStart = Date.now();
|
|
63
25
|
log('info', `Starting initial build`);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
project.globs.sass = await Array.fromAsync(
|
|
67
|
-
glob(project.package?.sdc?.sassGlobPath ||
|
|
68
|
-
`${project.path}{/_src/style,/blocks}/**/*.scss`)
|
|
69
|
-
);
|
|
70
|
-
await styleComponent.process();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (builds.includes('js')) {
|
|
74
|
-
project.globs.js = await Array.fromAsync(
|
|
75
|
-
glob(project.package?.sdc?.jsGlobPath ||
|
|
76
|
-
`${project.path}/_src/scripts/**/*.js`)
|
|
77
|
-
);
|
|
78
|
-
await scriptsComponent.process();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (builds.includes('blocks')) {
|
|
82
|
-
project.globs.blocks = await Array.fromAsync(
|
|
83
|
-
glob(`${project.path}/blocks/*`)
|
|
84
|
-
);
|
|
85
|
-
project.globs.blocksSass = await Array.fromAsync(
|
|
86
|
-
glob(`${project.path}/blocks/*/src/*.scss`)
|
|
87
|
-
);
|
|
88
|
-
// for (var filename of project.globs.blocksSass) {
|
|
89
|
-
// project.entries[`blocks/${path.basename(path.dirname(filename))}/style`] = [ filename ];
|
|
90
|
-
// }
|
|
91
|
-
await blocksComponent.process();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (builds.includes('images')) {
|
|
95
|
-
project.globs.images = await Array.fromAsync(
|
|
96
|
-
glob(project.package?.sdc?.imagesPath ||
|
|
97
|
-
`${project.paths.images}/**/*`)
|
|
98
|
-
);
|
|
99
|
-
project.globs.imageDirectories = [
|
|
100
|
-
project.paths.images,
|
|
101
|
-
...await utils.getAllSubdirectories(project.paths.images)
|
|
102
|
-
];
|
|
103
|
-
await imagesComponent.process();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (builds.includes('fonts')) {
|
|
107
|
-
await fontsComponent.process();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (builds.includes('php')) {
|
|
111
|
-
project.globs.php = await Array.fromAsync(
|
|
112
|
-
glob(project.package?.sdc?.jsGlobPath ||
|
|
113
|
-
`${project.path}/**/*.php`)
|
|
114
|
-
);
|
|
115
|
-
project.globs.blocksPHP = await Array.fromAsync(
|
|
116
|
-
glob(`${project.path}/blocks/*/build/*.php`)
|
|
117
|
-
);
|
|
118
|
-
project.chokidarOpts.ignored.concat(project.globs.blocksPHP);
|
|
119
|
-
// await phpComponent.process(null, { lintType: 'warn' }); // this errors "Fatal error: Allowed memory size"
|
|
26
|
+
for (let build of builds) {
|
|
27
|
+
await project.components[build].init();
|
|
120
28
|
}
|
|
121
|
-
|
|
122
29
|
log('info', `Finished initial build in ${Math.round((Date.now() - initialBuildTimerStart) / 1000)} seconds`);
|
|
123
30
|
|
|
124
31
|
if (argv.watch) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (builds.includes('sass')) {
|
|
129
|
-
styleComponent.watch();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (builds.includes('js')) {
|
|
133
|
-
scriptsComponent.watch();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (builds.includes('blocks')) {
|
|
137
|
-
blocksComponent.watch();
|
|
32
|
+
for (let build of builds) {
|
|
33
|
+
await project.components[build].watch();
|
|
138
34
|
}
|
|
139
|
-
|
|
140
|
-
if (builds.includes('images')) {
|
|
141
|
-
imagesComponent.watch();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (builds.includes('php') && project.shouldPHPLint) {
|
|
145
|
-
phpComponent.watch();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
35
|
try {
|
|
149
36
|
await fs.access(project.paths.errorLog);
|
|
150
37
|
let errorLogTail = new Tail(project.paths.errorLog);
|
|
@@ -154,7 +41,6 @@ for (const [name, files] of Object.entries(project.entries)) {
|
|
|
154
41
|
} catch (error) {
|
|
155
42
|
log('info', `Cannot find error log @ ${project.paths.errorLog}. Skipping watching php error logs`);
|
|
156
43
|
}
|
|
157
|
-
|
|
158
44
|
}
|
|
159
45
|
|
|
160
46
|
})();
|
package/lib/components/base.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
+
import * as utils from '../utils.js';
|
|
2
3
|
import project from '../project.js';
|
|
3
4
|
import log from '../logging.js';
|
|
4
5
|
import chokidar from 'chokidar';
|
|
6
|
+
import { glob } from 'node:fs/promises';
|
|
5
7
|
|
|
6
8
|
class BaseComponent {
|
|
7
9
|
|
|
8
10
|
constructor() {
|
|
9
11
|
this.timer = null;
|
|
10
12
|
this.path = path;
|
|
13
|
+
this.utils = utils;
|
|
11
14
|
this.project = project;
|
|
12
15
|
this.log = log;
|
|
13
16
|
this.chokidar = chokidar;
|
|
17
|
+
this.glob = glob;
|
|
18
|
+
this.files = [];
|
|
19
|
+
this.globs = [];
|
|
20
|
+
this.slug = 'base';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async init() {
|
|
24
|
+
//
|
|
14
25
|
}
|
|
15
26
|
|
|
16
27
|
start() {
|
|
@@ -27,8 +38,8 @@ class BaseComponent {
|
|
|
27
38
|
this.log('success', `${options.verb}${options.itemLabel ? ` ${options.itemLabel}` : ''} in ${options.timerEnd - options.timerStart}ms`);
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
async watch() {
|
|
42
|
+
//
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
}
|
package/lib/components/blocks.js
CHANGED
|
@@ -7,6 +7,20 @@ class BlocksComponent extends BaseComponent {
|
|
|
7
7
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
|
+
this.slug = 'blocks';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async init() {
|
|
14
|
+
this.globs = await Array.fromAsync(
|
|
15
|
+
this.glob(`${this.project.path}/blocks/*`)
|
|
16
|
+
);
|
|
17
|
+
this.globsSass = await Array.fromAsync(
|
|
18
|
+
this.glob(`${this.project.path}/blocks/*/src/*.scss`)
|
|
19
|
+
);
|
|
20
|
+
// for (var filename of this.globsSass) {
|
|
21
|
+
// this.project.entries[`blocks/${this.path.basename(this.path.dirname(filename))}/style`] = [ filename ];
|
|
22
|
+
// }
|
|
23
|
+
await this.process();
|
|
10
24
|
}
|
|
11
25
|
|
|
12
26
|
async build(entry, options) {
|
|
@@ -55,13 +69,13 @@ class BlocksComponent extends BaseComponent {
|
|
|
55
69
|
if (entry) {
|
|
56
70
|
await this.build(entry);
|
|
57
71
|
} else {
|
|
58
|
-
const promisesBlocks = this.
|
|
72
|
+
const promisesBlocks = this.globs.map(block => this.build(block));
|
|
59
73
|
await Promise.all(promisesBlocks);
|
|
60
74
|
}
|
|
61
75
|
}
|
|
62
76
|
|
|
63
77
|
watch() {
|
|
64
|
-
for (let block of this.
|
|
78
|
+
for (let block of this.globs) {
|
|
65
79
|
this.chokidar.watch(`${block}/src`, {
|
|
66
80
|
...this.project.chokidarOpts
|
|
67
81
|
}).on('all', (event, path) => {
|
package/lib/components/fonts.js
CHANGED
package/lib/components/images.js
CHANGED
|
@@ -8,6 +8,19 @@ class ImagesComponent extends BaseComponent {
|
|
|
8
8
|
|
|
9
9
|
constructor() {
|
|
10
10
|
super();
|
|
11
|
+
this.slug = 'images';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async init() {
|
|
15
|
+
this.globs = await Array.fromAsync(
|
|
16
|
+
this.glob(this.project.package?.sdc?.imagesPath ||
|
|
17
|
+
`${this.project.paths.images}/**/*`)
|
|
18
|
+
);
|
|
19
|
+
this.globsDirectories = [
|
|
20
|
+
this.project.paths.images,
|
|
21
|
+
...await this.utils.getAllSubdirectories(this.project.paths.images)
|
|
22
|
+
];
|
|
23
|
+
await this.process();
|
|
11
24
|
}
|
|
12
25
|
|
|
13
26
|
async build(entry, options) {
|
|
@@ -30,7 +43,7 @@ class ImagesComponent extends BaseComponent {
|
|
|
30
43
|
}
|
|
31
44
|
|
|
32
45
|
async process() {
|
|
33
|
-
const promisesImages = this.
|
|
46
|
+
const promisesImages = this.globsDirectories.map(directory => this.build(directory));
|
|
34
47
|
await Promise.all(promisesImages);
|
|
35
48
|
}
|
|
36
49
|
|
package/lib/components/php.js
CHANGED
|
@@ -7,9 +7,25 @@ class PHPComponent extends BaseComponent {
|
|
|
7
7
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
|
+
this.slug = 'php';
|
|
10
11
|
this.execPromise = promisify(exec);
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
async init() {
|
|
15
|
+
this.globs = await Array.fromAsync(
|
|
16
|
+
this.glob(this.project.package?.sdc?.phpGlobPath ||
|
|
17
|
+
`${this.project.path}/**/*.php`)
|
|
18
|
+
);
|
|
19
|
+
this.globsBlocks = await Array.fromAsync(
|
|
20
|
+
this.glob(`${this.project.path}/blocks/*/build/*.php`)
|
|
21
|
+
);
|
|
22
|
+
this.project.chokidarOpts.ignored = [
|
|
23
|
+
...this.project.chokidarOpts.ignored,
|
|
24
|
+
...this.globsBlocks
|
|
25
|
+
];
|
|
26
|
+
// await this.process(null, { lintType: 'warn' }); // this errors "Fatal error: Allowed memory size"
|
|
27
|
+
}
|
|
28
|
+
|
|
13
29
|
async build(entry, options) {
|
|
14
30
|
options = Object.assign({}, {
|
|
15
31
|
lintType: 'fix'
|
|
@@ -64,8 +80,8 @@ class PHPComponent extends BaseComponent {
|
|
|
64
80
|
}
|
|
65
81
|
}
|
|
66
82
|
}
|
|
67
|
-
if (this.project.server) {
|
|
68
|
-
this.project.server.reload();
|
|
83
|
+
if (this.project.components.server?.server) {
|
|
84
|
+
this.project.components.server?.server.reload();
|
|
69
85
|
}
|
|
70
86
|
|
|
71
87
|
this.end({
|
|
@@ -79,7 +95,7 @@ class PHPComponent extends BaseComponent {
|
|
|
79
95
|
}
|
|
80
96
|
|
|
81
97
|
watch() {
|
|
82
|
-
this.chokidar.watch(this.
|
|
98
|
+
this.chokidar.watch(this.globs, {
|
|
83
99
|
...this.project.chokidarOpts
|
|
84
100
|
}).on('all', (event, path) => {
|
|
85
101
|
this.process(path);
|
|
@@ -7,13 +7,23 @@ class ScriptsComponent extends BaseComponent {
|
|
|
7
7
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
|
+
this.slug = 'scripts';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async init() {
|
|
14
|
+
this.files = this.utils.addEntriesByFiletypes(['.js']);
|
|
15
|
+
this.globs = await Array.fromAsync(
|
|
16
|
+
this.glob(this.project.package?.sdc?.jsGlobPath ||
|
|
17
|
+
`${this.project.path}/_src/scripts/**/*.js`)
|
|
18
|
+
);
|
|
19
|
+
await this.process();
|
|
10
20
|
}
|
|
11
21
|
|
|
12
22
|
async build(entry, options) {
|
|
13
23
|
options = Object.assign({}, {
|
|
14
24
|
entriesToLint: null
|
|
15
25
|
}, options);
|
|
16
|
-
let entryLabel = `/dist/scripts/${this.entryBasename(entry).replace('.js', '.min.js')}`;
|
|
26
|
+
let entryLabel = `/dist/scripts/${this.utils.entryBasename(entry).replace('.js', '.min.js')}`;
|
|
17
27
|
|
|
18
28
|
this.start();
|
|
19
29
|
|
|
@@ -60,12 +70,12 @@ class ScriptsComponent extends BaseComponent {
|
|
|
60
70
|
}
|
|
61
71
|
|
|
62
72
|
async process() {
|
|
63
|
-
const promisesJS = this.
|
|
73
|
+
const promisesJS = this.files.map(block => this.build(block.file, { entriesToLint: this.globs }));
|
|
64
74
|
await Promise.all(promisesJS);
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
watch() {
|
|
68
|
-
this.chokidar.watch(this.
|
|
78
|
+
this.chokidar.watch(this.globs, {
|
|
69
79
|
...this.project.chokidarOpts
|
|
70
80
|
}).on('all', (event, path) => {
|
|
71
81
|
this.process();
|
package/lib/components/server.js
CHANGED
|
@@ -5,8 +5,12 @@ class ServerComponent extends BaseComponent {
|
|
|
5
5
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super();
|
|
8
|
+
this.slug = 'server';
|
|
8
9
|
this.server = bsCreate();
|
|
9
|
-
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async init() {
|
|
13
|
+
//
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
start() {
|
|
@@ -57,6 +61,10 @@ class ServerComponent extends BaseComponent {
|
|
|
57
61
|
this.server.init(bsOptions);
|
|
58
62
|
}
|
|
59
63
|
|
|
64
|
+
async watch() {
|
|
65
|
+
this.start();
|
|
66
|
+
}
|
|
67
|
+
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
export { ServerComponent as default }
|
package/lib/components/style.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import BaseComponent from './base.js';
|
|
2
|
-
import * as utils from '../utils.js';
|
|
3
2
|
import fs from 'fs';
|
|
4
3
|
import { promises } from 'fs';
|
|
5
4
|
import { fileURLToPath } from 'url';
|
|
@@ -13,6 +12,16 @@ class StyleComponent extends BaseComponent {
|
|
|
13
12
|
|
|
14
13
|
constructor() {
|
|
15
14
|
super();
|
|
15
|
+
this.slug = 'style';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async init() {
|
|
19
|
+
this.files = this.utils.addEntriesByFiletypes(['.scss']);
|
|
20
|
+
this.globs = await Array.fromAsync(
|
|
21
|
+
this.glob(this.project.package?.sdc?.sassGlobPath ||
|
|
22
|
+
`${this.project.path}{/_src/style,/blocks}/**/*.scss`)
|
|
23
|
+
);
|
|
24
|
+
await this.process();
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
async buildTheme() {
|
|
@@ -22,11 +31,11 @@ class StyleComponent extends BaseComponent {
|
|
|
22
31
|
if (theme.settings?.custom) {
|
|
23
32
|
for (var customAttribute in theme.settings.custom) {
|
|
24
33
|
if (customAttribute == 'dirDist') {
|
|
25
|
-
themeFileData += `$themeDirDist: "${theme.settings.custom[customAttribute]}"; // --wp--custom--${utils.camelToDash(customAttribute)}\n`;
|
|
34
|
+
themeFileData += `$themeDirDist: "${theme.settings.custom[customAttribute]}"; // --wp--custom--${this.utils.camelToDash(customAttribute)}\n`;
|
|
26
35
|
} else if (['breakpoints-rem', 'breakpoint-mobile'].includes(customAttribute)) {
|
|
27
36
|
// handled later in file - see 'fontSizeBase'
|
|
28
37
|
} else {
|
|
29
|
-
themeFileData += `$${customAttribute}: "${theme.settings.custom[customAttribute]}"; // --wp--custom--${utils.camelToDash(customAttribute)}\n`;
|
|
38
|
+
themeFileData += `$${customAttribute}: "${theme.settings.custom[customAttribute]}"; // --wp--custom--${this.utils.camelToDash(customAttribute)}\n`;
|
|
30
39
|
}
|
|
31
40
|
}
|
|
32
41
|
}
|
|
@@ -151,12 +160,12 @@ class StyleComponent extends BaseComponent {
|
|
|
151
160
|
if (options.buildTheme) {
|
|
152
161
|
await this.buildTheme();
|
|
153
162
|
}
|
|
154
|
-
for (var block of this.
|
|
163
|
+
for (var block of this.files) {
|
|
155
164
|
if (!entry || entry == block.file) {
|
|
156
165
|
await this.build(block.file, {
|
|
157
166
|
name: block.name,
|
|
158
|
-
entriesToLint: this.
|
|
159
|
-
|
|
167
|
+
entriesToLint: this.globs
|
|
168
|
+
});
|
|
160
169
|
if (entry == block.file) {
|
|
161
170
|
break;
|
|
162
171
|
}
|
|
@@ -167,13 +176,13 @@ class StyleComponent extends BaseComponent {
|
|
|
167
176
|
watch() {
|
|
168
177
|
this.chokidar.watch([
|
|
169
178
|
...[this.project.paths.theme.json],
|
|
170
|
-
this.
|
|
179
|
+
this.globs
|
|
171
180
|
], {
|
|
172
181
|
...this.project.chokidarOpts
|
|
173
182
|
}).on('all', (event, path) => {
|
|
174
183
|
let hasRanSingle = false;
|
|
175
|
-
for (var block of this.
|
|
176
|
-
if (path == block.file || utils.getImportedSASSFiles(block.file).includes(path)) {
|
|
184
|
+
for (var block of this.files) {
|
|
185
|
+
if (path == block.file || this.utils.getImportedSASSFiles(block.file).includes(path)) {
|
|
177
186
|
this.process(block.file, { buildTheme: path == this.project.paths.theme.json });
|
|
178
187
|
hasRanSingle = true;
|
|
179
188
|
}
|
package/lib/project.js
CHANGED
package/lib/utils.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { readdir } from 'node:fs/promises';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import project from './project.js';
|
|
4
5
|
|
|
5
6
|
export function camelToDash(camel) {
|
|
6
7
|
return camel.replace(/[A-Z]/g, m => '-' + m.toLowerCase());
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
export function entryBasename(entry) {
|
|
11
|
+
return path.parse(entry).base;
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
export async function getAllSubdirectories(dir) {
|
|
10
15
|
let subdirectories = [];
|
|
11
16
|
const subdirectoriesEntries = await readdir(dir, { withFileTypes: true });
|
|
@@ -36,3 +41,20 @@ export function getImportedSASSFiles(filePath) {
|
|
|
36
41
|
}
|
|
37
42
|
return imports;
|
|
38
43
|
}
|
|
44
|
+
|
|
45
|
+
export function addEntriesByFiletypes(filetypes = []) {
|
|
46
|
+
let finalFiles = [];
|
|
47
|
+
for (const [name, files] of Object.entries(project.package.sdc.entries)) {
|
|
48
|
+
for (let file of files) {
|
|
49
|
+
let fullPath = project.path + file;
|
|
50
|
+
let extension = path.parse(fullPath).ext;
|
|
51
|
+
if (filetypes.includes(extension)) {
|
|
52
|
+
finalFiles.push({
|
|
53
|
+
'name': name,
|
|
54
|
+
'file': fullPath
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return finalFiles;
|
|
60
|
+
}
|