@applicaster/zapplicaster-cli 17.0.0-alpha.5804334713 → 17.0.0-alpha.9147048829
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 +9 -5
- package/package.json +7 -6
- package/src/commands/init/setUpEnvironment.js +2 -7
- 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/README.md +56 -140
- package/src/commands/publishPlugin/__tests__/__snapshots__/configurator.test.js.snap +0 -2
- package/src/commands/publishPlugin/__tests__/configurator.test.js +5 -2
- package/src/commands/publishPlugin/__tests__/zappifestPublish.integration.test.js +154 -0
- package/src/commands/publishPlugin/__tests__/zappifestPublish.test.js +53 -153
- package/src/commands/publishPlugin/configurator.js +0 -7
- package/src/commands/publishPlugin/zappifestPublish.js +13 -154
- package/src/commands/publishPlugin/__tests__/zappApi.test.js +0 -271
- package/src/commands/publishPlugin/zappApi.js +0 -283
|
@@ -1,190 +1,90 @@
|
|
|
1
|
-
const
|
|
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
|
-
}
|
|
1
|
+
const { resolve } = require("path");
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}),
|
|
23
|
-
}));
|
|
24
|
-
|
|
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
|
-
}),
|
|
3
|
+
jest.mock("@applicaster/zappifest-nano", () => ({
|
|
4
|
+
publish: jest.fn().mockResolvedValue({ uploaded: 2 }),
|
|
31
5
|
}));
|
|
32
6
|
|
|
33
7
|
jest.mock("../../../logger", () => ({
|
|
34
8
|
log: jest.fn(),
|
|
9
|
+
warn: jest.fn(),
|
|
35
10
|
}));
|
|
36
11
|
|
|
37
|
-
|
|
38
|
-
findPlugin: jest.fn().mockImplementation(async ({ identifier }) => {
|
|
39
|
-
if (identifier === "cell_info_mobile") {
|
|
40
|
-
return { id: 11, name: "Cell Info" };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (identifier === "cell_info_tv") {
|
|
44
|
-
return { id: 22, name: "Cell Info TV" };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return { id: 99, name: "Test Plugin" };
|
|
48
|
-
}),
|
|
49
|
-
uploadPluginVersion: jest.fn().mockResolvedValue({ ok: true }),
|
|
50
|
-
}));
|
|
51
|
-
|
|
52
|
-
const {
|
|
53
|
-
zappifestPublish,
|
|
54
|
-
groupManifestsByIdentifier,
|
|
55
|
-
} = require("../zappifestPublish");
|
|
56
|
-
|
|
57
|
-
const { runInShellAsync } = require("../../../shell");
|
|
58
|
-
const { findPlugin, uploadPluginVersion } = require("../zappApi");
|
|
12
|
+
const { publish } = require("@applicaster/zappifest-nano");
|
|
59
13
|
const logger = require("../../../logger");
|
|
14
|
+
const { zappifestPublish } = require("../zappifestPublish");
|
|
60
15
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
uploadPluginVersion.mockClear();
|
|
66
|
-
delete process.env.USE_LEGACY_ZAPPIFEST;
|
|
67
|
-
}
|
|
16
|
+
const configuration = {
|
|
17
|
+
platforms: ["android", "ios"],
|
|
18
|
+
pluginPath: resolve(__dirname),
|
|
19
|
+
};
|
|
68
20
|
|
|
69
21
|
describe("publish zappifests", () => {
|
|
70
|
-
beforeEach(
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
publish.mockReset().mockResolvedValue({ uploaded: 2 });
|
|
24
|
+
jest.clearAllMocks();
|
|
25
|
+
});
|
|
71
26
|
|
|
72
|
-
it("
|
|
73
|
-
|
|
27
|
+
it("delegates the selected manifests in one batch without requiring an account", async () => {
|
|
28
|
+
expect(await zappifestPublish(configuration)).toBe(true);
|
|
74
29
|
|
|
75
|
-
|
|
76
|
-
expect(result).toBe(true);
|
|
30
|
+
expect(publish).toHaveBeenCalledTimes(1);
|
|
77
31
|
|
|
78
|
-
expect(
|
|
79
|
-
|
|
80
|
-
|
|
32
|
+
expect(publish).toHaveBeenCalledWith({
|
|
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,
|
|
81
40
|
});
|
|
82
|
-
|
|
83
|
-
expect(uploadPluginVersion).toHaveBeenCalledTimes(2);
|
|
84
|
-
expect(runInShellAsync).not.toHaveBeenCalled();
|
|
85
41
|
});
|
|
86
42
|
|
|
87
|
-
it("
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"android_for_quickbrick",
|
|
92
|
-
"android_tv_for_quickbrick",
|
|
93
|
-
"tvos_for_quickbrick",
|
|
94
|
-
],
|
|
43
|
+
it("does not pass legacy owner metadata as an account-validation request", async () => {
|
|
44
|
+
await zappifestPublish({
|
|
45
|
+
...configuration,
|
|
46
|
+
zappOwnerAccountId: "A1234",
|
|
95
47
|
});
|
|
96
48
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
expect(findPlugin).toHaveBeenCalledTimes(2);
|
|
100
|
-
|
|
101
|
-
expect(findPlugin).toHaveBeenCalledWith({
|
|
102
|
-
identifier: "cell_info_mobile",
|
|
103
|
-
name: "Cell Info",
|
|
104
|
-
});
|
|
49
|
+
expect(publish.mock.calls[0][0]).not.toHaveProperty("account");
|
|
50
|
+
});
|
|
105
51
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
52
|
+
it("publishes only the configured platform, not the entire manifest directory", async () => {
|
|
53
|
+
await zappifestPublish({
|
|
54
|
+
...configuration,
|
|
55
|
+
platforms: ["ios"],
|
|
109
56
|
});
|
|
110
57
|
|
|
111
|
-
expect(
|
|
112
|
-
|
|
113
|
-
const uploadsByPluginId = uploadPluginVersion.mock.calls.reduce(
|
|
114
|
-
(acc, [{ pluginId, manifest }]) => {
|
|
115
|
-
acc[pluginId] = acc[pluginId] || [];
|
|
116
|
-
acc[pluginId].push(manifest.platform);
|
|
117
|
-
|
|
118
|
-
return acc;
|
|
119
|
-
},
|
|
120
|
-
{}
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
expect(uploadsByPluginId[11].sort()).toEqual([
|
|
124
|
-
"android_for_quickbrick",
|
|
125
|
-
"ios_for_quickbrick",
|
|
126
|
-
]);
|
|
127
|
-
|
|
128
|
-
expect(uploadsByPluginId[22].sort()).toEqual([
|
|
129
|
-
"android_tv_for_quickbrick",
|
|
130
|
-
"tvos_for_quickbrick",
|
|
131
|
-
]);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("groups manifests by identifier", () => {
|
|
135
|
-
const grouped = groupManifestsByIdentifier([
|
|
136
|
-
{ identifier: "a", platform: "ios" },
|
|
137
|
-
{ identifier: "b", platform: "tvos" },
|
|
138
|
-
{ identifier: "a", platform: "android" },
|
|
58
|
+
expect(publish.mock.calls[0][0].manifestPaths).toEqual([
|
|
59
|
+
resolve(__dirname, "manifests/ios.json"),
|
|
139
60
|
]);
|
|
140
|
-
|
|
141
|
-
expect(Object.keys(grouped).sort()).toEqual(["a", "b"]);
|
|
142
|
-
expect(grouped.a.map((m) => m.platform).sort()).toEqual(["android", "ios"]);
|
|
143
|
-
expect(grouped.b.map((m) => m.platform)).toEqual(["tvos"]);
|
|
144
61
|
});
|
|
145
62
|
|
|
146
|
-
it(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
.fill()
|
|
152
|
-
.map(() => true);
|
|
153
|
-
|
|
154
|
-
expect(await zappifestPublish(configuration)).toEqual(expectedResult);
|
|
155
|
-
|
|
156
|
-
expect(runInShellAsync).toHaveBeenCalledTimes(
|
|
157
|
-
configuration.platforms.length
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
configuration.platforms.forEach((val, index) => {
|
|
161
|
-
expect(runInShellAsync).toHaveBeenNthCalledWith(
|
|
162
|
-
index + 1,
|
|
163
|
-
`zappifest publish --manifest ${__dirname}/manifests/${val}.json --account A1234`
|
|
63
|
+
it.each([{ dryRun: true }, { manifestOnly: true }])(
|
|
64
|
+
"does not upload with %j",
|
|
65
|
+
async (options) => {
|
|
66
|
+
expect(await zappifestPublish({ ...configuration, ...options })).toBe(
|
|
67
|
+
true
|
|
164
68
|
);
|
|
165
|
-
});
|
|
166
69
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
70
|
+
expect(publish.mock.calls[0][0].dryRun).toBe(true);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
170
73
|
|
|
171
|
-
it("
|
|
172
|
-
|
|
74
|
+
it.each([undefined, []])("skips absent platforms: %j", async (platforms) => {
|
|
75
|
+
expect(await zappifestPublish({ ...configuration, platforms })).toBe(true);
|
|
173
76
|
|
|
174
|
-
expect(
|
|
175
|
-
expect(runInShellAsync).not.toHaveBeenCalled();
|
|
176
|
-
expect(uploadPluginVersion).not.toHaveBeenCalled();
|
|
77
|
+
expect(publish).not.toHaveBeenCalled();
|
|
177
78
|
|
|
178
79
|
expect(logger.log).toHaveBeenCalledWith(
|
|
179
|
-
"
|
|
80
|
+
"Manifest does not exist, Skipping publishing"
|
|
180
81
|
);
|
|
181
82
|
});
|
|
182
83
|
|
|
183
|
-
it("
|
|
184
|
-
const
|
|
84
|
+
it("propagates validation, file, and upload failures to the task runner", async () => {
|
|
85
|
+
const error = new Error("Cannot read manifest");
|
|
86
|
+
publish.mockRejectedValueOnce(error);
|
|
185
87
|
|
|
186
|
-
await expect(zappifestPublish(configuration)).rejects.
|
|
187
|
-
"cannot resolve manifest"
|
|
188
|
-
);
|
|
88
|
+
await expect(zappifestPublish(configuration)).rejects.toBe(error);
|
|
189
89
|
});
|
|
190
90
|
});
|
|
@@ -50,13 +50,6 @@ 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
|
-
|
|
60
53
|
return [resolvedPluginPath, pluginPackageJson];
|
|
61
54
|
}
|
|
62
55
|
|
|
@@ -1,168 +1,27 @@
|
|
|
1
|
-
const R = require("ramda");
|
|
2
1
|
const { resolve } = require("path");
|
|
3
|
-
const {
|
|
2
|
+
const { publish } = require("@applicaster/zappifest-nano");
|
|
4
3
|
|
|
5
|
-
const { runInShellAsync } = require("../../shell");
|
|
6
4
|
const logger = require("../../logger");
|
|
7
|
-
const { findPlugin, uploadPluginVersion } = require("./zappApi");
|
|
8
|
-
|
|
9
|
-
function pushZappifestLegacy({
|
|
10
|
-
pluginPath,
|
|
11
|
-
dryRun,
|
|
12
|
-
manifestOnly,
|
|
13
|
-
zappOwnerAccountId,
|
|
14
|
-
}) {
|
|
15
|
-
return async function (platform) {
|
|
16
|
-
const manifestPath = resolve(pluginPath, `manifests/${platform}.json`);
|
|
17
|
-
const publishCommand = `zappifest publish --manifest ${manifestPath} --account ${zappOwnerAccountId}`;
|
|
18
|
-
|
|
19
|
-
if (dryRun || manifestOnly) {
|
|
20
|
-
logger.log(`running ${publishCommand}`);
|
|
21
|
-
logger.log(`with manifest: ${inspect(require(manifestPath))}`);
|
|
22
|
-
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return await runInShellAsync(publishCommand);
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Group platform manifests by Zapp plugin identifier.
|
|
32
|
-
* Some plugins (e.g. cell-info) ship mobile + TV under different identifiers
|
|
33
|
-
* in one npm package; each identifier must resolve to its own Zapp plugin id.
|
|
34
|
-
*/
|
|
35
|
-
function groupManifestsByIdentifier(manifests) {
|
|
36
|
-
return manifests.reduce((groups, manifest) => {
|
|
37
|
-
const key = manifest.identifier || "__missing_identifier__";
|
|
38
|
-
|
|
39
|
-
if (!groups[key]) {
|
|
40
|
-
groups[key] = [];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
groups[key].push(manifest);
|
|
44
|
-
|
|
45
|
-
return groups;
|
|
46
|
-
}, {});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function uploadManifestGroup({ identifier, manifests }) {
|
|
50
|
-
if (identifier === "__missing_identifier__") {
|
|
51
|
-
throw new Error(
|
|
52
|
-
`Cannot publish manifests without an identifier (platforms: ${manifests
|
|
53
|
-
.map((m) => m.platform)
|
|
54
|
-
.join(", ")})`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const { name } = manifests[0];
|
|
59
|
-
|
|
60
|
-
logger.log(`Looking up plugin '${identifier}' in Zapp...`);
|
|
61
|
-
const plugin = await findPlugin({ identifier, name });
|
|
62
|
-
logger.log(`Found plugin '${plugin.name}' (id: ${plugin.id}) in Zapp`);
|
|
63
|
-
|
|
64
|
-
await Promise.all(
|
|
65
|
-
manifests.map(async (manifest) => {
|
|
66
|
-
await uploadPluginVersion({ pluginId: plugin.id, manifest });
|
|
67
|
-
|
|
68
|
-
logger.log(
|
|
69
|
-
`✓ Uploaded manifest for platform '${manifest.platform}' (${manifest.manifest_version}) → plugin '${identifier}' (id: ${plugin.id})`
|
|
70
|
-
);
|
|
71
|
-
})
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
return manifests.length;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async function nativePublish({ platforms, pluginPath, dryRun, manifestOnly }) {
|
|
78
|
-
const manifests = platforms.map((platform) => {
|
|
79
|
-
const manifestPath = resolve(pluginPath, `manifests/${platform}.json`);
|
|
80
|
-
|
|
81
|
-
return require(manifestPath);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const grouped = groupManifestsByIdentifier(manifests);
|
|
85
|
-
const identifierCount = Object.keys(grouped).length;
|
|
86
|
-
|
|
87
|
-
if (dryRun || manifestOnly) {
|
|
88
|
-
Object.entries(grouped).forEach(([identifier, group]) => {
|
|
89
|
-
const platformsInGroup = group.map((m) => m.platform).join(", ");
|
|
90
|
-
|
|
91
|
-
logger.log(
|
|
92
|
-
`[dry-run] Would look up Zapp plugin '${identifier}' and upload ${group.length} platform(s): ${platformsInGroup}`
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
group.forEach((m) => {
|
|
96
|
-
logger.log(`[dry-run] Manifest: ${inspect(m)}`);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const startTime = Date.now();
|
|
104
|
-
|
|
105
|
-
logger.log(
|
|
106
|
-
`Uploading ${manifests.length} platform manifest(s) across ${identifierCount} Zapp plugin identifier(s)...`
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
// Resolve + upload each identifier group independently. Groups run
|
|
110
|
-
// sequentially so a lookup failure for one identifier does not leave
|
|
111
|
-
// ambiguous partial state across unrelated Zapp plugins; platforms
|
|
112
|
-
// within a group still upload in parallel.
|
|
113
|
-
let uploaded = 0;
|
|
114
|
-
|
|
115
|
-
for (const [identifier, group] of Object.entries(grouped)) {
|
|
116
|
-
uploaded += await uploadManifestGroup({ identifier, manifests: group });
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const duration = Date.now() - startTime;
|
|
120
|
-
|
|
121
|
-
logger.log(
|
|
122
|
-
`All ${uploaded} manifest(s) successfully uploaded to Zapp in ${duration}ms`
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
5
|
|
|
128
6
|
async function zappifestPublish(configuration) {
|
|
129
|
-
const { platforms, pluginPath, dryRun, manifestOnly
|
|
130
|
-
configuration;
|
|
131
|
-
|
|
132
|
-
if (dryRun || manifestOnly) {
|
|
133
|
-
logger.log(
|
|
134
|
-
"Running with --dry-run or --manifest-only option - not actually pushing to zapp"
|
|
135
|
-
);
|
|
136
|
-
}
|
|
7
|
+
const { platforms, pluginPath, dryRun, manifestOnly } = configuration;
|
|
137
8
|
|
|
138
|
-
if (!platforms ||
|
|
9
|
+
if (!platforms || platforms.length === 0) {
|
|
139
10
|
logger.log("Manifest does not exist, Skipping publishing");
|
|
140
11
|
|
|
141
12
|
return true;
|
|
142
13
|
}
|
|
143
14
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
dryRun,
|
|
152
|
-
manifestOnly,
|
|
153
|
-
zappOwnerAccountId,
|
|
154
|
-
}),
|
|
155
|
-
platforms
|
|
156
|
-
)
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return nativePublish({
|
|
161
|
-
platforms,
|
|
162
|
-
pluginPath,
|
|
163
|
-
dryRun,
|
|
164
|
-
manifestOnly,
|
|
15
|
+
await publish({
|
|
16
|
+
manifestPaths: platforms.map((platform) =>
|
|
17
|
+
resolve(pluginPath, `manifests/${platform}.json`)
|
|
18
|
+
),
|
|
19
|
+
dryRun: Boolean(dryRun || manifestOnly),
|
|
20
|
+
log: logger.log,
|
|
21
|
+
onWarning: logger.warn,
|
|
165
22
|
});
|
|
23
|
+
|
|
24
|
+
return true;
|
|
166
25
|
}
|
|
167
26
|
|
|
168
|
-
module.exports = { zappifestPublish
|
|
27
|
+
module.exports = { zappifestPublish };
|