[7.17] Add node scripts/yarn_deduplicate check (#169165) (#203043)

# Backport

This will backport the following commits from `main` to `7.17`:
- [[ci] Add node scripts/yarn_deduplicate check
(main)(#169165)](https://github.com/elastic/kibana/pull/169165)

---------

Co-authored-by: Jon <jon@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Brad White 2024-12-05 14:35:34 -07:00 committed by GitHub
parent e10060a559
commit 232eb0fe1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 2080 additions and 7289 deletions

View file

@ -22,3 +22,4 @@ export DISABLE_BOOTSTRAP_VALIDATION=false
.buildkite/scripts/steps/checks/test_projects.sh
.buildkite/scripts/steps/checks/test_hardening.sh
.buildkite/scripts/steps/checks/prettier_topology.sh
.buildkite/scripts/steps/checks/yarn_deduplicate.sh

View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
source .buildkite/scripts/common/util.sh
echo "--- Check yarn.lock for duplicated modules"
node scripts/yarn_deduplicate && yarn kbn bootstrap
check_for_changed_files 'node scripts/yarn_deduplicate' true 'TO FIX: Run node '"'"'scripts/yarn_deduplicate && yarn kbn bootstrap'"'"' locally, or add an exception to src/dev/yarn_deduplicate/index.ts and then commit the changes and push to your branch'

View file

@ -834,6 +834,7 @@
"xml-crypto": "^6.0.0",
"xmlbuilder": "13.0.2",
"yargs": "^15.4.1",
"yarn-deduplicate": "^6.0.2",
"zlib": "^1.0.5"
},
"packageManager": "yarn@1.22.21"

View file

@ -13,7 +13,7 @@ pageLoadAssetSize:
core: 435325
crossClusterReplication: 65408
customIntegrations: 28810
dashboard: 186763
dashboard: 218038
dashboardEnhanced: 65646
dashboardMode: 22716
data: 491273

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
require('../src/setup_node_env');
require('../src/dev/yarn_deduplicate');

View file

@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { resolve } from 'path';
import { writeFileSync, readFileSync } from 'fs';
import { fixDuplicates } from 'yarn-deduplicate';
import { REPO_ROOT } from '@kbn/utils';
const yarnLockFile = resolve(REPO_ROOT, 'yarn.lock');
const yarnLock = readFileSync(yarnLockFile, 'utf-8');
const output = fixDuplicates(yarnLock, {
useMostCommon: false,
excludeScopes: ['@types'],
excludePackages: ['axe-core', '@babel/types', 'classnames', 'csstype', 'yaml'],
});
writeFileSync(yarnLockFile, output);

1058
yarn.lock

File diff suppressed because it is too large Load diff