diff --git a/scripts/yarn_deduplicate.js b/scripts/yarn_deduplicate.js new file mode 100644 index 0000000000000..2e524d6217b34 --- /dev/null +++ b/scripts/yarn_deduplicate.js @@ -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'); diff --git a/src/dev/yarn_deduplicate/index.ts b/src/dev/yarn_deduplicate/index.ts new file mode 100644 index 0000000000000..5c355d5156544 --- /dev/null +++ b/src/dev/yarn_deduplicate/index.ts @@ -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'], +}); + +writeFileSync(yarnLockFile, output);