-
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.
Fix package.json updates during publish (#744)
Object.prototype.toJSON() is normally called when passed to JSON.stringify(), but write-pkg iterates Object.keys() before serializing so it has to be explicitly called here (otherwise it mangles the instance properties). This also adds universal interpolation of __TEST_VERSION__ inside fixture JSON files with the current version being tested. This is necessary for the new lerna-publish integration test, and is nice to have for all unit tests anyway. Fixes #741
- Loading branch information
Showing
16 changed files
with
257 additions
and
74 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"lerna": "2.0.0-beta.38", | ||
"lerna": "__TEST_VERSION__", | ||
"packages": [ | ||
"package-*" | ||
], | ||
|
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,15 @@ | ||
// this file is not transpiled by Jest when required in replaceLernaVersion.js | ||
"use strict"; | ||
|
||
const path = require("path"); | ||
const pkg = require("../../package.json"); | ||
|
||
/** | ||
Shared constants for tests | ||
**/ | ||
exports.REPO_ROOT = path.resolve(__dirname, "../.."); | ||
exports.LERNA_BIN = path.resolve(exports.REPO_ROOT, pkg.bin.lerna); | ||
exports.LERNA_VERSION = pkg.version; | ||
|
||
// placeholder used in fixture JSON files, replaced during tests | ||
exports.__TEST_VERSION__ = "__TEST_VERSION__"; |
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
100 changes: 100 additions & 0 deletions
100
test/integration/__snapshots__/lerna-publish.test.js.snap
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,100 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`packages: updates fixed versions 1`] = ` | ||
Array [ | ||
Object { | ||
"name": "package-1", | ||
"version": "1.0.1", | ||
}, | ||
Object { | ||
"dependencies": Object { | ||
"package-1": "^1.0.1", | ||
}, | ||
"name": "package-2", | ||
"version": "1.0.1", | ||
}, | ||
Object { | ||
"devDependencies": Object { | ||
"package-2": "^1.0.1", | ||
}, | ||
"name": "package-3", | ||
"version": "1.0.1", | ||
}, | ||
Object { | ||
"dependencies": Object { | ||
"package-1": "^0.0.0", | ||
}, | ||
"name": "package-4", | ||
"version": "1.0.1", | ||
}, | ||
Object { | ||
"dependencies": Object { | ||
"package-1": "^1.0.1", | ||
}, | ||
"name": "package-5", | ||
"private": true, | ||
"version": "1.0.1", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`packages: updates independent versions 1`] = ` | ||
Array [ | ||
Object { | ||
"name": "package-1", | ||
"version": "2.0.0", | ||
}, | ||
Object { | ||
"dependencies": Object { | ||
"package-1": "^2.0.0", | ||
}, | ||
"name": "package-2", | ||
"version": "3.0.0", | ||
}, | ||
Object { | ||
"devDependencies": Object { | ||
"package-2": "^3.0.0", | ||
}, | ||
"name": "package-3", | ||
"version": "4.0.0", | ||
}, | ||
Object { | ||
"dependencies": Object { | ||
"package-1": "^0.0.0", | ||
}, | ||
"name": "package-4", | ||
"version": "5.0.0", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`stdout: updates fixed versions 1`] = ` | ||
"Lerna __TEST_VERSION__ | ||
Current version: 1.0.0 | ||
Checking for updated packages... | ||
No tags found! Comparing with initial commit. | ||
Changes: | ||
- package-1: 1.0.0 => 1.0.1 | ||
- package-2: 1.0.0 => 1.0.1 | ||
- package-3: 1.0.0 => 1.0.1 | ||
- package-4: 1.0.0 => 1.0.1 | ||
- package-5: 1.0.0 => 1.0.1 (private) | ||
Assuming confirmation." | ||
`; | ||
|
||
exports[`stdout: updates independent versions 1`] = ` | ||
"Lerna __TEST_VERSION__ | ||
Independent Versioning Mode | ||
Checking for updated packages... | ||
No tags found! Comparing with initial commit. | ||
Changes: | ||
- package-1: 1.0.0 => 2.0.0 | ||
- package-2: 2.0.0 => 3.0.0 | ||
- package-3: 3.0.0 => 4.0.0 | ||
- package-4: 4.0.0 => 5.0.0 | ||
Assuming confirmation." | ||
`; |
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
Oops, something went wrong.