@24i/smartapps-bigscreen-rnv-build-engine 0.8.7-alpha.1415 → 0.8.7-alpha.1416
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 +1 -2
- package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/sdkInstaller.spec.js +88 -0
- package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/clean.spec.js +46 -0
- package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/download.spec.js +121 -0
- package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/install.spec.js +53 -0
- package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/unzip.spec.js +47 -0
- package/dist/src/sdks/sdk-tizen/index.js +4 -4
- package/dist/src/sdks/sdk-utils/index.js +14 -0
- package/dist/src/sdks/sdk-utils/installSdk.js +10 -0
- package/dist/src/sdks/{sdkUtils.js → sdk-utils/registerSdkPath.js} +1 -8
- package/dist/src/sdks/sdk-utils/sdk-installer/index.js +5 -0
- package/dist/src/sdks/sdk-utils/sdk-installer/sdkInstaller.js +38 -0
- package/dist/src/sdks/sdk-utils/sdk-installer/services/clean.js +11 -0
- package/dist/src/sdks/sdk-utils/sdk-installer/services/download.js +74 -0
- package/dist/src/sdks/sdk-utils/sdk-installer/services/index.js +11 -0
- package/dist/src/sdks/sdk-utils/sdk-installer/services/install.js +23 -0
- package/dist/src/sdks/sdk-utils/sdk-installer/services/unzip.js +12 -0
- package/dist/src/sdks/sdk-webos/index.js +4 -4
- package/jest.config.js +3 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -126,7 +126,7 @@ An example:
|
|
|
126
126
|
---
|
|
127
127
|
## Package content
|
|
128
128
|
|
|
129
|
-
### npm
|
|
129
|
+
### npm dependencies
|
|
130
130
|
All npm dependencies are listed in [package.json](package.json) file.
|
|
131
131
|
|
|
132
132
|
However, not all dependencies are directly bundled into a final npm package,
|
|
@@ -148,7 +148,6 @@ Firstly, the package contains main ReNative npm packages, namely:
|
|
|
148
148
|
Following dependencies are used in source code for custom build engine for ReNative:
|
|
149
149
|
|
|
150
150
|
- `@24i/smartapps-bigscreen-icon` *(generating SVG icons)*
|
|
151
|
-
- `@24i/smartapps-bigscreen-sdk-installer` *(installing SDKs for Tizen or webOS)*
|
|
152
151
|
- `glob` *(searching output builds)*
|
|
153
152
|
- `node-ssh` *(connection to HbbTV server)*
|
|
154
153
|
- `svgo` *(generating SVG icons)*
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sdk_installer_1 = require("../../../../sdks/sdk-utils/sdk-installer");
|
|
4
|
+
const services_1 = require("../../../../sdks/sdk-utils/sdk-installer/services");
|
|
5
|
+
jest.mock('../../../../sdks/sdk-utils/sdk-installer/services/download');
|
|
6
|
+
jest.mock('../../../../sdks/sdk-utils/sdk-installer/services/unzip');
|
|
7
|
+
jest.mock('../../../../sdks/sdk-utils/sdk-installer/services/install');
|
|
8
|
+
jest.mock('../../../../sdks/sdk-utils/sdk-installer/services/clean');
|
|
9
|
+
describe('SDK Installer', () => {
|
|
10
|
+
const URL_TO_DOWNLOAD_FILE_FROM = 'https://s3.amazonaws.com/file.zip';
|
|
11
|
+
const runSdkInstallerWithDefinedZipPath = async () => {
|
|
12
|
+
await sdk_installer_1.sdkInstaller({ zipPath: URL_TO_DOWNLOAD_FILE_FROM });
|
|
13
|
+
};
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
jest.clearAllMocks();
|
|
16
|
+
});
|
|
17
|
+
describe('throwing the errors', () => {
|
|
18
|
+
it('throws an error when zipPath is not a URL', async () => {
|
|
19
|
+
await expect(async () => {
|
|
20
|
+
await sdk_installer_1.sdkInstaller({ zipPath: '/local/path.zip' });
|
|
21
|
+
}).rejects.toBeInstanceOf(Error);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('printing log messages', () => {
|
|
25
|
+
it('does not print log messages by default', async () => {
|
|
26
|
+
const writeSpy = jest.spyOn(process.stdout, 'write');
|
|
27
|
+
await runSdkInstallerWithDefinedZipPath();
|
|
28
|
+
expect(writeSpy).not.toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
it('shows log messages when enabled', async () => {
|
|
31
|
+
const writeSpy = jest.spyOn(process.stdout, 'write');
|
|
32
|
+
writeSpy.mockImplementation(() => true);
|
|
33
|
+
await sdk_installer_1.sdkInstaller({ zipPath: URL_TO_DOWNLOAD_FILE_FROM, enableLogs: true });
|
|
34
|
+
expect(writeSpy).toHaveBeenCalled();
|
|
35
|
+
});
|
|
36
|
+
it('does not print log messages when it is not enabled', async () => {
|
|
37
|
+
const writeSpy = jest.spyOn(process.stdout, 'write');
|
|
38
|
+
await sdk_installer_1.sdkInstaller({ zipPath: URL_TO_DOWNLOAD_FILE_FROM, enableLogs: false });
|
|
39
|
+
expect(writeSpy).not.toHaveBeenCalled();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe('passing values to services when correct URL to ZIP file is provided', () => {
|
|
43
|
+
it('calls downloader with requested url to download file from', async () => {
|
|
44
|
+
await runSdkInstallerWithDefinedZipPath();
|
|
45
|
+
const filePathToSave = `${process.cwd()}/file.zip`;
|
|
46
|
+
expect(services_1.download).toHaveBeenCalledWith(URL_TO_DOWNLOAD_FILE_FROM, filePathToSave);
|
|
47
|
+
});
|
|
48
|
+
it('calls unzipper with requested file path to unzip', async () => {
|
|
49
|
+
await runSdkInstallerWithDefinedZipPath();
|
|
50
|
+
expect(services_1.unzip).toHaveBeenCalledWith(`${process.cwd()}/file.zip`);
|
|
51
|
+
});
|
|
52
|
+
it('calls installer with path to unzipped directory only', async () => {
|
|
53
|
+
await runSdkInstallerWithDefinedZipPath();
|
|
54
|
+
expect(services_1.install).toHaveBeenCalledWith(`${process.cwd()}/file`, undefined);
|
|
55
|
+
});
|
|
56
|
+
it('calls installer with path to unzipped directory and path to install to', async () => {
|
|
57
|
+
await sdk_installer_1.sdkInstaller({
|
|
58
|
+
zipPath: URL_TO_DOWNLOAD_FILE_FROM,
|
|
59
|
+
installPath: '/install/path',
|
|
60
|
+
});
|
|
61
|
+
expect(services_1.install).toHaveBeenCalledWith(`${process.cwd()}/file`, '/install/path');
|
|
62
|
+
});
|
|
63
|
+
it('calls cleaner with array including downloaded zip and unzipped dir paths', async () => {
|
|
64
|
+
await runSdkInstallerWithDefinedZipPath();
|
|
65
|
+
expect(services_1.clean).toHaveBeenCalledWith([
|
|
66
|
+
`${process.cwd()}/file.zip`,
|
|
67
|
+
`${process.cwd()}/file`,
|
|
68
|
+
]);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('cleaning when error occurs', () => {
|
|
72
|
+
it('calls cleaner when downloader throws an error', async () => {
|
|
73
|
+
services_1.download.mockImplementationOnce(async () => { throw new Error(); });
|
|
74
|
+
await expect(runSdkInstallerWithDefinedZipPath).rejects.toBeInstanceOf(Error);
|
|
75
|
+
expect(services_1.clean).toBeCalledTimes(1);
|
|
76
|
+
});
|
|
77
|
+
it('calls cleaner when unzipper throws an error', async () => {
|
|
78
|
+
services_1.unzip.mockImplementationOnce(() => { throw new Error(); });
|
|
79
|
+
await expect(runSdkInstallerWithDefinedZipPath).rejects.toBeInstanceOf(Error);
|
|
80
|
+
expect(services_1.clean).toBeCalledTimes(1);
|
|
81
|
+
});
|
|
82
|
+
it('calls cleaner when installer throws an error', async () => {
|
|
83
|
+
services_1.install.mockImplementationOnce(() => { throw new Error(); });
|
|
84
|
+
await expect(runSdkInstallerWithDefinedZipPath).rejects.toBeInstanceOf(Error);
|
|
85
|
+
expect(services_1.clean).toBeCalledTimes(1);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const childProcess = __importStar(require("child_process"));
|
|
23
|
+
const services_1 = require("../../../../../sdks/sdk-utils/sdk-installer/services");
|
|
24
|
+
jest.mock('child_process');
|
|
25
|
+
describe('SDK Installer - Cleaner', () => {
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
jest.clearAllMocks();
|
|
28
|
+
});
|
|
29
|
+
it('removes all dirs and files listed as paths in array', () => {
|
|
30
|
+
childProcess.spawnSync.mockImplementationOnce(() => { });
|
|
31
|
+
const spawnSyncSpy = jest.spyOn(childProcess, 'spawnSync');
|
|
32
|
+
const pathsToClean = [
|
|
33
|
+
'/path/to/dir1',
|
|
34
|
+
'/path/to/dir2',
|
|
35
|
+
'/path/to/file1.zip',
|
|
36
|
+
'/path/to/file2.js',
|
|
37
|
+
];
|
|
38
|
+
services_1.clean(pathsToClean);
|
|
39
|
+
expect(spawnSyncSpy).toHaveBeenCalledTimes(pathsToClean.length);
|
|
40
|
+
const [call0, call1, call2, call3] = spawnSyncSpy.mock.calls;
|
|
41
|
+
expect(call0).toEqual(['rm', ['-r', '/path/to/dir1']]);
|
|
42
|
+
expect(call1).toEqual(['rm', ['-r', '/path/to/dir2']]);
|
|
43
|
+
expect(call2).toEqual(['rm', ['-r', '/path/to/file1.zip']]);
|
|
44
|
+
expect(call3).toEqual(['rm', ['-r', '/path/to/file2.js']]);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const stream_1 = __importDefault(require("stream"));
|
|
26
|
+
const nock = __importStar(require("nock"));
|
|
27
|
+
const http_1 = __importDefault(require("http"));
|
|
28
|
+
const https_1 = __importDefault(require("https"));
|
|
29
|
+
const fs_1 = __importDefault(require("fs"));
|
|
30
|
+
const services_1 = require("../../../../../sdks/sdk-utils/sdk-installer/services");
|
|
31
|
+
jest.mock('fs');
|
|
32
|
+
fs_1.default.createWriteStream.mockImplementation(() => new stream_1.default.PassThrough());
|
|
33
|
+
describe('SDK Installer - Downloader', () => {
|
|
34
|
+
const HTTP_RESPONSE_STATUS_CODE_OK = 200;
|
|
35
|
+
const HTTP_RESPONSE_STATUS_CODE_NOT_FOUND = 404;
|
|
36
|
+
const httpBasePath = 'http://s3.amazonaws.com';
|
|
37
|
+
const zipRelativeFilePath = '/file.zip';
|
|
38
|
+
const zipFileHttpUrl = `${httpBasePath}${zipRelativeFilePath}`;
|
|
39
|
+
const headersWithZipContentType = { 'Content-Type': 'application/zip' };
|
|
40
|
+
const saveFilePath = `${process.cwd()}/test.zip`;
|
|
41
|
+
const makeValidHttpNock = () => nock.default(httpBasePath)
|
|
42
|
+
.get(zipRelativeFilePath)
|
|
43
|
+
.reply(HTTP_RESPONSE_STATUS_CODE_OK, '', headersWithZipContentType);
|
|
44
|
+
nock.disableNetConnect();
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
jest.clearAllMocks();
|
|
47
|
+
});
|
|
48
|
+
afterAll(() => {
|
|
49
|
+
nock.cleanAll();
|
|
50
|
+
nock.enableNetConnect();
|
|
51
|
+
});
|
|
52
|
+
describe('Supported protocols', () => {
|
|
53
|
+
it('calls http.get for URL with HTTP protocol', async () => {
|
|
54
|
+
makeValidHttpNock();
|
|
55
|
+
const getSpy = jest.spyOn(http_1.default, 'get');
|
|
56
|
+
await services_1.download(zipFileHttpUrl, saveFilePath);
|
|
57
|
+
expect(getSpy).toBeCalledTimes(1);
|
|
58
|
+
});
|
|
59
|
+
it('calls https.get for URL with HTTPS protocol', async () => {
|
|
60
|
+
nock.default(httpBasePath.replace('http:', 'https:'))
|
|
61
|
+
.get(zipRelativeFilePath)
|
|
62
|
+
.reply(HTTP_RESPONSE_STATUS_CODE_OK, '', headersWithZipContentType);
|
|
63
|
+
const getSpy = jest.spyOn(https_1.default, 'get');
|
|
64
|
+
await services_1.download(zipFileHttpUrl.replace('http:', 'https:'), saveFilePath);
|
|
65
|
+
expect(getSpy).toBeCalledTimes(1);
|
|
66
|
+
});
|
|
67
|
+
it('throws an error when URL has unsupported protocol', async () => {
|
|
68
|
+
await expect(async () => {
|
|
69
|
+
await services_1.download('ftp://file.zip', saveFilePath);
|
|
70
|
+
}).rejects.toThrow(new Error('ftp: protocol is not supported'));
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('Handling response errors', () => {
|
|
74
|
+
it('throws an error when returned content type is not application/zip', async () => {
|
|
75
|
+
nock.default(httpBasePath)
|
|
76
|
+
.get('/file.json')
|
|
77
|
+
.reply(HTTP_RESPONSE_STATUS_CODE_OK, '', { 'Content-Type': 'application/json' });
|
|
78
|
+
await expect(async () => {
|
|
79
|
+
await services_1.download(`${httpBasePath}/file.json`, saveFilePath);
|
|
80
|
+
}).rejects.toThrow(new Error('Wrong Content-Type: expected application/zip, received application/json'));
|
|
81
|
+
nock.default(httpBasePath)
|
|
82
|
+
.get(zipRelativeFilePath)
|
|
83
|
+
.reply(HTTP_RESPONSE_STATUS_CODE_OK, '');
|
|
84
|
+
await expect(async () => {
|
|
85
|
+
await services_1.download(zipFileHttpUrl, saveFilePath);
|
|
86
|
+
}).rejects.toThrow(new Error('Missing Content-Type: expected application/zip'));
|
|
87
|
+
});
|
|
88
|
+
it('throws an error when request status is not 200', async () => {
|
|
89
|
+
nock.default(httpBasePath)
|
|
90
|
+
.get(zipRelativeFilePath)
|
|
91
|
+
.reply(HTTP_RESPONSE_STATUS_CODE_NOT_FOUND, '', headersWithZipContentType);
|
|
92
|
+
await expect(async () => {
|
|
93
|
+
await services_1.download(zipFileHttpUrl, saveFilePath);
|
|
94
|
+
}).rejects.toThrow(new Error('Request Failed. Status Code: 404'));
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe('Writing received data into a file', () => {
|
|
98
|
+
beforeEach(() => {
|
|
99
|
+
makeValidHttpNock();
|
|
100
|
+
});
|
|
101
|
+
it('Creates dest path if does not exist', async () => {
|
|
102
|
+
const mkDirSync = jest.spyOn(fs_1.default, 'mkdirSync');
|
|
103
|
+
fs_1.default.existsSync.mockImplementationOnce(() => false);
|
|
104
|
+
await services_1.download(zipFileHttpUrl, saveFilePath);
|
|
105
|
+
expect(mkDirSync).toBeCalledTimes(1);
|
|
106
|
+
expect(mkDirSync).toHaveBeenCalledWith(process.cwd(), { recursive: true });
|
|
107
|
+
});
|
|
108
|
+
it('Does not create dest path if path exists', async () => {
|
|
109
|
+
const mkDirSync = jest.spyOn(fs_1.default, 'mkdirSync');
|
|
110
|
+
fs_1.default.existsSync.mockImplementationOnce(() => true);
|
|
111
|
+
await services_1.download(zipFileHttpUrl, saveFilePath);
|
|
112
|
+
expect(mkDirSync).toBeCalledTimes(0);
|
|
113
|
+
});
|
|
114
|
+
it('Calls write fn with dest param', async () => {
|
|
115
|
+
const createWriteStream = jest.spyOn(fs_1.default, 'createWriteStream');
|
|
116
|
+
await services_1.download(zipFileHttpUrl, saveFilePath);
|
|
117
|
+
expect(createWriteStream).toBeCalledTimes(1);
|
|
118
|
+
expect(createWriteStream).toHaveBeenCalledWith(saveFilePath);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const childProcess = __importStar(require("child_process"));
|
|
23
|
+
const services_1 = require("../../../../../sdks/sdk-utils/sdk-installer/services");
|
|
24
|
+
jest.mock('child_process');
|
|
25
|
+
describe('SDK Installer - Installer', () => {
|
|
26
|
+
childProcess.execSync.mockImplementation(() => '');
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
jest.clearAllMocks();
|
|
29
|
+
});
|
|
30
|
+
describe('Calling external install.js script', () => {
|
|
31
|
+
it('Calls with install.js path only when install path is not provided', () => {
|
|
32
|
+
const execSyncSpy = jest.spyOn(childProcess, 'execSync');
|
|
33
|
+
services_1.install('/install/from');
|
|
34
|
+
expect(execSyncSpy).toHaveBeenCalledTimes(1);
|
|
35
|
+
const params = execSyncSpy.mock.calls[0];
|
|
36
|
+
const command = params[0];
|
|
37
|
+
expect(command).toBe('node /install/from/install.js');
|
|
38
|
+
});
|
|
39
|
+
it('Calls with install path when it is provided', () => {
|
|
40
|
+
const execSyncSpy = jest.spyOn(childProcess, 'execSync');
|
|
41
|
+
services_1.install('/install/from', '/install/to');
|
|
42
|
+
expect(execSyncSpy).toHaveBeenCalledTimes(1);
|
|
43
|
+
const params = execSyncSpy.mock.calls[0];
|
|
44
|
+
const command = params[0];
|
|
45
|
+
expect(command).toBe('node /install/from/install.js /install/to');
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
it('returns installed path', () => {
|
|
49
|
+
childProcess.execSync.mockImplementationOnce(() => 'INSTALL_PATH=/sdk');
|
|
50
|
+
const pathInstalledTo = services_1.install('/install/from');
|
|
51
|
+
expect(pathInstalledTo).toBe('/sdk');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const childProcess = __importStar(require("child_process"));
|
|
23
|
+
const services_1 = require("../../../../../sdks/sdk-utils/sdk-installer/services");
|
|
24
|
+
jest.mock('child_process');
|
|
25
|
+
describe('SDK Installer - Unzipper', () => {
|
|
26
|
+
childProcess.spawnSync.mockImplementation(() => ({ stderr: '' }));
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
jest.clearAllMocks();
|
|
29
|
+
});
|
|
30
|
+
it('calls spawnSync with needed params', () => {
|
|
31
|
+
const spawnSyncSpy = jest.spyOn(childProcess, 'spawnSync');
|
|
32
|
+
services_1.unzip('/path/file.zip');
|
|
33
|
+
expect(spawnSyncSpy).toHaveBeenCalledTimes(1);
|
|
34
|
+
const params = spawnSyncSpy.mock.calls[0];
|
|
35
|
+
const command = params[0];
|
|
36
|
+
expect(command).toBe('unzip');
|
|
37
|
+
const args = params[1] || [];
|
|
38
|
+
expect(args).not.toBeUndefined();
|
|
39
|
+
expect(args.includes('/path/file.zip')).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
it('throws an error when error occurs during unzipping', async () => {
|
|
42
|
+
childProcess.spawnSync.mockImplementationOnce(() => ({ stderr: 'error' }));
|
|
43
|
+
expect(() => {
|
|
44
|
+
services_1.unzip('');
|
|
45
|
+
}).toThrow(new Error('error'));
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -26,7 +26,7 @@ const os = __importStar(require("os"));
|
|
|
26
26
|
const semver = __importStar(require("semver"));
|
|
27
27
|
const child_process_1 = require("child_process");
|
|
28
28
|
const rnv_1 = require("rnv");
|
|
29
|
-
const
|
|
29
|
+
const sdk_utils_1 = require("../sdk-utils");
|
|
30
30
|
const constants_1 = require("../../constants");
|
|
31
31
|
const { execCLI } = rnv_1.Exec;
|
|
32
32
|
const { CLI_TIZEN, REMOTE_DEBUGGER_ENABLED_PLATFORMS } = rnv_1.Constants;
|
|
@@ -225,12 +225,12 @@ const handleTizenSdk = async (c) => {
|
|
|
225
225
|
if (!TIZEN_SDK) {
|
|
226
226
|
handleLinuxKeyring();
|
|
227
227
|
if (fs.existsSync(installPath)) {
|
|
228
|
-
await
|
|
228
|
+
await sdk_utils_1.registerSdkPath(c, rnvSdkKey, installPath);
|
|
229
229
|
}
|
|
230
230
|
else {
|
|
231
|
-
const sdkInstalledToPath = await
|
|
231
|
+
const sdkInstalledToPath = await sdk_utils_1.installSdk(TIZEN_SDK_INSTALLER_URL, installPath);
|
|
232
232
|
if (sdkInstalledToPath) {
|
|
233
|
-
await
|
|
233
|
+
await sdk_utils_1.registerSdkPath(c, rnvSdkKey, sdkInstalledToPath);
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./installSdk"), exports);
|
|
14
|
+
__exportStar(require("./registerSdkPath"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.installSdk = void 0;
|
|
4
|
+
const sdk_installer_1 = require("./sdk-installer");
|
|
5
|
+
const installSdk = async (installerUrl, installPath) => sdk_installer_1.sdkInstaller({
|
|
6
|
+
zipPath: installerUrl,
|
|
7
|
+
installPath,
|
|
8
|
+
enableLogs: true,
|
|
9
|
+
});
|
|
10
|
+
exports.installSdk = installSdk;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.registerSdkPath = void 0;
|
|
4
4
|
const rnv_1 = require("rnv");
|
|
5
|
-
const smartapps_bigscreen_sdk_installer_1 = require("@24i/smartapps-bigscreen-sdk-installer");
|
|
6
5
|
const registerSdkPath = async (c, sdkKey, sdkValue) => {
|
|
7
6
|
const rnvWorkspaceConfigPath = c.paths.workspace.config;
|
|
8
7
|
const customObjectToMerge = { sdks: { [sdkKey]: sdkValue } };
|
|
@@ -10,9 +9,3 @@ const registerSdkPath = async (c, sdkKey, sdkValue) => {
|
|
|
10
9
|
Object.assign(c.buildConfig, customObjectToMerge);
|
|
11
10
|
};
|
|
12
11
|
exports.registerSdkPath = registerSdkPath;
|
|
13
|
-
const installSdk = async (installerUrl, installPath) => smartapps_bigscreen_sdk_installer_1.sdkInstaller({
|
|
14
|
-
zipPath: installerUrl,
|
|
15
|
-
installPath,
|
|
16
|
-
enableLogs: true,
|
|
17
|
-
});
|
|
18
|
-
exports.installSdk = installSdk;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sdkInstaller = void 0;
|
|
4
|
+
var sdkInstaller_1 = require("./sdkInstaller");
|
|
5
|
+
Object.defineProperty(exports, "sdkInstaller", { enumerable: true, get: function () { return sdkInstaller_1.sdkInstaller; } });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sdkInstaller = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const url_1 = require("url");
|
|
6
|
+
const services_1 = require("./services");
|
|
7
|
+
const log = (message) => process.stdout.write(message);
|
|
8
|
+
const sdkInstaller = async ({ zipPath, installPath, enableLogs }) => {
|
|
9
|
+
const logger = enableLogs ? log : () => false;
|
|
10
|
+
const pathsToDelete = [];
|
|
11
|
+
let usedInstallPath;
|
|
12
|
+
try {
|
|
13
|
+
const parsedZipPath = path_1.parse(zipPath);
|
|
14
|
+
const parsedZipUrl = url_1.parse(zipPath);
|
|
15
|
+
if (!parsedZipUrl.protocol) {
|
|
16
|
+
throw new Error('Installation from local packages is not supported yet.');
|
|
17
|
+
}
|
|
18
|
+
logger('Downloading...');
|
|
19
|
+
const downloadedFilePath = `${process.cwd()}/${parsedZipPath.base}`;
|
|
20
|
+
pathsToDelete.push(downloadedFilePath);
|
|
21
|
+
await services_1.download(zipPath, downloadedFilePath);
|
|
22
|
+
logger('\rUnpacking...');
|
|
23
|
+
const unzippedDirPath = `${process.cwd()}/${parsedZipPath.name}`;
|
|
24
|
+
pathsToDelete.push(unzippedDirPath);
|
|
25
|
+
services_1.unzip(downloadedFilePath);
|
|
26
|
+
logger('\rInstalling...');
|
|
27
|
+
usedInstallPath = services_1.install(unzippedDirPath, installPath);
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
services_1.clean(pathsToDelete);
|
|
31
|
+
throw e;
|
|
32
|
+
}
|
|
33
|
+
logger('\rCleaning...');
|
|
34
|
+
services_1.clean(pathsToDelete);
|
|
35
|
+
logger(`\rInstalled to ${usedInstallPath}\n`);
|
|
36
|
+
return usedInstallPath;
|
|
37
|
+
};
|
|
38
|
+
exports.sdkInstaller = sdkInstaller;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clean = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const deleteFileOrDirectory = (path) => {
|
|
6
|
+
child_process_1.spawnSync('rm', ['-r', path]);
|
|
7
|
+
};
|
|
8
|
+
const clean = (pathsToBeDeleted) => {
|
|
9
|
+
pathsToBeDeleted.forEach(deleteFileOrDirectory);
|
|
10
|
+
};
|
|
11
|
+
exports.clean = clean;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.download = void 0;
|
|
23
|
+
const fs = __importStar(require("fs"));
|
|
24
|
+
const path = __importStar(require("path"));
|
|
25
|
+
const url = __importStar(require("url"));
|
|
26
|
+
const http = __importStar(require("http"));
|
|
27
|
+
const https = __importStar(require("https"));
|
|
28
|
+
const createDirPathIfDoesntExist = async (dirPath) => {
|
|
29
|
+
if (!fs.existsSync(dirPath)) {
|
|
30
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const getNetworkProtocolAdapter = (requestedUrl) => {
|
|
34
|
+
const { protocol } = url.parse(requestedUrl);
|
|
35
|
+
switch (protocol) {
|
|
36
|
+
case 'http:': return http;
|
|
37
|
+
case 'https:': return https;
|
|
38
|
+
default: throw new Error(`${protocol} protocol is not supported`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const getResponseError = (response) => {
|
|
42
|
+
const HTTP_RESPONSE_STATUS_CODE_OK = 200;
|
|
43
|
+
const { statusCode, headers } = response;
|
|
44
|
+
const contentType = headers['content-type'];
|
|
45
|
+
if (statusCode !== HTTP_RESPONSE_STATUS_CODE_OK) {
|
|
46
|
+
return new Error(`Request Failed. Status Code: ${statusCode}`);
|
|
47
|
+
}
|
|
48
|
+
if (!contentType) {
|
|
49
|
+
return new Error('Missing Content-Type: expected application/zip');
|
|
50
|
+
}
|
|
51
|
+
if (!/^application\/zip/.test(contentType)) {
|
|
52
|
+
return new Error(`Wrong Content-Type: expected application/zip, received ${contentType}`);
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
const download = async (fromUrl, toFilePath) => {
|
|
57
|
+
const toDirPath = path.parse(toFilePath).dir;
|
|
58
|
+
await createDirPathIfDoesntExist(toDirPath);
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const request = getNetworkProtocolAdapter(fromUrl).get(fromUrl, (response) => {
|
|
61
|
+
const error = getResponseError(response);
|
|
62
|
+
if (error) {
|
|
63
|
+
reject(error);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const file = fs.createWriteStream(toFilePath);
|
|
67
|
+
file.on('error', reject);
|
|
68
|
+
file.on('finish', resolve);
|
|
69
|
+
response.pipe(file);
|
|
70
|
+
});
|
|
71
|
+
request.on('error', reject);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
exports.download = download;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clean = exports.install = exports.unzip = exports.download = void 0;
|
|
4
|
+
var download_1 = require("./download");
|
|
5
|
+
Object.defineProperty(exports, "download", { enumerable: true, get: function () { return download_1.download; } });
|
|
6
|
+
var unzip_1 = require("./unzip");
|
|
7
|
+
Object.defineProperty(exports, "unzip", { enumerable: true, get: function () { return unzip_1.unzip; } });
|
|
8
|
+
var install_1 = require("./install");
|
|
9
|
+
Object.defineProperty(exports, "install", { enumerable: true, get: function () { return install_1.install; } });
|
|
10
|
+
var clean_1 = require("./clean");
|
|
11
|
+
Object.defineProperty(exports, "clean", { enumerable: true, get: function () { return clean_1.clean; } });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.install = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const getInstalledPathFromOutput = (output) => {
|
|
6
|
+
const prefix = 'INSTALL_PATH=';
|
|
7
|
+
const installedPathRow = output
|
|
8
|
+
.split('\n')
|
|
9
|
+
.map((outputRow) => outputRow.trim())
|
|
10
|
+
.filter((trimmedOutputRow) => trimmedOutputRow.startsWith(prefix));
|
|
11
|
+
return installedPathRow[0]?.replace(prefix, '') || '';
|
|
12
|
+
};
|
|
13
|
+
const install = (installerDirPath, installToPath) => {
|
|
14
|
+
const installationScriptPath = `${installerDirPath}/install.js`;
|
|
15
|
+
const installationCommandWithoutCustomPath = `node ${installationScriptPath}`;
|
|
16
|
+
const installationCmdToBeUsed = installToPath
|
|
17
|
+
? `${installationCommandWithoutCustomPath} ${installToPath}`
|
|
18
|
+
: installationCommandWithoutCustomPath;
|
|
19
|
+
const execOptions = { maxBuffer: 5242880 };
|
|
20
|
+
const installationScriptOutput = child_process_1.execSync(installationCmdToBeUsed, execOptions).toString();
|
|
21
|
+
return getInstalledPathFromOutput(installationScriptOutput);
|
|
22
|
+
};
|
|
23
|
+
exports.install = install;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unzip = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const unzip = (filePath) => {
|
|
6
|
+
const spawnOptions = { maxBuffer: 5242880 };
|
|
7
|
+
const unzipProcess = child_process_1.spawnSync('unzip', ['-n', filePath], spawnOptions);
|
|
8
|
+
if (unzipProcess.stderr.length) {
|
|
9
|
+
throw new Error(unzipProcess.stderr.toString());
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
exports.unzip = unzip;
|
|
@@ -24,7 +24,7 @@ const fs = __importStar(require("fs"));
|
|
|
24
24
|
const path = __importStar(require("path"));
|
|
25
25
|
const os_1 = require("os");
|
|
26
26
|
const rnv_1 = require("rnv");
|
|
27
|
-
const
|
|
27
|
+
const sdk_utils_1 = require("../sdk-utils");
|
|
28
28
|
const { writeCleanFile } = rnv_1.FileUtils;
|
|
29
29
|
const { execCLI } = rnv_1.Exec;
|
|
30
30
|
const { getPlatformProjectDir, getTemplateProjectDir, getPlatformBuildDir, getConfigProp, checkPortInUse, confirmActiveBundler, } = rnv_1.Common;
|
|
@@ -123,11 +123,11 @@ const handleWebosSdk = async (c) => {
|
|
|
123
123
|
const rnvSdkKey = 'WEBOS_SDK';
|
|
124
124
|
if (!WEBOS_SDK) {
|
|
125
125
|
if (fs.existsSync(installPath)) {
|
|
126
|
-
await
|
|
126
|
+
await sdk_utils_1.registerSdkPath(c, rnvSdkKey, installPath);
|
|
127
127
|
}
|
|
128
|
-
const sdkInstalledToPath = await
|
|
128
|
+
const sdkInstalledToPath = await sdk_utils_1.installSdk(WEBOS_SDK_INSTALLER_URL, installPath);
|
|
129
129
|
if (sdkInstalledToPath) {
|
|
130
|
-
await
|
|
130
|
+
await sdk_utils_1.registerSdkPath(c, rnvSdkKey, sdkInstalledToPath);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
await rnv_1.SDKManager.Installer.checkAndConfigureWebosSdks(c);
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/smartapps-bigscreen-rnv-build-engine",
|
|
3
|
-
"version": "0.8.7-alpha.
|
|
3
|
+
"version": "0.8.7-alpha.1416+dc54bb74",
|
|
4
4
|
"description": "Package with build engine for SmartApps BIGscreen projects...",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@24i/smartapps-bigscreen-icon": "0.8.3",
|
|
22
|
-
"@24i/smartapps-bigscreen-sdk-installer": "0.8.3",
|
|
23
22
|
"core-js": "3.15.2",
|
|
24
23
|
"coveralls": "3.1.1",
|
|
25
24
|
"css-hot-loader": "1.4.4",
|
|
@@ -31,9 +30,11 @@
|
|
|
31
30
|
"html-webpack-harddisk-plugin": "1.0.2",
|
|
32
31
|
"html-webpack-plugin": "4.5.2",
|
|
33
32
|
"mini-css-extract-plugin": "1.6.2",
|
|
33
|
+
"nock": "13.1.3",
|
|
34
34
|
"node-ssh": "11.1.1",
|
|
35
35
|
"raf": "3.4.1",
|
|
36
36
|
"regenerator-runtime": "0.13.7",
|
|
37
|
+
"renative": "0.32.0-alpha.43",
|
|
37
38
|
"renative-template-blank": "0.32.0-alpha.43",
|
|
38
39
|
"rnv": "0.32.0-alpha.43",
|
|
39
40
|
"sass": "1.37.0",
|
|
@@ -60,5 +61,5 @@
|
|
|
60
61
|
"keywords": [],
|
|
61
62
|
"author": "24i",
|
|
62
63
|
"license": "ISC",
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "dc54bb74c827e4967ff7e31aaf33a15de6fb2e9b"
|
|
64
65
|
}
|