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:
parent
0dc99c9a28
commit
54e57fe9d7
5 changed files with 40 additions and 960 deletions
5
.changeset/chilly-sloths-move.md
Normal file
5
.changeset/chilly-sloths-move.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/upgrade': patch
|
||||
---
|
||||
|
||||
Fix unhandled error when running `@astrojs/upgrade beta` outside of a monorepo
|
|
@ -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) {
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"name": "@test/astro-upgrade-basic",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "1.0.0"
|
||||
}
|
||||
}
|
|
@ -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
962
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue