@24i/smartapps-bigscreen-rnv-build-engine 0.17.0 → 0.17.1-alpha.2054

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 (41) hide show
  1. package/README.md +3 -1
  2. package/dist/src/constants/platforms.js +1 -0
  3. package/dist/src/engine.js +5 -0
  4. package/dist/src/scripts/release/urlsMarkdown.js +1 -0
  5. package/dist/src/sdks/sdk-xbox/sdkXbox.js +1 -1
  6. package/dist/src/tasks/task.rnv.build.js +1 -0
  7. package/dist/src/tasks/task.rnv.configure.js +1 -0
  8. package/dist/src/tasks/task.rnv.deploy.js +1 -0
  9. package/dist/src/tasks/task.rnv.project.configure.js +1 -1
  10. package/dist/src/tasks/task.rnv.start.js +1 -0
  11. package/dist/templates/platforms/_shared/webpack.base.js +8 -8
  12. package/docs/PLATFORM_ADD.md +1 -1
  13. package/package.json +7 -7
  14. package/renative.engine.json +1 -0
  15. package/dist/src/__tests__/engine.spec.js +0 -57
  16. package/dist/src/__tests__/resolvers/resolveBaseUrl.spec.js +0 -99
  17. package/dist/src/__tests__/resolvers/resolveBuildFileExtension.spec.js +0 -26
  18. package/dist/src/__tests__/resolvers/resolveBuildFileName.spec.js +0 -89
  19. package/dist/src/__tests__/resolvers/resolveBuildVersion.spec.js +0 -50
  20. package/dist/src/__tests__/resolvers/resolveBuildVersionOffset.spec.js +0 -111
  21. package/dist/src/__tests__/resolvers/resolveDeployLocations.spec.js +0 -98
  22. package/dist/src/__tests__/resolvers/resolveGenericRnvConfig.spec.js +0 -92
  23. package/dist/src/__tests__/resolvers/resolveHbbtvDeployConfig.spec.js +0 -35
  24. package/dist/src/__tests__/resolvers/resolveHbbtvDeployUrl.spec.js +0 -41
  25. package/dist/src/__tests__/resolvers/resolveHbbtvRemoteBuildDirRelativePath.spec.js +0 -49
  26. package/dist/src/__tests__/resolvers/resolveSupportedPlatforms.spec.js +0 -22
  27. package/dist/src/__tests__/resolvers/resolveUsedFlavours.spec.js +0 -38
  28. package/dist/src/__tests__/resolvers/resolveZippedPlatformBuildsRelativeFilePath.spec.js +0 -18
  29. package/dist/src/__tests__/sdks/sdk-utils/registerSdkPath.spec.js +0 -60
  30. package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/sdkInstaller.spec.js +0 -85
  31. package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/clean.spec.js +0 -50
  32. package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/download.spec.js +0 -103
  33. package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/install.spec.js +0 -57
  34. package/dist/src/__tests__/sdks/sdk-utils/sdk-installer/services/unzip.spec.js +0 -51
  35. package/dist/src/__tests__/utils/forEachSupportedPlatformFlavour.spec.js +0 -104
  36. package/dist/src/__tests__/utils/generatePngSpriteMap.spec.js +0 -81
  37. package/dist/src/__tests__/utils/generateSvgSpriteMap.spec.js +0 -108
  38. package/dist/src/__tests__/utils/mergeSvgAndPngIcons.spec.js +0 -112
  39. package/dist/src/__tests__/utils/replaceRelevantStringsInConfig/replaceRelevantStringsInConfig.spec.js +0 -116
  40. package/dist/src/__tests__/utils/replaceRelevantStringsInConfig/replaceTemplateString.spec.js +0 -65
  41. package/dist/src/__tests__/utils/zipBuildsByPlatforms.spec.js +0 -69
