Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentezw committed Nov 16, 2023
1 parent 9258916 commit 38e8706
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 43 deletions.
13 changes: 13 additions & 0 deletions .changeset/happy-eagles-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'skeleton': patch
---

Updated internal dependencies for bug resolution.
Please update the `@shopify/cli` dependency in your app to avoid duplicated subdependencies:

```diff
"dependencies": {
- "@shopify/cli": "3.50.2",
+ "@shopify/cli": "3.51.0",
}
```
12 changes: 1 addition & 11 deletions .changeset/slimy-sloths-nail.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,4 @@
The `deploy` command now displays an error if there are uncommited changes in a project's Git repository. If you'd like to go ahead with the deployment regardless, you can use the new `force` flag.
When deploying with uncommited changes, we use a default description in the form of `<sha> with additional changes` (where `<sha>` represents the hash of the last commit). This description will be visible in the Shopify Admin for the deployment, and the `metadata-description` flag can be used to specify a different description.

In CI environments, the `deploy` command now creates a file "h2_deploy_output.log" file in the current working directory, for successful deployments. This file holds a JSON object with the URL of the deployment. This can be useful for scripting purposes, where consequent steps in your CI workflow require the deployment URL. The flag `--no-json-output` can be used to prevent this behaviour. In the future, we may add further keys to the JSON object.

Updated internal dependencies for bug resolution.
Please update the `@shopify/cli` dependency in your app to avoid duplicated subdependencies:

```diff
"dependencies": {
- "@shopify/cli": "3.50.2",
+ "@shopify/cli": "3.51.0",
}
```
In CI environments, the `deploy` command now creates a file "h2_deploy_output_log.json" file in the current working directory, for successful deployments. This file holds a JSON object with the URL of the deployment. This can be useful for scripting purposes, where consequent steps in your CI workflow require the deployment URL. The flag `--no-json-output` can be used to prevent this behaviour. In the future, we may add further keys to the JSON object.
20 changes: 11 additions & 9 deletions packages/cli/src/commands/hydrogen/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,20 @@ describe('deploy', () => {
expect(vi.mocked(renderSuccess)).toHaveBeenCalled;
});

it('returns when there are uncommited changes', async () => {
it('errors when there are uncommited changes', async () => {
vi.mocked(ensureIsClean).mockRejectedValue(
new GitDirectoryNotCleanError('Uncommitted changes'),
);

await oxygenDeploy(deployParams);
try {
await oxygenDeploy(deployParams);
} catch (error) {
expect(error).toBeInstanceOf(AbortError);
const abortError = error as AbortError;
expect(abortError.message).toBe('Uncommitted changes detected.');
}

expect(vi.mocked(createDeploy)).not.toHaveBeenCalled;
expect(vi.mocked(renderWarning)).toHaveBeenCalledWith({
body: expect.stringContaining('Uncommitted changes detected'),
nextSteps: expect.anything(),
});
});

it('proceeds with warning and modified description when there are uncommited changes and the force flag is used', async () => {
Expand All @@ -210,8 +212,8 @@ describe('deploy', () => {
});

expect(vi.mocked(renderWarning)).toHaveBeenCalledWith({
body: expect.stringContaining('no description has been provided'),
nextSteps: expect.anything(),
headline: 'No deployment description provided',
body: expect.anything(),
});
expect(vi.mocked(createDeploy)).toHaveBeenCalledWith({
config: {
Expand Down Expand Up @@ -318,7 +320,7 @@ describe('deploy', () => {
await oxygenDeploy(ciDeployParams);

expect(vi.mocked(writeFile)).toHaveBeenCalledWith(
'h2_deploy_output.log',
'h2_deploy_log.json',
JSON.stringify({url: 'https://a-lovely-deployment.com'}),
);

Expand Down
38 changes: 15 additions & 23 deletions packages/cli/src/commands/hydrogen/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,15 @@ export async function oxygenDeploy(
if (error instanceof GitDirectoryNotCleanError) {
isCleanGit = false;
}

if (!forceOnUncommitedChanges && !isCleanGit) {
renderWarning({
body: 'Uncommitted changes detected.',
nextSteps: [
[
'Commit your changes before deploying or use the ',
{command: '--force'},
' flag to deploy with uncommitted changes.',
],
throw new AbortError('Uncommitted changes detected.', null, [
[
'Commit your changes before deploying or use the ',
{command: '--force'},
' flag to deploy with uncommitted changes.',
],
});
return;
]);
}
}

Expand All @@ -212,18 +209,13 @@ export async function oxygenDeploy(

if (!metadataDescription && !isCleanGit) {
renderWarning({
body: 'Deploying uncommited changes, but no description has been provided.',
nextSteps: [
[
'Use the ',
{command: '--metadata-description'},
' flag to provide a description.',
],
[
'If no description is provided, the description defaults to ',
{userInput: '<sha> with additional changes'},
' using the SHA of the last commit.',
],
headline: 'No deployment description provided',
body: [
'Deploying uncommited changes, but no description has been provided. Use the ',
{command: '--metadata-description'},
'flag to provide a description. If no description is provided, the description defaults to ',
{userInput: '<sha> with additional changes'},
' using the SHA of the last commit.',
],
});
metadataDescription = `${commitHash} with additional changes`;
Expand Down Expand Up @@ -380,7 +372,7 @@ export async function oxygenDeploy(
// in CI environments, output to a file so consequent steps can access the URL
// the formatting of this file is likely to change in future versions.
if (isCI && !noJsonOutput) {
await writeFile('h2_deploy_output.log', JSON.stringify({url: url!}));
await writeFile('h2_deploy_log.json', JSON.stringify({url: url!}));
}
resolveDeploy();
})
Expand Down

0 comments on commit 38e8706

Please sign in to comment.