@shopify/oxygen-cli 1.7.0 → 1.8.2

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.
@@ -8,6 +8,7 @@ async function healthCheck(options) {
8
8
  outputInfo("Performing health check on the deployment...", logger);
9
9
  let attempts = 0;
10
10
  let delay = 0;
11
+ let calledHealthCheckError = false;
11
12
  const startTime = Date.now();
12
13
  const handleInterval = async () => {
13
14
  if (attempts < 10) {
@@ -18,7 +19,10 @@ async function healthCheck(options) {
18
19
  const elapsedTime = (Date.now() - startTime) / 1e3;
19
20
  if (elapsedTime + delay / 1e3 > config.healthCheckMaxDuration) {
20
21
  const error = new HealthCheckError("Unable to verify deployment health.");
21
- hooks?.onHealthCheckError?.(error);
22
+ if (!calledHealthCheckError) {
23
+ calledHealthCheckError = true;
24
+ hooks?.onHealthCheckError?.(error);
25
+ }
22
26
  throw error;
23
27
  }
24
28
  attempts++;
@@ -11,6 +11,7 @@ interface DeploymentHooks {
11
11
  onHealthCheckComplete?: () => void;
12
12
  onHealthCheckError?: (error: Error) => void;
13
13
  onUploadFilesStart?: () => void;
14
+ onUploadFilesError?: (error: Error) => void;
14
15
  onUploadFilesComplete?: () => void;
15
16
  }
16
17
  interface DeploymentConfig {
@@ -14,6 +14,9 @@ async function uploadFiles(options) {
14
14
  }).then(() => {
15
15
  hooks?.onUploadFilesComplete?.();
16
16
  outputCompleted(`Files uploaded successfully`, logger);
17
+ }).catch((err) => {
18
+ hooks?.onUploadFilesError?.(err);
19
+ throw err;
17
20
  });
18
21
  }
19
22
  async function uploadFile(config, target) {
@@ -30,15 +30,17 @@ vi.mock("@shopify/cli-kit/node/fs", () => {
30
30
  };
31
31
  });
32
32
  const testConfig = createTestConfig("/tmp/deploymentRoot");
33
+ let hooks;
33
34
  describe("UploadFiles", () => {
34
35
  beforeEach(() => {
35
36
  vi.mocked(fetch).mockReset();
37
+ hooks = {
38
+ onUploadFilesComplete: vi.fn(),
39
+ onUploadFilesError: vi.fn(),
40
+ onUploadFilesStart: vi.fn()
41
+ };
36
42
  });
37
43
  it("Performs a form upload", async () => {
38
- const hooks = {
39
- onUploadFilesStart: vi.fn(),
40
- onUploadFilesComplete: vi.fn()
41
- };
42
44
  const response = new Response();
43
45
  vi.mocked(fetch).mockResolvedValueOnce(response);
44
46
  const testWorkerUpload = [
@@ -90,12 +92,15 @@ describe("UploadFiles", () => {
90
92
  uploadFiles({
91
93
  config: testConfig,
92
94
  targets: testWorkerUpload,
93
- logger: stderrLogger
95
+ logger: stderrLogger,
96
+ hooks
94
97
  })
95
98
  ).rejects.toThrow("Failed to upload file index.js");
96
99
  expect(vi.mocked(fetch)).toHaveBeenCalledTimes(
97
100
  Number(deployDefaults.maxUploadAttempts) + 1
98
101
  );
102
+ expect(hooks.onUploadFilesError).toBeCalled();
103
+ expect(hooks.onUploadFilesComplete).not.toBeCalled();
99
104
  });
100
105
  it("Performs a resumable upload", async () => {
101
106
  const headers = {
@@ -116,7 +121,8 @@ describe("UploadFiles", () => {
116
121
  await uploadFiles({
117
122
  config: testConfig,
118
123
  targets: testWorkerUpload,
119
- logger: stderrLogger
124
+ logger: stderrLogger,
125
+ hooks
120
126
  });
121
127
  expect(vi.mocked(fetch)).toHaveBeenCalledTimes(2);
122
128
  const secondCall = vi.mocked(fetch).mock.calls[1];
@@ -125,6 +131,8 @@ describe("UploadFiles", () => {
125
131
  return req.method === "PUT" && req.body instanceof NamedReadable;
126
132
  };
127
133
  expect(validateRequestBody(secondCall[1])).toBe(true);
134
+ expect(hooks.onUploadFilesStart).toBeCalled();
135
+ expect(hooks.onUploadFilesComplete).toBeCalled();
128
136
  });
129
137
  it("Resumes a resumable upload", async () => {
130
138
  console.error = () => {
@@ -200,7 +208,8 @@ describe("UploadFiles", () => {
200
208
  uploadFiles({
201
209
  config: testConfig,
202
210
  targets: testWorkerUpload,
203
- logger: stderrLogger
211
+ logger: stderrLogger,
212
+ hooks
204
213
  })
205
214
  ).rejects.toThrow(
206
215
  `Failed to upload file index.js after ${deployDefaults.maxResumabeUploadAttempts} attempts`
@@ -209,5 +218,7 @@ describe("UploadFiles", () => {
209
218
  // for each attempt, we make two calls to fetch, plus the initial attempt makes two calls
210
219
  Number(deployDefaults.maxResumabeUploadAttempts) * 2 + 2
211
220
  );
221
+ expect(hooks.onUploadFilesError).toBeCalled();
222
+ expect(hooks.onUploadFilesComplete).not.toBeCalled();
212
223
  });
213
224
  });
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.0",
2
+ "version": "1.8.2",
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.7.0",
8
+ "version": "1.8.2",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "build": "tsup --clean --config ./tsup.config.ts && oclif manifest",
@@ -26,13 +26,16 @@
26
26
  "engines": {
27
27
  "node": ">=14.17.0"
28
28
  },
29
+ "exports": {
30
+ "./deploy": "./dist/deploy/index.js"
31
+ },
29
32
  "files": [
30
33
  "dist",
31
34
  "/oclif.manifest.json"
32
35
  ],
33
36
  "dependencies": {
34
- "@oclif/core": "2.9.4",
35
- "@shopify/cli-kit": "^3.47.5",
37
+ "@oclif/core": "2.11.5",
38
+ "@shopify/cli-kit": "^3.48.0",
36
39
  "async": "^3.2.4"
37
40
  },
38
41
  "devDependencies": {
@@ -40,14 +43,14 @@
40
43
  "@shopify/eslint-plugin": "^42.1.0",
41
44
  "@shopify/prettier-config": "^1.1.2",
42
45
  "@types/async": "^3.2.18",
43
- "@types/node": "^20.4.4",
44
- "@types/prettier": "^2.7.3",
45
- "eslint": "^8.45.0",
46
- "node-fetch": "^3.3.1",
46
+ "@types/node": "^20.4.5",
47
+ "@types/prettier": "^3.0.0",
48
+ "eslint": "^8.46.0",
49
+ "node-fetch": "^3.3.2",
47
50
  "oclif": "^3",
48
51
  "tsup": "^7.1.0",
49
52
  "typescript": "^5.1.3",
50
- "vite": "^4.4.6",
53
+ "vite": "^4.4.8",
51
54
  "vitest": "^0.33.0"
52
55
  },
53
56
  "prettier": "@shopify/prettier-config",