create-astro 5.0.0-beta.3 → 5.0.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/create-astro.mjs CHANGED
@@ -3,13 +3,13 @@
3
3
  'use strict';
4
4
 
5
5
  const currentVersion = process.versions.node;
6
- const requiredMajorVersion = parseInt(currentVersion.split('.')[0], 10);
6
+ const requiredMajorVersion = Number.parseInt(currentVersion.split('.')[0], 10);
7
7
  // TODO: remove once Stackblitz supports Node 22
8
8
  const IS_STACKBLITZ = !!process.versions.webcontainer;
9
9
  const minimumMajorVersion = IS_STACKBLITZ ? 20 : 22;
10
10
 
11
11
  if (requiredMajorVersion < minimumMajorVersion) {
12
- console.error(`Node.js v${currentVersion} is out of date and unsupported!`);
12
+ console.error(`Node.js v${currentVersion} is out-of-date and unsupported!`);
13
13
  console.error(`Please use Node.js v${minimumMajorVersion} or higher.`);
14
14
  process.exit(1);
15
15
  }
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  // ../../node_modules/.pnpm/arg@5.0.2/node_modules/arg/index.js
28
28
  var require_arg = __commonJS({
29
29
  "../../node_modules/.pnpm/arg@5.0.2/node_modules/arg/index.js"(exports, module) {
30
- var flagSymbol = Symbol("arg flag");
30
+ var flagSymbol = /* @__PURE__ */ Symbol("arg flag");
31
31
  var ArgError = class _ArgError extends Error {
32
32
  constructor(msg, code) {
33
33
  super(msg);
@@ -295,7 +295,7 @@ async function shell(command, flags, opts = {}) {
295
295
  let stdout2 = "";
296
296
  let stderr = "";
297
297
  try {
298
- child = spawn(`${command} ${flags.join(" ")}`, {
298
+ child = spawn(command, flags, {
299
299
  cwd: opts.cwd,
300
300
  shell: true,
301
301
  stdio: opts.stdio,
@@ -452,7 +452,7 @@ function printHelp({
452
452
  if (headline) {
453
453
  message.push(
454
454
  linebreak(),
455
- `${title(commandName)} ${color.green(`v${"5.0.0-beta.3"}`)} ${headline}`
455
+ `${title(commandName)} ${color.green(`v${"5.0.0"}`)} ${headline}`
456
456
  );
457
457
  }
458
458
  if (usage) {
@@ -482,7 +482,7 @@ function getPackageTag(packageSpecifier) {
482
482
  case "beta":
483
483
  case "rc":
484
484
  return packageSpecifier;
485
- // Will fallback to latest
485
+ // Will fall back to latest
486
486
  case void 0:
487
487
  default:
488
488
  return void 0;
@@ -537,8 +537,8 @@ async function getContext(argv) {
537
537
  let projectName2 = cwd;
538
538
  if (no) {
539
539
  yes = false;
540
- if (install2 == void 0) install2 = false;
541
- if (git2 == void 0) git2 = false;
540
+ if (install2 === void 0) install2 = false;
541
+ if (git2 === void 0) git2 = false;
542
542
  }
543
543
  skipHouston = (os.platform() === "win32" && !fancy || skipHouston) ?? [yes, no, install2, git2].some((v) => v !== void 0);
544
544
  const { messages, hats, ties } = getSeasonalHouston({ fancy });
@@ -551,7 +551,7 @@ async function getContext(argv) {
551
551
  packageManager,
552
552
  "astro",
553
553
  getPackageTag(packageSpecifier),
554
- "6.0.0-beta.7"
554
+ "6.0.0"
555
555
  ),
556
556
  skipHouston,
557
557
  fancy,
@@ -584,6 +584,21 @@ function detectPackageManager() {
584
584
  // src/actions/dependencies.ts
585
585
  import fs from "node:fs";
586
586
  import path from "node:path";
587
+
588
+ // ../internal-helpers/dist/cli.js
589
+ var NPM_PACKAGE_NAME_REGEX = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
590
+ function validatePackageName(packageName) {
591
+ return NPM_PACKAGE_NAME_REGEX.test(packageName);
592
+ }
593
+ function assertValidPackageName(packageName) {
594
+ if (!validatePackageName(packageName)) {
595
+ throw new Error(
596
+ `Invalid package name "${packageName}". Package names must follow npm naming rules: lowercase letters, numbers, hyphens, underscores, and dots. Scoped packages like @org/package are also supported.`
597
+ );
598
+ }
599
+ }
600
+
601
+ // src/actions/dependencies.ts
587
602
  import { color as color2 } from "@astrojs/cli-kit";
588
603
  async function dependencies(ctx) {
589
604
  let deps = ctx.install ?? ctx.yes;
@@ -599,6 +614,11 @@ async function dependencies(ctx) {
599
614
  ctx.install = deps;
600
615
  }
601
616
  ctx.add = ctx.add?.reduce((acc, item) => acc.concat(item.split(",")), []);
617
+ if (ctx.add) {
618
+ for (const addValue of ctx.add) {
619
+ assertValidPackageName(addValue);
620
+ }
621
+ }
602
622
  if (ctx.dryRun) {
603
623
  await info(
604
624
  "--dry-run",
@@ -651,11 +671,9 @@ async function astroAdd({
651
671
  cwd
652
672
  }) {
653
673
  if (packageManager === "yarn") await ensureYarnLock({ cwd });
654
- return shell(
655
- packageManager === "npm" ? "npx" : `${packageManager} dlx`,
656
- ["astro add", integrations.join(" "), "-y"],
657
- { cwd, timeout: 9e4, stdio: "ignore" }
658
- );
674
+ const command = packageManager === "npm" ? "npx" : packageManager;
675
+ const args = packageManager === "npm" ? ["astro", "add", ...integrations, "-y"] : ["dlx", "astro", "add", ...integrations, "-y"];
676
+ return shell(command, args, { cwd, timeout: 9e4, stdio: "ignore" });
659
677
  }
660
678
  async function install({ packageManager, cwd }) {
661
679
  if (packageManager === "yarn") await ensureYarnLock({ cwd });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "5.0.0-beta.3",
3
+ "version": "5.0.0",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "arg": "^5.0.2",
33
+ "@astrojs/internal-helpers": "0.8.0",
33
34
  "astro-scripts": "0.0.14"
34
35
  },
35
36
  "engines": {