Skip to content

Commit

Permalink
move validation to bootstrap (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: spalger <[email protected]>
  • Loading branch information
Spencer and spalger authored Sep 30, 2020
1 parent aca6579 commit ba26357
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 134 deletions.
51 changes: 51 additions & 0 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37906,6 +37906,57 @@ async function validateYarnLock(kbn, yarnLock) {

`);
process.exit(1);
} // look through all the package.json files to find packages which have mismatched version ranges


const depRanges = new Map();

for (const project of kbn.getAllProjects().values()) {
for (const [dep, range] of Object.entries(project.allDependencies)) {
const existingDep = depRanges.get(dep);

if (!existingDep) {
depRanges.set(dep, [{
range,
projects: [project]
}]);
continue;
}

const existingRange = existingDep.find(existing => existing.range === range);

if (!existingRange) {
existingDep.push({
range,
projects: [project]
});
continue;
}

existingRange.projects.push(project);
}
}

const duplicateRanges = Array.from(depRanges.entries()).filter(([, ranges]) => ranges.length > 1).reduce((acc, [dep, ranges]) => [...acc, dep, ...ranges.map(({
range,
projects
}) => ` ${range} => ${projects.map(p => p.name).join(', ')}`)], []).join('\n ');

if (duplicateRanges) {
_log__WEBPACK_IMPORTED_MODULE_3__["log"].error(dedent__WEBPACK_IMPORTED_MODULE_1___default.a`

[single_version_dependencies] Multiple version ranges for the same dependency
were found declared across different package.json files. Please consolidate
those to match across all package.json files. Different versions for the
same dependency is not supported.

If you have questions about this please reach out to the operations team.

The conflicting dependencies are:

${duplicateRanges}
`);
process.exit(1);
}

_log__WEBPACK_IMPORTED_MODULE_3__["log"].success('yarn.lock analysis completed without any issues');
Expand Down
61 changes: 61 additions & 0 deletions packages/kbn-pm/src/utils/validate_yarn_lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { writeFile } from './fs';
import { Kibana } from './kibana';
import { YarnLock } from './yarn_lock';
import { log } from './log';
import { Project } from './project';

export async function validateYarnLock(kbn: Kibana, yarnLock: YarnLock) {
// look through all of the packages in the yarn.lock file to see if
Expand Down Expand Up @@ -95,5 +96,65 @@ export async function validateYarnLock(kbn: Kibana, yarnLock: YarnLock) {
process.exit(1);
}

// look through all the package.json files to find packages which have mismatched version ranges
const depRanges = new Map<string, Array<{ range: string; projects: Project[] }>>();
for (const project of kbn.getAllProjects().values()) {
for (const [dep, range] of Object.entries(project.allDependencies)) {
const existingDep = depRanges.get(dep);
if (!existingDep) {
depRanges.set(dep, [
{
range,
projects: [project],
},
]);
continue;
}

const existingRange = existingDep.find((existing) => existing.range === range);
if (!existingRange) {
existingDep.push({
range,
projects: [project],
});
continue;
}

existingRange.projects.push(project);
}
}

const duplicateRanges = Array.from(depRanges.entries())
.filter(([, ranges]) => ranges.length > 1)
.reduce(
(acc: string[], [dep, ranges]) => [
...acc,
dep,
...ranges.map(
({ range, projects }) => ` ${range} => ${projects.map((p) => p.name).join(', ')}`
),
],
[]
)
.join('\n ');

if (duplicateRanges) {
log.error(dedent`
[single_version_dependencies] Multiple version ranges for the same dependency
were found declared across different package.json files. Please consolidate
those to match across all package.json files. Different versions for the
same dependency is not supported.
If you have questions about this please reach out to the operations team.
The conflicting dependencies are:
${duplicateRanges}
`);

process.exit(1);
}

log.success('yarn.lock analysis completed without any issues');
}
21 changes: 0 additions & 21 deletions scripts/check_single_version_dependencies.js

This file was deleted.

105 changes: 0 additions & 105 deletions src/dev/run_check_single_version_dependencies.ts

This file was deleted.

7 changes: 0 additions & 7 deletions test/scripts/checks/single_version_dependencies.sh

This file was deleted.

1 change: 0 additions & 1 deletion vars/tasks.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def check() {
kibanaPipeline.scriptTask('Check File Casing', 'test/scripts/checks/file_casing.sh'),
kibanaPipeline.scriptTask('Check Lockfile Symlinks', 'test/scripts/checks/lock_file_symlinks.sh'),
kibanaPipeline.scriptTask('Check Licenses', 'test/scripts/checks/licenses.sh'),
kibanaPipeline.scriptTask('Check Single Version Dependencies', 'test/scripts/checks/single_version_dependencies.sh'),
kibanaPipeline.scriptTask('Verify Dependency Versions', 'test/scripts/checks/verify_dependency_versions.sh'),
kibanaPipeline.scriptTask('Verify NOTICE', 'test/scripts/checks/verify_notice.sh'),
kibanaPipeline.scriptTask('Test Projects', 'test/scripts/checks/test_projects.sh'),
Expand Down

0 comments on commit ba26357

Please sign in to comment.