-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.js
48 lines (43 loc) · 1.63 KB
/
tasks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const { deleteFoldersRecursive, copyFiles, npmInstall, buildCraco } = require('@iobroker/build-tools');
const srcAdmin = `${__dirname}/src-admin/`;
const destAdmin = `${__dirname}/admin/custom`;
function admin0CleanSync() {
deleteFoldersRecursive(destAdmin);
deleteFoldersRecursive(`${destAdmin}/build`);
}
function copyAllFilesSync() {
copyFiles(
[
'src-admin/build/static/js/*.js',
'!src-admin/build/static/js/vendors*.js',
'!src-admin/build/static/js/src_bootstrap_*.js',
],
'admin/custom/static/js',
);
copyFiles(
[
'src-admin/build/static/js/*.map',
'!src-admin/build/static/js/vendors*.map',
'!src-admin/build/static/js/src_bootstrap_*.map',
],
'admin/custom/static/js',
);
copyFiles(['src-admin/build/customComponents.js'], 'admin/custom');
copyFiles(['src-admin/build/customComponents.js.map'], 'admin/custom');
copyFiles(['src-admin/src/i18n/*.json'], 'admin/custom/i18n');
}
if (process.argv.find(arg => arg.replace(/^--/, '') === '0-clean')) {
admin0CleanSync();
} else if (process.argv.find(arg => arg.replace(/^--/, '') === '1-npm')) {
npmInstall().catch(e => console.error(`Cannot install: ${e}`));
} else if (process.argv.find(arg => arg.replace(/^--/, '') === '2-compile')) {
buildCraco().catch(e => console.error(`Cannot compile: ${e}`));
} else if (process.argv.find(arg => arg.replace(/^--/, '') === '3-copy')) {
copyAllFilesSync();
} else {
admin0CleanSync();
npmInstall(srcAdmin).then(async () => {
await buildCraco();
copyAllFilesSync();
});
}