mirror of
https://github.com/bower/bower.git
synced 2026-04-24 03:00:19 -04:00
Compare commits
8 Commits
shallow-ss
...
fix-resolu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51c9c9af6d | ||
|
|
d6a18ae7ee | ||
|
|
b62faa19a6 | ||
|
|
50ee729ea2 | ||
|
|
bb17839bc2 | ||
|
|
5a6ae540f9 | ||
|
|
9eaa7e8c7b | ||
|
|
1935716660 |
@@ -16,7 +16,7 @@ function lookup(logger, name, config) {
|
||||
.then(function (entry) {
|
||||
return !entry ? null : {
|
||||
name: name,
|
||||
url: entry && entry.url
|
||||
url: entry.url
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -687,7 +687,6 @@ Manager.prototype._electSuitable = function (name, semvers, nonSemvers) {
|
||||
var unresolvable;
|
||||
var dataPicks;
|
||||
var save;
|
||||
var choices;
|
||||
var picks = [];
|
||||
var versionRegex = /(?:[\d\w]\.){2}[\d\w](?:.)*/;
|
||||
var picksReleases;
|
||||
@@ -826,7 +825,9 @@ Manager.prototype._electSuitable = function (name, semvers, nonSemvers) {
|
||||
});
|
||||
|
||||
// Save resolution
|
||||
this._storeResolution(picks[suitable]);
|
||||
if (this._config.argv.cooked.includes('--save')) {
|
||||
this._storeResolution(picks[suitable]);
|
||||
}
|
||||
|
||||
return Q.resolve(picks[suitable]);
|
||||
}
|
||||
@@ -845,7 +846,6 @@ Manager.prototype._electSuitable = function (name, semvers, nonSemvers) {
|
||||
picks: dataPicks
|
||||
});
|
||||
|
||||
choices = picks.map(function (pick, index) { return index + 1; });
|
||||
picksReleases = picks.map(function (pick) { return pick.pkgMeta._release; });
|
||||
return Q.nfcall(this._logger.prompt.bind(this._logger), {
|
||||
type: 'input',
|
||||
|
||||
@@ -176,6 +176,12 @@ function getConstructor(decEndpoint, options, registryClient) {
|
||||
|
||||
// Check if is a shorthand and expand it
|
||||
addResolver(function () {
|
||||
|
||||
// Check if the shorthandResolver is falsy
|
||||
if (!config.shorthandResolver) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip ssh and/or URL with auth
|
||||
if (/[:@]/.test(source)) {
|
||||
return;
|
||||
|
||||
@@ -19,14 +19,14 @@ function GitRemoteResolver(decEndpoint, config, logger) {
|
||||
this._name = this._name.slice(0, -4);
|
||||
}
|
||||
|
||||
// Get the host of this source
|
||||
// Get the remote of this source
|
||||
if (!/:\/\//.test(this._source)) {
|
||||
this._host = url.parse('ssh://' + this._source).host;
|
||||
this._remote = url.parse('ssh://' + this._source);
|
||||
} else {
|
||||
this._host = url.parse(this._source).host;
|
||||
this._remote = url.parse(this._source);
|
||||
}
|
||||
|
||||
this._remote = url.parse(this._source);
|
||||
|
||||
this._host = this._remote.host;
|
||||
|
||||
// Verify whether the server supports shallow cloning
|
||||
this._shallowClone = this._supportsShallowCloning;
|
||||
|
||||
@@ -121,8 +121,6 @@ GitResolver.prototype._findResolution = function (target) {
|
||||
version,
|
||||
index;
|
||||
|
||||
versionsArr = versions.map(function (obj) { return obj.version; });
|
||||
|
||||
// If there are no tags and target is *,
|
||||
// fallback to the latest commit on master
|
||||
if (!versions.length && target === '*') {
|
||||
|
||||
@@ -43,6 +43,9 @@ function doEnvReplaceStr (f) {
|
||||
|
||||
function envReplace(config) {
|
||||
var envReplaced = {};
|
||||
if ( lang.isArray(config) ) {
|
||||
envReplaced = [];
|
||||
}
|
||||
|
||||
object.forOwn(config, function (value, key) {
|
||||
|
||||
@@ -63,6 +66,9 @@ function envReplace(config) {
|
||||
if ( lang.isPlainObject(value) ) {
|
||||
envReplaced[key] = envReplace(value);
|
||||
}
|
||||
else if ( lang.isArray(value) ) {
|
||||
envReplaced[key] = envReplace(value);
|
||||
}
|
||||
else if ( lang.isString(value) ) {
|
||||
envReplaced[key] = doEnvReplaceStr(value);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,12 @@
|
||||
},
|
||||
"storage" : {
|
||||
"packages" : "${_BOWERRC_MY_PACKAGES}",
|
||||
"registry" : "~/.bower-test/registry"
|
||||
"registry" : {
|
||||
"register": "~/.bower-test/registry",
|
||||
"search": [
|
||||
"${_BOWERRC_MY_USER}:${_BOWERRC_MY_PASS}"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tmp" : "${_BOWERRC_MY_TMP}"
|
||||
}
|
||||
|
||||
@@ -224,10 +224,13 @@ describe('Allow ${ENV} variables in .bowerrc', function() {
|
||||
it('sets values from process.env', function() {
|
||||
process.env._BOWERRC_MY_PACKAGES = 'a';
|
||||
process.env._BOWERRC_MY_TMP = '/tmp/b';
|
||||
process.env._BOWERRC_MY_USER = 'username';
|
||||
process.env._BOWERRC_MY_PASS = 'password';
|
||||
|
||||
var config = require('../lib/Config').read('test/assets/env-variables-values');
|
||||
assert.equal('a', config.storage.packages);
|
||||
assert.equal('/tmp/b', config.tmp);
|
||||
assert.equal('username:password', config.storage.registry.search[0]);
|
||||
assert.equal('${_myshellvar}', config.scripts.postinstall);
|
||||
});
|
||||
});
|
||||
@@ -238,7 +241,7 @@ describe('untildify paths in .bowerrc', function() {
|
||||
var config = require('../lib/Config').read('test/assets/env-variables-values');
|
||||
var untildify = require('untildify');
|
||||
|
||||
assert.equal(untildify('~/.bower-test/registry') , config.storage.registry);
|
||||
assert.equal(untildify('~/.bower-test/registry') , config.storage.registry.register);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -356,6 +356,26 @@ describe('GitRemoteResolver', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should evaluate to true when source is a ssh protocol and host is defined to support shallow cloning', function (next) {
|
||||
var testSource = 'git@foo:bar.git';
|
||||
|
||||
var MyGitRemoteResolver = gitRemoteResolverFactory(
|
||||
createCmdHandlerFn(testSource, multiline(function () {/*
|
||||
foo: bar
|
||||
Content-Type: application/x-git-upload-pack-advertisement
|
||||
1234: 5678
|
||||
*/}))
|
||||
);
|
||||
|
||||
var resolver = new MyGitRemoteResolver({ source: testSource }, defaultConfig({ shallowCloneHosts: ['foo'] }), logger);
|
||||
|
||||
resolver._shallowClone().then(function (shallowCloningSupported) {
|
||||
expect(shallowCloningSupported).to.be(true);
|
||||
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
it('should cache hosts that support shallow cloning', function (next) {
|
||||
var testSource = 'https://foo/bar.git';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user