-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbuild.mjs
More file actions
95 lines (85 loc) · 2.58 KB
/
build.mjs
File metadata and controls
95 lines (85 loc) · 2.58 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { exec as _exec } from 'node:child_process';
import { copyFile, writeFile, cp } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { promisify } from 'node:util';
import { getWebTypesData } from 'custom-element-jet-brains-integration';
import {
getVsCodeCssCustomData,
getVsCodeHtmlCustomData,
} from 'custom-element-vs-code-integration';
import customElements from '../custom-elements.json' with { type: 'json' };
import report from './report.mjs';
import { buildComponents, buildThemes } from './sass.mjs';
const exec = promisify(_exec);
const DEST_DIR = path.join.bind(
null,
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../dist')
);
const RELEASE_FILES = [
'custom-elements.json',
'CHANGELOG.md',
'LICENSE',
'README.md',
];
async function runTask(tag, cmd) {
report.stdout.info(`[${tag}] Working...`);
try {
await cmd();
report.stdout.clearLine();
report.stdout.success(`[${tag}] Done\n`);
} catch (e) {
report.error(`[${tag}] Failed with: ${e.message}`);
}
}
(async () => {
await runTask('Clean up', () => exec('npm run clean'));
await runTask('Component styles', () => buildComponents(true));
await runTask('Themes', () => buildThemes(true));
// https://github.com/microsoft/TypeScript/issues/14619
await runTask('Components', () =>
exec(
'tsc -p scripts/tsconfig.prod.json && tsc -p scripts/tsconfig.dts.prod.json'
)
);
await runTask('Copying release files', async () => {
Promise.all([
copyFile('scripts/_package.json', DEST_DIR('package.json')),
...RELEASE_FILES.map((file) => copyFile(file, DEST_DIR(file))),
]);
});
await runTask('VSCode custom data + Web types', () =>
Promise.all([
writeFile(
DEST_DIR('igniteui-webcomponents.css-data.json'),
getVsCodeCssCustomData(customElements, {
hideCssPartsDocs: false,
hideCssPropertiesDocs: false,
hideLogs: true,
}),
'utf8'
),
writeFile(
DEST_DIR('igniteui-webcomponents.html-data.json'),
getVsCodeHtmlCustomData(customElements, {
hideMethodDocs: true,
hideLogs: true,
}),
'utf8'
),
writeFile(
DEST_DIR('web-types.json'),
getWebTypesData(customElements, {
hideMethodDocs: true,
hideCssPartsDocs: false,
hideLogs: true,
}),
'utf8'
),
])
);
await runTask('Copy skills directory', () => {
cp('skills', DEST_DIR('skills'), { recursive: true });
});
report.success('Done! 🎉');
})();