@24i/smartapps-bigscreen-rnv-build-engine 0.0.2-alpha.1321 → 0.0.2-alpha.1323

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 (64) hide show
  1. package/dist/src/index.js +3 -1
  2. package/dist/src/tasks/deploy/aswS3/deployS3.js +3 -2
  3. package/dist/src/tasks/deploy/hbbtv/deployHbbtv.js +12 -9
  4. package/dist/src/tasks/task.rnv.build.js +17 -15
  5. package/dist/src/tasks/task.rnv.configure.js +3 -1
  6. package/dist/src/tasks/task.rnv.configureSoft.js +3 -1
  7. package/dist/src/tasks/task.rnv.deploy.js +5 -2
  8. package/dist/src/tasks/task.rnv.hooks.run.js +4 -2
  9. package/dist/src/utils/forEachSupportedPlatformFlavour.js +8 -8
  10. package/dist/src/utils/getBaseConfig.js +5 -3
  11. package/dist/src/utils/getDeployLocations.js +1 -3
  12. package/dist/src/utils/getVersionOffset.js +4 -4
  13. package/dist/src/utils/replaceRelevantStringsInConfig/replaceTemplateString.js +2 -2
  14. package/engine/src/enginePlatforms.js +16 -0
  15. package/engine/src/index.js +67 -0
  16. package/engine/src/scripts/buildAllWithScheme.js +29 -0
  17. package/engine/src/scripts/gitReleaser/afterVersionBump.js +24 -0
  18. package/engine/src/scripts/gitReleaser/beforeVersionBump.js +15 -0
  19. package/engine/src/scripts/gitReleaser/checkReleaseNotes.js +22 -0
  20. package/engine/src/scripts/gitReleaser/pushRelease.js +41 -0
  21. package/engine/src/scripts/gitReleaser/pushReleaseCandidate.js +8 -0
  22. package/engine/src/scripts/gitReleaser/pushReleaseNotes.js +53 -0
  23. package/engine/src/scripts/release/deleteSourceMaps.js +14 -0
  24. package/engine/src/scripts/release/deployToAppCenter.js +79 -0
  25. package/engine/src/scripts/release/githubRelease.js +138 -0
  26. package/engine/src/scripts/release/notifySlack/makePayload.js +103 -0
  27. package/engine/src/scripts/release/notifySlack/notifySlack.js +26 -0
  28. package/engine/src/scripts/release/notifySlack/slackBlockKitBuilder.js +44 -0
  29. package/engine/src/scripts/release/sentryRelease.js +79 -0
  30. package/engine/src/scripts/release/urlsMarkdown.js +85 -0
  31. package/engine/src/scripts/releaseAllWithScheme.js +91 -0
  32. package/engine/src/scripts/utils/cmdUtils.js +16 -0
  33. package/engine/src/scripts/utils/fsUtils.js +14 -0
  34. package/engine/src/scripts/utils/gitUtils.js +94 -0
  35. package/engine/src/scripts/utils/index.js +11 -0
  36. package/engine/src/scripts/utils/stringUtils.js +5 -0
  37. package/engine/src/sdks/index.js +22 -0
  38. package/engine/src/sdks/sdk-tizen/index.js +287 -0
  39. package/engine/src/sdks/sdk-webos/index.js +201 -0
  40. package/engine/src/sdks/sdk-webpack/index.js +45 -0
  41. package/engine/src/sdks/sdkUtils.js +22 -0
  42. package/engine/src/tasks/deploy/aswS3/aws.js +27 -0
  43. package/engine/src/tasks/deploy/aswS3/deployS3.js +71 -0
  44. package/engine/src/tasks/deploy/hbbtv/deployHbbtv.js +144 -0
  45. package/engine/src/tasks/engineTasks.js +23 -0
  46. package/engine/src/tasks/task.rnv.build.js +126 -0
  47. package/engine/src/tasks/task.rnv.configure.js +52 -0
  48. package/engine/src/tasks/task.rnv.configureSoft.js +31 -0
  49. package/engine/src/tasks/task.rnv.deploy.js +40 -0
  50. package/engine/src/tasks/task.rnv.hooks.run.js +61 -0
  51. package/engine/src/tasks/task.rnv.package.js +27 -0
  52. package/engine/src/tasks/task.rnv.project.configure.js +109 -0
  53. package/engine/src/tasks/task.rnv.start.js +52 -0
  54. package/engine/src/utils/forEachSupportedPlatformFlavour.js +29 -0
  55. package/engine/src/utils/getBaseConfig.js +57 -0
  56. package/engine/src/utils/getDeployLocations.js +78 -0
  57. package/engine/src/utils/getVersionOffset.js +39 -0
  58. package/engine/src/utils/replaceRelevantStringsInConfig/index.js +1 -0
  59. package/engine/src/utils/replaceRelevantStringsInConfig/replaceRelevantStringsInConfig.js +36 -0
  60. package/engine/src/utils/replaceRelevantStringsInConfig/replaceTemplateString.js +70 -0
  61. package/engine/src/utils/resolveBaseUrl.js +35 -0
  62. package/engine/src/utils/resolveBuildVersion.js +47 -0
  63. package/engine/src/utils/zipBuildsByPlatforms.js +70 -0
  64. package/package.json +4 -3
