@applicaster/zapplicaster-cli 16.0.0-alpha.5063542327 → 16.0.0-alpha.5222020837
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": "16.0.0-alpha.
|
|
3
|
+
"version": "16.0.0-alpha.5222020837",
|
|
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": "16.0.0-alpha.
|
|
32
|
-
"@applicaster/zapp-react-native-android-tv-cli-template": "16.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-react-native-cli-template": "16.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-tvos-cli-template": "16.0.0-alpha.
|
|
31
|
+
"@applicaster/zapp-react-dom-cli-template": "16.0.0-alpha.5222020837",
|
|
32
|
+
"@applicaster/zapp-react-native-android-tv-cli-template": "16.0.0-alpha.5222020837",
|
|
33
|
+
"@applicaster/zapp-react-native-cli-template": "16.0.0-alpha.5222020837",
|
|
34
|
+
"@applicaster/zapp-react-native-tvos-cli-template": "16.0.0-alpha.5222020837",
|
|
35
35
|
"axios": "^0.28.0",
|
|
36
36
|
"camelize": "^1.0.0",
|
|
37
37
|
"chalk": "^2.3.2",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const R = require("ramda");
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const semver = require("semver");
|
|
4
|
-
const { resolve
|
|
5
|
-
const { existsSync } = require("fs");
|
|
4
|
+
const { resolve } = require("path");
|
|
6
5
|
const packageJSON = require("../../../package.json");
|
|
7
6
|
|
|
8
7
|
const {
|
|
@@ -31,36 +30,6 @@ const {
|
|
|
31
30
|
|
|
32
31
|
const { buildMobileApp } = require("./buildMobile");
|
|
33
32
|
|
|
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"))
|
|
39
|
-
) {
|
|
40
|
-
exec(`node ${process.cwd()}/development-app/patch_rn.js`);
|
|
41
|
-
} else if (
|
|
42
|
-
existsSync(
|
|
43
|
-
join(
|
|
44
|
-
process.cwd(),
|
|
45
|
-
"packages",
|
|
46
|
-
"zapp-react-dom-development-app",
|
|
47
|
-
"patch_rn.js"
|
|
48
|
-
)
|
|
49
|
-
)
|
|
50
|
-
) {
|
|
51
|
-
const pathToFile = join(
|
|
52
|
-
process.cwd(),
|
|
53
|
-
"packages",
|
|
54
|
-
"zapp-react-dom-development-app",
|
|
55
|
-
"patch_rn.js"
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
exec(`node ${pathToFile}`);
|
|
59
|
-
} else {
|
|
60
|
-
logger.log("Cannot patch packages, can't find the patch_rn.js file");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
33
|
/**
|
|
65
34
|
* fallback to en for missing dayjslocalization
|
|
66
35
|
* converts the locale code to a dayjs compatible locale code
|
|
@@ -132,7 +101,12 @@ async function appBootstrapper(configuration) {
|
|
|
132
101
|
|
|
133
102
|
const { templatePath, filesToCopy } = template.files;
|
|
134
103
|
|
|
135
|
-
copyFiles(
|
|
104
|
+
await copyFiles(
|
|
105
|
+
templatePath,
|
|
106
|
+
filesToCopy,
|
|
107
|
+
quickBrickProjectPath,
|
|
108
|
+
configuration
|
|
109
|
+
);
|
|
136
110
|
|
|
137
111
|
logger.log("injecting dependencies...");
|
|
138
112
|
const { dependencies, scripts } = template;
|
|
@@ -216,8 +190,6 @@ async function appBootstrapper(configuration) {
|
|
|
216
190
|
const quickBrickVersion = packageJSON.version;
|
|
217
191
|
checkAllPluginsSatisfiesQuickBrickVersion({ quickBrickVersion, plugins });
|
|
218
192
|
|
|
219
|
-
await patchPackages();
|
|
220
|
-
|
|
221
193
|
if (buildMobile) {
|
|
222
194
|
await buildMobileApp(configuration);
|
|
223
195
|
}
|
|
@@ -5,10 +5,27 @@ exports[`copyFiles when destination path has no package.json doesn't skips the c
|
|
|
5
5
|
[
|
|
6
6
|
"some/source/path/foo.json",
|
|
7
7
|
"some/destination/Path/foo.json",
|
|
8
|
+
[Function],
|
|
8
9
|
],
|
|
9
10
|
[
|
|
10
11
|
"some/source/path/package.json",
|
|
11
12
|
"some/destination/Path/package.json",
|
|
13
|
+
[Function],
|
|
14
|
+
],
|
|
15
|
+
]
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
exports[`copyFiles when there is no package.json to copy copies the dir 1`] = `
|
|
19
|
+
[
|
|
20
|
+
[
|
|
21
|
+
"some/source/path/files/file1.txt",
|
|
22
|
+
"some/destination/Path/files/file1.txt",
|
|
23
|
+
[Function],
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
"some/source/path/files/file2.txt",
|
|
27
|
+
"some/destination/Path/files/file2.txt",
|
|
28
|
+
[Function],
|
|
12
29
|
],
|
|
13
30
|
]
|
|
14
31
|
`;
|
|
@@ -18,10 +35,12 @@ exports[`copyFiles when there is no package.json to copy copies the files 1`] =
|
|
|
18
35
|
[
|
|
19
36
|
"some/source/path/foo.json",
|
|
20
37
|
"some/destination/Path/foo.json",
|
|
38
|
+
[Function],
|
|
21
39
|
],
|
|
22
40
|
[
|
|
23
41
|
"some/source/path/bar.json",
|
|
24
42
|
"some/destination/Path/bar.json",
|
|
43
|
+
[Function],
|
|
25
44
|
],
|
|
26
45
|
]
|
|
27
46
|
`;
|
|
@@ -38,14 +38,27 @@ describe("copyFiles", () => {
|
|
|
38
38
|
fs.writeFile("foo.json", { foo: "bar" }, jest.fn());
|
|
39
39
|
fs.writeFile("bar.json", { bar: "baz" }, jest.fn());
|
|
40
40
|
fs.writeFile("qux.json", { qux: 42 }, jest.fn());
|
|
41
|
-
fs.
|
|
41
|
+
fs.copyFile.mockClear();
|
|
42
|
+
fs.readdir.mockClear();
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
describe("when there is no package.json to copy", () => {
|
|
45
|
-
it("copies the files", () => {
|
|
46
|
-
copyFiles(sourcePath, ["foo.json", "bar.json"], destinationPath);
|
|
47
|
-
expect(fs.
|
|
48
|
-
expect(fs.
|
|
46
|
+
it("copies the files", async () => {
|
|
47
|
+
await copyFiles(sourcePath, ["foo.json", "bar.json"], destinationPath);
|
|
48
|
+
expect(fs.copyFile).toHaveBeenCalledTimes(2);
|
|
49
|
+
expect(fs.copyFile.mock.calls).toMatchSnapshot();
|
|
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
|
+
await copyFiles(sourcePath, ["files/"], destinationPath);
|
|
59
|
+
|
|
60
|
+
expect(fs.copyFile).toHaveBeenCalledTimes(2);
|
|
61
|
+
expect(fs.copyFile.mock.calls).toMatchSnapshot();
|
|
49
62
|
});
|
|
50
63
|
});
|
|
51
64
|
|
|
@@ -60,29 +73,40 @@ describe("copyFiles", () => {
|
|
|
60
73
|
fs.__resetFiles();
|
|
61
74
|
});
|
|
62
75
|
|
|
63
|
-
it("overrides it", () => {
|
|
76
|
+
it("overrides it", async () => {
|
|
64
77
|
const sourcePath = "some/source/path";
|
|
65
78
|
const destinationPath = "some/destination/Path";
|
|
66
79
|
|
|
67
|
-
copyFiles(
|
|
68
|
-
|
|
80
|
+
await copyFiles(
|
|
81
|
+
sourcePath,
|
|
82
|
+
["foo.json", "package.json"],
|
|
83
|
+
destinationPath
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(fs.copyFile).toHaveBeenCalledTimes(2);
|
|
69
87
|
|
|
70
|
-
expect(fs.
|
|
88
|
+
expect(fs.copyFile).toHaveBeenCalledWith(
|
|
71
89
|
`${sourcePath}/foo.json`,
|
|
72
|
-
`${destinationPath}/foo.json
|
|
90
|
+
`${destinationPath}/foo.json`,
|
|
91
|
+
expect.any(Function)
|
|
73
92
|
);
|
|
74
93
|
});
|
|
75
94
|
});
|
|
76
95
|
|
|
77
96
|
describe("when destination path has no package.json", () => {
|
|
78
|
-
it("doesn't skips the copy", () => {
|
|
97
|
+
it("doesn't skips the copy", async () => {
|
|
79
98
|
const sourcePath = "some/source/path";
|
|
80
99
|
const destinationPath = "some/destination/Path";
|
|
81
100
|
|
|
82
|
-
copyFiles(
|
|
83
|
-
|
|
101
|
+
await copyFiles(
|
|
102
|
+
sourcePath,
|
|
103
|
+
["foo.json", "package.json"],
|
|
104
|
+
destinationPath
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
expect(fs.copyFile).toHaveBeenCalledTimes(2);
|
|
84
108
|
|
|
85
|
-
expect(fs.
|
|
109
|
+
expect(fs.copyFile.mock.calls).toMatchSnapshot();
|
|
86
110
|
expect(logger.warn).not.toHaveBeenCalled();
|
|
87
111
|
});
|
|
88
112
|
});
|
|
@@ -100,7 +124,7 @@ describe("copyFolder", () => {
|
|
|
100
124
|
});
|
|
101
125
|
|
|
102
126
|
beforeEach(() => {
|
|
103
|
-
fs.
|
|
127
|
+
fs.copyFile.mockClear();
|
|
104
128
|
});
|
|
105
129
|
|
|
106
130
|
it("copies the file in the folder", async () => {
|
|
@@ -110,7 +134,7 @@ describe("copyFolder", () => {
|
|
|
110
134
|
await copyFolder(sourcePath, destinationPath);
|
|
111
135
|
|
|
112
136
|
expect(fs.readdir).toHaveBeenCalledWith(sourcePath, expect.any(Function));
|
|
113
|
-
expect(fs.
|
|
137
|
+
expect(fs.copyFile).toHaveBeenCalledTimes(2);
|
|
114
138
|
});
|
|
115
139
|
|
|
116
140
|
afterAll(() => {
|
package/src/file/index.js
CHANGED
|
@@ -5,7 +5,16 @@ 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
|
+
lstatSync,
|
|
14
|
+
mkdirSync,
|
|
15
|
+
existsSync,
|
|
16
|
+
} = require("fs");
|
|
17
|
+
|
|
9
18
|
const { promisify } = require("util");
|
|
10
19
|
const { join } = require("path");
|
|
11
20
|
|
|
@@ -66,19 +75,43 @@ function destinationFileNameMapper(destinationFileName) {
|
|
|
66
75
|
* @param {String} destination path
|
|
67
76
|
* @returns {Promise[]} array of promises with the status of the copied files
|
|
68
77
|
*/
|
|
69
|
-
function copyFiles(source, filesOrFilesGetter, destination, config) {
|
|
78
|
+
async function copyFiles(source, filesOrFilesGetter, destination, config) {
|
|
70
79
|
const files =
|
|
71
80
|
typeof filesOrFilesGetter === "function"
|
|
72
81
|
? filesOrFilesGetter(config)
|
|
73
82
|
: filesOrFilesGetter;
|
|
74
83
|
|
|
75
|
-
return
|
|
76
|
-
(file) =>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
return Promise.all(
|
|
85
|
+
R.map(async (file) => {
|
|
86
|
+
let sourcePath, destinationPath;
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
if (Array.isArray(file)) {
|
|
90
|
+
sourcePath = join(source, file[0]);
|
|
91
|
+
|
|
92
|
+
destinationPath = destinationFileNameMapper(
|
|
93
|
+
join(destination, file[1])
|
|
94
|
+
);
|
|
95
|
+
} else {
|
|
96
|
+
sourcePath = join(source, file);
|
|
97
|
+
destinationPath = destinationFileNameMapper(join(destination, file));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (lstatSync(sourcePath).isDirectory()) {
|
|
101
|
+
if (!existsSync(destinationPath)) {
|
|
102
|
+
mkdirSync(destinationPath, { recursive: true });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return await copyFolder(sourcePath, destinationPath);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return await copyFileAsync(sourcePath, destinationPath);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
`Failed to copy "${sourcePath}" to "${destinationPath}": ${error.message}`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}, files)
|
|
82
115
|
);
|
|
83
116
|
}
|
|
84
117
|
|
package/test_helpers/fsMock.js
CHANGED
|
@@ -2,6 +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 undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
function readdirSync(folder) {
|
|
6
10
|
return _fs.readdirSync(folder);
|
|
7
11
|
}
|
|
@@ -77,10 +81,16 @@ function __resetFiles() {
|
|
|
77
81
|
fs.__writenFiles = [];
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
fs.lstatSync = (_path) => ({
|
|
85
|
+
isDirectory: () => _path.endsWith("/"),
|
|
86
|
+
isFile: () => _path.endsWith("/") === false,
|
|
87
|
+
});
|
|
88
|
+
|
|
80
89
|
fs.__writenFiles = [];
|
|
81
90
|
fs.__resetFiles = __resetFiles;
|
|
82
91
|
fs.__addMockedFiles = __addMockedFiles;
|
|
83
92
|
fs.readdirSync = readdirSync;
|
|
93
|
+
fs.mkdirSync = mkdirSync;
|
|
84
94
|
fs.readdir = jest.fn(readdir);
|
|
85
95
|
fs.writeFile = jest.fn(writeFile);
|
|
86
96
|
fs.readFile = jest.fn(readFile);
|