Skip to content

Commit

Permalink
refactor!: align structure of integrity json
Browse files Browse the repository at this point in the history
Changes the integrity JSON structure returned from the integrity programmatic api command and the eik integrity cli command to align with the server response.

BREAKING CHANGE: The structure of integrity.json changes with PR which would be breaking for anyone depending on it.
  • Loading branch information
digitalsadhu committed Mar 19, 2021
1 parent 973ee99 commit 437bc78
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
14 changes: 1 addition & 13 deletions classes/integrity.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,7 @@ module.exports = class Integrity {

if (res.ok) {
this.log.debug(` ==> ok: true`);
const data = await res.json();

const files = {};
for (const file of data.files) {
files[file.pathname] = file.integrity;
}

return {
name: data.name,
version: data.version,
integrity: data.integrity,
files,
};
return await res.json();
}

this.log.debug(` ==> ok: false`);
Expand Down
3 changes: 3 additions & 0 deletions test/integration/integrity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,8 @@ test('eik meta : details provided by eik.json - npm namespace', async (t) => {
t.equal(integrity.name, 'test-app-npm');
t.equal(integrity.version, '1.0.0');
t.ok(integrity.integrity);
t.equal(integrity.files.length, 3);
t.equal(integrity.files[0].pathname, '/eik.json');
t.ok(integrity.files[0].integrity);
t.end();
});
7 changes: 6 additions & 1 deletion test/integrity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@ test('package integrity', async (t) => {
t.equal(result.name, 'my-app');
t.equal(result.version, '1.0.0');
t.ok(result.integrity);
t.same(Object.keys(result.files), ['/eik.json', '/index.js', '/index.css']);
t.equal(result.files[0].pathname, '/eik.json');
t.ok(result.files[0].integrity);
t.equal(result.files[1].pathname, '/index.js');
t.ok(result.files[1].integrity);
t.equal(result.files[2].pathname, '/index.css');
t.ok(result.files[2].integrity);
});

0 comments on commit 437bc78

Please sign in to comment.