@@ -0,0 +1,109 @@
1
+ import { configurePlugins, overrideTemplatePlugins, resolvePluginDependants } from 'rnv/dist/core/pluginManager';
2
+ import { chalk, logTask, logInfo } from 'rnv/dist/core/systemManager/logger';
3
+ import { checkIsRenativeProject, generateRuntimeConfig } from 'rnv/dist/core/configManager';
4
+ import { updateRenativeConfigs, configureRuntimeDefaults } from 'rnv/dist/core/runtimeManager';
5
+ import { applyTemplate, checkIfTemplateConfigured, configureTemplateFiles, isTemplateInstalled } from 'rnv/dist/core/templateManager';
6
+ import { fsExistsSync, fsMkdirSync } from 'rnv/dist/core/systemManager/fileutils';
7
+ import { checkCrypto } from 'rnv/dist/core/systemManager/crypto';
8
+ import { checkAndMigrateProject } from 'rnv/dist/core/projectManager/migrator';
9
+ import { TASK_INSTALL, TASK_PROJECT_CONFIGURE, TASK_TEMPLATE_APPLY, TASK_APP_CONFIGURE, TASK_WORKSPACE_CONFIGURE, PARAMS } from 'rnv/dist/core/constants';
10
+ import { checkAndCreateBabelConfig, copyRuntimeAssets, cleanPlaformAssets, checkAndCreateGitignore, versionCheck } from 'rnv/dist/core/projectManager';
11
+ import { configureEngines, getEngineRunnerByPlatform } from 'rnv/dist/core/engineManager';
12
+ import { executeTask, initializeTask, findSuitableTask } from 'rnv/dist/core/taskManager';
13
+ import { replaceRelevantStringsInConfig } from '../utils/replaceRelevantStringsInConfig';
14
+ import * as path from 'path';
15
+
16
+ const patchEngineTemplatesPath = (c) => {
17
+ const engineTemplatesPath = path.join(process.cwd(), 'node_modules', '@24i', 'smartapps-bigscreen-rnv-build-engine', 'dist', 'templates');
18
+ const engine = getEngineRunnerByPlatform(c, c.platform);
19
+
20
+ engine.originalTemplatePlatformsDir = path.join(engineTemplatesPath, 'platforms');
21
+ engine.originalTemplateAssetsDir = path.join(engineTemplatesPath, 'assets');
22
+ engine.originalTemplatePlatformProjectDir = path.join(engineTemplatesPath, 'platforms', 'project');
23
+
24
+ c.paths.project.platformTemplatesDirs[c.platform] = engine.originalTemplatePlatformsDir;
25
+ };
26
+
27
+ export const taskRnvProjectConfigure = async (c, parentTask, originTask) => {
28
+ logTask('taskRnvProjectConfigure');
29
+
30
+ patchEngineTemplatesPath(c);
31
+
32
+ if (c.paths.project.builds.dir && !fsExistsSync(c.paths.project.builds.dir)) {
33
+ logInfo(`Creating folder ${c.paths.project.builds.dir} ...DONE`);
34
+ fsMkdirSync(c.paths.project.builds.dir);
35
+ }
36
+ await checkAndMigrateProject(c);
37
+ await updateRenativeConfigs(c);
38
+ await checkIsRenativeProject(c);
39
+ await executeTask(c, TASK_WORKSPACE_CONFIGURE, TASK_PROJECT_CONFIGURE, originTask);
40
+
41
+ if (c.program.only && !!parentTask) {
42
+ await configureRuntimeDefaults(c);
43
+ await executeTask(c, TASK_APP_CONFIGURE, TASK_PROJECT_CONFIGURE, originTask);
44
+ await generateRuntimeConfig(c);
45
+ return true;
46
+ }
47
+
48
+ await checkIfTemplateConfigured(c);
49
+ await executeTask(c, TASK_INSTALL, TASK_PROJECT_CONFIGURE, originTask);
50
+ await checkCrypto(c, parentTask, originTask);
51
+ await configureRuntimeDefaults(c);
52
+
53
+ if (originTask !== TASK_TEMPLATE_APPLY) {
54
+ if (c.runtime.requiresBootstrap || !isTemplateInstalled(c)) {
55
+ await applyTemplate(c);
56
+ // We'll have to install the template first and reset current engine
57
+ logInfo('Your template has been bootstraped. Command reset is required. RESTRATING...DONE');
58
+
59
+ const taskInstance = await findSuitableTask(c);
60
+ c.runtime.requiresBootstrap = false;
61
+ return initializeTask(c, taskInstance.task);
62
+ }
63
+ await applyTemplate(c);
64
+ await configureRuntimeDefaults(c);
65
+ await executeTask(c, TASK_INSTALL, TASK_PROJECT_CONFIGURE, originTask);
66
+ await executeTask(c, TASK_APP_CONFIGURE, TASK_PROJECT_CONFIGURE, originTask);
67
+ // IMPORTANT: configurePlugins must run after appConfig present to ensure merge of all configs/plugins
68
+ await versionCheck(c);
69
+ await configureEngines(c);
70
+ await resolvePluginDependants(c);
71
+ await configurePlugins(c);
72
+
73
+ await configureRuntimeDefaults(c);
74
+ if (!c.runtime.disableReset) {
75
+ if (c.program.resetHard) {
76
+ logInfo(
77
+ `You passed ${chalk().white('-R, --resetHard')} argument. "${chalk().white('./platformAssets')}" will be cleaned up first`
78
+ );
79
+ await cleanPlaformAssets(c);
80
+ } else if (c.program.resetAssets) {
81
+ logInfo(
82
+ `You passed ${chalk().white('-a, --resetAssets')} argument. "${chalk().white('./platformAssets')}" will be cleaned up first`
83
+ );
84
+ await cleanPlaformAssets(c);
85
+ }
86
+ }
87
+
88
+ await copyRuntimeAssets(c);
89
+ await configureTemplateFiles(c);
90
+ await checkAndCreateGitignore(c);
91
+ await checkAndCreateBabelConfig(c);
92
+ if (!c.buildConfig.platforms) {
93
+ await updateRenativeConfigs(c);
94
+ }
95
+ replaceRelevantStringsInConfig(c);
96
+ await generateRuntimeConfig(c);
97
+ await overrideTemplatePlugins(c);
98
+ }
99
+
100
+ return true;
101
+ };
102
+
103
+ export default {
104
+ description: 'Configure current project',
105
+ fn: taskRnvProjectConfigure,
106
+ task: TASK_PROJECT_CONFIGURE,
107
+ params: PARAMS.withBase(),
108
+ platforms: [],
109
+ };
@@ -0,0 +1,52 @@
1
+ import open from 'better-opn';
2
+ import { TaskManager, Constants, Logger, PlatformManager, Common, WebpackUtils } from 'rnv';
3
+ import { enginePlatformList, enginePlatforms } from '../enginePlatforms';
4
+
5
+ const { getConfigProp } = Common;
6
+ const { logErrorPlatform } = PlatformManager;
7
+ const { logTask, logError } = Logger;
8
+ const { TASK_START, TASK_CONFIGURE, REMOTE_DEBUGGER_ENABLED_PLATFORMS, PARAMS } = Constants;
9
+ const { runWebpackServer, waitForWebpack } = WebpackUtils;
10
+ const { executeTask } = TaskManager;
11
+
12
+ export const taskRnvStart = async (c, parentTask, originTask) => {
13
+ const { platform, runtime, program } = c;
14
+ const { port } = runtime;
15
+ const { hosted } = program;
16
+
17
+ logTask('taskRnvStart', `parent:${parentTask} port:${port} hosted:${!!hosted}`);
18
+
19
+ if (!parentTask) {
20
+ await executeTask(c, TASK_CONFIGURE, TASK_START, originTask);
21
+ }
22
+
23
+ if (hosted) {
24
+ waitForWebpack(c)
25
+ .then(() => open(`http://${c.runtime.localhost}:${port}/`))
26
+ .catch(logError);
27
+ }
28
+ const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets');
29
+ const isWeinreEnabled = REMOTE_DEBUGGER_ENABLED_PLATFORMS.includes(platform) && !bundleAssets && !hosted;
30
+
31
+ switch (platform) {
32
+ case enginePlatforms.ENTONE:
33
+ case enginePlatforms.HBBTV:
34
+ case enginePlatforms.TIZEN:
35
+ case enginePlatforms.WEBOS:
36
+ case enginePlatforms.WEBTV:
37
+ return runWebpackServer(c, isWeinreEnabled);
38
+ default:
39
+ if (hosted) {
40
+ return logError('This platform does not support hosted mode', true);
41
+ }
42
+ return logErrorPlatform(c);
43
+ }
44
+ };
45
+
46
+ export default {
47
+ description: 'Starts bundler / server',
48
+ fn: taskRnvStart,
49
+ task: 'start',
50
+ params: PARAMS.withBase(PARAMS.withConfigure()),
51
+ platforms: enginePlatformList,
52
+ };
@@ -0,0 +1,29 @@
1
+ const getProgressMessage = (platforms, platformIndex, flavours, flavourIndex) => {
2
+ let string = `\nProcessing "${platforms[platformIndex]}" platform`;
3
+ string += ` (${platformIndex + 1}/${platforms.length})`;
4
+ string += ` and its "${flavours[flavourIndex]}" flavour`;
5
+ string += ` (${flavourIndex + 1}/${flavours.length})...`;
6
+
7
+ return string;
8
+ };
9
+
10
+ const forEachSupportedPlatformFlavour = (c, cb) => {
11
+
12
+ const processPlatformFlavours = (platform, platformIndex, platforms) => {
13
+
14
+ const processFlavour = (flavour, flavourIndex, flavours) => {
15
+ console.log(getProgressMessage(platforms, platformIndex, flavours, flavourIndex));
16
+ return cb({ platform, flavour, scheme: c.runtime.scheme });
17
+ };
18
+
19
+ const { supportedFlavours = [] } = c.buildConfig.platforms[platform]?.deploy || {};
20
+ supportedFlavours.forEach(processFlavour);
21
+ };
22
+
23
+ const { supportedPlatforms = [] } = c.buildConfig.defaults || {};
24
+ supportedPlatforms.forEach(processPlatformFlavours);
25
+ };
26
+
27
+ export {
28
+ forEachSupportedPlatformFlavour,
29
+ };
@@ -0,0 +1,57 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import * as ConfigManager from 'rnv/dist/core/configManager';
4
+ import { replaceRelevantStringsInConfig } from './replaceRelevantStringsInConfig';
5
+
6
+ export function isObject(item) {
7
+ return (item && typeof item === 'object' && !Array.isArray(item));
8
+ }
9
+
10
+ const mergeDeep = (target, ...sources) => {
11
+ if (!sources.length) return target;
12
+
13
+ const source = sources.shift();
14
+
15
+ if (isObject(target) && isObject(source)) {
16
+ Object.keys(source).forEach((key) => {
17
+ if (isObject(source[key])) {
18
+ if (!target[key]) Object.assign(target, { [key]: {} });
19
+ mergeDeep(target[key], source[key]);
20
+ } else {
21
+ Object.assign(target, { [key]: source[key] });
22
+ }
23
+ });
24
+ }
25
+
26
+ return mergeDeep(target, ...sources);
27
+ };
28
+
29
+ const mergeFileJsonIntoObject = (filePath = '', targetObject = {}) => {
30
+ const fileContentAsString = fs.readFileSync(filePath).toString();
31
+ const fileContentAsJSON = JSON.parse(fileContentAsString);
32
+ mergeDeep(targetObject, fileContentAsJSON);
33
+ };
34
+
35
+ const getBaseConfig = () => {
36
+ const c = ConfigManager.createRnvConfig({ ci: true }, process);
37
+
38
+ c.buildConfig = {};
39
+
40
+ const packageJsonfileContent = fs.readFileSync('package.json').toString();
41
+ c.files.project.package = JSON.parse(packageJsonfileContent)
42
+
43
+ // renative.json
44
+ mergeFileJsonIntoObject(c.paths.project.config, c.buildConfig);
45
+
46
+ // appConfigs/base/renative.json
47
+ const baseConfigPath = path.join(c.paths.project.appConfigBase.dir, 'renative.json');
48
+ mergeFileJsonIntoObject(baseConfigPath, c.buildConfig);
49
+
50
+ replaceRelevantStringsInConfig(c);
51
+
52
+ return c;
53
+ };
54
+
55
+ export {
56
+ getBaseConfig,
57
+ };
@@ -0,0 +1,78 @@
1
+ import fs from 'fs';
2
+ import { getHbbTVDeployUrl } from '../tasks/deploy/hbbtv/deployHbbtv';
3
+ import { resolveBaseUrl } from './resolveBaseUrl';
4
+ import { resolveBuildVersion } from './resolveBuildVersion';
5
+
6
+ const getBuildVersion = (c) => {
7
+ const { platform, runtime } = c;
8
+ const { scheme, appId } = runtime;
9
+
10
+ return resolveBuildVersion({
11
+ platform,
12
+ scheme,
13
+ appConfigId: appId,
14
+ });
15
+ };
16
+
17
+ const getSupportedPlatforms = (c) => {
18
+ const { supportedPlatforms = [] } = c.buildConfig.defaults || {};
19
+ return supportedPlatforms;
20
+ };
21
+
22
+ const getSupportedFlavoursForPlatform = (c, platformName) => {
23
+ const { supportedFlavours = [] } = c.buildConfig.platforms[platformName]?.deploy || {};
24
+ return supportedFlavours;
25
+ };
26
+
27
+ const makeOutputObject = (buildVersion = '') => ({
28
+ versions: {
29
+ [buildVersion]: {
30
+ platforms: {},
31
+ },
32
+ },
33
+ });
34
+
35
+ const makeUrls = (c, platformName, flavourName) => {
36
+ const isHbbTVPlatform = platformName === 'hbbtv';
37
+ const baseUrl = resolveBaseUrl({
38
+ platform: platformName,
39
+ scheme: c.runtime.scheme || '',
40
+ appConfigId: flavourName,
41
+ });
42
+ if (!baseUrl) return null;
43
+
44
+ const packageOutputDirPath = `platformBuilds/${flavourName}_${platformName}/output`;
45
+ const outputFilenameList = fs.readdirSync(packageOutputDirPath);
46
+ const packageFileName = outputFilenameList[0];
47
+
48
+ const packageUrl = packageFileName ? `${baseUrl}/build/${packageFileName}` : '';
49
+ const indexUrl = isHbbTVPlatform
50
+ ? getHbbTVDeployUrl(c, c.runtime.scheme, flavourName)
51
+ : `${baseUrl}/public/index.html`;
52
+
53
+ return { packageUrl, indexUrl };
54
+ };
55
+
56
+ const getDeployLocations = (c) => {
57
+ const buildVersion = getBuildVersion(c);
58
+ const output = makeOutputObject(buildVersion);
59
+ const outputPlatforms = output.versions[buildVersion].platforms;
60
+
61
+ const processPlatform = (platformName) => {
62
+ const processPlatformFlavour = (flavourName) => ({
63
+ [flavourName]: makeUrls(c, platformName, flavourName),
64
+ });
65
+
66
+ const outputPlatformData = getSupportedFlavoursForPlatform(c, platformName)
67
+ .map(processPlatformFlavour);
68
+ outputPlatforms[platformName] = Object.assign({}, ...outputPlatformData)
69
+ };
70
+
71
+ getSupportedPlatforms(c).forEach(processPlatform);
72
+
73
+ return output;
74
+ };
75
+
76
+ export {
77
+ getDeployLocations,
78
+ };
@@ -0,0 +1,39 @@
1
+ import { execSync } from 'child_process';
2
+
3
+ const getCurrentGitBranchName = () => {
4
+ if (process.env.BRANCH) return process.env.BRANCH; // exported in Travis CI config
5
+
6
+ const gitCommand = 'git branch --show-current';
7
+ return execSync(gitCommand, { stdio: 'pipe' }).toString().trim();
8
+ };
9
+
10
+ const getMergedPullRequestsOffsetFromBranch = (branch) => {
11
+ const defaultValue = '';
12
+ const mergeTitleRegex = '^Merge pull request #'; // it's a default title for GitHub
13
+ const cmd = `git rev-list --count --merges --grep="${mergeTitleRegex}" HEAD ^origin/${branch}`;
14
+
15
+ try {
16
+ const diffCount = execSync(cmd, { stdio: 'pipe' }).toString().trim();
17
+ const diffCountNumeric = parseInt(diffCount, 10);
18
+
19
+ return diffCountNumeric > 0 ? String(diffCountNumeric) : defaultValue;
20
+ } catch (error) {
21
+ return defaultValue;
22
+ }
23
+ };
24
+
25
+ const getVersionOffset = (c) => {
26
+ const { branchNames = {} } = c.buildConfig?.common?.git || {};
27
+
28
+ switch (getCurrentGitBranchName()) {
29
+ case branchNames.dev:
30
+ return getMergedPullRequestsOffsetFromBranch(branchNames.dist);
31
+ case branchNames.rc:
32
+ return getMergedPullRequestsOffsetFromBranch(branchNames.dev);
33
+ default: return '';
34
+ }
35
+ };
36
+
37
+ export {
38
+ getVersionOffset,
39
+ };
@@ -0,0 +1 @@
1
+ export { replaceRelevantStringsInConfig } from './replaceRelevantStringsInConfig';
@@ -0,0 +1,36 @@
1
+ import { replaceTemplateString } from './replaceTemplateString';
2
+
3
+ const processObject = (c, object, excludedPropsList = []) => {
4
+ if (!object) return;
5
+ const objectKeys = Object.keys(object);
6
+
7
+ const processStringValue = (string, objectKeyName) => {
8
+ const replacedString = replaceTemplateString(c, string);
9
+ if (replacedString !== string) {
10
+ object[objectKeyName] = replacedString;
11
+ }
12
+ };
13
+
14
+ objectKeys.forEach((key) => {
15
+ const keyValue = object[key];
16
+ if (typeof keyValue === 'string') {
17
+ processStringValue(keyValue, key);
18
+ } else if (typeof keyValue === 'object' && keyValue !== null) {
19
+ if (!excludedPropsList.includes(key)) {
20
+ processObject(c, keyValue);
21
+ }
22
+ }
23
+ });
24
+ };
25
+
26
+ const replaceRelevantStringsInConfig = (c) => {
27
+ const { defaults, common, platforms } = c.buildConfig;
28
+
29
+ processObject(c, defaults);
30
+ processObject(c, common, ['']);
31
+ processObject(c, platforms);
32
+ };
33
+
34
+ export {
35
+ replaceRelevantStringsInConfig,
36
+ };
@@ -0,0 +1,70 @@
1
+ import { Common } from 'rnv';
2
+ import { getVersionOffset } from '../getVersionOffset';
3
+
4
+ const { getConfigProp } = Common;
5
+
6
+ const getValueFromConfigByStringPath = (c, stringPathToObjectProp = '') => {
7
+ const pathToPropList = stringPathToObjectProp.split('.');
8
+ const listLength = pathToPropList.length;
9
+ let currentPropValue = c;
10
+
11
+ try {
12
+ for (let i = 1; i < listLength; i++) { // i = 1 to skip processing parent (base) object
13
+ currentPropValue = currentPropValue[pathToPropList[i]];
14
+ if (currentPropValue === undefined) {
15
+ return null;
16
+ }
17
+ }
18
+ return currentPropValue;
19
+ } catch (error) {
20
+ return null;
21
+ }
22
+ };
23
+
24
+ const getValue = (c, stringInsideBracelets = '') => {
25
+ if (stringInsideBracelets.startsWith('c.')) {
26
+ return getValueFromConfigByStringPath(c, stringInsideBracelets);
27
+ }
28
+ if (stringInsideBracelets.startsWith('configProps.')) {
29
+ return getConfigProp(c, c.platform, stringInsideBracelets.replace('configProps.', ''));
30
+ }
31
+ if (stringInsideBracelets === 'BRANCH_COMMIT_OFFSET') {
32
+ return getVersionOffset(c);
33
+ }
34
+
35
+ return stringInsideBracelets;
36
+ };
37
+
38
+ const handleStringEnd = (string) => {
39
+ // string ends with "[[X]]" - instead X, there can be any char(s) except "[" and "]"
40
+ let outputString = string.replace(/\[\[[^[\]]+]]$/, '');
41
+
42
+ const matches = outputString.match(/\[\[[^[\]]+]]/g);
43
+ if (!matches || !matches.length) return outputString;
44
+
45
+ const getStringInside = (templateString = '') => templateString.slice(2, -2);
46
+ const removeBracelets = (match) => {
47
+ outputString = outputString.replace(match, getStringInside(match));
48
+ };
49
+ matches.forEach(removeBracelets);
50
+ return outputString;
51
+ };
52
+
53
+ const injectorStartMark = '{{';
54
+ const injectorEndMark = '}}';
55
+ const injectorRegexp = new RegExp(`${injectorStartMark}.*?${injectorEndMark}`, 'g');
56
+
57
+ const replaceTemplateString = (c, string = '') => {
58
+ if (!string || typeof string !== 'string') return '';
59
+ const replacer = (match) => {
60
+ const stringInBracelets = match.slice(injectorStartMark.length, -injectorEndMark.length);
61
+ const value = getValue(c, stringInBracelets);
62
+ return value === match ? value : replaceTemplateString(c, value);
63
+ };
64
+ const parsedString = string.replace(injectorRegexp, replacer);
65
+ return handleStringEnd(parsedString);
66
+ };
67
+
68
+ export {
69
+ replaceTemplateString,
70
+ };
@@ -0,0 +1,35 @@
1
+ import { getBaseConfig } from './getBaseConfig';
2
+
3
+ const resolveBaseUrl = ({ platform = '', scheme = '', appConfigId = '' }) => {
4
+ const c = getBaseConfig();
5
+ c.platform = platform;
6
+ c.runtime.scheme = scheme;
7
+ c.runtime.appConfigId = appConfigId;
8
+
9
+ const { packageVersion = '', deploy = {} } = c.buildConfig?.common || {};
10
+ const bucketName = deploy.aws3?.bucketName || '';
11
+
12
+ const bucketUrl = `http://${bucketName}.s3.amazonaws.com`;
13
+ const appFolderUrl = `${bucketUrl}/builds/${platform}/${appConfigId}`;
14
+
15
+ if (!packageVersion) {
16
+ return '';
17
+ }
18
+
19
+ switch (scheme) {
20
+ case 'dev:latest':
21
+ return `${appFolderUrl}/latest/dev`;
22
+ case 'rc:latest':
23
+ return `${appFolderUrl}/latest/rc`;
24
+ case 'release:latest':
25
+ return `${appFolderUrl}/latest/release`;
26
+ case 'release:dist':
27
+ return `${appFolderUrl}/dist/v${packageVersion}`;
28
+ default:
29
+ return '';
30
+ }
31
+ };
32
+
33
+ export {
34
+ resolveBaseUrl,
35
+ };
@@ -0,0 +1,47 @@
1
+ import { getBaseConfig } from './getBaseConfig';
2
+ import { getVersionOffset } from './getVersionOffset';
3
+
4
+ const resolvePackageVersion = (c) => c.buildConfig.common.packageVersion || '';
5
+
6
+ const resolveBuildType = (c) => {
7
+ switch (c.runtime.scheme) {
8
+ case 'debug':
9
+ return '.debug';
10
+ case 'dev':
11
+ case 'dev:latest':
12
+ return '.dev';
13
+ case 'rc':
14
+ case 'rc:latest':
15
+ return '.rc';
16
+ case 'release':
17
+ case 'release:latest':
18
+ case 'release:dist':
19
+ return '';
20
+ default:
21
+ throw new Error(`resolveBuildType: scheme "${c.runtime.scheme}" is not defined!`);
22
+ }
23
+ };
24
+
25
+ const resolveVersionOffset = (c) => {
26
+ const versionOffsetString = getVersionOffset(c);
27
+ return versionOffsetString
28
+ ? `-${versionOffsetString}`
29
+ : '';
30
+ };
31
+
32
+ const resolveBuildVersion = ({ platform = '', scheme = '', appConfigId = '' }) => {
33
+ const c = getBaseConfig();
34
+ c.platform = platform;
35
+ c.runtime.scheme = scheme;
36
+ c.runtime.appConfigId = appConfigId;
37
+
38
+ const packageVersion = resolvePackageVersion(c);
39
+ const buildType = resolveBuildType(c);
40
+ const maybeGitCommitsOffset = resolveVersionOffset(c);
41
+
42
+ return `v${packageVersion}${buildType}${maybeGitCommitsOffset}`;
43
+ };
44
+
45
+ export {
46
+ resolveBuildVersion,
47
+ };
@@ -0,0 +1,70 @@
1
+ import { mkdirSync, copyFileSync, rmdirSync } from 'fs';
2
+ import { basename, dirname } from 'path';
3
+ import { execSync } from 'child_process';
4
+ import glob from 'glob';
5
+ import { getConfigProp } from 'rnv/dist/core/common';
6
+
7
+ const zipDir = (dir, outputFile) => execSync(`zip ${outputFile} -0 -j ${dir}/*`);
8
+
9
+ const getPlatformBuildFileExtension = (platformName) => {
10
+ switch (platformName) {
11
+ case 'tizen': return 'wgt';
12
+ case 'webos': return 'ipk';
13
+ default: return 'zip';
14
+ }
15
+ };
16
+
17
+ const getPlatformBuildsPaths = (c, platformName) => {
18
+ const { platformBuildsDir } = c.buildConfig.paths;
19
+ const outputGlob = `${platformBuildsDir}/**/output`;
20
+ const platformBuildsGlob = `${outputGlob}/*.${getPlatformBuildFileExtension(platformName)}`;
21
+ const buildsPathsCandidates = glob.sync(platformBuildsGlob);
22
+
23
+ return buildsPathsCandidates.filter(
24
+ (path) => path.includes(platformName),
25
+ );
26
+ };
27
+
28
+
29
+ const getZippedPlatformBuildsFilePath = (c, platformName = '') => {
30
+ const { platformBuildsDir } = c.buildConfig.paths;
31
+ const zippedFilesParentDir = 'zipped_by_platform';
32
+ const appNameInFileName = getConfigProp(c, platformName, 'appNameInFileName', '');
33
+ const buildVersion = getConfigProp(c, platformName, 'packageVersion', '');
34
+ const fileExtension = 'zip';
35
+
36
+ const relativePathToDir = `${platformBuildsDir}/${zippedFilesParentDir}`;
37
+ const zipFileName = `${appNameInFileName}_${platformName}_${buildVersion}.${fileExtension}`;
38
+
39
+ return `${relativePathToDir}/${zipFileName}`;
40
+ };
41
+
42
+ const processPlatform = (c, platformName) => {
43
+ const platformBuildsPaths = getPlatformBuildsPaths(c, platformName);
44
+ if (platformBuildsPaths.length === 0) return;
45
+
46
+ const outputZipFilePath = getZippedPlatformBuildsFilePath(c, platformName);
47
+
48
+ const tempPlatformDir = `${dirname(outputZipFilePath)}/${platformName}`;
49
+ mkdirSync(tempPlatformDir, { recursive: true });
50
+
51
+ const copyBuildFileIntoTempPlatformDir = (buildFilePath) => {
52
+ const buildFileName = basename(buildFilePath);
53
+ const dest = `${tempPlatformDir}/${buildFileName}`;
54
+ copyFileSync(buildFilePath, dest);
55
+ };
56
+ platformBuildsPaths.forEach(copyBuildFileIntoTempPlatformDir);
57
+
58
+ zipDir(tempPlatformDir, outputZipFilePath);
59
+ rmdirSync(tempPlatformDir, { recursive: true });
60
+ };
61
+
62
+ const zipBuildsByPlatforms = (c) => {
63
+ const { supportedPlatforms = [] } = c.buildConfig.defaults || {};
64
+ supportedPlatforms.forEach((platformName) => processPlatform(c, platformName));
65
+ };
66
+
67
+ export {
68
+ zipBuildsByPlatforms,
69
+ getZippedPlatformBuildsFilePath,
70
+ };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@24i/smartapps-bigscreen-rnv-build-engine",
3
- "version": "0.0.2-alpha.1321+d729a850",
3
+ "version": "0.0.2-alpha.1323+8a3de07d",
4
4
  "description": "",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
7
7
  "build:clean": "rm -rf dist",
8
- "build:engine": "babel src -d dist/src --copy-files --include-dotfiles",
8
+ "build:engine": "babel engine/src -d dist/src --copy-files --include-dotfiles",
9
9
  "build:templates": "babel templates -d dist/templates --copy-files --include-dotfiles",
10
10
  "build": "npm run build:clean && npm run build:engine && npm run build:templates",
11
11
  "eslint": "eslint \"./src/**/*.{ts,tsx}\"",
@@ -28,6 +28,7 @@
28
28
  "glob": "7.1.7",
29
29
  "html-webpack-harddisk-plugin": "1.0.2",
30
30
  "html-webpack-plugin": "4.5.2",
31
+ "inquirer": "8.1.1",
31
32
  "mini-css-extract-plugin": "1.6.2",
32
33
  "node-ssh": "11.1.1",
33
34
  "raf": "3.4.1",
@@ -53,5 +54,5 @@
53
54
  "keywords": [],
54
55
  "author": "24i",
55
56
  "license": "ISC",
56
- "gitHead": "d729a8504e74750ca6f92b2ce8229a07c5dd0b2a"
57
+ "gitHead": "8a3de07d684fab7b0e5524d8fe38a16397e59f77"
57
58
  }