@astrojs/upgrade 0.1.2 → 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 (3) hide show
  1. package/LICENSE +0 -2
  2. package/dist/index.js +19 -5
  3. package/package.json +1 -1
package/LICENSE CHANGED
@@ -20,7 +20,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
22
 
23
-
24
23
  """
25
24
  This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
26
25
 
@@ -33,7 +32,6 @@ The above copyright notice and this permission notice shall be included in all c
33
32
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
33
  """
35
34
 
36
-
37
35
  """
38
36
  This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
39
37
 
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,
@@ -703,7 +716,7 @@ async function resolveTargetVersion(packageInfo, registry) {
703
716
  throw new Error(`Unable to resolve "${packageInfo.name}"`);
704
717
  }
705
718
  const { repository } = await latestMetadata.json();
706
- const branch = "main";
719
+ const branch = bump === "premajor" ? "next" : "main";
707
720
  packageInfo.changelogURL = extractChangelogURLFromRepository(repository, version, branch);
708
721
  packageInfo.changelogTitle = "CHANGELOG";
709
722
  } else {
@@ -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.1.2",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",