[kbn/pm] sort package.json in bootstrap (#118805)

This commit is contained in:
Spencer 2021-11-16 15:41:59 -08:00 committed by GitHub
parent 10c5318c3d
commit 96ec161569
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 1766 additions and 1026 deletions

View file

@ -16,12 +16,14 @@ is_pr() {
verify_no_git_changes() {
RED='\033[0;31m'
YELLOW='\033[0;33m'
C_RESET='\033[0m' # Reset color
GIT_CHANGES="$(git ls-files --modified -- . ':!:.bazelrc')"
if [ "$GIT_CHANGES" ]; then
echo -e "\n${RED}ERROR: '$1' caused changes to the following files:${C_RESET}\n"
echo -e "$GIT_CHANGES\n"
echo -e "\n${YELLOW}TO FIX: Run '$1' locally, commit the changes and push to your branch${C_RESET}\n"
exit 1
fi
}

View file

@ -37,44 +37,47 @@
},
"author": "Rashid Khan <rashid.khan@elastic.co>",
"scripts": {
"backport-skip-ci": "backport --prDescription \"[skip-ci]\"",
"bazel": "bazel",
"preinstall": "node ./preinstall_check",
"kbn": "node scripts/kbn",
"es": "node scripts/es",
"test:jest": "node scripts/jest",
"test:jest_integration": "node scripts/jest_integration",
"test:ftr": "node scripts/functional_tests",
"test:ftr:server": "node scripts/functional_tests_server",
"test:ftr:runner": "node scripts/functional_test_runner",
"checkLicenses": "node scripts/check_licenses --dev",
"build": "node scripts/build --all-platforms",
"build:apidocs": "node scripts/build_api_docs",
"start": "node scripts/kibana --dev",
"build:types": "rm -rf ./target/types && tsc --p tsconfig.types.json",
"checkLicenses": "node scripts/check_licenses --dev",
"cover:functional:merge": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report/functional --reporter=json-summary",
"cover:report": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report --reporter=lcov && open ./target/coverage/report/lcov-report/index.html",
"debug": "node --nolazy --inspect scripts/kibana --dev",
"debug-break": "node --nolazy --inspect-brk scripts/kibana --dev",
"docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
"es": "node scripts/es",
"preinstall": "node ./preinstall_check",
"postinstall": "node scripts/kbn patch_native_modules",
"kbn": "node scripts/kbn",
"lint": "yarn run lint:es && yarn run lint:style",
"lint:es": "node scripts/eslint",
"lint:style": "node scripts/stylelint",
"makelogs": "node scripts/makelogs",
"build:types": "rm -rf ./target/types && tsc --p tsconfig.types.json",
"docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
"spec_to_console": "node scripts/spec_to_console",
"backport-skip-ci": "backport --prDescription \"[skip-ci]\"",
"start": "node scripts/kibana --dev",
"storybook": "node scripts/storybook",
"cover:report": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report --reporter=lcov && open ./target/coverage/report/lcov-report/index.html",
"cover:functional:merge": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report/functional --reporter=json-summary",
"postinstall": "node scripts/kbn patch_native_modules"
"test:ftr": "node scripts/functional_tests",
"test:ftr:runner": "node scripts/functional_test_runner",
"test:ftr:server": "node scripts/functional_tests_server",
"test:jest": "node scripts/jest",
"test:jest_integration": "node scripts/jest_integration"
},
"repository": {
"type": "git",
"url": "https://github.com/elastic/kibana.git"
},
"engines": {
"node": "16.13.0",
"yarn": "^1.21.1"
},
"resolutions": {
"**/@types/node": "16.10.2",
"**/chokidar": "^3.4.3",
"**/deepmerge": "^4.2.2",
"**/fast-deep-equal": "^3.1.1",
"globby/fast-glob": "3.2.5",
"**/hoist-non-react-statics": "^3.3.2",
"**/isomorphic-fetch/node-fetch": "^2.6.1",
"**/istanbul-instrumenter-loader/schema-utils": "1.0.0",
@ -85,11 +88,8 @@
"**/react-syntax-highlighter/**/highlight.js": "^10.4.1",
"**/trim": "1.0.1",
"**/typescript": "4.1.3",
"**/underscore": "^1.13.1"
},
"engines": {
"node": "16.13.0",
"yarn": "^1.21.1"
"**/underscore": "^1.13.1",
"globby/fast-glob": "3.2.5"
},
"dependencies": {
"@babel/runtime": "^7.16.3",
@ -792,6 +792,7 @@
"shelljs": "^0.8.4",
"simple-git": "1.116.0",
"sinon": "^7.4.2",
"sort-package-json": "^1.53.1",
"spawn-sync": "^1.0.15",
"string-replace-loader": "^2.2.0",
"strong-log-transformer": "^2.1.0",
@ -828,4 +829,4 @@
"yargs": "^15.4.1",
"zlib": "^1.0.5"
}
}
}

File diff suppressed because one or more lines are too long

View file

