-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
ui.ts
48 lines (45 loc) · 1.36 KB
/
ui.ts
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
import { ChildProcess } from '@bcms/selfhosted-utils/child-process';
import path from 'path';
import { FS } from '@bcms/selfhosted-utils/fs';
export async function packUiComponents() {
await ChildProcess.advancedExec('npm pack', {
cwd: path.join(process.cwd(), 'ui', 'dist-components'),
onChunk(type, chunk) {
process[type].write(chunk);
},
}).awaiter;
}
export async function buildUiComponents() {
const basePath = path.join(process.cwd(), 'ui');
const localFs = new FS(basePath);
const dist = 'dist-components';
if (await localFs.exist(dist)) {
await localFs.deleteDir(dist);
}
const toCopy = [
'components',
'data',
'directives',
'hooks',
'layouts',
'services',
'styles',
'util',
'webgl',
'store.ts',
'window.ts',
];
for (let i = 0; i < toCopy.length; i++) {
await localFs.copy(['src', toCopy[i]], [dist, toCopy[i]]);
}
await localFs.copy('tailwind.config.cjs', [dist, 'tailwind.config.cjs']);
await localFs.copy('package.json', [dist, 'package.json']);
}
export async function buildUi() {
await ChildProcess.advancedExec('npm run build', {
cwd: path.join(process.cwd(), 'ui'),
onChunk(type, chunk) {
process[type].write(chunk);
},
}).awaiter;
}