@applicaster/zapplicaster-cli 15.1.0-rc.1 → 16.0.0-alpha.9803580571
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 +5 -5
- package/src/commands/index.js +1 -1
- package/src/commands/prepareWorkspace/appBootstrapper.js +1 -34
- package/src/commands/publishPlugin/__tests__/generateManifest.test.js +14 -5
- package/src/commands/publishPlugin/generateManifest.js +20 -2
- package/src/file/__tests__/__snapshots__/file.test.js.snap +13 -0
- package/src/file/__tests__/file.test.js +16 -0
- package/src/file/index.js +32 -9
- package/test_helpers/fsMock.js +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapplicaster-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0-alpha.9803580571",
|
|
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": "
|
|
32
|
-
"@applicaster/zapp-react-native-android-tv-cli-template": "
|
|
33
|
-
"@applicaster/zapp-react-native-cli-template": "
|
|
34
|
-
"@applicaster/zapp-react-native-tvos-cli-template": "
|
|
31
|
+
"@applicaster/zapp-react-dom-cli-template": "16.0.0-alpha.9803580571",
|
|
32
|
+
"@applicaster/zapp-react-native-android-tv-cli-template": "16.0.0-alpha.9803580571",
|
|
33
|
+
"@applicaster/zapp-react-native-cli-template": "16.0.0-alpha.9803580571",
|
|
34
|
+
"@applicaster/zapp-react-native-tvos-cli-template": "16.0.0-alpha.9803580571",
|
|
35
35
|
"axios": "^0.28.0",
|
|
36
36
|
"camelize": "^1.0.0",
|
|
37
37
|
"chalk": "^2.3.2",
|
package/src/commands/index.js
CHANGED
|
@@ -117,7 +117,7 @@ const commands = [
|
|
|
117
117
|
["-g, --skip-git", "Doesn't commit changes to git"],
|
|
118
118
|
[
|
|
119
119
|
"-s, --single-platform [singlePlatform]",
|
|
120
|
-
"Platform to deploy.
|
|
120
|
+
"Platform to deploy. Omit to publish for all supported platforms",
|
|
121
121
|
],
|
|
122
122
|
[
|
|
123
123
|
"-m, --manifest-only",
|
|
@@ -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
|
|
@@ -216,8 +185,6 @@ async function appBootstrapper(configuration) {
|
|
|
216
185
|
const quickBrickVersion = packageJSON.version;
|
|
217
186
|
checkAllPluginsSatisfiesQuickBrickVersion({ quickBrickVersion, plugins });
|
|
218
187
|
|
|
219
|
-
await patchPackages();
|
|
220
|
-
|
|
221
188
|
if (buildMobile) {
|
|
222
189
|
await buildMobileApp(configuration);
|
|
223
190
|
}
|
|
@@ -42,9 +42,19 @@ function clearMocks() {
|
|
|
42
42
|
describe("generate manifest", () => {
|
|
43
43
|
beforeEach(clearMocks);
|
|
44
44
|
|
|
45
|
-
it("
|
|
45
|
+
it("throws if an invalid platform is provided", async () => {
|
|
46
|
+
const configuration = getConfig({
|
|
47
|
+
platforms: ["android", "invalid_platform"],
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await expect(generateManifest(configuration)).rejects.toThrow(
|
|
51
|
+
/Invalid platform provided/
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("doesn't create the manifest if there is no platform", async () => {
|
|
46
56
|
const configuration = getConfig({ platforms: undefined });
|
|
47
|
-
expect(generateManifest(configuration)).resolves.toBe(true);
|
|
57
|
+
await expect(generateManifest(configuration)).resolves.toBe(true);
|
|
48
58
|
expect(writeJsonToFile).not.toHaveBeenCalled();
|
|
49
59
|
});
|
|
50
60
|
|
|
@@ -91,12 +101,11 @@ describe("generate manifest", () => {
|
|
|
91
101
|
|
|
92
102
|
it("throws if the config file cannot be found", async () => {
|
|
93
103
|
const configuration = getConfig({ pluginPath: "resolve_error" });
|
|
94
|
-
|
|
95
|
-
expect(generateManifest(configuration)).rejects.toMatchSnapshot();
|
|
104
|
+
await expect(generateManifest(configuration)).rejects.toMatchSnapshot();
|
|
96
105
|
});
|
|
97
106
|
|
|
98
107
|
it("throws if the manifests cannot be written", async () => {
|
|
99
108
|
const configuration = getConfig({ pluginPath: "write_error" });
|
|
100
|
-
expect(generateManifest(configuration)).rejects.toMatchSnapshot();
|
|
109
|
+
await expect(generateManifest(configuration)).rejects.toMatchSnapshot();
|
|
101
110
|
});
|
|
102
111
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const R = require("ramda");
|
|
2
1
|
const { resolve } = require("path");
|
|
3
2
|
const { inspect } = require("util");
|
|
4
3
|
|
|
@@ -48,6 +47,19 @@ function renderManifest({
|
|
|
48
47
|
};
|
|
49
48
|
}
|
|
50
49
|
|
|
50
|
+
const validPlatforms = [
|
|
51
|
+
"lg_tv",
|
|
52
|
+
"samsung_tv",
|
|
53
|
+
"vizio",
|
|
54
|
+
"android_tv_for_quickbrick",
|
|
55
|
+
"amazon_fire_tv_for_quickbrick",
|
|
56
|
+
"tvos_for_quickbrick",
|
|
57
|
+
"android_for_quickbrick",
|
|
58
|
+
"ios_for_quickbrick",
|
|
59
|
+
"ios",
|
|
60
|
+
"android",
|
|
61
|
+
];
|
|
62
|
+
|
|
51
63
|
async function generateManifest(configuration) {
|
|
52
64
|
const { pluginPath, platforms, version, dryRun } = configuration;
|
|
53
65
|
|
|
@@ -57,6 +69,12 @@ async function generateManifest(configuration) {
|
|
|
57
69
|
return true;
|
|
58
70
|
}
|
|
59
71
|
|
|
72
|
+
if (!platforms.every((platform) => validPlatforms.includes(platform))) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`Invalid platform provided. Valid platforms are: ${validPlatforms.join(", ")}`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
60
78
|
try {
|
|
61
79
|
const manifestConfig = require(
|
|
62
80
|
resolve(pluginPath, "manifests/manifest.config.js")
|
|
@@ -72,7 +90,7 @@ async function generateManifest(configuration) {
|
|
|
72
90
|
dryRun,
|
|
73
91
|
});
|
|
74
92
|
|
|
75
|
-
return Promise.all(
|
|
93
|
+
return Promise.all(platforms.map(manifestRenderer));
|
|
76
94
|
} catch (e) {
|
|
77
95
|
throw new Error(
|
|
78
96
|
"An error occured when generating the manifest: " + e.message
|
|
@@ -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,27 @@ function copyFiles(source, filesOrFilesGetter, destination, config) {
|
|
|
72
82
|
? filesOrFilesGetter(config)
|
|
73
83
|
: filesOrFilesGetter;
|
|
74
84
|
|
|
75
|
-
return R.map(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
return R.map((file) => {
|
|
86
|
+
let sourcePath, destinationPath;
|
|
87
|
+
|
|
88
|
+
if (Array.isArray(file)) {
|
|
89
|
+
sourcePath = join(source, file[0]);
|
|
90
|
+
destinationPath = destinationFileNameMapper(join(destination, file[1]));
|
|
91
|
+
} else {
|
|
92
|
+
sourcePath = join(source, file);
|
|
93
|
+
destinationPath = destinationFileNameMapper(join(destination, file));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (lstatSync(sourcePath).isDirectory()) {
|
|
97
|
+
if (!existsSync(destinationPath)) {
|
|
98
|
+
mkdirSync(destinationPath, { recursive: true });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return copyFolder(sourcePath, destinationPath);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return copyFileSync(sourcePath, destinationPath);
|
|
105
|
+
}, files);
|
|
83
106
|
}
|
|
84
107
|
|
|
85
108
|
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);
|