@shopify/oxygen-cli 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
package/dist/deploy/types.d.ts
CHANGED
@@ -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
|
});
|
package/oclif.manifest.json
CHANGED
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.
|
8
|
+
"version": "1.8.0",
|
9
9
|
"type": "module",
|
10
10
|
"scripts": {
|
11
11
|
"build": "tsup --clean --config ./tsup.config.ts && oclif manifest",
|
@@ -31,8 +31,8 @@
|
|
31
31
|
"/oclif.manifest.json"
|
32
32
|
],
|
33
33
|
"dependencies": {
|
34
|
-
"@oclif/core": "2.
|
35
|
-
"@shopify/cli-kit": "^3.
|
34
|
+
"@oclif/core": "2.10.0",
|
35
|
+
"@shopify/cli-kit": "^3.48.0",
|
36
36
|
"async": "^3.2.4"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
@@ -40,14 +40,14 @@
|
|
40
40
|
"@shopify/eslint-plugin": "^42.1.0",
|
41
41
|
"@shopify/prettier-config": "^1.1.2",
|
42
42
|
"@types/async": "^3.2.18",
|
43
|
-
"@types/node": "^20.4.
|
43
|
+
"@types/node": "^20.4.5",
|
44
44
|
"@types/prettier": "^2.7.3",
|
45
45
|
"eslint": "^8.45.0",
|
46
|
-
"node-fetch": "^3.3.
|
46
|
+
"node-fetch": "^3.3.2",
|
47
47
|
"oclif": "^3",
|
48
48
|
"tsup": "^7.1.0",
|
49
49
|
"typescript": "^5.1.3",
|
50
|
-
"vite": "^4.4.
|
50
|
+
"vite": "^4.4.7",
|
51
51
|
"vitest": "^0.33.0"
|
52
52
|
},
|
53
53
|
"prettier": "@shopify/prettier-config",
|