@astrojs/upgrade 0.6.1 → 0.7.0-alpha.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/index.js +52 -45
- package/package.json +6 -6
- package/upgrade.mjs +3 -1
package/dist/index.js
CHANGED
|
@@ -439,7 +439,7 @@ import { fileURLToPath } from "node:url";
|
|
|
439
439
|
import { color as color2, say } from "@astrojs/cli-kit";
|
|
440
440
|
import { random, sleep } from "@astrojs/cli-kit/utils";
|
|
441
441
|
import { resolveCommand } from "package-manager-detector";
|
|
442
|
-
async function install(ctx) {
|
|
442
|
+
async function install(ctx, shellFn = shell) {
|
|
443
443
|
await banner();
|
|
444
444
|
newline();
|
|
445
445
|
const { current, dependencies, devDependencies } = filterPackages(ctx);
|
|
@@ -486,7 +486,7 @@ async function install(ctx) {
|
|
|
486
486
|
if (ctx.dryRun) {
|
|
487
487
|
await info("--dry-run", `Skipping dependency installation`);
|
|
488
488
|
} else {
|
|
489
|
-
await runInstallCommand(ctx, dependencies, devDependencies);
|
|
489
|
+
await runInstallCommand(ctx, dependencies, devDependencies, shellFn);
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
492
|
function filterPackages(ctx) {
|
|
@@ -513,7 +513,7 @@ function sortPackages(a, b) {
|
|
|
513
513
|
if (b.name.startsWith("@astrojs") && !a.name.startsWith("@astrojs")) return 1;
|
|
514
514
|
return a.name.localeCompare(b.name);
|
|
515
515
|
}
|
|
516
|
-
async function runInstallCommand(ctx, dependencies, devDependencies) {
|
|
516
|
+
async function runInstallCommand(ctx, dependencies, devDependencies, shellFn = shell) {
|
|
517
517
|
const cwd = fileURLToPath(ctx.cwd);
|
|
518
518
|
if (ctx.packageManager.name === "yarn") await ensureYarnLock({ cwd });
|
|
519
519
|
const installCommand = resolveCommand(ctx.packageManager.agent, "add", []);
|
|
@@ -521,52 +521,59 @@ async function runInstallCommand(ctx, dependencies, devDependencies) {
|
|
|
521
521
|
error("error", `Unable to find install command for ${ctx.packageManager.name}.`);
|
|
522
522
|
return ctx.exit(1);
|
|
523
523
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
try {
|
|
529
|
-
if (dependencies.length > 0) {
|
|
530
|
-
await shell(
|
|
531
|
-
installCommand.command,
|
|
532
|
-
[
|
|
533
|
-
...installCommand.args,
|
|
534
|
-
...dependencies.map(
|
|
535
|
-
({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, "")}`
|
|
536
|
-
)
|
|
537
|
-
],
|
|
538
|
-
{ cwd, timeout: 9e4, stdio: "ignore" }
|
|
539
|
-
);
|
|
540
|
-
}
|
|
541
|
-
if (devDependencies.length > 0) {
|
|
542
|
-
await shell(
|
|
543
|
-
installCommand.command,
|
|
544
|
-
[
|
|
545
|
-
...installCommand.args,
|
|
546
|
-
...devDependencies.map(
|
|
547
|
-
({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, "")}`
|
|
548
|
-
)
|
|
549
|
-
],
|
|
550
|
-
{ cwd, timeout: 9e4, stdio: "ignore" }
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
|
-
} catch {
|
|
554
|
-
const manualInstallCommand = [
|
|
524
|
+
const doInstall = async (legacyPeerDeps = false) => {
|
|
525
|
+
try {
|
|
526
|
+
if (dependencies.length > 0) {
|
|
527
|
+
await shellFn(
|
|
555
528
|
installCommand.command,
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
529
|
+
[
|
|
530
|
+
...installCommand.args,
|
|
531
|
+
...legacyPeerDeps ? ["--legacy-peer-deps"] : [],
|
|
532
|
+
...dependencies.map(
|
|
533
|
+
({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, "")}`
|
|
534
|
+
)
|
|
535
|
+
],
|
|
536
|
+
{ cwd, timeout: 9e4 }
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
if (devDependencies.length > 0) {
|
|
540
|
+
await shellFn(
|
|
541
|
+
installCommand.command,
|
|
542
|
+
[
|
|
543
|
+
...installCommand.args,
|
|
544
|
+
...legacyPeerDeps ? ["--legacy-peer-deps"] : [],
|
|
545
|
+
...devDependencies.map(
|
|
546
|
+
({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, "")}`
|
|
547
|
+
)
|
|
548
|
+
],
|
|
549
|
+
{ cwd, timeout: 9e4 }
|
|
566
550
|
);
|
|
567
|
-
return ctx.exit(1);
|
|
568
551
|
}
|
|
552
|
+
} catch (err) {
|
|
553
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
554
|
+
if (ctx.packageManager.name === "npm" && !legacyPeerDeps && errorMessage.includes("peer dependenc")) {
|
|
555
|
+
return doInstall(true);
|
|
556
|
+
}
|
|
557
|
+
const manualInstallCommand = [
|
|
558
|
+
installCommand.command,
|
|
559
|
+
...installCommand.args,
|
|
560
|
+
...[...dependencies, ...devDependencies].map(
|
|
561
|
+
({ name, targetVersion }) => `${name}@${targetVersion}`
|
|
562
|
+
)
|
|
563
|
+
].join(" ");
|
|
564
|
+
newline();
|
|
565
|
+
error(
|
|
566
|
+
"error",
|
|
567
|
+
`Dependencies failed to install, please run the following command manually:
|
|
568
|
+
${color2.bold(manualInstallCommand)}`
|
|
569
|
+
);
|
|
570
|
+
return ctx.exit(1);
|
|
569
571
|
}
|
|
572
|
+
};
|
|
573
|
+
await spinner({
|
|
574
|
+
start: `Installing dependencies with ${ctx.packageManager.name}...`,
|
|
575
|
+
end: `Installed dependencies!`,
|
|
576
|
+
while: doInstall
|
|
570
577
|
});
|
|
571
578
|
await say([`${random(celebrations)} ${random(done)}`, random(bye)], { clear: false });
|
|
572
579
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/upgrade",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
"//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@astrojs/cli-kit": "^0.4.1",
|
|
27
|
-
"package-manager-detector": "^1.
|
|
28
|
-
"semver": "^7.7.
|
|
29
|
-
"terminal-link": "^
|
|
27
|
+
"package-manager-detector": "^1.5.0",
|
|
28
|
+
"semver": "^7.7.3",
|
|
29
|
+
"terminal-link": "^4.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/semver": "^7.7.
|
|
32
|
+
"@types/semver": "^7.7.1",
|
|
33
33
|
"arg": "^5.0.2",
|
|
34
34
|
"astro-scripts": "0.0.14"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
|
-
"node": "
|
|
37
|
+
"node": "^20.19.5 || >=22.12.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "astro-scripts build \"src/index.ts\" --bundle && tsc",
|
package/upgrade.mjs
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
const currentVersion = process.versions.node;
|
|
6
6
|
const requiredMajorVersion = parseInt(currentVersion.split('.')[0], 10);
|
|
7
|
-
|
|
7
|
+
// TODO: remove once Stackblitz supports Node 22
|
|
8
|
+
const IS_STACKBLITZ = !!process.versions.webcontainer;
|
|
9
|
+
const minimumMajorVersion = IS_STACKBLITZ ? 20 : 22;
|
|
8
10
|
|
|
9
11
|
if (requiredMajorVersion < minimumMajorVersion) {
|
|
10
12
|
console.error(`Node.js v${currentVersion} is out of date and unsupported!`);
|