-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.js
executable file
·63 lines (54 loc) · 1.18 KB
/
vite.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env zx
import 'zx/globals';
await $`rm -rf vite`;
await $`mkdir -p vite`;
cd('vite');
const templates = [
'vanilla',
'vanilla-ts',
'vue',
'vue-ts',
'react',
'react-ts',
'react-swc',
'react-swc-ts',
'preact',
'preact-ts',
'lit',
'lit-ts',
'svelte',
'svelte-ts',
'solid',
'solid-ts',
'qwik',
'qwik-ts',
];
const base = '@pluvial';
await $`mkdir -p ${base}`;
// non-parallel version
// const failed = [];
// for (const template of templates) {
// try {
// const name = `${base}/vite-${template}`;
// await $`create-vite ${name} --template ${template}`;
// await $`mv ${name} ${template}`;
// } catch {
// failed.push(template);
// }
// }
const timeout = '10s';
const results = await Promise.allSettled(
templates.map(async template => {
const name = `${base}/vite-${template}`;
await $`create-vite ${name} --template ${template}`.timeout(timeout);
await $`mv ${name} ${template}`;
}),
);
const failed = results
.map((result, i) => (result.status === 'rejected' ? templates[i] : null))
.filter(x => x);
if (failed.length > 0) {
console.warn(`Failed templates: ${failed}`);
}
await $`rmdir ${base}`;
cd('..');