create-astro 4.2.1 โ 4.4.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/actions/typescript.d.ts +4 -4
- package/dist/index.js +91 -45
- package/package.json +4 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from './context.js';
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
|
|
5
|
-
}
|
|
2
|
+
type PickedTypeScriptContext = Pick<Context, 'typescript' | 'yes' | 'prompt' | 'dryRun' | 'cwd' | 'exit' | 'packageManager' | 'install'>;
|
|
3
|
+
export declare function typescript(ctx: PickedTypeScriptContext): Promise<void>;
|
|
4
|
+
export declare function setupTypeScript(value: string, ctx: PickedTypeScriptContext): Promise<void>;
|
|
5
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -249,24 +249,31 @@ async function spinner(args) {
|
|
|
249
249
|
}
|
|
250
250
|
var title = (text2) => align(label(text2), "end", 7) + " ";
|
|
251
251
|
var welcome = [
|
|
252
|
-
`Let's claim your corner of the internet.`,
|
|
253
|
-
`I'll be your assistant today.`,
|
|
254
|
-
`Let's build something awesome!`,
|
|
255
|
-
`Let's build something great!`,
|
|
256
|
-
`Let's build something fast!`,
|
|
257
|
-
`Let's build the web we want.`,
|
|
258
|
-
`Let's make the web weird!`,
|
|
259
|
-
`Let's make the web a better place!`,
|
|
260
|
-
`Let's create a new project!`,
|
|
261
|
-
`Let's create something unique!`,
|
|
262
|
-
`Time to build a new website.`,
|
|
263
|
-
`Time to build a faster website.`,
|
|
264
|
-
`Time to build a sweet new website.`,
|
|
265
|
-
`We're glad to have you on board.`,
|
|
266
|
-
`Keeping the internet weird since 2021.`,
|
|
267
|
-
`Initiating launch sequence...`,
|
|
268
|
-
`Initiating launch sequence... right... now!`,
|
|
269
|
-
`Awaiting further instructions
|
|
252
|
+
// `Let's claim your corner of the internet.`,
|
|
253
|
+
// `I'll be your assistant today.`,
|
|
254
|
+
// `Let's build something awesome!`,
|
|
255
|
+
// `Let's build something great!`,
|
|
256
|
+
// `Let's build something fast!`,
|
|
257
|
+
// `Let's build the web we want.`,
|
|
258
|
+
// `Let's make the web weird!`,
|
|
259
|
+
// `Let's make the web a better place!`,
|
|
260
|
+
// `Let's create a new project!`,
|
|
261
|
+
// `Let's create something unique!`,
|
|
262
|
+
// `Time to build a new website.`,
|
|
263
|
+
// `Time to build a faster website.`,
|
|
264
|
+
// `Time to build a sweet new website.`,
|
|
265
|
+
// `We're glad to have you on board.`,
|
|
266
|
+
// `Keeping the internet weird since 2021.`,
|
|
267
|
+
// `Initiating launch sequence...`,
|
|
268
|
+
// `Initiating launch sequence... right... now!`,
|
|
269
|
+
// `Awaiting further instructions.`,
|
|
270
|
+
`Booo! Let's scare the interwebs!`,
|
|
271
|
+
`Get ready to haunt the internet with Halloween vibes.`,
|
|
272
|
+
`Harness the power of the web for your frightful ideas.`,
|
|
273
|
+
`It's time to conjure up an online spooktacular masterpiece.`,
|
|
274
|
+
`Prepare for a web of Halloween wonders to be woven.`,
|
|
275
|
+
`Chills and thrills await as you embark on your web journey`,
|
|
276
|
+
`The internet is about to get a whole lot creepier thanks to your new project.`
|
|
270
277
|
];
|
|
271
278
|
var getName = () => new Promise((resolve) => {
|
|
272
279
|
exec("git config user.name", { encoding: "utf-8" }, (_1, gitName) => {
|
|
@@ -384,7 +391,7 @@ function printHelp({
|
|
|
384
391
|
if (headline) {
|
|
385
392
|
message.push(
|
|
386
393
|
linebreak(),
|
|
387
|
-
`${title(commandName)} ${color.green(`v${"4.
|
|
394
|
+
`${title(commandName)} ${color.green(`v${"4.4.0"}`)} ${headline}`
|
|
388
395
|
);
|
|
389
396
|
}
|
|
390
397
|
if (usage) {
|
|
@@ -470,7 +477,8 @@ async function getContext(argv) {
|
|
|
470
477
|
projectName: projectName2,
|
|
471
478
|
template: template2,
|
|
472
479
|
ref: ref ?? "latest",
|
|
473
|
-
hat:
|
|
480
|
+
hat: random(["\u{1F383}", "\u{1F47B}", "\u{1F56F}\uFE0F"]),
|
|
481
|
+
//fancy ? random(['๐ฉ', '๐ฉ', '๐ฉ', '๐ฉ', '๐', '๐', '๐งข', '๐ฆ']) : undefined,
|
|
474
482
|
yes,
|
|
475
483
|
install: install2 ?? (noInstall ? false : void 0),
|
|
476
484
|
git: git2 ?? (noGit ? false : void 0),
|
|
@@ -855,7 +863,12 @@ async function copyTemplate(tmpl, ctx) {
|
|
|
855
863
|
dir: "."
|
|
856
864
|
});
|
|
857
865
|
} catch (err) {
|
|
858
|
-
|
|
866
|
+
if (ctx.cwd !== "." && ctx.cwd !== "./" && !ctx.cwd.startsWith("../")) {
|
|
867
|
+
try {
|
|
868
|
+
fs4.rmdirSync(ctx.cwd);
|
|
869
|
+
} catch (_) {
|
|
870
|
+
}
|
|
871
|
+
}
|
|
859
872
|
if (err.message.includes("404")) {
|
|
860
873
|
throw new Error(`Template ${color6.reset(tmpl)} ${color6.dim("does not exist!")}`);
|
|
861
874
|
} else {
|
|
@@ -883,8 +896,7 @@ async function copyTemplate(tmpl, ctx) {
|
|
|
883
896
|
|
|
884
897
|
// src/actions/typescript.ts
|
|
885
898
|
import { color as color7 } from "@astrojs/cli-kit";
|
|
886
|
-
import
|
|
887
|
-
import { readFile } from "node:fs/promises";
|
|
899
|
+
import { readFile, rm, writeFile } from "node:fs/promises";
|
|
888
900
|
import path6 from "node:path";
|
|
889
901
|
|
|
890
902
|
// ../../node_modules/.pnpm/strip-json-comments@5.0.1/node_modules/strip-json-comments/index.js
|
|
@@ -1005,7 +1017,7 @@ async function typescript(ctx) {
|
|
|
1005
1017
|
} else {
|
|
1006
1018
|
if (!["strict", "strictest", "relaxed", "default", "base"].includes(ts)) {
|
|
1007
1019
|
if (!ctx.dryRun) {
|
|
1008
|
-
|
|
1020
|
+
await rm(ctx.cwd, { recursive: true, force: true });
|
|
1009
1021
|
}
|
|
1010
1022
|
error(
|
|
1011
1023
|
"Error",
|
|
@@ -1026,7 +1038,7 @@ async function typescript(ctx) {
|
|
|
1026
1038
|
await spinner({
|
|
1027
1039
|
start: "TypeScript customizing...",
|
|
1028
1040
|
end: "TypeScript customized",
|
|
1029
|
-
while: () => setupTypeScript(ts,
|
|
1041
|
+
while: () => setupTypeScript(ts, ctx).catch((e) => {
|
|
1030
1042
|
error("error", e);
|
|
1031
1043
|
process.exit(1);
|
|
1032
1044
|
})
|
|
@@ -1034,29 +1046,63 @@ async function typescript(ctx) {
|
|
|
1034
1046
|
} else {
|
|
1035
1047
|
}
|
|
1036
1048
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
});
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1049
|
+
var FILES_TO_UPDATE2 = {
|
|
1050
|
+
"package.json": async (file, options) => {
|
|
1051
|
+
try {
|
|
1052
|
+
if (options.ctx.install)
|
|
1053
|
+
await shell(options.ctx.packageManager, ["install", "@astrojs/check", "typescript"], {
|
|
1054
|
+
cwd: path6.dirname(file),
|
|
1055
|
+
stdio: "ignore"
|
|
1056
|
+
});
|
|
1057
|
+
const data = await readFile(file, { encoding: "utf-8" });
|
|
1058
|
+
const indent = /(^\s+)/m.exec(data)?.[1] ?? " ";
|
|
1059
|
+
const parsedPackageJson = JSON.parse(data);
|
|
1060
|
+
const buildScript = parsedPackageJson.scripts?.build;
|
|
1061
|
+
if (typeof buildScript === "string" && !buildScript.includes("astro check")) {
|
|
1062
|
+
const newPackageJson = Object.assign(parsedPackageJson, {
|
|
1063
|
+
scripts: {
|
|
1064
|
+
build: "astro check && " + buildScript
|
|
1065
|
+
}
|
|
1066
|
+
});
|
|
1067
|
+
await writeFile(file, JSON.stringify(newPackageJson, null, indent), "utf-8");
|
|
1068
|
+
}
|
|
1069
|
+
} catch (err) {
|
|
1070
|
+
if (err && err.code === "ENOENT")
|
|
1071
|
+
return;
|
|
1072
|
+
if (err instanceof Error)
|
|
1073
|
+
throw new Error(err.message);
|
|
1051
1074
|
}
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
)
|
|
1075
|
+
},
|
|
1076
|
+
"tsconfig.json": async (file, options) => {
|
|
1077
|
+
try {
|
|
1078
|
+
const data = await readFile(file, { encoding: "utf-8" });
|
|
1079
|
+
const templateTSConfig = JSON.parse(stripJsonComments(data));
|
|
1080
|
+
if (templateTSConfig && typeof templateTSConfig === "object") {
|
|
1081
|
+
const result = Object.assign(templateTSConfig, {
|
|
1082
|
+
extends: `astro/tsconfigs/${options.value}`
|
|
1083
|
+
});
|
|
1084
|
+
await writeFile(file, JSON.stringify(result, null, 2));
|
|
1085
|
+
} else {
|
|
1086
|
+
throw new Error(
|
|
1087
|
+
"There was an error applying the requested TypeScript settings. This could be because the template's tsconfig.json is malformed"
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
} catch (err) {
|
|
1091
|
+
if (err && err.code === "ENOENT") {
|
|
1092
|
+
await writeFile(
|
|
1093
|
+
file,
|
|
1094
|
+
JSON.stringify({ extends: `astro/tsconfigs/${options.value}` }, null, 2)
|
|
1095
|
+
);
|
|
1096
|
+
}
|
|
1058
1097
|
}
|
|
1059
1098
|
}
|
|
1099
|
+
};
|
|
1100
|
+
async function setupTypeScript(value, ctx) {
|
|
1101
|
+
await Promise.all(
|
|
1102
|
+
Object.entries(FILES_TO_UPDATE2).map(
|
|
1103
|
+
async ([file, update]) => update(path6.resolve(path6.join(ctx.cwd, file)), { value, ctx })
|
|
1104
|
+
)
|
|
1105
|
+
);
|
|
1060
1106
|
}
|
|
1061
1107
|
|
|
1062
1108
|
// src/actions/verify.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astro",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,6 +39,9 @@
|
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=18.14.1"
|
|
41
41
|
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"provenance": true
|
|
44
|
+
},
|
|
42
45
|
"scripts": {
|
|
43
46
|
"build": "astro-scripts build \"src/index.ts\" --bundle && tsc",
|
|
44
47
|
"build:ci": "astro-scripts build \"src/index.ts\" --bundle",
|