@ -15,6 +15,7 @@ import { linkProjectExecutables } from '../utils/link_project_executables';
import { getNonBazelProjectsOnly, topologicallyBatchProjects } from '../utils/projects';
import { ICommand } from './';
import { readYarnLock } from '../utils/yarn_lock';
import { sortPackageJson } from '../utils/sort_package_json';
import { validateDependencies } from '../utils/validate_dependencies';
import {
ensureYarnIntegrityFileExists,
@ -107,6 +108,8 @@ export const BootstrapCommand: ICommand = {
}
}
await sortPackageJson(kbn);
const yarnLock = await readYarnLock(kbn);
if (options.validate) {

View file

@ -0,0 +1,47 @@
/*
* 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 Fs from 'fs/promises';
import sorter from 'sort-package-json';
import { Kibana } from './kibana';
export async function sortPackageJson(kbn: Kibana) {
const packageJsonPath = kbn.getAbsolute('package.json');
const packageJson = await Fs.readFile(packageJsonPath, 'utf-8');
await Fs.writeFile(
packageJsonPath,
JSON.stringify(
sorter(JSON.parse(packageJson), {
// top level keys in the order they were written when this was implemented
sortOrder: [
'name',
'description',
'keywords',
'private',
'version',
'branch',
'types',
'tsdocMetadata',
'build',
'homepage',
'bugs',
'kibana',
'author',
'scripts',
'repository',
'engines',
'resolutions',
],
}),
null,
2
)
);
}

View file

@ -11932,6 +11932,11 @@ detect-indent@^5.0.0:
resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d"
integrity sha1-OHHMCmoALow+Wzz38zYmRnXwa50=
detect-indent@^6.0.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.1.0.tgz#592485ebbbf6b3b1ab2be175c8393d04ca0d57e6"
integrity sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==
detect-libc@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"
@ -11942,7 +11947,7 @@ detect-newline@2.X:
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2"
integrity sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=
detect-newline@^3.0.0:
detect-newline@3.1.0, detect-newline@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==
@ -14691,6 +14696,11 @@ gifwrap@^0.9.2:
image-q "^1.1.1"
omggif "^1.0.10"
git-hooks-list@1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/git-hooks-list/-/git-hooks-list-1.0.3.tgz#be5baaf78203ce342f2f844a9d2b03dba1b45156"
integrity sha512-Y7wLWcrLUXwk2noSka166byGCvhMtDRpgHdzCno1UQv/n/Hegp++a2xBWJL1lJarnKD3SWaljD+0z1ztqxuKyQ==
github-from-package@0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce"
@ -14904,6 +14914,20 @@ globalthis@^1.0.0:
dependencies:
define-properties "^1.1.3"
globby@10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.0.tgz#abfcd0630037ae174a88590132c2f6804e291072"
integrity sha512-3LifW9M4joGZasyYPz2A1U74zbC/45fvpXUvO/9KbSa+VV0aGZarWkfdgKyR9sExNP0t0x0ss/UMJpNpcaTspw==
dependencies:
"@types/glob" "^7.1.1"
array-union "^2.1.0"
dir-glob "^3.0.1"
fast-glob "^3.0.3"
glob "^7.1.3"
ignore "^5.1.1"
merge2 "^1.2.3"
slash "^3.0.0"
globby@11.0.1:
version "11.0.1"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.1.tgz#9a2bf107a068f3ffeabc49ad702c79ede8cfd357"
@ -16718,16 +16742,16 @@ is-path-inside@^3.0.1, is-path-inside@^3.0.2:
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.2.tgz#f5220fc82a3e233757291dddc9c5877f2a1f3017"
integrity sha512-/2UGPSgmtqwo1ktx8NDHjuPwZWmHhO+gj0f93EkhLB5RgW9RZevWYYlIkS6zePc6U2WpOdQYIwHe9YC4DWEBVg==
is-plain-obj@2.1.0, is-plain-obj@^2.0.0, is-plain-obj@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287"
integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==
is-plain-obj@^1.0.0, is-plain-obj@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e"
integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4=
is-plain-obj@^2.0.0, is-plain-obj@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287"
integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==
is-plain-object@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.0.tgz#47bfc5da1b5d50d64110806c199359482e75a928"
@ -25588,6 +25612,23 @@ sort-keys@^2.0.0:
dependencies:
is-plain-obj "^1.0.0"
sort-object-keys@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/sort-object-keys/-/sort-object-keys-1.1.3.tgz#bff833fe85cab147b34742e45863453c1e190b45"
integrity sha512-855pvK+VkU7PaKYPc+Jjnmt4EzejQHyhhF33q31qG8x7maDzkeFhAAThdCYay11CISO+qAMwjOBP+fPZe0IPyg==
sort-package-json@^1.53.1:
version "1.53.1"
resolved "https://registry.yarnpkg.com/sort-package-json/-/sort-package-json-1.53.1.tgz#8f2672b06314cf04d9a6bcefc75a5f38d600b811"
integrity sha512-ltLORrQuuPMpy23YkWCA8fO7zBOxM4P1j9LcGxci4K2Fk8jmSyCA/ATU6CFyy8qR2HQRx4RBYWzoi78FU/Anuw==
dependencies:
detect-indent "^6.0.0"
detect-newline "3.1.0"
git-hooks-list "1.0.3"
globby "10.0.0"
is-plain-obj "2.1.0"
sort-object-keys "^1.1.3"
source-list-map@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34"