create-astro 0.14.3 → 0.15.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/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import ora from "ora";
6
6
  import os from "os";
7
7
  import path from "path";
8
8
  import prompts from "prompts";
9
+ import url from "url";
9
10
  import detectPackageManager from "which-pm-runs";
10
11
  import yargs from "yargs-parser";
11
12
  import { loadWithRocketGradient, rocketAscii } from "./gradient.js";
@@ -236,9 +237,72 @@ ${bold(
236
237
  ora().info(dim(`--dry-run enabled, skipping.`));
237
238
  } else if (gitResponse.git) {
238
239
  await execaCommand("git init", { cwd });
240
+ ora().succeed("Git repository created!");
239
241
  } else {
240
242
  ora().info(dim(`Sounds good! You can come back and run ${cyan(`git init`)} later.`));
241
243
  }
244
+ const tsResponse = await prompts(
245
+ {
246
+ type: "select",
247
+ name: "typescript",
248
+ message: "How would you like to setup TypeScript?",
249
+ choices: [
250
+ {
251
+ title: "Relaxed",
252
+ value: "default"
253
+ },
254
+ {
255
+ title: "Strict (recommended)",
256
+ description: "Enable `strict` typechecking rules",
257
+ value: "strict"
258
+ },
259
+ {
260
+ title: "Strictest",
261
+ description: "Enable all typechecking rules",
262
+ value: "stricter"
263
+ },
264
+ {
265
+ title: "I prefer not to use TypeScript",
266
+ description: `That's cool too!`,
267
+ value: "optout"
268
+ }
269
+ ]
270
+ },
271
+ {
272
+ onCancel: () => {
273
+ ora().info(
274
+ dim(
275
+ "Operation cancelled. Your project folder has been created but no TypeScript configuration file was created."
276
+ )
277
+ );
278
+ process.exit(1);
279
+ }
280
+ }
281
+ );
282
+ if (tsResponse.typescript === "optout") {
283
+ console.log(``);
284
+ ora().warn(yellow(bold(`Astro \u2764\uFE0F TypeScript!`)));
285
+ console.log(` Astro supports TypeScript inside of ".astro" component scripts, so`);
286
+ console.log(` we still need to create some TypeScript-related files in your project.`);
287
+ console.log(` You can safely ignore these files, but don't delete them!`);
288
+ console.log(dim(" (ex: tsconfig.json, src/types.d.ts)"));
289
+ console.log(``);
290
+ tsResponse.typescript = "default";
291
+ await wait(300);
292
+ }
293
+ if (args.dryRun) {
294
+ ora().info(dim(`--dry-run enabled, skipping.`));
295
+ } else if (tsResponse.typescript) {
296
+ fs.copyFileSync(
297
+ path.join(
298
+ url.fileURLToPath(new URL("..", import.meta.url)),
299
+ "tsconfigs",
300
+ `tsconfig.${tsResponse.typescript}.json`
301
+ ),
302
+ path.join(cwd, "tsconfig.json")
303
+ );
304
+ ora().succeed("TypeScript settings applied!");
305
+ }
242
306
  ora().succeed("Setup complete.");
243
307
  ora({ text: green("Ready for liftoff!") }).succeed();
244
308
  await wait(300);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "0.14.3",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -19,7 +19,8 @@
19
19
  },
20
20
  "files": [
21
21
  "dist",
22
- "create-astro.js"
22
+ "create-astro.js",
23
+ "tsconfigs"
23
24
  ],
24
25
  "dependencies": {
25
26
  "chalk": "^5.0.1",
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable top-level await, and other modern ESM features.
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ // Enable node-style module resolution, for things like npm package imports.
7
+ "moduleResolution": "node",
8
+ // Enable JSON imports.
9
+ "resolveJsonModule": true,
10
+ // Enable stricter transpilation for better output.
11
+ "isolatedModules": true,
12
+ // Astro will directly run your TypeScript code, no transpilation needed.
13
+ "noEmit": true,
14
+ // Enable strict type checking.
15
+ "strict": true,
16
+ // Error when a value import is only used as a type.
17
+ "importsNotUsedAsValues": "error"
18
+ }
19
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable top-level await, and other modern ESM features.
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ // Enable node-style module resolution, for things like npm package imports.
7
+ "moduleResolution": "node",
8
+ // Enable JSON imports.
9
+ "resolveJsonModule": true,
10
+ // Enable stricter transpilation for better output.
11
+ "isolatedModules": true,
12
+ // Astro will directly run your TypeScript code, no transpilation needed.
13
+ "noEmit": true,
14
+ // Enable strict type checking.
15
+ "strict": true,
16
+ // Error when a value import is only used as a type.
17
+ "importsNotUsedAsValues": "error",
18
+ // Report errors for fallthrough cases in switch statements
19
+ "noFallthroughCasesInSwitch": true,
20
+ // Force functions designed to override their parent class to be specified as `override`.
21
+ "noImplicitOverride": true,
22
+ // Force functions to specify that they can return `undefined` if a possibe code path does not return a value.
23
+ "noImplicitReturns": true,
24
+ // Report an error when a variable is declared but never used.
25
+ "noUnusedLocals": true,
26
+ // Report an error when a parameter is declared but never used.
27
+ "noUnusedParameters": true,
28
+ // Force the usage of the indexed syntax to access fields declared using an index signature.
29
+ "noUncheckedIndexedAccess": true,
30
+ // Report an error when the value `undefined` is given to an optional property that doesn't specify `undefined` as a valid value.
31
+ "exactOptionalPropertyTypes": true
32
+ }
33
+ }