@24i/smartapps-bigscreen-rnv-build-engine 0.8.7-xbox-alpha1.1385 → 0.9.1

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.
Files changed (76) hide show
  1. package/README.md +2 -3
  2. package/dist/src/__tests__/sdks/sdk-utils/registerSdkPath.spec.js +60 -0
  3. package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/sdkInstaller.spec.js +85 -0
  4. package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/clean.spec.js +46 -0
  5. package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/download.spec.js +121 -0
  6. package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/install.spec.js +53 -0
  7. package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/unzip.spec.js +47 -0
  8. package/dist/src/engine.js +82 -0
  9. package/dist/src/index.js +4 -60
  10. package/dist/src/resolvers/resolveBaseUrl.js +1 -1
  11. package/dist/src/resolvers/resolveBuildFileName.js +2 -2
  12. package/dist/src/resolvers/resolveBuildVersion.js +2 -2
  13. package/dist/src/resolvers/resolveBuildVersionOffset.js +2 -2
  14. package/dist/src/resolvers/resolveDeployLocations.js +5 -5
  15. package/dist/src/resolvers/resolveGenericRnvConfig.js +2 -2
  16. package/dist/src/resolvers/resolveHbbtvDeployUrl.js +2 -2
  17. package/dist/src/resolvers/resolveUsedFlavours.js +1 -1
  18. package/dist/src/scripts/buildAllWithScheme.js +3 -3
  19. package/dist/src/scripts/generateDeployUrls/index.js +4 -4
  20. package/dist/src/scripts/generateDeployUrls/makeTableDataByScheme.js +3 -3
  21. package/dist/src/scripts/gitReleaser/afterVersionBump.js +6 -6
  22. package/dist/src/scripts/gitReleaser/beforeVersionBump.js +6 -6
  23. package/dist/src/scripts/gitReleaser/checkReleaseNotes.js +1 -1
  24. package/dist/src/scripts/gitReleaser/pushRelease.js +7 -7
  25. package/dist/src/scripts/gitReleaser/pushReleaseCandidate.js +1 -1
  26. package/dist/src/scripts/gitReleaser/pushReleaseNotes.js +7 -7
  27. package/dist/src/scripts/release/deleteSourceMaps.js +1 -1
  28. package/dist/src/scripts/release/deployToAppCenter.js +6 -6
  29. package/dist/src/scripts/release/githubRelease.js +16 -16
  30. package/dist/src/scripts/release/notifySlack/makePayload.js +1 -1
  31. package/dist/src/scripts/release/notifySlack/notifySlack.js +1 -1
  32. package/dist/src/scripts/release/sentryRelease.js +3 -3
  33. package/dist/src/scripts/release/urlsMarkdown.js +1 -1
  34. package/dist/src/scripts/releaseAllWithScheme.js +11 -11
  35. package/dist/src/scripts/utils/cmdUtils.js +1 -1
  36. package/dist/src/scripts/utils/fsUtils.js +1 -1
  37. package/dist/src/scripts/utils/gitUtils.js +17 -17
  38. package/dist/src/sdks/sdk-tizen/index.js +11 -11
  39. package/dist/src/sdks/sdk-utils/index.js +14 -0
  40. package/dist/src/sdks/sdk-utils/registerSdkPath.js +14 -0
  41. package/dist/src/sdks/sdk-utils/sdk-installer/index.js +5 -0
  42. package/dist/src/sdks/sdk-utils/sdk-installer/sdkInstaller.js +39 -0
  43. package/dist/src/sdks/sdk-utils/sdk-installer/services/clean.js +11 -0
  44. package/dist/src/sdks/sdk-utils/sdk-installer/services/download.js +74 -0
  45. package/dist/src/sdks/sdk-utils/sdk-installer/services/index.js +11 -0
  46. package/dist/src/sdks/sdk-utils/sdk-installer/services/install.js +23 -0
  47. package/dist/src/sdks/sdk-utils/sdk-installer/services/unzip.js +12 -0
  48. package/dist/src/sdks/sdk-webos/index.js +5 -5
  49. package/dist/src/tasks/deploy/aswS3/aws.js +2 -2
  50. package/dist/src/tasks/deploy/aswS3/deployS3.js +2 -2
  51. package/dist/src/tasks/deploy/hbbtv/deployHbbtv.js +7 -7
  52. package/dist/src/tasks/task.rnv.build.js +8 -8
  53. package/dist/src/tasks/task.rnv.configure.js +1 -1
  54. package/dist/src/tasks/task.rnv.configureSoft.js +2 -2
  55. package/dist/src/tasks/task.rnv.deploy.js +3 -3
  56. package/dist/src/tasks/task.rnv.hooks.run.js +1 -1
  57. package/dist/src/tasks/task.rnv.project.configure.js +2 -2
  58. package/dist/src/utils/forEachSupportedPlatformFlavour.js +1 -1
  59. package/dist/src/utils/replaceRelevantStringsInConfig/replaceRelevantStringsInConfig.js +1 -1
  60. package/dist/src/utils/replaceRelevantStringsInConfig/replaceTemplateString.js +1 -1
  61. package/dist/src/utils/zipBuildsByPlatforms.js +9 -9
  62. package/dist/templates/platforms/entone/webpack.config.dev.js +1 -1
  63. package/dist/templates/platforms/entone/webpack.config.prod.js +1 -1
  64. package/dist/templates/platforms/hbbtv/webpack.config.dev.js +1 -1
  65. package/dist/templates/platforms/hbbtv/webpack.config.prod.js +1 -1
  66. package/dist/templates/platforms/saphi/webpack.config.dev.js +1 -1
  67. package/dist/templates/platforms/saphi/webpack.config.prod.js +1 -1
  68. package/dist/templates/platforms/tizen/webpack.config.dev.js +1 -1
  69. package/dist/templates/platforms/tizen/webpack.config.prod.js +1 -1
  70. package/dist/templates/platforms/webos/webpack.config.dev.js +1 -1
  71. package/dist/templates/platforms/webos/webpack.config.prod.js +1 -1
  72. package/dist/templates/platforms/webtv/webpack.config.dev.js +1 -1
  73. package/dist/templates/platforms/webtv/webpack.config.prod.js +1 -1
  74. package/jest.config.js +6 -0
  75. package/package.json +16 -18
  76. package/dist/src/sdks/sdkUtils.js +0 -18
