Skip to content

Commit

Permalink
Hash recalculation is disabled
Browse files Browse the repository at this point in the history
It had caused more problems then it solved
  • Loading branch information
mutantcornholio committed Mar 14, 2018
1 parent 6d33ac1 commit a8ea425
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 114 deletions.
19 changes: 0 additions & 19 deletions lib/install/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,6 @@ function install({force = false, config, rePull = false, lockfile = null}) {

throw error;
})
.then(() => {
if (lockfile === null) {
return resolveLockfile().then(resolvedLockfile => lockfile = resolvedLockfile);
}
})
.then(() => {
if (lockfile === null) {
return;
}

return fsExtra.readFile(lockfile)
.then(lockfileBuf => {
newLockfileContents = JSON.parse(lockfileBuf.toString());
newPkgJsonHash = pkgJsonUtils.calcHash(newPkgJson, newLockfileContents, config.packageHash);

logger.info(`New hash is:\t${newPkgJsonHash}`);
})

})
.then(() => {
if (done) {
if (missingBackends.length > 0) {
Expand Down
10 changes: 2 additions & 8 deletions test/integration/testCases/gitPush/testcase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,8 @@ cd repolocal

npm_ver="$(npm --version)"

if [[ "$npm_ver" == 3* ]] || [[ "$npm_ver" == 4* ]]; then
git checkout veendor-7d0db335c82dfd9aa2b96dabc485b89ebaa1496f
tar -xf 7d0db335c82dfd9aa2b96dabc485b89ebaa1496f.tar.gz
else
git checkout veendor-1722dc5c5ee28cf0bcdc5ac1da82e0608b655f88
tar -xf 1722dc5c5ee28cf0bcdc5ac1da82e0608b655f88.tar.gz # package-lock.json is created during the run
# veendor should recalculate hash and push new one
fi
git checkout veendor-7d0db335c82dfd9aa2b96dabc485b89ebaa1496f
tar -xf 7d0db335c82dfd9aa2b96dabc485b89ebaa1496f.tar.gz

if [[ ! -f "node_modules/deep-object-diff/package.json" ]]; then
echo "gitPush failed; node_modules/deep-object-diff/package.json is not there"
Expand Down
7 changes: 1 addition & 6 deletions test/integration/testCases/localPush/testcase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ node "$rootdir/bin/veendor.js" install --debug
npm_ver="$(npm --version)"

cd "$(pwd)/local"
if [[ "$npm_ver" == 3* ]] || [[ "$npm_ver" == 4* ]]; then
tar -xf 7d0db335c82dfd9aa2b96dabc485b89ebaa1496f.tar.gz
else
tar -xf 1722dc5c5ee28cf0bcdc5ac1da82e0608b655f88.tar.gz # package-lock.json is created during the run
# veendor should recalculate hash and push new one
fi
tar -xf 7d0db335c82dfd9aa2b96dabc485b89ebaa1496f.tar.gz

if [[ ! -f "node_modules/deep-object-diff/package.json" ]]; then
echo "gitPush failed; node_modules/deep-object-diff/package.json is not there"
Expand Down
81 changes: 0 additions & 81 deletions test/unit/install/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1003,87 +1003,6 @@ describe('install', () => {

assert.isRejected(install({config}), errors.BundleAlreadyExistsError).notify(done);
});

it('should re-calc hash after npm install', done => {
// because npm install with lockfile will change the lockfile and we need to push with new hash
mockfs({
'package.json': JSON.stringify(PKGJSON),
'package-lock.json': JSON.stringify(olderLockfiles[0]),
});

fakeBackends[1].backend.pull = () => Promise.reject(new errors.BundleNotFoundError);
const backendMock0 = sandbox.mock(fakeBackends[0].backend);
npmWrapper.installAll.restore();

sandbox.stub(npmWrapper, 'installAll').callsFake(() => {
mockfs({
'package.json': JSON.stringify(PKGJSON),
'package-lock.json': JSON.stringify(LOCKFILE),
});

return Promise.resolve();
});


backendMock0.expects('push').withArgs('PKGJSONHashWithNewLockfile').resolves();

const checkResult = checkMockResult.bind(null, [backendMock0], done);

install({config, lockfile: 'package-lock.json'}).then(checkResult, checkResult);
});

it('should locate lockfile and re-calc hash after npm install', done => {
// because npm install with lockfile will change the lockfile and we need to push with new hash
mockfs({
'package.json': JSON.stringify(PKGJSON),
});

fakeBackends[1].backend.pull = () => Promise.reject(new errors.BundleNotFoundError);
const backendMock0 = sandbox.mock(fakeBackends[0].backend);

npmWrapper.installAll.restore();
sandbox.stub(npmWrapper, 'installAll').callsFake(() => {
mockfs({
'package.json': JSON.stringify(PKGJSON),
'package-lock.json': JSON.stringify(LOCKFILE),
});

return Promise.resolve();
});

backendMock0.expects('push').withArgs('PKGJSONHashWithNewLockfile').resolves();

const checkResult = checkMockResult.bind(null, [backendMock0], done);

install({config}).then(checkResult, checkResult);
});

it('re-pulling should work after hash recalculation', done => {
const backendMock0 = sandbox.mock(fakeBackends[0].backend);

backendMock0.expects('pull').withArgs('PKGJSONHash').rejects(new errors.BundleNotFoundError);
fakeBackends[1].backend.pull = () => Promise.reject(new errors.BundleNotFoundError);

backendMock0.expects('push')
.withArgs('PKGJSONHashWithNewLockfile')
.rejects(new errors.BundleAlreadyExistsError);

backendMock0.expects('pull').withArgs('PKGJSONHashWithNewLockfile').resolves();

npmWrapper.installAll.restore();
sandbox.stub(npmWrapper, 'installAll').callsFake(() => {
mockfs({
'package.json': JSON.stringify(PKGJSON),
'package-lock.json': JSON.stringify(LOCKFILE),
});

return Promise.resolve();
});

const checkResult = checkMockResult.bind(null, [backendMock0], done);

install({config}).then(checkResult, checkResult);
});
});
});

Expand Down

0 comments on commit a8ea425

Please sign in to comment.