@applicaster/zapplicaster-cli 16.0.0-alpha.1745039402 → 16.0.0-alpha.1774022213
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.
- package/package.json +5 -5
- package/src/commands/prepareWorkspace/__tests__/__snapshots__/configurator.test.js.snap +2 -0
- package/src/commands/prepareWorkspace/appBootstrapper.js +9 -0
- package/src/commands/prepareWorkspace/configurator.js +19 -0
- package/src/commands/publishPlugin/__tests__/commitToGit.test.js +1 -1
- package/src/commands/publishPlugin/__tests__/configurator.test.js +2 -2
- package/src/commands/publishPlugin/__tests__/zappApi.test.js +268 -0
- package/src/commands/publishPlugin/__tests__/zappifestPublish.test.js +35 -32
- package/src/commands/publishPlugin/commitToGit.js +1 -1
- package/src/commands/publishPlugin/configurator.js +1 -1
- package/src/commands/publishPlugin/updateCorePluginsIfNeeded.js +22 -12
- package/src/commands/publishPlugin/zappApi.js +285 -0
- package/src/commands/publishPlugin/zappifestPublish.js +72 -7
- package/src/commands/reloadConfig/__tests__/__snapshots__/reloadConfig.test.js.snap +58 -0
- package/src/commands/reloadConfig/__tests__/reloadConfig.test.js +86 -0
- package/src/commands/reloadConfig/index.js +6 -6
- package/src/commands/publishPlugin/__tests__/__snapshots__/zappifestPublish.test.js.snap +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapplicaster-cli",
|
|
3
|
-
"version": "16.0.0-alpha.
|
|
3
|
+
"version": "16.0.0-alpha.1774022213",
|
|
4
4
|
"description": "CLI Tool for the zapp app and Quick Brick project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/zapp-react-dom-cli-template": "16.0.0-alpha.
|
|
32
|
-
"@applicaster/zapp-react-native-android-tv-cli-template": "16.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-react-native-cli-template": "16.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-tvos-cli-template": "16.0.0-alpha.
|
|
31
|
+
"@applicaster/zapp-react-dom-cli-template": "16.0.0-alpha.1774022213",
|
|
32
|
+
"@applicaster/zapp-react-native-android-tv-cli-template": "16.0.0-alpha.1774022213",
|
|
33
|
+
"@applicaster/zapp-react-native-cli-template": "16.0.0-alpha.1774022213",
|
|
34
|
+
"@applicaster/zapp-react-native-tvos-cli-template": "16.0.0-alpha.1774022213",
|
|
35
35
|
"axios": "^0.28.0",
|
|
36
36
|
"camelize": "^1.0.0",
|
|
37
37
|
"chalk": "^2.3.2",
|
|
@@ -8,6 +8,7 @@ exports[`configurator builds the configuration object 1`] = `
|
|
|
8
8
|
"appVersionId": "APP_VERSION_ID",
|
|
9
9
|
"assets_url": "https://assets-secure.applicaster.com/zapp/accounts/5ae06cef8fba0f00084bd3c6/apps/com.quickbricktest/apple_store/1.8/styles/assets_styles.json",
|
|
10
10
|
"otherParam": "param",
|
|
11
|
+
"vidaa_client_partner_id": undefined,
|
|
11
12
|
},
|
|
12
13
|
"destinationPath": "development-app",
|
|
13
14
|
"deviceTarget": undefined,
|
|
@@ -32,6 +33,7 @@ exports[`configurator sets a null path if none is provided and the cli doesn't r
|
|
|
32
33
|
"appVersionId": "APP_VERSION_ID",
|
|
33
34
|
"assets_url": "https://assets-secure.applicaster.com/zapp/accounts/5ae06cef8fba0f00084bd3c6/apps/com.quickbricktest/apple_store/1.8/styles/assets_styles.json",
|
|
34
35
|
"otherParam": "param",
|
|
36
|
+
"vidaa_client_partner_id": undefined,
|
|
35
37
|
},
|
|
36
38
|
"destinationPath": null,
|
|
37
39
|
"deviceTarget": undefined,
|
|
@@ -193,6 +193,15 @@ async function appBootstrapper(configuration) {
|
|
|
193
193
|
.map(toDayJSLocaleMap)
|
|
194
194
|
.filter((v) => v !== "en");
|
|
195
195
|
|
|
196
|
+
if (
|
|
197
|
+
configuration.buildParams.device_target === "vidaa" &&
|
|
198
|
+
!configuration.buildParams.vidaa_client_partner_id
|
|
199
|
+
) {
|
|
200
|
+
logger.warn(
|
|
201
|
+
"In order to use the VIDAA SDK you will need to set vidaa_client_partner_id"
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
196
205
|
configuration.excludedNodeModules = getExcludedNodeModules(plugins);
|
|
197
206
|
const { filesToRender } = template.files;
|
|
198
207
|
|
|
@@ -9,6 +9,22 @@ const { getAppVersionParams } = require("../../zapp");
|
|
|
9
9
|
const { resolveAppTemplate } = require("../../templates");
|
|
10
10
|
const { isZappReactNativeRepo } = require("../../settings");
|
|
11
11
|
|
|
12
|
+
function resolveVidaaClientPartnerId(buildParams = {}) {
|
|
13
|
+
const fromBuildParams = buildParams.vidaa_client_partner_id;
|
|
14
|
+
|
|
15
|
+
if (typeof fromBuildParams === "string" && fromBuildParams.trim()) {
|
|
16
|
+
return fromBuildParams.trim();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const fromEnv = process.env.vidaa_client_partner_id;
|
|
20
|
+
|
|
21
|
+
if (typeof fromEnv === "string" && fromEnv.trim()) {
|
|
22
|
+
return fromEnv.trim();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
12
28
|
const store_map = {
|
|
13
29
|
amazon: "amazon",
|
|
14
30
|
google_play: "android",
|
|
@@ -78,6 +94,9 @@ async function configurator({ cliArgs, cliOptions }) {
|
|
|
78
94
|
|
|
79
95
|
const buildParams = await getAppVersionParams(appVersionId);
|
|
80
96
|
|
|
97
|
+
buildParams.vidaa_client_partner_id =
|
|
98
|
+
resolveVidaaClientPartnerId(buildParams);
|
|
99
|
+
|
|
81
100
|
delete buildParams.styles_url; // deprecated
|
|
82
101
|
|
|
83
102
|
const platform = resolvePlatform(buildParams.assets_url);
|
|
@@ -14,7 +14,7 @@ const getOptions = (opts = {}) => ({
|
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
jest.mock("simple-git
|
|
17
|
+
jest.mock("simple-git", () =>
|
|
18
18
|
jest.fn((path) => {
|
|
19
19
|
return {
|
|
20
20
|
status: function () {
|
|
@@ -87,7 +87,7 @@ jest.mock("fs", () => ({
|
|
|
87
87
|
}));
|
|
88
88
|
|
|
89
89
|
const logger = require("../../../logger");
|
|
90
|
-
const git = require("simple-git
|
|
90
|
+
const git = require("simple-git");
|
|
91
91
|
|
|
92
92
|
const { configurator } = require("../configurator");
|
|
93
93
|
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
const {
|
|
2
|
+
formatIdentifier,
|
|
3
|
+
findPlugin,
|
|
4
|
+
uploadPluginVersion,
|
|
5
|
+
ZAPP_URL,
|
|
6
|
+
USER_AGENT,
|
|
7
|
+
} = require("../zappApi");
|
|
8
|
+
|
|
9
|
+
describe("zappApi", () => {
|
|
10
|
+
const originalFetch = global.fetch;
|
|
11
|
+
const originalToken = process.env.ZAPP_TOKEN;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
process.env.ZAPP_TOKEN = "dummy-token";
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
global.fetch = originalFetch;
|
|
19
|
+
process.env.ZAPP_TOKEN = originalToken;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe("formatIdentifier", () => {
|
|
23
|
+
it("strips _ios, -ios, _android, -android suffixes", () => {
|
|
24
|
+
expect(formatIdentifier("my_plugin_ios")).toBe("my_plugin");
|
|
25
|
+
expect(formatIdentifier("my_plugin-ios")).toBe("my_plugin");
|
|
26
|
+
expect(formatIdentifier("my_plugin_android")).toBe("my_plugin");
|
|
27
|
+
expect(formatIdentifier("my_plugin-android")).toBe("my_plugin");
|
|
28
|
+
expect(formatIdentifier("my_plugin")).toBe("my_plugin");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("handles empty or null identifier gracefully", () => {
|
|
32
|
+
expect(formatIdentifier("")).toBe("");
|
|
33
|
+
expect(formatIdentifier(null)).toBe("");
|
|
34
|
+
expect(formatIdentifier(undefined)).toBe("");
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe("findPlugin", () => {
|
|
39
|
+
it("finds plugin by slug on direct lookup", async () => {
|
|
40
|
+
const mockPlugin = {
|
|
41
|
+
id: 42,
|
|
42
|
+
name: "My Plugin",
|
|
43
|
+
external_identifier: "my-plugin",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
global.fetch = jest.fn().mockResolvedValue({
|
|
47
|
+
ok: true,
|
|
48
|
+
status: 200,
|
|
49
|
+
json: async () => mockPlugin,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const result = await findPlugin({
|
|
53
|
+
identifier: "my-plugin_ios",
|
|
54
|
+
name: "My Plugin",
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(result).toEqual(mockPlugin);
|
|
58
|
+
|
|
59
|
+
expect(global.fetch).toHaveBeenCalledWith(
|
|
60
|
+
`${ZAPP_URL}/plugins/my-plugin.json?access_token=dummy-token`,
|
|
61
|
+
expect.objectContaining({
|
|
62
|
+
headers: expect.objectContaining({ Accept: "application/json" }),
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("falls back to raw identifier if formatted slug returns 404", async () => {
|
|
68
|
+
const mockPlugin = {
|
|
69
|
+
id: 42,
|
|
70
|
+
name: "My Plugin",
|
|
71
|
+
external_identifier: "my-plugin_ios",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
global.fetch = jest
|
|
75
|
+
.fn()
|
|
76
|
+
.mockResolvedValueOnce({
|
|
77
|
+
ok: false,
|
|
78
|
+
status: 404,
|
|
79
|
+
})
|
|
80
|
+
.mockResolvedValueOnce({
|
|
81
|
+
ok: true,
|
|
82
|
+
status: 200,
|
|
83
|
+
json: async () => mockPlugin,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const result = await findPlugin({
|
|
87
|
+
identifier: "my-plugin_ios",
|
|
88
|
+
name: "My Plugin",
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
expect(result).toEqual(mockPlugin);
|
|
92
|
+
expect(global.fetch).toHaveBeenCalledTimes(2);
|
|
93
|
+
|
|
94
|
+
expect(global.fetch).toHaveBeenNthCalledWith(
|
|
95
|
+
1,
|
|
96
|
+
`${ZAPP_URL}/plugins/my-plugin.json?access_token=dummy-token`,
|
|
97
|
+
expect.anything()
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
expect(global.fetch).toHaveBeenNthCalledWith(
|
|
101
|
+
2,
|
|
102
|
+
`${ZAPP_URL}/plugins/my-plugin_ios.json?access_token=dummy-token`,
|
|
103
|
+
expect.anything()
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("throws error when plugin is not found in Zapp", async () => {
|
|
108
|
+
global.fetch = jest.fn().mockResolvedValue({
|
|
109
|
+
ok: false,
|
|
110
|
+
status: 404,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
await expect(
|
|
114
|
+
findPlugin({ identifier: "non-existent", name: "Non Existent" })
|
|
115
|
+
).rejects.toThrow(
|
|
116
|
+
"Plugin with identifier 'non-existent' not found in Zapp"
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("throws error on server error with status text", async () => {
|
|
121
|
+
global.fetch = jest.fn().mockResolvedValue({
|
|
122
|
+
ok: false,
|
|
123
|
+
status: 500,
|
|
124
|
+
text: async () => "Internal Error",
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
await expect(findPlugin({ identifier: "some-plugin" })).rejects.toThrow(
|
|
128
|
+
"Failed to fetch plugin 'some-plugin' from Zapp: HTTP 500 - Internal Error"
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("throws error when ZAPP_TOKEN is not set", async () => {
|
|
133
|
+
delete process.env.ZAPP_TOKEN;
|
|
134
|
+
|
|
135
|
+
await expect(
|
|
136
|
+
findPlugin({ identifier: "my-plugin", token: null })
|
|
137
|
+
).rejects.toThrow("ZAPP_TOKEN environment variable is not set");
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
describe("uploadPluginVersion", () => {
|
|
142
|
+
it("submits multipart FormData with targets and ui_frameworks to /plugin_versions", async () => {
|
|
143
|
+
let requestBody = null;
|
|
144
|
+
let requestMethod = null;
|
|
145
|
+
let requestHeaders = null;
|
|
146
|
+
|
|
147
|
+
global.fetch = jest.fn().mockImplementation((url, options) => {
|
|
148
|
+
if (url.includes("/targets.json")) {
|
|
149
|
+
return Promise.resolve({
|
|
150
|
+
ok: true,
|
|
151
|
+
status: 200,
|
|
152
|
+
json: async () => [
|
|
153
|
+
{ id: 1, name: "mobile" },
|
|
154
|
+
{ id: 2, name: "tv" },
|
|
155
|
+
],
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (url.includes("/ui_frameworks.json")) {
|
|
160
|
+
return Promise.resolve({
|
|
161
|
+
ok: true,
|
|
162
|
+
status: 200,
|
|
163
|
+
json: async () => [
|
|
164
|
+
{ id: 1, name: "native" },
|
|
165
|
+
{ id: 2, name: "quickbrick" },
|
|
166
|
+
],
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
requestMethod = options.method;
|
|
171
|
+
requestBody = options.body;
|
|
172
|
+
requestHeaders = options.headers;
|
|
173
|
+
|
|
174
|
+
return Promise.resolve({
|
|
175
|
+
ok: true,
|
|
176
|
+
status: 200,
|
|
177
|
+
text: async () => "OK",
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const manifest = {
|
|
182
|
+
name: "My Plugin",
|
|
183
|
+
identifier: "my-plugin",
|
|
184
|
+
manifest_version: "1.0.0",
|
|
185
|
+
platform: "ios_for_quickbrick",
|
|
186
|
+
author_email: "test@example.com",
|
|
187
|
+
scheme: "my-scheme",
|
|
188
|
+
targets: ["mobile"],
|
|
189
|
+
ui_frameworks: ["quickbrick"],
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
await uploadPluginVersion({
|
|
193
|
+
pluginId: 42,
|
|
194
|
+
manifest,
|
|
195
|
+
token: "secret-token",
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
expect(global.fetch).toHaveBeenCalledWith(
|
|
199
|
+
`${ZAPP_URL}/plugin_versions`,
|
|
200
|
+
expect.objectContaining({
|
|
201
|
+
method: "POST",
|
|
202
|
+
headers: expect.objectContaining({
|
|
203
|
+
"User-Agent": USER_AGENT,
|
|
204
|
+
Accept: "application/json",
|
|
205
|
+
}),
|
|
206
|
+
})
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
expect(requestMethod).toBe("POST");
|
|
210
|
+
expect(requestHeaders["User-Agent"]).toBe(USER_AGENT);
|
|
211
|
+
expect(requestBody).toBeInstanceOf(FormData);
|
|
212
|
+
expect(requestBody.get("access_token")).toBe("secret-token");
|
|
213
|
+
expect(requestBody.get("plugin_version[plugin_id]")).toBe("42");
|
|
214
|
+
expect(requestBody.get("plugin_version[version]")).toBe("1.0.0");
|
|
215
|
+
|
|
216
|
+
expect(requestBody.get("plugin_version[platform]")).toBe(
|
|
217
|
+
"ios_for_quickbrick"
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
expect(requestBody.get("plugin_version[author_email]")).toBe(
|
|
221
|
+
"test@example.com"
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
expect(requestBody.get("plugin_version[scheme]")).toBe("my-scheme");
|
|
225
|
+
|
|
226
|
+
expect(requestBody.get("plugin_version[targets]")).toBe(
|
|
227
|
+
JSON.stringify([1])
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
expect(requestBody.get("plugin_version[ui_frameworks]")).toBe(
|
|
231
|
+
JSON.stringify([2])
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
expect(requestBody.get("plugin_version[manifest]")).toBe(
|
|
235
|
+
JSON.stringify(manifest)
|
|
236
|
+
);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("throws error on HTTP failure status", async () => {
|
|
240
|
+
global.fetch = jest.fn().mockImplementation((url) => {
|
|
241
|
+
if (url.includes("/targets.json") || url.includes("/ui_frameworks.json")) {
|
|
242
|
+
return Promise.resolve({
|
|
243
|
+
ok: true,
|
|
244
|
+
status: 200,
|
|
245
|
+
json: async () => [],
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return Promise.resolve({
|
|
250
|
+
ok: false,
|
|
251
|
+
status: 422,
|
|
252
|
+
text: async () => "Validation failed: version has already been taken",
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const manifest = {
|
|
257
|
+
manifest_version: "1.0.0",
|
|
258
|
+
platform: "ios_for_quickbrick",
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
await expect(
|
|
262
|
+
uploadPluginVersion({ pluginId: 42, manifest })
|
|
263
|
+
).rejects.toThrow(
|
|
264
|
+
"Failed to upload manifest for platform 'ios_for_quickbrick': HTTP 422 - Validation failed: version has already been taken"
|
|
265
|
+
);
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
});
|
|
@@ -34,20 +34,44 @@ jest.mock("../../../logger", () => ({
|
|
|
34
34
|
log: jest.fn(),
|
|
35
35
|
}));
|
|
36
36
|
|
|
37
|
+
jest.mock("../zappApi", () => ({
|
|
38
|
+
findPlugin: jest.fn().mockResolvedValue({ id: 99, name: "Test Plugin" }),
|
|
39
|
+
uploadPluginVersion: jest.fn().mockResolvedValue({ ok: true }),
|
|
40
|
+
}));
|
|
41
|
+
|
|
37
42
|
const { zappifestPublish } = require("../zappifestPublish");
|
|
38
43
|
const { runInShellAsync } = require("../../../shell");
|
|
44
|
+
const { findPlugin, uploadPluginVersion } = require("../zappApi");
|
|
39
45
|
const logger = require("../../../logger");
|
|
40
|
-
const { inspect } = require("util");
|
|
41
46
|
|
|
42
47
|
function clearMocks() {
|
|
43
48
|
logger.log.mockClear();
|
|
44
49
|
runInShellAsync.mockClear();
|
|
50
|
+
findPlugin.mockClear();
|
|
51
|
+
uploadPluginVersion.mockClear();
|
|
52
|
+
delete process.env.USE_LEGACY_ZAPPIFEST;
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
describe("publish zappifests", () => {
|
|
48
56
|
beforeEach(clearMocks);
|
|
49
57
|
|
|
50
|
-
it("
|
|
58
|
+
it("publishes manifests natively via zappApi by default", async () => {
|
|
59
|
+
const configuration = getConfig();
|
|
60
|
+
|
|
61
|
+
const result = await zappifestPublish(configuration);
|
|
62
|
+
expect(result).toBe(true);
|
|
63
|
+
|
|
64
|
+
expect(findPlugin).toHaveBeenCalledWith({
|
|
65
|
+
identifier: undefined,
|
|
66
|
+
name: "my plugin name",
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
expect(uploadPluginVersion).toHaveBeenCalledTimes(2);
|
|
70
|
+
expect(runInShellAsync).not.toHaveBeenCalled();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("falls back to legacy Ruby zappifest when USE_LEGACY_ZAPPIFEST is true", async () => {
|
|
74
|
+
process.env.USE_LEGACY_ZAPPIFEST = "true";
|
|
51
75
|
const configuration = getConfig();
|
|
52
76
|
|
|
53
77
|
const expectedResult = new Array(configuration.platforms.length)
|
|
@@ -66,49 +90,28 @@ describe("publish zappifests", () => {
|
|
|
66
90
|
`zappifest publish --manifest ${__dirname}/manifests/${val}.json --account A1234`
|
|
67
91
|
);
|
|
68
92
|
});
|
|
93
|
+
|
|
94
|
+
expect(findPlugin).not.toHaveBeenCalled();
|
|
95
|
+
expect(uploadPluginVersion).not.toHaveBeenCalled();
|
|
69
96
|
});
|
|
70
97
|
|
|
71
98
|
it("only logs in the console when running with dry run flag", async () => {
|
|
72
99
|
const configuration = getConfig({ dryRun: true });
|
|
73
100
|
|
|
74
|
-
|
|
75
|
-
.fill()
|
|
76
|
-
.map(() => true);
|
|
77
|
-
|
|
78
|
-
expect(await zappifestPublish(configuration)).toEqual(expectedResult);
|
|
101
|
+
expect(await zappifestPublish(configuration)).toBe(true);
|
|
79
102
|
expect(runInShellAsync).not.toHaveBeenCalled();
|
|
103
|
+
expect(uploadPluginVersion).not.toHaveBeenCalled();
|
|
80
104
|
|
|
81
|
-
expect(logger.log).
|
|
82
|
-
1 + configuration.platforms.length * 2
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
expect(logger.log).toHaveBeenNthCalledWith(
|
|
86
|
-
1,
|
|
105
|
+
expect(logger.log).toHaveBeenCalledWith(
|
|
87
106
|
"Running with --dry-run or --manifest-only option - not actually pushing to zapp"
|
|
88
107
|
);
|
|
89
|
-
|
|
90
|
-
configuration.platforms.forEach((val, index) => {
|
|
91
|
-
expect(logger.log).toHaveBeenNthCalledWith(
|
|
92
|
-
index * 2 + 2,
|
|
93
|
-
expect.stringMatching(
|
|
94
|
-
/running zappifest publish --manifest .*(ios|android)\.json/
|
|
95
|
-
)
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
expect(logger.log).toHaveBeenNthCalledWith(
|
|
99
|
-
index * 2 + 3,
|
|
100
|
-
`with manifest: ${inspect(require(`./manifests/${val}.json`))}`
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
108
|
});
|
|
104
109
|
|
|
105
110
|
it("it throws if a manifest cannot be found", async () => {
|
|
106
111
|
const configuration = getConfig({ pluginPath: "resolve_error" });
|
|
107
|
-
expect(zappifestPublish(configuration)).rejects.toMatchSnapshot();
|
|
108
|
-
});
|
|
109
112
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
await expect(zappifestPublish(configuration)).rejects.toThrow(
|
|
114
|
+
"cannot resolve manifest"
|
|
115
|
+
);
|
|
113
116
|
});
|
|
114
117
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const R = require("ramda");
|
|
2
2
|
const { resolve } = require("path");
|
|
3
3
|
const semver = require("semver");
|
|
4
|
-
const git = require("simple-git
|
|
4
|
+
const git = require("simple-git");
|
|
5
5
|
const logger = require("../../logger");
|
|
6
6
|
const { existsSync } = require("fs");
|
|
7
7
|
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
const R = require("ramda");
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
|
-
const { writeJsonToFile } = require("../../file");
|
|
4
|
+
const { writeJsonToFile, readJsonFile } = require("../../file");
|
|
5
5
|
const logger = require("../../logger");
|
|
6
6
|
|
|
7
7
|
const PACKAGE_DOT_JSON = "package.json";
|
|
8
8
|
const QUICK_BRICK_WORKSPACE_NAME = "quick-brick";
|
|
9
9
|
const CORE_PLUGINS_PATH = "packages/quick-brick-core-plugins";
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
const { name: workspaceName } = require(
|
|
13
|
-
path.join(process.cwd(), PACKAGE_DOT_JSON)
|
|
14
|
-
);
|
|
11
|
+
let writeLock = Promise.resolve();
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
async function doUpdateCorePlugins(configuration) {
|
|
14
|
+
const rootPackageJsonPath = path.join(process.cwd(), PACKAGE_DOT_JSON);
|
|
15
|
+
const rootPackageJson = await readJsonFile(rootPackageJsonPath);
|
|
16
|
+
|
|
17
|
+
if (rootPackageJson.name !== QUICK_BRICK_WORKSPACE_NAME) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
const { version, pluginPackageJson } = configuration;
|
|
21
22
|
const { name } = pluginPackageJson;
|
|
22
23
|
|
|
23
|
-
const
|
|
24
|
-
|
|
24
|
+
const corePluginsPackageJsonPath = path.join(
|
|
25
|
+
process.cwd(),
|
|
26
|
+
CORE_PLUGINS_PATH,
|
|
27
|
+
PACKAGE_DOT_JSON
|
|
25
28
|
);
|
|
26
29
|
|
|
30
|
+
const corePluginsPackageJson = await readJsonFile(corePluginsPackageJsonPath);
|
|
31
|
+
|
|
27
32
|
const { dependencies } = corePluginsPackageJson;
|
|
28
33
|
const isPluginCore = R.contains(name, R.keys(dependencies));
|
|
29
34
|
|
|
30
35
|
if (isPluginCore) {
|
|
31
36
|
corePluginsPackageJson.dependencies[name] = version;
|
|
32
37
|
|
|
33
|
-
await writeJsonToFile(
|
|
34
|
-
path.join(process.cwd(), CORE_PLUGINS_PATH, PACKAGE_DOT_JSON),
|
|
35
|
-
corePluginsPackageJson
|
|
36
|
-
);
|
|
38
|
+
await writeJsonToFile(corePluginsPackageJsonPath, corePluginsPackageJson);
|
|
37
39
|
|
|
38
40
|
logger.log(`Core Plugins updated with ${name}@${version}`);
|
|
39
41
|
} else {
|
|
@@ -41,4 +43,12 @@ async function updateCorePluginsIfNeeded(configuration) {
|
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
async function updateCorePluginsIfNeeded(configuration) {
|
|
47
|
+
// Ensure that concurrent publishing tasks do not race when updating core plugins
|
|
48
|
+
const result = writeLock.then(() => doUpdateCorePlugins(configuration));
|
|
49
|
+
writeLock = result.catch(() => {});
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
module.exports = { updateCorePluginsIfNeeded };
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
const ZAPP_URL =
|
|
2
|
+
process.env.ZAPP_URL || "https://zapp.applicaster.com/api/v1/admin";
|
|
3
|
+
|
|
4
|
+
const USER_AGENT = "Zappifest/0.66.0";
|
|
5
|
+
|
|
6
|
+
const DEFAULT_TARGETS_MAP = {
|
|
7
|
+
mobile: 1,
|
|
8
|
+
tv: 2,
|
|
9
|
+
roku: 3,
|
|
10
|
+
tablet: 4,
|
|
11
|
+
web: 5,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const DEFAULT_UI_FRAMEWORKS_MAP = {
|
|
15
|
+
native: 1,
|
|
16
|
+
quickbrick: 2,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
let targetsCache = null;
|
|
20
|
+
let uiFrameworksCache = null;
|
|
21
|
+
|
|
22
|
+
async function getTargetsMap({
|
|
23
|
+
token = process.env.ZAPP_TOKEN,
|
|
24
|
+
baseUrl = ZAPP_URL,
|
|
25
|
+
} = {}) {
|
|
26
|
+
if (targetsCache) {
|
|
27
|
+
return targetsCache;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const url = `${baseUrl}/targets.json?access_token=${encodeURIComponent(token)}`;
|
|
32
|
+
|
|
33
|
+
const res = await fetch(url, {
|
|
34
|
+
headers: {
|
|
35
|
+
Accept: "application/json",
|
|
36
|
+
"User-Agent": USER_AGENT,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (res.ok) {
|
|
41
|
+
const data = await res.json();
|
|
42
|
+
const map = {};
|
|
43
|
+
|
|
44
|
+
data.forEach((t) => {
|
|
45
|
+
if (t.name && t.id) {
|
|
46
|
+
map[t.name] = t.id;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
targetsCache = map;
|
|
51
|
+
|
|
52
|
+
return map;
|
|
53
|
+
}
|
|
54
|
+
} catch (_e) {
|
|
55
|
+
// fallback to static defaults
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return DEFAULT_TARGETS_MAP;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function getUiFrameworksMap({
|
|
62
|
+
token = process.env.ZAPP_TOKEN,
|
|
63
|
+
baseUrl = ZAPP_URL,
|
|
64
|
+
} = {}) {
|
|
65
|
+
if (uiFrameworksCache) {
|
|
66
|
+
return uiFrameworksCache;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const url = `${baseUrl}/ui_frameworks.json?access_token=${encodeURIComponent(token)}`;
|
|
71
|
+
|
|
72
|
+
const res = await fetch(url, {
|
|
73
|
+
headers: {
|
|
74
|
+
Accept: "application/json",
|
|
75
|
+
"User-Agent": USER_AGENT,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (res.ok) {
|
|
80
|
+
const data = await res.json();
|
|
81
|
+
const map = {};
|
|
82
|
+
|
|
83
|
+
data.forEach((f) => {
|
|
84
|
+
if (f.name && f.id) {
|
|
85
|
+
map[f.name] = f.id;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
uiFrameworksCache = map;
|
|
90
|
+
|
|
91
|
+
return map;
|
|
92
|
+
}
|
|
93
|
+
} catch (_e) {
|
|
94
|
+
// fallback to static defaults
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return DEFAULT_UI_FRAMEWORKS_MAP;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function formatIdentifier(identifier) {
|
|
101
|
+
if (!identifier) return "";
|
|
102
|
+
|
|
103
|
+
return String(identifier).replace(/((_|-)(ios|android))/gi, "");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function findPlugin({
|
|
107
|
+
identifier,
|
|
108
|
+
_name,
|
|
109
|
+
token = process.env.ZAPP_TOKEN,
|
|
110
|
+
baseUrl = ZAPP_URL,
|
|
111
|
+
}) {
|
|
112
|
+
if (!token) {
|
|
113
|
+
throw new Error("ZAPP_TOKEN environment variable is not set");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const formattedSlug = encodeURIComponent(formatIdentifier(identifier));
|
|
117
|
+
let url = `${baseUrl}/plugins/${formattedSlug}.json?access_token=${encodeURIComponent(token)}`;
|
|
118
|
+
|
|
119
|
+
let res = await fetch(url, {
|
|
120
|
+
headers: {
|
|
121
|
+
Accept: "application/json",
|
|
122
|
+
"User-Agent": USER_AGENT,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
if (res.ok) {
|
|
127
|
+
const plugin = await res.json();
|
|
128
|
+
|
|
129
|
+
if (plugin && plugin.id) {
|
|
130
|
+
return plugin;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Fallback: if formatted slug returned 404, try raw identifier if different
|
|
135
|
+
const rawSlug = encodeURIComponent(identifier);
|
|
136
|
+
|
|
137
|
+
if (res.status === 404 && rawSlug !== formattedSlug) {
|
|
138
|
+
url = `${baseUrl}/plugins/${rawSlug}.json?access_token=${encodeURIComponent(token)}`;
|
|
139
|
+
|
|
140
|
+
res = await fetch(url, {
|
|
141
|
+
headers: {
|
|
142
|
+
Accept: "application/json",
|
|
143
|
+
"User-Agent": USER_AGENT,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
if (res.ok) {
|
|
148
|
+
const plugin = await res.json();
|
|
149
|
+
|
|
150
|
+
if (plugin && plugin.id) {
|
|
151
|
+
return plugin;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (res.status === 404) {
|
|
157
|
+
throw new Error(
|
|
158
|
+
`Plugin with identifier '${identifier}' not found in Zapp.`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const errText = await res.text();
|
|
163
|
+
throw new Error(
|
|
164
|
+
`Failed to fetch plugin '${identifier}' from Zapp: HTTP ${res.status} - ${errText}`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function uploadPluginVersion({
|
|
169
|
+
pluginId,
|
|
170
|
+
manifest,
|
|
171
|
+
token = process.env.ZAPP_TOKEN,
|
|
172
|
+
baseUrl = ZAPP_URL,
|
|
173
|
+
}) {
|
|
174
|
+
if (!token) {
|
|
175
|
+
throw new Error("ZAPP_TOKEN environment variable is not set");
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (!pluginId) {
|
|
179
|
+
throw new Error("pluginId is required to upload plugin version");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const targetsMap = await getTargetsMap({ token, baseUrl });
|
|
183
|
+
const uiFrameworksMap = await getUiFrameworksMap({ token, baseUrl });
|
|
184
|
+
|
|
185
|
+
const url = `${baseUrl}/plugin_versions`;
|
|
186
|
+
|
|
187
|
+
const formData = new FormData();
|
|
188
|
+
formData.append("access_token", token);
|
|
189
|
+
formData.append("plugin_version[plugin_id]", String(pluginId));
|
|
190
|
+
|
|
191
|
+
formData.append(
|
|
192
|
+
"plugin_version[manifest]",
|
|
193
|
+
typeof manifest === "string" ? manifest : JSON.stringify(manifest)
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
if (manifest.author_email) {
|
|
197
|
+
formData.append("plugin_version[author_email]", manifest.author_email);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (manifest.manifest_version) {
|
|
201
|
+
formData.append("plugin_version[version]", manifest.manifest_version);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (manifest.platform) {
|
|
205
|
+
formData.append("plugin_version[platform]", manifest.platform);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (manifest.scheme) {
|
|
209
|
+
formData.append("plugin_version[scheme]", manifest.scheme);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
formData.append(
|
|
213
|
+
"plugin_version[latest_version]",
|
|
214
|
+
String(manifest.latest_version ?? true)
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
let rawTargets = manifest.targets;
|
|
218
|
+
|
|
219
|
+
if (!rawTargets || !rawTargets.length) {
|
|
220
|
+
const isTV =
|
|
221
|
+
manifest.platform &&
|
|
222
|
+
(manifest.platform.includes("tv") ||
|
|
223
|
+
manifest.platform.includes("lg") ||
|
|
224
|
+
manifest.platform.includes("samsung") ||
|
|
225
|
+
manifest.platform.includes("vidaa") ||
|
|
226
|
+
manifest.platform.includes("vizio"));
|
|
227
|
+
|
|
228
|
+
rawTargets = isTV ? ["tv"] : ["mobile"];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const targetIds = rawTargets
|
|
232
|
+
.map((name) => targetsMap[name])
|
|
233
|
+
.filter(Boolean);
|
|
234
|
+
|
|
235
|
+
if (targetIds.length) {
|
|
236
|
+
formData.append("plugin_version[targets]", JSON.stringify(targetIds));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
let rawUiFrameworks = manifest.ui_frameworks;
|
|
240
|
+
|
|
241
|
+
if (!rawUiFrameworks || !rawUiFrameworks.length) {
|
|
242
|
+
rawUiFrameworks = ["quickbrick"];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const uiFrameworkIds = rawUiFrameworks
|
|
246
|
+
.map((name) => uiFrameworksMap[name])
|
|
247
|
+
.filter(Boolean);
|
|
248
|
+
|
|
249
|
+
if (uiFrameworkIds.length) {
|
|
250
|
+
formData.append(
|
|
251
|
+
"plugin_version[ui_frameworks]",
|
|
252
|
+
JSON.stringify(uiFrameworkIds)
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const res = await fetch(url, {
|
|
257
|
+
method: "POST",
|
|
258
|
+
headers: {
|
|
259
|
+
Accept: "application/json",
|
|
260
|
+
"User-Agent": USER_AGENT,
|
|
261
|
+
},
|
|
262
|
+
body: formData,
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
if (!res.ok) {
|
|
266
|
+
const errText = await res.text();
|
|
267
|
+
throw new Error(
|
|
268
|
+
`Failed to upload manifest for platform '${manifest.platform}': HTTP ${res.status} - ${errText}`
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return res;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
module.exports = {
|
|
276
|
+
ZAPP_URL,
|
|
277
|
+
USER_AGENT,
|
|
278
|
+
DEFAULT_TARGETS_MAP,
|
|
279
|
+
DEFAULT_UI_FRAMEWORKS_MAP,
|
|
280
|
+
formatIdentifier,
|
|
281
|
+
getTargetsMap,
|
|
282
|
+
getUiFrameworksMap,
|
|
283
|
+
findPlugin,
|
|
284
|
+
uploadPluginVersion,
|
|
285
|
+
};
|
|
@@ -4,8 +4,9 @@ const { inspect } = require("util");
|
|
|
4
4
|
|
|
5
5
|
const { runInShellAsync } = require("../../shell");
|
|
6
6
|
const logger = require("../../logger");
|
|
7
|
+
const { findPlugin, uploadPluginVersion } = require("./zappApi");
|
|
7
8
|
|
|
8
|
-
function
|
|
9
|
+
function pushZappifestLegacy({
|
|
9
10
|
pluginPath,
|
|
10
11
|
dryRun,
|
|
11
12
|
manifestOnly,
|
|
@@ -26,6 +27,54 @@ function pushZappifest({
|
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
async function nativePublish({ platforms, pluginPath, dryRun, manifestOnly }) {
|
|
31
|
+
const manifests = platforms.map((platform) => {
|
|
32
|
+
const manifestPath = resolve(pluginPath, `manifests/${platform}.json`);
|
|
33
|
+
|
|
34
|
+
return require(manifestPath);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (dryRun || manifestOnly) {
|
|
38
|
+
manifests.forEach((m) => {
|
|
39
|
+
logger.log(`[dry-run] Would upload manifest for platform: ${m.platform}`);
|
|
40
|
+
logger.log(`[dry-run] Manifest: ${inspect(m)}`);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const firstManifest = manifests[0];
|
|
47
|
+
const { identifier, name } = firstManifest;
|
|
48
|
+
|
|
49
|
+
logger.log(`Looking up plugin '${identifier}' in Zapp...`);
|
|
50
|
+
const plugin = await findPlugin({ identifier, name });
|
|
51
|
+
logger.log(`Found plugin '${plugin.name}' (id: ${plugin.id}) in Zapp`);
|
|
52
|
+
|
|
53
|
+
const startTime = Date.now();
|
|
54
|
+
|
|
55
|
+
logger.log(
|
|
56
|
+
`Uploading ${manifests.length} platform manifest(s) directly to Zapp in parallel...`
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
await Promise.all(
|
|
60
|
+
manifests.map(async (manifest) => {
|
|
61
|
+
await uploadPluginVersion({ pluginId: plugin.id, manifest });
|
|
62
|
+
|
|
63
|
+
logger.log(
|
|
64
|
+
`✓ Uploaded manifest for platform '${manifest.platform}' (${manifest.manifest_version})`
|
|
65
|
+
);
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const duration = Date.now() - startTime;
|
|
70
|
+
|
|
71
|
+
logger.log(
|
|
72
|
+
`All ${manifests.length} manifest(s) successfully uploaded to Zapp in ${duration}ms`
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
29
78
|
async function zappifestPublish(configuration) {
|
|
30
79
|
const { platforms, pluginPath, dryRun, manifestOnly, zappOwnerAccountId } =
|
|
31
80
|
configuration;
|
|
@@ -42,12 +91,28 @@ async function zappifestPublish(configuration) {
|
|
|
42
91
|
return true;
|
|
43
92
|
}
|
|
44
93
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
94
|
+
if (process.env.USE_LEGACY_ZAPPIFEST === "true") {
|
|
95
|
+
logger.log("USE_LEGACY_ZAPPIFEST enabled: Using legacy Ruby zappifest CLI");
|
|
96
|
+
|
|
97
|
+
return Promise.all(
|
|
98
|
+
R.map(
|
|
99
|
+
pushZappifestLegacy({
|
|
100
|
+
pluginPath,
|
|
101
|
+
dryRun,
|
|
102
|
+
manifestOnly,
|
|
103
|
+
zappOwnerAccountId,
|
|
104
|
+
}),
|
|
105
|
+
platforms
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return nativePublish({
|
|
111
|
+
platforms,
|
|
112
|
+
pluginPath,
|
|
113
|
+
dryRun,
|
|
114
|
+
manifestOnly,
|
|
115
|
+
});
|
|
51
116
|
}
|
|
52
117
|
|
|
53
118
|
module.exports = { zappifestPublish };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`reloadConfig runs the reload config task 1`] = `
|
|
4
|
+
[
|
|
5
|
+
[
|
|
6
|
+
"reload configuration",
|
|
7
|
+
"We're reloading the configuration for your app",
|
|
8
|
+
],
|
|
9
|
+
]
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
exports[`reloadConfig runs the reload config task 2`] = `[]`;
|
|
13
|
+
|
|
14
|
+
exports[`reloadConfig runs the reload config task 3`] = `[]`;
|
|
15
|
+
|
|
16
|
+
exports[`reloadConfig runs the reload config task 4`] = `[]`;
|
|
17
|
+
|
|
18
|
+
exports[`reloadConfig runs the reload config task 5`] = `
|
|
19
|
+
[
|
|
20
|
+
[
|
|
21
|
+
"checking prerequisites...",
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
"Gathering configuration",
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
"Creating workspace",
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
"Creating runtime URLs configuration file",
|
|
31
|
+
],
|
|
32
|
+
[
|
|
33
|
+
"Retrieving configuration files",
|
|
34
|
+
],
|
|
35
|
+
]
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
exports[`reloadConfig runs the reload config task 6`] = `
|
|
39
|
+
[
|
|
40
|
+
[
|
|
41
|
+
"All good - moving on",
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
"configuration retrieved",
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
"Workspace created !",
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
"Runtime configuration URLs file created",
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
"Configuration files retrieved !",
|
|
54
|
+
],
|
|
55
|
+
]
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
exports[`reloadConfig runs the reload config task 7`] = `[]`;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const { reloadConfig } = require("../index");
|
|
2
|
+
|
|
3
|
+
const appVersionId = "e7a17c6f-4113-41ac-9450-6281d22153a1";
|
|
4
|
+
|
|
5
|
+
const options = {
|
|
6
|
+
appVersionId,
|
|
7
|
+
openSdk: true,
|
|
8
|
+
config: "some_file",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
jest.mock("../../../logger", () => ({
|
|
12
|
+
welcome: jest.fn(),
|
|
13
|
+
log: jest.fn(),
|
|
14
|
+
error: jest.fn(),
|
|
15
|
+
warn: jest.fn(),
|
|
16
|
+
startStep: jest.fn(),
|
|
17
|
+
endStep: jest.fn(),
|
|
18
|
+
success: jest.fn(),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock("../../prepareWorkspace/prerequisitesChecker.js", () => ({
|
|
22
|
+
prerequisitesChecker: jest.fn(() => true),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
const mockConfig = { appVersionId, buildParams: {} };
|
|
26
|
+
|
|
27
|
+
jest.mock("../../prepareWorkspace/configurator.js", () => ({
|
|
28
|
+
configurator: jest.fn(() => mockConfig),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
jest.mock("../../prepareWorkspace/workspaceCreator.js", () => ({
|
|
32
|
+
workspaceCreator: jest.fn(),
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
jest.mock("../../prepareWorkspace/configFilesRetriever.js", () => ({
|
|
36
|
+
configFilesRetriever: jest.fn(),
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
jest.mock("../../prepareWorkspace/runtimeConfigurationUrlsCreator.js", () => ({
|
|
40
|
+
runtimeConfigurationUrlsCreator: jest.fn(),
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
prerequisitesChecker,
|
|
45
|
+
} = require("../../prepareWorkspace/prerequisitesChecker");
|
|
46
|
+
|
|
47
|
+
const { configurator } = require("../../prepareWorkspace/configurator");
|
|
48
|
+
const { workspaceCreator } = require("../../prepareWorkspace/workspaceCreator");
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
configFilesRetriever,
|
|
52
|
+
} = require("../../prepareWorkspace/configFilesRetriever");
|
|
53
|
+
|
|
54
|
+
const {
|
|
55
|
+
runtimeConfigurationUrlsCreator,
|
|
56
|
+
} = require("../../prepareWorkspace/runtimeConfigurationUrlsCreator");
|
|
57
|
+
|
|
58
|
+
const logger = require("../../../logger");
|
|
59
|
+
|
|
60
|
+
describe("reloadConfig", () => {
|
|
61
|
+
it("runs the reload config task", async () => {
|
|
62
|
+
await reloadConfig(appVersionId, options);
|
|
63
|
+
|
|
64
|
+
expect(logger.welcome.mock.calls).toMatchSnapshot();
|
|
65
|
+
expect(logger.log.mock.calls).toMatchSnapshot();
|
|
66
|
+
expect(logger.error.mock.calls).toMatchSnapshot();
|
|
67
|
+
expect(logger.warn.mock.calls).toMatchSnapshot();
|
|
68
|
+
expect(logger.startStep.mock.calls).toMatchSnapshot();
|
|
69
|
+
expect(logger.endStep.mock.calls).toMatchSnapshot();
|
|
70
|
+
expect(logger.success.mock.calls).toMatchSnapshot();
|
|
71
|
+
|
|
72
|
+
expect(prerequisitesChecker).toHaveBeenCalledWith({
|
|
73
|
+
cliArgs: [appVersionId],
|
|
74
|
+
cliOptions: options,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
expect(configurator).toHaveBeenCalledWith({
|
|
78
|
+
cliArgs: [appVersionId],
|
|
79
|
+
cliOptions: options,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
expect(workspaceCreator).toHaveBeenCalledWith(mockConfig);
|
|
83
|
+
expect(runtimeConfigurationUrlsCreator).toHaveBeenCalledWith(mockConfig);
|
|
84
|
+
expect(configFilesRetriever).toHaveBeenCalledWith(mockConfig);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -27,18 +27,18 @@ const reloadConfigTask = {
|
|
|
27
27
|
error: "Could not create workspace",
|
|
28
28
|
completion: "Workspace created !",
|
|
29
29
|
},
|
|
30
|
-
{
|
|
31
|
-
start: "Retrieving configuration files",
|
|
32
|
-
run: configFilesRetriever,
|
|
33
|
-
error: "Could not retrieve configuration files",
|
|
34
|
-
completion: "Configuration files retrieved !",
|
|
35
|
-
},
|
|
36
30
|
{
|
|
37
31
|
start: "Creating runtime URLs configuration file",
|
|
38
32
|
run: runtimeConfigurationUrlsCreator,
|
|
39
33
|
error: "Could not create runtime_configuration_urls.json",
|
|
40
34
|
completion: "Runtime configuration URLs file created",
|
|
41
35
|
},
|
|
36
|
+
{
|
|
37
|
+
start: "Retrieving configuration files",
|
|
38
|
+
run: configFilesRetriever,
|
|
39
|
+
error: "Could not retrieve configuration files",
|
|
40
|
+
completion: "Configuration files retrieved !",
|
|
41
|
+
},
|
|
42
42
|
],
|
|
43
43
|
};
|
|
44
44
|
|