Update example dependencies versions with a script (#7367)

This commit is contained in:
Bjorn Lu 2023-06-12 20:48:04 +08:00 committed by GitHub
parent 0325bf7e0f
commit 718cebd526
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 183 additions and 67 deletions

View file

@ -8,14 +8,6 @@ module.exports = {
useTabs: true, useTabs: true,
plugins: ['./node_modules/prettier-plugin-astro'], plugins: ['./node_modules/prettier-plugin-astro'],
overrides: [ overrides: [
{
// Changesets run Prettier using our configuration, however it uses a very old version of Prettier that does
// not support our plugin and it ends up doing more harm than good. As such, we'll disable our plugin for changelogs
files: ['CHANGELOG.md'],
options: {
plugins: [],
},
},
{ {
files: ['.*', '*.json', '*.md', '*.toml', '*.yml'], files: ['.*', '*.json', '*.md', '*.toml', '*.yml'],
options: { options: {

View file

@ -29,7 +29,7 @@
"test:e2e:match": "cd packages/astro && pnpm playwright install && pnpm run test:e2e:match", "test:e2e:match": "cd packages/astro && pnpm playwright install && pnpm run test:e2e:match",
"benchmark": "astro-benchmark", "benchmark": "astro-benchmark",
"lint": "eslint --cache .", "lint": "eslint --cache .",
"version": "changeset version && pnpm install --no-frozen-lockfile && pnpm run format", "version": "changeset version && node ./scripts/deps/update-example-versions.js && pnpm install --no-frozen-lockfile && pnpm run format",
"preinstall": "npx only-allow pnpm" "preinstall": "npx only-allow pnpm"
}, },
"workspaces": [ "workspaces": [
@ -68,9 +68,6 @@
"allowAny": [ "allowAny": [
"astro" "astro"
] ]
},
"patchedDependencies": {
"@changesets/cli@2.23.0": "patches/@changesets__cli@2.23.0.patch"
} }
}, },
"dependencies": { "dependencies": {
@ -78,8 +75,8 @@
"astro-benchmark": "workspace:*" "astro-benchmark": "workspace:*"
}, },
"devDependencies": { "devDependencies": {
"@changesets/changelog-github": "0.4.4", "@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "2.23.0", "@changesets/cli": "^2.26.1",
"@types/node": "^18.7.21", "@types/node": "^18.7.21",
"@typescript-eslint/eslint-plugin": "^5.58.0", "@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0", "@typescript-eslint/parser": "^5.58.0",

View file

@ -1,14 +0,0 @@
diff --git a/dist/cli.cjs.dev.js b/dist/cli.cjs.dev.js
index 5511d0c05d3b7472876dcc8410e938ccf612654f..aa75e3982b68e1226ba1877a7f32017e517480f5 100644
--- a/dist/cli.cjs.dev.js
+++ b/dist/cli.cjs.dev.js
@@ -279,6 +279,9 @@ async function confirmMajorRelease(pkgJSON) {
}
async function getPackagesToRelease(changedPackages, allPackages) {
+ const isPrivate = (name) => name === 'astro-scripts' || name.startsWith('@example/') || name.startsWith('@test/') || name.startsWith('@e2e/');
+ changedPackages = changedPackages.filter(name => !isPrivate(name));
+ allPackages = allPackages.filter(({ packageJson: { name }}) => !isPrivate(name));
function askInitialReleaseQuestion(defaultChoiceList) {
return askCheckboxPlus( // TODO: Make this wording better
// TODO: take objects and be fancy with matching

View file

@ -9,11 +9,6 @@ overrides:
packageExtensionsChecksum: 01871422d489547c532184effb134b35 packageExtensionsChecksum: 01871422d489547c532184effb134b35
patchedDependencies:
'@changesets/cli@2.23.0':
hash: kcozqtpxuwjzskw6zg5royevn4
path: patches/@changesets__cli@2.23.0.patch
importers: importers:
.: .:
@ -26,11 +21,11 @@ importers:
version: link:benchmark version: link:benchmark
devDependencies: devDependencies:
'@changesets/changelog-github': '@changesets/changelog-github':
specifier: 0.4.4 specifier: ^0.4.8
version: 0.4.4 version: 0.4.8
'@changesets/cli': '@changesets/cli':
specifier: 2.23.0 specifier: ^2.26.1
version: 2.23.0(patch_hash=kcozqtpxuwjzskw6zg5royevn4) version: 2.26.1
'@types/node': '@types/node':
specifier: ^18.7.21 specifier: ^18.7.21
version: 18.16.3 version: 18.16.3
@ -4390,7 +4385,7 @@ importers:
version: 9.2.2 version: 9.2.2
vite: vite:
specifier: ^4.3.1 specifier: ^4.3.1
version: 4.3.1(@types/node@18.16.3)(sass@1.52.2) version: 4.3.1(@types/node@14.18.21)
packages/integrations/netlify/test/edge-functions/fixtures/dynimport: packages/integrations/netlify/test/edge-functions/fixtures/dynimport:
dependencies: dependencies:
@ -4908,7 +4903,7 @@ importers:
version: 3.0.0(vite@4.3.1)(vue@3.2.47) version: 3.0.0(vite@4.3.1)(vue@3.2.47)
'@vue/babel-plugin-jsx': '@vue/babel-plugin-jsx':
specifier: ^1.1.1 specifier: ^1.1.1
version: 1.1.1(@babel/core@7.21.8) version: 1.1.1
'@vue/compiler-sfc': '@vue/compiler-sfc':
specifier: ^3.2.39 specifier: ^3.2.39
version: 3.2.39 version: 3.2.39
@ -5472,7 +5467,7 @@ packages:
astro: '*' astro: '*'
svelte: ^3.54.0 svelte: ^3.54.0
dependencies: dependencies:
'@sveltejs/vite-plugin-svelte': 2.4.1(svelte@3.58.0)(vite@4.3.1) '@sveltejs/vite-plugin-svelte': 2.4.1(svelte@3.58.0)
astro: link:packages/astro astro: link:packages/astro
svelte: 3.58.0 svelte: 3.58.0
svelte2tsx: 0.5.23(svelte@3.58.0)(typescript@5.0.2) svelte2tsx: 0.5.23(svelte@3.58.0)(typescript@5.0.2)
@ -7054,8 +7049,8 @@ packages:
'@changesets/types': 5.2.1 '@changesets/types': 5.2.1
dev: true dev: true
/@changesets/changelog-github@0.4.4: /@changesets/changelog-github@0.4.8:
resolution: {integrity: sha512-htSILqCkyYtTB5/LoVKwx7GCJQGxAiBcYbfUKWiz/QoDARuM01owYtMXhV6/iytJZq/Dqqz3PjMZUNB4MphpbQ==} resolution: {integrity: sha512-jR1DHibkMAb5v/8ym77E4AMNWZKB5NPzw5a5Wtqm1JepAuIF+hrKp2u04NKM14oBZhHglkCfrla9uq8ORnK/dw==}
dependencies: dependencies:
'@changesets/get-github-info': 0.5.2 '@changesets/get-github-info': 0.5.2
'@changesets/types': 5.2.1 '@changesets/types': 5.2.1
@ -7064,8 +7059,8 @@ packages:
- encoding - encoding
dev: true dev: true
/@changesets/cli@2.23.0(patch_hash=kcozqtpxuwjzskw6zg5royevn4): /@changesets/cli@2.26.1:
resolution: {integrity: sha512-Gi3tMi0Vr6eNd8GX6q73tbOm9XOzGfuLEm4PYVeWG2neg5DlRGNOjYwrFULJ/An3N9MHtHn4r5h1Qvnju9Ijug==} resolution: {integrity: sha512-XnTa+b51vt057fyAudvDKGB0Sh72xutQZNAdXkCqPBKO2zvs2yYZx5hFZj1u9cbtpwM6Sxtcr02/FQJfZOzemQ==}
hasBin: true hasBin: true
dependencies: dependencies:
'@babel/runtime': 7.21.5 '@babel/runtime': 7.21.5
@ -7076,12 +7071,12 @@ packages:
'@changesets/errors': 0.1.4 '@changesets/errors': 0.1.4
'@changesets/get-dependents-graph': 1.3.5 '@changesets/get-dependents-graph': 1.3.5
'@changesets/get-release-plan': 3.0.16 '@changesets/get-release-plan': 3.0.16
'@changesets/git': 1.5.0 '@changesets/git': 2.0.0
'@changesets/logger': 0.0.5 '@changesets/logger': 0.0.5
'@changesets/pre': 1.0.14 '@changesets/pre': 1.0.14
'@changesets/read': 0.5.9 '@changesets/read': 0.5.9
'@changesets/types': 5.2.1 '@changesets/types': 5.2.1
'@changesets/write': 0.1.9 '@changesets/write': 0.2.3
'@manypkg/get-packages': 1.1.3 '@manypkg/get-packages': 1.1.3
'@types/is-ci': 3.0.0 '@types/is-ci': 3.0.0
'@types/semver': 6.2.3 '@types/semver': 6.2.3
@ -7102,7 +7097,6 @@ packages:
term-size: 2.2.1 term-size: 2.2.1
tty-table: 4.2.1 tty-table: 4.2.1
dev: true dev: true
patched: true
/@changesets/config@2.3.0: /@changesets/config@2.3.0:
resolution: {integrity: sha512-EgP/px6mhCx8QeaMAvWtRrgyxW08k/Bx2tpGT+M84jEdX37v3VKfh4Cz1BkwrYKuMV2HZKeHOh8sHvja/HcXfQ==} resolution: {integrity: sha512-EgP/px6mhCx8QeaMAvWtRrgyxW08k/Bx2tpGT+M84jEdX37v3VKfh4Cz1BkwrYKuMV2HZKeHOh8sHvja/HcXfQ==}
@ -7157,17 +7151,6 @@ packages:
resolution: {integrity: sha512-SVqwYs5pULYjYT4op21F2pVbcrca4qA/bAA3FmFXKMN7Y+HcO8sbZUTx3TAy2VXulP2FACd1aC7f2nTuqSPbqg==} resolution: {integrity: sha512-SVqwYs5pULYjYT4op21F2pVbcrca4qA/bAA3FmFXKMN7Y+HcO8sbZUTx3TAy2VXulP2FACd1aC7f2nTuqSPbqg==}
dev: true dev: true
/@changesets/git@1.5.0:
resolution: {integrity: sha512-Xo8AT2G7rQJSwV87c8PwMm6BAc98BnufRMsML7m7Iw8Or18WFvFmxqG5aOL5PBvhgq9KrKvaeIBNIymracSuHg==}
dependencies:
'@babel/runtime': 7.21.5
'@changesets/errors': 0.1.4
'@changesets/types': 5.2.1
'@manypkg/get-packages': 1.1.3
is-subdir: 1.2.0
spawndamnit: 2.0.0
dev: true
/@changesets/git@2.0.0: /@changesets/git@2.0.0:
resolution: {integrity: sha512-enUVEWbiqUTxqSnmesyJGWfzd51PY4H7mH9yUw0hPVpZBJ6tQZFMU3F3mT/t9OJ/GjyiM4770i+sehAn6ymx6A==} resolution: {integrity: sha512-enUVEWbiqUTxqSnmesyJGWfzd51PY4H7mH9yUw0hPVpZBJ6tQZFMU3F3mT/t9OJ/GjyiM4770i+sehAn6ymx6A==}
dependencies: dependencies:
@ -7224,14 +7207,14 @@ packages:
resolution: {integrity: sha512-myLfHbVOqaq9UtUKqR/nZA/OY7xFjQMdfgfqeZIBK4d0hA6pgxArvdv8M+6NUzzBsjWLOtvApv8YHr4qM+Kpfg==} resolution: {integrity: sha512-myLfHbVOqaq9UtUKqR/nZA/OY7xFjQMdfgfqeZIBK4d0hA6pgxArvdv8M+6NUzzBsjWLOtvApv8YHr4qM+Kpfg==}
dev: true dev: true
/@changesets/write@0.1.9: /@changesets/write@0.2.3:
resolution: {integrity: sha512-E90ZrsrfJVOOQaP3Mm5Xd7uDwBAqq3z5paVEavTHKA8wxi7NAL8CmjgbGxSFuiP7ubnJA2BuHlrdE4z86voGOg==} resolution: {integrity: sha512-Dbamr7AIMvslKnNYsLFafaVORx4H0pvCA2MHqgtNCySMe1blImEyAEOzDmcgKAkgz4+uwoLz7demIrX+JBr/Xw==}
dependencies: dependencies:
'@babel/runtime': 7.21.5 '@babel/runtime': 7.21.5
'@changesets/types': 5.2.1 '@changesets/types': 5.2.1
fs-extra: 7.0.1 fs-extra: 7.0.1
human-id: 1.0.2 human-id: 1.0.2
prettier: 1.19.1 prettier: 2.8.8
dev: true dev: true
/@cloudflare/kv-asset-handler@0.2.0: /@cloudflare/kv-asset-handler@0.2.0:
@ -8594,6 +8577,24 @@ packages:
string.prototype.matchall: 4.0.8 string.prototype.matchall: 4.0.8
dev: false dev: false
/@sveltejs/vite-plugin-svelte-inspector@1.0.2(@sveltejs/vite-plugin-svelte@2.4.1)(svelte@3.58.0):
resolution: {integrity: sha512-Cy1dUMcYCnDVV/hPLXa43YZJ2jGKVW5rA0xuNL9dlmYhT0yoS1g7+FOFSRlgk0BXKk/Oc7grs+8BVA5Iz2fr8A==}
engines: {node: ^14.18.0 || >= 16}
peerDependencies:
'@sveltejs/vite-plugin-svelte': ^2.2.0
svelte: ^3.54.0 || ^4.0.0-next.0
vite: ^4.0.0
peerDependenciesMeta:
vite:
optional: true
dependencies:
'@sveltejs/vite-plugin-svelte': 2.4.1(svelte@3.58.0)
debug: 4.3.4
svelte: 3.58.0
transitivePeerDependencies:
- supports-color
dev: false
/@sveltejs/vite-plugin-svelte-inspector@1.0.2(@sveltejs/vite-plugin-svelte@2.4.1)(svelte@3.58.0)(vite@4.3.1): /@sveltejs/vite-plugin-svelte-inspector@1.0.2(@sveltejs/vite-plugin-svelte@2.4.1)(svelte@3.58.0)(vite@4.3.1):
resolution: {integrity: sha512-Cy1dUMcYCnDVV/hPLXa43YZJ2jGKVW5rA0xuNL9dlmYhT0yoS1g7+FOFSRlgk0BXKk/Oc7grs+8BVA5Iz2fr8A==} resolution: {integrity: sha512-Cy1dUMcYCnDVV/hPLXa43YZJ2jGKVW5rA0xuNL9dlmYhT0yoS1g7+FOFSRlgk0BXKk/Oc7grs+8BVA5Iz2fr8A==}
engines: {node: ^14.18.0 || >= 16} engines: {node: ^14.18.0 || >= 16}
@ -8613,6 +8614,28 @@ packages:
- supports-color - supports-color
dev: false dev: false
/@sveltejs/vite-plugin-svelte@2.4.1(svelte@3.58.0):
resolution: {integrity: sha512-bNNKvoRY89ptY7udeBSCmTdCVwkjmMcZ0j/z9J5MuedT8jPjq0zrknAo/jF1sToAza4NVaAgR9AkZoD9oJJmnA==}
engines: {node: ^14.18.0 || >= 16}
peerDependencies:
svelte: ^3.54.0 || ^4.0.0-next.0
vite: ^4.0.0
peerDependenciesMeta:
vite:
optional: true
dependencies:
'@sveltejs/vite-plugin-svelte-inspector': 1.0.2(@sveltejs/vite-plugin-svelte@2.4.1)(svelte@3.58.0)
debug: 4.3.4
deepmerge: 4.3.1
kleur: 4.1.5
magic-string: 0.30.0
svelte: 3.58.0
svelte-hmr: 0.15.1(svelte@3.58.0)
vitefu: 0.2.4(vite@4.3.1)
transitivePeerDependencies:
- supports-color
dev: false
/@sveltejs/vite-plugin-svelte@2.4.1(svelte@3.58.0)(vite@4.3.1): /@sveltejs/vite-plugin-svelte@2.4.1(svelte@3.58.0)(vite@4.3.1):
resolution: {integrity: sha512-bNNKvoRY89ptY7udeBSCmTdCVwkjmMcZ0j/z9J5MuedT8jPjq0zrknAo/jF1sToAza4NVaAgR9AkZoD9oJJmnA==} resolution: {integrity: sha512-bNNKvoRY89ptY7udeBSCmTdCVwkjmMcZ0j/z9J5MuedT8jPjq0zrknAo/jF1sToAza4NVaAgR9AkZoD9oJJmnA==}
engines: {node: ^14.18.0 || >= 16} engines: {node: ^14.18.0 || >= 16}
@ -9327,6 +9350,23 @@ packages:
resolution: {integrity: sha512-hz4R8tS5jMn8lDq6iD+yWL6XNB699pGIVLk7WSJnn1dbpjaazsjZQkieJoRX6gW5zpYSCFqQ7jUquPNY65tQYA==} resolution: {integrity: sha512-hz4R8tS5jMn8lDq6iD+yWL6XNB699pGIVLk7WSJnn1dbpjaazsjZQkieJoRX6gW5zpYSCFqQ7jUquPNY65tQYA==}
dev: false dev: false
/@vue/babel-plugin-jsx@1.1.1:
resolution: {integrity: sha512-j2uVfZjnB5+zkcbc/zsOc0fSNGCMMjaEXP52wdwdIfn0qjFfEYpYZBFKFg+HHnQeJCVrjOeO0YxgaL7DMrym9w==}
dependencies:
'@babel/helper-module-imports': 7.21.4
'@babel/plugin-syntax-jsx': 7.21.4(@babel/core@7.18.2)
'@babel/template': 7.20.7
'@babel/traverse': 7.18.2
'@babel/types': 7.21.5
'@vue/babel-helper-vue-transform-on': 1.0.2
camelcase: 6.3.0
html-tags: 3.3.1
svg-tags: 1.0.0
transitivePeerDependencies:
- '@babel/core'
- supports-color
dev: false
/@vue/babel-plugin-jsx@1.1.1(@babel/core@7.21.8): /@vue/babel-plugin-jsx@1.1.1(@babel/core@7.21.8):
resolution: {integrity: sha512-j2uVfZjnB5+zkcbc/zsOc0fSNGCMMjaEXP52wdwdIfn0qjFfEYpYZBFKFg+HHnQeJCVrjOeO0YxgaL7DMrym9w==} resolution: {integrity: sha512-j2uVfZjnB5+zkcbc/zsOc0fSNGCMMjaEXP52wdwdIfn0qjFfEYpYZBFKFg+HHnQeJCVrjOeO0YxgaL7DMrym9w==}
dependencies: dependencies:
@ -15499,12 +15539,6 @@ packages:
synckit: 0.8.5 synckit: 0.8.5
dev: false dev: false
/prettier@1.19.1:
resolution: {integrity: sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==}
engines: {node: '>=4'}
hasBin: true
dev: true
/prettier@2.8.8: /prettier@2.8.8:
resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==}
engines: {node: '>=10.13.0'} engines: {node: '>=10.13.0'}
@ -17630,6 +17664,39 @@ packages:
- supports-color - supports-color
dev: false dev: false
/vite@4.3.1(@types/node@14.18.21):
resolution: {integrity: sha512-EPmfPLAI79Z/RofuMvkIS0Yr091T2ReUoXQqc5ppBX/sjFRhHKiPPF/R46cTdoci/XgeQpB23diiJxq5w30vdg==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
peerDependencies:
'@types/node': '>= 14'
less: '*'
sass: '*'
stylus: '*'
sugarss: '*'
terser: ^5.4.0
peerDependenciesMeta:
'@types/node':
optional: true
less:
optional: true
sass:
optional: true
stylus:
optional: true
sugarss:
optional: true
terser:
optional: true
dependencies:
'@types/node': 14.18.21
esbuild: 0.17.18
postcss: 8.4.23
rollup: 3.21.8
optionalDependencies:
fsevents: 2.3.2
dev: true
/vite@4.3.1(@types/node@18.16.3)(sass@1.52.2): /vite@4.3.1(@types/node@18.16.3)(sass@1.52.2):
resolution: {integrity: sha512-EPmfPLAI79Z/RofuMvkIS0Yr091T2ReUoXQqc5ppBX/sjFRhHKiPPF/R46cTdoci/XgeQpB23diiJxq5w30vdg==} resolution: {integrity: sha512-EPmfPLAI79Z/RofuMvkIS0Yr091T2ReUoXQqc5ppBX/sjFRhHKiPPF/R46cTdoci/XgeQpB23diiJxq5w30vdg==}
engines: {node: ^14.18.0 || >=16.0.0} engines: {node: ^14.18.0 || >=16.0.0}

View file

@ -0,0 +1,74 @@
import path from 'node:path';
import fs from 'node:fs/promises';
import { globby as glob } from 'globby';
/*
This file updates the dependencies' versions in `examples/*` to match the workspace packages' versions.
This should be run after `changeset version` so the release PR updates all the versions together.
*/
const rootUrl = new URL('../..', import.meta.url);
const rootPackageJson = JSON.parse(await fs.readFile(new URL('./package.json', rootUrl), 'utf-8'));
// get all workspace package name to versions
/** @type {Map<string, string>} */
const packageToVersions = new Map();
// Changeset detects workspace packages to publish via `workspaces` in package.json.
// Although this conflicts with the `pnpm-workspace.yaml` config, it's easier to configure what gets
// published through this field, so this file also respects this field when updating the versions.
const workspaceDirs = await glob(rootPackageJson.workspaces, {
onlyDirectories: true,
cwd: rootUrl,
});
for (const workspaceDir of workspaceDirs) {
const packageJsonPath = path.join(workspaceDir, './package.json');
const packageJson = await readAndParsePackageJson(packageJsonPath);
if (!packageJson) continue;
if (!packageJson.name) {
throw new Error(`${packageJsonPath} does not contain a "name" field.`);
}
if (!packageJson.version) {
throw new Error(`${packageJsonPath} does not contain a "version" field.`);
}
packageToVersions.set(packageJson.name, packageJson.version);
}
// Update all examples' package.json
const exampleDirs = await glob('examples/*', {
onlyDirectories: true,
cwd: rootUrl,
});
for (const exampleDir of exampleDirs) {
const packageJsonPath = path.join(exampleDir, './package.json');
const packageJson = await readAndParsePackageJson(packageJsonPath);
if (!packageJson) continue;
// Update dependencies
for (const depName of Object.keys(packageJson.dependencies ?? [])) {
if (packageToVersions.has(depName)) {
packageJson.dependencies[depName] = `^${packageToVersions.get(depName)}`;
}
}
// Update devDependencies
for (const depName of Object.keys(packageJson.devDependencies ?? [])) {
if (packageToVersions.has(depName)) {
packageJson.devDependencies[depName] = `^${packageToVersions.get(depName)}`;
}
}
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
}
/**
* @param {string} packageJsonPath
* @returns {Promise<Record<string, any> | undefined>}
*/
async function readAndParsePackageJson(packageJsonPath) {
try {
return JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
} catch {}
}