create-astro 5.0.0-beta.3 → 5.0.0-beta.4
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 +26 -8
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -295,7 +295,7 @@ async function shell(command, flags, opts = {}) {
|
|
|
295
295
|
let stdout2 = "";
|
|
296
296
|
let stderr = "";
|
|
297
297
|
try {
|
|
298
|
-
child = spawn(
|
|
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.
|
|
455
|
+
`${title(commandName)} ${color.green(`v${"5.0.0-beta.4"}`)} ${headline}`
|
|
456
456
|
);
|
|
457
457
|
}
|
|
458
458
|
if (usage) {
|
|
@@ -551,7 +551,7 @@ async function getContext(argv) {
|
|
|
551
551
|
packageManager,
|
|
552
552
|
"astro",
|
|
553
553
|
getPackageTag(packageSpecifier),
|
|
554
|
-
"6.0.0-beta.
|
|
554
|
+
"6.0.0-beta.10"
|
|
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
|
-
|
|
655
|
-
|
|
656
|
-
|
|
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
|
+
"version": "5.0.0-beta.4",
|
|
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-beta.1",
|
|
33
34
|
"astro-scripts": "0.0.14"
|
|
34
35
|
},
|
|
35
36
|
"engines": {
|