Skip to content

Commit

Permalink
Add preversion/postversion script for propagating versions in npm wor…
Browse files Browse the repository at this point in the history
…kspaces (microsoft#5303)

* Add postversion script

* Rename postversion to propagate-version

* Remove cldr-data

* Add preversion/postversion

* Fix postversion

* Typo

* Move to localDependencies

* Fix postversion

* Fix postversion should write

* Fix postversion again
  • Loading branch information
compulim authored Sep 24, 2024
1 parent 9ba786e commit 0537887
Show file tree
Hide file tree
Showing 19 changed files with 138 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/daily-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- run: npm clean-install --no-production

- name: Propagate versions
run: npm version --no-git-tag-version --workspaces `cat package.json | jq -r .version`
run: npm version --no-git-tag-version --no-workspaces-update --workspaces `cat package.json | jq -r .version`

- env:
NODE_ENV: production
Expand Down
19 changes: 15 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,23 @@
"build:tsup": "tsup --config ./tsup.config.ts",
"build:typescript": "tsc --project src/tsconfig.json",
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localPeerDependencies // []) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localPeerDependencies // []) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
"eslint": "npm run precommit",
"postversion": "cat package.json | jq '.version as $V | (.localDependencies // {} | with_entries(select(.value == \"production\") | { key: .key, value: $V })) as $L1 | (.localDependencies // {} | with_entries(select(.value == \"development\") | { key: .key, value: $V })) as $L2 | ((.dependencies // {}) + $L1 | to_entries | sort_by(.key) | from_entries) as $D1 | ((.devDependencies // {}) + $L2 | to_entries | sort_by(.key) | from_entries) as $D2 | . + { dependencies: $D1, devDependencies: $D2 }' > package-temp.json && mv package-temp.json package.json",
"precommit": "npm run precommit:eslint -- src && npm run precommit:typecheck",
"precommit:eslint": "../../node_modules/.bin/eslint --report-unused-disable-directives --max-warnings 0",
"precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false",
"preversion": "cat package.json | jq '(.localDependencies // {} | to_entries | map([if .value == \"production\" then \"dependencies\" else \"devDependencies\" end, .key])) as $P | delpaths($P)' > package-temp.json && mv package-temp.json package.json",
"start": "concurrently --kill-others --prefix-colors \"auto\" \"npm:start:*\"",
"start:babel": "npm run build:babel -- --skip-initial-build --watch",
"start:tsup": "npm run build:tsup -- --watch",
"start:typescript": "npm run build:typescript -- --watch"
},
"localPeerDependencies": [
"botframework-webchat-cldr-data",
"botframework-webchat-core"
],
"localDependencies": {
"botframework-webchat-cldr-data": "development",
"botframework-webchat-core": "production"
},
"pinDependencies": {
"@babel/cli": [
"7.18.10",
Expand Down Expand Up @@ -118,7 +120,6 @@
"babel-plugin-istanbul": "^6.1.1",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"botframework-webchat-cldr-data": "36.0.0-0",
"cldr-data": "^36.0.2",
"concurrently": "^8.2.2",
"core-js": "^3.37.0",
"cross-env": "^7.0.3",
Expand Down
22 changes: 12 additions & 10 deletions packages/bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,28 @@
"build:typescript": "tsc --project src/tsconfig.json",
"build:webpack": "webpack-cli",
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localPeerDependencies // []) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localPeerDependencies // []) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
"eslint": "npm run precommit",
"postversion": "cat package.json | jq '.version as $V | (.localDependencies // {} | with_entries(select(.value == \"production\") | { key: .key, value: $V })) as $L1 | (.localDependencies // {} | with_entries(select(.value == \"development\") | { key: .key, value: $V })) as $L2 | ((.dependencies // {}) + $L1 | to_entries | sort_by(.key) | from_entries) as $D1 | ((.devDependencies // {}) + $L2 | to_entries | sort_by(.key) | from_entries) as $D2 | . + { dependencies: $D1, devDependencies: $D2 }' > package-temp.json && mv package-temp.json package.json",
"precommit": "npm run precommit:eslint -- src && npm run precommit:typecheck",
"precommit:eslint": "../../node_modules/.bin/eslint --report-unused-disable-directives --max-warnings 0",
"precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false",
"preversion": "cat package.json | jq '(.localDependencies // {} | to_entries | map([if .value == \"production\" then \"dependencies\" else \"devDependencies\" end, .key])) as $P | delpaths($P)' > package-temp.json && mv package-temp.json package.json",
"start": "concurrently --kill-others --prefix-colors \"auto\" \"npm:start:*\"",
"start:babel": "npm run build:babel -- --skip-initial-build --watch",
"start:devserver": "node ./scripts/devServer.mjs",
"start:tsup": "npm run build:tsup -- --watch",
"start:typescript": "npm run build:typescript -- --watch"
},
"localPeerDependencies": [
"botframework-directlinespeech-sdk",
"botframework-webchat-api",
"botframework-webchat-component",
"botframework-webchat-core",
"isomorphic-react",
"isomorphic-react-dom"
],
"localDependencies": {
"botframework-directlinespeech-sdk": "production",
"botframework-webchat-api": "production",
"botframework-webchat-component": "production",
"botframework-webchat-core": "production",
"isomorphic-react": "development",
"isomorphic-react-dom": "development"
},
"pinDependencies": {
"@babel/cli": [
"7.18.10",
Expand Down
14 changes: 8 additions & 6 deletions packages/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,23 @@
"build:tsup": "tsup --config ./tsup.config.ts",
"build:typescript": "tsc --project src/tsconfig.json",
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localPeerDependencies // []) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localPeerDependencies // []) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
"eslint": "npm run precommit",
"postversion": "cat package.json | jq '.version as $V | (.localDependencies // {} | with_entries(select(.value == \"production\") | { key: .key, value: $V })) as $L1 | (.localDependencies // {} | with_entries(select(.value == \"development\") | { key: .key, value: $V })) as $L2 | ((.dependencies // {}) + $L1 | to_entries | sort_by(.key) | from_entries) as $D1 | ((.devDependencies // {}) + $L2 | to_entries | sort_by(.key) | from_entries) as $D2 | . + { dependencies: $D1, devDependencies: $D2 }' > package-temp.json && mv package-temp.json package.json",
"precommit": "npm run precommit:eslint -- src && npm run precommit:typecheck",
"precommit:eslint": "../../node_modules/.bin/eslint --report-unused-disable-directives --max-warnings 0",
"precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false",
"preversion": "cat package.json | jq '(.localDependencies // {} | to_entries | map([if .value == \"production\" then \"dependencies\" else \"devDependencies\" end, .key])) as $P | delpaths($P)' > package-temp.json && mv package-temp.json package.json",
"start": "concurrently --kill-others --prefix-colors \"auto\" \"npm:start:*\"",
"start:babel": "npm run build:babel -- --skip-initial-build --watch",
"start:tsup": "npm run build:tsup -- --watch",
"start:typescript": "npm run build:typescript -- --watch"
},
"localPeerDependencies": [
"botframework-webchat-api",
"botframework-webchat-core"
],
"localDependencies": {
"botframework-webchat-api": "production",
"botframework-webchat-core": "production"
},
"pinDependencies": {
"@babel/cli": [
"7.18.10",
Expand Down
8 changes: 5 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@
"build:tsup": "tsup --config ./tsup.config.ts",
"build:typescript": "tsc --project src/tsconfig.json",
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localPeerDependencies // []) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localPeerDependencies // []) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
"eslint": "npm run precommit",
"postversion": "cat package.json | jq '.version as $V | (.localDependencies // {} | with_entries(select(.value == \"production\") | { key: .key, value: $V })) as $L1 | (.localDependencies // {} | with_entries(select(.value == \"development\") | { key: .key, value: $V })) as $L2 | ((.dependencies // {}) + $L1 | to_entries | sort_by(.key) | from_entries) as $D1 | ((.devDependencies // {}) + $L2 | to_entries | sort_by(.key) | from_entries) as $D2 | . + { dependencies: $D1, devDependencies: $D2 }' > package-temp.json && mv package-temp.json package.json",
"precommit": "npm run precommit:eslint -- src && npm run precommit:typecheck",
"precommit:eslint": "../../node_modules/.bin/eslint --report-unused-disable-directives --max-warnings 0",
"precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false",
"preversion": "cat package.json | jq '(.localDependencies // {} | to_entries | map([if .value == \"production\" then \"dependencies\" else \"devDependencies\" end, .key])) as $P | delpaths($P)' > package-temp.json && mv package-temp.json package.json",
"start": "concurrently --kill-others --prefix-colors \"auto\" \"npm:start:*\"",
"start:babel": "npm run build:babel -- --skip-initial-build --watch",
"start:tsup": "npm run build:tsup -- --watch",
Expand All @@ -65,7 +67,7 @@
"engines": {
"node": ">=12.0.0"
},
"localPeerDependences": [],
"localDependences": {},
"pinDependencies": {
"@babel/cli": [
"7.18.10",
Expand Down
Loading

0 comments on commit 0537887

Please sign in to comment.