Skip to content

Commit

Permalink
fix(upgrade): Remove semver parse (#9213)
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored Nov 28, 2023
1 parent 0dc99c9 commit 54e57fe
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 968 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-sloths-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/upgrade': patch
---

Fix unhandled error when running `@astrojs/upgrade beta` outside of a monorepo
5 changes: 2 additions & 3 deletions packages/upgrade/src/messages.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint no-console: 'off' */
import { color, label, spinner as load } from '@astrojs/cli-kit';
import { align } from '@astrojs/cli-kit/utils';
import semverParse from 'semver/functions/parse.js';
import terminalLink from 'terminal-link';
import detectPackageManager from 'which-pm-runs';
import type { PackageInfo } from './actions/context.js';
Expand Down Expand Up @@ -110,8 +109,8 @@ export const upgrade = async (packageInfo: PackageInfo, text: string) => {
const bg = isMajor ? (v: string) => color.bgYellow(color.black(` ${v} `)) : color.green;
const style = isMajor ? color.yellow : color.green;
const symbol = isMajor ? '▲' : '●';
const toVersion = semverParse(targetVersion)!;
const version = `v${toVersion.version}`;
const toVersion = targetVersion.replace(/^\D+/, '');
const version = `v${toVersion}`;

const length = 12 + name.length + text.length + version.length;
if (length > stdout.columns) {
Expand Down
7 changes: 0 additions & 7 deletions packages/upgrade/test/fixtures/basic/package.json

This file was deleted.

21 changes: 0 additions & 21 deletions packages/upgrade/test/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fs from 'node:fs';
import { setStdout } from '../dist/index.js';
import stripAnsi from 'strip-ansi';

Expand Down Expand Up @@ -30,23 +29,3 @@ export function setup() {
},
};
}

const resetBasicFixture = async () => {
const packagePath = new URL('./fixtures/basic/package.json', import.meta.url);
const packageJsonData = JSON.parse(
await fs.promises.readFile(packagePath, { encoding: 'utf-8' })
);
const overriddenPackageJson = Object.assign(packageJsonData, {
dependencies: {
astro: '1.0.0',
},
});

return Promise.all([
fs.promises.writeFile(packagePath, JSON.stringify(overriddenPackageJson, null, 2), {
encoding: 'utf-8',
}),
]);
};

export const resetFixtures = () => Promise.allSettled([resetBasicFixture()]);
Loading

0 comments on commit 54e57fe

Please sign in to comment.