Compare commits

...

8 Commits

Author SHA1 Message Date
Adam Stankiewicz
51c9c9af6d Merge branch 'master' into fix-resolutions-save 2018-03-28 18:09:14 +02:00
Adam Stankiewicz
d6a18ae7ee Revert "Update request version in bower-registry-client #2336"
This reverts commit 1e2c27f338.
2018-03-28 18:09:01 +02:00
Adam Stankiewicz
b62faa19a6 Update request version in bower-registry-client #2336 2018-03-28 18:09:01 +02:00
Adam Stankiewicz
50ee729ea2 Allow to disable shorthand resolver (#2507) 2018-03-28 17:58:56 +02:00
Adam Stankiewicz
bb17839bc2 Allow shallow cloning when source is a ssh protocol (#2506) 2018-03-28 17:37:34 +02:00
Michael Lee
5a6ae540f9 Adding support for Arrays in Environment Variable replacement (#2411) 2018-03-28 17:05:13 +02:00
Adam Stankiewicz
9eaa7e8c7b Do not store resolutions if --save is not used, fixes #2344 2018-03-28 16:47:44 +02:00
Max Schaefer
1935716660 Fix issues found by lgtm (#2493) 2018-03-28 15:51:53 +02:00
9 changed files with 51 additions and 13 deletions

View File

@@ -16,7 +16,7 @@ function lookup(logger, name, config) {
.then(function (entry) {
return !entry ? null : {
name: name,
url: entry && entry.url
url: entry.url
};
});
}

View File

@@ -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',

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 === '*') {

View File

@@ -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);
}

View File

@@ -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}"
}

View File

@@ -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);
});
});

View File

@@ -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';