@astrojs/upgrade 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -622,12 +622,25 @@ async function verifyAstroProject(ctx) {
622
622
  collectPackageInfo(ctx, dependencies, devDependencies);
623
623
  return true;
624
624
  }
625
- function isAstroPackage(name) {
625
+ function isAstroPackage(name, _version) {
626
626
  return name === "astro" || name.startsWith("@astrojs/");
627
627
  }
628
- function collectPackageInfo(ctx, dependencies, devDependencies) {
628
+ function isAllowedPackage(name, _version) {
629
+ return name !== "@astrojs/upgrade";
630
+ }
631
+ function isValidVersion(_name, version) {
632
+ return semverCoerce(version, { loose: true }) !== null;
633
+ }
634
+ function isSupportedPackage(name, version) {
635
+ for (const validator of [isAstroPackage, isAllowedPackage, isValidVersion]) {
636
+ if (!validator(name, version))
637
+ return false;
638
+ }
639
+ return true;
640
+ }
641
+ function collectPackageInfo(ctx, dependencies = {}, devDependencies = {}) {
629
642
  for (const [name, currentVersion] of Object.entries(dependencies)) {
630
- if (!isAstroPackage(name))
643
+ if (!isSupportedPackage(name, currentVersion))
631
644
  continue;
632
645
  ctx.packages.push({
633
646
  name,
@@ -636,7 +649,7 @@ function collectPackageInfo(ctx, dependencies, devDependencies) {
636
649
  });
637
650
  }
638
651
  for (const [name, currentVersion] of Object.entries(devDependencies)) {
639
- if (!isAstroPackage(name))
652
+ if (!isSupportedPackage(name, currentVersion))
640
653
  continue;
641
654
  ctx.packages.push({
642
655
  name,
@@ -732,6 +745,7 @@ async function main() {
732
745
  process.exit(0);
733
746
  }
734
747
  export {
748
+ collectPackageInfo,
735
749
  getContext,
736
750
  install,
737
751
  main,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/upgrade",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",