@applicaster/zapplicaster-cli 15.0.0-alpha.5197372201 → 15.0.0-alpha.5262500595

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapplicaster-cli",
3
- "version": "15.0.0-alpha.5197372201",
3
+ "version": "15.0.0-alpha.5262500595",
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": "15.0.0-alpha.5197372201",
32
- "@applicaster/zapp-react-native-android-tv-cli-template": "15.0.0-alpha.5197372201",
33
- "@applicaster/zapp-react-native-cli-template": "15.0.0-alpha.5197372201",
34
- "@applicaster/zapp-react-native-tvos-cli-template": "15.0.0-alpha.5197372201",
31
+ "@applicaster/zapp-react-dom-cli-template": "15.0.0-alpha.5262500595",
32
+ "@applicaster/zapp-react-native-android-tv-cli-template": "15.0.0-alpha.5262500595",
33
+ "@applicaster/zapp-react-native-cli-template": "15.0.0-alpha.5262500595",
34
+ "@applicaster/zapp-react-native-tvos-cli-template": "15.0.0-alpha.5262500595",
35
35
  "axios": "^0.28.0",
36
36
  "camelize": "^1.0.0",
37
37
  "chalk": "^2.3.2",
@@ -1,7 +1,4 @@
1
1
  const { appBootstrapper, isVersionSatisfies } = require("../appBootstrapper");
2
- const { mkdtempSync, mkdirSync, writeFileSync, rmSync } = require("fs");
3
- const os = require("os");
4
- const path = require("path");
5
2
 
