create-astro 4.9.0 → 4.9.2
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/create-astro.mjs +1 -1
- package/dist/index.js +10 -53
- package/package.json +2 -3
package/create-astro.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -278,27 +278,10 @@ function rarity(frequency, emoji) {
|
|
|
278
278
|
|
|
279
279
|
// src/messages.ts
|
|
280
280
|
import { exec } from "node:child_process";
|
|
281
|
+
import { stripVTControlCharacters } from "node:util";
|
|
281
282
|
import { color, say as houston, label, spinner as load } from "@astrojs/cli-kit";
|
|
282
283
|
import { align, sleep } from "@astrojs/cli-kit/utils";
|
|
283
284
|
|
|
284
|
-
// ../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
|
|
285
|
-
function ansiRegex({ onlyFirst = false } = {}) {
|
|
286
|
-
const pattern = [
|
|
287
|
-
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
288
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
|
289
|
-
].join("|");
|
|
290
|
-
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
|
|
294
|
-
var regex = ansiRegex();
|
|
295
|
-
function stripAnsi(string) {
|
|
296
|
-
if (typeof string !== "string") {
|
|
297
|
-
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
298
|
-
}
|
|
299
|
-
return string.replace(regex, "");
|
|
300
|
-
}
|
|
301
|
-
|
|
302
285
|
// src/shell.ts
|
|
303
286
|
import { spawn } from "node:child_process";
|
|
304
287
|
import { text as textFromStream } from "node:stream/consumers";
|
|
@@ -420,7 +403,7 @@ var nextSteps = async ({ projectDir, devCmd }) => {
|
|
|
420
403
|
${prefix}Enter your project directory using`,
|
|
421
404
|
color.cyan(`cd ${projectDir}`, "")
|
|
422
405
|
];
|
|
423
|
-
const len = enter[0].length +
|
|
406
|
+
const len = enter[0].length + stripVTControlCharacters(enter[1]).length;
|
|
424
407
|
log(enter.join(len > max ? "\n" + prefix : " "));
|
|
425
408
|
}
|
|
426
409
|
log(
|
|
@@ -463,7 +446,7 @@ function printHelp({
|
|
|
463
446
|
if (headline) {
|
|
464
447
|
message.push(
|
|
465
448
|
linebreak(),
|
|
466
|
-
`${title(commandName)} ${color.green(`v${"4.9.
|
|
449
|
+
`${title(commandName)} ${color.green(`v${"4.9.2"}`)} ${headline}`
|
|
467
450
|
);
|
|
468
451
|
}
|
|
469
452
|
if (usage) {
|
|
@@ -540,7 +523,7 @@ async function getContext(argv) {
|
|
|
540
523
|
prompt,
|
|
541
524
|
packageManager,
|
|
542
525
|
username: getName(),
|
|
543
|
-
version: getVersion(packageManager, "astro", "4.
|
|
526
|
+
version: getVersion(packageManager, "astro", "4.16.0"),
|
|
544
527
|
skipHouston,
|
|
545
528
|
fancy,
|
|
546
529
|
dryRun,
|
|
@@ -858,7 +841,7 @@ async function checkCwd(cwd) {
|
|
|
858
841
|
import fs4 from "node:fs";
|
|
859
842
|
import path5 from "node:path";
|
|
860
843
|
import { color as color6 } from "@astrojs/cli-kit";
|
|
861
|
-
import { downloadTemplate } from "giget";
|
|
844
|
+
import { downloadTemplate } from "@bluwy/giget-core";
|
|
862
845
|
async function template(ctx) {
|
|
863
846
|
if (!ctx.template && ctx.yes) ctx.template = "basics";
|
|
864
847
|
if (ctx.template) {
|
|
@@ -957,9 +940,6 @@ async function copyTemplate(tmpl, ctx) {
|
|
|
957
940
|
}
|
|
958
941
|
throw new Error(`Unable to download template ${color6.reset(tmpl)}`);
|
|
959
942
|
}
|
|
960
|
-
if (fs4.readdirSync(ctx.cwd).length === 0) {
|
|
961
|
-
throw new Error(`Template ${color6.reset(tmpl)} ${color6.dim("is empty!")}`);
|
|
962
|
-
}
|
|
963
943
|
const removeFiles = FILES_TO_REMOVE.map(async (file) => {
|
|
964
944
|
const fileLoc = path5.resolve(path5.join(ctx.cwd, file));
|
|
965
945
|
if (fs4.existsSync(fileLoc)) {
|
|
@@ -1140,8 +1120,8 @@ var FILES_TO_UPDATE2 = {
|
|
|
1140
1120
|
parsedPackageJson.scripts.build = `astro check && ${buildScript}`;
|
|
1141
1121
|
}
|
|
1142
1122
|
const [astroCheckVersion, typescriptVersion] = await Promise.all([
|
|
1143
|
-
getVersion(options.ctx.packageManager, "@astrojs/check", "0.9.
|
|
1144
|
-
getVersion(options.ctx.packageManager, "typescript", "5.
|
|
1123
|
+
getVersion(options.ctx.packageManager, "@astrojs/check", "0.9.4"),
|
|
1124
|
+
getVersion(options.ctx.packageManager, "typescript", "5.6.2")
|
|
1145
1125
|
]);
|
|
1146
1126
|
parsedPackageJson.dependencies ??= {};
|
|
1147
1127
|
parsedPackageJson.dependencies["@astrojs/check"] = `^${astroCheckVersion}`;
|
|
@@ -1201,6 +1181,7 @@ async function setupTypeScript(value, ctx) {
|
|
|
1201
1181
|
// src/actions/verify.ts
|
|
1202
1182
|
import dns from "node:dns/promises";
|
|
1203
1183
|
import { color as color8 } from "@astrojs/cli-kit";
|
|
1184
|
+
import { verifyTemplate } from "@bluwy/giget-core";
|
|
1204
1185
|
async function verify(ctx) {
|
|
1205
1186
|
if (!ctx.dryRun) {
|
|
1206
1187
|
const online = await isOnline();
|
|
@@ -1212,7 +1193,8 @@ async function verify(ctx) {
|
|
|
1212
1193
|
}
|
|
1213
1194
|
}
|
|
1214
1195
|
if (ctx.template) {
|
|
1215
|
-
const
|
|
1196
|
+
const target = getTemplateTarget(ctx.template, ctx.ref);
|
|
1197
|
+
const ok = await verifyTemplate(target);
|
|
1216
1198
|
if (!ok) {
|
|
1217
1199
|
bannerAbort();
|
|
1218
1200
|
log("");
|
|
@@ -1228,31 +1210,6 @@ function isOnline() {
|
|
|
1228
1210
|
() => false
|
|
1229
1211
|
);
|
|
1230
1212
|
}
|
|
1231
|
-
async function verifyTemplate(tmpl, ref) {
|
|
1232
|
-
const target = getTemplateTarget(tmpl, ref);
|
|
1233
|
-
const { repo, subdir, ref: branch } = parseGitURI(target.replace("github:", ""));
|
|
1234
|
-
const url = new URL(`/repos/${repo}/contents${subdir}?ref=${branch}`, "https://api.github.com/");
|
|
1235
|
-
let res = await fetch(url.toString(), {
|
|
1236
|
-
headers: {
|
|
1237
|
-
Accept: "application/vnd.github+json",
|
|
1238
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
1239
|
-
}
|
|
1240
|
-
});
|
|
1241
|
-
if (res.status === 403) {
|
|
1242
|
-
res = await fetch(`https://github.com/${repo}/tree/${branch}${subdir}`);
|
|
1243
|
-
}
|
|
1244
|
-
return res.status === 200;
|
|
1245
|
-
}
|
|
1246
|
-
var GIT_RE = /^(?<repo>[\w.-]+\/[\w.-]+)(?<subdir>[^#]+)?(?<ref>#[\w.-]+)?/;
|
|
1247
|
-
function parseGitURI(input) {
|
|
1248
|
-
const m = GIT_RE.exec(input)?.groups;
|
|
1249
|
-
if (!m) throw new Error(`Unable to parse "${input}"`);
|
|
1250
|
-
return {
|
|
1251
|
-
repo: m.repo,
|
|
1252
|
-
subdir: m.subdir || "/",
|
|
1253
|
-
ref: m.ref ? m.ref.slice(1) : "main"
|
|
1254
|
-
};
|
|
1255
|
-
}
|
|
1256
1213
|
|
|
1257
1214
|
// src/index.ts
|
|
1258
1215
|
var exit = () => process.exit(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astro",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,11 +26,10 @@
|
|
|
26
26
|
"//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@astrojs/cli-kit": "^0.4.1",
|
|
29
|
-
"giget": "1.
|
|
29
|
+
"@bluwy/giget-core": "^0.1.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"arg": "^5.0.2",
|
|
33
|
-
"strip-ansi": "^7.1.0",
|
|
34
33
|
"strip-json-comments": "^5.0.1",
|
|
35
34
|
"astro-scripts": "0.0.14"
|
|
36
35
|
},
|