@@ -1,111 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const child_process_1 = require("child_process");
4
- const resolveBuildVersionOffset_1 = require("../../resolvers/resolveBuildVersionOffset");
5
- const c = {
6
- buildConfig: {
7
- common: {
8
- git: {
9
- branchNames: {
10
- dev: 'DEV',
11
- rc: 'RC',
12
- dist: 'DIST',
13
- },
14
- },
15
- },
16
- },
17
- };
18
- jest.mock('child_process');
19
- describe('resolveBuildVersionOffset', () => {
20
- const oldEnv = process.env;
21
- beforeEach(() => {
22
- process.env = { ...oldEnv };
23
- });
24
- afterEach(() => {
25
- jest.clearAllMocks();
26
- jest.resetAllMocks();
27
- jest.resetModules();
28
- });
29
- afterAll(() => {
30
- process.env = oldEnv;
31
- });
32
- it('resolve process.env.BRANCH as a current branch when it is set', () => {
33
- child_process_1.execSync.mockImplementation(() => '');
34
- process.env.BRANCH = 'DEV';
35
- (0, resolveBuildVersionOffset_1.resolveBuildVersionOffset)(c);
36
- expect(child_process_1.execSync.mock.calls).toHaveLength(1);
37
- const firstCalledCmd = child_process_1.execSync.mock.calls[0][0];
38
- expect(firstCalledCmd).not.toBe('git branch --show-current');
39
- });
40
- it('uses git command to resolve current branch when process.env.BRANCH is not set', () => {
41
- child_process_1.execSync.mockImplementation(() => '');
42
- (0, resolveBuildVersionOffset_1.resolveBuildVersionOffset)(c);
43
- expect(child_process_1.execSync.mock.calls).toHaveLength(1);
44
- const firstCalledCmd = child_process_1.execSync.mock.calls[0][0];
45
- expect(firstCalledCmd).toBe('git branch --show-current');
46
- });
47
- it('compares against DIST branch when current branch is DEV', () => {
48
- child_process_1.execSync.mockImplementation((cmd) => {
49
- if (cmd === 'git branch --show-current')
50
- return 'DEV';
51
- return '';
52
- });
53
- (0, resolveBuildVersionOffset_1.resolveBuildVersionOffset)(c);
54
- expect(child_process_1.execSync.mock.calls).toHaveLength(2);
55
- const secondCalledCmd = child_process_1.execSync.mock.calls[1][0];
56
- expect(secondCalledCmd).toBe('git rev-list --count --merges --grep="^Merge pull request #" HEAD ^origin/DIST');
57
- });
58
- it('compares against DEV branch when current branch is RC', () => {
59
- child_process_1.execSync.mockImplementation((cmd) => {
60
- if (cmd === 'git branch --show-current')
61
- return 'RC';
62
- return '';
63
- });
64
- (0, resolveBuildVersionOffset_1.resolveBuildVersionOffset)(c);
65
- expect(child_process_1.execSync.mock.calls).toHaveLength(2);
66
- const secondCalledCmd = child_process_1.execSync.mock.calls[1][0];
67
- expect(secondCalledCmd).toBe('git rev-list --count --merges --grep="^Merge pull request #" HEAD ^origin/DEV');
68
- });
69
- it('returns empty string when current branch is not DEV or RC', () => {
70
- child_process_1.execSync.mockImplementation((cmd) => {
71
- if (cmd === 'git branch --show-current')
72
- return 'ANY_BRANCH';
73
- return '';
74
- });
75
- expect((0, resolveBuildVersionOffset_1.resolveBuildVersionOffset)(c)).toBe('');
76
- expect(child_process_1.execSync.mock.calls).toHaveLength(1);
77
- });
78
- it('returns empty string when there is no version offset', () => {
79
- child_process_1.execSync.mockImplementation((cmd) => {
80
- if (cmd === 'git branch --show-current')
81
- return 'DEV';
82
- if (cmd.startsWith('git rev-list --count --merges'))
83
- return '0';
84
- return '';
85
- });
86
- expect((0, resolveBuildVersionOffset_1.resolveBuildVersionOffset)(c)).toBe('');
87
- expect(child_process_1.execSync.mock.calls).toHaveLength(2);
88
- });
89
- it('returns version offset as string', () => {
90
- child_process_1.execSync.mockImplementation((cmd) => {
91
- if (cmd === 'git branch --show-current')
92
- return 'DEV';
93
- if (cmd.startsWith('git rev-list --count --merges'))
94
- return '10';
95
- return '';
96
- });
97
- expect((0, resolveBuildVersionOffset_1.resolveBuildVersionOffset)(c)).toBe('10');
98
- expect(child_process_1.execSync.mock.calls).toHaveLength(2);
99
- });
100
- it('returns empty string when git rev-list cmd throws an error', () => {
101
- child_process_1.execSync.mockImplementation((cmd) => {
102
- if (cmd === 'git branch --show-current')
103
- return 'DEV';
104
- if (cmd.startsWith('git rev-list --count --merges'))
105
- throw new Error('test error');
106
- return '';
107
- });
108
- expect((0, resolveBuildVersionOffset_1.resolveBuildVersionOffset)(c)).toBe('');
109
- expect(child_process_1.execSync.mock.calls).toHaveLength(2);
110
- });
111
- });
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resolveGenericRnvConfig_1 = require("../../resolvers/resolveGenericRnvConfig");
4
- const resolveDeployLocations_1 = require("../../resolvers/resolveDeployLocations");
5
- const resolveBuildVersionOffset_1 = require("../../resolvers/resolveBuildVersionOffset");
6
- const constants_1 = require("../../constants");
7
- jest.mock('../../resolvers/resolveGenericRnvConfig');
8
- jest.mock('../../resolvers/resolveBuildVersionOffset');
9
- const c = {
10
- platform: constants_1.Platforms.WEBTV,
11
- runtime: {
12
- scheme: constants_1.BuildSchemes.RELEASE_LATEST,
13
- appId: 'flavour1',
14
- },
15
- buildConfig: {
16
- defaults: { supportedPlatforms: [constants_1.Platforms.TIZEN, constants_1.Platforms.WEBTV, constants_1.Platforms.HBBTV, constants_1.Platforms.XBOX] },
17
- common: {
18
- appNameInFileName: 'appName',
19
- packageVersion: '1.0.0',
20
- deploy: {
21
- aws3: {
22
- bucketName: 'bucketName',
23
- },
24
- },
25
- },
26
- platforms: {
27
- tizen: {
28
- deploy: {
29
- supportedFlavours: ['flavour1', 'flavour2'],
30
- },
31
- },
32
- webtv: {
33
- deploy: {
34
- supportedFlavours: ['flavour1'],
35
- },
36
- },
37
- hbbtv: {
38
- deploy: {
39
- supportedFlavours: ['flavour3'],
40
- },
41
- },
42
- xbox: {
43
- deploy: {
44
- supportedFlavours: ['flavour1'],
45
- },
46
- },
47
- },
48
- },
49
- };
50
- describe('resolveDeployLocations', () => {
51
- resolveGenericRnvConfig_1.getBaseConfig.mockReturnValue(c);
52
- resolveBuildVersionOffset_1.resolveBuildVersionOffset.mockReturnValue('');
53
- afterAll(() => {
54
- jest.clearAllMocks();
55
- jest.resetAllMocks();
56
- jest.resetModules();
57
- });
58
- it('returns object with correct structure', () => {
59
- const resolvedDeployLocations = (0, resolveDeployLocations_1.resolveDeployLocations)(c);
60
- const bucketBaseUrl = 'http://bucketName.s3.amazonaws.com';
61
- expect(resolvedDeployLocations).toStrictEqual({
62
- versions: {
63
- 'v1.0.0': {
64
- platforms: {
65
- hbbtv: {
66
- flavour3: {
67
- indexUrl: 'http://nxg-bigscreen-test.24imedia.tv/appName/flavour3/latest/release/public/index.html',
68
- packageUrl: `${bucketBaseUrl}/builds/hbbtv/flavour3/latest/release/build/appName_hbbtv_latest.release_flavour3.zip`,
69
- },
70
- },
71
- tizen: {
72
- flavour1: {
73
- indexUrl: `${bucketBaseUrl}/builds/tizen/flavour1/latest/release/public/index.html`,
74
- packageUrl: `${bucketBaseUrl}/builds/tizen/flavour1/latest/release/build/appName_tizen_latest.release_flavour1.wgt`,
75
- },
76
- flavour2: {
77
- indexUrl: `${bucketBaseUrl}/builds/tizen/flavour2/latest/release/public/index.html`,
78
- packageUrl: `${bucketBaseUrl}/builds/tizen/flavour2/latest/release/build/appName_tizen_latest.release_flavour2.wgt`,
79
- },
80
- },
81
- webtv: {
82
- flavour1: {
83
- indexUrl: `${bucketBaseUrl}/builds/webtv/flavour1/latest/release/public/index.html`,
84
- packageUrl: `${bucketBaseUrl}/builds/webtv/flavour1/latest/release/build/appName_webtv_latest.release_flavour1.zip`,
85
- },
86
- },
87
- xbox: {
88
- flavour1: {
89
- indexUrl: `${bucketBaseUrl}/builds/xbox/flavour1/latest/release/public/index.html`,
90
- packageUrl: `${bucketBaseUrl}/builds/xbox/flavour1/latest/release/build/appName_xbox_latest.release_flavour1.zip`,
91
- },
92
- },
93
- },
94
- },
95
- },
96
- });
97
- });
98
- });
@@ -1,92 +0,0 @@
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 rnv_1 = require("rnv");
7
- const fs_1 = __importDefault(require("fs"));
8
- const resolveGenericRnvConfig_1 = require("../../resolvers/resolveGenericRnvConfig");
9
- jest.mock('rnv');
10
- jest.mock('fs');
11
- const packageJson = { version: '1.2.3', foo: 'bar' };
12
- const rootRenativeJson = {
13
- rootProp: 'rootValue',
14
- common: { rootProp0: 'rootValue0', rootProp1: 'rootValue1' },
15
- };
16
- const baseFlavourRenativeJson = {
17
- common: { rootProp0: 'overwrittenByFlavourValue', flavourProp: 'flavourValue' },
18
- flavourProp: 'flavourValue',
19
- };
20
- describe('getBaseConfig', () => {
21
- rnv_1.ConfigManager.createRnvConfig.mockReturnValue({
22
- files: { project: {} },
23
- paths: {
24
- project: {
25
- config: '/path/to/project/renative.json',
26
- appConfigBase: { dir: '/path/to/project/appConfigs/base/renative.json' },
27
- },
28
- },
29
- });
30
- fs_1.default.readFileSync.mockImplementation((path) => {
31
- const spaces = 4;
32
- if (path.endsWith('package.json')) {
33
- return JSON.stringify(packageJson, null, spaces);
34
- }
35
- if (path.endsWith('renative.json')) {
36
- if (path.includes('appConfigs/base/')) {
37
- return JSON.stringify(baseFlavourRenativeJson, null, spaces);
38
- }
39
- return JSON.stringify(rootRenativeJson, null, spaces);
40
- }
41
- return null;
42
- });
43
- afterAll(() => {
44
- jest.clearAllMocks();
45
- jest.resetAllMocks();
46
- jest.resetModules();
47
- });
48
- it('returns object with merged data from package.json file', () => {
49
- const c = (0, resolveGenericRnvConfig_1.getBaseConfig)();
50
- expect(c.files.project.package).toStrictEqual(packageJson);
51
- });
52
- it('merges root renative.json from project root and renative.json from base flavour', () => {
53
- const c = (0, resolveGenericRnvConfig_1.getBaseConfig)();
54
- expect(c.buildConfig).toStrictEqual({
55
- rootProp: 'rootValue',
56
- flavourProp: 'flavourValue',
57
- common: {
58
- rootProp0: 'overwrittenByFlavourValue',
59
- rootProp1: 'rootValue1',
60
- flavourProp: 'flavourValue',
61
- },
62
- });
63
- });
64
- it('returns with resolved template values', () => {
65
- fs_1.default.readFileSync.mockImplementation((path) => {
66
- const spaces = 4;
67
- if (path.endsWith('package.json')) {
68
- return JSON.stringify({}, null, spaces);
69
- }
70
- if (path.endsWith('renative.json')) {
71
- if (path.includes('appConfigs/base/')) {
72
- return JSON.stringify({}, null, spaces);
73
- }
74
- return JSON.stringify({
75
- common: {
76
- prop1: 'value',
77
- prop2: '{{c.buildConfig.common.prop1}}',
78
- },
79
- }, null, spaces);
80
- }
81
- console.log(path);
82
- return null;
83
- });
84
- const c = (0, resolveGenericRnvConfig_1.getBaseConfig)();
85
- expect(c.buildConfig).toStrictEqual({
86
- common: {
87
- prop1: 'value',
88
- prop2: 'value',
89
- },
90
- });
91
- });
92
- });
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resolveHbbtvDeployConfig_1 = require("../../resolvers/resolveHbbtvDeployConfig");
4
- describe('resolveHbbtvDeployConfig', () => {
5
- it('returns object with defined "host" value', () => {
6
- expect(typeof (0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().host).toBe('string');
7
- expect((0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().host.length).toBeGreaterThan(0);
8
- });
9
- it('returns object with defined "username" value', () => {
10
- expect(typeof (0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().username).toBe('string');
11
- expect((0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().username.length).toBeGreaterThan(0);
12
- });
13
- it('returns object with defined "privateKeyRelativePath" value', () => {
14
- expect(typeof (0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().privateKeyRelativePath).toBe('string');
15
- expect((0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().privateKeyRelativePath.length).toBeGreaterThan(0);
16
- });
17
- it('returns object with "passphrase" value obtained from environment', () => {
18
- const originalPassphraseValue = process.env.CI_SSH_KEY_PASSPHRASE;
19
- process.env.CI_SSH_KEY_PASSPHRASE = 'password';
20
- expect((0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().passphrase).toBe('password');
21
- process.env.CI_SSH_KEY_PASSPHRASE = originalPassphraseValue;
22
- });
23
- it('returns object with defined "hostHomeDir" value', () => {
24
- expect(typeof (0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().hostHomeDir).toBe('string');
25
- expect((0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().hostHomeDir.length).toBeGreaterThan(0);
26
- });
27
- it('returns object with defined "dockerHtmlRootDir" value', () => {
28
- expect(typeof (0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().dockerHtmlRootDir).toBe('string');
29
- expect((0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().dockerHtmlRootDir.length).toBeGreaterThan(0);
30
- });
31
- it('returns object with defined "dockerContainerName" value', () => {
32
- expect(typeof (0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().dockerContainerName).toBe('string');
33
- expect((0, resolveHbbtvDeployConfig_1.resolveHbbtvDeployConfig)().dockerContainerName.length).toBeGreaterThan(0);
34
- });
35
- });
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resolveHbbtvDeployUrl_1 = require("../../resolvers/resolveHbbtvDeployUrl");
4
- const constants_1 = require("../../constants");
5
- describe('resolveHbbtvDeployUrl', () => {
6
- const baseUrl = 'http://nxg-bigscreen-test.24imedia.tv';
7
- const c = {
8
- buildConfig: {
9
- common: {
10
- appNameInFileName: 'appName',
11
- packageVersion: '1.0.0',
12
- },
13
- },
14
- };
15
- it('returns proper URL for "latest development" build schemes', () => {
16
- expect((0, resolveHbbtvDeployUrl_1.resolveHbbtvDeployUrl)(c, constants_1.BuildSchemes.DEV_LATEST, 'flavour')).toBe(`${baseUrl}/appName/flavour/latest/dev/public/index.html`);
17
- });
18
- it('returns proper URL for "latest release candidate" build schemes', () => {
19
- expect((0, resolveHbbtvDeployUrl_1.resolveHbbtvDeployUrl)(c, constants_1.BuildSchemes.RC_LATEST, 'flavour')).toBe(`${baseUrl}/appName/flavour/latest/rc/public/index.html`);
20
- });
21
- it('returns proper URL for "latest release" build schemes', () => {
22
- expect((0, resolveHbbtvDeployUrl_1.resolveHbbtvDeployUrl)(c, constants_1.BuildSchemes.RELEASE_LATEST, 'flavour')).toBe(`${baseUrl}/appName/flavour/latest/release/public/index.html`);
23
- });
24
- it('returns proper URL for "distribution release" build schemes', () => {
25
- expect((0, resolveHbbtvDeployUrl_1.resolveHbbtvDeployUrl)(c, constants_1.BuildSchemes.RELEASE_DIST, 'flavour')).toBe(`${baseUrl}/appName/flavour/dist/v1.0.0/public/index.html`);
26
- });
27
- it('returns empty string for all other build schemes', () => {
28
- const ignoredBuildSchemes = [
29
- constants_1.BuildSchemes.DEV_LATEST,
30
- constants_1.BuildSchemes.RC_LATEST,
31
- constants_1.BuildSchemes.RELEASE_LATEST,
32
- constants_1.BuildSchemes.RELEASE_DIST,
33
- ];
34
- Object
35
- .values(constants_1.BuildSchemes)
36
- .filter((scheme) => !ignoredBuildSchemes.includes(scheme))
37
- .forEach((schemeButNotAnyIgnored) => {
38
- expect((0, resolveHbbtvDeployUrl_1.resolveHbbtvDeployUrl)(c, schemeButNotAnyIgnored, 'flavour')).toBe('');
39
- });
40
- });
41
- });
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resolveHbbtvRemoteBuildDirRelativePath_1 = require("../../resolvers/resolveHbbtvRemoteBuildDirRelativePath");
4
- const constants_1 = require("../../constants");
5
- describe('resolveHbbtvRemoteBuildDirRelativePath', () => {
6
- it('returns empty string when c.buildConfig.common.appNameInFileName is not set', () => {
7
- const c = { buildConfig: { common: {} } };
8
- expect((0, resolveHbbtvRemoteBuildDirRelativePath_1.resolveHbbtvRemoteBuildDirRelativePath)(c, constants_1.BuildSchemes.DEV_LATEST, 'flavour')).toBe('');
9
- });
10
- it('returns empty string when flavour is not set', () => {
11
- const c = { buildConfig: { common: { appNameInFileName: 'appName' } } };
12
- expect((0, resolveHbbtvRemoteBuildDirRelativePath_1.resolveHbbtvRemoteBuildDirRelativePath)(c, constants_1.BuildSchemes.DEV_LATEST, '')).toBe('');
13
- });
14
- it('returns proper path for "latest development" build scheme', () => {
15
- const c = { buildConfig: { common: { appNameInFileName: 'appName' } } };
16
- expect((0, resolveHbbtvRemoteBuildDirRelativePath_1.resolveHbbtvRemoteBuildDirRelativePath)(c, constants_1.BuildSchemes.DEV_LATEST, 'flavour')).toBe('appName/flavour/latest/dev');
17
- });
18
- it('returns proper path for "latest release candidate" build scheme', () => {
19
- const c = { buildConfig: { common: { appNameInFileName: 'appName' } } };
20
- expect((0, resolveHbbtvRemoteBuildDirRelativePath_1.resolveHbbtvRemoteBuildDirRelativePath)(c, constants_1.BuildSchemes.RC_LATEST, 'flavour')).toBe('appName/flavour/latest/rc');
21
- });
22
- it('returns proper path for "latest release" build scheme', () => {
23
- const c = { buildConfig: { common: { appNameInFileName: 'appName' } } };
24
- expect((0, resolveHbbtvRemoteBuildDirRelativePath_1.resolveHbbtvRemoteBuildDirRelativePath)(c, constants_1.BuildSchemes.RELEASE_LATEST, 'flavour')).toBe('appName/flavour/latest/release');
25
- });
26
- it('returns proper path for "distribution release" build scheme', () => {
27
- expect((0, resolveHbbtvRemoteBuildDirRelativePath_1.resolveHbbtvRemoteBuildDirRelativePath)({
28
- buildConfig: { common: { appNameInFileName: 'appName', packageVersion: '1.0.0' } },
29
- }, constants_1.BuildSchemes.RELEASE_DIST, 'flavour')).toBe('appName/flavour/dist/v1.0.0');
30
- expect((0, resolveHbbtvRemoteBuildDirRelativePath_1.resolveHbbtvRemoteBuildDirRelativePath)({
31
- buildConfig: { common: { appNameInFileName: 'appName' } },
32
- }, constants_1.BuildSchemes.RELEASE_DIST, 'flavour')).toBe('');
33
- });
34
- it('returns empty string for all other build schemes', () => {
35
- const c = { buildConfig: { common: { appNameInFileName: 'appName' } } };
36
- const ignoredBuildSchemes = [
37
- constants_1.BuildSchemes.DEV_LATEST,
38
- constants_1.BuildSchemes.RC_LATEST,
39
- constants_1.BuildSchemes.RELEASE_LATEST,
40
- constants_1.BuildSchemes.RELEASE_DIST,
41
- ];
42
- Object
43
- .values(constants_1.BuildSchemes)
44
- .filter((scheme) => !ignoredBuildSchemes.includes(scheme))
45
- .forEach((schemeButNotAnyIgnored) => {
46
- expect((0, resolveHbbtvRemoteBuildDirRelativePath_1.resolveHbbtvRemoteBuildDirRelativePath)(c, schemeButNotAnyIgnored, 'flavour')).toBe('');
47
- });
48
- });
49
- });
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resolveSupportedPlatforms_1 = require("../../resolvers/resolveSupportedPlatforms");
4
- const constants_1 = require("../../constants");
5
- describe('resolveSupportedPlatforms', () => {
6
- it('returns empty array when c.buildConfig.defaults.supportedPlatforms is not defined', () => {
7
- const c = {
8
- buildConfig: { defaults: {} },
9
- };
10
- expect((0, resolveSupportedPlatforms_1.resolveSupportedPlatforms)(c)).toStrictEqual([]);
11
- });
12
- it('returns c.buildConfig.defaults.supportedPlatforms array when it is defined', () => {
13
- const c = {
14
- buildConfig: {
15
- defaults: {
16
- supportedPlatforms: [constants_1.Platforms.TIZEN, constants_1.Platforms.WEBOS],
17
- },
18
- },
19
- };
20
- expect((0, resolveSupportedPlatforms_1.resolveSupportedPlatforms)(c)).toStrictEqual([constants_1.Platforms.TIZEN, constants_1.Platforms.WEBOS]);
21
- });
22
- });
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resolveUsedFlavours_1 = require("../../resolvers/resolveUsedFlavours");
4
- const constants_1 = require("../../constants");
5
- describe('resolveUsedFlavours', () => {
6
- it('returns empty array when platform deploy config is not set', () => {
7
- const c = {
8
- buildConfig: {
9
- defaults: {
10
- supportedPlatforms: [constants_1.Platforms.TIZEN, constants_1.Platforms.WEBOS, constants_1.Platforms.WEBTV],
11
- },
12
- platforms: {
13
- [constants_1.Platforms.TIZEN]: {},
14
- [constants_1.Platforms.WEBOS]: { deploy: {} },
15
- },
16
- },
17
- };
18
- expect((0, resolveUsedFlavours_1.resolveUsedFlavours)(c)).toStrictEqual([]);
19
- });
20
- it('returns alphabetically sorted array with used flavours', () => {
21
- const c = {
22
- buildConfig: {
23
- defaults: {
24
- supportedPlatforms: [constants_1.Platforms.TIZEN, constants_1.Platforms.WEBOS],
25
- },
26
- platforms: {
27
- [constants_1.Platforms.TIZEN]: {
28
- deploy: { supportedFlavours: ['b', 'a'] },
29
- },
30
- [constants_1.Platforms.WEBOS]: {
31
- deploy: { supportedFlavours: ['b', 'c'] },
32
- },
33
- },
34
- },
35
- };
36
- expect((0, resolveUsedFlavours_1.resolveUsedFlavours)(c)).toStrictEqual(['a', 'b', 'c']);
37
- });
38
- });
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resolveZippedPlatformBuildsRelativeFilePath_1 = require("../../resolvers/resolveZippedPlatformBuildsRelativeFilePath");
4
- const constants_1 = require("../../constants");
5
- describe('resolveZippedPlatformBuildsRelativeFilePath', () => {
6
- it('resolves path to zipped platform builds for all platforms', () => {
7
- const c = {
8
- buildConfig: {
9
- paths: { platformBuildsDir: './dir1/dir2/dir3' },
10
- common: { appNameInFileName: 'appName', packageVersion: '1.0.0' },
11
- },
12
- };
13
- Object.values(constants_1.Platforms).forEach((platform) => {
14
- const r = (0, resolveZippedPlatformBuildsRelativeFilePath_1.resolveZippedPlatformBuildsRelativeFilePath)(c, platform);
15
- expect(r).toBe(`./dir1/dir2/dir3/zipped_by_platform/appName_${platform}_1.0.0.zip`);
16
- });
17
- });
18
- });
@@ -1,60 +0,0 @@
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
- });
@@ -1,85 +0,0 @@
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
- });