Skip to content

Commit

Permalink
Update @typespec/migrate to work with updated semver package (#2202)
Browse files Browse the repository at this point in the history
Fix #2195.
  • Loading branch information
tjprescott authored Jul 21, 2023
1 parent 7ac833a commit 8648c2e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@
"program": "${workspaceFolder}/packages/migrate/dist/src/cli.js",
"smartStep": true,
"sourceMaps": true,
"skipFiles": ["<node_internals>/**/*.js"],
"cwd": "C:/Github/Sandbox/playground/cadl/migrate/0.37"
"skipFiles": ["<node_internals>/**/*.js"]
},
{
"type": "node",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/migrate",
"comment": "Fix issue with latest semver package.",
"type": "none"
}
],
"packageName": "@typespec/migrate"
}
7 changes: 6 additions & 1 deletion packages/migrate/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ async function main() {
console.log(`Current Typespec version ${cliOptions.tspVersion}.`);
const stepKeys = Object.keys(migrationConfigurations);
for (const key of stepKeys) {
if (semver.gt(key, cliOptions.tspVersion)) {
const compKey = semver.coerce(key);
if (compKey === null) {
console.log(`Invalid migration step version; could not be coerced: ${key}`);
process.exit(1);
}
if (semver.gt(compKey, cliOptions.tspVersion)) {
console.log(
`Migration step found to upgrade from ${cliOptions.tspVersion} to ${key}. Migrating...`
);
Expand Down

0 comments on commit 8648c2e

Please sign in to comment.