-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from Anifacted/lazy-flag
Add `lazy` flag
- Loading branch information
Showing
6 changed files
with
234 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { format } = require("prettier-package-json"); | ||
const merge = require("lodash/merge"); | ||
|
||
module.exports = (basePackageJson, modificationsBlob) => { | ||
const merged = merge(basePackageJson, modificationsBlob); | ||
return format(merged); | ||
}; |
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,81 @@ | ||
const expect = require("unexpected"); | ||
const modifyPackageJson = require("./modifyPackageJson"); | ||
|
||
const baseJson = JSON.parse(`{ | ||
"name": "lerna-update-wizard", | ||
"bin": { | ||
"lernaupdate": "./bin/lernaupdate" | ||
}, | ||
"version": "0.12.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Anifacted/lerna-update-wizard" | ||
}, | ||
"dependencies": { | ||
"chalk": "^2.3.0", | ||
"semver-compare": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
}, | ||
"scripts": { | ||
"test": "jest --verbose --runInBand" | ||
}, | ||
"jest": { | ||
"testURL": "http://localhost" | ||
} | ||
}`); | ||
|
||
describe("modifyPackageJson", () => { | ||
it("should work", () => { | ||
const mods = { | ||
dependencies: { | ||
d3: "3", | ||
}, | ||
devDependencies: { | ||
lodash: "3", | ||
}, | ||
peerDependencies: { | ||
underscore: "~2", | ||
}, | ||
}; | ||
|
||
expect( | ||
modifyPackageJson, | ||
"when called with", | ||
[baseJson, mods], | ||
"to equal", | ||
`{ | ||
"name": "lerna-update-wizard", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Anifacted/lerna-update-wizard" | ||
}, | ||
"version": "0.12.0", | ||
"main": "index.js", | ||
"bin": { | ||
"lernaupdate": "./bin/lernaupdate" | ||
}, | ||
"scripts": { | ||
"test": "jest --verbose --runInBand" | ||
}, | ||
"dependencies": { | ||
"chalk": "^2.3.0", | ||
"d3": "3", | ||
"semver-compare": "^1.0.0" | ||
}, | ||
"peerDependencies": { | ||
"underscore": "~2" | ||
}, | ||
"devDependencies": { | ||
"lodash": "3" | ||
}, | ||
"jest": { | ||
"testURL": "http://localhost" | ||
} | ||
}\n` | ||
); | ||
}); | ||
}); |
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,67 @@ | ||
const { default: runProgram } = require("./utils/runProgram"); | ||
const generateProject = require("./utils/generateProject"); | ||
|
||
describe("Lazy install dependency", async () => { | ||
describe("dep is not installed in any of the packages", () => { | ||
it("lazily installs the dependency", async () => { | ||
// eslint-disable-next-line | ||
jest.setTimeout(100000); | ||
|
||
const projectPath = await generateProject({ | ||
name: "project-a", | ||
packages: [ | ||
{ name: "sub-package-a" }, | ||
{ | ||
name: "sub-package-b", | ||
dependencies: { lodash: "0.1.0" }, | ||
}, | ||
], | ||
}); | ||
|
||
await runProgram( | ||
`${projectPath} --lazy --dependency "treediff@latest"`, | ||
` | ||
Fetching package information for "treediff" | ||
>>> wait | ||
? Select packages to affect: (Press <space> to select, <a> to toggle all, <i> to | ||
invert selection) | ||
❯◯ sub-package-a | ||
◯ sub-package-b | ||
>>> input SPACE | ||
>>> input ENTER | ||
Resolving dependency version for "treediff@latest" | ||
>>> wait | ||
Using version ^0.2.5 ✓ | ||
>>> wait | ||
? Select dependency installation type for "sub-package-a" (Use arrow keys) | ||
❯ dependencies | ||
devDependencies | ||
>>> input ENTER | ||
project-a: npm install | ||
>>> wait | ||
? Do you want to create a new git branch for the change? (Y/n) | ||
>>> input n | ||
>>> input ENTER | ||
? Do you want to create a new git commit for the change? (Y/n) | ||
>>> input n | ||
>>> input ENTER | ||
` | ||
); | ||
}); | ||
}); | ||
}); |