@applicaster/zapplicaster-cli 13.0.0-alpha.3244448100 → 13.0.0-alpha.3251251233

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-alpha.3244448100",
3
+ "version": "13.0.0-alpha.3251251233",
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-alpha.3244448100",
36
- "@applicaster/zapp-react-native-android-tv-cli-template": "13.0.0-alpha.3244448100",
37
- "@applicaster/zapp-react-native-cli-template": "13.0.0-alpha.3244448100",
38
- "@applicaster/zapp-react-native-tvos-cli-template": "13.0.0-alpha.3244448100",
35
+ "@applicaster/zapp-react-dom-cli-template": "13.0.0-alpha.3251251233",
36
+ "@applicaster/zapp-react-native-android-tv-cli-template": "13.0.0-alpha.3251251233",
37
+ "@applicaster/zapp-react-native-cli-template": "13.0.0-alpha.3251251233",
38
+ "@applicaster/zapp-react-native-tvos-cli-template": "13.0.0-alpha.3251251233",
39
39
  "axios": "^0.28.0",
40
40
  "camelize": "^1.0.0",
41
41
  "chalk": "^2.3.2",
@@ -50,18 +50,6 @@ describe("configFilesRetriever", () => {
50
50
  expect(mock_curriedSaveRemoteJsonToFile).toHaveBeenCalledTimes(5);
51
51
  });
52
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);
63
- });
64
-
65
53
  it("saves custom config files form the template", async () => {
66
54
  const configFiles = [
67
55
  { name: "custom_conf.json", getJsonContent: () => ({ foo: "bar" }) },
@@ -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
 
@@ -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
  };