@applicaster/zapplicaster-cli 15.1.26-alpha.9986471322 → 15.1.26-rc.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.
- package/README.md +5 -9
- package/package.json +6 -7
- package/src/commands/init/setUpEnvironment.js +7 -2
- package/src/commands/prepareWorkspace/__tests__/__snapshots__/prerequisitesChecker-incorrecNode.test.js.snap +1 -1
- package/src/commands/prepareWorkspace/prerequisitesChecker.js +2 -2
- package/src/commands/publishPlugin/__tests__/__snapshots__/configurator.test.js.snap +2 -0
- package/src/commands/publishPlugin/__tests__/__snapshots__/zappifestPublish.test.js.snap +5 -0
- package/src/commands/publishPlugin/__tests__/commitToGit.test.js +1 -1
- package/src/commands/publishPlugin/__tests__/configurator.test.js +4 -7
- package/src/commands/publishPlugin/__tests__/manifests/android.json +1 -3
- package/src/commands/publishPlugin/__tests__/manifests/ios.json +1 -3
- package/src/commands/publishPlugin/__tests__/npmPublish.test.js +23 -39
- package/src/commands/publishPlugin/__tests__/zappifestPublish.test.js +85 -61
- package/src/commands/publishPlugin/commitToGit.js +1 -1
- package/src/commands/publishPlugin/configurator.js +8 -1
- package/src/commands/publishPlugin/npmPublish.js +9 -6
- package/src/commands/publishPlugin/updateCorePluginsIfNeeded.js +12 -29
- package/src/commands/publishPlugin/zappifestPublish.js +39 -13
- package/src/file/__tests__/file.test.js +1 -7
- package/src/file/index.js +3 -14
- package/test_helpers/fsMock.js +0 -11
- package/src/commands/publishPlugin/README.md +0 -46
- package/src/commands/publishPlugin/__tests__/manifests/android_for_quickbrick.json +0 -6
- package/src/commands/publishPlugin/__tests__/manifests/android_tv_for_quickbrick.json +0 -6
- package/src/commands/publishPlugin/__tests__/manifests/ios_for_quickbrick.json +0 -6
- package/src/commands/publishPlugin/__tests__/manifests/tvos_for_quickbrick.json +0 -6
- package/src/commands/publishPlugin/__tests__/zappifestPublish.integration.test.js +0 -154
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ $ node_modules/.bin/zapplicaster <command> <...args> [...options]
|
|
|
30
30
|
|
|
31
31
|
#### `init`
|
|
32
32
|
|
|
33
|
-
Sets up the applicaster environment. It will check installation of brew, zapptool, yarn and node. If any of these tools aren't installed, the script will install them.
|
|
33
|
+
Sets up the applicaster environment. It will check installation of brew, zappifest, zapptool, yarn, nvm and node. If any of these tools aren't installed, the script will install them.
|
|
34
34
|
This command will also prompt the user for some data required to run the App (Zapp Token, path to native folders, name of android emulators). It will also offer to clone the repositories if needed.
|
|
35
35
|
Once all the data is configured, it is saved at `~/.applicaster.json`
|
|
36
36
|
|
|
@@ -116,9 +116,9 @@ npx zapplicaster-cli publish_plugin path/to/plugin [...options]
|
|
|
116
116
|
This command can be used to publish a QuickBrick plugin to Zapp.
|
|
117
117
|
It will push the plugin to npm, generate the manifests for the supported platforms, push the zappifests to Zapp, and commit the changes to your current branches.
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
In order to work, you need to make sure you are logged in to npm to an account which is allowed to publish the npm package of your plugin. You also need to make sure you can run zappifest commands, which means you have the right ruby version, the latest version of zappifest, and the `ZAPP_TOKEN` environment variable set.
|
|
120
120
|
|
|
121
|
-
You will also need to define an `applicaster` property in your package.json file to declare the list of platforms which are supported by the plugin. By default, the command will publish all
|
|
121
|
+
You will also need to define an `applicaster` property in your package.json file to declare the list of platforms which are supported by the plugin. By default, the command will try to publish all plugins at once, but you can use the `-s, --single-platform` flag to target only one platform. However, if you ask the script to publish the plugin for a single platform, the script will not let you publish to a platform that is not listed in the supported platforms.
|
|
122
122
|
|
|
123
123
|
```json
|
|
124
124
|
// package.json
|
|
@@ -127,12 +127,8 @@ You will also need to define an `applicaster` property in your package.json file
|
|
|
127
127
|
"name": "my-awesome-plugin",
|
|
128
128
|
"version": "1.5.0",
|
|
129
129
|
"applicaster": {
|
|
130
|
-
"supportedPlatforms": [
|
|
131
|
-
|
|
132
|
-
"android_for_quickbrick",
|
|
133
|
-
"tvos_for_quickbrick",
|
|
134
|
-
"samsung_tv"
|
|
135
|
-
]
|
|
130
|
+
"supportedPlatforms": ["ios", "android", "tvos", "samsung"],
|
|
131
|
+
"zappOwnerAccountId": "<plugin owner account from zapp>"
|
|
136
132
|
}
|
|
137
133
|
}
|
|
138
134
|
```
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapplicaster-cli",
|
|
3
|
-
"version": "15.1.26-
|
|
3
|
+
"version": "15.1.26-rc.0",
|
|
4
4
|
"description": "CLI Tool for the zapp app and Quick Brick project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
10
|
+
"node": ">= 18.0.0",
|
|
11
11
|
"yarn": "^4.0.0"
|
|
12
12
|
},
|
|
13
13
|
"bin": "./index.js",
|
|
@@ -28,11 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/zapp-react-dom-cli-template": "15.1.26-
|
|
32
|
-
"@applicaster/zapp-react-native-android-tv-cli-template": "15.1.26-
|
|
33
|
-
"@applicaster/zapp-react-native-cli-template": "15.1.26-
|
|
34
|
-
"@applicaster/zapp-react-native-tvos-cli-template": "15.1.26-
|
|
35
|
-
"@applicaster/zappifest-nano": "^1.0.0",
|
|
31
|
+
"@applicaster/zapp-react-dom-cli-template": "15.1.26-rc.0",
|
|
32
|
+
"@applicaster/zapp-react-native-android-tv-cli-template": "15.1.26-rc.0",
|
|
33
|
+
"@applicaster/zapp-react-native-cli-template": "15.1.26-rc.0",
|
|
34
|
+
"@applicaster/zapp-react-native-tvos-cli-template": "15.1.26-rc.0",
|
|
36
35
|
"axios": "^0.28.0",
|
|
37
36
|
"camelize": "^1.0.0",
|
|
38
37
|
"chalk": "^2.3.2",
|
|
@@ -2,13 +2,14 @@ const logger = require("../../logger");
|
|
|
2
2
|
const { runInShellAsync } = require("../../shell");
|
|
3
3
|
|
|
4
4
|
const BREW = "brew";
|
|
5
|
+
const ZAPPIFEST = "zappifest";
|
|
5
6
|
const ZAPPTOOL = "zapptool";
|
|
6
7
|
const YARN = "yarn";
|
|
7
8
|
const NODE = "node";
|
|
8
9
|
|
|
9
|
-
const LIBS = [BREW, ZAPPTOOL, YARN, NODE];
|
|
10
|
+
const LIBS = [BREW, ZAPPIFEST, ZAPPTOOL, YARN, NODE];
|
|
10
11
|
|
|
11
|
-
const NODE_VERSION = "
|
|
12
|
+
const NODE_VERSION = "12.16.1";
|
|
12
13
|
const YARN_VERSION = "1.21.1";
|
|
13
14
|
|
|
14
15
|
const INSTALL_SCRIPTS = {
|
|
@@ -21,6 +22,10 @@ const INSTALL_SCRIPTS = {
|
|
|
21
22
|
await runInShellAsync("brew tap applicaster/tap");
|
|
22
23
|
},
|
|
23
24
|
|
|
25
|
+
async [ZAPPIFEST]() {
|
|
26
|
+
await runInShellAsync("brew install zappifest");
|
|
27
|
+
},
|
|
28
|
+
|
|
24
29
|
async [ZAPPTOOL]() {
|
|
25
30
|
await runInShellAsync("brew install zapptool");
|
|
26
31
|
},
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`prerequisitesChecker node version requirements are not satisfied throws when running on a invalid node version 1`] = `"Unsupported node version - please use any version compliant with >=
|
|
3
|
+
exports[`prerequisitesChecker node version requirements are not satisfied throws when running on a invalid node version 1`] = `"Unsupported node version - please use any version compliant with >= 12.0.0"`;
|
|
@@ -17,9 +17,9 @@ function prerequisitesChecker() {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// runs node LTS
|
|
20
|
-
if (!semver.satisfies(process.version, ">=
|
|
20
|
+
if (!semver.satisfies(process.version, ">= 12.0.0")) {
|
|
21
21
|
throw new Error(
|
|
22
|
-
"Unsupported node version - please use any version compliant with >=
|
|
22
|
+
"Unsupported node version - please use any version compliant with >= 12.0.0"
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -50,6 +50,8 @@ exports[`publish plugin configurator throws when the package json cannot be foun
|
|
|
50
50
|
|
|
51
51
|
exports[`publish plugin configurator throws when the package.json doesn't contain the applicaster property 1`] = `[Error: your plugin's package.json is missing the applicaster property]`;
|
|
52
52
|
|
|
53
|
+
exports[`publish plugin configurator throws when the package.json doesn't contain the zapp account owner Id 1`] = `[Error: your plugin's package.json is missing zappOwnerAccountId]`;
|
|
54
|
+
|
|
53
55
|
exports[`publish plugin configurator throws when the packages.json applicaster prop doesn't have list of supported platforms 1`] = `[Error: your plugin's package.json doesn't have a list of supported platforms]`;
|
|
54
56
|
|
|
55
57
|
exports[`publish plugin configurator throws when the plugin path cannot be resolved 1`] = `[Error: cannot resolve file]`;
|
|
@@ -14,7 +14,7 @@ const getOptions = (opts = {}) => ({
|
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
jest.mock("simple-git", () =>
|
|
17
|
+
jest.mock("simple-git/promise", () =>
|
|
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/promise");
|
|
91
91
|
|
|
92
92
|
const { configurator } = require("../configurator");
|
|
93
93
|
|
|
@@ -123,12 +123,9 @@ describe("publish plugin configurator", () => {
|
|
|
123
123
|
expect(configurator(options)).rejects.toMatchSnapshot();
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
it("
|
|
126
|
+
it("throws when the package.json doesn't contain the zapp account owner Id", async () => {
|
|
127
127
|
const options = getOptions({ pluginPath: "bad_missing_zapp_account" });
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
expect(config.platforms).toEqual(["ios", "android"]);
|
|
131
|
-
expect(config.zappOwnerAccountId).toBeUndefined();
|
|
128
|
+
expect(configurator(options)).rejects.toMatchSnapshot();
|
|
132
129
|
});
|
|
133
130
|
|
|
134
131
|
it("throws when the packages.json applicaster prop doesn't have list of supported platforms", async () => {
|
|
@@ -42,21 +42,11 @@ const { npmPublish } = require("../npmPublish");
|
|
|
42
42
|
const { runInShellAsync } = require("../../../shell");
|
|
43
43
|
const logger = require("../../../logger");
|
|
44
44
|
const { retryPublishCommand } = require("../../utils/retryPublishCommand");
|
|
45
|
-
const { readJsonFile, writeJsonToFile } = require("../../../file");
|
|
46
|
-
|
|
47
|
-
jest.mock("../../../file", () => ({
|
|
48
|
-
readJsonFile: jest.fn(() =>
|
|
49
|
-
Promise.resolve({ name: "my-plugin", version: "1.0.0" })
|
|
50
|
-
),
|
|
51
|
-
writeJsonToFile: jest.fn(() => Promise.resolve()),
|
|
52
|
-
}));
|
|
53
45
|
|
|
54
46
|
function clearMocks() {
|
|
55
47
|
logger.log.mockClear();
|
|
56
48
|
retryPublishCommand.mockClear();
|
|
57
49
|
runInShellAsync.mockClear();
|
|
58
|
-
if (writeJsonToFile.mockClear) writeJsonToFile.mockClear();
|
|
59
|
-
if (readJsonFile.mockClear) readJsonFile.mockClear();
|
|
60
50
|
jest.resetModules();
|
|
61
51
|
}
|
|
62
52
|
|
|
@@ -68,10 +58,12 @@ describe("npm publish step", () => {
|
|
|
68
58
|
const configuration = getConfig();
|
|
69
59
|
expect(await npmPublish(configuration)).toEqual(true);
|
|
70
60
|
expect(retryPublishCommand).toHaveBeenCalledTimes(1);
|
|
61
|
+
expect(runInShellAsync).toHaveBeenCalledTimes(1);
|
|
71
62
|
|
|
72
|
-
expect(
|
|
73
|
-
|
|
74
|
-
|
|
63
|
+
expect(runInShellAsync).toHaveBeenNthCalledWith(
|
|
64
|
+
1,
|
|
65
|
+
`npm version ${configuration.version}`,
|
|
66
|
+
expect.objectContaining({ cwd: configuration.pluginPath })
|
|
75
67
|
);
|
|
76
68
|
|
|
77
69
|
expect(retryPublishCommand).toHaveBeenNthCalledWith(
|
|
@@ -83,12 +75,8 @@ describe("npm publish step", () => {
|
|
|
83
75
|
});
|
|
84
76
|
|
|
85
77
|
it("throws if the npm command fails", async () => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const configuration = getConfig();
|
|
91
|
-
await expect(npmPublish(configuration)).rejects.toMatchSnapshot();
|
|
78
|
+
const configuration = getConfig({ version: "fail" });
|
|
79
|
+
expect(npmPublish(configuration)).rejects.toMatchSnapshot();
|
|
92
80
|
});
|
|
93
81
|
|
|
94
82
|
it.skip("re tries 3 times if the npm command fails with ESOCKETTIMEDOUT", async () => {
|
|
@@ -146,14 +134,15 @@ describe("npm publish step", () => {
|
|
|
146
134
|
const configuration = getConfig({ dryRun: true });
|
|
147
135
|
|
|
148
136
|
expect(await npmPublish(configuration)).toEqual(true);
|
|
137
|
+
expect(runInShellAsync).toHaveBeenCalledTimes(1);
|
|
138
|
+
expect(retryPublishCommand).toHaveBeenCalledTimes(1);
|
|
149
139
|
|
|
150
|
-
expect(
|
|
151
|
-
|
|
152
|
-
|
|
140
|
+
expect(runInShellAsync).toHaveBeenNthCalledWith(
|
|
141
|
+
1,
|
|
142
|
+
`npm version ${configuration.version}`,
|
|
143
|
+
expect.objectContaining({ cwd: configuration.pluginPath })
|
|
153
144
|
);
|
|
154
145
|
|
|
155
|
-
expect(retryPublishCommand).toHaveBeenCalledTimes(1);
|
|
156
|
-
|
|
157
146
|
expect(retryPublishCommand).toHaveBeenNthCalledWith(
|
|
158
147
|
1,
|
|
159
148
|
"npm publish --dry-run",
|
|
@@ -178,13 +167,15 @@ describe("npm publish step", () => {
|
|
|
178
167
|
|
|
179
168
|
expect(await npmPublish(configuration)).toEqual(true);
|
|
180
169
|
|
|
181
|
-
expect(
|
|
182
|
-
"plugins/my-plugin/package.json",
|
|
183
|
-
expect.objectContaining({ version: configuration.version })
|
|
184
|
-
);
|
|
185
|
-
|
|
170
|
+
expect(runInShellAsync).toHaveBeenCalledTimes(1);
|
|
186
171
|
expect(retryPublishCommand).toHaveBeenCalledTimes(1);
|
|
187
172
|
|
|
173
|
+
expect(runInShellAsync).toHaveBeenNthCalledWith(
|
|
174
|
+
1,
|
|
175
|
+
`npm version ${configuration.version}`,
|
|
176
|
+
expect.objectContaining({ cwd: configuration.pluginPath })
|
|
177
|
+
);
|
|
178
|
+
|
|
188
179
|
expect(retryPublishCommand).toHaveBeenNthCalledWith(
|
|
189
180
|
1,
|
|
190
181
|
"npm publish --tag next",
|
|
@@ -199,16 +190,9 @@ describe("npm publish step", () => {
|
|
|
199
190
|
expect(await npmPublish(configuration)).toEqual(true);
|
|
200
191
|
expect(retryPublishCommand).toHaveBeenCalledTimes(1);
|
|
201
192
|
|
|
202
|
-
expect(
|
|
203
|
-
|
|
204
|
-
expect.objectContaining({
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
expect(retryPublishCommand).toHaveBeenNthCalledWith(
|
|
208
|
-
1,
|
|
209
|
-
"npm publish --tag next",
|
|
210
|
-
expect.objectContaining({ cwd: configuration.pluginPath }),
|
|
211
|
-
configuration.version
|
|
193
|
+
expect(runInShellAsync).toHaveBeenCalledWith(
|
|
194
|
+
`npm version ${configuration.version} --git-tag-version=false --commit-hooks=false --workspaces-update=false`,
|
|
195
|
+
expect.objectContaining({ cwd: configuration.pluginPath })
|
|
212
196
|
);
|
|
213
197
|
});
|
|
214
198
|
});
|
|
@@ -1,90 +1,114 @@
|
|
|
1
|
-
const
|
|
1
|
+
const getConfig = (config = {}) => ({
|
|
2
|
+
platforms: ["android", "ios"],
|
|
3
|
+
pluginPath: "plugins/my-plugn",
|
|
4
|
+
dryRun: false,
|
|
5
|
+
zappOwnerAccountId: "A1234",
|
|
6
|
+
...config,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
jest.mock("path", () => ({
|
|
10
|
+
resolve: jest.fn((path, platformpath) => {
|
|
11
|
+
if (path.includes("resolve_error")) {
|
|
12
|
+
throw new Error("cannot resolve manifest");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (path.includes("zappifest_error")) {
|
|
16
|
+
/* eslint-disable-next-line no-path-concat */
|
|
17
|
+
return __dirname + "/zappifest_error.json";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* eslint-disable-next-line no-path-concat */
|
|
21
|
+
return __dirname + "/" + platformpath;
|
|
22
|
+
}),
|
|
23
|
+
}));
|
|
2
24
|
|
|
3
|
-
jest.mock("
|
|
4
|
-
|
|
25
|
+
jest.mock("../../../shell", () => ({
|
|
26
|
+
runInShellAsync: jest.fn((command) => {
|
|
27
|
+
return command.includes("zappifest_error")
|
|
28
|
+
? Promise.reject(new Error("zappifest failed"))
|
|
29
|
+
: Promise.resolve(true);
|
|
30
|
+
}),
|
|
5
31
|
}));
|
|
6
32
|
|
|
7
33
|
jest.mock("../../../logger", () => ({
|
|
8
34
|
log: jest.fn(),
|
|
9
|
-
warn: jest.fn(),
|
|
10
35
|
}));
|
|
11
36
|
|
|
12
|
-
const { publish } = require("@applicaster/zappifest-nano");
|
|
13
|
-
const logger = require("../../../logger");
|
|
14
37
|
const { zappifestPublish } = require("../zappifestPublish");
|
|
38
|
+
const { runInShellAsync } = require("../../../shell");
|
|
39
|
+
const logger = require("../../../logger");
|
|
40
|
+
const { inspect } = require("util");
|
|
15
41
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
42
|
+
function clearMocks() {
|
|
43
|
+
logger.log.mockClear();
|
|
44
|
+
runInShellAsync.mockClear();
|
|
45
|
+
}
|
|
20
46
|
|
|
21
47
|
describe("publish zappifests", () => {
|
|
22
|
-
beforeEach(
|
|
23
|
-
publish.mockReset().mockResolvedValue({ uploaded: 2 });
|
|
24
|
-
jest.clearAllMocks();
|
|
25
|
-
});
|
|
48
|
+
beforeEach(clearMocks);
|
|
26
49
|
|
|
27
|
-
it("
|
|
28
|
-
|
|
50
|
+
it("runs the zappifest command for all platforms", async () => {
|
|
51
|
+
const configuration = getConfig();
|
|
29
52
|
|
|
30
|
-
|
|
53
|
+
const expectedResult = new Array(configuration.platforms.length)
|
|
54
|
+
.fill()
|
|
55
|
+
.map(() => true);
|
|
31
56
|
|
|
32
|
-
expect(
|
|
33
|
-
manifestPaths: [
|
|
34
|
-
resolve(__dirname, "manifests/android.json"),
|
|
35
|
-
resolve(__dirname, "manifests/ios.json"),
|
|
36
|
-
],
|
|
37
|
-
dryRun: false,
|
|
38
|
-
log: logger.log,
|
|
39
|
-
onWarning: logger.warn,
|
|
40
|
-
});
|
|
41
|
-
});
|
|
57
|
+
expect(await zappifestPublish(configuration)).toEqual(expectedResult);
|
|
42
58
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
zappOwnerAccountId: "A1234",
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
expect(publish.mock.calls[0][0]).not.toHaveProperty("account");
|
|
50
|
-
});
|
|
59
|
+
expect(runInShellAsync).toHaveBeenCalledTimes(
|
|
60
|
+
configuration.platforms.length
|
|
61
|
+
);
|
|
51
62
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
configuration.platforms.forEach((val, index) => {
|
|
64
|
+
expect(runInShellAsync).toHaveBeenNthCalledWith(
|
|
65
|
+
index + 1,
|
|
66
|
+
`zappifest publish --manifest ${__dirname}/manifests/${val}.json --account A1234`
|
|
67
|
+
);
|
|
56
68
|
});
|
|
57
|
-
|
|
58
|
-
expect(publish.mock.calls[0][0].manifestPaths).toEqual([
|
|
59
|
-
resolve(__dirname, "manifests/ios.json"),
|
|
60
|
-
]);
|
|
61
69
|
});
|
|
62
70
|
|
|
63
|
-
it
|
|
64
|
-
|
|
65
|
-
async (options) => {
|
|
66
|
-
expect(await zappifestPublish({ ...configuration, ...options })).toBe(
|
|
67
|
-
true
|
|
68
|
-
);
|
|
71
|
+
it("only logs in the console when running with dry run flag", async () => {
|
|
72
|
+
const configuration = getConfig({ dryRun: true });
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
const expectedResult = new Array(configuration.platforms.length)
|
|
75
|
+
.fill()
|
|
76
|
+
.map(() => true);
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
expect(
|
|
78
|
+
expect(await zappifestPublish(configuration)).toEqual(expectedResult);
|
|
79
|
+
expect(runInShellAsync).not.toHaveBeenCalled();
|
|
76
80
|
|
|
77
|
-
expect(
|
|
81
|
+
expect(logger.log).toHaveBeenCalledTimes(
|
|
82
|
+
1 + configuration.platforms.length * 2
|
|
83
|
+
);
|
|
78
84
|
|
|
79
|
-
expect(logger.log).
|
|
80
|
-
|
|
85
|
+
expect(logger.log).toHaveBeenNthCalledWith(
|
|
86
|
+
1,
|
|
87
|
+
"Running with --dry-run or --manifest-only option - not actually pushing to zapp"
|
|
81
88
|
);
|
|
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
|
+
});
|
|
82
103
|
});
|
|
83
104
|
|
|
84
|
-
it("
|
|
85
|
-
const
|
|
86
|
-
|
|
105
|
+
it("it throws if a manifest cannot be found", async () => {
|
|
106
|
+
const configuration = getConfig({ pluginPath: "resolve_error" });
|
|
107
|
+
expect(zappifestPublish(configuration)).rejects.toMatchSnapshot();
|
|
108
|
+
});
|
|
87
109
|
|
|
88
|
-
|
|
110
|
+
it("it throws if the zappifest command fails", async () => {
|
|
111
|
+
const configuration = getConfig({ pluginPath: "zappifest_error" });
|
|
112
|
+
expect(zappifestPublish(configuration)).rejects.toMatchSnapshot();
|
|
89
113
|
});
|
|
90
114
|
});
|
|
@@ -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/promise");
|
|
5
5
|
const logger = require("../../logger");
|
|
6
6
|
const { existsSync } = require("fs");
|
|
7
7
|
|
|
@@ -50,6 +50,13 @@ function resolvePluginPath(pluginPath) {
|
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
if (
|
|
54
|
+
manifestExists(pluginPath) &&
|
|
55
|
+
!pluginPackageJson.applicaster.zappOwnerAccountId
|
|
56
|
+
) {
|
|
57
|
+
throw new Error("your plugin's package.json is missing zappOwnerAccountId");
|
|
58
|
+
}
|
|
59
|
+
|
|
53
60
|
return [resolvedPluginPath, pluginPackageJson];
|
|
54
61
|
}
|
|
55
62
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { runInShellAsync } = require("../../shell");
|
|
2
2
|
const logger = require("../../logger");
|
|
3
3
|
const { retryPublishCommand } = require("../utils/retryPublishCommand");
|
|
4
|
-
const { readJsonFile, writeJsonToFile } = require("../../file");
|
|
5
4
|
|
|
6
5
|
async function npmPublish(configuration) {
|
|
7
6
|
const { dryRun, yarn, next, version, pluginPath, manifestOnly } =
|
|
@@ -30,10 +29,14 @@ async function npmPublish(configuration) {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
if (version) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
if (yarn) {
|
|
33
|
+
await runInShellAsync(
|
|
34
|
+
`npm version ${version} --git-tag-version=false --commit-hooks=false --workspaces-update=false`,
|
|
35
|
+
cmdOptions
|
|
36
|
+
);
|
|
37
|
+
} else {
|
|
38
|
+
await runInShellAsync(`npm version ${version}`, cmdOptions);
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
await retryPublishCommand(publishCommand, cmdOptions, version);
|
|
@@ -1,41 +1,39 @@
|
|
|
1
1
|
const R = require("ramda");
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
|
-
const { writeJsonToFile
|
|
4
|
+
const { writeJsonToFile } = 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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const rootPackageJson = await readJsonFile(rootPackageJsonPath);
|
|
11
|
+
async function updateCorePluginsIfNeeded(configuration) {
|
|
12
|
+
const { name: workspaceName } = require(
|
|
13
|
+
path.join(process.cwd(), PACKAGE_DOT_JSON)
|
|
14
|
+
);
|
|
16
15
|
|
|
17
|
-
if (
|
|
16
|
+
if (workspaceName !== QUICK_BRICK_WORKSPACE_NAME) {
|
|
18
17
|
return;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
const { version, pluginPackageJson } = configuration;
|
|
22
21
|
const { name } = pluginPackageJson;
|
|
23
22
|
|
|
24
|
-
const
|
|
25
|
-
process.cwd(),
|
|
26
|
-
CORE_PLUGINS_PATH,
|
|
27
|
-
PACKAGE_DOT_JSON
|
|
23
|
+
const corePluginsPackageJson = require(
|
|
24
|
+
path.join(process.cwd(), CORE_PLUGINS_PATH, PACKAGE_DOT_JSON)
|
|
28
25
|
);
|
|
29
26
|
|
|
30
|
-
const corePluginsPackageJson = await readJsonFile(corePluginsPackageJsonPath);
|
|
31
|
-
|
|
32
27
|
const { dependencies } = corePluginsPackageJson;
|
|
33
28
|
const isPluginCore = R.contains(name, R.keys(dependencies));
|
|
34
29
|
|
|
35
30
|
if (isPluginCore) {
|
|
36
31
|
corePluginsPackageJson.dependencies[name] = version;
|
|
37
32
|
|
|
38
|
-
await writeJsonToFile(
|
|
33
|
+
await writeJsonToFile(
|
|
34
|
+
path.join(process.cwd(), CORE_PLUGINS_PATH, PACKAGE_DOT_JSON),
|
|
35
|
+
corePluginsPackageJson
|
|
36
|
+
);
|
|
39
37
|
|
|
40
38
|
logger.log(`Core Plugins updated with ${name}@${version}`);
|
|
41
39
|
} else {
|
|
@@ -43,19 +41,4 @@ async function doUpdateCorePlugins(configuration) {
|
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
async function updateCorePluginsIfNeeded(configuration) {
|
|
47
|
-
// During monorepo deploy (--skip-git), scripts/deploy updates quick-brick-core-plugins
|
|
48
|
-
// once in memory across all published plugins and writes it prior to its own publish.
|
|
49
|
-
// Skipping here prevents concurrent workers from racing to overwrite the file on disk.
|
|
50
|
-
if (configuration.skipGit) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Ensure that concurrent publishing tasks do not race when updating core plugins
|
|
55
|
-
const result = writeLock.then(() => doUpdateCorePlugins(configuration));
|
|
56
|
-
writeLock = result.catch(() => {});
|
|
57
|
-
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
44
|
module.exports = { updateCorePluginsIfNeeded };
|
|
@@ -1,27 +1,53 @@
|
|
|
1
|
+
const R = require("ramda");
|
|
1
2
|
const { resolve } = require("path");
|
|
2
|
-
const {
|
|
3
|
+
const { inspect } = require("util");
|
|
3
4
|
|
|
5
|
+
const { runInShellAsync } = require("../../shell");
|
|
4
6
|
const logger = require("../../logger");
|
|
5
7
|
|
|
8
|
+
function pushZappifest({
|
|
9
|
+
pluginPath,
|
|
10
|
+
dryRun,
|
|
11
|
+
manifestOnly,
|
|
12
|
+
zappOwnerAccountId,
|
|
13
|
+
}) {
|
|
14
|
+
return async function (platform) {
|
|
15
|
+
const manifestPath = resolve(pluginPath, `manifests/${platform}.json`);
|
|
16
|
+
const publishCommand = `zappifest publish --manifest ${manifestPath} --account ${zappOwnerAccountId}`;
|
|
17
|
+
|
|
18
|
+
if (dryRun || manifestOnly) {
|
|
19
|
+
logger.log(`running ${publishCommand}`);
|
|
20
|
+
logger.log(`with manifest: ${inspect(require(manifestPath))}`);
|
|
21
|
+
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return await runInShellAsync(publishCommand);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
6
29
|
async function zappifestPublish(configuration) {
|
|
7
|
-
const { platforms, pluginPath, dryRun, manifestOnly } =
|
|
30
|
+
const { platforms, pluginPath, dryRun, manifestOnly, zappOwnerAccountId } =
|
|
31
|
+
configuration;
|
|
32
|
+
|
|
33
|
+
if (dryRun || manifestOnly) {
|
|
34
|
+
logger.log(
|
|
35
|
+
"Running with --dry-run or --manifest-only option - not actually pushing to zapp"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
8
38
|
|
|
9
|
-
if (!platforms ||
|
|
39
|
+
if (!platforms || !zappOwnerAccountId) {
|
|
10
40
|
logger.log("Manifest does not exist, Skipping publishing");
|
|
11
41
|
|
|
12
42
|
return true;
|
|
13
43
|
}
|
|
14
44
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
onWarning: logger.warn,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return true;
|
|
45
|
+
return Promise.all(
|
|
46
|
+
R.map(
|
|
47
|
+
pushZappifest({ pluginPath, dryRun, manifestOnly, zappOwnerAccountId }),
|
|
48
|
+
platforms
|
|
49
|
+
)
|
|
50
|
+
);
|
|
25
51
|
}
|
|
26
52
|
|
|
27
53
|
module.exports = { zappifestPublish };
|
|
@@ -22,14 +22,8 @@ describe("writeJsonTofile", () => {
|
|
|
22
22
|
await writeJsonToFile(filePath, json);
|
|
23
23
|
|
|
24
24
|
expect(fs.writeFile).toHaveBeenCalledWith(
|
|
25
|
-
expect.stringMatching(/^someFile\.json\.tmp\./),
|
|
26
|
-
JSON.stringify(json, null, 2),
|
|
27
|
-
expect.any(Function)
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
expect(fs.rename).toHaveBeenCalledWith(
|
|
31
|
-
expect.stringMatching(/^someFile\.json\.tmp\./),
|
|
32
25
|
filePath,
|
|
26
|
+
JSON.stringify(json, null, 2),
|
|
33
27
|
expect.any(Function)
|
|
34
28
|
);
|
|
35
29
|
});
|
package/src/file/index.js
CHANGED
|
@@ -5,34 +5,23 @@ const R = require("ramda");
|
|
|
5
5
|
* @module @applicaster/zapplicaster-cli/util/file
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
const {
|
|
9
|
-
writeFile,
|
|
10
|
-
readFile,
|
|
11
|
-
readdir,
|
|
12
|
-
copyFile,
|
|
13
|
-
copyFileSync,
|
|
14
|
-
rename,
|
|
15
|
-
} = require("fs");
|
|
16
|
-
|
|
8
|
+
const { writeFile, readFile, readdir, copyFile, copyFileSync } = require("fs");
|
|
17
9
|
const { promisify } = require("util");
|
|
18
10
|
const { join } = require("path");
|
|
19
11
|
|
|
20
12
|
const writeFileAsync = promisify(writeFile);
|
|
21
|
-
const renameAsync = promisify(rename);
|
|
22
13
|
const readFileAsync = promisify(readFile);
|
|
23
14
|
const readdirAsync = promisify(readdir);
|
|
24
15
|
const copyFileAsync = promisify(copyFile);
|
|
25
16
|
|
|
26
17
|
/**
|
|
27
|
-
* Writes a pretty-printed json file from a javascript object
|
|
18
|
+
* Writes a pretty-printed json file from a javascript object
|
|
28
19
|
* @param {String} path : path of the file to write
|
|
29
20
|
* @param {Object} object : object to write to the file
|
|
30
21
|
* @returns {Promise}
|
|
31
22
|
*/
|
|
32
23
|
async function writeJsonToFile(path, object) {
|
|
33
|
-
|
|
34
|
-
await writeFileAsync(tmpPath, JSON.stringify(object, null, 2));
|
|
35
|
-
await renameAsync(tmpPath, path);
|
|
24
|
+
return await writeFileAsync(path, JSON.stringify(object, null, 2));
|
|
36
25
|
}
|
|
37
26
|
|
|
38
27
|
/**
|
package/test_helpers/fsMock.js
CHANGED
|
@@ -48,16 +48,6 @@ function copyFileSync() {
|
|
|
48
48
|
return { status: "ok" };
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
function rename(oldPath, newPath, callback) {
|
|
52
|
-
const file = fs.__writenFiles.find((f) => f.fileName === oldPath);
|
|
53
|
-
|
|
54
|
-
if (file) {
|
|
55
|
-
file.fileName = newPath;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
callback(null);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
51
|
function existsSync(path) {
|
|
62
52
|
return R.includes(path, R.map(R.prop("fileName"), fs.__writenFiles));
|
|
63
53
|
}
|
|
@@ -97,7 +87,6 @@ fs.readFile = jest.fn(readFile);
|
|
|
97
87
|
fs.readFileSync = jest.fn(readFileSync);
|
|
98
88
|
fs.copyFile = jest.fn(copyFile);
|
|
99
89
|
fs.copyFileSync = jest.fn(copyFileSync);
|
|
100
|
-
fs.rename = jest.fn(rename);
|
|
101
90
|
fs.existsSync = jest.fn(existsSync);
|
|
102
91
|
fs.statSync = jest.fn(statSync);
|
|
103
92
|
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Plugin manifest publishing
|
|
2
|
-
|
|
3
|
-
`publish_plugin` generates platform manifests and delegates their upload to the
|
|
4
|
-
published `@applicaster/zappifest-nano` CommonJS API. QuickBrick owns manifest
|
|
5
|
-
generation, npm package publishing, Apple templates, core-plugin updates, and Git
|
|
6
|
-
commits; Nano owns Zapp requests, validation, identifier grouping, and uploads.
|
|
7
|
-
|
|
8
|
-
## Requirements
|
|
9
|
-
|
|
10
|
-
- Node.js 22+ and `ZAPP_TOKEN` for live uploads.
|
|
11
|
-
- Optional `ZAPP_URL` to override the Zapp Admin API endpoint.
|
|
12
|
-
- An existing Zapp plugin for each manifest identifier. QuickBrick does not
|
|
13
|
-
automatically create plugins or overwrite existing version records.
|
|
14
|
-
|
|
15
|
-
`applicaster.zappOwnerAccountId` is no longer required. Existing metadata remains
|
|
16
|
-
accepted, but is not forwarded as an account-validation request: the established
|
|
17
|
-
account-free publishing path makes no Accounts API calls.
|
|
18
|
-
|
|
19
|
-
## Selection and safety
|
|
20
|
-
|
|
21
|
-
The adapter passes exactly the configured platform files in one `publish` call.
|
|
22
|
-
It deliberately does not scan the directory, so `--single-platform` cannot upload
|
|
23
|
-
stale manifests from other platforms. Nano reads fresh JSON from disk, validates
|
|
24
|
-
the selected batch, shares mapping lookups, and uploads platforms with the same
|
|
25
|
-
identifier in parallel. Different identifiers run sequentially.
|
|
26
|
-
|
|
27
|
-
Both `--dry-run` and `--manifest-only` map to Nano's `dryRun: true`: this step
|
|
28
|
-
validates locally without authentication, network calls, or Zapp writes.
|
|
29
|
-
`--manifest-only` can still generate local JSON in the earlier generation step.
|
|
30
|
-
|
|
31
|
-
Nano synchronizes supplied parent metadata once per identifier when it differs
|
|
32
|
-
from the server, without changing owner or whitelist. Conflicting parent metadata
|
|
33
|
-
within one identifier is rejected. Mapping fallbacks are surfaced through the CLI
|
|
34
|
-
warning logger; progress uses the regular CLI logger.
|
|
35
|
-
|
|
36
|
-
Failures propagate to the task runner. Uploads are not transactional: successful
|
|
37
|
-
platforms or parent updates may remain applied after a failure. Inspect Zapp
|
|
38
|
-
before retrying. No Ruby subprocess fallback remains; `USE_LEGACY_ZAPPIFEST` no
|
|
39
|
-
longer selects a different publisher.
|
|
40
|
-
|
|
41
|
-
## CI
|
|
42
|
-
|
|
43
|
-
The checked-in primary-image recipe no longer installs Ruby or zappifest.
|
|
44
|
-
Publishing uses the workspace dependency. The existing prebuilt
|
|
45
|
-
`applicaster/quick-brick:3.0` image is unchanged until the image is rebuilt and
|
|
46
|
-
released separately; this migration does not require that image release.
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
const { resolve } = require("path");
|
|
2
|
-
|
|
3
|
-
jest.mock("../../../logger", () => ({
|
|
4
|
-
log: jest.fn(),
|
|
5
|
-
warn: jest.fn(),
|
|
6
|
-
}));
|
|
7
|
-
|
|
8
|
-
const { zappifestPublish } = require("../zappifestPublish");
|
|
9
|
-
|
|
10
|
-
const configuration = {
|
|
11
|
-
pluginPath: resolve(__dirname),
|
|
12
|
-
platforms: ["ios_for_quickbrick", "android_for_quickbrick"],
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
describe("published Nano integration", () => {
|
|
16
|
-
const originalFetch = global.fetch;
|
|
17
|
-
const originalToken = process.env.ZAPP_TOKEN;
|
|
18
|
-
const originalUrl = process.env.ZAPP_URL;
|
|
19
|
-
let requests;
|
|
20
|
-
let pendingUploads;
|
|
21
|
-
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
requests = [];
|
|
24
|
-
pendingUploads = [];
|
|
25
|
-
process.env.ZAPP_TOKEN = "test-token";
|
|
26
|
-
process.env.ZAPP_URL = "https://zapp.example.test/api/v1/admin";
|
|
27
|
-
|
|
28
|
-
global.fetch = jest.fn(async (url, options) => {
|
|
29
|
-
const path = new URL(url).pathname;
|
|
30
|
-
requests.push({ path, options });
|
|
31
|
-
|
|
32
|
-
if (path.endsWith("/targets.json")) {
|
|
33
|
-
return Response.json([
|
|
34
|
-
{ name: "mobile", id: 1 },
|
|
35
|
-
{ name: "tv", id: 2 },
|
|
36
|
-
]);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (path.endsWith("/ui_frameworks.json")) {
|
|
40
|
-
return Response.json([{ name: "quickbrick", id: 2 }]);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (path.endsWith("/plugins/cell_info_mobile.json")) {
|
|
44
|
-
return Response.json({ id: 11, name: "Cell Info" });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (path.endsWith("/plugins/cell_info_tv.json")) {
|
|
48
|
-
return Response.json({ id: 22, name: "Cell Info TV" });
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (path.endsWith("/plugin_versions")) {
|
|
52
|
-
return new Promise((resolve) => {
|
|
53
|
-
pendingUploads.push(resolve);
|
|
54
|
-
|
|
55
|
-
if (pendingUploads.length === 2) {
|
|
56
|
-
pendingUploads.splice(0).forEach((finish) => {
|
|
57
|
-
finish(Response.json({ ok: true }));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
throw new Error(`Unexpected request: ${path}`);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
afterEach(() => {
|
|
68
|
-
global.fetch = originalFetch;
|
|
69
|
-
|
|
70
|
-
if (originalToken === undefined) delete process.env.ZAPP_TOKEN;
|
|
71
|
-
else process.env.ZAPP_TOKEN = originalToken;
|
|
72
|
-
|
|
73
|
-
if (originalUrl === undefined) delete process.env.ZAPP_URL;
|
|
74
|
-
else process.env.ZAPP_URL = originalUrl;
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("shares mappings and uploads each identifier's platforms concurrently without account calls", async () => {
|
|
78
|
-
await expect(
|
|
79
|
-
zappifestPublish({
|
|
80
|
-
...configuration,
|
|
81
|
-
platforms: [
|
|
82
|
-
...configuration.platforms,
|
|
83
|
-
"android_tv_for_quickbrick",
|
|
84
|
-
"tvos_for_quickbrick",
|
|
85
|
-
],
|
|
86
|
-
})
|
|
87
|
-
).resolves.toBe(true);
|
|
88
|
-
|
|
89
|
-
expect(requests.map(({ path }) => path)).toEqual([
|
|
90
|
-
"/api/v1/admin/targets.json",
|
|
91
|
-
"/api/v1/admin/ui_frameworks.json",
|
|
92
|
-
"/api/v1/admin/plugins/cell_info_mobile.json",
|
|
93
|
-
"/api/v1/admin/plugin_versions",
|
|
94
|
-
"/api/v1/admin/plugin_versions",
|
|
95
|
-
"/api/v1/admin/plugins/cell_info_tv.json",
|
|
96
|
-
"/api/v1/admin/plugin_versions",
|
|
97
|
-
"/api/v1/admin/plugin_versions",
|
|
98
|
-
]);
|
|
99
|
-
|
|
100
|
-
const uploads = requests.filter(({ options }) => options.method === "POST");
|
|
101
|
-
|
|
102
|
-
expect(
|
|
103
|
-
uploads.map(({ options }) =>
|
|
104
|
-
options.body.get("plugin_version[plugin_id]")
|
|
105
|
-
)
|
|
106
|
-
).toEqual(["11", "11", "22", "22"]);
|
|
107
|
-
|
|
108
|
-
expect(
|
|
109
|
-
uploads.every(
|
|
110
|
-
({ options }) => options.body.get("access_token") === "test-token"
|
|
111
|
-
)
|
|
112
|
-
).toBe(true);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it.each([{ dryRun: true }, { manifestOnly: true }])(
|
|
116
|
-
"validates real fixture files without a token or network for %j",
|
|
117
|
-
async (options) => {
|
|
118
|
-
delete process.env.ZAPP_TOKEN;
|
|
119
|
-
|
|
120
|
-
await expect(
|
|
121
|
-
zappifestPublish({ ...configuration, ...options })
|
|
122
|
-
).resolves.toBe(true);
|
|
123
|
-
|
|
124
|
-
expect(global.fetch).not.toHaveBeenCalled();
|
|
125
|
-
}
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
it("rejects a missing selected file before any network request", async () => {
|
|
129
|
-
await expect(
|
|
130
|
-
zappifestPublish({
|
|
131
|
-
...configuration,
|
|
132
|
-
platforms: ["ios_for_quickbrick", "missing_platform"],
|
|
133
|
-
})
|
|
134
|
-
).rejects.toThrow("Cannot read manifest");
|
|
135
|
-
|
|
136
|
-
expect(global.fetch).not.toHaveBeenCalled();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it("propagates an HTTP upload failure with partial-success context", async () => {
|
|
140
|
-
const fetchManifestRequest = global.fetch.getMockImplementation();
|
|
141
|
-
|
|
142
|
-
global.fetch.mockImplementation(async (url, options) => {
|
|
143
|
-
if (new URL(url).pathname.endsWith("/plugin_versions")) {
|
|
144
|
-
return new Response(null, { status: 422 });
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return fetchManifestRequest(url, options);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
await expect(zappifestPublish(configuration)).rejects.toThrow(
|
|
151
|
-
/HTTP 422.*Batch stopped/
|
|
152
|
-
);
|
|
153
|
-
});
|
|
154
|
-
});
|