From 8e6295e989e76167575d3c2976470d7416be7db9 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Fri, 7 Jun 2024 13:19:08 +0200 Subject: [PATCH] chore: use `workspace:` protocol for workspace dependencies Closes #10547 Signed-off-by: Jon Koops --- GETTING-STARTED.md | 4 - package.json | 6 +- packages/react-charts/package.json | 4 +- packages/react-code-editor/package.json | 6 +- packages/react-core/package.json | 6 +- packages/react-docs/package.json | 18 ++--- packages/react-drag-drop/package.json | 6 +- .../demo-app-ts/package.json | 2 +- packages/react-table/package.json | 8 +- packages/react-templates/package.json | 8 +- scripts/verifyPatternflyVersions.js | 75 ------------------ yarn.lock | 76 +++++++++---------- 12 files changed, 69 insertions(+), 150 deletions(-) delete mode 100644 scripts/verifyPatternflyVersions.js diff --git a/GETTING-STARTED.md b/GETTING-STARTED.md index 1b12f973a3c..abd574d3573 100644 --- a/GETTING-STARTED.md +++ b/GETTING-STARTED.md @@ -38,7 +38,3 @@ PatternFly React has 3 linters you can run all at once using `yarn lint:all`. Th ### ESLint ESLint is run on .js, .jsx, .ts, and .tsx files. It uses the [@typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) parser with custom config added over the years. We write some of our own ESLint rules in `eslint-plugin-patternfly-react`. You can run this linter with `yarn lint:ts` or on specific files with `yarn lint `. - -### Version lint - -The `@patternfly` version linter is run on all `package.json` files to ensure that versions of all `@patternfly/*` packages match. This is done to prevent mismatching versions of essential PatternFly packages from accidentally being published. You can run this linter with `yarn lint:versions`. diff --git a/package.json b/package.json index 0a6cac9a93b..76a0cf36b06 100644 --- a/package.json +++ b/package.json @@ -88,10 +88,9 @@ "clean:exports": "lerna run clean:exports --parallel --stream", "generate": "yarn plop", "lint": "eslint --ext js,jsx,ts,tsx --cache --cache-strategy content", - "lint:all": "yarn lint:md && yarn lint:versions && yarn lint:ts", + "lint:all": "yarn lint:md && yarn lint:ts", "lint:md": "yarn eslint packages --ext md --no-eslintrc --config .eslintrc-md.json --cache --cache-strategy content", "lint:ts": "yarn lint packages/*/src", - "lint:versions": "node scripts/verifyPatternflyVersions.js", "lint:tests": "yarn lint packages/*/src/components/*/__tests__/*.test.*", "prepare": "ts-patch install -s", "serve:docs": "yarn workspace @patternfly/react-docs serve", @@ -113,8 +112,7 @@ }, "lint-staged": { "*.md": "yarn lint:md --fix", - "*.{js,jsx,ts,tsx}": "yarn lint --fix", - "*.json": "yarn lint:versions --fix" + "*.{js,jsx,ts,tsx}": "yarn lint --fix" }, "workspaces": { "packages": [ diff --git a/packages/react-charts/package.json b/packages/react-charts/package.json index 3d16329eab5..703f6345480 100644 --- a/packages/react-charts/package.json +++ b/packages/react-charts/package.json @@ -28,8 +28,8 @@ }, "homepage": "https://github.com/patternfly/patternfly-react#readme", "dependencies": { - "@patternfly/react-styles": "^5.4.0-prerelease.6", - "@patternfly/react-tokens": "^5.4.0-prerelease.5", + "@patternfly/react-styles": "workspace:^", + "@patternfly/react-tokens": "workspace:^", "hoist-non-react-statics": "^3.3.2", "lodash": "^4.17.21", "tslib": "^2.6.2", diff --git a/packages/react-code-editor/package.json b/packages/react-code-editor/package.json index 7e97f18f449..fff35d39c48 100644 --- a/packages/react-code-editor/package.json +++ b/packages/react-code-editor/package.json @@ -30,9 +30,9 @@ }, "dependencies": { "@monaco-editor/react": "^4.6.0", - "@patternfly/react-core": "^5.4.0-prerelease.15", - "@patternfly/react-icons": "^5.4.0-prerelease.5", - "@patternfly/react-styles": "^5.4.0-prerelease.6", + "@patternfly/react-core": "workspace:^", + "@patternfly/react-icons": "workspace:^", + "@patternfly/react-styles": "workspace:^", "react-dropzone": "14.2.3", "tslib": "^2.6.2" }, diff --git a/packages/react-core/package.json b/packages/react-core/package.json index 19d4531da43..cf45a3b380c 100644 --- a/packages/react-core/package.json +++ b/packages/react-core/package.json @@ -46,9 +46,9 @@ "clean:exports": "node scripts/cleanDistExports.js" }, "dependencies": { - "@patternfly/react-icons": "^5.4.0-prerelease.5", - "@patternfly/react-styles": "^5.4.0-prerelease.6", - "@patternfly/react-tokens": "^5.4.0-prerelease.5", + "@patternfly/react-icons": "workspace:^", + "@patternfly/react-styles": "workspace:^", + "@patternfly/react-tokens": "workspace:^", "focus-trap": "7.5.4", "react-dropzone": "^14.2.3", "tslib": "^2.6.2" diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json index 43bcb76b145..e3ba1a2c1aa 100644 --- a/packages/react-docs/package.json +++ b/packages/react-docs/package.json @@ -23,15 +23,15 @@ }, "dependencies": { "@patternfly/patternfly": "5.4.0-prerelease.3", - "@patternfly/react-charts": "^7.4.0-prerelease.11", - "@patternfly/react-code-editor": "^5.4.0-prerelease.17", - "@patternfly/react-core": "^5.4.0-prerelease.15", - "@patternfly/react-drag-drop": "^5.4.0-prerelease.16", - "@patternfly/react-icons": "^5.4.0-prerelease.5", - "@patternfly/react-styles": "^5.4.0-prerelease.6", - "@patternfly/react-table": "^5.4.0-prerelease.16", - "@patternfly/react-templates": "^1.1.0-prerelease.15", - "@patternfly/react-tokens": "^5.4.0-prerelease.5" + "@patternfly/react-charts": "workspace:^", + "@patternfly/react-code-editor": "workspace:^", + "@patternfly/react-core": "workspace:^", + "@patternfly/react-drag-drop": "workspace:^", + "@patternfly/react-icons": "workspace:^", + "@patternfly/react-styles": "workspace:^", + "@patternfly/react-table": "workspace:^", + "@patternfly/react-templates": "workspace:^", + "@patternfly/react-tokens": "workspace:^" }, "devDependencies": { "@patternfly/documentation-framework": "^5.16.4", diff --git a/packages/react-drag-drop/package.json b/packages/react-drag-drop/package.json index acbe6214301..46cb872c8e0 100644 --- a/packages/react-drag-drop/package.json +++ b/packages/react-drag-drop/package.json @@ -32,9 +32,9 @@ "@dnd-kit/core": "^6.1.0", "@dnd-kit/modifiers": "^6.0.1", "@dnd-kit/sortable": "^7.0.2", - "@patternfly/react-core": "^5.4.0-prerelease.15", - "@patternfly/react-icons": "^5.4.0-prerelease.5", - "@patternfly/react-styles": "^5.4.0-prerelease.6", + "@patternfly/react-core": "workspace:^", + "@patternfly/react-icons": "workspace:^", + "@patternfly/react-styles": "workspace:^", "memoize-one": "^5.1.0", "resize-observer-polyfill": "^1.5.1" }, diff --git a/packages/react-integration/demo-app-ts/package.json b/packages/react-integration/demo-app-ts/package.json index 3a0fd121182..911ec4fb64b 100644 --- a/packages/react-integration/demo-app-ts/package.json +++ b/packages/react-integration/demo-app-ts/package.json @@ -9,7 +9,7 @@ "preview": "vite preview --port 3000" }, "dependencies": { - "@patternfly/react-core": "^5.4.0-prerelease.15", + "@patternfly/react-core": "workspace:^", "react": "^18.3.1", "react-dom": "^18.3.1", "react-router": "^5.3.4", diff --git a/packages/react-table/package.json b/packages/react-table/package.json index 1e0bec52c8b..cdb19b46028 100644 --- a/packages/react-table/package.json +++ b/packages/react-table/package.json @@ -39,10 +39,10 @@ "subpaths": "node ../../scripts/exportSubpaths.js --config subpaths.config.json" }, "dependencies": { - "@patternfly/react-core": "^5.4.0-prerelease.15", - "@patternfly/react-icons": "^5.4.0-prerelease.5", - "@patternfly/react-styles": "^5.4.0-prerelease.6", - "@patternfly/react-tokens": "^5.4.0-prerelease.5", + "@patternfly/react-core": "workspace:^", + "@patternfly/react-icons": "workspace:^", + "@patternfly/react-styles": "workspace:^", + "@patternfly/react-tokens": "workspace:^", "lodash": "^4.17.21", "tslib": "^2.6.2" }, diff --git a/packages/react-templates/package.json b/packages/react-templates/package.json index 96aa9883d1c..99d1c693736 100644 --- a/packages/react-templates/package.json +++ b/packages/react-templates/package.json @@ -33,10 +33,10 @@ "subpaths": "node ../../scripts/exportSubpaths.js --config subpaths.config.json" }, "dependencies": { - "@patternfly/react-core": "^5.4.0-prerelease.15", - "@patternfly/react-icons": "^5.4.0-prerelease.5", - "@patternfly/react-styles": "^5.4.0-prerelease.6", - "@patternfly/react-tokens": "^5.4.0-prerelease.5", + "@patternfly/react-core": "workspace:^", + "@patternfly/react-icons": "workspace:^", + "@patternfly/react-styles": "workspace:^", + "@patternfly/react-tokens": "workspace:^", "tslib": "^2.6.2" }, "peerDependencies": { diff --git a/scripts/verifyPatternflyVersions.js b/scripts/verifyPatternflyVersions.js deleted file mode 100644 index d9860dc24a1..00000000000 --- a/scripts/verifyPatternflyVersions.js +++ /dev/null @@ -1,75 +0,0 @@ -/* eslint-disable no-console */ -const semver = require('semver'); -const { detectProjects } = require("lerna/utils"); - -// '@patternfly/patternfly': {'4.0.4': ['@patternfly/react-styles', ...]}, -// '@patternfly/react-core': {'^4.0.3': ['@patternfly/react-docs', ...]] -const patternflyDeps = {}; -const otherDeps = ['typescript', 'tslib']; - -async function accumulateDependencies(package, dependencies) { - if (!dependencies) { - return; - } - Object.entries(dependencies) - .filter(([dep, _version]) => dep.startsWith('@patternfly') || otherDeps.includes(dep)) - .forEach(([dep, version]) => { - patternflyDeps[dep] = patternflyDeps[dep] || {}; - patternflyDeps[dep][version] = patternflyDeps[dep][version] || []; - patternflyDeps[dep][version].push(package); - }); -} - -function setDependency(dependencies, package, version) { - if (dependencies && dependencies[package]) { - dependencies[package] = version; - } -} - -async function verifyPatternflyVersions() { - const { projectGraph, projectFileMap } = await detectProjects(); - Object.values(projectGraph.nodes).forEach((node) => { - const package = node.package; - accumulateDependencies(package.name, { [package.name]: `^${package.version}` }); - accumulateDependencies(package.name, package.dependencies); - accumulateDependencies(package.name, package.devDependencies); - }); - - let failed = false; - const mismatchedVersions = Object.entries(patternflyDeps).filter( - ([_dep, versions]) => Object.keys(versions).length > 1 - ); - - mismatchedVersions.forEach(([dep, versions]) => { - failed = true; - console.error(`Mismatching versions for ${dep}:`); - Object.entries(versions).forEach(([version, packages]) => console.error(`${version}: ${packages.join(' ')}`)); - }); - - if (process.argv[2] === '--fix') { - mismatchedVersions.forEach(([dep, versions]) => { - const highestVersion = Object.keys(versions) - .sort((a, b) => semver.compare(a.replace(/^\^/, ''), b.replace(/^\^/, ''))) - .pop(); - Object.keys(versions) - .filter((version) => version !== highestVersion) - .map((version) => versions[version]) - .forEach((mismatchedPackages) => { - console.log(`Writing ${dep}@${highestVersion}:`); - mismatchedPackages - .map((package) => projectGraph.nodes[package]) - .forEach((package) => { - console.log(package.package.manifestLocation); - setDependency(package.package.dependencies, dep, highestVersion); - setDependency(package.package.devDependencies, dep, highestVersion); - package.package.serialize(); - }); - }); - }); - } else if (failed) { - console.error('\nRun script again with --fix to bump to latest version'); - process.exit(1); - } -} - -verifyPatternflyVersions(); diff --git a/yarn.lock b/yarn.lock index 45fe8415f34..b5fd3a5e22f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3076,12 +3076,12 @@ __metadata: languageName: node linkType: hard -"@patternfly/react-charts@npm:^7.4.0-prerelease.11, @patternfly/react-charts@workspace:packages/react-charts": +"@patternfly/react-charts@workspace:^, @patternfly/react-charts@workspace:packages/react-charts": version: 0.0.0-use.local resolution: "@patternfly/react-charts@workspace:packages/react-charts" dependencies: - "@patternfly/react-styles": "npm:^5.4.0-prerelease.6" - "@patternfly/react-tokens": "npm:^5.4.0-prerelease.5" + "@patternfly/react-styles": "workspace:^" + "@patternfly/react-tokens": "workspace:^" "@types/lodash": "npm:^4.17.4" css: "npm:^2.2.4" fs-extra: "npm:^11.2.0" @@ -3111,14 +3111,14 @@ __metadata: languageName: unknown linkType: soft -"@patternfly/react-code-editor@npm:^5.4.0-prerelease.17, @patternfly/react-code-editor@workspace:packages/react-code-editor": +"@patternfly/react-code-editor@workspace:^, @patternfly/react-code-editor@workspace:packages/react-code-editor": version: 0.0.0-use.local resolution: "@patternfly/react-code-editor@workspace:packages/react-code-editor" dependencies: "@monaco-editor/react": "npm:^4.6.0" - "@patternfly/react-core": "npm:^5.4.0-prerelease.15" - "@patternfly/react-icons": "npm:^5.4.0-prerelease.5" - "@patternfly/react-styles": "npm:^5.4.0-prerelease.6" + "@patternfly/react-core": "workspace:^" + "@patternfly/react-icons": "workspace:^" + "@patternfly/react-styles": "workspace:^" monaco-editor: "npm:^0.49.0" react-dropzone: "npm:14.2.3" tslib: "npm:^2.6.2" @@ -3128,14 +3128,14 @@ __metadata: languageName: unknown linkType: soft -"@patternfly/react-core@npm:^5.4.0-prerelease.15, @patternfly/react-core@workspace:packages/react-core": +"@patternfly/react-core@workspace:^, @patternfly/react-core@workspace:packages/react-core": version: 0.0.0-use.local resolution: "@patternfly/react-core@workspace:packages/react-core" dependencies: "@patternfly/patternfly": "npm:5.4.0-prerelease.3" - "@patternfly/react-icons": "npm:^5.4.0-prerelease.5" - "@patternfly/react-styles": "npm:^5.4.0-prerelease.6" - "@patternfly/react-tokens": "npm:^5.4.0-prerelease.5" + "@patternfly/react-icons": "workspace:^" + "@patternfly/react-styles": "workspace:^" + "@patternfly/react-tokens": "workspace:^" css: "npm:^2.2.4" focus-trap: "npm:7.5.4" fs-extra: "npm:^11.2.0" @@ -3154,28 +3154,28 @@ __metadata: "@patternfly/documentation-framework": "npm:^5.16.4" "@patternfly/patternfly": "npm:5.4.0-prerelease.3" "@patternfly/patternfly-a11y": "npm:4.3.1" - "@patternfly/react-charts": "npm:^7.4.0-prerelease.11" - "@patternfly/react-code-editor": "npm:^5.4.0-prerelease.17" - "@patternfly/react-core": "npm:^5.4.0-prerelease.15" - "@patternfly/react-drag-drop": "npm:^5.4.0-prerelease.16" - "@patternfly/react-icons": "npm:^5.4.0-prerelease.5" - "@patternfly/react-styles": "npm:^5.4.0-prerelease.6" - "@patternfly/react-table": "npm:^5.4.0-prerelease.16" - "@patternfly/react-templates": "npm:^1.1.0-prerelease.15" - "@patternfly/react-tokens": "npm:^5.4.0-prerelease.5" + "@patternfly/react-charts": "workspace:^" + "@patternfly/react-code-editor": "workspace:^" + "@patternfly/react-core": "workspace:^" + "@patternfly/react-drag-drop": "workspace:^" + "@patternfly/react-icons": "workspace:^" + "@patternfly/react-styles": "workspace:^" + "@patternfly/react-table": "workspace:^" + "@patternfly/react-templates": "workspace:^" + "@patternfly/react-tokens": "workspace:^" languageName: unknown linkType: soft -"@patternfly/react-drag-drop@npm:^5.4.0-prerelease.16, @patternfly/react-drag-drop@workspace:packages/react-drag-drop": +"@patternfly/react-drag-drop@workspace:^, @patternfly/react-drag-drop@workspace:packages/react-drag-drop": version: 0.0.0-use.local resolution: "@patternfly/react-drag-drop@workspace:packages/react-drag-drop" dependencies: "@dnd-kit/core": "npm:^6.1.0" "@dnd-kit/modifiers": "npm:^6.0.1" "@dnd-kit/sortable": "npm:^7.0.2" - "@patternfly/react-core": "npm:^5.4.0-prerelease.15" - "@patternfly/react-icons": "npm:^5.4.0-prerelease.5" - "@patternfly/react-styles": "npm:^5.4.0-prerelease.6" + "@patternfly/react-core": "workspace:^" + "@patternfly/react-icons": "workspace:^" + "@patternfly/react-styles": "workspace:^" memoize-one: "npm:^5.1.0" resize-observer-polyfill: "npm:^1.5.1" peerDependencies: @@ -3184,7 +3184,7 @@ __metadata: languageName: unknown linkType: soft -"@patternfly/react-icons@npm:^5.4.0-prerelease.5, @patternfly/react-icons@workspace:packages/react-icons": +"@patternfly/react-icons@workspace:^, @patternfly/react-icons@workspace:packages/react-icons": version: 0.0.0-use.local resolution: "@patternfly/react-icons@workspace:packages/react-icons" dependencies: @@ -3265,7 +3265,7 @@ __metadata: languageName: unknown linkType: soft -"@patternfly/react-styles@npm:^5.4.0-prerelease.6, @patternfly/react-styles@workspace:packages/react-styles": +"@patternfly/react-styles@workspace:^, @patternfly/react-styles@workspace:packages/react-styles": version: 0.0.0-use.local resolution: "@patternfly/react-styles@workspace:packages/react-styles" dependencies: @@ -3277,14 +3277,14 @@ __metadata: languageName: unknown linkType: soft -"@patternfly/react-table@npm:^5.4.0-prerelease.16, @patternfly/react-table@workspace:packages/react-table": +"@patternfly/react-table@workspace:^, @patternfly/react-table@workspace:packages/react-table": version: 0.0.0-use.local resolution: "@patternfly/react-table@workspace:packages/react-table" dependencies: - "@patternfly/react-core": "npm:^5.4.0-prerelease.15" - "@patternfly/react-icons": "npm:^5.4.0-prerelease.5" - "@patternfly/react-styles": "npm:^5.4.0-prerelease.6" - "@patternfly/react-tokens": "npm:^5.4.0-prerelease.5" + "@patternfly/react-core": "workspace:^" + "@patternfly/react-icons": "workspace:^" + "@patternfly/react-styles": "workspace:^" + "@patternfly/react-tokens": "workspace:^" lodash: "npm:^4.17.21" tslib: "npm:^2.6.2" peerDependencies: @@ -3293,14 +3293,14 @@ __metadata: languageName: unknown linkType: soft -"@patternfly/react-templates@npm:^1.1.0-prerelease.15, @patternfly/react-templates@workspace:packages/react-templates": +"@patternfly/react-templates@workspace:^, @patternfly/react-templates@workspace:packages/react-templates": version: 0.0.0-use.local resolution: "@patternfly/react-templates@workspace:packages/react-templates" dependencies: - "@patternfly/react-core": "npm:^5.4.0-prerelease.15" - "@patternfly/react-icons": "npm:^5.4.0-prerelease.5" - "@patternfly/react-styles": "npm:^5.4.0-prerelease.6" - "@patternfly/react-tokens": "npm:^5.4.0-prerelease.5" + "@patternfly/react-core": "workspace:^" + "@patternfly/react-icons": "workspace:^" + "@patternfly/react-styles": "workspace:^" + "@patternfly/react-tokens": "workspace:^" tslib: "npm:^2.6.2" peerDependencies: react: ^17 || ^18 @@ -3308,7 +3308,7 @@ __metadata: languageName: unknown linkType: soft -"@patternfly/react-tokens@npm:^5.4.0-prerelease.5, @patternfly/react-tokens@workspace:packages/react-tokens": +"@patternfly/react-tokens@workspace:^, @patternfly/react-tokens@workspace:packages/react-tokens": version: 0.0.0-use.local resolution: "@patternfly/react-tokens@workspace:packages/react-tokens" dependencies: @@ -8303,7 +8303,7 @@ __metadata: version: 0.0.0-use.local resolution: "demo-app-ts@workspace:packages/react-integration/demo-app-ts" dependencies: - "@patternfly/react-core": "npm:^5.4.0-prerelease.15" + "@patternfly/react-core": "workspace:^" "@types/react-router": "npm:^5.1.20" "@types/react-router-dom": "npm:^5.3.3" "@vitejs/plugin-react-swc": "npm:^3.7.0"