Skip to content

Commit

Permalink
New upgrade CLI command (#1458)
Browse files Browse the repository at this point in the history
* Add version changelog boilerplate

* update

* update

* .

* Update package-lock.json

Add version changelog boilerplate

update

update

.

add version_changelog.json

* merge main

* update oclif manifest

* Delete packages/cli/VERSION_CHANGELOG.md

* merge

* merge main

* Updage changelog to 2023.10

* remove groupings

* add support for conditional npm installs and all remix packages

* update changelog

* WIP upgrade command tests

* upgrade command tests

add additional remix upgrade test

* delete reels

* update changelog to the latest version

* cleanup

* add changeset

* add createChangelogHandler boilerplate

* Fixes

* Updated --dry-run logic, support upgrading other outdated dependencies

* update tests to match new logic

* Simplify getSelectedRelease and tests

* Stop using process.exit in favor of AbortError

* Remove extra logs in dev command when there's nothing to do

* Hoist mocks

* Use output mock instead of render mocks

* Fix going back to previous menu

* Add --force flag to test in dirty git repos and fix typo

* add support and test for dependenciesMeta

* Add support for @next versions and add additional test for Remix and meta dependencies

* Change mocked package.json to use the skeleton template as base

* Use semver in getAbsoluteVersion

* Fix displayUpgradeSummary when upgrading only dependencies

* update changeset for upgrade command

* Use local package.json instead of fetching it

* Use local changelog.json in tests

* Remove duplicated changelog.json

* Update packages/cli/src/commands/hydrogen/upgrade.ts

Co-authored-by: Graham F. Scott <gfscott@users.noreply.github.com>

* prep for release

* remove createChangelogHandler

* Save instrunctions to .hydrogen instead of .shopify so that they can be tracked

* fix changelog


---------

Co-authored-by: Hydrogen Bot <hydrogen@shopify.com>
Co-authored-by: Fran Dios <fran.dios@shopify.com>
Co-authored-by: Graham F. Scott <gfscott@users.noreply.github.com>
  • Loading branch information
4 people committed Nov 17, 2023
1 parent 9ed789d commit bca112e
Show file tree
Hide file tree
Showing 7 changed files with 2,334 additions and 7 deletions.
42 changes: 42 additions & 0 deletions .changeset/honest-apricots-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
'@shopify/cli-hydrogen': patch
---

New `h2 upgrade` command

We are introducing a new hydrogen cli `upgrade` command that:

- Makes upgrading hydrogen as easy as typing `h2 upgrade` in your terminal
- Provides a quick summary of the key `features` and `fixes` of any available
hydrogen version(s)
- Generates a `TODO` instructions file detailing all cumulative code changes required
to adopt a given hydrogen version
- Provides a gentle notice during development detailing when a hydrogen is outdated, as well as a quick glance into the number of hydrogen version available

## Basic use

```bash
# from the base of the project run
h2 upgrade
```

### `--version` flag

The version flag let's you upgrade to a specific release version without any further
prompts. If an invalid version is provided you will be prompted to choose a hydrogen
version via a CLI prompt

```bash
h2 upgrade --version 2023.10.0
```

### `--dry-run` flag

If your are unsure about upgrading or just want to preview the TODO list of
changes to a given hydrogen version you can run

```bash
h2 upgrade --dry-run

# this will output a new .md file inside the .hydrogen/ folder for a given upgrade
```
172 changes: 172 additions & 0 deletions package-lock.json

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

48 changes: 48 additions & 0 deletions packages/cli/oclif.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@
"char": "e",
"description": "Specify an environment's branch name when using remote environment variables.",
"multiple": false
},
"disable-version-check": {
"name": "disable-version-check",
"type": "boolean",
"description": "Skip the version check when running `hydrogen dev`",
"required": false,
"allowNo": false
}
},
"args": {}
Expand Down Expand Up @@ -647,6 +654,47 @@
},
"args": {}
},
"hydrogen:upgrade": {
"id": "hydrogen:upgrade",
"description": "Upgrade Remix and Hydrogen npm dependencies.",
"strict": true,
"pluginName": "@shopify/cli-hydrogen",
"pluginAlias": "@shopify/cli-hydrogen",
"pluginType": "core",
"aliases": [],
"flags": {
"path": {
"name": "path",
"type": "option",
"description": "The path to the directory of the Hydrogen storefront. The default is the current directory.",
"multiple": false
},
"version": {
"name": "version",
"type": "option",
"char": "v",
"description": "A target hydrogen version to update to",
"required": false,
"multiple": false
},
"dry-run": {
"name": "dry-run",
"type": "boolean",
"char": "d",
"description": "Generate a summary and .md file with upgrade instructions without actually upgrading the dependencies",
"required": false,
"allowNo": false
},
"force": {
"name": "force",
"type": "boolean",
"char": "f",
"description": "Ignore warnings and force the upgrade to the target version",
"allowNo": false
}
},
"args": {}
},
"hydrogen:debug:cpu": {
"id": "hydrogen:debug:cpu",
"description": "Builds and profiles the server startup time the app.",
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"@types/recursive-readdir": "^2.2.1",
"@types/stack-trace": "^0.0.30",
"@types/tar-fs": "^2.0.1",
"devtools-protocol": "^0.0.1177611",
"get-port": "^7.0.0",
"@vitest/coverage-v8": "^0.33.0",
"devtools-protocol": "^0.0.1177611",
"fast-glob": "^3.2.12",
"flame-chart-js": "2.3.1",
"get-port": "^7.0.0",
"type-fest": "^3.6.0",
"vitest": "^0.33.0"
},
Expand All @@ -40,6 +40,7 @@
"@shopify/mini-oxygen": "^2.2.3",
"@shopify/oxygen-cli": "2.6.2",
"ansi-escapes": "^6.2.0",
"cli-truncate": "^4.0.0",
"diff": "^5.1.0",
"fs-extra": "^11.1.0",
"get-port": "^7.0.0",
Expand Down

0 comments on commit bca112e

Please sign in to comment.