@shopify/oxygen-cli 1.11.7-unstable.202309081456.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,16 +2,12 @@ import { Logger } from '@shopify/cli-kit/node/output';
2
2
  import { DeploymentConfig } from './types.js';
3
3
  import { DeploymentCancelResponse } from './graphql/deployment-cancel.js';
4
4
 
5
- declare enum DeploymentCancelReason {
6
- Failed = "FAILED",
7
- Cancelled = "CANCELLED"
8
- }
9
5
  interface DeploymentCancelOptions {
10
6
  config: DeploymentConfig;
11
7
  deploymentId: string;
12
- reason: DeploymentCancelReason;
8
+ reason: string;
13
9
  logger: Logger;
14
10
  }
15
11
  declare function deploymentCancel(options: DeploymentCancelOptions): Promise<DeploymentCancelResponse>;
16
12
 
17
- export { DeploymentCancelReason, deploymentCancel };
13
+ export { deploymentCancel };
@@ -4,11 +4,6 @@ import { outputInfo } from '@shopify/cli-kit/node/output';
4
4
  import { Header, errorHandler } from '../utils/utils.js';
5
5
  import { DeploymentCancelQuery } from './graphql/deployment-cancel.js';
6
6
 
7
- var DeploymentCancelReason = /* @__PURE__ */ ((DeploymentCancelReason2) => {
8
- DeploymentCancelReason2["Failed"] = "FAILED";
9
- DeploymentCancelReason2["Cancelled"] = "CANCELLED";
10
- return DeploymentCancelReason2;
11
- })(DeploymentCancelReason || {});
12
7
  async function deploymentCancel(options) {
13
8
  const { config, deploymentId, reason, logger } = options;
14
9
  const variables = {
@@ -39,4 +34,4 @@ async function deploymentCancel(options) {
39
34
  }
40
35
  }
41
36
 
42
- export { DeploymentCancelReason, deploymentCancel };
37
+ export { deploymentCancel };
@@ -3,7 +3,7 @@ import { graphqlRequest } from '@shopify/cli-kit/node/api/graphql';
3
3
  import { vi, describe, test, expect } from 'vitest';
4
4
  import { createTestConfig } from '../utils/test-helper.js';
5
5
  import { stderrLogger, Header } from '../utils/utils.js';
6
- import { deploymentCancel, DeploymentCancelReason } from './deployment-cancel.js';
6
+ import { deploymentCancel } from './deployment-cancel.js';
7
7
 
8
8
  vi.mock("@shopify/cli-kit/node/api/graphql");
9
9
  vi.mock("@shopify/cli-kit/node/output");
@@ -22,7 +22,7 @@ describe("DeploymentComplete", () => {
22
22
  const completeResponse = await deploymentCancel({
23
23
  config: testConfig,
24
24
  deploymentId: "deployment-1",
25
- reason: DeploymentCancelReason.Failed,
25
+ reason: "error message",
26
26
  logger: stderrLogger
27
27
  });
28
28
  expect(completeResponse).toEqual(response.deploymentCancel);
@@ -33,7 +33,7 @@ describe("DeploymentComplete", () => {
33
33
  token: testConfig.deploymentToken.accessToken,
34
34
  variables: {
35
35
  deploymentId: "deployment-1",
36
- reason: DeploymentCancelReason.Failed
36
+ reason: "error message"
37
37
  },
38
38
  addedHeaders: {
39
39
  [Header.OxygenNamespaceHandle]: `${testConfig.deploymentToken.namespace}`
@@ -55,7 +55,7 @@ describe("DeploymentComplete", () => {
55
55
  deploymentCancel({
56
56
  config: testConfig,
57
57
  deploymentId: "deployment-1",
58
- reason: DeploymentCancelReason.Failed,
58
+ reason: "error message",
59
59
  logger: stderrLogger
60
60
  })
61
61
  ).rejects.toThrow(
@@ -74,7 +74,7 @@ describe("DeploymentComplete", () => {
74
74
  deploymentCancel({
75
75
  config: testConfig,
76
76
  deploymentId: "deployment-1",
77
- reason: DeploymentCancelReason.Failed,
77
+ reason: "error message",
78
78
  logger: stderrLogger
79
79
  })
80
80
  ).rejects.toThrow(
@@ -1,6 +1,6 @@
1
1
  import { OxygenError } from '../types.js';
2
2
 
3
- declare const DeploymentCancelQuery = "\nmutation DeploymentCancel($deploymentId: ID!, $reason: DeploymentCancellationReason!) {\n deploymentCancel(id: $deploymentId, reason: $reason) {\n deployment {\n id\n }\n userErrors {\n message\n }\n }\n}\n";
3
+ declare const DeploymentCancelQuery = "\nmutation DeploymentCancel($deploymentId: ID!, $reason: String!) {\n deploymentCancel(id: $deploymentId, reason: $reason) {\n deployment {\n id\n }\n userErrors {\n message\n }\n }\n}\n";
4
4
  interface DeploymentCancelQueryData {
5
5
  deploymentCancel: DeploymentCancelResponse;
6
6
  }
@@ -1,5 +1,5 @@
1
1
  const DeploymentCancelQuery = `
2
- mutation DeploymentCancel($deploymentId: ID!, $reason: DeploymentCancellationReason!) {
2
+ mutation DeploymentCancel($deploymentId: ID!, $reason: String!) {
3
3
  deploymentCancel(id: $deploymentId, reason: $reason) {
4
4
  deployment {
5
5
  id
@@ -7,7 +7,7 @@ import { getUploadFiles } from './get-upload-files.js';
7
7
  import { deploymentInitiate } from './deployment-initiate.js';
8
8
  import { deploymentComplete } from './deployment-complete.js';
9
9
  import { healthCheck } from './health-check.js';
10
- import { deploymentCancel, DeploymentCancelReason } from './deployment-cancel.js';
10
+ import { deploymentCancel } from './deployment-cancel.js';
11
11
  import { uploadFiles } from './upload-files.js';
12
12
  import { HealthCheckError } from './types.js';
13
13
  import { buildProject } from './build-project.js';
@@ -107,7 +107,7 @@ ${urlMessage} preview URL: ${deploymentCompleteOp.deployment.url}`,
107
107
  await deploymentCancel({
108
108
  config,
109
109
  deploymentId: deployment.deployment.id,
110
- reason: DeploymentCancelReason.Failed,
110
+ reason: error.message,
111
111
  logger
112
112
  }).catch((err) => {
113
113
  if (err instanceof Error) {
@@ -8,10 +8,10 @@ async function getMetadata(config, logger) {
8
8
  let metadata = {};
9
9
  try {
10
10
  const gitCommit = await getLatestGitCommit(config.rootPath);
11
- const branch = gitCommit.refs.split(" ");
11
+ const branch = (/HEAD -> ([^,]*)/.exec(gitCommit.refs) || [])[1];
12
12
  metadata = {
13
13
  actor: gitCommit.author_name,
14
- branch: branch[branch.length - 1],
14
+ branch,
15
15
  commitDate: gitCommit.date,
16
16
  commitSha: gitCommit.hash,
17
17
  commitMessage: gitCommit.message.substring(0, maxLabelLength)
@@ -7,6 +7,7 @@ import { getMetadata, getEnvironmentInput, createLabels } from './metadata.js';
7
7
 
8
8
  vi.mock("@shopify/cli-kit/node/context/local");
9
9
  vi.mock("@shopify/cli-kit/node/git");
10
+ vi.mock("@shopify/cli-kit/node/output");
10
11
  describe("getMetadata", () => {
11
12
  test("should return custom metadata from environment", async () => {
12
13
  vi.mocked(ciPlatform).mockReturnValueOnce({
@@ -69,6 +70,39 @@ describe("getMetadata", () => {
69
70
  expect(metadataResult.name).toBe("none");
70
71
  expect(metadataResult.url).toBe(void 0);
71
72
  });
73
+ test("should derive branch correctly from commit refs", async () => {
74
+ vi.mocked(ciPlatform).mockReturnValue({
75
+ isCI: false
76
+ });
77
+ const testCases = {
78
+ "HEAD -> main, origin/main, origin/HEAD": "main",
79
+ "HEAD -> dev, origin/dev, origin/HEAD": "dev",
80
+ "HEAD -> feature/awesome-feature, origin/feature/awesome-feature, origin/HEAD": "feature/awesome-feature",
81
+ "HEAD -> bugfix/123-fix-bug, origin/bugfix/123-fix-bug, origin/HEAD": "bugfix/123-fix-bug",
82
+ "HEAD -> release/v1.0.0, origin/release/v1.0.0, origin/HEAD": "release/v1.0.0",
83
+ "HEAD -> hotfix/urgent-fix, origin/hotfix/urgent-fix, origin/HEAD": "hotfix/urgent-fix",
84
+ "HEAD -> test, origin/test, origin/HEAD": "test",
85
+ "HEAD -> my-branch, origin/my-branch, origin/HEAD": "my-branch",
86
+ "HEAD -> long-branch-name, origin/long-branch-name, origin/HEAD": "long-branch-name",
87
+ "HEAD -> branch_with_underscores, origin/branch_with_underscores, origin/HEAD": "branch_with_underscores",
88
+ "HEAD -> branch-with-dashes, origin/branch-with-dashes, origin/HEAD": "branch-with-dashes",
89
+ "HEAD -> branch.with.dots, origin/branch.with.dots, origin/HEAD": "branch.with.dots"
90
+ };
91
+ for (const [refs, expectedBranch] of Object.entries(testCases)) {
92
+ vi.mocked(getLatestGitCommit).mockResolvedValueOnce({
93
+ author_name: "gh_author",
94
+ author_email: "test@github.com",
95
+ hash: "gh_hash",
96
+ message: "gh_message",
97
+ refs,
98
+ date: "gh_date",
99
+ body: "gh_body"
100
+ });
101
+ const testConfig = createTestConfig("/tmp/deploymentRoot/");
102
+ const metadataResult = await getMetadata(testConfig, stderrLogger);
103
+ expect(metadataResult.branch).toBe(expectedBranch);
104
+ }
105
+ });
72
106
  });
73
107
  describe("getEnvironmentInput", () => {
74
108
  test("should return environment tag from config", () => {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.11.7-unstable.202309081456.0",
2
+ "version": "1.12.0",
3
3
  "commands": {
4
4
  "oxygen:deploy": {
5
5
  "id": "oxygen:deploy",
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "@shopify:registry": "https://registry.npmjs.org"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "1.11.7-unstable.202309081456.0",
8
+ "version": "1.12.0",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "build": "tsup --clean --config ./tsup.config.ts && oclif manifest",
@@ -16,7 +16,8 @@
16
16
  "lint:format": "prettier --write \"**/*.*\" && npm run lint --fix",
17
17
  "generate:manifest": "oclif manifest",
18
18
  "prepack": "npm install && npm run build",
19
- "release": "npm run build && npx changeset publish",
19
+ "prepublishOnly": "rm -rf dist/**/*.test.*",
20
+ "release": "npm run build && npx changeset publish && git push --follow-tags",
20
21
  "test": "vitest run",
21
22
  "test:watch": "vitest"
22
23
  },
@@ -24,7 +25,7 @@
24
25
  "oxygen-cli": "./dist/oxygen-cli.js"
25
26
  },
26
27
  "engines": {
27
- "node": ">=14.17.0"
28
+ "node": ">=16.14.0"
28
29
  },
29
30
  "exports": {
30
31
  "./deploy": "./dist/deploy/index.js"
@@ -35,7 +36,7 @@
35
36
  ],
36
37
  "dependencies": {
37
38
  "@oclif/core": "2.15.0",
38
- "@shopify/cli-kit": "nightly",
39
+ "@shopify/cli-kit": "^3.49.2",
39
40
  "async": "^3.2.4"
40
41
  },
41
42
  "devDependencies": {
@@ -44,7 +45,7 @@
44
45
  "@shopify/prettier-config": "^1.1.2",
45
46
  "@types/async": "^3.2.18",
46
47
  "@types/node": "^20.5.9",
47
- "eslint": "^8.48.0",
48
+ "eslint": "^8.49.0",
48
49
  "eslint-plugin-prettier": "^5.0.0",
49
50
  "node-fetch": "^3.3.2",
50
51
  "oclif": "^3",