-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support mapping package version to other
--package-version-mapping-file={mapping.json} format: ```json { "pedding": { "1.0.0": { "version": "1.1.0", "reason": "Security problem on 1.0.0" } } } ```
- Loading branch information
Showing
5 changed files
with
121 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
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 @@ | ||
{ | ||
"name": "package-version-mapping-file", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"pedding": "1.0.0" | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"pedding": { | ||
"1.0.0": { "version": "1.1.0", "reason": "Security problem on 1.0.0" } | ||
} | ||
} |
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,86 @@ | ||
'use strict'; | ||
|
||
const coffee = require('coffee'); | ||
const rimraf = require('rimraf'); | ||
const mkdirp = require('mkdirp'); | ||
const path = require('path'); | ||
|
||
describe('package-version-mapping-file.test.js', () => { | ||
const tmp = path.join(__dirname, 'fixtures', 'tmp'); | ||
const demo = path.join(__dirname, 'fixtures', 'package-version-mapping-file-app'); | ||
const mappingFile = path.join(__dirname, 'fixtures', 'package-version-mapping.json'); | ||
const bin = path.join(__dirname, '../bin/install.js'); | ||
const update = path.join(__dirname, '../bin/update.js'); | ||
|
||
function cleanup() { | ||
rimraf.sync(tmp); | ||
rimraf.sync(path.join(demo, 'node_modules')); | ||
} | ||
|
||
beforeEach(() => { | ||
cleanup(); | ||
mkdirp.sync(tmp); | ||
}); | ||
afterEach(cleanup); | ||
|
||
it('should use 1.1.0 instead of 1.0.0', done => { | ||
coffee.fork(bin, [ | ||
'pedding@1.0.0', | ||
'--package-version-mapping-file=' + mappingFile, | ||
'-d', | ||
'--no-cache', | ||
], { cwd: tmp }) | ||
.debug() | ||
.expect('code', 0) | ||
.expect('stdout', /pedding@1\.1\.0@pedding/) | ||
.end(done); | ||
}); | ||
|
||
it('should support on install and update', function* () { | ||
yield coffee.fork(bin, [ | ||
'--package-version-mapping-file=' + mappingFile, | ||
'-d', | ||
'--no-cache', | ||
], { cwd: demo }) | ||
.debug() | ||
.expect('code', 0) | ||
.expect('stdout', /pedding@1\.1\.0@pedding/) | ||
.end(); | ||
|
||
yield coffee.fork(update, [ | ||
'--package-version-mapping-file=' + mappingFile, | ||
'-d', | ||
'--no-cache', | ||
], { cwd: demo }) | ||
.debug() | ||
.expect('code', 0) | ||
.expect('stdout', /pedding@1\.1\.0@pedding/) | ||
.end(); | ||
}); | ||
|
||
it('should not match version', done => { | ||
coffee.fork(bin, [ | ||
'pedding@0.0.1', | ||
'--package-version-mapping-file=' + mappingFile, | ||
'-d', | ||
'--no-cache', | ||
], { cwd: tmp }) | ||
.debug() | ||
.expect('code', 0) | ||
.expect('stdout', /pedding@0\.0\.1@pedding/) | ||
.end(done); | ||
}); | ||
|
||
it('should not match name', done => { | ||
coffee.fork(bin, [ | ||
'mm', | ||
'--package-version-mapping-file=' + mappingFile, | ||
'-d', | ||
'--no-cache', | ||
], { cwd: tmp }) | ||
.debug() | ||
.expect('code', 0) | ||
.expect('stdout', /mm@\* installed/) | ||
.end(done); | ||
}); | ||
}); |