@astrojs/upgrade 0.2.0 → 0.2.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/dist/index.js +22 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -513,6 +513,7 @@ async function runInstallCommand(ctx, dependencies, devDependencies) {
|
|
|
513
513
|
const cwd = fileURLToPath(ctx.cwd);
|
|
514
514
|
if (ctx.packageManager === "yarn")
|
|
515
515
|
await ensureYarnLock({ cwd });
|
|
516
|
+
const installCmd = ctx.packageManager === "yarn" || ctx.packageManager === "pnpm" ? "add" : "install";
|
|
516
517
|
await spinner({
|
|
517
518
|
start: `Installing dependencies with ${ctx.packageManager}...`,
|
|
518
519
|
end: `Installed dependencies!`,
|
|
@@ -522,7 +523,7 @@ async function runInstallCommand(ctx, dependencies, devDependencies) {
|
|
|
522
523
|
await shell(
|
|
523
524
|
ctx.packageManager,
|
|
524
525
|
[
|
|
525
|
-
|
|
526
|
+
installCmd,
|
|
526
527
|
...dependencies.map(
|
|
527
528
|
({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, "")}`
|
|
528
529
|
)
|
|
@@ -534,7 +535,7 @@ async function runInstallCommand(ctx, dependencies, devDependencies) {
|
|
|
534
535
|
await shell(
|
|
535
536
|
ctx.packageManager,
|
|
536
537
|
[
|
|
537
|
-
|
|
538
|
+
installCmd,
|
|
538
539
|
"--save-dev",
|
|
539
540
|
...devDependencies.map(
|
|
540
541
|
({ name, targetVersion }) => `${name}@${targetVersion.replace(/^\^/, "")}`
|
|
@@ -550,7 +551,7 @@ async function runInstallCommand(ctx, dependencies, devDependencies) {
|
|
|
550
551
|
"error",
|
|
551
552
|
`Dependencies failed to install, please run the following command manually:
|
|
552
553
|
${color2.bold(
|
|
553
|
-
`${ctx.packageManager}
|
|
554
|
+
`${ctx.packageManager} ${installCmd} ${packages}`
|
|
554
555
|
)}`
|
|
555
556
|
);
|
|
556
557
|
return ctx.exit(1);
|
|
@@ -622,12 +623,25 @@ async function verifyAstroProject(ctx) {
|
|
|
622
623
|
collectPackageInfo(ctx, dependencies, devDependencies);
|
|
623
624
|
return true;
|
|
624
625
|
}
|
|
625
|
-
function isAstroPackage(name) {
|
|
626
|
+
function isAstroPackage(name, _version) {
|
|
626
627
|
return name === "astro" || name.startsWith("@astrojs/");
|
|
627
628
|
}
|
|
628
|
-
function
|
|
629
|
+
function isAllowedPackage(name, _version) {
|
|
630
|
+
return name !== "@astrojs/upgrade";
|
|
631
|
+
}
|
|
632
|
+
function isValidVersion(_name, version) {
|
|
633
|
+
return semverCoerce(version, { loose: true }) !== null;
|
|
634
|
+
}
|
|
635
|
+
function isSupportedPackage(name, version) {
|
|
636
|
+
for (const validator of [isAstroPackage, isAllowedPackage, isValidVersion]) {
|
|
637
|
+
if (!validator(name, version))
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
return true;
|
|
641
|
+
}
|
|
642
|
+
function collectPackageInfo(ctx, dependencies = {}, devDependencies = {}) {
|
|
629
643
|
for (const [name, currentVersion] of Object.entries(dependencies)) {
|
|
630
|
-
if (!
|
|
644
|
+
if (!isSupportedPackage(name, currentVersion))
|
|
631
645
|
continue;
|
|
632
646
|
ctx.packages.push({
|
|
633
647
|
name,
|
|
@@ -636,7 +650,7 @@ function collectPackageInfo(ctx, dependencies, devDependencies) {
|
|
|
636
650
|
});
|
|
637
651
|
}
|
|
638
652
|
for (const [name, currentVersion] of Object.entries(devDependencies)) {
|
|
639
|
-
if (!
|
|
653
|
+
if (!isSupportedPackage(name, currentVersion))
|
|
640
654
|
continue;
|
|
641
655
|
ctx.packages.push({
|
|
642
656
|
name,
|
|
@@ -732,6 +746,7 @@ async function main() {
|
|
|
732
746
|
process.exit(0);
|
|
733
747
|
}
|
|
734
748
|
export {
|
|
749
|
+
collectPackageInfo,
|
|
735
750
|
getContext,
|
|
736
751
|
install,
|
|
737
752
|
main,
|