0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-17 22:44:24 -05:00

fix(upgrade): Remove semver parse (#9213)

This commit is contained in:
Nate Moore 2023-11-28 15:20:16 -06:00 committed by GitHub
parent 0dc99c9a28
commit 54e57fe9d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 960 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/upgrade': patch
---
Fix unhandled error when running `@astrojs/upgrade beta` outside of a monorepo

View file

@ -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';
@ -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) {

View file

@ -1,7 +0,0 @@
{
"name": "@test/astro-upgrade-basic",
"private": true,
"dependencies": {
"astro": "1.0.0"
}
}

View file

@ -1,4 +1,3 @@
import fs from 'node:fs';
import { setStdout } from '../dist/index.js';
import stripAnsi from 'strip-ansi';
@ -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()]);

962
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff