@applicaster/zapplicaster-cli 16.0.0-alpha.2480030155 → 16.0.0-alpha.2500443242
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/__tests__/buildPluginsCreator.test.js +99 -0
- package/src/commands/prepareWorkspace/appBootstrapper.js +3 -2
- package/src/commands/prepareWorkspace/buildPluginsCreator.js +61 -0
- package/src/commands/prepareWorkspace/configFilesRetriever.js +3 -0
- package/src/commands/prepareWorkspace/configurator.js +2 -1
- 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/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.2500443242",
|
|
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.2500443242",
|
|
32
|
+
"@applicaster/zapp-react-native-android-tv-cli-template": "16.0.0-alpha.2500443242",
|
|
33
|
+
"@applicaster/zapp-react-native-cli-template": "16.0.0-alpha.2500443242",
|
|
34
|
+
"@applicaster/zapp-react-native-tvos-cli-template": "16.0.0-alpha.2500443242",
|
|
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,
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const os = require("os");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
jest.mock("../../../render", () => ({
|
|
6
|
+
saveConfigFile: jest.fn(),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
jest.mock("../../../settings/paths", () => ({
|
|
10
|
+
getFileDestinationPath: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
jest.mock("../../../logger", () => ({
|
|
14
|
+
error: jest.fn(),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
const { saveConfigFile } = require("../../../render");
|
|
18
|
+
const { getFileDestinationPath } = require("../../../settings/paths");
|
|
19
|
+
const logger = require("../../../logger");
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
buildPluginsCreator,
|
|
23
|
+
getBuildPlugins,
|
|
24
|
+
} = require("../buildPluginsCreator");
|
|
25
|
+
|
|
26
|
+
const pluginConfigurations = [
|
|
27
|
+
{
|
|
28
|
+
plugin: {
|
|
29
|
+
identifier: "zeta",
|
|
30
|
+
name: "Zeta",
|
|
31
|
+
manifest_version: "2.0.0",
|
|
32
|
+
dependency_version: "1.0.0",
|
|
33
|
+
},
|
|
34
|
+
configuration_json: { key: "value" },
|
|
35
|
+
},
|
|
36
|
+
{ plugin: { identifier: "alpha", dependency_version: "3.1.0" } },
|
|
37
|
+
{ plugin: { name: "no identifier, skipped" } },
|
|
38
|
+
{ configuration_json: {} },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const expected = [
|
|
42
|
+
{ id: "alpha", name: null, version: "3.1.0" },
|
|
43
|
+
{ id: "zeta", name: "Zeta", version: "2.0.0" },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const configuration = { destinationPath: "path/to/workspace", platform: "ios" };
|
|
47
|
+
|
|
48
|
+
describe("getBuildPlugins", () => {
|
|
49
|
+
it("maps plugins to id, name, version sorted by id, preferring manifest_version", () => {
|
|
50
|
+
expect(getBuildPlugins(pluginConfigurations)).toEqual(expected);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("buildPluginsCreator", () => {
|
|
55
|
+
const file = path.join(
|
|
56
|
+
os.tmpdir(),
|
|
57
|
+
`plugin_configurations_${process.pid}.json`
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
afterEach(() => {
|
|
61
|
+
jest.clearAllMocks();
|
|
62
|
+
fs.rmSync(file, { force: true });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("writes build_plugins.json from the downloaded plugin_configurations.json", async () => {
|
|
66
|
+
fs.writeFileSync(file, JSON.stringify(pluginConfigurations));
|
|
67
|
+
getFileDestinationPath.mockReturnValue(file);
|
|
68
|
+
|
|
69
|
+
await buildPluginsCreator(configuration);
|
|
70
|
+
|
|
71
|
+
expect(getFileDestinationPath).toHaveBeenCalledWith({
|
|
72
|
+
...configuration,
|
|
73
|
+
folder: "config",
|
|
74
|
+
fileName: "plugin_configurations.json",
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
expect(saveConfigFile).toHaveBeenCalledWith(
|
|
78
|
+
configuration,
|
|
79
|
+
"build_plugins.json",
|
|
80
|
+
expected
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
expect(logger.error).not.toHaveBeenCalled();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("writes an empty list and logs an error when plugin_configurations.json is missing", async () => {
|
|
87
|
+
getFileDestinationPath.mockReturnValue(file);
|
|
88
|
+
|
|
89
|
+
await buildPluginsCreator(configuration);
|
|
90
|
+
|
|
91
|
+
expect(saveConfigFile).toHaveBeenCalledWith(
|
|
92
|
+
configuration,
|
|
93
|
+
"build_plugins.json",
|
|
94
|
+
[]
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect(logger.error).toHaveBeenCalled();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -257,8 +257,9 @@ function checkAllPluginsSatisfiesQuickBrickVersion({
|
|
|
257
257
|
for (let i = 0; i < plugins.length; i++) {
|
|
258
258
|
const plugin = plugins[i];
|
|
259
259
|
|
|
260
|
-
const packagePath = `${process.cwd()}/node_modules/${
|
|
261
|
-
|
|
260
|
+
const packagePath = `${process.cwd()}/node_modules/${
|
|
261
|
+
plugin.packageName
|
|
262
|
+
}/package.json`;
|
|
262
263
|
|
|
263
264
|
if (!fs.existsSync(packagePath)) {
|
|
264
265
|
return;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
|
|
3
|
+
const { saveConfigFile } = require("../../render");
|
|
4
|
+
const { getFileDestinationPath } = require("../../settings/paths");
|
|
5
|
+
const logger = require("../../logger");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Plugins the app is built with, as [{ id, name, version }] sorted by id.
|
|
9
|
+
* version is manifest_version, falling back to dependency_version.
|
|
10
|
+
* @param {Array} pluginConfigurations content of plugin_configurations.json
|
|
11
|
+
*/
|
|
12
|
+
function getBuildPlugins(pluginConfigurations) {
|
|
13
|
+
return pluginConfigurations
|
|
14
|
+
.filter((entry) => typeof entry?.plugin?.identifier === "string")
|
|
15
|
+
.map(({ plugin }) => ({
|
|
16
|
+
id: plugin.identifier,
|
|
17
|
+
name: plugin.name ?? null,
|
|
18
|
+
version: plugin.manifest_version ?? plugin.dependency_version ?? null,
|
|
19
|
+
}))
|
|
20
|
+
.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Writes build_plugins.json next to the downloaded plugin_configurations.json.
|
|
25
|
+
* The app bundles it on every platform (plugin_configurations.json itself is only bundled in __DEV__),
|
|
26
|
+
* so tools like X-Ray can report what the build contains, not what Zapp serves now.
|
|
27
|
+
* @param {Object} configuration
|
|
28
|
+
* @param {String} configuration.destinationPath path of the workspace
|
|
29
|
+
* @param {String} configuration.platform platform of the app
|
|
30
|
+
*/
|
|
31
|
+
async function buildPluginsCreator(configuration) {
|
|
32
|
+
const { destinationPath, platform } = configuration;
|
|
33
|
+
|
|
34
|
+
let buildPlugins = [];
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const pluginConfigurations = JSON.parse(
|
|
38
|
+
fs.readFileSync(
|
|
39
|
+
getFileDestinationPath({
|
|
40
|
+
destinationPath,
|
|
41
|
+
platform,
|
|
42
|
+
folder: "config",
|
|
43
|
+
fileName: "plugin_configurations.json",
|
|
44
|
+
}),
|
|
45
|
+
"utf8"
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
buildPlugins = getBuildPlugins(pluginConfigurations);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
logger.error(
|
|
52
|
+
`Could not read plugin_configurations.json, build_plugins.json will be empty: ${e.message}`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
await saveConfigFile(configuration, "build_plugins.json", buildPlugins);
|
|
57
|
+
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = { buildPluginsCreator, getBuildPlugins };
|
|
@@ -7,6 +7,7 @@ const {
|
|
|
7
7
|
} = require("../../download");
|
|
8
8
|
|
|
9
9
|
const { renderConfigFile } = require("../../render");
|
|
10
|
+
const { buildPluginsCreator } = require("./buildPluginsCreator");
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @typedef configuration
|
|
@@ -45,6 +46,8 @@ async function configFilesRetriever(configuration) {
|
|
|
45
46
|
R.map(saveRemoteJsonToFile(configuration), configFilesUrls)
|
|
46
47
|
);
|
|
47
48
|
|
|
49
|
+
await buildPluginsCreator(configuration);
|
|
50
|
+
|
|
48
51
|
const { fonts_url, fonts, assets_url } = buildParams;
|
|
49
52
|
saveFontFiles(configuration, fonts_url, fonts);
|
|
50
53
|
saveAssets(configuration, assets_url);
|
|
@@ -94,7 +94,8 @@ async function configurator({ cliArgs, cliOptions }) {
|
|
|
94
94
|
|
|
95
95
|
const buildParams = await getAppVersionParams(appVersionId);
|
|
96
96
|
|
|
97
|
-
buildParams.vidaa_client_partner_id =
|
|
97
|
+
buildParams.vidaa_client_partner_id =
|
|
98
|
+
resolveVidaaClientPartnerId(buildParams);
|
|
98
99
|
|
|
99
100
|
delete buildParams.styles_url; // deprecated
|
|
100
101
|
|
|
@@ -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
|
|