forked from atom/apm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow installing old versions not listed in the package info
Fixes atom#733 Rather than relying only on the JSON returned for the package, we now fall back to the `GET /api/packages/:package_name/versions/:version_name` endpoint if necessary, and use the tarball URL from there if we find one. Since I changed the code to use `version` to mean a version JSON object, I renamed `packageVersion` to `versionName` in a few places to be more clear. I also rely on `version.version` containing the version name, which required updating some test fixtures. This also adds tests for installing old versions in general and producing the expected error message if a version isn't found.
- Loading branch information
1 parent
478f7be
commit 1b3a97c
Showing
14 changed files
with
164 additions
and
57 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,6 @@ | ||
{ | ||
"dist": { | ||
"tarball": "http://localhost:3000/tarball/test-module-0.2.0.tgz" | ||
}, | ||
"version": "0.2.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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
|
@@ -37,12 +37,20 @@ describe 'apm install', -> | |
response.sendfile path.join(__dirname, 'fixtures', 'node_x64.lib') | ||
app.get '/node/v0.10.3/SHASUMS256.txt', (request, response) -> | ||
response.sendfile path.join(__dirname, 'fixtures', 'SHASUMS256.txt') | ||
app.get '/tarball/test-module-0.2.0.tgz', (request, response) -> | ||
response.sendfile path.join(__dirname, 'fixtures', 'test-module-0.2.0.tgz') | ||
app.get '/tarball/test-module-0.3.0.tgz', (request, response) -> | ||
response.sendfile path.join(__dirname, 'fixtures', 'test-module-0.3.0.tgz') | ||
app.get '/tarball/test-module-0.4.0.tgz', (request, response) -> | ||
response.sendfile path.join(__dirname, 'fixtures', 'test-module-0.4.0.tgz') | ||
app.get '/tarball/test-module-1.0.0.tgz', (request, response) -> | ||
response.sendfile path.join(__dirname, 'fixtures', 'test-module-1.0.0.tgz') | ||
app.get '/tarball/test-module2-2.0.0.tgz', (request, response) -> | ||
response.sendfile path.join(__dirname, 'fixtures', 'test-module2-2.0.0.tgz') | ||
app.get '/packages/test-module', (request, response) -> | ||
response.sendfile path.join(__dirname, 'fixtures', 'install-test-module.json') | ||
app.get '/packages/test-module/versions/0.2.0', (request, response) -> | ||
response.sendfile path.join(__dirname, 'fixtures', 'install-test-module-version-0.2.0.json') | ||
app.get '/packages/test-module2', (request, response) -> | ||
response.sendfile path.join(__dirname, 'fixtures', 'install-test-module2.json') | ||
app.get '/packages/test-rename', (request, response) -> | ||
|
@@ -201,6 +209,43 @@ describe 'apm install', -> | |
expect(fs.existsSync(path.join(testModuleDirectory, 'package.json'))).toBeTruthy() | ||
expect(callback.mostRecentCall.args[0]).toBeNull() | ||
|
||
describe 'when an explicit version is specified', -> | ||
it 'installs the version', -> | ||
testModuleDirectory = path.join(atomHome, 'packages', 'test-module') | ||
|
||
callback = jasmine.createSpy('callback') | ||
apm.run(['install', "[email protected]"], callback) | ||
|
||
waitsFor 'waiting for install to complete', 600000, -> | ||
callback.callCount is 1 | ||
|
||
runs -> | ||
expect(callback.mostRecentCall.args[0]).toBeNull() | ||
expect(JSON.parse(fs.readFileSync(path.join(testModuleDirectory, 'package.json'))).version).toBe "0.3.0" | ||
|
||
it 'allows installing versions not in the package JSON', -> | ||
testModuleDirectory = path.join(atomHome, 'packages', 'test-module') | ||
|
||
callback = jasmine.createSpy('callback') | ||
apm.run(['install', "[email protected]"], callback) | ||
|
||
waitsFor 'waiting for install to complete', 600000, -> | ||
callback.callCount is 1 | ||
|
||
runs -> | ||
expect(callback.mostRecentCall.args[0]).toBeNull() | ||
expect(JSON.parse(fs.readFileSync(path.join(testModuleDirectory, 'package.json'))).version).toBe "0.2.0" | ||
|
||
it 'gives an error when installing a nonexistent version', -> | ||
callback = jasmine.createSpy('callback') | ||
apm.run(['install', "[email protected]"], callback) | ||
|
||
waitsFor 'waiting for install to complete', 600000, -> | ||
callback.callCount is 1 | ||
|
||
runs -> | ||
expect(callback.mostRecentCall.args[0]).toBe 'Package version: 0.1.0 not found' | ||
|
||
describe 'when multiple package names are specified', -> | ||
it 'installs all packages', -> | ||
testModuleDirectory = path.join(atomHome, 'packages', 'test-module') | ||
|
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