-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.js
executable file
·85 lines (75 loc) · 2.69 KB
/
astro.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env zx
import 'zx/globals';
await $`rm -rf astro`;
await $`mkdir -p astro`;
cd('astro');
// | Name | Description |
// | :--------------------------- | :----------------------------------------------------- |
// | `--help` (`-h`) | Display available flags. |
// | `--template <name>` | Specify your template. |
// | `--install` / `--no-install` | Install dependencies (or not). |
// | `--git` / `--no-git` | Initialize git repo (or not). |
// | `--yes` (`-y`) | Skip all prompts by accepting defaults. |
// | `--no` (`-n`) | Skip all prompts by declining defaults. |
// | `--dry-run` | Walk through steps without executing. |
// | `--skip-houston` | Skip Houston animation. |
// | `--ref` | Specify an Astro branch (default: latest). |
// | `--fancy` | Enable full Unicode support for Windows. |
// | `--typescript <option>` | TypeScript option: `strict` / `strictest` / `relaxed`. |
const templates = [
'basics',
'blog',
'component',
'framework-alpine',
'framework-lit',
'framework-multiple',
'framework-preact',
'framework-react',
'framework-solid',
'framework-svelte',
'framework-vue',
'hackernews',
'integration',
'middleware',
'minimal',
'non-html-pages',
'portfolio',
'ssr',
'view-transitions',
'with-markdoc',
'with-markdown-plugins',
'with-markdown-shiki',
'with-mdx',
'with-nanostores',
'with-tailwindcss',
'with-vite-plugin-pwa',
'with-vitest',
];
const base = '@pluvial';
await $`mkdir -p ${base}`;
// non-parallel version
// const failed = [];
// for (const template of templates) {
// try {
// const name = `${base}/astro-${template}`;
// await $`create-astro ${name} -y --template ${template} --no-install --no-git --typescript strictest`;
// await $`mv ${name} ${template}`;
// } catch {
// failed.push(template);
// }
// }
const results = await Promise.allSettled(
templates.map(async template => {
const name = `${base}/astro-${template}`;
await $`create-astro ${name} -y --template ${template} --no-install --no-git --typescript strictest`;
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('..');