-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
skuba migrate node 22 #1735
base: main
Are you sure you want to change the base?
skuba migrate node 22 #1735
Conversation
|
src/cli/migrate/nodeVersion/index.ts
Outdated
'dist-tags': Record<string, string>; | ||
}; | ||
|
||
export const getLatestNodeTypes = async (): Promise<VersionResult> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm we might not want the latest latest, because Node releases odd number versions as unstable so there may be Node 23 types coming soon. If possible we want to get the latest version 22 types
src/cli/migrate/nodeVersion/index.ts
Outdated
try { | ||
const fetchResponse = await fetch(url, { headers }); | ||
const jsonResponse = (await fetchResponse.json()) as RegistryResponse; | ||
const latestNode22 = jsonResponse['dist-tags'].node22; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does a node22 dist tag exist..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it turns out... no 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swapped it for your suggestion of
npm show @types/node@^22 version --json
export const getNode22TypesVersion = () => | ||
execSync("npm show @types/node@^22 version --json | jq '.[-1]'").toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could generalise a bit:
export const getNode22TypesVersion = () => | |
execSync("npm show @types/node@^22 version --json | jq '.[-1]'").toString(); | |
export const getNodeTypesVersionForMajor = (major: number) => | |
execSync(`npm show @types/node@^${major} version --json | jq '.[-1]'`).toString(); |
src/cli/migrate/index.ts
Outdated
@@ -3,7 +3,7 @@ import { log } from '../../utils/logging'; | |||
import { nodeVersionMigration } from './nodeVersion'; | |||
|
|||
const migrations: Record<string, () => Promise<void>> = { | |||
node20: () => nodeVersionMigration(20), | |||
node22: () => nodeVersionMigration(22), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it could be fine to keep 20 around just for purposes of people doing a 2-step upgrade? 🤷 maybe not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel we need to test how this behaves in a file structure, would the best way to do this be by utilising memfs
?
src/cli/migrate/nodeVersion/index.ts
Outdated
{ | ||
id: 'package-json-2', | ||
files: '**/package.json', | ||
test: /("engines":\s*{[^}]*"node":\s*">=)(\d+)("[^}]*})(?![^}]*"skuba":\s*{[^}]*"type":\s*"package")/gm, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regex is doing what checkSkubaType()
does, thoughts on keeping both or just using the function?
Resolves #1549