-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
skuba migrate
command to upgrade projects to Node.js 20 (#1382)
* Automatically upgrade projects to Node.js 20 * Also patch CDK * Update .changeset/real-oranges-rescue.md * Workshop changelog * Update .changeset/real-oranges-rescue.md * Run `skuba format` * Move code around * Move to a skuba migrate command * Add doc * Revert template changes * Wrangle types * Patch inline docker images too * Changeset * Go for node20 but keep the code reusable for later --------- Co-authored-by: skuba <[email protected]>
- Loading branch information
1 parent
97a84fd
commit 8fb2d8f
Showing
26 changed files
with
373 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
'skuba': minor | ||
--- | ||
|
||
migrate: Introduce `skuba migrate node20` to automatically upgrade a project's Node.js version | ||
|
||
`skuba migrate node20` will attempt to automatically upgrade projects to Node.js 20. | ||
It will look in the project root for Dockerfiles, `.nvmrc`, and Serverless files, | ||
as well as CDK files in `infra/` and `.buildkite/` files, and try to upgrade them to a Node.js 20 version. | ||
|
||
skuba might not be able to upgrade all projects, so please check your project for any files that skuba missed. It's | ||
possible that skuba will modify a file incorrectly, in which case please | ||
[open an issue](https://github.com/seek-oss/skuba/issues/new). | ||
|
||
Node.js 20 comes with its own breaking changes, so please read the [Node.js 20 release notes](https://nodejs.org/en/blog/announcements/v20-release-announce) alongside the skuba release notes. In addition, | ||
|
||
- For AWS Lambda runtime updates to `nodejs20.x`, consider reading the [release announcement](https://aws.amazon.com/blogs/compute/node-js-20-x-runtime-now-available-in-aws-lambda/) as there are some breaking changes with this upgrade. | ||
- You may need to upgrade your versions of CDK and Serverless as appropriate to support nodejs20.x. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
parent: CLI | ||
nav_order: 7 | ||
nav_order: 8 | ||
--- | ||
|
||
# Help | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
parent: CLI | ||
nav_order: 7 | ||
--- | ||
|
||
# Migrate | ||
|
||
--- | ||
|
||
## skuba migrate help | ||
|
||
Echoes the available **skuba** migrations | ||
|
||
```shell | ||
skuba migrate help | ||
``` | ||
|
||
--- | ||
|
||
## skuba migrate node20 | ||
|
||
`skuba migrate node20` will attempt to automatically upgrade projects to Node.js 20. | ||
It will look in the project root for Dockerfiles, `.nvmrc`, and Serverless files, | ||
as well as CDK files in `infra/` and `.buildkite/` files, and try to upgrade them to a Node.js 20 version. | ||
|
||
**skuba** might not be able to upgrade all projects, so please check your project for any files that **skuba** missed. It's | ||
possible that **skuba** will modify a file incorrectly, in which case please | ||
[open an issue](https://github.com/seek-oss/skuba/issues/new). | ||
|
||
Node.js 20 comes with its own breaking changes, so please read the [Node.js 20 release notes](https://nodejs.org/en/blog/announcements/v20-release-announce) alongside the skuba release notes. In addition, | ||
|
||
- For AWS Lambda runtime updates to `nodejs20.x`, consider reading the [release announcement](https://aws.amazon.com/blogs/compute/node-js-20-x-runtime-now-available-in-aws-lambda/) as there are some breaking changes with this upgrade. | ||
- You may need to upgrade your versions of CDK and Serverless as appropriate to support nodejs20.x. | ||
|
||
```shell | ||
skuba migrate node20 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
src/cli/configure/upgrade/index.test.ts → .../lint/internalLints/upgrade/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ade/patches/7.3.1/addEmptyExports.test.ts → ...ade/patches/7.3.1/addEmptyExports.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...oveNpmrcOutOfIgnoreManagedSection.test.ts → ...oveNpmrcOutOfIgnoreManagedSection.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { log } from '../../utils/logging'; | ||
|
||
import { nodeVersionMigration } from './nodeVersion'; | ||
|
||
const migrations: Record<string, () => Promise<void>> = { | ||
node20: () => nodeVersionMigration(20), | ||
}; | ||
|
||
const logAvailableMigrations = () => { | ||
log.ok('Available migrations:'); | ||
Object.keys(migrations).forEach((migration) => { | ||
log.ok(`- ${migration}`); | ||
}); | ||
}; | ||
|
||
export const migrate = async (args = process.argv.slice(2)) => { | ||
if (!args[0]) { | ||
log.err('Provide a migration to run.'); | ||
logAvailableMigrations(); | ||
process.exitCode = 1; | ||
return; | ||
} | ||
|
||
if (args.includes('--help') || args.includes('-h') || args[0] === 'help') { | ||
logAvailableMigrations(); | ||
return; | ||
} | ||
|
||
const migration = migrations[args[0]]; | ||
|
||
if (!migration) { | ||
log.err(`Migration "${args[0]}" is not a valid option.`); | ||
logAvailableMigrations(); | ||
process.exitCode = 1; | ||
return; | ||
} | ||
|
||
await migration(); | ||
}; |
Oops, something went wrong.