-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(repair): add migration to remove unused "lerna" field from lerna…
….json (#3734)
- Loading branch information
1 parent
e6c7427
commit 4fb0427
Showing
4 changed files
with
56 additions
and
0 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
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
37 changes: 37 additions & 0 deletions
37
...ages/lerna/src/migrations/remove-invalid-lerna-config/remove-invalid-lerna-config.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { readJson, Tree, writeJson } from "@nx/devkit"; | ||
import { createTreeWithEmptyWorkspace } from "@nx/devkit/testing"; | ||
import removeInvalidConfigMigration from "./remove-invalid-lerna-config"; | ||
|
||
describe("remove-invalid-lerna-config", () => { | ||
let tree: Tree; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(); | ||
}); | ||
|
||
it(`should remove "lerna" config if present`, async () => { | ||
writeJson(tree, "lerna.json", { | ||
lerna: "2.0.0-rc.5", | ||
}); | ||
await removeInvalidConfigMigration(tree); | ||
expect(readJson(tree, "lerna.json")).toMatchInlineSnapshot(`Object {}`); | ||
}); | ||
|
||
it(`should not not modify the file if no "lerna" config is present`, async () => { | ||
writeJson(tree, "lerna.json", { | ||
something: false, | ||
somethingElse: { | ||
nested: "value", | ||
}, | ||
}); | ||
await removeInvalidConfigMigration(tree); | ||
expect(readJson(tree, "lerna.json")).toMatchInlineSnapshot(` | ||
Object { | ||
"something": false, | ||
"somethingElse": Object { | ||
"nested": "value", | ||
}, | ||
} | ||
`); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/lerna/src/migrations/remove-invalid-lerna-config/remove-invalid-lerna-config.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { formatFiles, readJson, Tree, writeJson } from "@nx/devkit"; | ||
|
||
export default async function generator(tree: Tree) { | ||
const lernaJson = readJson(tree, "lerna.json"); | ||
|
||
if (lernaJson.lerna !== undefined) { | ||
delete lernaJson.lerna; | ||
writeJson(tree, "lerna.json", lernaJson); | ||
} | ||
|
||
await formatFiles(tree); | ||
} |