create-astro 4.9.1 → 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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- /* eslint-disable no-console */
2
+
3
3
  'use strict';
4
4
 
5
5
  const currentVersion = process.versions.node;
package/dist/index.js CHANGED
@@ -446,7 +446,7 @@ function printHelp({
446
446
  if (headline) {
447
447
  message.push(
448
448
  linebreak(),
449
- `${title(commandName)} ${color.green(`v${"4.9.1"}`)} ${headline}`
449
+ `${title(commandName)} ${color.green(`v${"4.9.2"}`)} ${headline}`
450
450
  );
451
451
  }
452
452
  if (usage) {
@@ -523,7 +523,7 @@ async function getContext(argv) {
523
523
  prompt,
524
524
  packageManager,
525
525
  username: getName(),
526
- version: getVersion(packageManager, "astro", "4.15.12"),
526
+ version: getVersion(packageManager, "astro", "4.16.0"),
527
527
  skipHouston,
528
528
  fancy,
529
529
  dryRun,
@@ -841,7 +841,7 @@ async function checkCwd(cwd) {
841
841
  import fs4 from "node:fs";
842
842
  import path5 from "node:path";
843
843
  import { color as color6 } from "@astrojs/cli-kit";
844
- import { downloadTemplate } from "giget";
844
+ import { downloadTemplate } from "@bluwy/giget-core";
845
845
  async function template(ctx) {
846
846
  if (!ctx.template && ctx.yes) ctx.template = "basics";
847
847
  if (ctx.template) {
@@ -940,9 +940,6 @@ async function copyTemplate(tmpl, ctx) {
940
940
  }
941
941
  throw new Error(`Unable to download template ${color6.reset(tmpl)}`);
942
942
  }
943
- if (fs4.readdirSync(ctx.cwd).length === 0) {
944
- throw new Error(`Template ${color6.reset(tmpl)} ${color6.dim("is empty!")}`);
945
- }
946
943
  const removeFiles = FILES_TO_REMOVE.map(async (file) => {
947
944
  const fileLoc = path5.resolve(path5.join(ctx.cwd, file));
948
945
  if (fs4.existsSync(fileLoc)) {
@@ -1184,6 +1181,7 @@ async function setupTypeScript(value, ctx) {
1184
1181
  // src/actions/verify.ts
1185
1182
  import dns from "node:dns/promises";
1186
1183
  import { color as color8 } from "@astrojs/cli-kit";
1184
+ import { verifyTemplate } from "@bluwy/giget-core";
1187
1185
  async function verify(ctx) {
1188
1186
  if (!ctx.dryRun) {
1189
1187
  const online = await isOnline();
@@ -1195,7 +1193,8 @@ async function verify(ctx) {
1195
1193
  }
1196
1194
  }
1197
1195
  if (ctx.template) {
1198
- const ok = await verifyTemplate(ctx.template, ctx.ref);
1196
+ const target = getTemplateTarget(ctx.template, ctx.ref);
1197
+ const ok = await verifyTemplate(target);
1199
1198
  if (!ok) {
1200
1199
  bannerAbort();
1201
1200
  log("");
@@ -1211,31 +1210,6 @@ function isOnline() {
1211
1210
  () => false
1212
1211
  );
1213
1212
  }
1214
- async function verifyTemplate(tmpl, ref) {
1215
- const target = getTemplateTarget(tmpl, ref);
1216
- const { repo, subdir, ref: branch } = parseGitURI(target.replace("github:", ""));
1217
- const url = new URL(`/repos/${repo}/contents${subdir}?ref=${branch}`, "https://api.github.com/");
1218
- let res = await fetch(url.toString(), {
1219
- headers: {
1220
- Accept: "application/vnd.github+json",
1221
- "X-GitHub-Api-Version": "2022-11-28"
1222
- }
1223
- });
1224
- if (res.status === 403) {
1225
- res = await fetch(`https://github.com/${repo}/tree/${branch}${subdir}`);
1226
- }
1227
- return res.status === 200;
1228
- }
1229
- var GIT_RE = /^(?<repo>[\w.-]+\/[\w.-]+)(?<subdir>[^#]+)?(?<ref>#[\w.-]+)?/;
1230
- function parseGitURI(input) {
1231
- const m = GIT_RE.exec(input)?.groups;
1232
- if (!m) throw new Error(`Unable to parse "${input}"`);
1233
- return {
1234
- repo: m.repo,
1235
- subdir: m.subdir || "/",
1236
- ref: m.ref ? m.ref.slice(1) : "main"
1237
- };
1238
- }
1239
1213
 
1240
1214
  // src/index.ts
1241
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.1",
3
+ "version": "4.9.2",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES",
27
27
  "dependencies": {
28
28
  "@astrojs/cli-kit": "^0.4.1",
29
- "giget": "1.2.3"
29
+ "@bluwy/giget-core": "^0.1.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "arg": "^5.0.2",