@applicaster/zapplicaster-cli 13.0.0-rc.11 → 13.0.0-rc.13

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 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": "13.0.0-rc.11",
3
+ "version": "13.0.0-rc.13",
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": "13.0.0-rc.11",
36
- "@applicaster/zapp-react-native-android-tv-cli-template": "13.0.0-rc.11",
37
- "@applicaster/zapp-react-native-cli-template": "13.0.0-rc.11",
38
- "@applicaster/zapp-react-native-tvos-cli-template": "13.0.0-rc.11",
35
+ "@applicaster/zapp-react-dom-cli-template": "13.0.0-rc.13",
36
+ "@applicaster/zapp-react-native-android-tv-cli-template": "13.0.0-rc.13",
37
+ "@applicaster/zapp-react-native-cli-template": "13.0.0-rc.13",
38
+ "@applicaster/zapp-react-native-tvos-cli-template": "13.0.0-rc.13",
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
- "Retrieving configuration files",
30
+ "Creating runtime URLs configuration file",
31
31
  ],
32
32
  Array [
33
- "Creating runtime URLs configuration file",
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
- "Configuration files retrieved !",
56
+ "Runtime configuration URLs file created",
57
57
  ],
58
58
  Array [
59
- "Runtime configuration URLs file created",
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
- // it("retrieves specific config files from the template", () => {});
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(5);
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 = [], remoteFiles = () => [] } = template;
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 = R.compose(
36
- R.concat(remoteFiles(configuration)),
37
- R.map(
38
- R.compose(
39
- R.zipObj(["name", "url"]),
40
- R.juxt([
41
- R.compose(R.concat(R.__, ".json"), R.replace("_url", "")),
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 http://host.com/error.json: Request failed with status code 500]`;
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 })(fileUrl);
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
- name: fileName,
76
- url: fileUrl,
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
- fileUrlWithError
92
- );
94
+ await saveRemoteJsonToFile({ destinationPath, platform })([
95
+ fileName,
96
+ fileUrlWithError,
97
+ ]);
93
98
  } catch (e) {
94
99
  expect(e).toMatchSnapshot();
95
100
  }
@@ -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 (file) {
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 ${filename}: ${e.message}`
43
+ `An error occurred while trying to retrieve ${fileName}: ${e.message}`
51
44
  );
52
45
  }
53
46
  };