6
3
  jest.mock("path", () => ({
7
4
  ...jest.requireActual("path"),
@@ -217,38 +214,6 @@ describe("appBootstrapper", () => {
217
214
  expect(exec.mock.calls).toMatchSnapshot();
218
215
  });
219
216
 
220
- it("applies rn-patches from development-app to root node_modules", async () => {
221
- const quickBrickProjectPath = mkdtempSync(
222
- path.join(os.tmpdir(), "quick-brick-workspace-")
223
- );
224
-
225
- mkdirSync(
226
- path.join(quickBrickProjectPath, "node_modules", "quick-brick-app"),
227
- {
228
- recursive: true,
229
- }
230
- );
231
- mkdirSync(path.join(quickBrickProjectPath, "development-app", "rn-patches"), {
232
- recursive: true,
233
- });
234
- writeFileSync(
235
- path.join(quickBrickProjectPath, "package.json"),
236
- JSON.stringify({ workspaces: ["development-app"] })
237
- );
238
-
239
- try {
240
- const config = configuration({ destinationPath: quickBrickProjectPath });
241
-
242
- await appBootstrapper(config);
243
-
244
- expect(exec).toHaveBeenCalledWith(
245
- `cd "${quickBrickProjectPath}" && yarn patch-package --patch-dir development-app/rn-patches`
246
- );
247
- } finally {
248
- rmSync(quickBrickProjectPath, { recursive: true, force: true });
249
- }
250
- });
251
-
252
217
  it("Version satisfies", async () => {
253
218
  expect(isVersionSatisfies("6.1.7", "6.1.7")).toBe(true);
254
219
  expect(isVersionSatisfies("6.1.7", "6.1.7-rc.13")).toBe(true);
@@ -30,98 +30,34 @@ const {
30
30
  } = require("../../render");
31
31
 
32
32
  const { buildMobileApp } = require("./buildMobile");
33
- const { has } = require("lodash");
34
33
 
35
- function hasQuickBrickAppWorkspace(quickBrickProjectPath) {
36
- const packageJsonPath = join(quickBrickProjectPath, "package.json");
37
-
38
- if (!existsSync(packageJsonPath)) {
39
- return false;
40
- }
41
-
42
- try {
43
- const { workspaces } = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
44
-
45
- const hasWorkspacesConfigured = Boolean(workspaces);
46
-
47
- const hasQuickBrickAppInstalled = existsSync(
48
- join(quickBrickProjectPath, "node_modules", "quick-brick-app")
49
- );
50
-
51
- return hasWorkspacesConfigured && hasQuickBrickAppInstalled;
52
- } catch (error) {
53
- logger.warn(
54
- "Skipping yarn workspace quick-brick-app patch:rn; unable to read workspace configuration."
55
- );
56
-
57
- return false;
58
- }
59
- }
60
-
61
- async function patchPackages(quickBrickProjectPath = process.cwd()) {
62
- // ./development-app/rn-patches
63
- const rnPatchesQB = join(
64
- quickBrickProjectPath,
65
- join("development-app", "rn-patches")
66
- );
67
-
68
- logger.log(
69
- "Applying patch-package patches from rn-patches to workspace root node_modules"
70
- );
71
-
72
- // Verify if the rn-patches directory exists before attempting to run patch-package, fallback to legacy patch_rn.js if it doesn't exist or if the patch-package command fails
73
- if (
74
- existsSync(rnPatchesQB) &&
75
- exec(`yarn patch-package --patch-dir ${rnPatchesQB}`).code !== 0
34
+ async function patchPackages() {
35
+ if (existsSync(join(process.cwd(), "quick_brick", "patch_rn.js"))) {
36
+ exec(`node ${process.cwd()}/quick_brick/patch_rn.js`);
37
+ } else if (
38
+ existsSync(join(process.cwd(), "development-app", "patch_rn.js"))
76
39
  ) {
77
- logger.log(
78
- "patch-package command failed, falling back to legacy patch_rn.js files"
79
- );
80
-
81
- // Legacy patching method using patch:rn and patch_rn.js files
82
- if (hasQuickBrickAppWorkspace(quickBrickProjectPath)) {
83
- const { code } = exec(
84
- `cd "${quickBrickProjectPath}" && yarn workspace quick-brick-app patch:rn`
85
- );
86
-
87
- if (code === 0) {
88
- return;
89
- }
90
-
91
- logger.log(
92
- "patch:rn command failed or is unavailable, falling back to legacy patch_rn.js files"
93
- );
94
- } else {
95
- logger.log(
96
- "Skipping yarn workspace quick-brick-app patch:rn; quick-brick-app workspace not found."
97
- );
98
- }
99
-
100
- const patchPaths = [
101
- join(quickBrickProjectPath, "quick_brick", "patch_rn.js"),
102
- join(quickBrickProjectPath, "development-app", "patch_rn.js"),
40
+ exec(`node ${process.cwd()}/development-app/patch_rn.js`);
41
+ } else if (
42
+ existsSync(
103
43
  join(
104
- quickBrickProjectPath,
44
+ process.cwd(),
105
45
  "packages",
106
46
  "zapp-react-dom-development-app",
107
47
  "patch_rn.js"
108
- ),
109
- ];
110
-
111
- let status = false;
112
-
113
- for (const patchRNPath of patchPaths) {
114
- if (existsSync(patchRNPath) && exec(`node ${patchRNPath}`).code === 0) {
115
- status = true;
116
- break;
117
- }
118
- }
48
+ )
49
+ )
50
+ ) {
51
+ const pathToFile = join(
52
+ process.cwd(),
53
+ "packages",
54
+ "zapp-react-dom-development-app",
55
+ "patch_rn.js"
56
+ );
119
57
 
120
- if (!status) {
121
- logger.log("no patch_rn.js file found, skipping patching");
122
- }
58
+ exec(`node ${pathToFile}`);
123
59
  } else {
124
- logger.log("patch-package applied successfully");
60
+ logger.log("Cannot patch packages, can't find the patch_rn.js file");
125
61
  }
126
62
  }
127
63
 
@@ -146,6 +82,10 @@ const toDayJSLocaleMap = (code) => {
146
82
  tt: null,
147
83
  "es-LA": "es",
148
84
  "en-UK": "en-gb",
85
+ "en-ZA": null,
86
+ "en-NG": null,
87
+ "en-ZW": null,
88
+ "en-ZM": null,
149
89
  };
150
90
 
151
91
  if (map[code] === null) {
@@ -276,7 +216,7 @@ async function appBootstrapper(configuration) {
276
216
  const quickBrickVersion = packageJSON.version;
277
217
  checkAllPluginsSatisfiesQuickBrickVersion({ quickBrickVersion, plugins });
278
218
 
279
- await patchPackages(quickBrickProjectPath);
219
+ await patchPackages();
280
220
 
281
221
  if (buildMobile) {
282
222
  await buildMobileApp(configuration);
@@ -13,19 +13,6 @@ exports[`copyFiles when destination path has no package.json doesn't skips the c
13
13
  ]
14
14
  `;
15
15
 
16
- exports[`copyFiles when there is no package.json to copy copies the dir 1`] = `
17
- [
18
- [
19
- "some/source/path/files/file1.txt",
20
- "some/destination/Path/files/file1.txt",
21
- ],
22
- [
23
- "some/source/path/files/file2.txt",
24
- "some/destination/Path/files/file2.txt",
25
- ],
26
- ]
27
- `;
28
-
29
16
  exports[`copyFiles when there is no package.json to copy copies the files 1`] = `
30
17
  [
31
18
  [
@@ -39,7 +39,6 @@ describe("copyFiles", () => {
39
39
  fs.writeFile("bar.json", { bar: "baz" }, jest.fn());
40
40
  fs.writeFile("qux.json", { qux: 42 }, jest.fn());
41
41
  fs.copyFileSync.mockClear();
42
- fs.readdir.mockClear();
43
42
  });
44
43
 
45
44
  describe("when there is no package.json to copy", () => {
@@ -48,21 +47,6 @@ describe("copyFiles", () => {
48
47
  expect(fs.copyFileSync).toHaveBeenCalledTimes(2);
49
48
  expect(fs.copyFileSync.mock.calls).toMatchSnapshot();
50
49
  });
51
-
52
- it("copies the dir", async () => {
53
- // Mock fs.readdir to return some files when the directory is read
54
- fs.readdir.mockImplementationOnce((path, callback) => {
55
- callback(null, ["file1.txt", "file2.txt"]);
56
- });
57
-
58
- const results = copyFiles(sourcePath, ["files/"], destinationPath);
59
-
60
- // Wait for the promise to resolve (the directory copy operation)
61
- await Promise.all(results);
62
-
63
- expect(fs.copyFileSync).toHaveBeenCalledTimes(2);
64
- expect(fs.copyFileSync.mock.calls).toMatchSnapshot();
65
- });
66
50
  });
67
51
 
68
52
  describe("when destination path has package.json", () => {
package/src/file/index.js CHANGED
@@ -5,17 +5,7 @@ const R = require("ramda");
5
5
  * @module @applicaster/zapplicaster-cli/util/file
6
6
  */
7
7
 
8
- const {
9
- writeFile,
10
- readFile,
11
- readdir,
12
- copyFile,
13
- copyFileSync,
14
- lstatSync,
15
- mkdirSync,
16
- existsSync,
17
- } = require("fs");
18
-
8
+ const { writeFile, readFile, readdir, copyFile, copyFileSync } = require("fs");
19
9
  const { promisify } = require("util");
20
10
  const { join } = require("path");
21
11
 
@@ -82,20 +72,14 @@ function copyFiles(source, filesOrFilesGetter, destination, config) {
82
72
  ? filesOrFilesGetter(config)
83
73
  : filesOrFilesGetter;
84
74
 
85
- return R.map((file) => {
86
- const sourcePath = join(source, file);
87
- const destinationPath = destinationFileNameMapper(join(destination, file));
88
-
89
- if (lstatSync(sourcePath).isDirectory()) {
90
- if (!existsSync(destinationPath)) {
91
- mkdirSync(destinationPath, { recursive: true });
92
- }
93
-
94
- return copyFolder(sourcePath, destinationPath);
95
- }
96
-
97
- return copyFileSync(sourcePath, destinationPath);
98
- }, files);
75
+ return R.map(
76
+ (file) =>
77
+ copyFileSync(
78
+ join(source, file),
79
+ destinationFileNameMapper(join(destination, file))
80
+ ),
81
+ files
82
+ );
99
83
  }
100
84
 
101
85
  module.exports = {
@@ -2,18 +2,10 @@ const fs = jest.genMockFromModule("fs");
2
2
  const _fs = jest.requireActual("fs");
3
3
  const R = require("ramda");
4
4
 
5
- function mkdirSync() {
6
- return {};
7
- }
8
-
9
5
  function readdirSync(folder) {
10
6
  return _fs.readdirSync(folder);
11
7
  }
12
8
 
13
- async function readdirAsync(folder) {
14
- return Promise.resolve(_fs.readdirSync(folder));
15
- }
16
-
17
9
  function readdir(folder, callback) {
18
10
  const files = R.map(R.prop("fileName"), fs.__writenFiles);
19
11
 
@@ -85,17 +77,10 @@ function __resetFiles() {
85
77
  fs.__writenFiles = [];
86
78
  }
87
79
 
88
- fs.lstatSync = (_path) => ({
89
- isDirectory: () => _path.endsWith("/"),
90
- isFile: () => _path.endsWith("/") === false,
91
- });
92
-
93
80
  fs.__writenFiles = [];
94
81
  fs.__resetFiles = __resetFiles;
95
82
  fs.__addMockedFiles = __addMockedFiles;
96
83
  fs.readdirSync = readdirSync;
97
- fs.readdirAsync = readdirAsync;
98
- fs.mkdirSync = mkdirSync;
99
84
  fs.readdir = jest.fn(readdir);
100
85
  fs.writeFile = jest.fn(writeFile);
101
86
  fs.readFile = jest.fn(readFile);