create-astro 0.15.0 → 1.0.1-next.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 +29 -11
- package/package.json +3 -2
- package/tsconfigs/tsconfig.strict.json +0 -19
- package/tsconfigs/tsconfig.stricter.json +0 -33
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assign, parse, stringify } from "comment-json";
|
|
1
2
|
import degit from "degit";
|
|
2
3
|
import { execa, execaCommand } from "execa";
|
|
3
4
|
import fs from "fs";
|
|
@@ -6,7 +7,6 @@ import ora from "ora";
|
|
|
6
7
|
import os from "os";
|
|
7
8
|
import path from "path";
|
|
8
9
|
import prompts from "prompts";
|
|
9
|
-
import url from "url";
|
|
10
10
|
import detectPackageManager from "which-pm-runs";
|
|
11
11
|
import yargs from "yargs-parser";
|
|
12
12
|
import { loadWithRocketGradient, rocketAscii } from "./gradient.js";
|
|
@@ -96,6 +96,7 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
|
|
|
96
96
|
}
|
|
97
97
|
let templateSpinner = await loadWithRocketGradient("Copying project files...");
|
|
98
98
|
const hash = args.commit ? `#${args.commit}` : "";
|
|
99
|
+
const isThirdParty = options.template.includes("/");
|
|
99
100
|
const templateTarget = options.template.includes("/") ? options.template : `withastro/astro/examples/${options.template}#latest`;
|
|
100
101
|
const emitter = degit(`${templateTarget}${hash}`, {
|
|
101
102
|
cache: false,
|
|
@@ -259,7 +260,7 @@ ${bold(
|
|
|
259
260
|
{
|
|
260
261
|
title: "Strictest",
|
|
261
262
|
description: "Enable all typechecking rules",
|
|
262
|
-
value: "
|
|
263
|
+
value: "strictest"
|
|
263
264
|
},
|
|
264
265
|
{
|
|
265
266
|
title: "I prefer not to use TypeScript",
|
|
@@ -285,7 +286,7 @@ ${bold(
|
|
|
285
286
|
console.log(` Astro supports TypeScript inside of ".astro" component scripts, so`);
|
|
286
287
|
console.log(` we still need to create some TypeScript-related files in your project.`);
|
|
287
288
|
console.log(` You can safely ignore these files, but don't delete them!`);
|
|
288
|
-
console.log(dim(" (ex: tsconfig.json, src/
|
|
289
|
+
console.log(dim(" (ex: tsconfig.json, src/env.d.ts)"));
|
|
289
290
|
console.log(``);
|
|
290
291
|
tsResponse.typescript = "default";
|
|
291
292
|
await wait(300);
|
|
@@ -293,14 +294,31 @@ ${bold(
|
|
|
293
294
|
if (args.dryRun) {
|
|
294
295
|
ora().info(dim(`--dry-run enabled, skipping.`));
|
|
295
296
|
} else if (tsResponse.typescript) {
|
|
296
|
-
|
|
297
|
-
path.join(
|
|
298
|
-
|
|
299
|
-
"
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
297
|
+
if (tsResponse.typescript !== "default") {
|
|
298
|
+
const templateTSConfigPath = path.join(cwd, "tsconfig.json");
|
|
299
|
+
fs.readFile(templateTSConfigPath, (err, data) => {
|
|
300
|
+
if (err && err.code === "ENOENT") {
|
|
301
|
+
fs.writeFileSync(
|
|
302
|
+
templateTSConfigPath,
|
|
303
|
+
stringify({ extends: `astro/tsconfigs/${tsResponse.typescript}` }, null, 2)
|
|
304
|
+
);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const templateTSConfig = parse(data.toString());
|
|
308
|
+
if (templateTSConfig && typeof templateTSConfig === "object") {
|
|
309
|
+
const result = assign(templateTSConfig, {
|
|
310
|
+
extends: `astro/tsconfigs/${tsResponse.typescript}`
|
|
311
|
+
});
|
|
312
|
+
fs.writeFileSync(templateTSConfigPath, stringify(result, null, 2));
|
|
313
|
+
} else {
|
|
314
|
+
console.log(
|
|
315
|
+
yellow(
|
|
316
|
+
"There was an error applying the requested TypeScript settings. This could be because the template's tsconfig.json is malformed"
|
|
317
|
+
)
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
304
322
|
ora().succeed("TypeScript settings applied!");
|
|
305
323
|
}
|
|
306
324
|
ora().succeed("Setup complete.");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1-next.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"chalk": "^5.0.1",
|
|
27
|
+
"comment-json": "^4.2.3",
|
|
27
28
|
"degit": "^2.8.4",
|
|
28
29
|
"execa": "^6.1.0",
|
|
29
30
|
"kleur": "^4.1.4",
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"@types/prompts": "^2.0.14",
|
|
40
41
|
"@types/which-pm-runs": "^1.0.0",
|
|
41
42
|
"@types/yargs-parser": "^21.0.0",
|
|
42
|
-
"astro-scripts": "0.0.
|
|
43
|
+
"astro-scripts": "0.0.7",
|
|
43
44
|
"chai": "^4.3.6",
|
|
44
45
|
"mocha": "^9.2.2",
|
|
45
46
|
"uvu": "^0.5.3"
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|