create-astro 2.0.0-beta.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/index.js +32 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -43,6 +43,8 @@ May be provided in place of prompts
|
|
|
43
43
|
| `--template` | Specify the template name ([list][examples]) |
|
|
44
44
|
| `--commit` | Specify a specific Git commit or branch to use from this repo (by default, `main` branch of this repo will be used) |
|
|
45
45
|
| `--fancy` | For Windows users, `--fancy` will enable full unicode support |
|
|
46
|
+
| `--typescript` | Specify the [tsconfig][typescript] to use |
|
|
47
|
+
| `--yes`/`-y` | Skip prompts and use default values |
|
|
46
48
|
|
|
47
49
|
### Debugging
|
|
48
50
|
|
|
@@ -60,3 +62,4 @@ yarn create astro my-astro-project --verbose
|
|
|
60
62
|
```
|
|
61
63
|
|
|
62
64
|
[examples]: https://github.com/withastro/astro/tree/main/examples
|
|
65
|
+
[typescript]: https://github.com/withastro/astro/tree/main/packages/astro/tsconfigs
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from "./messages.js";
|
|
25
25
|
import { TEMPLATES } from "./templates.js";
|
|
26
26
|
const cleanArgv = process.argv.filter((arg) => arg !== "--");
|
|
27
|
-
const args = yargs(cleanArgv, { boolean: ["fancy"] });
|
|
27
|
+
const args = yargs(cleanArgv, { boolean: ["fancy", "y"], alias: { y: "yes" } });
|
|
28
28
|
if (platform() === "win32")
|
|
29
29
|
args.skipHouston = true;
|
|
30
30
|
prompts.override(args);
|
|
@@ -161,7 +161,19 @@ async function main() {
|
|
|
161
161
|
} catch (err) {
|
|
162
162
|
fs.rmdirSync(cwd);
|
|
163
163
|
if (err.message.includes("404")) {
|
|
164
|
-
console.error(`
|
|
164
|
+
console.error(`Could not find template ${color.underline(options.template)}!`);
|
|
165
|
+
if (isThirdParty) {
|
|
166
|
+
const hasBranch = options.template.includes("#");
|
|
167
|
+
if (hasBranch) {
|
|
168
|
+
console.error("Are you sure this GitHub repo and branch exist?");
|
|
169
|
+
} else {
|
|
170
|
+
console.error(
|
|
171
|
+
`Are you sure this GitHub repo exists?This command uses the ${color.bold("main")} branch by default.
|
|
172
|
+
If the repo doesn't have a main branch, specify a custom branch name:
|
|
173
|
+
` + color.underline(options.template + color.bold("#branch-name"))
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
165
177
|
} else {
|
|
166
178
|
console.error(err.message);
|
|
167
179
|
}
|
|
@@ -178,7 +190,7 @@ async function main() {
|
|
|
178
190
|
}
|
|
179
191
|
templateSpinner.text = green("Template copied!");
|
|
180
192
|
templateSpinner.succeed();
|
|
181
|
-
const
|
|
193
|
+
const install = args.y ? true : (await prompts(
|
|
182
194
|
{
|
|
183
195
|
type: "confirm",
|
|
184
196
|
name: "install",
|
|
@@ -197,10 +209,10 @@ async function main() {
|
|
|
197
209
|
process.exit(1);
|
|
198
210
|
}
|
|
199
211
|
}
|
|
200
|
-
);
|
|
212
|
+
)).install;
|
|
201
213
|
if (args.dryRun) {
|
|
202
214
|
ora().info(dim(`--dry-run enabled, skipping.`));
|
|
203
|
-
} else if (
|
|
215
|
+
} else if (install) {
|
|
204
216
|
const installExec = execa(pkgManager, ["install"], { cwd });
|
|
205
217
|
const installingPackagesMsg = `Installing packages${emojiWithFallback(" \u{1F4E6}", "...")}`;
|
|
206
218
|
const installSpinner = await loadWithRocketGradient(installingPackagesMsg);
|
|
@@ -220,11 +232,13 @@ ${bold(
|
|
|
220
232
|
} else {
|
|
221
233
|
await info("No problem!", "Remember to install dependencies after setup.");
|
|
222
234
|
}
|
|
223
|
-
const gitResponse = await prompts(
|
|
235
|
+
const gitResponse = args.y ? true : (await prompts(
|
|
224
236
|
{
|
|
225
237
|
type: "confirm",
|
|
226
238
|
name: "git",
|
|
227
|
-
message: `Would you like to initialize a new git repository? ${reset(
|
|
239
|
+
message: `Would you like to initialize a new git repository? ${reset(
|
|
240
|
+
dim("(optional)")
|
|
241
|
+
)}`,
|
|
228
242
|
initial: true
|
|
229
243
|
},
|
|
230
244
|
{
|
|
@@ -235,10 +249,10 @@ ${bold(
|
|
|
235
249
|
process.exit(1);
|
|
236
250
|
}
|
|
237
251
|
}
|
|
238
|
-
);
|
|
252
|
+
)).git;
|
|
239
253
|
if (args.dryRun) {
|
|
240
254
|
ora().info(dim(`--dry-run enabled, skipping.`));
|
|
241
|
-
} else if (gitResponse
|
|
255
|
+
} else if (gitResponse) {
|
|
242
256
|
await execaCommand("git init", { cwd });
|
|
243
257
|
ora().succeed("Git repository created!");
|
|
244
258
|
} else {
|
|
@@ -247,7 +261,11 @@ ${bold(
|
|
|
247
261
|
`You can come back and run ${color.reset(`git init`)}${color.dim(" later.")}`
|
|
248
262
|
);
|
|
249
263
|
}
|
|
250
|
-
|
|
264
|
+
if (args.y && !args.typescript) {
|
|
265
|
+
ora().warn(dim('--typescript <choice> missing. Defaulting to "strict"'));
|
|
266
|
+
args.typescript = "strict";
|
|
267
|
+
}
|
|
268
|
+
const tsResponse = args.typescript || (await prompts(
|
|
251
269
|
{
|
|
252
270
|
type: "select",
|
|
253
271
|
name: "typescript",
|
|
@@ -269,20 +287,20 @@ ${bold(
|
|
|
269
287
|
process.exit(1);
|
|
270
288
|
}
|
|
271
289
|
}
|
|
272
|
-
);
|
|
273
|
-
if (tsResponse
|
|
290
|
+
)).typescript;
|
|
291
|
+
if (tsResponse === "unsure") {
|
|
274
292
|
await typescriptByDefault();
|
|
275
293
|
tsResponse.typescript = "base";
|
|
276
294
|
}
|
|
277
295
|
if (args.dryRun) {
|
|
278
296
|
ora().info(dim(`--dry-run enabled, skipping.`));
|
|
279
|
-
} else if (tsResponse
|
|
297
|
+
} else if (tsResponse) {
|
|
280
298
|
const templateTSConfigPath = path.join(cwd, "tsconfig.json");
|
|
281
299
|
fs.readFile(templateTSConfigPath, (err, data) => {
|
|
282
300
|
if (err && err.code === "ENOENT") {
|
|
283
301
|
fs.writeFileSync(
|
|
284
302
|
templateTSConfigPath,
|
|
285
|
-
stringify({ extends: `astro/tsconfigs/${tsResponse
|
|
303
|
+
stringify({ extends: `astro/tsconfigs/${tsResponse}` }, null, 2)
|
|
286
304
|
);
|
|
287
305
|
return;
|
|
288
306
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astro",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@types/prompts": "^2.0.14",
|
|
43
43
|
"@types/which-pm-runs": "^1.0.0",
|
|
44
44
|
"@types/yargs-parser": "^21.0.0",
|
|
45
|
-
"astro-scripts": "0.0.10
|
|
45
|
+
"astro-scripts": "0.0.10",
|
|
46
46
|
"chai": "^4.3.6",
|
|
47
47
|
"mocha": "^9.2.2",
|
|
48
48
|
"uvu": "^0.5.3"
|