package/README.md CHANGED
@@ -126,7 +126,7 @@ An example:
126
126
  ---
127
127
  ## Package content
128
128
 
129
- ### npm dependenncies
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,
@@ -140,7 +140,6 @@ which simplify the future dependencies update and reduce the amount of time spen
140
140
  #### ReNative npm dependencies
141
141
  Firstly, the package contains main ReNative npm packages, namely:
142
142
 
143
- - `renative`
144
143
  - `renative-template-blank`
145
144
  - `rnv`
146
145
 
@@ -148,7 +147,6 @@ Firstly, the package contains main ReNative npm packages, namely:
148
147
  Following dependencies are used in source code for custom build engine for ReNative:
149
148
 
150
149
  - `@24i/smartapps-bigscreen-icon` *(generating SVG icons)*
151
- - `@24i/smartapps-bigscreen-sdk-installer` *(installing SDKs for Tizen or webOS)*
152
150
  - `glob` *(searching output builds)*
153
151
  - `node-ssh` *(connection to HbbTV server)*
154
152
  - `svgo` *(generating SVG icons)*
@@ -164,6 +162,7 @@ The package has also dependencies which are related to build the applications wi
164
162
  - `html-webpack-harddisk-plugin`
165
163
  - `html-webpack-plugin`
166
164
  - `mini-css-extract-plugin`
165
+ - `ora`
167
166
  - `sass`
168
167
  - `sass-loader`
