Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Versioning the retail react app #1209

Merged
merged 296 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
296 commits
Select commit Hold shift + click to select a range
e2bb649
more fixes for out of sync package / lockfiles
bfeister Mar 14, 2023
f4790fc
add missing pwa-kit packages
yunakim714 Mar 14, 2023
e18076c
Fix regex matching patterns (#1057)
yunakim714 Mar 14, 2023
694104e
fix dependency dupes
bfeister Mar 14, 2023
7664191
Remove all console logs / cleanup / unnecessary code
bfeister Mar 15, 2023
2e1ec7f
fix some problems with final cleanup
bfeister Mar 15, 2023
80e29f9
merge
bfeister Mar 15, 2023
389a1df
Merge branch 'feature/template-extensibility-stress-test' into featur…
bfeister Mar 15, 2023
a456791
remove stress test files post-merge
bfeister Mar 15, 2023
de04c3e
added pdp page override with small customization
yunakim714 Mar 16, 2023
d1ca004
add constants file to spike project and tweak overrides values
yunakim714 Mar 16, 2023
c843b5c
Fix bug where `<path>/dir/index.(js|jsx|etc)` was being picked up by …
bfeister Mar 20, 2023
f675074
fix package.json scripts
bfeister Mar 21, 2023
478276d
fix falsy value defaulting causing errors in `path.join` fix broken `…
bfeister Mar 23, 2023
89795cc
delete `build/loadable-stat.json` from git, gitignore should work fro…
bfeister Mar 23, 2023
d7f8861
fix some file pathing issues in how SDK looks up default / universal …
bfeister Mar 23, 2023
71c037c
Perf enhancements, don't use regex all (.*) for module replacement, r…
bfeister Mar 23, 2023
c7e9be5
minor code style tweak
bfeister Mar 23, 2023
1306b57
cleanup
bfeister Mar 23, 2023
3f8939e
initial work on moving code to use resolver
yunakim714 Mar 27, 2023
f650221
fix getoverridepath and break on ^ imports
yunakim714 Mar 29, 2023
a5d3f01
add todos and comments
yunakim714 Mar 29, 2023
2eecb75
rewrite requestcontext.request for path with caret
yunakim714 Mar 30, 2023
3766818
perform overrideshashmap lookup for relative import
yunakim714 Mar 30, 2023
24bb5c3
merge v3 and regenerate lock files with version 2
yunakim714 Apr 3, 2023
1b42d87
progress
yunakim714 Apr 4, 2023
6fd8cdd
fix conflicts
yunakim714 Apr 5, 2023
7f3c364
fix package lockfiles that were out of sync
bfeister Apr 5, 2023
f0900d5
Revert "fix package lockfiles that were out of sync"
bfeister Apr 5, 2023
9a2252c
progress
yunakim714 Apr 5, 2023
f4e332e
fix out of sync lockfiles
bfeister Apr 5, 2023
b2cad1d
Merge branch 'v3' into feature/template-extensibility
bfeister Apr 6, 2023
b4ef5b9
merge feature branch back
yunakim714 Apr 6, 2023
93727d1
resolve merge conflicts
yunakim714 Apr 6, 2023
d664877
Merge branch 'v3' into feature/template-extensibility
bfeister Apr 6, 2023
a11bbcc
merge conflict
bfeister Apr 6, 2023
34dc3f0
resolve merge conflict
bfeister Apr 6, 2023
ca6a625
update spike project's engines / regen v3 lockfiles
bfeister Apr 6, 2023
3863783
regenerate lock files
yunakim714 Apr 6, 2023
c562975
add missing node engines
bfeister Apr 6, 2023
cee6d04
add missing useToast (bad merge)
bfeister Apr 6, 2023
dfb656b
updates from underlying template-retail-react-app
bfeister Apr 6, 2023
5f364df
drop unnecessary pages/product-detail override
bfeister Apr 6, 2023
cc30d3a
Merge branch 'feature/template-extensibility' into extensibility-code…
bfeister Apr 6, 2023
a22ef36
fix dupe useToast
bfeister Apr 6, 2023
74f1d24
progress on making `charles-solution` work
bfeister Apr 6, 2023
8b80436
initial pass at migration to `resolver.getHook('resolve').tapAsync` w…
bfeister Apr 7, 2023
b388e56
restore icons file and add extensible text to home
yunakim714 Apr 7, 2023
6541b8f
add some comments and construct hashmap in new plugin
yunakim714 Apr 10, 2023
a654ef3
working glob sync lookup??
yunakim714 Apr 11, 2023
2cb9cce
resolve lookup when there is no extension
yunakim714 Apr 11, 2023
fcd183b
add component slot for testing
yunakim714 Apr 11, 2023
7adceb1
fix some lookup errors
yunakim714 Apr 11, 2023
de69faa
migrate to new directory
bfeister Apr 12, 2023
592931e
remove unnecessary directory nesting, remove unnecessary files for "m…
bfeister Apr 12, 2023
9e4b187
add example of extending routes non-destructively, add example of qui…
bfeister Apr 12, 2023
32e0ae0
Update example route
bfeister Apr 12, 2023
c751bbf
add some demo examples of overrides
bfeister Apr 12, 2023
d287a16
cleanup
yunakim714 Apr 13, 2023
1dcb461
commit package name change
bfeister Apr 13, 2023
a8b593d
rewrite requests coming from underlying template
yunakim714 Apr 14, 2023
9d79b8e
cleanup
yunakim714 Apr 14, 2023
6ebbe1a
rename plugin file
yunakim714 Apr 14, 2023
38f3b92
resolve merge conflict
yunakim714 Apr 14, 2023
be3bb04
remove unnecessary build files
yunakim714 Apr 19, 2023
0cb80f4
rename to overrides
yunakim714 Apr 19, 2023
2b726b9
fix lookup errors
yunakim714 Apr 20, 2023
1ae6125
Merge branch 'v3' into feature/template-extensibility
bfeister Apr 25, 2023
940565a
Merge branch 'feature/template-extensibility' into extensibility-code…
bfeister Apr 25, 2023
e76ee0a
fix some broken upstream changes, eslint fixes
bfeister Apr 25, 2023
1f9ac65
fix bad merge conflict
bfeister Apr 25, 2023
7345439
Bring back the deleted package.json
vmarta Apr 26, 2023
f9b1477
Install new eslint plugin
vmarta Apr 26, 2023
71f21b2
No more relative imports in retail-react-app
vmarta Apr 26, 2023
16cca08
Create .prettierrc.yaml
vmarta Apr 26, 2023
4fcbf92
restore other deleted package lockfiles
bfeister Apr 26, 2023
a8d9021
fix some eslint issues
bfeister Apr 26, 2023
d3f6860
remove `^` imports and begin migrating logic away from previous API. …
bfeister Apr 26, 2023
ef25c00
bring back deleted package lockfiles
vmarta Apr 26, 2023
f0bed51
short circuit plugin temporarily, get webpack `alias` working for tem…
bfeister Apr 26, 2023
856427d
fix unreachable condition
bfeister Apr 26, 2023
e8cc5b4
wow... freaking works 🚀
bfeister Apr 26, 2023
f2ce238
cleanup, get `template-retail-react-app` working again
bfeister Apr 26, 2023
24622a6
cleanup
bfeister Apr 26, 2023
6df83a6
Create .eslintrc.js
vmarta Apr 27, 2023
edacf34
fix routes.jsx which no longer pulled relative template
bfeister Apr 27, 2023
1862c9e
make routes.jsx more concise
bfeister Apr 27, 2023
20c3042
update lockfiles
bfeister Apr 27, 2023
69fcd79
add jsconfig.json for IDEs to have magic `retail-react-app` be discov…
bfeister Apr 27, 2023
240a9d5
Merge branch 'v3' into feature/template-extensibility
bfeister Apr 28, 2023
78b6c53
Merge branch 'feature/template-extensibility' into feature/template-e…
bfeister Apr 28, 2023
4241eab
more cleanup
bfeister Apr 28, 2023
7bac071
change package.json key from `mobify` => `ccExtensibility`
bfeister Apr 28, 2023
dbaba8b
cleanup
bfeister Apr 28, 2023
06cb1f0
Final cleanup, remove console.logs, make `extendable` dynamic for int…
bfeister Apr 28, 2023
98c382b
fix straggler non-dynamic filepath
bfeister Apr 28, 2023
29e6e58
cleanup
bfeister Apr 28, 2023
c3fa1f3
remove code that shouldn't be in v3+
bfeister Apr 28, 2023
29f5bfc
bump-version script ignores the retail-react-app
vmarta May 1, 2023
ebf716d
See if this `--pre-dist-tag` works as expected
vmarta May 1, 2023
13ff1bf
Clean up code
vmarta May 1, 2023
a827459
Add todo
vmarta May 1, 2023
9b39529
sync package.json deps in extended example project
bfeister May 2, 2023
b8fe972
cleanup / pr feedback
bfeister May 2, 2023
02eb090
Update npm scripts
vmarta May 2, 2023
4014396
Disable `npm install` step
vmarta May 2, 2023
a33de20
List the packages' versions for easy review
vmarta May 2, 2023
50b2f09
Fix bug with versioning the root package file
vmarta May 2, 2023
67623a2
Merge branch 'feature/template-extensibility-algo-refactor' into vers…
vmarta May 2, 2023
7eea73f
A bit of refactoring
vmarta May 2, 2023
2d33647
Some clean up
vmarta May 2, 2023
148ea0a
pr feedback, great catch @kevinxh
bfeister May 3, 2023
4543a4d
fix problem with bad copy from underlying template file
bfeister May 3, 2023
11701dc
pr feedback / cleanup
bfeister May 3, 2023
e1aabf1
cleanup
bfeister May 3, 2023
c6b5e1f
Merge branch 'feature/template-extensibility-algo-refactor' into vers…
vmarta May 3, 2023
2fe771e
Update package-lock.json
vmarta May 3, 2023
83f07fe
WIP
vcua-mobify May 3, 2023
7e3b678
drop unneeded complexity
bfeister May 3, 2023
95488be
lockfiles
bfeister May 3, 2023
8b6f5fb
moving toward an array of `alias`es
bfeister May 4, 2023
a92b6ef
Generator: try downloading retail-react-app@latest from npm
vmarta May 4, 2023
7c3030c
Some refactoring
vmarta May 5, 2023
a29cc07
Refactor template extensibility functionality to use `resolve.alias` …
bfeister May 5, 2023
bdc1cfb
Tweak the versioning logic
vmarta May 5, 2023
7367fd7
These are optional options
vmarta May 5, 2023
9fe7f69
Use a new npm tag for testing purpose
vmarta May 5, 2023
d96c107
Merge branch 'feature/template-extensibility-algo-refactor' of github…
vcua-mobify May 5, 2023
ce151a1
add brand-logo with no clash for server side viewBox
bfeister May 5, 2023
034e2d7
add `request-processor.js` (required for worker.js to load) and fix b…
bfeister May 5, 2023
c9b13c4
Merge branch 'feature/template-extensibility-algo-refactor' into vers…
vmarta May 8, 2023
c680256
Add some comments
vmarta May 8, 2023
e0cbc17
Install shelljs
vmarta May 8, 2023
937fc25
retail-react-app: version updates scoped to this directory only
vmarta May 8, 2023
253874f
Update versioning logic in the root
vmarta May 8, 2023
ee66828
retail-react-app: simplify the versioning logic
vmarta May 8, 2023
3aad2da
fake sdk release v3
vmarta May 8, 2023
f8dcaa0
fake release of retail-react-app v1
vmarta May 8, 2023
a0086fd
lint fix
bfeister May 9, 2023
a9ec4bf
fix failing pwa-kit-react-sdk tests
bfeister May 9, 2023
2afa605
cleanup
bfeister May 9, 2023
94308c5
Merge branch 'v3' into feature/template-extensibility
bfeister May 9, 2023
2c6be38
regen package lockfiles
bfeister May 9, 2023
de5fd5c
Merge branch 'feature/template-extensibility' into feature/template-e…
bfeister May 9, 2023
5cb9f44
lint:fix
bfeister May 9, 2023
42a8bc1
Explore publishing certain packages only
vmarta May 9, 2023
342f294
Revert "fake release of retail-react-app v1"
vmarta May 9, 2023
13a7c26
Revert "fake sdk release v3"
vmarta May 9, 2023
58becd0
fix failing tests in CI re: `TextDecoder is not defined`
bfeister May 9, 2023
344a65e
take 2 attempting to fix TextDecoder global in jest
bfeister May 9, 2023
e7eba97
fix jest module mapper
bfeister May 9, 2023
79a1b55
fix jest moduleMapper config
bfeister May 9, 2023
e0c6c4b
REALLY fix jest moduleNameMapper config for new pathing + fix node `u…
bfeister May 9, 2023
e750b29
add brand-logo
bfeister May 9, 2023
f5b14d0
remove previously added `AbovePDP` Template Hook component
bfeister May 9, 2023
65293a2
replay #1128 from bad merge
bfeister May 9, 2023
a9fae57
eslint:fix for `retail-react-app` base paths
bfeister May 10, 2023
f382362
de-duplicate deps in bundle
bfeister May 10, 2023
eafa3b1
fix path defaulting, don't pass nullish value to path.resolve
bfeister May 10, 2023
151b96b
improve pathing for overridesDir in pwa-kit-dev webapack config + add…
bfeister May 10, 2023
61e32b8
Merge branch 'v3' into feature/template-extensibility-algo-refactor
bfeister May 10, 2023
868f9b2
fix pathing
bfeister May 11, 2023
fe7c3ce
fix pathing issue that was mysteriously UNFIXED
bfeister May 11, 2023
bf921b9
fix `worker.js` path
bfeister May 11, 2023
1115294
Merge branch 'feature/template-extensibility-algo-refactor' into vers…
vmarta May 11, 2023
bef1c95
Now also increment the pre-release version of the templates
vmarta May 11, 2023
0622c8c
Now allows for publishing one package only to npm
vmarta May 12, 2023
74d1191
fix app/static pathing in non-extensible builds
bfeister May 12, 2023
2250b4e
Make sure Lerna uses the exact versions (without carrot)
vmarta May 12, 2023
fe78312
Update package.json
vmarta May 12, 2023
a45c24b
What I expect to see from Ben's work
vmarta May 15, 2023
34bcdac
Some refactoring
vmarta May 15, 2023
509b145
Scale to multiple independent packages
vmarta May 15, 2023
335b52b
Make sure version updates are synced throughout
vmarta May 15, 2023
06cbf0c
Some refactoring
vmarta May 15, 2023
c432be9
Remove commented lines
vmarta May 15, 2023
fdda4b4
Merge branch 'feature/template-extensibility-algo-refactor' into vers…
vmarta May 16, 2023
a73346d
No need to do version-pinning ourselves
vmarta May 16, 2023
3fa148b
Add eslint and prettier
vmarta May 16, 2023
915ced6
Move script to allow reuse by future templates
vmarta May 16, 2023
3e57e0b
[Extensibility] Remove Einstein proxy and send Einstein events direct…
vcua-mobify May 16, 2023
dd5ba30
Merge branch 'feature/template-extensibility-algo-refactor' into vers…
vmarta May 16, 2023
412c3f8
Replace ExtendsCircularImportsPlugin with OverridesResolverPlugin (#1…
vcua-mobify May 16, 2023
ac0e092
Move `npm install` to the publishing step
vmarta May 16, 2023
b2de157
Update console log
vmarta May 17, 2023
b3d3ac1
Prep for fixing a bug
vmarta May 17, 2023
3a9419e
Updating a package version checks deps in other packages
vmarta May 17, 2023
6a53a96
remove irrelevant bundlesize check to pass CI
bfeister May 17, 2023
ee25ccd
Extract shared util functions
vmarta May 17, 2023
5195a2b
Consistency: add newline to EOF
vmarta May 18, 2023
371dd71
Get the name of the current package
vmarta May 18, 2023
d429521
Fix `vendor.js` inclusion of `retail-react-app` files (#1198)
bfeister May 18, 2023
8795667
Merge branch 'feature/template-extensibility-algo-refactor' into vers…
vmarta May 18, 2023
bddb532
replace relative with absolute path fetchTranslations (#1215)
alexvuong May 18, 2023
0ddd790
For now, make this package private
vmarta May 18, 2023
f074f3f
Iterate over the other packages only
vmarta May 18, 2023
8524c0f
Exclude these npm scripts from the smoke test
vmarta May 18, 2023
f5ce28b
Handle scenario of an SDK package with independent version
vmarta May 18, 2023
e1b5bfd
Refactor for unit testing, fix pathing issue from old version of file…
bfeister May 18, 2023
8e73a02
Add a 'sync' version of the script
vmarta May 18, 2023
d3407b3
Tweak conditions
vmarta May 18, 2023
20c9c9d
Some refactoring
vmarta May 18, 2023
0a8d6fb
Some refactoring
vmarta May 18, 2023
1af6712
Script to run a local npm registry
vmarta May 19, 2023
49f3338
Add todos for bug fixes
vmarta May 19, 2023
bf77140
Verify where the npm registry is
vmarta May 19, 2023
bc774ea
Merge branch 'feature/template-extensibility-algo-refactor' into vers…
vmarta May 19, 2023
534778c
Ignore this linting error
vmarta May 19, 2023
e9fac09
Update regex
vmarta May 19, 2023
7efe707
Add comments
vmarta May 19, 2023
00b17ea
Checks for clean working tree
vmarta May 19, 2023
86de1b7
Handle uncommitted changes
vmarta May 22, 2023
2a655a1
Make sure to update the package lock files
vmarta May 22, 2023
ea214fe
If error, make sure to still clean up
vmarta May 22, 2023
b29cb1f
Install from the root
vmarta May 22, 2023
ecb73d1
Some refactoring
vmarta May 22, 2023
d6f64ce
No longer needing this install step
vmarta May 22, 2023
116942b
For safety
vmarta May 22, 2023
f8501e2
If not on CI, make sure to publish to local npm
vmarta May 23, 2023
88b26c1
Only exit if there's an error
vmarta May 23, 2023
7dafb99
Merge branch 'develop' into feature/template-extensibility
bfeister May 23, 2023
9585094
remove demo extensible app in light of soon-to-be-merged PR from @bendvc
bfeister May 23, 2023
e2c82d1
lockfiles from reaact18 / chakra2
bfeister May 23, 2023
851366a
Feature/template extensibility (#1162)
bfeister May 23, 2023
2b40687
support windows file paths
bfeister May 23, 2023
911f1f9
Merge branch 'feature/template-extensibility' into versioning-retail-…
bfeister May 24, 2023
9bd5fea
Remove package
vmarta May 24, 2023
1b05f2c
Make sure versions are all 3.0.0-dev
vmarta May 24, 2023
c5f97b7
Update package lock files
vmarta May 24, 2023
7e82d8e
Follow up to recent merge conflicts
vmarta May 24, 2023
c8a2b92
Revert these changes to the generator
vmarta May 24, 2023
31ae716
Fix issue with failed tests because of react query dev tools
bendvc May 23, 2023
33b3058
Let the output of `npm version` pass through
vmarta May 24, 2023
cbf8768
Revert "Let the output of `npm version` pass through"
vmarta May 24, 2023
8c06d52
Make sure to `npm install` after updating dependencies
vmarta May 24, 2023
31cb7a8
Prepare to consolidate all of the versioning scripts
vmarta May 25, 2023
2ecacca
Move the rest of scripts into the monorepo root
vmarta May 26, 2023
9c2e3db
commerce-sdk-react now has its own version
vmarta May 26, 2023
49cc1c4
Use correct package name
vmarta May 26, 2023
61eceb3
Add todos
vmarta May 26, 2023
315be52
Reconsider where to do `npm install`
vmarta May 26, 2023
e1059c2
Clean up
vmarta May 26, 2023
8053cfa
Remove todo
vmarta May 26, 2023
1612d55
Merge branch 'develop' into versioning-retail-react-app
vmarta May 26, 2023
95a5cba
Remove unused dependency
vmarta May 26, 2023
3210576
Some code cleanup
vmarta May 26, 2023
bb3fc73
Merge branch 'develop' into versioning-retail-react-app
vmarta May 26, 2023
7f66aec
Move the versioning scripts into their own folder
vmarta May 29, 2023
0fcf9f3
Merge branch 'develop' into versioning-retail-react-app
vmarta May 29, 2023
6ea4a4a
Delete run-local-npm.js
vmarta May 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/actions/publish_to_npm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ inputs:
runs:
using: composite
steps:
# TODO: Figure out a way to specify whether to publish to "latest" or "next" tag
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is resolved. Now our script would correctly assign the npm tag latest or next:

`npm run lerna -- publish from-package --yes --no-verify-access --pre-dist-tag next ${

- name: Publish to NPM
run: |-
# Add NPM token to allow publishing
echo "//registry.npmjs.org/:_authToken=${{ inputs.NODE_AUTH_TOKEN }}" > ~/.npmrc

# Publish all changed packages. The "from-package" arg means "look
# at the version numbers in each package.json file and if that doesn't
# exist on NPM, publish"
npm run lerna -- publish from-package --yes --no-verify-access
npm run publish-to-npm

# Cleanup
rm ~/.npmrc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ jobs:

- name: Generate ${{ matrix.template }} project
run: |-
node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir generated-${{ matrix.template }}
node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir ${{ env.PROJECT_DIR }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just some refactoring to make it consistent with what's happening in that file.

env:
GENERATOR_PRESET: ${{ matrix.template }}
timeout-minutes: 7
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"name": "pwa-kit",
"version": "3.0.0-dev",
"scripts": {
"bump-version": "node ./scripts/bump-version.js",
"bump-version": "node ./scripts/bump-version/index.js",
"bump-version:retail-react-app": "node ./scripts/bump-version/index.js --package=retail-react-app",
"bump-version:commerce-sdk-react": "node ./scripts/bump-version/index.js --package=commerce-sdk-react-preview",
"publish-to-npm": "node ./scripts/publish-to-npm.js",
"format": "lerna run --stream format",
"preinstall": "node ./scripts/check-version.js",
"postinstall": "node ./scripts/bootstrap.js",
Expand Down
1 change: 1 addition & 0 deletions packages/template-retail-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "retail-react-app",
"version": "3.0.0-dev",
"license": "See license in LICENSE",
"author": "[email protected]",
"ccExtensibility": {
"extendable": ["retail-react-app"]
},
Expand Down
10 changes: 10 additions & 0 deletions scripts/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

module.exports = {
extends: [require.resolve('../packages/pwa-kit-dev/dist/configs/eslint/no-react')]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding some eslint and prettier rules for the root's scripts folder.

}
7 changes: 7 additions & 0 deletions scripts/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
printWidth: 100
singleQuote: true
semi: false
bracketSpacing: false
tabWidth: 4
arrowParens: 'always'
trailingComma: 'none'
50 changes: 0 additions & 50 deletions scripts/bump-version.js

This file was deleted.

47 changes: 47 additions & 0 deletions scripts/bump-version/independent-pkg-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env node
/*
* Copyright (c) 2023, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

/* eslint-disable @typescript-eslint/no-var-requires */
const sh = require('shelljs')
const path = require('path')
const {saveJSONToFile, setPackageVersion} = require('../utils')

// Exit upon error
sh.set('-e')

const monorepoPackages = JSON.parse(sh.exec('lerna list --all --json', {silent: true}))

const pathToPackage = (packageName) => {
const pkg = monorepoPackages.find((pkg) => pkg.name === packageName)
return pkg?.location
}

// Meant for setting the version of a package that has its own independent version
const main = () => {
const version = process.argv[2]
const pkgName = process.argv[3]
const otherPackages = monorepoPackages.filter((pkg) => pkg.name !== pkgName)

setPackageVersion(version, {cwd: pathToPackage(pkgName)})

// Update other packages who depend on the current package
otherPackages.forEach(({location}) => {
const pathToPkgJson = path.join(location, 'package.json')
const pkgJson = JSON.parse(sh.cat(pathToPkgJson))

if (pkgJson.dependencies?.[pkgName]) {
pkgJson.dependencies[pkgName] = version
} else if (pkgJson.devDependencies?.[pkgName]) {
pkgJson.devDependencies[pkgName] = version
}

saveJSONToFile(pkgJson, pathToPkgJson)
})
}

main()
129 changes: 129 additions & 0 deletions scripts/bump-version/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#!/usr/bin/env node
/*
* Copyright (c) 2023, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

/* eslint-disable @typescript-eslint/no-var-requires */
const sh = require('shelljs')
const path = require('path')
const program = require('commander')
const {saveJSONToFile, setPackageVersion} = require('../utils')

// Exit upon error
sh.set('-e')

const rootPath = path.join(__dirname, '..', '..')
const lernaConfigPath = path.join(rootPath, 'lerna.json')

const monorepoPackages = JSON.parse(sh.exec('lerna list --all --json', {silent: true}))
const monorepoPackageNames = monorepoPackages.map((pkg) => pkg.name)

const INDEPENDENT_PACKAGES = ['retail-react-app', 'commerce-sdk-react-preview']
const independentPackages = INDEPENDENT_PACKAGES.map((pkgName) =>
monorepoPackages.find((pkg) => pkg.name === pkgName)
)

/**
* @param {import('commander').CommanderStatic} program
*/
const main = (program) => {
const targetVersion = program.args[0]
if (!targetVersion) {
program.help()
}

const opts = program.opts()
if (opts.package !== 'sdk') {
// Assume that we're bumping the version of package that has its own independent version

const script1 = path.join(__dirname, 'independent-pkg-version.js')
sh.exec(`node ${script1} ${targetVersion} ${opts.package}`)

const script2 = path.join(__dirname, 'pwa-kit-deps-version.js')
const updateDepsBehaviour = /-dev\b/.test(targetVersion) ? 'sync' : 'latest'
sh.exec(`node ${script2} ${updateDepsBehaviour} ${opts.package}`)

// After updating the dependencies, let's update the package lock files
sh.exec('npm install')

process.exit(0)
}

sh.exec(`lerna version --exact --no-push --no-git-tag-version --yes ${targetVersion}`)
// `--exact` above is for pinning the version of the pwa-kit dependencies
// https://github.com/lerna/lerna/tree/main/libs/commands/version#--exact

const lernaConfig = JSON.parse(sh.cat(lernaConfigPath))
const newMonorepoVersion = lernaConfig.version

// update versions for root package and root package lock
setPackageVersion(newMonorepoVersion, {cwd: rootPath})

independentPackages.forEach((pkg) => {
const {location, version: oldVersion} = pkg
// Restore and then increment to the next pre-release version
// TODO: is it possible to _not_ trigger the lifecycle scripts? See CHANGELOG.md
setPackageVersion(oldVersion, {cwd: location})
setPackageVersion('prerelease', {cwd: location})

const newVersion = JSON.parse(sh.exec('npm pkg get version', {cwd: location, silent: true}))
pkg.version = newVersion
})

// Now that all of the package version updates are done,
// let's make sure some dependencies' versions are updated accordingly
monorepoPackages.forEach(({location}) => {
const pathToPkgJson = path.join(location, 'package.json')
const pkgJson = JSON.parse(sh.cat(pathToPkgJson))

updatePeerDeps(pkgJson, newMonorepoVersion)
updateDeps(pkgJson)

saveJSONToFile(pkgJson, pathToPkgJson)
})

// After updating the dependencies, let's update the package lock files
sh.exec('npm install')

sh.echo('\nVersions of packages in the monorepo:\n')
sh.exec('lerna list --all --long')
}

const updatePeerDeps = (pkgJson, newMonorepoVersion) => {
const peerDependencies = pkgJson.peerDependencies
if (!peerDependencies) return

Object.keys(peerDependencies).forEach((dep) => {
if (monorepoPackageNames.includes(dep)) {
console.log(`Found lerna local package ${dep} as a peer dependency of ${pkgJson.name}.`)
peerDependencies[dep] = `^${newMonorepoVersion}`
}
})
}

const updateDeps = (pkgJson) => {
independentPackages.forEach((independentPkg) => {
const newVersion = independentPkg.version

if (pkgJson.dependencies?.[independentPkg.name]) {
pkgJson.dependencies[independentPkg.name] = newVersion
} else if (pkgJson.devDependencies?.[independentPkg.name]) {
pkgJson.devDependencies[independentPkg.name] = newVersion
}
})
}

program.description('Bump the version of a package in our monorepo')
program.arguments('<target-version>')

program.option(
'-p, --package <package-name>',
'the package name or an alias to a group of packages',
'sdk'
)

program.parse(process.argv)
main(program)
58 changes: 58 additions & 0 deletions scripts/bump-version/pwa-kit-deps-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2023, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

/* eslint-disable @typescript-eslint/no-var-requires */
const sh = require('shelljs')
const path = require('path')
const {saveJSONToFile} = require('../utils')

// Exit upon error
sh.set('-e')

const publicPackages = JSON.parse(sh.exec('lerna list --json', {silent: true}))

const pathToPackage = (packageName) => {
const pkg = publicPackages.find((pkg) => pkg.name === packageName)
return pkg?.location
}

// Assuming that this is run within a specific package,
// the script would update its pwa-kit/sdk dependencies.
const main = () => {
const updateBehaviour = process.argv[2]
const packageName = process.argv[3]

const pathToPackageJson = path.join(pathToPackage(packageName), 'package.json')
const pkgJson = JSON.parse(sh.cat(pathToPackageJson))

if (updateBehaviour === 'latest') {
publicPackages.forEach(({name}) => {
if (pkgJson.dependencies?.[name]) {
pkgJson.dependencies[name] = getLatestVersion(name)
} else if (pkgJson.devDependencies?.[name]) {
pkgJson.devDependencies[name] = getLatestVersion(name)
}
})
} else if (updateBehaviour === 'sync') {
// Sync version with what's in the monorepo
publicPackages.forEach(({version, name}) => {
if (pkgJson.dependencies?.[name]) {
pkgJson.dependencies[name] = version
} else if (pkgJson.devDependencies?.[name]) {
pkgJson.devDependencies[name] = version
}
})
}

saveJSONToFile(pkgJson, pathToPackageJson)
}

const getLatestVersion = (pkgName) => {
return sh.exec(`npm info ${pkgName}@latest version`, {silent: true}).trim()
}

main()
Loading