wp-blank-scripts 3.1.19 → 4.0.0-alpha.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 +160 -233
- package/cli/config.js +6 -6
- package/cli/deploy.js +8 -8
- package/cli/migrate-sass.js +86 -0
- package/cli/setup.js +22 -44
- package/index.js +22 -11
- package/lib/buildProject.js +15 -3
- package/lib/deployProject.js +18 -27
- package/lib/index.js +0 -2
- package/lib/pullSQL.js +1 -3
- package/lib/setupProject.js +4 -6
- package/overridable/checkProjectDependencies.js +22 -13
- package/overridable/index.js +0 -2
- package/package.json +40 -45
- package/utils/checkNodeVersion.js +3 -3
- package/utils/ensureGitignore.js +24 -0
- package/utils/execSsh.js +2 -2
- package/utils/git.js +10 -87
- package/utils/isReactProject.js +3 -0
- package/utils/replaceSQL.js +6 -10
- package/utils/runProjectBuildTask.js +6 -2
- package/utils/startMAMP.js +5 -5
- package/utils/tunnelSsh.js +20 -20
- package/webpack.base.config.js +112 -39
- package/webpack.react.config.js +3 -3
- package/webpack.wp.config.js +59 -30
- package/overridable/copyFx.js +0 -5
- package/utils/deploySQLFromCI.js +0 -34
- package/utils/getDefaultSetup.js +0 -5
- package/utils/getFxFiles.js +0 -119
package/webpack.base.config.js
CHANGED
|
@@ -10,11 +10,10 @@ const glob = require('glob');
|
|
|
10
10
|
const postcssPresetEnv = require('postcss-preset-env');
|
|
11
11
|
|
|
12
12
|
const logger = require('./logger');
|
|
13
|
-
const { copyFiles,
|
|
13
|
+
const { copyFiles, loaderOptions } = require('./overridable');
|
|
14
14
|
|
|
15
15
|
const getEnvironmentFile = require('./utils/getEnvironmentFile');
|
|
16
16
|
const getSettings = require('./utils/projectSettings');
|
|
17
|
-
const getFxFiles = require('./utils/getFxFiles');
|
|
18
17
|
const verifyLoaderOptions = require('./utils/verifyLoaderOptions');
|
|
19
18
|
|
|
20
19
|
function makeBaseConfig(options) {
|
|
@@ -30,11 +29,21 @@ function makeBaseConfig(options) {
|
|
|
30
29
|
|
|
31
30
|
// Absolute paths
|
|
32
31
|
const sourcePath = path.join(process.cwd(), sourceDir);
|
|
33
|
-
const
|
|
32
|
+
const buildDir = process.env.DEPLOY_OUT_DIR || settings.directories.build;
|
|
33
|
+
const buildPath = path.join(process.cwd(), buildDir);
|
|
34
34
|
const themePath = path.join(buildPath, themeDir);
|
|
35
35
|
|
|
36
|
-
const fxFiles = getFxFiles(copyFx());
|
|
37
36
|
const fontsDir = path.join(sourceDir, 'assets', 'fonts');
|
|
37
|
+
const fxClassesDir = 'vendor/vivo-digital/fx-classes';
|
|
38
|
+
|
|
39
|
+
// Detect legacy vs new image directory (legacy: assets/img, new: assets/images)
|
|
40
|
+
const legacyImgDir = path.join(sourceDir, 'assets', 'img');
|
|
41
|
+
const imgSourceDir = fs.existsSync(legacyImgDir)
|
|
42
|
+
? legacyImgDir
|
|
43
|
+
: path.join(sourceDir, 'assets', 'images');
|
|
44
|
+
const imgDestDir = fs.existsSync(legacyImgDir)
|
|
45
|
+
? path.join(themePath, 'assets', 'img')
|
|
46
|
+
: path.join(themePath, 'assets', 'images');
|
|
38
47
|
|
|
39
48
|
const sourceFiles = [
|
|
40
49
|
{
|
|
@@ -47,8 +56,8 @@ function makeBaseConfig(options) {
|
|
|
47
56
|
},
|
|
48
57
|
{ from: path.join(sourceDir, 'style.css'), to: themePath },
|
|
49
58
|
{
|
|
50
|
-
from:
|
|
51
|
-
to:
|
|
59
|
+
from: imgSourceDir,
|
|
60
|
+
to: imgDestDir,
|
|
52
61
|
globOptions: { ignore: ['.DS_Store'] },
|
|
53
62
|
},
|
|
54
63
|
...(fs.existsSync(fontsDir)
|
|
@@ -67,6 +76,41 @@ function makeBaseConfig(options) {
|
|
|
67
76
|
ignore: ['.DS_Store'],
|
|
68
77
|
},
|
|
69
78
|
},
|
|
79
|
+
...(fs.existsSync(path.join(sourceDir, 'parts'))
|
|
80
|
+
? [
|
|
81
|
+
{
|
|
82
|
+
from: path.join(sourceDir, 'parts'),
|
|
83
|
+
to: path.join(themePath, 'parts'),
|
|
84
|
+
globOptions: { ignore: ['.DS_Store'] },
|
|
85
|
+
},
|
|
86
|
+
]
|
|
87
|
+
: []),
|
|
88
|
+
// Blocks
|
|
89
|
+
...(fs.existsSync(path.join(sourceDir, 'blocks'))
|
|
90
|
+
? [
|
|
91
|
+
{
|
|
92
|
+
from: path.join(sourceDir, 'blocks', '**', 'block.json'),
|
|
93
|
+
to({ absoluteFilename }) {
|
|
94
|
+
const relativePath = path.relative(
|
|
95
|
+
path.join(sourceDir, 'blocks'),
|
|
96
|
+
path.dirname(absoluteFilename)
|
|
97
|
+
);
|
|
98
|
+
return path.join(themePath, 'blocks', relativePath, 'block.json');
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
from: path.join(sourceDir, 'blocks', '**', 'render.php'),
|
|
103
|
+
to({ absoluteFilename }) {
|
|
104
|
+
const relativePath = path.relative(
|
|
105
|
+
path.join(sourceDir, 'blocks'),
|
|
106
|
+
path.dirname(absoluteFilename)
|
|
107
|
+
);
|
|
108
|
+
return path.join(themePath, 'blocks', relativePath, 'render.php');
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
]
|
|
112
|
+
: []),
|
|
113
|
+
// /End blocks
|
|
70
114
|
{
|
|
71
115
|
from: path.join(sourceDir, 'inc'),
|
|
72
116
|
to: path.join(themePath, 'inc'),
|
|
@@ -79,12 +123,22 @@ function makeBaseConfig(options) {
|
|
|
79
123
|
},
|
|
80
124
|
globOptions: { ignore: ['.DS_Store'] },
|
|
81
125
|
},
|
|
82
|
-
...
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
126
|
+
...(fs.existsSync(fxClassesDir)
|
|
127
|
+
? [
|
|
128
|
+
{
|
|
129
|
+
from: '**/*',
|
|
130
|
+
to: path.join(themePath, 'inc', 'fx-classes'),
|
|
131
|
+
context: path.join(fxClassesDir, 'dist'),
|
|
132
|
+
globOptions: { ignore: ['.DS_Store'] },
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
from: '**/*',
|
|
136
|
+
to: path.join(themePath, 'inc', 'fx-classes'),
|
|
137
|
+
context: path.join(fxClassesDir, 'lib'),
|
|
138
|
+
globOptions: { ignore: ['.DS_Store'] },
|
|
139
|
+
},
|
|
140
|
+
]
|
|
141
|
+
: []),
|
|
88
142
|
];
|
|
89
143
|
|
|
90
144
|
const envFiles = [
|
|
@@ -112,19 +166,6 @@ function makeBaseConfig(options) {
|
|
|
112
166
|
{ from: 'wp-content', to: 'wp-content' },
|
|
113
167
|
];
|
|
114
168
|
|
|
115
|
-
// ViVO Master Blocks package copy process
|
|
116
|
-
const includeBlocks = process.env.MASTER_BLOCKS;
|
|
117
|
-
const masterBlocksPath = process.env.MASTER_BLOCKS_DEV
|
|
118
|
-
? '../../vivo/vivo-master-blocks/dist'
|
|
119
|
-
: 'vendor/vivo-digital/vivo-master-blocks/dist';
|
|
120
|
-
|
|
121
|
-
const masterBlocks = [
|
|
122
|
-
{
|
|
123
|
-
from: path.join(process.cwd(), masterBlocksPath),
|
|
124
|
-
to: path.join(themePath, 'inc', 'vivo-master-blocks'),
|
|
125
|
-
},
|
|
126
|
-
];
|
|
127
|
-
|
|
128
169
|
let customFiles = [];
|
|
129
170
|
if (typeof copyFiles === 'function') {
|
|
130
171
|
customFiles = copyFiles({
|
|
@@ -136,20 +177,44 @@ function makeBaseConfig(options) {
|
|
|
136
177
|
});
|
|
137
178
|
}
|
|
138
179
|
|
|
139
|
-
const filesToCopy = [
|
|
140
|
-
...sourceFiles,
|
|
141
|
-
...envFiles,
|
|
142
|
-
...wordpressFiles,
|
|
143
|
-
...customFiles,
|
|
144
|
-
...(includeBlocks ? masterBlocks : []),
|
|
145
|
-
];
|
|
146
|
-
|
|
147
|
-
// Admin entries
|
|
148
|
-
const adminScripts = glob.sync(path.join(sourcePath, 'assets', 'admin', 'js', '*.js'));
|
|
149
|
-
const adminStyles = glob.sync(path.join(sourcePath, 'assets', 'admin', 'css', '*.scss'));
|
|
180
|
+
const filesToCopy = [...sourceFiles, ...envFiles, ...wordpressFiles, ...customFiles];
|
|
150
181
|
|
|
182
|
+
// Admin entries — use same structure detection as webpack.wp.config.js (src/index.js = new)
|
|
183
|
+
const isLegacyStructure = !fs.existsSync(path.join(sourcePath, 'index.js'));
|
|
184
|
+
const adminScripts = isLegacyStructure
|
|
185
|
+
? glob.sync(path.join(sourcePath, 'assets', 'admin', 'js', '*.js'))
|
|
186
|
+
: glob.sync(path.join(sourcePath, 'admin', '*.js'));
|
|
187
|
+
const adminStyles = isLegacyStructure
|
|
188
|
+
? glob.sync(path.join(sourcePath, 'assets', 'admin', 'css', '*.scss'))
|
|
189
|
+
: glob.sync(path.join(sourcePath, 'admin', '*.scss'));
|
|
151
190
|
const mainStyleVariables = path.join(sourcePath, 'assets', 'css', 'utils', 'variables.scss');
|
|
152
191
|
|
|
192
|
+
// Admin component styles (new structure only)
|
|
193
|
+
const adminComponentStyles = isLegacyStructure
|
|
194
|
+
? []
|
|
195
|
+
: glob.sync(path.join(sourcePath, 'admin', 'components', '***', '*.{scss,css}'));
|
|
196
|
+
|
|
197
|
+
const blockJsonFiles = [];
|
|
198
|
+
|
|
199
|
+
glob.sync(path.join(sourcePath, 'blocks', '***', '*.json')).forEach((filePath) => {
|
|
200
|
+
blockJsonFiles.push(filePath);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
const blockJsonScripts = [];
|
|
204
|
+
const blockJsonStyles = [];
|
|
205
|
+
|
|
206
|
+
blockJsonFiles.forEach((file) => {
|
|
207
|
+
const content = JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
208
|
+
if (content.editorScript) {
|
|
209
|
+
const editorScript = `${path.dirname(file)}/${content.editorScript}`;
|
|
210
|
+
blockJsonScripts.push(editorScript);
|
|
211
|
+
}
|
|
212
|
+
if (content.editorStyle) {
|
|
213
|
+
const editorStyle = `${path.dirname(file)}/${content.editorStyle}`;
|
|
214
|
+
blockJsonStyles.push(editorStyle);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
|
|
153
218
|
let sassVariables = `$env: ${process.env.NODE_ENV};`;
|
|
154
219
|
|
|
155
220
|
for (const key of Object.keys(process.env)) {
|
|
@@ -173,8 +238,8 @@ function makeBaseConfig(options) {
|
|
|
173
238
|
mode,
|
|
174
239
|
target: 'web',
|
|
175
240
|
entry: {
|
|
176
|
-
adminScripts: [...
|
|
177
|
-
'admin.style': [...
|
|
241
|
+
adminScripts: [...blockJsonScripts, ...adminScripts],
|
|
242
|
+
'admin.style': [...blockJsonStyles, ...adminComponentStyles, ...adminStyles],
|
|
178
243
|
},
|
|
179
244
|
output: {
|
|
180
245
|
path: buildPath,
|
|
@@ -234,9 +299,16 @@ function makeBaseConfig(options) {
|
|
|
234
299
|
{
|
|
235
300
|
loader: 'sass-loader',
|
|
236
301
|
options: {
|
|
302
|
+
api: 'modern',
|
|
237
303
|
sourceMap: !isProd,
|
|
238
304
|
additionalData: sassVariables,
|
|
239
|
-
|
|
305
|
+
sassOptions: {
|
|
306
|
+
// Silence Dart Sass 2+ deprecation warnings from legacy project SCSS.
|
|
307
|
+
// These are expected in older projects and will need to be migrated
|
|
308
|
+
// project-by-project via: wp-scripts migrate-sass
|
|
309
|
+
// New projects using @use/@forward won't trigger these.
|
|
310
|
+
silenceDeprecations: ['import', 'color-functions', 'slash-div', 'global-builtin'],
|
|
311
|
+
},
|
|
240
312
|
},
|
|
241
313
|
},
|
|
242
314
|
],
|
|
@@ -271,6 +343,7 @@ function makeBaseConfig(options) {
|
|
|
271
343
|
devtool: isProd ? undefined : 'cheap-module-source-map',
|
|
272
344
|
performance: {
|
|
273
345
|
maxEntrypointSize: Infinity,
|
|
346
|
+
maxAssetSize: Infinity,
|
|
274
347
|
assetFilter: function (assetFilename) {
|
|
275
348
|
// Only warn about large JS assets
|
|
276
349
|
return (
|
package/webpack.react.config.js
CHANGED
|
@@ -20,8 +20,8 @@ function makeReactWebpackConfig(options) {
|
|
|
20
20
|
const entryPath = [path.join(sourcePath, 'index.js')];
|
|
21
21
|
const globalVariablesPath = path.join(sourcePath, 'variables.scss');
|
|
22
22
|
const globalVariables = fs.existsSync(globalVariablesPath)
|
|
23
|
-
? fs.readFileSync(globalVariablesPath, 'utf8')
|
|
24
|
-
:
|
|
23
|
+
? fs.readFileSync(globalVariablesPath, 'utf8')
|
|
24
|
+
: null;
|
|
25
25
|
|
|
26
26
|
const settings = getSettings();
|
|
27
27
|
const themeDir = path.join('wp-content', 'themes', settings.project);
|
|
@@ -146,7 +146,7 @@ function makeReactWebpackConfig(options) {
|
|
|
146
146
|
test: /\.(gif|png|svg|jpe?g)$/i,
|
|
147
147
|
type: 'asset/resource',
|
|
148
148
|
generator: {
|
|
149
|
-
filename: `${path.join(themeDir, 'assets', '
|
|
149
|
+
filename: `${path.join(themeDir, 'assets', 'images')}/[contenthash][ext][query]`,
|
|
150
150
|
},
|
|
151
151
|
},
|
|
152
152
|
{
|
package/webpack.wp.config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
2
3
|
|
|
3
4
|
const glob = require('glob');
|
|
4
5
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
@@ -6,53 +7,81 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
6
7
|
const logger = require('./logger');
|
|
7
8
|
|
|
8
9
|
// Overridable build config utils
|
|
9
|
-
const { copyFx } = require('./overridable');
|
|
10
|
-
|
|
11
|
-
const getFxFiles = require('./utils/getFxFiles');
|
|
12
10
|
const getSettings = require('./utils/projectSettings');
|
|
13
11
|
|
|
14
12
|
function makeWpWebpackConfig() {
|
|
15
|
-
const mode = process.env.NODE_ENV || 'development';
|
|
16
|
-
|
|
17
13
|
const settings = getSettings();
|
|
18
14
|
|
|
19
15
|
const sourceDir = 'src';
|
|
20
16
|
const sourcePath = path.join(process.cwd(), sourceDir);
|
|
21
17
|
const themeDir = path.join('wp-content', 'themes', settings.project);
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
// Detect project structure: new (4.0) uses src/index.js, legacy (3.x) uses src/assets/js/
|
|
20
|
+
const isNewStructure = fs.existsSync(path.join(sourcePath, 'index.js'));
|
|
21
|
+
|
|
22
|
+
// Blocks (supported in both structures)
|
|
23
|
+
const blockJsonScripts = [];
|
|
24
|
+
const blockJsonStyles = [];
|
|
25
|
+
|
|
26
|
+
glob.sync(path.join(sourcePath, 'blocks', '***', '*.json')).forEach((file) => {
|
|
27
|
+
const content = JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
28
|
+
if (content.viewScript) {
|
|
29
|
+
blockJsonScripts.push(`${path.dirname(file)}/${content.viewScript}`);
|
|
30
|
+
}
|
|
31
|
+
if (content.viewStyle) {
|
|
32
|
+
blockJsonStyles.push(`${path.dirname(file)}/${content.viewStyle}`);
|
|
33
|
+
}
|
|
30
34
|
});
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
+
// Parts (supported in both structures)
|
|
37
|
+
const partsScripts = glob.sync(path.join(sourcePath, 'parts', '***', '*.js'));
|
|
38
|
+
const partsStyles = glob.sync(path.join(sourcePath, 'parts', '***', '*.{scss,css}'));
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
mainScripts.main = [];
|
|
39
|
-
}
|
|
40
|
+
let entry;
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
if (isNewStructure) {
|
|
43
|
+
// New 4.0 structure: src/index.js + src/style.scss
|
|
44
|
+
const entryScript = glob.sync(path.join(sourcePath, 'index.js'));
|
|
45
|
+
if (!entryScript.length) {
|
|
46
|
+
logger.warn('No file was found for the common chunk, make sure you have a index.js file');
|
|
47
|
+
}
|
|
48
|
+
const mainStyles = glob.sync(path.join(sourcePath, 'style.scss'));
|
|
46
49
|
|
|
47
|
-
|
|
50
|
+
entry = {
|
|
51
|
+
main: [...blockJsonScripts, ...partsScripts, ...entryScript],
|
|
52
|
+
style: [...blockJsonStyles, ...partsStyles, ...mainStyles],
|
|
53
|
+
};
|
|
54
|
+
} else {
|
|
55
|
+
// Legacy 3.x structure: src/assets/js/*.js + gutenberg + src/assets/css/*.scss
|
|
56
|
+
const mainScripts = {};
|
|
48
57
|
|
|
49
|
-
|
|
58
|
+
glob.sync(path.join(sourcePath, 'assets', 'js', '*.js')).forEach((filePath) => {
|
|
59
|
+
const name = path.basename(filePath, '.js');
|
|
60
|
+
mainScripts[name] = [filePath];
|
|
61
|
+
});
|
|
50
62
|
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
glob.sync(path.join(sourcePath, 'assets', 'js', 'gutenberg', '*.js')).forEach((filePath) => {
|
|
64
|
+
const name = path.basename(filePath, '.js');
|
|
65
|
+
mainScripts[`gutenberg/${name}`] = [filePath];
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (!mainScripts.main) {
|
|
69
|
+
mainScripts.main = [];
|
|
70
|
+
logger.warn('No file was found for the common chunk, make sure you have a main.js file');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
mainScripts.main.unshift(...blockJsonScripts, ...partsScripts);
|
|
74
|
+
|
|
75
|
+
const mainStyles = glob.sync(path.join(sourcePath, 'assets', 'css', '*.scss'));
|
|
76
|
+
|
|
77
|
+
entry = {
|
|
53
78
|
...mainScripts,
|
|
54
|
-
style: [...
|
|
55
|
-
}
|
|
79
|
+
style: [...blockJsonStyles, ...partsStyles, ...mainStyles],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
entry,
|
|
56
85
|
plugins: [
|
|
57
86
|
new MiniCssExtractPlugin({
|
|
58
87
|
filename: path.join(themeDir, 'assets', 'css', '[name].css'),
|
package/overridable/copyFx.js
DELETED
package/utils/deploySQLFromCI.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const fetch = require('node-fetch');
|
|
3
|
-
|
|
4
|
-
const getMostRecentSqlFile = require('./getMostRecentSqlFile');
|
|
5
|
-
const getSettings = require('./projectSettings');
|
|
6
|
-
const replaceSQL = require('../utils/replaceSQL');
|
|
7
|
-
|
|
8
|
-
const DEPLOY_URL = 'https://a64vpm7gjh4nzgmrys6vmltsva0dydvc.lambda-url.ap-southeast-2.on.aws/';
|
|
9
|
-
|
|
10
|
-
async function deploySQLFromCI(options) {
|
|
11
|
-
const file = getMostRecentSqlFile(true);
|
|
12
|
-
|
|
13
|
-
console.log({ file });
|
|
14
|
-
|
|
15
|
-
await replaceSQL({
|
|
16
|
-
environmentIn: 'local',
|
|
17
|
-
environmentOut: options.environment,
|
|
18
|
-
file,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const sql = fs.readFileSync(file, 'utf8');
|
|
22
|
-
|
|
23
|
-
const response = await fetch(DEPLOY_URL, {
|
|
24
|
-
method: 'POST',
|
|
25
|
-
body: JSON.stringify({
|
|
26
|
-
sql,
|
|
27
|
-
settings: getSettings(),
|
|
28
|
-
}),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
console.log(response.status);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports = deploySQLFromCI;
|
package/utils/getDefaultSetup.js
DELETED
package/utils/getFxFiles.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
const glob = require('glob');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const FX_MODULE_SASS_ENTRY = 'assets/styles.scss';
|
|
5
|
-
const FX_MODULE_JS_ENTRY = 'assets/index.js';
|
|
6
|
-
const FX_MODULE_ADMIN_SASS_ENTRY = 'admin/styles.scss';
|
|
7
|
-
const FX_MODULE_ADMIN_JS_ENTRY = 'admin/index.js';
|
|
8
|
-
const FX_MODULE_LIB = 'lib';
|
|
9
|
-
|
|
10
|
-
const FX_CLASSES_ASSETS = 'dist';
|
|
11
|
-
const FX_CLASSES_LIB = 'lib';
|
|
12
|
-
|
|
13
|
-
function getAllViVODeps() {
|
|
14
|
-
return glob.sync('vendor/vivo-digital/*/');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function isFxClasses(dep) {
|
|
18
|
-
return dep.name.includes('fx-classes');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function isFxModule(dep) {
|
|
22
|
-
return dep.name.includes('fx-module-');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function formatCopyOptions(deps) {
|
|
26
|
-
const copyOptions = [];
|
|
27
|
-
deps.forEach(dep => {
|
|
28
|
-
const { name, dir } = dep;
|
|
29
|
-
if (isFxClasses(dep)) {
|
|
30
|
-
copyOptions.push({
|
|
31
|
-
context: path.join(dir, FX_CLASSES_ASSETS),
|
|
32
|
-
from: '**/*',
|
|
33
|
-
to: name,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
copyOptions.push({
|
|
37
|
-
context: path.join(dir, FX_CLASSES_LIB),
|
|
38
|
-
from: '**/*',
|
|
39
|
-
to: name,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (isFxModule(dep)) {
|
|
46
|
-
copyOptions.push({
|
|
47
|
-
context: path.join(dir, FX_MODULE_LIB),
|
|
48
|
-
from: '**/*',
|
|
49
|
-
to: name,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return copyOptions;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function getSassEntry(dep) {
|
|
58
|
-
// TODO: Check exists
|
|
59
|
-
return path.join(dep.dir, FX_MODULE_SASS_ENTRY);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function getJsEntry(dep) {
|
|
63
|
-
// TODO: Check exists
|
|
64
|
-
return path.join(dep.dir, FX_MODULE_JS_ENTRY);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function getAdminSassEntry(dep) {
|
|
68
|
-
// TODO: Check exists
|
|
69
|
-
return path.join(dep.dir, FX_MODULE_ADMIN_SASS_ENTRY);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function getAdminJsEntry(dep) {
|
|
73
|
-
// TODO: Check exists
|
|
74
|
-
return path.join(dep.dir, FX_MODULE_ADMIN_JS_ENTRY);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function formatSassEntries(deps, isAdmin) {
|
|
78
|
-
return deps.filter(isFxModule).map(dep => (isAdmin ? getAdminSassEntry(dep) : getSassEntry(dep)));
|
|
79
|
-
}
|
|
80
|
-
function formatJsEntries(deps, isAdmin) {
|
|
81
|
-
return deps.filter(isFxModule).map(dep => (isAdmin ? getAdminJsEntry(dep) : getJsEntry(dep)));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function getFxFiles(overrides) {
|
|
85
|
-
const depPaths = getAllViVODeps();
|
|
86
|
-
|
|
87
|
-
const deps = depPaths.map(depPath => {
|
|
88
|
-
const name = path.basename(depPath);
|
|
89
|
-
const overridePath = overrides[name];
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
name,
|
|
93
|
-
dir: overridePath || depPath,
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
Object.entries(overrides).forEach(([name, dir]) => {
|
|
98
|
-
const hasDep = deps.some(dep => dep.name === name);
|
|
99
|
-
if (!hasDep) {
|
|
100
|
-
// Module doesn't exist, so it must be new, let's include it
|
|
101
|
-
deps.push({
|
|
102
|
-
name,
|
|
103
|
-
dir,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
copy: formatCopyOptions(deps),
|
|
110
|
-
sass: formatSassEntries(deps),
|
|
111
|
-
js: formatJsEntries(deps),
|
|
112
|
-
admin: {
|
|
113
|
-
js: formatJsEntries(deps, true),
|
|
114
|
-
sass: formatJsEntries(deps, true),
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
module.exports = getFxFiles;
|