@applicaster/zapplicaster-cli 17.0.0-rc.1 → 17.0.0-rc.4
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__/npmPublish.test.js +39 -23
- 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/npmPublish.js +6 -9
- package/src/commands/publishPlugin/updateCorePluginsIfNeeded.js +7 -0
- package/src/commands/publishPlugin/zappifestPublish.js +13 -154
- package/src/file/__tests__/file.test.js +7 -1
- package/src/file/index.js +14 -3
- package/test_helpers/fsMock.js +11 -0
- package/src/commands/publishPlugin/__tests__/zappApi.test.js +0 -271
- package/src/commands/publishPlugin/zappApi.js +0 -283
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,
|
|
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. Manifest publishing uses the bundled npm dependency instead of a separately installed Ruby zappifest.
|
|
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
|
+
Requires Node.js 22+, npm publishing access for your plugin, and the `ZAPP_TOKEN` environment variable. Manifest uploads use `@applicaster/zappifest-nano` in-process; Ruby and the legacy zappifest CLI are not required. See the [publishing contract](src/commands/publishPlugin/README.md) for platform selection, dry-run behavior, and failure handling.
|
|
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
|
|
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 supported platforms, but you can use the `-s, --single-platform` flag to target only one platform. The selected platform must be listed in `supportedPlatforms`.
|
|
122
122
|
|
|
123
123
|
```json
|
|
124
124
|
// package.json
|
|
@@ -127,8 +127,12 @@ 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
|
-
|
|
130
|
+
"supportedPlatforms": [
|
|
131
|
+
"ios_for_quickbrick",
|
|
132
|
+
"android_for_quickbrick",
|
|
133
|
+
"tvos_for_quickbrick",
|
|
134
|
+
"samsung_tv"
|
|
135
|
+
]
|
|
132
136
|
}
|
|
133
137
|
}
|
|
134
138
|
```
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapplicaster-cli",
|
|
3
|
-
"version": "17.0.0-rc.
|
|
3
|
+
"version": "17.0.0-rc.4",
|
|
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": ">= 22.0.0",
|
|
11
11
|
"yarn": "^4.0.0"
|
|
12
12
|
},
|
|
13
13
|
"bin": "./index.js",
|
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/zapp-react-dom-cli-template": "17.0.0-rc.
|
|
32
|
-
"@applicaster/zapp-react-native-android-tv-cli-template": "17.0.0-rc.
|
|
33
|
-
"@applicaster/zapp-react-native-cli-template": "17.0.0-rc.
|
|
34
|
-
"@applicaster/zapp-react-native-tvos-cli-template": "17.0.0-rc.
|
|
31
|
+
"@applicaster/zapp-react-dom-cli-template": "17.0.0-rc.4",
|
|
32
|
+
"@applicaster/zapp-react-native-android-tv-cli-template": "17.0.0-rc.4",
|
|
33
|
+
"@applicaster/zapp-react-native-cli-template": "17.0.0-rc.4",
|
|
34
|
+
"@applicaster/zapp-react-native-tvos-cli-template": "17.0.0-rc.4",
|
|
35
|
+
"@applicaster/zappifest-nano": "^1.0.0",
|
|
35
36
|
"axios": "^0.28.0",
|
|
36
37
|
"camelize": "^1.0.0",
|
|
37
38
|
"chalk": "^2.3.2",
|
|
@@ -2,14 +2,13 @@ const logger = require("../../logger");
|
|
|
2
2
|
const { runInShellAsync } = require("../../shell");
|
|
3
3
|
|
|
4
4
|
const BREW = "brew";
|
|
5
|
-
const ZAPPIFEST = "zappifest";
|
|
6
5
|
const ZAPPTOOL = "zapptool";
|
|
7
6
|
const YARN = "yarn";
|
|
8
7
|
const NODE = "node";
|
|
9
8
|
|
|
10
|
-
const LIBS = [BREW,
|
|
9
|
+
const LIBS = [BREW, ZAPPTOOL, YARN, NODE];
|
|
11
10
|
|
|
12
|
-
const NODE_VERSION = "
|
|
11
|
+
const NODE_VERSION = "22";
|
|
13
12
|
const YARN_VERSION = "1.21.1";
|
|
14
13
|
|
|
15
14
|
const INSTALL_SCRIPTS = {
|
|
@@ -22,10 +21,6 @@ const INSTALL_SCRIPTS = {
|
|
|
22
21
|
await runInShellAsync("brew tap applicaster/tap");
|
|
23
22
|
},
|
|
24
23
|
|
|
25
|
-
async [ZAPPIFEST]() {
|
|
26
|
-
await runInShellAsync("brew install zappifest");
|
|
27
|
-
},
|
|
28
|
-
|
|
29
24
|
async [ZAPPTOOL]() {
|
|
30
25
|
await runInShellAsync("brew install zapptool");
|
|
31
26
|
},
|
|
@@ -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 >= 22.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, ">= 22.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 >= 22.0.0"
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -1,140 +1,56 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
C1 --> D1[Slow Boot & Auth]
|
|
58
|
-
C2 --> D2[Slow Boot & Auth]
|
|
59
|
-
C3 --> D3[Slow Boot & Auth]
|
|
60
|
-
C4 --> D4[Slow Boot & Auth]
|
|
61
|
-
C5 --> D5[Slow Boot & Auth]
|
|
62
|
-
D1 --> E[Total Time: ~14 Minutes]
|
|
63
|
-
end
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Zappifest Nano Architecture (Blazing Fast)
|
|
67
|
-
```mermaid
|
|
68
|
-
flowchart TD
|
|
69
|
-
subgraph Nano [Zappifest Nano v2]
|
|
70
|
-
P[Topological Batch Queue] --> W1[Worker 1]
|
|
71
|
-
P --> W2[Worker 2]
|
|
72
|
-
P --> W3[Worker 3]
|
|
73
|
-
P --> W4[Worker 4]
|
|
74
|
-
W1 --> L1[Direct .json Lookup ~120ms]
|
|
75
|
-
L1 --> U1[Promise.all: Upload All 9 Manifests in Parallel]
|
|
76
|
-
U1 --> R[Total Time: ~4 Minutes 🚀]
|
|
77
|
-
end
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## 🛠️ Key Technical Superpowers
|
|
83
|
-
|
|
84
|
-
### 1. Parallel Platform Manifest Uploads
|
|
85
|
-
Instead of shelling out to publish 9 manifests one after another, Zappifest Nano reads all generated manifests in-memory and dispatches them directly via `Promise.all`:
|
|
86
|
-
```typescript
|
|
87
|
-
await Promise.all(
|
|
88
|
-
manifests.map(async (manifest) => {
|
|
89
|
-
await uploadPluginVersion({ pluginId: plugin.id, manifest });
|
|
90
|
-
})
|
|
91
|
-
);
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### 2. Topological Dependency Batching with Worker Pools
|
|
95
|
-
Plugins and core framework packages form a Directed Acyclic Graph (DAG). Packages in the same dependency tier publish in parallel using a resilient 4-worker queue pool:
|
|
96
|
-
```typescript
|
|
97
|
-
const BATCH_CONCURRENCY = 4;
|
|
98
|
-
const workers = Array.from({ length: concurrency }, async () => {
|
|
99
|
-
while (currentIndex < batch.length) {
|
|
100
|
-
const index = currentIndex++;
|
|
101
|
-
await batch[index].publish(version);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
await Promise.all(workers);
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### 3. CloudFront WAF Compliance
|
|
108
|
-
Zapp's edge infrastructure protects the Admin API via CloudFront WAF rules. Zappifest Nano handles user agent negotiation and native multipart streaming seamlessly:
|
|
109
|
-
- **User-Agent**: Explicitly identifies with authorized `Zappifest/0.66.0` signature.
|
|
110
|
-
- **REST Endpoints**: Calls `/plugins/${slug}.json` directly, eliminating Rails 406 format errors.
|
|
111
|
-
|
|
112
|
-
### 4. Dynamic Target & Framework ID Mapping
|
|
113
|
-
Rails model validations on Zapp Admin require integer database IDs for targets and UI frameworks rather than raw manifest strings. Zappifest Nano automatically resolves and caches these mappings:
|
|
114
|
-
- `mobile` ➔ `[1]`
|
|
115
|
-
- `tv` ➔ `[2]`
|
|
116
|
-
- `quickbrick` ➔ `[2]`
|
|
117
|
-
|
|
118
|
-
### 5. Atomic Workspace File Writes
|
|
119
|
-
Under heavy concurrent publishing, npm CLI traverses parent directories to discover workspaces. Zappifest Nano guarantees zero-byte file read errors through atomic temporary file generation and filesystem renames:
|
|
120
|
-
```typescript
|
|
121
|
-
const tmpPath = `${targetPath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2, 6)}`;
|
|
122
|
-
await fs.promises.writeFile(tmpPath, data, options);
|
|
123
|
-
await fs.promises.rename(tmpPath, targetPath);
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## 🛡️ Escape Hatch: Legacy Fallback
|
|
129
|
-
|
|
130
|
-
If for any troubleshooting reason you ever need to fall back to the legacy Ruby CLI, simply set the environment variable:
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
export USE_LEGACY_ZAPPIFEST=true
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
*(Warning: doing so will bring back the 14-minute deploy time!)*
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
*Engineered with pride for the QuickBrick developer community.*
|
|
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.
|
|
47
|
+
|
|
48
|
+
Deploy fetches full commit history and release tags for the current branch
|
|
49
|
+
without historical file contents (`--filter=blob:none`). Git can fetch those
|
|
50
|
+
contents on demand. The checkout stays at the pipeline commit even if the remote
|
|
51
|
+
branch has advanced.
|
|
52
|
+
|
|
53
|
+
Plugin publishing keeps npm workspace discovery enabled so it can load the
|
|
54
|
+
repository-root `.npmrc` for authentication. Framework package versions are
|
|
55
|
+
written atomically so concurrent npm workspace scans never read a partially
|
|
56
|
+
written `package.json`.
|
|
@@ -50,8 +50,6 @@ 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
|
-
|
|
55
53
|
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]`;
|
|
56
54
|
|
|
57
55
|
exports[`publish plugin configurator throws when the plugin path cannot be resolved 1`] = `[Error: cannot resolve file]`;
|
|
@@ -123,9 +123,12 @@ describe("publish plugin configurator", () => {
|
|
|
123
123
|
expect(configurator(options)).rejects.toMatchSnapshot();
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
it("
|
|
126
|
+
it("allows publishing existing plugins without a zapp account owner Id", async () => {
|
|
127
127
|
const options = getOptions({ pluginPath: "bad_missing_zapp_account" });
|
|
128
|
-
|
|
128
|
+
const config = await configurator(options);
|
|
129
|
+
|
|
130
|
+
expect(config.platforms).toEqual(["ios", "android"]);
|
|
131
|
+
expect(config.zappOwnerAccountId).toBeUndefined();
|
|
129
132
|
});
|
|
130
133
|
|
|
131
134
|
it("throws when the packages.json applicaster prop doesn't have list of supported platforms", async () => {
|
|
@@ -42,11 +42,21 @@ 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
|
+
}));
|
|
45
53
|
|
|
46
54
|
function clearMocks() {
|
|
47
55
|
logger.log.mockClear();
|
|
48
56
|
retryPublishCommand.mockClear();
|
|
49
57
|
runInShellAsync.mockClear();
|
|
58
|
+
if (writeJsonToFile.mockClear) writeJsonToFile.mockClear();
|
|
59
|
+
if (readJsonFile.mockClear) readJsonFile.mockClear();
|
|
50
60
|
jest.resetModules();
|
|
51
61
|
}
|
|
52
62
|
|
|
@@ -58,12 +68,10 @@ describe("npm publish step", () => {
|
|
|
58
68
|
const configuration = getConfig();
|
|
59
69
|
expect(await npmPublish(configuration)).toEqual(true);
|
|
60
70
|
expect(retryPublishCommand).toHaveBeenCalledTimes(1);
|
|
61
|
-
expect(runInShellAsync).toHaveBeenCalledTimes(1);
|
|
62
71
|
|
|
63
|
-
expect(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
expect.objectContaining({ cwd: configuration.pluginPath })
|
|
72
|
+
expect(writeJsonToFile).toHaveBeenCalledWith(
|
|
73
|
+
"plugins/my-plugin/package.json",
|
|
74
|
+
expect.objectContaining({ version: configuration.version })
|
|
67
75
|
);
|
|
68
76
|
|
|
69
77
|
expect(retryPublishCommand).toHaveBeenNthCalledWith(
|
|
@@ -75,8 +83,12 @@ describe("npm publish step", () => {
|
|
|
75
83
|
});
|
|
76
84
|
|
|
77
85
|
it("throws if the npm command fails", async () => {
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
retryPublishCommand.mockImplementationOnce(() =>
|
|
87
|
+
Promise.reject(mock_publish_error)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const configuration = getConfig();
|
|
91
|
+
await expect(npmPublish(configuration)).rejects.toMatchSnapshot();
|
|
80
92
|
});
|
|
81
93
|
|
|
82
94
|
it.skip("re tries 3 times if the npm command fails with ESOCKETTIMEDOUT", async () => {
|
|
@@ -134,15 +146,14 @@ describe("npm publish step", () => {
|
|
|
134
146
|
const configuration = getConfig({ dryRun: true });
|
|
135
147
|
|
|
136
148
|
expect(await npmPublish(configuration)).toEqual(true);
|
|
137
|
-
expect(runInShellAsync).toHaveBeenCalledTimes(1);
|
|
138
|
-
expect(retryPublishCommand).toHaveBeenCalledTimes(1);
|
|
139
149
|
|
|
140
|
-
expect(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
expect.objectContaining({ cwd: configuration.pluginPath })
|
|
150
|
+
expect(writeJsonToFile).toHaveBeenCalledWith(
|
|
151
|
+
"plugins/my-plugin/package.json",
|
|
152
|
+
expect.objectContaining({ version: configuration.version })
|
|
144
153
|
);
|
|
145
154
|
|
|
155
|
+
expect(retryPublishCommand).toHaveBeenCalledTimes(1);
|
|
156
|
+
|
|
146
157
|
expect(retryPublishCommand).toHaveBeenNthCalledWith(
|
|
147
158
|
1,
|
|
148
159
|
"npm publish --dry-run",
|
|
@@ -167,15 +178,13 @@ describe("npm publish step", () => {
|
|
|
167
178
|
|
|
168
179
|
expect(await npmPublish(configuration)).toEqual(true);
|
|
169
180
|
|
|
170
|
-
expect(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
expect(runInShellAsync).toHaveBeenNthCalledWith(
|
|
174
|
-
1,
|
|
175
|
-
`npm version ${configuration.version}`,
|
|
176
|
-
expect.objectContaining({ cwd: configuration.pluginPath })
|
|
181
|
+
expect(writeJsonToFile).toHaveBeenCalledWith(
|
|
182
|
+
"plugins/my-plugin/package.json",
|
|
183
|
+
expect.objectContaining({ version: configuration.version })
|
|
177
184
|
);
|
|
178
185
|
|
|
186
|
+
expect(retryPublishCommand).toHaveBeenCalledTimes(1);
|
|
187
|
+
|
|
179
188
|
expect(retryPublishCommand).toHaveBeenNthCalledWith(
|
|
180
189
|
1,
|
|
181
190
|
"npm publish --tag next",
|
|
@@ -190,9 +199,16 @@ describe("npm publish step", () => {
|
|
|
190
199
|
expect(await npmPublish(configuration)).toEqual(true);
|
|
191
200
|
expect(retryPublishCommand).toHaveBeenCalledTimes(1);
|
|
192
201
|
|
|
193
|
-
expect(
|
|
194
|
-
|
|
195
|
-
expect.objectContaining({
|
|
202
|
+
expect(writeJsonToFile).toHaveBeenCalledWith(
|
|
203
|
+
"plugins/my-plugin/package.json",
|
|
204
|
+
expect.objectContaining({ version: configuration.version })
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
expect(retryPublishCommand).toHaveBeenNthCalledWith(
|
|
208
|
+
1,
|
|
209
|
+
"npm publish --tag next",
|
|
210
|
+
expect.objectContaining({ cwd: configuration.pluginPath }),
|
|
211
|
+
configuration.version
|
|
196
212
|
);
|
|
197
213
|
});
|
|
198
214
|
});
|
|
@@ -0,0 +1,154 @@
|
|
|
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
|
+
});
|