From 6d17338046f4eac2d460a1b59f94afda011db071 Mon Sep 17 00:00:00 2001 From: Johannes Lumpe Date: Wed, 12 Jun 2019 20:03:29 -0400 Subject: [PATCH] feat: support `--group`, `--app` and `--set` for `check`, fixes #3 --- .gitignore | 1 + jest.config.js | 3 + src/cli/__tests__/index.ts | 824 +++++++++++++----- src/cli/commands/applications/add.ts | 9 +- src/cli/commands/version-check.ts | 57 +- src/core/version-check.ts | 60 +- .../application_a/package.json | 0 .../application_b}/package.json | 2 +- .../application_c}/package.json | 2 +- .../application_d}/package.json | 2 +- .../mixed-config/application_e/package.json | 8 + .../mixed-config/application_f/package.json | 8 + .../check/mixed-config/config_fixture.json | 164 ++++ .../application_b/package.json | 8 - .../config_fixture.json | 56 -- .../application_b/package.json | 8 - .../config_fixture.json | 56 -- .../application_a/package.json | 0 .../application_b/package.json | 8 + .../application_c/package.json | 8 + .../application_d/package.json | 8 + .../config_fixture.json | 4 +- .../application_a/package.json | 0 .../application_b/package.json | 8 + .../application_c/package.json | 8 + .../application_d/package.json | 8 + .../config_fixture.json | 4 +- .../application_b/package.json | 8 - .../config_fixture.json | 29 - .../application_b/package.json | 8 - .../config_fixture.json | 29 - 31 files changed, 948 insertions(+), 450 deletions(-) rename test/fixtures/check/{multiple-groups-one-app-per-group-dependencies-invalid => mixed-config}/application_a/package.json (100%) rename test/fixtures/check/{single-group-two-apps-dependencies-valid/application_a => mixed-config/application_b}/package.json (77%) rename test/fixtures/check/{single-group-one-app-dependencies-valid/application_a => mixed-config/application_c}/package.json (77%) rename test/fixtures/check/{single-group-two-apps-dependencies-invalid/application_a => mixed-config/application_d}/package.json (77%) create mode 100644 test/fixtures/check/mixed-config/application_e/package.json create mode 100644 test/fixtures/check/mixed-config/application_f/package.json create mode 100644 test/fixtures/check/mixed-config/config_fixture.json delete mode 100644 test/fixtures/check/multiple-groups-one-app-per-group-dependencies-invalid/application_b/package.json delete mode 100644 test/fixtures/check/multiple-groups-one-app-per-group-dependencies-invalid/config_fixture.json delete mode 100644 test/fixtures/check/multiple-groups-one-app-per-group-dependencies-valid/application_b/package.json delete mode 100644 test/fixtures/check/multiple-groups-one-app-per-group-dependencies-valid/config_fixture.json rename test/fixtures/check/{multiple-groups-one-app-per-group-dependencies-valid => simple-config-invalid}/application_a/package.json (100%) create mode 100644 test/fixtures/check/simple-config-invalid/application_b/package.json create mode 100644 test/fixtures/check/simple-config-invalid/application_c/package.json create mode 100644 test/fixtures/check/simple-config-invalid/application_d/package.json rename test/fixtures/check/{single-group-one-app-dependencies-invalid => simple-config-invalid}/config_fixture.json (87%) rename test/fixtures/check/{single-group-one-app-dependencies-invalid => simple-config-valid}/application_a/package.json (100%) create mode 100644 test/fixtures/check/simple-config-valid/application_b/package.json create mode 100644 test/fixtures/check/simple-config-valid/application_c/package.json create mode 100644 test/fixtures/check/simple-config-valid/application_d/package.json rename test/fixtures/check/{single-group-one-app-dependencies-valid => simple-config-valid}/config_fixture.json (88%) delete mode 100644 test/fixtures/check/single-group-two-apps-dependencies-invalid/application_b/package.json delete mode 100644 test/fixtures/check/single-group-two-apps-dependencies-invalid/config_fixture.json delete mode 100644 test/fixtures/check/single-group-two-apps-dependencies-valid/application_b/package.json delete mode 100644 test/fixtures/check/single-group-two-apps-dependencies-valid/config_fixture.json diff --git a/.gitignore b/.gitignore index f97e396..7f29eb9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ **/node_modules /.vscode +/coverage /lib copied_*.json \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index 725353e..6ca80ba 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,7 @@ module.exports = { + coverageDirectory: './coverage/', + collectCoverageFrom: ['src/**/*.ts'], + collectCoverage: true, roots: ['/src'], testMatch: ['**/__tests__/**/*.ts'], globals: { diff --git a/src/cli/__tests__/index.ts b/src/cli/__tests__/index.ts index 0145b83..5eddf7c 100644 --- a/src/cli/__tests__/index.ts +++ b/src/cli/__tests__/index.ts @@ -68,6 +68,10 @@ async function assertGroupListContainsGroupsInOrder( expect(getCleanedMockStdout()).toBe(formatGroupListOutput(groups)); } +function guard(): void { + expect(true).toBe(false); +} + describe('versionguard', () => { beforeAll(() => cleanFixtureDir(FIXTURE_DIR)); beforeEach(removeAutogeneratedConfigFile); @@ -142,7 +146,7 @@ describe('versionguard', () => { 'a', ); - expect(getCleanedMockStdout()).toBe(`ℹ a + expect(getCleanedMockStdout()).toContain(`a Applications: application_a, application_b @@ -244,7 +248,7 @@ Dependency sets 'dependencies/one_dependency_set', )('dependencies:add', 'a', 'set_a', `dep_a${range}`); // should never get here - expect(true).toBe(false); + guard(); } catch (e) { expect(getCleanedMockStdout()).toBe( `✖ ${range.replace( @@ -311,19 +315,20 @@ Dependency sets }); describe('check', () => { - describe('valid dependencies', () => { - describe('single group, one application', () => { + describe('no arguments', () => { + describe('only valid entries', () => { it('should pass', async () => { - await executeCliWithCopiedConfigFixture( - 'check/single-group-one-app-dependencies-valid', - )('check', 'a'); + await executeCliWithCopiedConfigFixture('check/simple-config-valid')( + 'check', + ); expect(getCleanedMockStdout()).toBe('✔ Check passed!'); }); it('should pass, verbose', async () => { - await executeCliWithCopiedConfigFixture( - 'check/single-group-one-app-dependencies-valid', - )('check', 'a', '--verbose'); + await executeCliWithCopiedConfigFixture('check/simple-config-valid')( + 'check', + '--verbose', + ); expect(getCleanedMockStdout()).toBe(trim` ℹ ┌─────────────┬──────────┬─────────┬────────┬─────┐ @@ -332,25 +337,146 @@ Dependency sets │application_a│dep_a │^1.0.0 │1.x │✔ │ │ │dep_b │1.2.3 │1.x │✔ │ │ │dep_c │~1.5.0 │1.x │✔ │ + │application_b│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ └─────────────┴──────────┴─────────┴────────┴─────┘ ✔ Check passed! `); }); }); - describe('single group, multiple applications', () => { - it('should pass', async () => { - await executeCliWithCopiedConfigFixture( - 'check/single-group-two-apps-dependencies-valid', - )('check', 'a'); - expect(getCleanedMockStdout()).toBe('✔ Check passed!'); + describe('only invalid entries', () => { + it('should fail', async () => { + try { + await executeCliWithCopiedConfigFixture( + 'check/simple-config-invalid', + )('check'); + guard(); + } catch (e) { + expect(getCleanedMockStdout()).toBe( + '✖ Group all-invalid-a did not meet dependency version requirements', + ); + } }); - it('should pass, verbose', async () => { - await executeCliWithCopiedConfigFixture( - 'check/single-group-two-apps-dependencies-valid', - )('check', 'a', '--verbose'); + it('should fail, verbose', async () => { + try { + await executeCliWithCopiedConfigFixture( + 'check/simple-config-invalid', + )('check', '--verbose'); + guard(); + } catch (e) { + expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_a│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + │application_b│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✖ Group all-invalid-a did not meet dependency version requirements + `); + } + }); + }); + }); + }); + + describe('--group', () => { + describe('single group with only valid entries', () => { + const args = ['check', '--group', 'all-valid-a']; + it('should pass', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')(...args); + expect(getCleanedMockStdout()).toBe('✔ Check passed!'); + }); + it('should pass, verbose', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + '--verbose', + ); + expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_a│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + │application_b│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✔ Check passed! + `); + }); + }); + + describe('single group with invalid entries', () => { + const args = ['check', '--group', 'all-invalid-a']; + it('should fail', async () => { + try { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + ); + guard(); + } catch (e) { + expect(getCleanedMockStdout()).toBe( + '✖ Group all-invalid-a did not meet dependency version requirements', + ); + } + }); + + it('should fail, verbose', async () => { + try { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + '--verbose', + ); + guard(); + } catch (e) { expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_a│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + │application_b│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✖ Group all-invalid-a did not meet dependency version requirements + `); + } + }); + }); + + describe('multiple groups with valid entries', () => { + it('should pass', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + 'check', + '--group', + 'all-valid-a', + 'all-valid-b', + ); + expect(getCleanedMockStdout()).toBe('✔ Check passed!'); + }); + + it('should pass, verbose', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + 'check', + '--group', + 'all-valid-a', + 'all-valid-b', + '--verbose', + ); + expect(getCleanedMockStdout()).toBe(trim` ℹ ┌─────────────┬──────────┬─────────┬────────┬─────┐ │Application │Dependency│Installed│Required│Valid│ @@ -358,24 +484,156 @@ Dependency sets │application_a│dep_a │^1.0.0 │1.x │✔ │ │ │dep_b │1.2.3 │1.x │✔ │ │ │dep_c │~1.5.0 │1.x │✔ │ + │application_b│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_c│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + │application_d│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ └─────────────┴──────────┴─────────┴────────┴─────┘ ✔ Check passed! `); - }); }); + }); - describe('multiple groups, one application per group', () => { - it('should pass', async () => { - await executeCliWithCopiedConfigFixture( - 'check/multiple-groups-one-app-per-group-dependencies-valid', - )('check', 'a', 'b'); - expect(getCleanedMockStdout()).toBe('✔ Check passed!'); - }); + describe('multiple groups with invalid entries', () => { + const args = ['check', '--group', 'all-invalid-a', 'all-invalid-b']; + it('should fail', async () => { + try { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + ); + guard(); + } catch (e) { + expect(getCleanedMockStdout()).toBe( + '✖ Groups all-invalid-a, all-invalid-b did not meet dependency version requirements', + ); + } + }); + it('should fail, verbose', async () => { + try { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + '--verbose', + ); + guard(); + } catch (e) { + expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_a│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + │application_b│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_c│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + │application_d│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✖ Groups all-invalid-a, all-invalid-b did not meet dependency version requirements + `); + } + }); + }); + }); - it('should pass, verbose', async () => { - await executeCliWithCopiedConfigFixture( - 'check/multiple-groups-one-app-per-group-dependencies-valid', - )('check', 'a', 'b', '--verbose'); + describe('--app', () => { + describe('single application with valid entries in single group', () => { + const args = ['check', '--app', 'application_e']; + it('should pass', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')(...args); + expect(getCleanedMockStdout()).toBe('✔ Check passed!'); + }); + it('should pass, verbose', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + '--verbose', + ); + expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_e│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✔ Check passed! + `); + }); + }); + + describe('multiple applications with valid entries in different groups', () => { + const args = ['check', '--app', 'application_e', 'application_f']; + it('should pass', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')(...args); + expect(getCleanedMockStdout()).toBe('✔ Check passed!'); + }); + it('should pass, verbose', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + '--verbose', + ); + expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_e│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_f│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✔ Check passed! + `); + }); + }); + + describe('single application with valid and invalid entries in multiple groups', () => { + const args = ['check', '--app', 'application_a']; + it('should fail', async () => { + try { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + ); + guard(); + } catch (e) { + expect(getCleanedMockStdout()).toBe( + '✖ Group all-invalid-a did not meet dependency version requirements', + ); + } + }); + it('should fail, verbose', async () => { + try { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + '--verbose', + ); + guard(); + } catch (e) { expect(getCleanedMockStdout()).toBe(trim` ℹ ┌─────────────┬──────────┬─────────┬────────┬─────┐ @@ -384,231 +642,391 @@ Dependency sets │application_a│dep_a │^1.0.0 │1.x │✔ │ │ │dep_b │1.2.3 │1.x │✔ │ │ │dep_c │~1.5.0 │1.x │✔ │ - │application_b│dep_a │^1.5.0 │1.x │✔ │ - │ │dep_b │1.6.3 │1.x │✔ │ - │ │dep_c │~1.7.0 │1.x │✔ │ └─────────────┴──────────┴─────────┴────────┴─────┘ ┌─────────────┬──────────┬─────────┬────────┬─────┐ │Application │Dependency│Installed│Required│Valid│ ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_a│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✖ Group all-invalid-a did not meet dependency version requirements + `); + } + }); + }); + }); + + describe('--set', () => { + describe('single set with valid entries existing in multiple groups', () => { + it('should pass', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + 'check', + '--set', + 'public-allvalid', + ); + expect(getCleanedMockStdout()).toBe('✔ Check passed!'); + }); + it('should pass, verbose', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + 'check', + '--set', + 'public-allvalid', + '--verbose', + ); + expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_e│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_f│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✔ Check passed! + `); + }); + }); + + describe('single set with valid and invalid entries existing in multiple groups', () => { + const args = ['check', '--set', 'public']; + it('should fail', async () => { + try { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + ); + guard(); + } catch (e) { + expect(getCleanedMockStdout()).toBe( + '✖ Groups all-invalid-a, all-invalid-b did not meet dependency version requirements', + ); + } + }); + it('should fail, verbose', async () => { + try { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + '--verbose', + ); + guard(); + } catch (e) { + expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ │application_a│dep_a │^1.0.0 │1.x │✔ │ │ │dep_b │1.2.3 │1.x │✔ │ + │application_b│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_c│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │application_d│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_a│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │application_b│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_c│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │application_d│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✖ Groups all-invalid-a, all-invalid-b did not meet dependency version requirements + `); + } + }); + }); + + describe('multiple sets with valid entries in multiple groups', () => { + const args = ['check', '--set', 'public-allvalid', 'private-allvalid']; + it('should pass', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')(...args); + expect(getCleanedMockStdout()).toBe('✔ Check passed!'); + }); + it('should pass, verbose', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + '--verbose', + ); + expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_e│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ │ │dep_c │~1.5.0 │1.x │✔ │ - │application_b│dep_a │^1.5.0 │1.x │✔ │ - │ │dep_b │1.6.3 │1.x │✔ │ - │ │dep_c │~1.7.0 │1.x │✔ │ └─────────────┴──────────┴─────────┴────────┴─────┘ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_f│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ ✔ Check passed! `); - }); }); + }); + + describe('multiple sets with valid and invalid entries existing in multiple groups', () => { + const args = ['check', '--set', 'public', 'private']; + it('should fail', async () => { + try { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + ); + guard(); + } catch (e) { + expect(getCleanedMockStdout()).toBe( + '✖ Groups all-invalid-a, all-invalid-b did not meet dependency version requirements', + ); + } + }); + it('should fail, verbose', async () => { + try { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...args, + '--verbose', + ); + guard(); + } catch (e) { + expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_a│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + │application_b│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_c│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + │application_d│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_a│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + │application_b│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_c│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + │application_d│dep_a │^1.0.0 │3.x │✖ │ + │ │dep_b │1.2.3 │3.x │✖ │ + │ │dep_c │~1.5.0 │3.x │✖ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✖ Groups all-invalid-a, all-invalid-b did not meet dependency version requirements + `); + } + }); + }); - describe('no group arguments', () => { + describe('--group, --app and --set combinations', () => { + const argsA = [ + 'check', + '--group', + 'all-valid-a', + '--app', + 'application_a', + '--set', + 'public', + ]; + describe(argsA.slice(1).join(' '), () => { it('should pass', async () => { - await executeCliWithCopiedConfigFixture( - 'check/multiple-groups-one-app-per-group-dependencies-valid', - )('check'); + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...argsA, + ); expect(getCleanedMockStdout()).toBe('✔ Check passed!'); }); it('should pass, verbose', async () => { - await executeCliWithCopiedConfigFixture( - 'check/multiple-groups-one-app-per-group-dependencies-valid', - )('check', '--verbose'); + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...argsA, + '--verbose', + ); expect(getCleanedMockStdout()).toBe(trim` - ℹ - ┌─────────────┬──────────┬─────────┬────────┬─────┐ - │Application │Dependency│Installed│Required│Valid│ - ├─────────────┼──────────┼─────────┼────────┼─────┤ - │application_a│dep_a │^1.0.0 │1.x │✔ │ - │ │dep_b │1.2.3 │1.x │✔ │ - │ │dep_c │~1.5.0 │1.x │✔ │ - │application_b│dep_a │^1.5.0 │1.x │✔ │ - │ │dep_b │1.6.3 │1.x │✔ │ - │ │dep_c │~1.7.0 │1.x │✔ │ - └─────────────┴──────────┴─────────┴────────┴─────┘ - ┌─────────────┬──────────┬─────────┬────────┬─────┐ - │Application │Dependency│Installed│Required│Valid│ - ├─────────────┼──────────┼─────────┼────────┼─────┤ - │application_a│dep_a │^1.0.0 │1.x │✔ │ - │ │dep_b │1.2.3 │1.x │✔ │ - │ │dep_c │~1.5.0 │1.x │✔ │ - │application_b│dep_a │^1.5.0 │1.x │✔ │ - │ │dep_b │1.6.3 │1.x │✔ │ - │ │dep_c │~1.7.0 │1.x │✔ │ - └─────────────┴──────────┴─────────┴────────┴─────┘ - ✔ Check passed! - `); + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_a│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✔ Check passed! + `); }); }); - }); - describe('invalid dependencies', () => { - describe('single group, one application', () => { - it('should fail', async () => { - try { - await executeCliWithCopiedConfigFixture( - 'check/single-group-one-app-dependencies-invalid', - )('check', 'a'); - expect(true).toBe(false); - } catch (e) { - expect(getCleanedMockStdout()).toBe( - '✖ Group a did not meet dependency version requirements', - ); - } + const argsB = [ + 'check', + '--group', + 'all-valid-a', + '--app', + 'application_a', + '--set', + 'public', + 'private', + ]; + describe(argsB.slice(1).join(' '), () => { + it('should pass', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...argsB, + ); + expect(getCleanedMockStdout()).toBe('✔ Check passed!'); }); - it('should fail, verbose', async () => { - try { - await executeCliWithCopiedConfigFixture( - 'check/single-group-one-app-dependencies-invalid', - )('check', 'a', '--verbose'); - expect(true).toBe(false); - } catch (e) { - expect(getCleanedMockStdout()).toBe(trim` - ℹ - ┌─────────────┬──────────┬─────────┬────────┬─────┐ - │Application │Dependency│Installed│Required│Valid│ - ├─────────────┼──────────┼─────────┼────────┼─────┤ - │application_a│dep_a │^1.0.0 │3.x │✖ │ - │ │dep_b │1.2.3 │3.x │✖ │ - │ │dep_c │~1.5.0 │3.x │✖ │ - └─────────────┴──────────┴─────────┴────────┴─────┘ - ✖ Group a did not meet dependency version requirements - `); - } + it('should pass, verbose', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...argsB, + '--verbose', + ); + expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_a│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✔ Check passed! + `); }); }); - describe('single group, multiple applications', () => { - it('should fail', async () => { - try { - await executeCliWithCopiedConfigFixture( - 'check/single-group-two-apps-dependencies-invalid', - )('check', 'a'); - expect(true).toBe(false); - } catch (e) { - expect(getCleanedMockStdout()).toBe( - '✖ Group a did not meet dependency version requirements', - ); - } + const argsC = [ + 'check', + '--group', + 'all-valid-a', + '--app', + 'application_a', + 'application_b', + '--set', + 'public', + 'private', + ]; + describe(argsC.slice(1).join(' '), () => { + it('should pass', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...argsC, + ); + expect(getCleanedMockStdout()).toBe('✔ Check passed!'); }); - it('should fail, verbose', async () => { - try { - await executeCliWithCopiedConfigFixture( - 'check/single-group-two-apps-dependencies-invalid', - )('check', 'a', '--verbose'); - expect(true).toBe(false); - } catch (e) { - expect(getCleanedMockStdout()).toBe(trim` - ℹ - ┌─────────────┬──────────┬─────────┬────────┬─────┐ - │Application │Dependency│Installed│Required│Valid│ - ├─────────────┼──────────┼─────────┼────────┼─────┤ - │application_a│dep_a │^1.0.0 │3.x │✖ │ - │ │dep_b │1.2.3 │3.x │✖ │ - │ │dep_c │~1.5.0 │3.x │✖ │ - └─────────────┴──────────┴─────────┴────────┴─────┘ - ✖ Group a did not meet dependency version requirements - `); - } + it('should pass, verbose', async () => { + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...argsC, + '--verbose', + ); + expect(getCleanedMockStdout()).toBe(trim` + ℹ + ┌─────────────┬──────────┬─────────┬────────┬─────┐ + │Application │Dependency│Installed│Required│Valid│ + ├─────────────┼──────────┼─────────┼────────┼─────┤ + │application_a│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + │application_b│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + └─────────────┴──────────┴─────────┴────────┴─────┘ + ✔ Check passed! + `); }); }); - describe('multiple groups, one application per group', () => { + const argsD = [ + 'check', + '--group', + 'all-valid-a', + 'all-invalid-a', + '--app', + 'application_a', + 'application_b', + '--set', + 'public', + 'private', + ]; + describe(argsD.slice(1).join(' '), () => { it('should fail', async () => { try { - await executeCliWithCopiedConfigFixture( - 'check/multiple-groups-one-app-per-group-dependencies-invalid', - )('check', 'a', 'b'); - expect(true).toBe(false); + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...argsD, + ); + guard(); } catch (e) { expect(getCleanedMockStdout()).toBe( - '✖ Groups a, b did not meet dependency version requirements', + '✖ Group all-invalid-a did not meet dependency version requirements', ); } }); it('should fail, verbose', async () => { try { - await executeCliWithCopiedConfigFixture( - 'check/multiple-groups-one-app-per-group-dependencies-invalid', - )('check', 'a', 'b', '--verbose'); - expect(true).toBe(false); + await executeCliWithCopiedConfigFixture('check/mixed-config')( + ...argsD, + '--verbose', + ); + guard(); } catch (e) { - expect(getCleanedMockStdout()).toBe(trim` - ℹ + expect(getCleanedMockStdout()).toContain(trim` ┌─────────────┬──────────┬─────────┬────────┬─────┐ │Application │Dependency│Installed│Required│Valid│ ├─────────────┼──────────┼─────────┼────────┼─────┤ - │application_a│dep_a │^1.0.0 │3.x │✖ │ - │ │dep_b │1.2.3 │3.x │✖ │ - │ │dep_c │~1.5.0 │3.x │✖ │ - │application_b│dep_a │^1.5.0 │3.x │✖ │ - │ │dep_b │1.6.3 │3.x │✖ │ - │ │dep_c │~1.7.0 │3.x │✖ │ + │application_a│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ + │application_b│dep_a │^1.0.0 │1.x │✔ │ + │ │dep_b │1.2.3 │1.x │✔ │ + │ │dep_c │~1.5.0 │1.x │✔ │ └─────────────┴──────────┴─────────┴────────┴─────┘ ┌─────────────┬──────────┬─────────┬────────┬─────┐ │Application │Dependency│Installed│Required│Valid│ - ├─────────────┼──────────┼─────────┼────────┼─────┤ + ├─────────────┼──────────┼─────────┼────────┼─────┤ │application_a│dep_a │^1.0.0 │3.x │✖ │ │ │dep_b │1.2.3 │3.x │✖ │ │ │dep_c │~1.5.0 │3.x │✖ │ - │application_b│dep_a │^1.5.0 │3.x │✖ │ - │ │dep_b │1.6.3 │3.x │✖ │ - │ │dep_c │~1.7.0 │3.x │✖ │ - └─────────────┴──────────┴─────────┴────────┴─────┘ - ✖ Groups a, b did not meet dependency version requirements - `); - } - }); - }); - - describe('no arguments', () => { - it('should fail', async () => { - try { - await executeCliWithCopiedConfigFixture( - 'check/multiple-groups-one-app-per-group-dependencies-invalid', - )('check'); - expect(true).toBe(false); - } catch (e) { - expect(getCleanedMockStdout()).toBe( - '✖ Groups a, b did not meet dependency version requirements', - ); - } - }); - - it('should fail, verbose', async () => { - try { - await executeCliWithCopiedConfigFixture( - 'check/multiple-groups-one-app-per-group-dependencies-invalid', - )('check', '--verbose'); - expect(true).toBe(false); - } catch (e) { - expect(getCleanedMockStdout()).toBe(trim` - ℹ - ┌─────────────┬──────────┬─────────┬────────┬─────┐ - │Application │Dependency│Installed│Required│Valid│ - ├─────────────┼──────────┼─────────┼────────┼─────┤ - │application_a│dep_a │^1.0.0 │3.x │✖ │ - │ │dep_b │1.2.3 │3.x │✖ │ - │ │dep_c │~1.5.0 │3.x │✖ │ - │application_b│dep_a │^1.5.0 │3.x │✖ │ - │ │dep_b │1.6.3 │3.x │✖ │ - │ │dep_c │~1.7.0 │3.x │✖ │ - └─────────────┴──────────┴─────────┴────────┴─────┘ - ┌─────────────┬──────────┬─────────┬────────┬─────┐ - │Application │Dependency│Installed│Required│Valid│ - ├─────────────┼──────────┼─────────┼────────┼─────┤ - │application_a│dep_a │^1.0.0 │3.x │✖ │ + │application_b│dep_a │^1.0.0 │3.x │✖ │ │ │dep_b │1.2.3 │3.x │✖ │ │ │dep_c │~1.5.0 │3.x │✖ │ - │application_b│dep_a │^1.5.0 │3.x │✖ │ - │ │dep_b │1.6.3 │3.x │✖ │ - │ │dep_c │~1.7.0 │3.x │✖ │ └─────────────┴──────────┴─────────┴────────┴─────┘ - ✖ Groups a, b did not meet dependency version requirements + ✖ Group all-invalid-a did not meet dependency version requirements `); } }); diff --git a/src/cli/commands/applications/add.ts b/src/cli/commands/applications/add.ts index 91e8517..9964806 100644 --- a/src/cli/commands/applications/add.ts +++ b/src/cli/commands/applications/add.ts @@ -35,13 +35,12 @@ export function addApplicationCommand( }); await writeConfig(config.path, updatedConfig); success( - emphasize`${pluralize( - 'Application', - applicationpaths.length, - )} in ${pluralize( + `${pluralize('Application', applicationpaths.length)} in ${pluralize( 'path', applicationpaths.length, - )} ${applicationpaths.join(', ')} added to group ${groupname}`, + )} ${emphasize`${applicationpaths.join( + ', ', + )}`} added to group ${groupname}`, ); })(); }, diff --git a/src/cli/commands/version-check.ts b/src/cli/commands/version-check.ts index bc23677..77bf76f 100644 --- a/src/cli/commands/version-check.ts +++ b/src/cli/commands/version-check.ts @@ -64,24 +64,53 @@ export function versionCheckCommand( yargs: ArgvWithGlobalOptions, ): ArgvWithGlobalOptions { return yargs.command( - 'check [groups..]', + 'check', 'check dependencies for given groups', yargs => - yargs - .positional('groups', { - describe: 'groups to check dependencies for', - }) - .string('groups') - .array('groups'), + yargs.options({ + group: { + array: true, + description: 'groups to check', + type: 'string', + default: [] as string[], + }, + app: { + array: true, + description: 'applications to check', + type: 'string', + default: [] as string[], + }, + set: { + array: true, + description: 'sets to check', + type: 'string', + default: [] as string[], + }, + }), argv => { argv._asyncResult = (async () => { - const { config, verbose, groups } = argv; + const { config, verbose, group, set, app } = argv; const result = await checkDependencies({ config: config.contents, configPath: config.path, - groupsToCheck: groups, + groups: group, + sets: set, + applications: app, }); + // TODO support --json + // format: + // { + // failed: [{ + // application: string; + // applicationPath: string; + // dependencies: string[]; + // }] + // passed: [{ + // same as above + // }] + // } + if (verbose) { const tables = Object.entries(result.groupResults).reduce( (acc, [, groupResult]) => { @@ -103,9 +132,15 @@ export function versionCheckCommand( } if (!result.passed) { - const groups = Object.keys(result.groupResults); + const groups = Object.entries(result.groupResults); + const failedGroups = groups + .filter(([, groupResult]) => !groupResult.passed) + .map(([group]) => group); throw VersionGuardError.from( - `${pluralize('Group', groups.length)} ${emphasize`${groups.join( + `${pluralize( + 'Group', + failedGroups.length, + )} ${emphasize`${failedGroups.join( ', ', )} did not meet dependency version requirements`}`, ); diff --git a/src/core/version-check.ts b/src/core/version-check.ts index c3417e5..8e8b91f 100644 --- a/src/core/version-check.ts +++ b/src/core/version-check.ts @@ -64,16 +64,14 @@ async function readPackageJsons({ function invalidGroupsInvariant({ config, - availableGroups, + groups, }: { config: VersionGuardConfig; - availableGroups: string[]; + groups: string[]; }): void { const allGroups = Object.keys(config); - if (availableGroups.length) { - const invalidGroups = availableGroups.filter( - group => !allGroups.includes(group), - ); + if (groups.length) { + const invalidGroups = groups.filter(group => !allGroups.includes(group)); if (invalidGroups.length) { throw VersionGuardError.from( `${pluralize( @@ -88,37 +86,55 @@ function invalidGroupsInvariant({ export async function checkDependencies({ config, configPath, - groupsToCheck, + groups, + sets, + applications, }: { config: VersionGuardConfig; configPath: string; - groupsToCheck: string[]; + groups: string[]; + sets: string[]; + applications: string[]; }): Promise> { - const availableGroups = Object.keys(config); - invalidGroupsInvariant({ config, availableGroups }); - const groups = availableGroups.filter( - group => !groupsToCheck.length || groupsToCheck.includes(group), - ); + invalidGroupsInvariant({ config, groups: groups }); const groupResults: Dictionary = {}; - const applicationDependencyResults: Dictionary = {}; let allGroupsPassed = true; // TODO refactor - for (const group of groups) { - const groupConfig = config[group]; - const { applications, dependencies } = groupConfig; + const allEntries = Object.entries(config); + const entriesToCheck = !groups.length + ? allEntries + : allEntries.filter(([group]) => groups.includes(group)); + + for (const [group, groupConfig] of entriesToCheck) { + const applicationDependencyResults: Dictionary = {}; + const { applications: availableApplications, dependencies } = groupConfig; + const applicationsToCheck = applications.length + ? availableApplications.filter(app => applications.includes(app)) + : availableApplications; + // this group does not contain any applications we want to check + if (!applicationsToCheck.length) { + continue; + } + const availableDependencySets = Object.entries(dependencies); + const dependencySetsToCheck = sets.length + ? availableDependencySets.filter(([setName]) => sets.includes(setName)) + : availableDependencySets; + // this group does not contain any dependency sets we want to check + if (!dependencySetsToCheck.length) { + continue; + } const dependenciesByApplication = await readPackageJsons({ configPath, - applications, + applications: applicationsToCheck, }); - const dependencySets = Object.keys(dependencies); let groupPassed = true; - for (const setKey of dependencySets) { - const setConfig = dependencies[setKey]; + + for (const [, setConfig] of dependencySetsToCheck) { for (const dependency of Object.keys(setConfig.dependencySemvers)) { const [, requiredDependencyVersion] = setConfig.dependencySemvers[ dependency ].semver.split('@'); - for (const application of applications) { + for (const application of applicationsToCheck) { const dependencyVersion = dependenciesByApplication[application][dependency]; const dependencySatisfied = semver.satisfies( diff --git a/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-invalid/application_a/package.json b/test/fixtures/check/mixed-config/application_a/package.json similarity index 100% rename from test/fixtures/check/multiple-groups-one-app-per-group-dependencies-invalid/application_a/package.json rename to test/fixtures/check/mixed-config/application_a/package.json diff --git a/test/fixtures/check/single-group-two-apps-dependencies-valid/application_a/package.json b/test/fixtures/check/mixed-config/application_b/package.json similarity index 77% rename from test/fixtures/check/single-group-two-apps-dependencies-valid/application_a/package.json rename to test/fixtures/check/mixed-config/application_b/package.json index 8c18e0a..b2bcc5c 100644 --- a/test/fixtures/check/single-group-two-apps-dependencies-valid/application_a/package.json +++ b/test/fixtures/check/mixed-config/application_b/package.json @@ -1,5 +1,5 @@ { - "name": "application-a", + "name": "application-b", "dependencies": { "dep_a": "^1.0.0", "dep_b": "1.2.3", diff --git a/test/fixtures/check/single-group-one-app-dependencies-valid/application_a/package.json b/test/fixtures/check/mixed-config/application_c/package.json similarity index 77% rename from test/fixtures/check/single-group-one-app-dependencies-valid/application_a/package.json rename to test/fixtures/check/mixed-config/application_c/package.json index 8c18e0a..7ee1a2c 100644 --- a/test/fixtures/check/single-group-one-app-dependencies-valid/application_a/package.json +++ b/test/fixtures/check/mixed-config/application_c/package.json @@ -1,5 +1,5 @@ { - "name": "application-a", + "name": "application-c", "dependencies": { "dep_a": "^1.0.0", "dep_b": "1.2.3", diff --git a/test/fixtures/check/single-group-two-apps-dependencies-invalid/application_a/package.json b/test/fixtures/check/mixed-config/application_d/package.json similarity index 77% rename from test/fixtures/check/single-group-two-apps-dependencies-invalid/application_a/package.json rename to test/fixtures/check/mixed-config/application_d/package.json index 8c18e0a..f3fc3fb 100644 --- a/test/fixtures/check/single-group-two-apps-dependencies-invalid/application_a/package.json +++ b/test/fixtures/check/mixed-config/application_d/package.json @@ -1,5 +1,5 @@ { - "name": "application-a", + "name": "application-d", "dependencies": { "dep_a": "^1.0.0", "dep_b": "1.2.3", diff --git a/test/fixtures/check/mixed-config/application_e/package.json b/test/fixtures/check/mixed-config/application_e/package.json new file mode 100644 index 0000000..f3fc3fb --- /dev/null +++ b/test/fixtures/check/mixed-config/application_e/package.json @@ -0,0 +1,8 @@ +{ + "name": "application-d", + "dependencies": { + "dep_a": "^1.0.0", + "dep_b": "1.2.3", + "dep_c": "~1.5.0" + } +} diff --git a/test/fixtures/check/mixed-config/application_f/package.json b/test/fixtures/check/mixed-config/application_f/package.json new file mode 100644 index 0000000..f3fc3fb --- /dev/null +++ b/test/fixtures/check/mixed-config/application_f/package.json @@ -0,0 +1,8 @@ +{ + "name": "application-d", + "dependencies": { + "dep_a": "^1.0.0", + "dep_b": "1.2.3", + "dep_c": "~1.5.0" + } +} diff --git a/test/fixtures/check/mixed-config/config_fixture.json b/test/fixtures/check/mixed-config/config_fixture.json new file mode 100644 index 0000000..3228ce9 --- /dev/null +++ b/test/fixtures/check/mixed-config/config_fixture.json @@ -0,0 +1,164 @@ +{ + "all-valid-a": { + "applications": ["application_a", "application_b"], + "dependencies": { + "public": { + "dependencySemvers": { + "dep_a": { + "dateAdded": 1560081600000, + "semver": "dep_a@1.x" + }, + "dep_b": { + "dateAdded": 1560081600000, + "semver": "dep_b@1.x" + } + }, + "gracePeriod": Infinity + }, + "private": { + "dependencySemvers": { + "dep_c": { + "dateAdded": 1560081600000, + "semver": "dep_c@1.x" + } + }, + "gracePeriod": Infinity + } + } + }, + "all-valid-b": { + "applications": ["application_c", "application_d"], + "dependencies": { + "public": { + "dependencySemvers": { + "dep_a": { + "dateAdded": 1560081600000, + "semver": "dep_a@1.x" + }, + "dep_b": { + "dateAdded": 1560081600000, + "semver": "dep_b@1.x" + } + }, + "gracePeriod": Infinity + }, + "private": { + "dependencySemvers": { + "dep_c": { + "dateAdded": 1560081600000, + "semver": "dep_c@1.x" + } + }, + "gracePeriod": Infinity + } + } + }, + "all-valid-c": { + "applications": ["application_e"], + "dependencies": { + "public-allvalid": { + "dependencySemvers": { + "dep_a": { + "dateAdded": 1560081600000, + "semver": "dep_a@1.x" + }, + "dep_b": { + "dateAdded": 1560081600000, + "semver": "dep_b@1.x" + } + }, + "gracePeriod": Infinity + }, + "private-allvalid": { + "dependencySemvers": { + "dep_c": { + "dateAdded": 1560081600000, + "semver": "dep_c@1.x" + } + }, + "gracePeriod": Infinity + } + } + }, + "all-valid-d": { + "applications": ["application_f"], + "dependencies": { + "public-allvalid": { + "dependencySemvers": { + "dep_a": { + "dateAdded": 1560081600000, + "semver": "dep_a@1.x" + }, + "dep_b": { + "dateAdded": 1560081600000, + "semver": "dep_b@1.x" + } + }, + "gracePeriod": Infinity + }, + "private-allvalid": { + "dependencySemvers": { + "dep_c": { + "dateAdded": 1560081600000, + "semver": "dep_c@1.x" + } + }, + "gracePeriod": Infinity + } + } + }, + "all-invalid-a": { + "applications": ["application_a", "application_b"], + "dependencies": { + "public": { + "dependencySemvers": { + "dep_a": { + "dateAdded": 1560081600000, + "semver": "dep_a@3.x" + }, + "dep_b": { + "dateAdded": 1560081600000, + "semver": "dep_b@3.x" + } + }, + "gracePeriod": Infinity + }, + "private": { + "dependencySemvers": { + "dep_c": { + "dateAdded": 1560081600000, + "semver": "dep_c@3.x" + } + }, + "gracePeriod": Infinity + } + } + }, + "all-invalid-b": { + "applications": ["application_c", "application_d"], + "dependencies": { + "public": { + "dependencySemvers": { + "dep_a": { + "dateAdded": 1560081600000, + "semver": "dep_a@3.x" + }, + "dep_b": { + "dateAdded": 1560081600000, + "semver": "dep_b@3.x" + } + }, + "gracePeriod": Infinity + }, + "private": { + "dependencySemvers": { + "dep_c": { + "dateAdded": 1560081600000, + "semver": "dep_c@3.x" + } + }, + "gracePeriod": Infinity + } + } + } +} diff --git a/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-invalid/application_b/package.json b/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-invalid/application_b/package.json deleted file mode 100644 index 4bae16b..0000000 --- a/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-invalid/application_b/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "application-b", - "dependencies": { - "dep_a": "^1.5.0", - "dep_b": "1.6.3", - "dep_c": "~1.7.0" - } -} diff --git a/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-invalid/config_fixture.json b/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-invalid/config_fixture.json deleted file mode 100644 index 7031b01..0000000 --- a/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-invalid/config_fixture.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "a": { - "applications": ["application_a"], - "dependencies": { - "public": { - "dependencySemvers": { - "dep_a": { - "dateAdded": 1560081600000, - "semver": "dep_a@3.x" - }, - "dep_b": { - "dateAdded": 1560081600000, - "semver": "dep_b@3.x" - } - }, - "gracePeriod": Infinity - }, - "private": { - "dependencySemvers": { - "dep_c": { - "dateAdded": 1560081600000, - "semver": "dep_c@3.x" - } - }, - "gracePeriod": Infinity - } - } - }, - "b": { - "applications": ["application_b"], - "dependencies": { - "public": { - "dependencySemvers": { - "dep_a": { - "dateAdded": 1560081600000, - "semver": "dep_a@3.x" - }, - "dep_b": { - "dateAdded": 1560081600000, - "semver": "dep_b@3.x" - } - }, - "gracePeriod": Infinity - }, - "private": { - "dependencySemvers": { - "dep_c": { - "dateAdded": 1560081600000, - "semver": "dep_c@3.x" - } - }, - "gracePeriod": Infinity - } - } - } -} diff --git a/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-valid/application_b/package.json b/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-valid/application_b/package.json deleted file mode 100644 index 4bae16b..0000000 --- a/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-valid/application_b/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "application-b", - "dependencies": { - "dep_a": "^1.5.0", - "dep_b": "1.6.3", - "dep_c": "~1.7.0" - } -} diff --git a/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-valid/config_fixture.json b/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-valid/config_fixture.json deleted file mode 100644 index cc170b2..0000000 --- a/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-valid/config_fixture.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "a": { - "applications": ["application_a"], - "dependencies": { - "public": { - "dependencySemvers": { - "dep_a": { - "dateAdded": 1560081600000, - "semver": "dep_a@1.x" - }, - "dep_b": { - "dateAdded": 1560081600000, - "semver": "dep_b@1.x" - } - }, - "gracePeriod": Infinity - }, - "private": { - "dependencySemvers": { - "dep_c": { - "dateAdded": 1560081600000, - "semver": "dep_c@1.x" - } - }, - "gracePeriod": Infinity - } - } - }, - "b": { - "applications": ["application_b"], - "dependencies": { - "public": { - "dependencySemvers": { - "dep_a": { - "dateAdded": 1560081600000, - "semver": "dep_a@1.x" - }, - "dep_b": { - "dateAdded": 1560081600000, - "semver": "dep_b@1.x" - } - }, - "gracePeriod": Infinity - }, - "private": { - "dependencySemvers": { - "dep_c": { - "dateAdded": 1560081600000, - "semver": "dep_c@1.x" - } - }, - "gracePeriod": Infinity - } - } - } -} diff --git a/test/fixtures/check/multiple-groups-one-app-per-group-dependencies-valid/application_a/package.json b/test/fixtures/check/simple-config-invalid/application_a/package.json similarity index 100% rename from test/fixtures/check/multiple-groups-one-app-per-group-dependencies-valid/application_a/package.json rename to test/fixtures/check/simple-config-invalid/application_a/package.json diff --git a/test/fixtures/check/simple-config-invalid/application_b/package.json b/test/fixtures/check/simple-config-invalid/application_b/package.json new file mode 100644 index 0000000..b2bcc5c --- /dev/null +++ b/test/fixtures/check/simple-config-invalid/application_b/package.json @@ -0,0 +1,8 @@ +{ + "name": "application-b", + "dependencies": { + "dep_a": "^1.0.0", + "dep_b": "1.2.3", + "dep_c": "~1.5.0" + } +} diff --git a/test/fixtures/check/simple-config-invalid/application_c/package.json b/test/fixtures/check/simple-config-invalid/application_c/package.json new file mode 100644 index 0000000..7ee1a2c --- /dev/null +++ b/test/fixtures/check/simple-config-invalid/application_c/package.json @@ -0,0 +1,8 @@ +{ + "name": "application-c", + "dependencies": { + "dep_a": "^1.0.0", + "dep_b": "1.2.3", + "dep_c": "~1.5.0" + } +} diff --git a/test/fixtures/check/simple-config-invalid/application_d/package.json b/test/fixtures/check/simple-config-invalid/application_d/package.json new file mode 100644 index 0000000..f3fc3fb --- /dev/null +++ b/test/fixtures/check/simple-config-invalid/application_d/package.json @@ -0,0 +1,8 @@ +{ + "name": "application-d", + "dependencies": { + "dep_a": "^1.0.0", + "dep_b": "1.2.3", + "dep_c": "~1.5.0" + } +} diff --git a/test/fixtures/check/single-group-one-app-dependencies-invalid/config_fixture.json b/test/fixtures/check/simple-config-invalid/config_fixture.json similarity index 87% rename from test/fixtures/check/single-group-one-app-dependencies-invalid/config_fixture.json rename to test/fixtures/check/simple-config-invalid/config_fixture.json index 44fd69d..ffacc88 100644 --- a/test/fixtures/check/single-group-one-app-dependencies-invalid/config_fixture.json +++ b/test/fixtures/check/simple-config-invalid/config_fixture.json @@ -1,6 +1,6 @@ { - "a": { - "applications": ["application_a"], + "all-invalid-a": { + "applications": ["application_a", "application_b"], "dependencies": { "public": { "dependencySemvers": { diff --git a/test/fixtures/check/single-group-one-app-dependencies-invalid/application_a/package.json b/test/fixtures/check/simple-config-valid/application_a/package.json similarity index 100% rename from test/fixtures/check/single-group-one-app-dependencies-invalid/application_a/package.json rename to test/fixtures/check/simple-config-valid/application_a/package.json diff --git a/test/fixtures/check/simple-config-valid/application_b/package.json b/test/fixtures/check/simple-config-valid/application_b/package.json new file mode 100644 index 0000000..b2bcc5c --- /dev/null +++ b/test/fixtures/check/simple-config-valid/application_b/package.json @@ -0,0 +1,8 @@ +{ + "name": "application-b", + "dependencies": { + "dep_a": "^1.0.0", + "dep_b": "1.2.3", + "dep_c": "~1.5.0" + } +} diff --git a/test/fixtures/check/simple-config-valid/application_c/package.json b/test/fixtures/check/simple-config-valid/application_c/package.json new file mode 100644 index 0000000..7ee1a2c --- /dev/null +++ b/test/fixtures/check/simple-config-valid/application_c/package.json @@ -0,0 +1,8 @@ +{ + "name": "application-c", + "dependencies": { + "dep_a": "^1.0.0", + "dep_b": "1.2.3", + "dep_c": "~1.5.0" + } +} diff --git a/test/fixtures/check/simple-config-valid/application_d/package.json b/test/fixtures/check/simple-config-valid/application_d/package.json new file mode 100644 index 0000000..f3fc3fb --- /dev/null +++ b/test/fixtures/check/simple-config-valid/application_d/package.json @@ -0,0 +1,8 @@ +{ + "name": "application-d", + "dependencies": { + "dep_a": "^1.0.0", + "dep_b": "1.2.3", + "dep_c": "~1.5.0" + } +} diff --git a/test/fixtures/check/single-group-one-app-dependencies-valid/config_fixture.json b/test/fixtures/check/simple-config-valid/config_fixture.json similarity index 88% rename from test/fixtures/check/single-group-one-app-dependencies-valid/config_fixture.json rename to test/fixtures/check/simple-config-valid/config_fixture.json index 2401bc6..fd434e4 100644 --- a/test/fixtures/check/single-group-one-app-dependencies-valid/config_fixture.json +++ b/test/fixtures/check/simple-config-valid/config_fixture.json @@ -1,6 +1,6 @@ { - "a": { - "applications": ["application_a"], + "all-valid-a": { + "applications": ["application_a", "application_b"], "dependencies": { "public": { "dependencySemvers": { diff --git a/test/fixtures/check/single-group-two-apps-dependencies-invalid/application_b/package.json b/test/fixtures/check/single-group-two-apps-dependencies-invalid/application_b/package.json deleted file mode 100644 index 4bae16b..0000000 --- a/test/fixtures/check/single-group-two-apps-dependencies-invalid/application_b/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "application-b", - "dependencies": { - "dep_a": "^1.5.0", - "dep_b": "1.6.3", - "dep_c": "~1.7.0" - } -} diff --git a/test/fixtures/check/single-group-two-apps-dependencies-invalid/config_fixture.json b/test/fixtures/check/single-group-two-apps-dependencies-invalid/config_fixture.json deleted file mode 100644 index 44fd69d..0000000 --- a/test/fixtures/check/single-group-two-apps-dependencies-invalid/config_fixture.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "a": { - "applications": ["application_a"], - "dependencies": { - "public": { - "dependencySemvers": { - "dep_a": { - "dateAdded": 1560081600000, - "semver": "dep_a@3.x" - }, - "dep_b": { - "dateAdded": 1560081600000, - "semver": "dep_b@3.x" - } - }, - "gracePeriod": Infinity - }, - "private": { - "dependencySemvers": { - "dep_c": { - "dateAdded": 1560081600000, - "semver": "dep_c@3.x" - } - }, - "gracePeriod": Infinity - } - } - } -} diff --git a/test/fixtures/check/single-group-two-apps-dependencies-valid/application_b/package.json b/test/fixtures/check/single-group-two-apps-dependencies-valid/application_b/package.json deleted file mode 100644 index 4bae16b..0000000 --- a/test/fixtures/check/single-group-two-apps-dependencies-valid/application_b/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "application-b", - "dependencies": { - "dep_a": "^1.5.0", - "dep_b": "1.6.3", - "dep_c": "~1.7.0" - } -} diff --git a/test/fixtures/check/single-group-two-apps-dependencies-valid/config_fixture.json b/test/fixtures/check/single-group-two-apps-dependencies-valid/config_fixture.json deleted file mode 100644 index 2401bc6..0000000 --- a/test/fixtures/check/single-group-two-apps-dependencies-valid/config_fixture.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "a": { - "applications": ["application_a"], - "dependencies": { - "public": { - "dependencySemvers": { - "dep_a": { - "dateAdded": 1560081600000, - "semver": "dep_a@1.x" - }, - "dep_b": { - "dateAdded": 1560081600000, - "semver": "dep_b@1.x" - } - }, - "gracePeriod": Infinity - }, - "private": { - "dependencySemvers": { - "dep_c": { - "dateAdded": 1560081600000, - "semver": "dep_c@1.x" - } - }, - "gracePeriod": Infinity - } - } - } -}