mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
64c3ea445b
If packages are being published to verdaccio as well as upstream to npmjs.org, then when the cache is updated from npmjs.org it uses the dist-tags from the upstream even if the locally published version is actually newer. This makes it very difficult to use verdaccio as a staging registry for testing out potential releases. This change partially reverts a change in behaviour that was introduced in #8 which caused a regression for the staging style workflow that was supported by sinopia.
61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
let assert = require('assert');
|
|
let semver_sort = require('../../lib/utils').semver_sort;
|
|
let merge = require('../../lib/storage')._merge_versions;
|
|
|
|
require('../../lib/logger').setup([]);
|
|
|
|
describe('Merge', function() {
|
|
it('simple', function() {
|
|
let x = {
|
|
'versions': {a: 1, b: 1, c: 1},
|
|
'dist-tags': {},
|
|
};
|
|
merge(x, {versions: {a: 2, q: 2}});
|
|
assert.deepEqual(x, {
|
|
'versions': {a: 1, b: 1, c: 1, q: 2},
|
|
'dist-tags': {},
|
|
});
|
|
});
|
|
|
|
it('dist-tags - compat', function() {
|
|
let x = {
|
|
'versions': {},
|
|
'dist-tags': {q: '1.1.1', w: '2.2.2'},
|
|
};
|
|
merge(x, {'dist-tags': {q: '2.2.2', w: '3.3.3', t: '4.4.4'}});
|
|
assert.deepEqual(x, {
|
|
'versions': {},
|
|
'dist-tags': {q: '2.2.2', w: '3.3.3', t: '4.4.4'},
|
|
});
|
|
});
|
|
|
|
it('dist-tags - staging', function() {
|
|
let x = {
|
|
versions: {},
|
|
// we've been locally publishing 1.1.x in preparation for the next
|
|
// public release
|
|
'dist-tags': {q:'1.1.10',w:'2.2.2'},
|
|
}
|
|
// 1.1.2 is the latest public release, but we want to continue testing
|
|
// against our local 1.1.10, which may end up published as 1.1.3 in the
|
|
// future
|
|
merge(x, {'dist-tags':{q:'1.1.2',w:'3.3.3',t:'4.4.4'}})
|
|
assert.deepEqual(x, {
|
|
versions: {},
|
|
'dist-tags': {q:'1.1.10',w:'3.3.3',t:'4.4.4'},
|
|
});
|
|
});
|
|
|
|
it('semver_sort', function() {
|
|
assert.deepEqual(semver_sort(['1.2.3', '1.2', '1.2.3a', '1.2.3c', '1.2.3-b']),
|
|
['1.2.3a',
|
|
'1.2.3-b',
|
|
'1.2.3c',
|
|
'1.2.3']
|
|
);
|
|
});
|
|
});
|
|
|