169
168
  - `source-map-loader`
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const sdk_utils_1 = require("../../../sdks/sdk-utils");
8
+ const rnvC = {
9
+ paths: {
10
+ workspace: {
11
+ config: `${process.cwd()}/renative_test.json`,
12
+ },
13
+ },
14
+ buildConfig: {},
15
+ };
16
+ const getWorkspaceConfigPath = () => rnvC.paths.workspace.config;
17
+ describe('SDK Utils - registerSdkPath', () => {
18
+ afterEach(() => {
19
+ fs_1.default.rmSync(getWorkspaceConfigPath(), { force: true });
20
+ rnvC.buildConfig.sdks = undefined;
21
+ });
22
+ it('adds requested sdk entry into the file', async () => {
23
+ expect(fs_1.default.existsSync(getWorkspaceConfigPath())).toBe(false);
24
+ await (0, sdk_utils_1.registerSdkPath)(rnvC, 'SDK_KEY_0', 'SDK_VALUE_0');
25
+ await (0, sdk_utils_1.registerSdkPath)(rnvC, 'SDK_KEY_1', 'SDK_VALUE_1');
26
+ expect(fs_1.default.existsSync(getWorkspaceConfigPath())).toBe(true);
27
+ const fileContent = fs_1.default.readFileSync(getWorkspaceConfigPath()).toString();
28
+ expect(JSON.parse(fileContent).sdks).toStrictEqual({
29
+ SDK_KEY_0: 'SDK_VALUE_0',
30
+ SDK_KEY_1: 'SDK_VALUE_1',
31
+ });
32
+ });
33
+ it('adds requested sdk entry into the rnv C object', async () => {
34
+ expect(rnvC.buildConfig.sdks).toBeUndefined();
35
+ await (0, sdk_utils_1.registerSdkPath)(rnvC, 'SDK_KEY_0', 'SDK_VALUE_0');
36
+ await (0, sdk_utils_1.registerSdkPath)(rnvC, 'SDK_KEY_1', 'SDK_VALUE_1');
37
+ expect(rnvC.buildConfig.sdks).toStrictEqual({
38
+ SDK_KEY_0: 'SDK_VALUE_0',
39
+ SDK_KEY_1: 'SDK_VALUE_1',
40
+ });
41
+ });
42
+ it('overwrites entry in the file', async () => {
43
+ expect(fs_1.default.existsSync(getWorkspaceConfigPath())).toBe(false);
44
+ await (0, sdk_utils_1.registerSdkPath)(rnvC, 'SDK_KEY_0', 'SDK_VALUE_0');
45
+ await (0, sdk_utils_1.registerSdkPath)(rnvC, 'SDK_KEY_0', 'SDK_VALUE_0_OVERWRITTEN');
46
+ expect(fs_1.default.existsSync(getWorkspaceConfigPath())).toBe(true);
47
+ const fileContent = fs_1.default.readFileSync(getWorkspaceConfigPath()).toString();
48
+ expect(JSON.parse(fileContent).sdks).toStrictEqual({
49
+ SDK_KEY_0: 'SDK_VALUE_0_OVERWRITTEN',
50
+ });
51
+ });
52
+ it('overwrites sdk entry in rnv C object', async () => {
53
+ expect(rnvC.buildConfig.sdks).toBeUndefined();
54
+ await (0, sdk_utils_1.registerSdkPath)(rnvC, 'SDK_KEY_0', 'SDK_VALUE_0');
55
+ await (0, sdk_utils_1.registerSdkPath)(rnvC, 'SDK_KEY_0', 'SDK_VALUE_0_OVERWRITTEN');
56
+ expect(rnvC.buildConfig.sdks).toStrictEqual({
57
+ SDK_KEY_0: 'SDK_VALUE_0_OVERWRITTEN',
58
+ });
59
+ });
60
+ });
@@ -0,0 +1,85 @@
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 (0, sdk_installer_1.sdkInstaller)(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 (0, sdk_installer_1.sdkInstaller)('/local/path.zip');
21
+ }).rejects.toBeInstanceOf(Error);
22
+ });
23
+ });
24
+ describe('printing log messages', () => {
25
+ it('do 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 (0, sdk_installer_1.sdkInstaller)(URL_TO_DOWNLOAD_FILE_FROM, '', 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 (0, sdk_installer_1.sdkInstaller)(URL_TO_DOWNLOAD_FILE_FROM, '', 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 (0, sdk_installer_1.sdkInstaller)(URL_TO_DOWNLOAD_FILE_FROM, '/install/path');
58
+ expect(services_1.install).toHaveBeenCalledWith(`${process.cwd()}/file`, '/install/path');
59
+ });
60
+ it('calls cleaner with array including downloaded zip and unzipped dir paths', async () => {
61
+ await runSdkInstallerWithDefinedZipPath();
62
+ expect(services_1.clean).toHaveBeenCalledWith([
63
+ `${process.cwd()}/file.zip`,
64
+ `${process.cwd()}/file`,
65
+ ]);
66
+ });
67
+ });
68
+ describe('cleaning when error occurs', () => {
69
+ it('calls cleaner when downloader throws an error', async () => {
70
+ services_1.download.mockImplementationOnce(async () => { throw new Error(); });
71
+ await expect(runSdkInstallerWithDefinedZipPath).rejects.toBeInstanceOf(Error);
72
+ expect(services_1.clean).toBeCalledTimes(1);
73
+ });
74
+ it('calls cleaner when unzipper throws an error', async () => {
75
+ services_1.unzip.mockImplementationOnce(() => { throw new Error(); });
76
+ await expect(runSdkInstallerWithDefinedZipPath).rejects.toBeInstanceOf(Error);
77
+ expect(services_1.clean).toBeCalledTimes(1);
78
+ });
79
+ it('calls cleaner when installer throws an error', async () => {
80
+ services_1.install.mockImplementationOnce(() => { throw new Error(); });
81
+ await expect(runSdkInstallerWithDefinedZipPath).rejects.toBeInstanceOf(Error);
82
+ expect(services_1.clean).toBeCalledTimes(1);
83
+ });
84
+ });
85
+ });
@@ -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
+ (0, 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 (0, 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 (0, 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 (0, 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 (0, 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 (0, 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 (0, 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 (0, 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 (0, 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 (0, 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
+ (0, 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
+ (0, 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 = (0, 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
+ (0, 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
+ (0, services_1.unzip)('');
45
+ }).toThrow(new Error('error'));
46
+ });
47
+ });
@@ -0,0 +1,82 @@
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.Resolvers = exports.Constants = void 0;
23
+ const rnv_1 = require("rnv");
24
+ const Constants = __importStar(require("./constants"));
25
+ exports.Constants = Constants;
26
+ const Resolvers = __importStar(require("./resolvers"));
27
+ exports.Resolvers = Resolvers;
28
+ const CNF = __importStar(require("../../renative.engine.json"));
29
+ const constants_1 = require("./constants");
30
+ const engineTasks_1 = require("./tasks/engineTasks");
31
+ const { generateEngineTasks } = rnv_1.EngineManager;
32
+ const generateEngineExtensions = (platformExtensions) => {
33
+ const fileExtensions = ['js', 'jsx', 'ts', 'tsx', 'json'];
34
+ const output = [];
35
+ fileExtensions.forEach((fileExtension) => {
36
+ platformExtensions.forEach((platformExtension) => {
37
+ output.push(`${platformExtension}.${fileExtension}`);
38
+ });
39
+ output.push(fileExtension);
40
+ });
41
+ return output;
42
+ };
43
+ exports.default = {
44
+ initializeRuntimeConfig: (c) => rnv_1.Config.initializeConfig(c),
45
+ tasks: generateEngineTasks(engineTasks_1.engineTaskList),
46
+ config: CNF,
47
+ projectDirName: 'project',
48
+ serverDirName: 'server',
49
+ ejectPlatform: null,
50
+ platforms: {
51
+ [constants_1.Platforms.ENTONE]: {
52
+ extenstions: generateEngineExtensions(['entone']),
53
+ defaultPort: 8094,
54
+ isWebHosted: true,
55
+ },
56
+ [constants_1.Platforms.HBBTV]: {
57
+ extenstions: generateEngineExtensions(['hbbtv.tv']),
58
+ defaultPort: 8095,
59
+ isWebHosted: true,
60
+ },
61
+ [constants_1.Platforms.SAPHI]: {
62
+ extenstions: generateEngineExtensions(['saphi.tv']),
63
+ defaultPort: 8096,
64
+ isWebHosted: true,
65
+ },
66
+ [constants_1.Platforms.TIZEN]: {
67
+ extenstions: generateEngineExtensions(['tizen.tv']),
68
+ defaultPort: 8087,
69
+ isWebHosted: true,
70
+ },
71
+ [constants_1.Platforms.WEBOS]: {
72
+ extenstions: generateEngineExtensions(['webos.tv']),
73
+ defaultPort: 8088,
74
+ isWebHosted: true,
75
+ },
76
+ [constants_1.Platforms.WEBTV]: {
77
+ extenstions: generateEngineExtensions(['webtv']),
78
+ defaultPort: 8080,
79
+ isWebHosted: true,
80
+ },
81
+ },
82
+ };
package/dist/src/index.js CHANGED
@@ -20,63 +20,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.Resolvers = exports.Constants = void 0;
23
- const rnv_1 = require("rnv");
24
- const Constants = __importStar(require("./constants"));
25
- exports.Constants = Constants;
26
- const Resolvers = __importStar(require("./resolvers"));
27
- exports.Resolvers = Resolvers;
28
- const CNF = __importStar(require("../../renative.engine.json"));
29
- const constants_1 = require("./constants");
30
- const engineTasks_1 = require("./tasks/engineTasks");
31
- const { generateEngineTasks } = rnv_1.EngineManager;
32
- const generateEngineExtensions = (platformExtensions) => {
33
- const fileExtensions = ['js', 'jsx', 'ts', 'tsx', 'json'];
34
- const output = [];
35
- fileExtensions.forEach((fileExtension) => {
36
- platformExtensions.forEach((platformExtension) => {
37
- output.push(`${platformExtension}.${fileExtension}`);
38
- });
39
- output.push(fileExtension);
40
- });
41
- return output;
42
- };
43
- exports.default = {
44
- initializeRuntimeConfig: (c) => rnv_1.Config.initializeConfig(c),
45
- tasks: generateEngineTasks(engineTasks_1.engineTaskList),
46
- config: CNF,
47
- projectDirName: 'project',
48
- serverDirName: 'server',
49
- ejectPlatform: null,
50
- platforms: {
51
- [constants_1.Platforms.ENTONE]: {
52
- extenstions: generateEngineExtensions(['entone']),
53
- defaultPort: 8094,
54
- isWebHosted: true,
55
- },
56
- [constants_1.Platforms.HBBTV]: {
57
- extenstions: generateEngineExtensions(['hbbtv.tv']),
58
- defaultPort: 8095,
59
- isWebHosted: true,
60
- },
61
- [constants_1.Platforms.SAPHI]: {
62
- extenstions: generateEngineExtensions(['saphi.tv']),
63
- defaultPort: 8096,
64
- isWebHosted: true,
65
- },
66
- [constants_1.Platforms.TIZEN]: {
67
- extenstions: generateEngineExtensions(['tizen.tv']),
68
- defaultPort: 8087,
69
- isWebHosted: true,
70
- },
71
- [constants_1.Platforms.WEBOS]: {
72
- extenstions: generateEngineExtensions(['webos.tv']),
73
- defaultPort: 8088,
74
- isWebHosted: true,
75
- },
76
- [constants_1.Platforms.WEBTV]: {
77
- extenstions: generateEngineExtensions(['webtv']),
78
- defaultPort: 8080,
79
- isWebHosted: true,
80
- },
81
- },
82
- };
23
+ const engine_1 = __importStar(require("./engine"));
24
+ Object.defineProperty(exports, "Constants", { enumerable: true, get: function () { return engine_1.Constants; } });
25
+ Object.defineProperty(exports, "Resolvers", { enumerable: true, get: function () { return engine_1.Resolvers; } });
26
+ exports.default = engine_1.default;
@@ -4,7 +4,7 @@ exports.resolveBaseUrl = void 0;
4
4
  const resolveGenericRnvConfig_1 = require("./resolveGenericRnvConfig");
5
5
  const constants_1 = require("../constants");
6
6
  const resolveBaseUrl = ({ platform, scheme, flavour }) => {
7
- const c = resolveGenericRnvConfig_1.getBaseConfig();
7
+ const c = (0, resolveGenericRnvConfig_1.getBaseConfig)();
8
8
  c.platform = platform;
9
9
  c.runtime.scheme = scheme;
10
10
  c.runtime.appId = flavour;
@@ -17,7 +17,7 @@ const getBuildVersionForFileName = (c) => {
17
17
  case constants_1.BuildSchemes.RELEASE_LATEST:
18
18
  return 'latest.release';
19
19
  default:
20
- return resolveBuildVersion_1.resolveBuildVersion({
20
+ return (0, resolveBuildVersion_1.resolveBuildVersion)({
21
21
  platform,
22
22
  scheme,
23
23
  flavour: appId,
@@ -29,7 +29,7 @@ const resolveBuildFileName = (c) => {
29
29
  const appNameInFileName = getConfigProp(c, platformName, 'appNameInFileName', '');
30
30
  const buildVersion = getBuildVersionForFileName(c);
31
31
  const appConfigId = c.runtime.appId || '';
32
- const extension = resolveBuildFileExtension_1.resolveBuildFileExtension(platformName);
32
+ const extension = (0, resolveBuildFileExtension_1.resolveBuildFileExtension)(platformName);
33
33
  return `${appNameInFileName}_${platformName}_${buildVersion}_${appConfigId}.${extension}`;
34
34
  };
35
35
  exports.resolveBuildFileName = resolveBuildFileName;
@@ -24,13 +24,13 @@ const resolveBuildType = (c) => {
24
24
  }
25
25
  };
26
26
  const resolveVersionOffset = (c) => {
27
- const versionOffsetString = resolveBuildVersionOffset_1.resolveBuildVersionOffset(c);
27
+ const versionOffsetString = (0, resolveBuildVersionOffset_1.resolveBuildVersionOffset)(c);
28
28
  return versionOffsetString
29
29
  ? `-${versionOffsetString}`
30
30
  : '';
31
31
  };
32
32
  const resolveBuildVersion = ({ platform, scheme, flavour }) => {
33
- const c = resolveGenericRnvConfig_1.getBaseConfig();
33
+ const c = (0, resolveGenericRnvConfig_1.getBaseConfig)();
34
34
  c.platform = platform;
35
35
  c.runtime.scheme = scheme;
36
36
  c.runtime.appId = flavour;
@@ -6,14 +6,14 @@ const getCurrentGitBranchName = () => {
6
6
  if (process.env.BRANCH)
7
7
  return process.env.BRANCH;
8
8
  const gitCommand = 'git branch --show-current';
9
- return child_process_1.execSync(gitCommand, { stdio: 'pipe' }).toString().trim();
9
+ return (0, child_process_1.execSync)(gitCommand, { stdio: 'pipe' }).toString().trim();
10
10
  };
11
11
  const getMergedPullRequestsOffsetFromBranch = (branch) => {
12
12
  const defaultValue = '';
13
13
  const mergeTitleRegex = '^Merge pull request #';
14
14
  const cmd = `git rev-list --count --merges --grep="${mergeTitleRegex}" HEAD ^origin/${branch}`;
15
15
  try {
16
- const diffCount = child_process_1.execSync(cmd, { stdio: 'pipe' }).toString().trim();
16
+ const diffCount = (0, child_process_1.execSync)(cmd, { stdio: 'pipe' }).toString().trim();
17
17
  const diffCountNumeric = parseInt(diffCount, 10);
18
18
  return diffCountNumeric > 0 ? String(diffCountNumeric) : defaultValue;
19
19
  }