@applicaster/zapplicaster-cli 15.0.0-alpha.1228610025 → 15.0.0-alpha.1232030550
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.
|
|
3
|
+
"version": "15.0.0-alpha.1232030550",
|
|
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.
|
|
32
|
-
"@applicaster/zapp-react-native-android-tv-cli-template": "15.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-react-native-cli-template": "15.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-tvos-cli-template": "15.0.0-alpha.
|
|
31
|
+
"@applicaster/zapp-react-dom-cli-template": "15.0.0-alpha.1232030550",
|
|
32
|
+
"@applicaster/zapp-react-native-android-tv-cli-template": "15.0.0-alpha.1232030550",
|
|
33
|
+
"@applicaster/zapp-react-native-cli-template": "15.0.0-alpha.1232030550",
|
|
34
|
+
"@applicaster/zapp-react-native-tvos-cli-template": "15.0.0-alpha.1232030550",
|
|
35
35
|
"axios": "^0.28.0",
|
|
36
36
|
"camelize": "^1.0.0",
|
|
37
37
|
"chalk": "^2.3.2",
|
|
@@ -31,17 +31,67 @@ const {
|
|
|
31
31
|
|
|
32
32
|
const { buildMobileApp } = require("./buildMobile");
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
function hasQuickBrickAppWorkspace(quickBrickProjectPath) {
|
|
35
|
+
const packageJsonPath = join(quickBrickProjectPath, "package.json");
|
|
36
|
+
|
|
37
|
+
if (!existsSync(packageJsonPath)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const { workspaces } = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
43
|
+
|
|
44
|
+
const hasWorkspacesConfigured = Boolean(workspaces);
|
|
45
|
+
|
|
46
|
+
const hasQuickBrickAppInstalled = existsSync(
|
|
47
|
+
join(quickBrickProjectPath, "node_modules", "quick-brick-app")
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return hasWorkspacesConfigured && hasQuickBrickAppInstalled;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
logger.warn(
|
|
53
|
+
"Skipping yarn workspace quick-brick-app patch:rn; unable to read workspace configuration."
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function patchPackages(quickBrickProjectPath = process.cwd()) {
|
|
61
|
+
if (hasQuickBrickAppWorkspace(quickBrickProjectPath)) {
|
|
62
|
+
logger.log(
|
|
63
|
+
"Applying patch-package patches via yarn workspace quick-brick-app patch:rn"
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const { code } = exec(
|
|
67
|
+
`cd "${quickBrickProjectPath}" && yarn workspace quick-brick-app patch:rn`
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
if (code === 0) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
logger.log(
|
|
75
|
+
"patch:rn command failed or is unavailable, falling back to legacy patch_rn.js files"
|
|
76
|
+
);
|
|
77
|
+
} else {
|
|
78
|
+
logger.log(
|
|
79
|
+
"Skipping yarn workspace quick-brick-app patch:rn; quick-brick-app workspace not found."
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (existsSync(join(quickBrickProjectPath, "quick_brick", "patch_rn.js"))) {
|
|
84
|
+
exec(`node ${join(quickBrickProjectPath, "quick_brick", "patch_rn.js")}`);
|
|
37
85
|
} else if (
|
|
38
|
-
existsSync(join(
|
|
86
|
+
existsSync(join(quickBrickProjectPath, "development-app", "patch_rn.js"))
|
|
39
87
|
) {
|
|
40
|
-
exec(
|
|
88
|
+
exec(
|
|
89
|
+
`node ${join(quickBrickProjectPath, "development-app", "patch_rn.js")}`
|
|
90
|
+
);
|
|
41
91
|
} else if (
|
|
42
92
|
existsSync(
|
|
43
93
|
join(
|
|
44
|
-
|
|
94
|
+
quickBrickProjectPath,
|
|
45
95
|
"packages",
|
|
46
96
|
"zapp-react-dom-development-app",
|
|
47
97
|
"patch_rn.js"
|
|
@@ -49,7 +99,7 @@ async function patchPackages() {
|
|
|
49
99
|
)
|
|
50
100
|
) {
|
|
51
101
|
const pathToFile = join(
|
|
52
|
-
|
|
102
|
+
quickBrickProjectPath,
|
|
53
103
|
"packages",
|
|
54
104
|
"zapp-react-dom-development-app",
|
|
55
105
|
"patch_rn.js"
|
|
@@ -57,7 +107,7 @@ async function patchPackages() {
|
|
|
57
107
|
|
|
58
108
|
exec(`node ${pathToFile}`);
|
|
59
109
|
} else {
|
|
60
|
-
logger.log("Cannot patch packages, can't find
|
|
110
|
+
logger.log("Cannot patch packages, can't find any legacy patch_rn.js file");
|
|
61
111
|
}
|
|
62
112
|
}
|
|
63
113
|
|
|
@@ -212,7 +262,7 @@ async function appBootstrapper(configuration) {
|
|
|
212
262
|
const quickBrickVersion = packageJSON.version;
|
|
213
263
|
checkAllPluginsSatisfiesQuickBrickVersion({ quickBrickVersion, plugins });
|
|
214
264
|
|
|
215
|
-
await patchPackages();
|
|
265
|
+
await patchPackages(quickBrickProjectPath);
|
|
216
266
|
|
|
217
267
|
if (buildMobile) {
|
|
218
268
|
await buildMobileApp(configuration);
|
|
@@ -13,6 +13,19 @@ 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
|
+
|
|
16
29
|
exports[`copyFiles when there is no package.json to copy copies the files 1`] = `
|
|
17
30
|
[
|
|
18
31
|
[
|
|
@@ -39,6 +39,7 @@ 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();
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
describe("when there is no package.json to copy", () => {
|
|
@@ -47,6 +48,21 @@ describe("copyFiles", () => {
|
|
|
47
48
|
expect(fs.copyFileSync).toHaveBeenCalledTimes(2);
|
|
48
49
|
expect(fs.copyFileSync.mock.calls).toMatchSnapshot();
|
|
49
50
|
});
|
|
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
|
+
});
|
|
50
66
|
});
|
|
51
67
|
|
|
52
68
|
describe("when destination path has package.json", () => {
|
package/src/file/index.js
CHANGED
|
@@ -5,7 +5,17 @@ const R = require("ramda");
|
|
|
5
5
|
* @module @applicaster/zapplicaster-cli/util/file
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
const {
|
|
8
|
+
const {
|
|
9
|
+
writeFile,
|
|
10
|
+
readFile,
|
|
11
|
+
readdir,
|
|
12
|
+
copyFile,
|
|
13
|
+
copyFileSync,
|
|
14
|
+
lstatSync,
|
|
15
|
+
mkdirSync,
|
|
16
|
+
existsSync,
|
|
17
|
+
} = require("fs");
|
|
18
|
+
|
|
9
19
|
const { promisify } = require("util");
|
|
10
20
|
const { join } = require("path");
|
|
11
21
|
|
|
@@ -72,14 +82,20 @@ function copyFiles(source, filesOrFilesGetter, destination, config) {
|
|
|
72
82
|
? filesOrFilesGetter(config)
|
|
73
83
|
: filesOrFilesGetter;
|
|
74
84
|
|
|
75
|
-
return R.map(
|
|
76
|
-
(file)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
|
|
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);
|
|
83
99
|
}
|
|
84
100
|
|
|
85
101
|
module.exports = {
|
package/test_helpers/fsMock.js
CHANGED
|
@@ -2,10 +2,18 @@ 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
|
+
|
|
5
9
|
function readdirSync(folder) {
|
|
6
10
|
return _fs.readdirSync(folder);
|
|
7
11
|
}
|
|
8
12
|
|
|
13
|
+
async function readdirAsync(folder) {
|
|
14
|
+
return Promise.resolve(_fs.readdirSync(folder));
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
function readdir(folder, callback) {
|
|
10
18
|
const files = R.map(R.prop("fileName"), fs.__writenFiles);
|
|
11
19
|
|
|
@@ -77,10 +85,17 @@ function __resetFiles() {
|
|
|
77
85
|
fs.__writenFiles = [];
|
|
78
86
|
}
|
|
79
87
|
|
|
88
|
+
fs.lstatSync = (_path) => ({
|
|
89
|
+
isDirectory: () => _path.endsWith("/"),
|
|
90
|
+
isFile: () => _path.endsWith("/") === false,
|
|
91
|
+
});
|
|
92
|
+
|
|
80
93
|
fs.__writenFiles = [];
|
|
81
94
|
fs.__resetFiles = __resetFiles;
|
|
82
95
|
fs.__addMockedFiles = __addMockedFiles;
|
|
83
96
|
fs.readdirSync = readdirSync;
|
|
97
|
+
fs.readdirAsync = readdirAsync;
|
|
98
|
+
fs.mkdirSync = mkdirSync;
|
|
84
99
|
fs.readdir = jest.fn(readdir);
|
|
85
100
|
fs.writeFile = jest.fn(writeFile);
|
|
86
101
|
fs.readFile = jest.fn(readFile);
|