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

List the uncommitted files that the deploy command errors on #1944

Merged
merged 4 commits into from
Apr 9, 2024

Conversation

graygilmore
Copy link
Contributor

@graygilmore graygilmore commented Apr 4, 2024

WHY are these changes introduced?

Now that we're guiding merchants to use the deploy command a number of them are hitting an error that they haven't seen before:

➜  hydrogen git:(main) h2 deploy --preview
╭─ error ──────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  Uncommitted changes detected.                                               │
│                                                                              │
│  Next steps                                                                  │
│    • Commit your changes before deploying or use the  `--force`  flag to     │
│      deploy with uncommitted changes.                                        │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

This is easy to debug locally because you can run git status to see what has changed but it's cumbersome when it's only happening in your CI environment. The most likely cause of this is that their package manager's lockfile is being updated during the dependency installation process but it's not easy to tell.

WHAT is this pull request doing?

This PR updates the error message to include all of the file changes by capturing the changes with git status -s and adding them to the banner. For example, while working on this change locally I had the following output:

➜  skeleton git:(gg-list-uncommitted-changes) h2 deploy --preview
╭─ error ──────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                              │
│  Uncommitted changes detected:                                                               │
│                                                                                              │
│   M ../../packages/cli/oclif.manifest.json                                                   │
│   M ../../packages/cli/src/commands/hydrogen/deploy.test.ts                                  │
│   M ../../packages/cli/src/commands/hydrogen/deploy.ts                                       │
│  ?? bun.lockb                                                                                │
│  ?? pnpm-lock.yaml                                                                           │
│                                                                                              │
│  Next steps                                                                                  │
│    • Commit your changes before deploying or use the `--force` flag to deploy with           │
│      uncommitted changes.                                                                    │
│    • If you are using pnpm, try running `pnpm install --frozen-lockfile` to avoid changes    │
│      to pnpm-lock.yaml.                                                                      │
│    • If you are using bun, try running `bun install --frozen-lockfile` to avoid changes to   │
│      bun.lockb.                                                                              │
│                                                                                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────╯

Additionally if we find that there are lockfiles present in the diff we'll add an additional item in "next steps" to explain how you might be able to avoid those files changing during a CI deploy.

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

@graygilmore graygilmore marked this pull request as ready for review April 4, 2024 22:00
@graygilmore graygilmore requested review from vincentezw and a team April 4, 2024 22:01
packages/cli/src/commands/hydrogen/deploy.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@frandiox frandiox left a comment

Choose a reason for hiding this comment

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

Good change!

One more suggestion. Since this feature is more focused for CI environments, can we try to find package-lock.json (and variants) in the list of files and, if found, show a next step with "You should use npm ci instead of npm i" or similar?

packages/cli/src/commands/hydrogen/deploy.ts Outdated Show resolved Hide resolved
Copy link
Contributor

shopify bot commented Apr 8, 2024

Oxygen deployed a preview of your gg-list-uncommitted-changes branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment April 9, 2024 5:29 PM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment April 9, 2024 5:29 PM
vite ✅ Successful (Logs) Preview deployment Inspect deployment April 9, 2024 5:42 PM
subscriptions ✅ Successful (Logs) Preview deployment Inspect deployment April 9, 2024 5:30 PM
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment April 9, 2024 5:29 PM
skeleton ✅ Successful (Logs) Preview deployment Inspect deployment April 9, 2024 5:29 PM

Learn more about Hydrogen's GitHub integration.

Comment on lines -43 to -49
vi.mock('@shopify/cli-kit/node/output', async () => {
return {
outputContent: () => ({value: ''}),
outputInfo: () => {},
outputWarn: () => {},
};
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These weren't being mocked in any way so I'm removing this.

@graygilmore graygilmore requested review from frandiox, vincentezw and a team April 8, 2024 21:34
Copy link
Contributor

@vincentezw vincentezw left a comment

Choose a reason for hiding this comment

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

nice!

Copy link
Contributor

@frandiox frandiox left a comment

Choose a reason for hiding this comment

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

LGTM, just a minor fix:

packages/cli/src/lib/package-managers.ts Outdated Show resolved Hide resolved
@graygilmore
Copy link
Contributor Author

Force Push Patch Notes

  • Replace --immutable with --frozen-lockfile for backward compatibility

Copy link

@martinamarien martinamarien left a comment

Choose a reason for hiding this comment

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

🎩 With and without a linked storefront
Looks good to me

@graygilmore
Copy link
Contributor Author

Force Push Patch Notes

  • Rebased with main to see if CI gets fixed

@graygilmore graygilmore merged commit e3baaba into main Apr 9, 2024
13 checks passed
@graygilmore graygilmore deleted the gg-list-uncommitted-changes branch April 9, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants