@applicaster/zapplicaster-cli 12.0.3-alpha.5953460913 → 13.0.0-alpha.1436249127
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 +0 -1
- package/package.json +5 -5
- package/src/commands/prepareWorkspace/__tests__/__snapshots__/prepareWorkspace.test.js.snap +4 -4
- package/src/commands/prepareWorkspace/__tests__/configFilesRetriever.test.js +12 -14
- package/src/commands/prepareWorkspace/configFilesRetriever.js +9 -22
- package/src/commands/prepareWorkspace/index.js +6 -6
- package/src/commands/prepareWorkspace/runtimeConfigurationUrlsCreator.js +3 -0
- package/src/download/__tests__/__snapshots__/download.test.js.snap +1 -1
- package/src/download/__tests__/download.test.js +14 -9
- package/src/download/index.js +2 -9
- package/src/templates/newWorkspaceTemplate/index.js +0 -1
package/README.md
CHANGED
|
@@ -98,7 +98,6 @@ const template = {
|
|
|
98
98
|
getJsonContent: config => ({ ... }) // function to get the config file's content from the CLI's configuration object. optional
|
|
99
99
|
}
|
|
100
100
|
],
|
|
101
|
-
remoteFiles: config => [] // function which returns an array of remote urls to save as config files. optional
|
|
102
101
|
}
|
|
103
102
|
```
|
|
104
103
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapplicaster-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0-alpha.1436249127",
|
|
4
4
|
"description": "CLI Tool for the zapp app and Quick Brick project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@applicaster/zapp-react-dom-cli-template": "
|
|
36
|
-
"@applicaster/zapp-react-native-android-tv-cli-template": "
|
|
37
|
-
"@applicaster/zapp-react-native-cli-template": "
|
|
38
|
-
"@applicaster/zapp-react-native-tvos-cli-template": "
|
|
35
|
+
"@applicaster/zapp-react-dom-cli-template": "13.0.0-alpha.1436249127",
|
|
36
|
+
"@applicaster/zapp-react-native-android-tv-cli-template": "13.0.0-alpha.1436249127",
|
|
37
|
+
"@applicaster/zapp-react-native-cli-template": "13.0.0-alpha.1436249127",
|
|
38
|
+
"@applicaster/zapp-react-native-tvos-cli-template": "13.0.0-alpha.1436249127",
|
|
39
39
|
"axios": "^0.28.0",
|
|
40
40
|
"camelize": "^1.0.0",
|
|
41
41
|
"chalk": "^2.3.2",
|
|
@@ -27,10 +27,10 @@ Array [
|
|
|
27
27
|
"Creating workspace",
|
|
28
28
|
],
|
|
29
29
|
Array [
|
|
30
|
-
"
|
|
30
|
+
"Creating runtime URLs configuration file",
|
|
31
31
|
],
|
|
32
32
|
Array [
|
|
33
|
-
"
|
|
33
|
+
"Retrieving configuration files",
|
|
34
34
|
],
|
|
35
35
|
Array [
|
|
36
36
|
"Bootstraping app project",
|
|
@@ -53,10 +53,10 @@ Array [
|
|
|
53
53
|
"Workspace created !",
|
|
54
54
|
],
|
|
55
55
|
Array [
|
|
56
|
-
"
|
|
56
|
+
"Runtime configuration URLs file created",
|
|
57
57
|
],
|
|
58
58
|
Array [
|
|
59
|
-
"
|
|
59
|
+
"Configuration files retrieved !",
|
|
60
60
|
],
|
|
61
61
|
Array [
|
|
62
62
|
"Successfully bootstrapped the app!",
|
|
@@ -11,6 +11,7 @@ jest.mock("../../../download", () => ({
|
|
|
11
11
|
|
|
12
12
|
jest.mock("../../../render", () => ({
|
|
13
13
|
renderConfigFile: jest.fn(() => mock_curriedRenderConfigFile),
|
|
14
|
+
saveConfigFile: jest.fn(),
|
|
14
15
|
}));
|
|
15
16
|
|
|
16
17
|
const {
|
|
@@ -22,6 +23,11 @@ const {
|
|
|
22
23
|
const { renderConfigFile } = require("../../../render");
|
|
23
24
|
|
|
24
25
|
const { build_params: buildParams } = require("./fixtures/buildParams.json");
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
runtimeConfigurationUrlsCreator,
|
|
29
|
+
} = require("../runtimeConfigurationUrlsCreator");
|
|
30
|
+
|
|
25
31
|
const destinationPath = "path/to/workspace";
|
|
26
32
|
const platform = "ios";
|
|
27
33
|
const template = {};
|
|
@@ -34,7 +40,11 @@ const configuration = {
|
|
|
34
40
|
};
|
|
35
41
|
|
|
36
42
|
describe("configFilesRetriever", () => {
|
|
37
|
-
|
|
43
|
+
beforeAll((done) => {
|
|
44
|
+
runtimeConfigurationUrlsCreator(configuration).then(() => {
|
|
45
|
+
done();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
38
48
|
|
|
39
49
|
afterEach(() => {
|
|
40
50
|
mock_curriedSaveRemoteJsonToFile.mockClear();
|
|
@@ -47,19 +57,7 @@ describe("configFilesRetriever", () => {
|
|
|
47
57
|
await configFilesRetriever(configuration);
|
|
48
58
|
|
|
49
59
|
expect(saveRemoteJsonToFile).toHaveBeenCalledWith(configuration);
|
|
50
|
-
expect(mock_curriedSaveRemoteJsonToFile).toHaveBeenCalledTimes(
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("also downloads remote files from the template", async () => {
|
|
54
|
-
const config = {
|
|
55
|
-
...configuration,
|
|
56
|
-
template: { remoteFiles: () => ["additional_file"] },
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
await configFilesRetriever(config);
|
|
60
|
-
|
|
61
|
-
expect(saveRemoteJsonToFile).toHaveBeenCalledWith(config);
|
|
62
|
-
expect(mock_curriedSaveRemoteJsonToFile).toHaveBeenCalledTimes(6);
|
|
60
|
+
expect(mock_curriedSaveRemoteJsonToFile).toHaveBeenCalledTimes(4);
|
|
63
61
|
});
|
|
64
62
|
|
|
65
63
|
it("saves custom config files form the template", async () => {
|
|
@@ -24,34 +24,21 @@ const { renderConfigFile } = require("../../render");
|
|
|
24
24
|
* @param {configuration} configuration
|
|
25
25
|
*/
|
|
26
26
|
async function configFilesRetriever(configuration) {
|
|
27
|
-
const { buildParams, template } = configuration;
|
|
27
|
+
const { buildParams, template, runtimeConfigurationUrls } = configuration;
|
|
28
28
|
|
|
29
|
-
const { configFiles = []
|
|
29
|
+
const { configFiles = [] } = template;
|
|
30
30
|
|
|
31
31
|
if (Array.isArray(configFiles) && !R.propEq("length", 0, configFiles)) {
|
|
32
32
|
await Promise.all(R.map(renderConfigFile(configuration), configFiles));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const configFilesUrls =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
R.prop(R.__, buildParams),
|
|
43
|
-
])
|
|
44
|
-
)
|
|
45
|
-
),
|
|
46
|
-
R.reject(
|
|
47
|
-
R.compose(
|
|
48
|
-
R.either(R.isNil, R.compose(R.not, R.test(/(.json)$/i))),
|
|
49
|
-
R.prop(R.__, buildParams)
|
|
50
|
-
)
|
|
51
|
-
),
|
|
52
|
-
R.filter(R.test(/(_url)$/i)),
|
|
53
|
-
R.keys
|
|
54
|
-
)(buildParams);
|
|
35
|
+
const configFilesUrls = Object.entries(runtimeConfigurationUrls).map(
|
|
36
|
+
([key, value]) => {
|
|
37
|
+
const newKey = key.replace("_url", ".json");
|
|
38
|
+
|
|
39
|
+
return [newKey, value];
|
|
40
|
+
}
|
|
41
|
+
);
|
|
55
42
|
|
|
56
43
|
// download files & save json files
|
|
57
44
|
await Promise.all(
|
|
@@ -32,18 +32,18 @@ const prepareWorkspaceTask = {
|
|
|
32
32
|
error: "Could not create workspace",
|
|
33
33
|
completion: "Workspace created !",
|
|
34
34
|
},
|
|
35
|
-
{
|
|
36
|
-
start: "Retrieving configuration files",
|
|
37
|
-
run: configFilesRetriever,
|
|
38
|
-
error: "Could not retrieve configuration files",
|
|
39
|
-
completion: "Configuration files retrieved !",
|
|
40
|
-
},
|
|
41
35
|
{
|
|
42
36
|
start: "Creating runtime URLs configuration file",
|
|
43
37
|
run: runtimeConfigurationUrlsCreator,
|
|
44
38
|
error: "Could not create runtime_configuration_urls.json",
|
|
45
39
|
completion: "Runtime configuration URLs file created",
|
|
46
40
|
},
|
|
41
|
+
{
|
|
42
|
+
start: "Retrieving configuration files",
|
|
43
|
+
run: configFilesRetriever,
|
|
44
|
+
error: "Could not retrieve configuration files",
|
|
45
|
+
completion: "Configuration files retrieved !",
|
|
46
|
+
},
|
|
47
47
|
{
|
|
48
48
|
start: "Bootstraping app project",
|
|
49
49
|
run: appBootstrapper,
|
|
@@ -31,6 +31,9 @@ async function runtimeConfigurationUrlsCreator(configuration) {
|
|
|
31
31
|
runtimeConfigurationUrls
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
+
// Intentionally mutating parameter to pass runtimeConfigurationUrls to the next step
|
|
35
|
+
configuration.runtimeConfigurationUrls = runtimeConfigurationUrls;
|
|
36
|
+
|
|
34
37
|
return true;
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`saveRemoteJsonToFile throws an error if the download fails 1`] = `[Error: An error occurred while trying to retrieve
|
|
3
|
+
exports[`saveRemoteJsonToFile throws an error if the download fails 1`] = `[Error: An error occurred while trying to retrieve file.json: Request failed with status code 500]`;
|
|
@@ -38,10 +38,11 @@ const platform = "ios";
|
|
|
38
38
|
|
|
39
39
|
describe("saveRemoteJsonToFile", () => {
|
|
40
40
|
const fileUrl = "http://host.com/file.json";
|
|
41
|
-
const fileUrlWithError = "http://host.com/error.json";
|
|
42
41
|
|
|
43
42
|
const fileName = getFileName(fileUrl);
|
|
44
43
|
|
|
44
|
+
const fileUrlWithError = "http://host.com/error.json";
|
|
45
|
+
|
|
45
46
|
const filePath = `${destinationPath}/config/${platform}/${fileName}`;
|
|
46
47
|
|
|
47
48
|
const fileContent = {
|
|
@@ -61,7 +62,10 @@ describe("saveRemoteJsonToFile", () => {
|
|
|
61
62
|
});
|
|
62
63
|
|
|
63
64
|
it("downloads the file and writes it to the path", async () => {
|
|
64
|
-
await saveRemoteJsonToFile({ destinationPath, platform })(
|
|
65
|
+
await saveRemoteJsonToFile({ destinationPath, platform })([
|
|
66
|
+
fileName,
|
|
67
|
+
fileUrl,
|
|
68
|
+
]);
|
|
65
69
|
|
|
66
70
|
expect(loggerSpy).toHaveBeenCalledWith(
|
|
67
71
|
`saving ${fileName} from ${fileUrl}`
|
|
@@ -71,10 +75,10 @@ describe("saveRemoteJsonToFile", () => {
|
|
|
71
75
|
});
|
|
72
76
|
|
|
73
77
|
it("can download files from an object", async () => {
|
|
74
|
-
await saveRemoteJsonToFile({ destinationPath, platform })(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
await saveRemoteJsonToFile({ destinationPath, platform })([
|
|
79
|
+
fileName,
|
|
80
|
+
fileUrl,
|
|
81
|
+
]);
|
|
78
82
|
|
|
79
83
|
expect(loggerSpy).toHaveBeenCalledWith(
|
|
80
84
|
`saving ${fileName} from ${fileUrl}`
|
|
@@ -87,9 +91,10 @@ describe("saveRemoteJsonToFile", () => {
|
|
|
87
91
|
expect.assertions(1);
|
|
88
92
|
|
|
89
93
|
try {
|
|
90
|
-
await saveRemoteJsonToFile({ destinationPath, platform })(
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
await saveRemoteJsonToFile({ destinationPath, platform })([
|
|
95
|
+
fileName,
|
|
96
|
+
fileUrlWithError,
|
|
97
|
+
]);
|
|
93
98
|
} catch (e) {
|
|
94
99
|
expect(e).toMatchSnapshot();
|
|
95
100
|
}
|
package/src/download/index.js
CHANGED
|
@@ -12,8 +12,6 @@ const getFileName = R.ifElse(
|
|
|
12
12
|
R.prop("name")
|
|
13
13
|
);
|
|
14
14
|
|
|
15
|
-
const getFileUrl = R.unless(R.is(String), R.prop("url"));
|
|
16
|
-
|
|
17
15
|
/**
|
|
18
16
|
* saves a remote json file in the app's configuration folder.
|
|
19
17
|
* curried function of the shape saveRemoteJsonToFile(configuration)(fileUrl)
|
|
@@ -24,11 +22,8 @@ const getFileUrl = R.unless(R.is(String), R.prop("url"));
|
|
|
24
22
|
* @returns {Promise<Object>} status of the file write operation
|
|
25
23
|
*/
|
|
26
24
|
function saveRemoteJsonToFile({ destinationPath, platform }) {
|
|
27
|
-
return async function (
|
|
25
|
+
return async function ([fileName, fileUrl]) {
|
|
28
26
|
try {
|
|
29
|
-
const fileName = getFileName(file);
|
|
30
|
-
const fileUrl = getFileUrl(file);
|
|
31
|
-
|
|
32
27
|
logger.log(`saving ${fileName} from ${fileUrl}`);
|
|
33
28
|
|
|
34
29
|
const { data: fileContent } = await axios.get(fileUrl);
|
|
@@ -44,10 +39,8 @@ function saveRemoteJsonToFile({ destinationPath, platform }) {
|
|
|
44
39
|
|
|
45
40
|
return result;
|
|
46
41
|
} catch (e) {
|
|
47
|
-
const filename = typeof file === "string" ? file : file.name;
|
|
48
|
-
|
|
49
42
|
throw new Error(
|
|
50
|
-
`An error occurred while trying to retrieve ${
|
|
43
|
+
`An error occurred while trying to retrieve ${fileName}: ${e.message}`
|
|
51
44
|
);
|
|
52
45
|
}
|
|
53
46
|
};
|
|
@@ -11,7 +11,6 @@ const template = {
|
|
|
11
11
|
dependencies: [
|
|
12
12
|
{ name: "@babel/core", version: "^7.2.2", type: "devDependencies" },
|
|
13
13
|
{ name: "@babel/preset-env", version: "^7.3.1", type: "devDependencies" },
|
|
14
|
-
{ name: "@babel/preset-flow", version: "^7.0.0", type: "devDependencies" },
|
|
15
14
|
{ name: "@babel/preset-react", version: "^7.0.0", type: "devDependencies" },
|
|
16
15
|
{ name: "babel-core", version: "^7.0.0-bridge.0", type: "devDependencies" },
|
|
17
16
|
{ name: "babel-eslint", version: "^8.0.3", type: "devDependencies" },
|