@24i/smartapps-bigscreen-rnv-build-engine 0.17.5 → 0.17.6-alpha.10

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 (48) hide show
  1. package/README.md +25 -18
  2. package/dist/src/__tests__/resolvers/resolveBuildEnvType.spec.js +23 -0
  3. package/dist/src/constants/buildEnvironments.js +9 -0
  4. package/dist/src/constants/buildProductionPackages.js +9 -0
  5. package/dist/src/constants/delopyLivePlatforms.js +13 -0
  6. package/dist/src/constants/index.js +3 -1
  7. package/dist/src/resolvers/index.js +6 -1
  8. package/dist/src/resolvers/resolveBaseUrl.js +11 -1
  9. package/dist/src/resolvers/resolveBuildEnvName.js +7 -14
  10. package/dist/src/resolvers/resolveBuildEnvType.js +23 -0
  11. package/dist/src/resolvers/resolveDeployLocations.js +3 -6
  12. package/dist/src/resolvers/resolveGenericRnvConfig.js +9 -2
  13. package/dist/src/resolvers/resolveProductionZipFileRelativePath.js +36 -0
  14. package/dist/src/resolvers/resolveSupportedFlavoursForPlatform.js +8 -0
  15. package/dist/src/resolvers/resolveZippedPlatformBuildsRelativeFilePath.js +25 -1
  16. package/dist/src/scripts/buildAllWithSchemes.js +88 -0
  17. package/dist/src/scripts/buildProductionPackagesAll.js +75 -0
  18. package/dist/src/scripts/deployLiveAll.js +27 -0
  19. package/dist/src/scripts/deployLivePlatform.js +44 -0
  20. package/dist/src/scripts/generateDeployUrls/makeTableDataByScheme.js +1 -1
  21. package/dist/src/scripts/release/appCenter/appCenter.js +17 -0
  22. package/dist/src/scripts/release/appCenter/deployProductionPackagesToAppCenter.js +117 -0
  23. package/dist/src/scripts/release/{deployToAppCenter.js → appCenter/deployToAppCenter.js} +6 -17
  24. package/dist/src/scripts/release/notifySlack/notifySlack.js +11 -8
  25. package/dist/src/scripts/release/sentryRelease.js +11 -5
  26. package/dist/src/scripts/releaseAllWithScheme.js +4 -4
  27. package/dist/src/scripts/releaseAllWithSchemes.js +158 -0
  28. package/dist/src/scripts/releaseProductionPackagesAll.js +13 -0
  29. package/dist/src/sdks/sdk-androidtv/sdkAndroidtv.js +16 -6
  30. package/dist/src/sdks/sdk-tizen/sdkTizen.js +3 -0
  31. package/dist/src/sdks/sdk-webos/sdkWebos.js +3 -0
  32. package/dist/src/sdks/sdk-webpack/sdkWebpack.js +23 -3
  33. package/dist/src/tasks/deploy/aswS3/aws.js +21 -3
  34. package/dist/src/tasks/deploy/aswS3/deployS3.js +8 -2
  35. package/dist/src/tasks/deploy/aswS3/distToLiveS3.js +76 -0
  36. package/dist/src/tasks/deploy/hbbtv/deployHbbtv.js +7 -1
  37. package/dist/src/tasks/task.rnv.build.js +10 -1
  38. package/dist/src/tasks/task.rnv.deploy.js +10 -1
  39. package/dist/src/utils/copyEnvironmentFolder.js +65 -0
  40. package/dist/src/utils/forEachSupportedPlatformFlavour.js +29 -7
  41. package/dist/src/utils/getSafeSchemeString.js +7 -0
  42. package/dist/src/utils/zipBuildsByPlatforms.js +8 -5
  43. package/dist/src/utils/zipStagingProdBuildsByPlatforms.js +114 -0
  44. package/dist/templates/platforms/_shared/webpack.base.js +2 -2
  45. package/dist/templates/platforms/androidtv/project/app/src/main/java/com/twentyfouri/tvbridge/bridge/BridgeFromJavaScript.kt +44 -0
  46. package/dist/templates/platforms/androidtv/project/app/src/main/java/com/twentyfouri/tvbridge/webview/model/MediaEventType.kt +3 -1
  47. package/dist/templates/platforms/androidtv/project/app/src/main/java/com/twentyfouri/tvbridge/webview/viewmodel/WebViewModel.kt +11 -0
  48. package/package.json +3 -1
@@ -23,23 +23,26 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.deployToS3 = void 0;
26
+ exports.deployToS3 = exports.urlToS3Protocol = void 0;
27
27
  const path = __importStar(require("path"));
28
28
  const rnv_1 = require("rnv");
29
29
  const aws = __importStar(require("./aws"));
30
30
  const constants_1 = require("../../../constants");
31
31
  const resolvers_1 = require("../../../resolvers");
32
+ const getSafeSchemeString_1 = require("../../../utils/getSafeSchemeString");
32
33
  const { getConfigProp } = rnv_1.Common;
33
34
  const uploadPackage = (c, sourcePath, uploadPath) => {
34
35
  const packageOutputDirPath = `${sourcePath}/output`;
35
36
  const packageFileName = (0, resolvers_1.resolveBuildFileName)(c);
36
37
  const packageLocalPath = `"${packageOutputDirPath}/${packageFileName}"`;
37
38
  const packageRemotePath = `"${uploadPath}/build/${packageFileName}"`;
39
+ rnv_1.Logger.logDebug(`uploadPackage: src: ${packageLocalPath}, dest: ${packageRemotePath}`);
38
40
  aws.cp(packageLocalPath, packageRemotePath);
39
41
  };
40
42
  const uploadPublicDir = (sourcePath, uploadPath) => {
41
43
  const publicDirLocalPath = path.join(sourcePath, 'project', 'public');
42
44
  const publicDirRemotePath = `${uploadPath}/public`;
45
+ rnv_1.Logger.logDebug(`uploadPublicDir: src: ${publicDirLocalPath}, dest: ${publicDirRemotePath}`);
43
46
  aws.cp(publicDirLocalPath, publicDirRemotePath);
44
47
  };
45
48
  const urlToS3Protocol = (url) => {
@@ -47,9 +50,12 @@ const urlToS3Protocol = (url) => {
47
50
  const bucketHostnameAwsPostfix = '.s3.amazonaws.com';
48
51
  return hostWithPath.replace(bucketHostnameAwsPostfix, '');
49
52
  };
53
+ exports.urlToS3Protocol = urlToS3Protocol;
50
54
  const deployToS3 = async (c) => {
55
+ rnv_1.Logger.logTask(`deployToS3`);
51
56
  const { platform, runtime } = c;
52
- const sourcePath = runtime.appDir;
57
+ const schemeDirName = c.program.schemeFolder ? (0, getSafeSchemeString_1.getSafeSchemeString)(runtime.scheme) : '';
58
+ const sourcePath = path.join(c.paths.project.builds.dir, schemeDirName, `${runtime.appId}_${platform}`);
53
59
  const { isBuildHosted } = getConfigProp(c, platform, 'webpackConfig', {});
54
60
  const baseUrl = (0, resolvers_1.resolveBaseUrl)({
55
61
  platform,
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.checkAWSAuth = exports.checkDistVersionAvailability = exports.distToLiveS3 = void 0;
27
+ const resolveBaseUrl_1 = require("../../../resolvers/resolveBaseUrl");
28
+ const resolveGenericRnvConfig_1 = require("../../../resolvers/resolveGenericRnvConfig");
29
+ const deployS3_1 = require("./deployS3");
30
+ const aws = __importStar(require("./aws"));
31
+ const getUploadPath = (options, version) => {
32
+ const { packageVersion } = (0, resolveGenericRnvConfig_1.getBaseConfig)().buildConfig?.common;
33
+ const baseUrl = (0, resolveBaseUrl_1.resolveBaseUrl)(options);
34
+ if (!baseUrl) {
35
+ return undefined;
36
+ }
37
+ return (0, deployS3_1.urlToS3Protocol)(baseUrl).replace(packageVersion, version);
38
+ };
39
+ const checkAWSAuth = () => {
40
+ try {
41
+ aws.getIdentity();
42
+ }
43
+ catch {
44
+ throw new Error('Failed to get AWS user identity, are your credentials configured correctly?\n');
45
+ }
46
+ return true;
47
+ };
48
+ exports.checkAWSAuth = checkAWSAuth;
49
+ const checkDistVersionAvailability = (options, version) => {
50
+ const uploadPath = getUploadPath(options, version);
51
+ if (!uploadPath)
52
+ return false;
53
+ try {
54
+ process.stdout.write(`Verifying distribution v${version} availability for flavour ${options.flavour}.\n`);
55
+ aws.ls(uploadPath);
56
+ process.stdout.write('OK.\n');
57
+ }
58
+ catch {
59
+ throw new Error(`Failed to locate distribution version ${version} for platform "${options.platform}" flavour ${options.flavour}.
60
+ attempted to look at: ${uploadPath}.\n`);
61
+ }
62
+ return true;
63
+ };
64
+ exports.checkDistVersionAvailability = checkDistVersionAvailability;
65
+ const distToLiveS3 = (options, version, copyIndexOnly) => {
66
+ const uploadPath = getUploadPath(options, version);
67
+ if (!uploadPath)
68
+ return false;
69
+ const indexPath = copyIndexOnly ? 'index.html' : '';
70
+ const copyFrom = `${uploadPath}/public/${indexPath}`;
71
+ const copyTo = `${uploadPath.replace(/dist\/v.*/, 'live')}/public/${indexPath}`;
72
+ aws.cpRemote(copyFrom, copyTo);
73
+ process.stdout.write('Publish done.\n');
74
+ return true;
75
+ };
76
+ exports.distToLiveS3 = distToLiveS3;
@@ -28,6 +28,7 @@ const path = __importStar(require("path"));
28
28
  const nodessh = __importStar(require("node-ssh"));
29
29
  const constants_1 = require("../../../constants");
30
30
  const resolvers_1 = require("../../../resolvers");
31
+ const getSafeSchemeString_1 = require("../../../utils/getSafeSchemeString");
31
32
  const getSshKeyAbsolutePath = (c, sshKeyRelativePath) => {
32
33
  if (!sshKeyRelativePath)
33
34
  return '';
@@ -44,7 +45,12 @@ const makeSshConnection = async (c) => {
44
45
  await ssh.connect({ host, username, privateKey, passphrase });
45
46
  return ssh;
46
47
  };
47
- const getLocalBuildPackagePath = (c) => (path.join(c.runtime.appDir, 'output', (0, resolvers_1.resolveBuildFileName)(c)));
48
+ const getLocalBuildPackagePath = (c) => {
49
+ const { runtime, platform } = c;
50
+ const schemeDirName = c.program.schemeFolder ? (0, getSafeSchemeString_1.getSafeSchemeString)(runtime.scheme) : '';
51
+ const appDirPath = path.join(c.paths.project.builds.dir, schemeDirName, `${runtime.appId}_${platform}`);
52
+ path.join(appDirPath, 'output', (0, resolvers_1.resolveBuildFileName)(c));
53
+ };
48
54
  const resolveRemotePaths = (c) => {
49
55
  const { scheme, appId } = c.runtime;
50
56
  const remoteBuildDirRelativePath = (0, resolvers_1.resolveHbbtvRemoteBuildDirRelativePath)(c, scheme, appId);
@@ -31,6 +31,12 @@ const constants_1 = require("../constants");
31
31
  const sdks_1 = require("../sdks");
32
32
  const resolvers_1 = require("../resolvers");
33
33
  const { TASK_BUILD, TASK_PACKAGE, PARAMS } = rnv_1.Constants;
34
+ const PARAM_KEYS = {
35
+ productionPackagesHostedUrl: {
36
+ key: 'productionPackagesHostedUrl',
37
+ description: 'Uses production package hosted URL of App',
38
+ }
39
+ };
34
40
  const makeZipOutput = (c) => {
35
41
  const platformBuildDir = rnv_1.Common.getPlatformBuildDir(c);
36
42
  const copiedProjectBuildDir = `${platformBuildDir}/build`;
@@ -59,6 +65,9 @@ const buildFn = async (c, parentTask, originTask) => {
59
65
  rnv_1.Logger.logTask('taskRnvBuild', `parent:${parentTask}`);
60
66
  const { platform } = c;
61
67
  c.runtime.forceBundleAssets = true;
68
+ if (c.program.rawArgs?.includes(`--${PARAM_KEYS.productionPackagesHostedUrl.key}`)) {
69
+ c.program[PARAM_KEYS.productionPackagesHostedUrl.key] = true;
70
+ }
62
71
  await (0, sdks_1.handlePlatformSdk)(c);
63
72
  await rnv_1.TaskManager.executeOrSkipTask(c, TASK_PACKAGE, TASK_BUILD, originTask);
64
73
  switch (platform) {
@@ -93,7 +102,7 @@ const customRnvBuildTask = {
93
102
  description: 'Build project binary',
94
103
  fn: buildFn,
95
104
  task: 'build',
96
- params: PARAMS.withBase(PARAMS.withConfigure()),
105
+ params: PARAMS.withBase(PARAMS.withConfigure([PARAM_KEYS.productionPackagesHostedUrl])),
97
106
  platforms: Object.values(constants_1.Platforms),
98
107
  };
99
108
  exports.customRnvBuildTask = customRnvBuildTask;
@@ -5,6 +5,12 @@ const rnv_1 = require("rnv");
5
5
  const constants_1 = require("../constants");
6
6
  const deployS3_1 = require("./deploy/aswS3/deployS3");
7
7
  const deployHbbtv_1 = require("./deploy/hbbtv/deployHbbtv");
8
+ const PARAM_KEYS = {
9
+ schemeFolder: {
10
+ key: 'schemeFolder',
11
+ description: 'Flag to use scheme folder in path of build',
12
+ }
13
+ };
8
14
  const { logErrorPlatform } = rnv_1.PlatformManager;
9
15
  const { logTask } = rnv_1.Logger;
10
16
  const { TASK_EXPORT, TASK_DEPLOY, PARAMS } = rnv_1.Constants;
@@ -12,6 +18,9 @@ const { executeOrSkipTask } = rnv_1.TaskManager;
12
18
  const deployFn = async (c, parentTask, originTask) => {
13
19
  logTask('taskRnvDeploy', `parent:${parentTask}`);
14
20
  await executeOrSkipTask(c, TASK_EXPORT, TASK_DEPLOY, originTask);
21
+ if (c.program.rawArgs?.includes(`--${PARAM_KEYS.schemeFolder.key}`)) {
22
+ c.program[PARAM_KEYS.schemeFolder.key] = true;
23
+ }
15
24
  switch (c.platform) {
16
25
  case constants_1.Platforms.HBBTV:
17
26
  await (0, deployHbbtv_1.deployHbbTV)(c);
@@ -36,7 +45,7 @@ const customRnvDeployTask = {
36
45
  description: 'Deploy the binary via selected deployment integration or build hook',
37
46
  fn: deployFn,
38
47
  task: 'deploy',
39
- params: PARAMS.withBase(PARAMS.withConfigure()),
48
+ params: PARAMS.withBase(PARAMS.withConfigure([PARAM_KEYS.schemeFolder])),
40
49
  platforms: Object.values(constants_1.Platforms),
41
50
  };
42
51
  exports.customRnvDeployTask = customRnvDeployTask;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.copyEnvFolderInPublicConfig = exports.copyEnvFolderInProject = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ const path = __importStar(require("path"));
29
+ const rnv_1 = require("rnv");
30
+ const resolveBuildEnvType_1 = require("../resolvers/resolveBuildEnvType");
31
+ const findClosestEnvFolder = (dirPath, envType) => {
32
+ const envHierarchy = ['dev', 'staging', 'prod'];
33
+ const envIndex = envHierarchy.indexOf(envType);
34
+ for (let i = envIndex; i < envHierarchy.length; i++) {
35
+ const currentEnvType = envHierarchy[i];
36
+ const envDir = path.join(dirPath, `_${currentEnvType}`);
37
+ if (fs.existsSync(envDir)) {
38
+ return envDir;
39
+ }
40
+ }
41
+ return undefined;
42
+ };
43
+ const copyEnvironmentFolder = (c, dirPath) => {
44
+ rnv_1.Logger.logTask('copyEnvironmentFolder');
45
+ const envType = (0, resolveBuildEnvType_1.resolveBuildEnvType)(c.runtime.scheme);
46
+ const envFolderPath = findClosestEnvFolder(dirPath, envType);
47
+ if (envFolderPath) {
48
+ rnv_1.FileUtils.copyFolderContentsRecursiveSync(envFolderPath, path.join(envFolderPath, '..'));
49
+ }
50
+ const envs = ['dev', 'staging', 'prod'];
51
+ envs.forEach((envType) => {
52
+ const envDir = path.join(dirPath, `_${envType}`);
53
+ fs.rmSync(envDir, { recursive: true, force: true });
54
+ });
55
+ };
56
+ const copyEnvFolderInProject = (c, subPath) => {
57
+ const buildProjectDirOrSubpath = path.join(rnv_1.Common.getPlatformProjectDir(c), subPath || '');
58
+ copyEnvironmentFolder(c, buildProjectDirOrSubpath);
59
+ };
60
+ exports.copyEnvFolderInProject = copyEnvFolderInProject;
61
+ const copyEnvFolderInPublicConfig = (c) => {
62
+ const buildProjectPublicContentConfigDir = path.join(rnv_1.Common.getPlatformProjectDir(c), 'public', 'content', 'conf');
63
+ copyEnvironmentFolder(c, buildProjectPublicContentConfigDir);
64
+ };
65
+ exports.copyEnvFolderInPublicConfig = copyEnvFolderInPublicConfig;
@@ -1,24 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.forEachSupportedPlatformFlavour = void 0;
3
+ exports.forEachSupportedPlatformFlavour = exports.forEachPlatformFlavour = exports.getProgressMessage = void 0;
4
4
  const resolvers_1 = require("../resolvers");
5
- const getProgressMessage = (platforms, platformIndex, flavours, flavourIndex) => {
6
- let string = `\nProcessing "${platforms[platformIndex]}" platform`;
5
+ const getProgressMessage = ({ schemes, schemeIndex, platforms, platformIndex, flavours, flavourIndex, }) => {
6
+ const printScheme = schemes && schemes.length && schemeIndex !== undefined;
7
+ let string = `\nProcessing`;
8
+ if (printScheme) {
9
+ string += ` "${schemes[schemeIndex]}" scheme"`;
10
+ string += ` (${schemeIndex + 1}/${schemes.length}),`;
11
+ }
12
+ string += ` "${platforms[platformIndex]}" platform`;
7
13
  string += ` (${platformIndex + 1}/${platforms.length})`;
8
14
  string += ` and its "${flavours[flavourIndex]}" flavour`;
9
15
  string += ` (${flavourIndex + 1}/${flavours.length})...`;
10
16
  return string;
11
17
  };
12
- const forEachSupportedPlatformFlavour = (c, cb) => {
18
+ exports.getProgressMessage = getProgressMessage;
19
+ const _forEachPlatformFlavour = (platforms, c, cb, options = {}) => {
20
+ const { ignoredPlatforms = [], schemes = [], schemeIndex = 0, } = options;
13
21
  const processPlatformFlavours = (platform, platformIndex, platforms) => {
22
+ if (ignoredPlatforms.includes(platform)) {
23
+ console.log(`\nSkipping "${platforms[platformIndex]}" platform (${platformIndex + 1}/${platforms.length}).`);
24
+ return;
25
+ }
14
26
  const processFlavour = (flavour, flavourIndex, flavours) => {
15
- console.log(getProgressMessage(platforms, platformIndex, flavours, flavourIndex));
27
+ console.log(getProgressMessage({
28
+ schemes, schemeIndex, platforms, platformIndex, flavours, flavourIndex,
29
+ }));
16
30
  const { scheme } = c.runtime;
17
31
  return cb({ platform, flavour, scheme });
18
32
  };
19
- const { supportedFlavours = [] } = c.buildConfig.platforms[platform]?.deploy || {};
33
+ const supportedFlavours = (0, resolvers_1.resolveSupportedFlavoursForPlatform)(c, platform);
20
34
  supportedFlavours.forEach(processFlavour);
21
35
  };
22
- (0, resolvers_1.resolveSupportedPlatforms)(c).forEach(processPlatformFlavours);
36
+ platforms.forEach(processPlatformFlavours);
37
+ };
38
+ const forEachSupportedPlatformFlavour = (c, cb, options = {}) => {
39
+ const supportedPlatforms = (0, resolvers_1.resolveSupportedPlatforms)(c);
40
+ _forEachPlatformFlavour(supportedPlatforms, c, cb, options);
23
41
  };
24
42
  exports.forEachSupportedPlatformFlavour = forEachSupportedPlatformFlavour;
43
+ const forEachPlatformFlavour = (platforms, c, cb) => {
44
+ _forEachPlatformFlavour(platforms, c, cb);
45
+ };
46
+ exports.forEachPlatformFlavour = forEachPlatformFlavour;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSafeSchemeString = void 0;
4
+ const getSafeSchemeString = (scheme) => {
5
+ return scheme.replace(/:/g, '_');
6
+ };
7
+ exports.getSafeSchemeString = getSafeSchemeString;
@@ -24,15 +24,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.zipBuildsByPlatforms = void 0;
27
- const fs_1 = require("fs");
28
- const path_1 = require("path");
29
27
  const child_process_1 = require("child_process");
28
+ const fs_1 = require("fs");
29
+ const path = __importStar(require("path"));
30
30
  const glob = __importStar(require("glob"));
31
31
  const resolvers_1 = require("../resolvers");
32
+ const getSafeSchemeString_1 = require("../utils/getSafeSchemeString");
32
33
  const zipDir = (srcDir, outputFile) => (0, child_process_1.execSync)(`zip ${outputFile} -0 -j ${srcDir}/*`);
33
34
  const getPlatformBuildsPaths = (c, platformName) => {
34
35
  const { platformBuildsDir } = c.buildConfig.paths;
35
- const outputGlob = `${platformBuildsDir}/**/output`;
36
+ const schemeDirName = c.program.schemeFolder ? (0, getSafeSchemeString_1.getSafeSchemeString)(c.runtime.scheme) : '';
37
+ const schemesBuildsPath = path.join(platformBuildsDir, schemeDirName);
38
+ const outputGlob = `${schemesBuildsPath}/**/output`;
36
39
  const platformBuildsGlob = `${outputGlob}/*.${(0, resolvers_1.resolveBuildFileExtension)(platformName)}`;
37
40
  try {
38
41
  const buildsPathsCandidates = glob.sync(platformBuildsGlob) || [];
@@ -47,10 +50,10 @@ const processPlatform = (c, platformName) => {
47
50
  if (platformBuildsPaths && platformBuildsPaths.length === 0)
48
51
  return;
49
52
  const outputZipFilePath = (0, resolvers_1.resolveZippedPlatformBuildsRelativeFilePath)(c, platformName);
50
- const tempPlatformDir = `${(0, path_1.dirname)(outputZipFilePath)}/${platformName}`;
53
+ const tempPlatformDir = `${path.dirname(outputZipFilePath)}/${platformName}`;
51
54
  (0, fs_1.mkdirSync)(tempPlatformDir, { recursive: true });
52
55
  const copyBuildFileIntoTempPlatformDir = (buildFilePath) => {
53
- const buildFileName = (0, path_1.basename)(buildFilePath);
56
+ const buildFileName = path.basename(buildFilePath);
54
57
  const dest = `${tempPlatformDir}/${buildFileName}`;
55
58
  (0, fs_1.copyFileSync)(buildFilePath, dest);
56
59
  };
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.zipStagingProdBuildsByPlatforms = void 0;
27
+ const child_process_1 = require("child_process");
28
+ const fs_1 = require("fs");
29
+ const fse = __importStar(require("fs-extra"));
30
+ const path = __importStar(require("path"));
31
+ const glob = __importStar(require("glob"));
32
+ const rnv_1 = require("rnv");
33
+ const index_1 = require("../resolvers/index");
34
+ const getSafeSchemeString_1 = require("./getSafeSchemeString");
35
+ const { getConfigProp } = rnv_1.Common;
36
+ const zipDir = (srcDir, outputFile) => (0, child_process_1.execSync)(`zip ${outputFile} -0 -r *`, { cwd: srcDir });
37
+ const getPlatformBuildsPaths = (c, platformName, scheme) => {
38
+ const { platformBuildsDir } = c.buildConfig.paths;
39
+ const schemeDirName = (0, getSafeSchemeString_1.getSafeSchemeString)(scheme);
40
+ const schemesBuildsPath = path.join(platformBuildsDir, schemeDirName);
41
+ const outputGlob = `${schemesBuildsPath}/**/output`;
42
+ const platformBuildsGlob = `${outputGlob}/*.${(0, index_1.resolveBuildFileExtension)(platformName)}`;
43
+ try {
44
+ const buildsPathsCandidates = glob.sync(platformBuildsGlob) || [];
45
+ const platformBuilsPaths = buildsPathsCandidates.filter((path) => path.includes(platformName));
46
+ return platformBuilsPaths;
47
+ }
48
+ catch (e) {
49
+ return [];
50
+ }
51
+ };
52
+ const getPublicDirPath = (c, platform, flavour, scheme) => {
53
+ const schemeDirName = (0, getSafeSchemeString_1.getSafeSchemeString)(scheme);
54
+ const sourcePath = path.join(c.paths.project.builds.dir, schemeDirName, `${flavour}_${platform}`);
55
+ c.runtime.scheme = scheme;
56
+ const baseC = (0, index_1.getBaseConfig)({ scheme });
57
+ const { isBuildHosted } = getConfigProp(baseC, platform, 'webpackConfig', {});
58
+ const sourceDirPath = isBuildHosted ? `${sourcePath}-public` : sourcePath;
59
+ const contentDirPath = path.join(sourceDirPath, 'project', 'public');
60
+ return contentDirPath;
61
+ };
62
+ const copyProdContentIntoTempPlatformFlavourDir = (c, platform, flavour, prodScheme, destPlatformFlavourPath) => {
63
+ const srcPublicDirPath = getPublicDirPath(c, platform, flavour, prodScheme);
64
+ const platformFlavourPublicDirPath = path.join(destPlatformFlavourPath, 'public');
65
+ fse.copySync(srcPublicDirPath, platformFlavourPublicDirPath);
66
+ };
67
+ const copyBuildFileIntoTempPlatformFlavourDir = (buildFilePath, tempPlatformFlavourBuildsDir) => {
68
+ const buildFileName = path.basename(buildFilePath);
69
+ const dest = path.join(tempPlatformFlavourBuildsDir, buildFileName);
70
+ (0, fs_1.copyFileSync)(buildFilePath, dest);
71
+ };
72
+ const processPlatform = (c, platformName, schemes) => {
73
+ const [stagingScheme, prodScheme] = schemes;
74
+ if (!prodScheme) {
75
+ throw new Error('Missing production scheme.');
76
+ }
77
+ const outputZipFilePath = (0, index_1.resolveZippedPlatformBuildsRelativeFilePath)(c, platformName);
78
+ const stagingBuildsPaths = stagingScheme ? getPlatformBuildsPaths(c, platformName, stagingScheme) : [];
79
+ const prodBuildsPaths = prodScheme ? getPlatformBuildsPaths(c, platformName, prodScheme) : [];
80
+ const flavourBuilds = [];
81
+ const supportedFlavours = (0, index_1.resolveSupportedFlavoursForPlatform)(c, platformName);
82
+ supportedFlavours.forEach((flavour) => {
83
+ const flavourStagingBuildsPaths = stagingBuildsPaths.filter((path) => path.includes(flavour));
84
+ const flavourProdBuildsPaths = prodBuildsPaths.filter((path) => path.includes(flavour));
85
+ flavourBuilds.push({
86
+ flavour,
87
+ stagingBuildsPaths: flavourStagingBuildsPaths,
88
+ prodBuildsPaths: flavourProdBuildsPaths,
89
+ });
90
+ });
91
+ const tempPlatformDir = `${path.dirname(outputZipFilePath)}/${platformName}`;
92
+ flavourBuilds.forEach((flavourBuild) => {
93
+ const { flavour, stagingBuildsPaths, prodBuildsPaths } = flavourBuild;
94
+ const tempPFDir = path.join(tempPlatformDir, flavour);
95
+ const tempPFBuildsDir = path.join(tempPFDir, 'builds');
96
+ (0, fs_1.mkdirSync)(tempPFDir, { recursive: true });
97
+ (0, fs_1.mkdirSync)(tempPFBuildsDir, { recursive: true });
98
+ [...stagingBuildsPaths, ...prodBuildsPaths].forEach((buildFilePath) => {
99
+ copyBuildFileIntoTempPlatformFlavourDir(buildFilePath, tempPFBuildsDir);
100
+ });
101
+ copyProdContentIntoTempPlatformFlavourDir(c, platformName, flavour, prodScheme, tempPFDir);
102
+ });
103
+ zipDir(tempPlatformDir, path.resolve(outputZipFilePath));
104
+ (0, fs_1.rmdirSync)(tempPlatformDir, { recursive: true });
105
+ };
106
+ const zipStagingProdBuildsByPlatforms = (c, schemes) => {
107
+ const [stagingScheme, prodScheme] = schemes;
108
+ if (!prodScheme) {
109
+ throw new Error('Missing production scheme.');
110
+ }
111
+ (0, index_1.resolveSupportedPlatforms)(c)
112
+ .forEach((platformName) => processPlatform(c, platformName, schemes));
113
+ };
114
+ exports.zipStagingProdBuildsByPlatforms = zipStagingProdBuildsByPlatforms;
@@ -125,13 +125,13 @@ function generateConfig(config) {
125
125
  scheme: config.scheme,
126
126
  flavour: config.appConfigId,
127
127
  };
128
+ const { PLATFORM, HOSTED_URL } = process.env;
128
129
  const { buildConfig } = smartapps_bigscreen_rnv_build_engine_1.Resolvers.getBaseConfig();
129
130
  const buildVersion = smartapps_bigscreen_rnv_build_engine_1.Resolvers.resolveBuildVersion(platformSchemeAppIdObj);
130
- const baseUrl = smartapps_bigscreen_rnv_build_engine_1.Resolvers.resolveBaseUrl(platformSchemeAppIdObj);
131
+ const baseUrl = HOSTED_URL || smartapps_bigscreen_rnv_build_engine_1.Resolvers.resolveBaseUrl(platformSchemeAppIdObj);
131
132
  const packageVersions = smartapps_bigscreen_rnv_build_engine_1.Resolvers.resolvePackageVersions(projectDir);
132
133
  const devServerHost = config.devServerHost || '0.0.0.0';
133
134
  const isDevServer = appBuildEngineProjectDir.endsWith('/server');
134
- const { PLATFORM } = process.env;
135
135
  const isBuildHosted = config.isBuildHosted || false;
136
136
  const appContentPath = getAppContentPath(baseUrl, isBuildHosted);
137
137
  const copiedDirWithPublicContentPath = path_1.default.join(appBuildDir, `../${path_1.default.parse(appBuildDir).name}-public`);
@@ -282,6 +282,50 @@ class BridgeFromJavaScript(
282
282
  viewModel.subtitleTrack?.let { toJson(it) } ?: DISABLED_SUBTITLE_TRACK
283
283
  }
284
284
 
285
+ /*
286
+ Returns VIDEO track BITRATE, if not available returns null
287
+ */
288
+ @JavascriptInterface
289
+ fun bridgeJavaScriptToAndroid_GetBitrate(): Int? = runBlocking("bridgeJavaScriptToAndroid_GetBitrate") {
290
+ viewModel.videoTrack?.bitrate
291
+ }
292
+
293
+ /*
294
+ Returns VIDEO track RENDITION, if not available returns null
295
+ */
296
+ @JavascriptInterface
297
+ fun bridgeJavaScriptToAndroid_GetRendition(): String? = runBlocking("bridgeJavaScriptToAndroid_GetRendition") {
298
+ viewModel.videoTrack?.run {
299
+ return@runBlocking "${width}x${height}${formatBitrate(bitrate)}"
300
+ }
301
+ null
302
+ }
303
+
304
+ private fun formatBitrate(bitrate: Int): String {
305
+ return when {
306
+ bitrate <= 0 -> ""
307
+ bitrate < 1e3 -> "@${bitrate}bps"
308
+ bitrate < 1e6 -> "@${(bitrate / 1e3).roundToInt()}Kbps"
309
+ else -> "@${(bitrate / 1e4).roundToInt() / 1e2}Mbps"
310
+ }
311
+ }
312
+
313
+ /*
314
+ Returns AUDIO track CODEC, if not available returns null
315
+ */
316
+ @JavascriptInterface
317
+ fun bridgeJavaScriptToAndroid_GetAudioCodec(): String? = runBlocking("bridgeJavaScriptToAndroid_GetAudioCodec") {
318
+ viewModel.audioTrack?.codec
319
+ }
320
+
321
+ /*
322
+ Returns VIDEO track CODEC, if not available returns null
323
+ */
324
+ @JavascriptInterface
325
+ fun bridgeJavaScriptToAndroid_GetVideoCodec(): String? = runBlocking("bridgeJavaScriptToAndroid_GetVideoCodec") {
326
+ viewModel.videoTrack?.codec
327
+ }
328
+
285
329
  /*
286
330
  Set the cookies to localstorage
287
331
  */
@@ -8,8 +8,10 @@ object MediaEventType {
8
8
  const val ERROR = "error"
9
9
  const val PLAYING = "playing"
10
10
  const val PAUSE = "pause"
11
- const val PLAY = "pause"
11
+ const val PLAY = "play"
12
12
  const val ENDED = "ended"
13
+ const val CANPLAY = "canplay"
14
+ const val LOADEDMETADATA = "loadedmetadata"
13
15
  const val WAITING = "waiting"
14
16
  const val SEEKING = "seeking"
15
17
  const val SEEKED = "seeked"
@@ -68,6 +68,8 @@ class WebViewModel @Inject constructor(
68
68
 
69
69
  private var contentModel: ContentModel? = null
70
70
 
71
+ val videoTrack: VideoTrack?
72
+ get() = player?.selectedVideoTrack
71
73
  val audioTrack: AudioTrack?
72
74
  get() = player?.selectedAudioTrack
73
75
  val subtitleTrack: TextTrack?
@@ -355,6 +357,12 @@ class WebViewModel @Inject constructor(
355
357
  jsBridge.bridgeAndroidToJavaScript_ErrorEvent(MediaEventType.ERROR, "${event.error.message} - ${event.error.nativeCode}")
356
358
  stopPlayer()
357
359
  }
360
+ is LoadedMetadataEvent -> {
361
+ jsBridge.bridgeAndroidToJavaScript_MediaEvent(MediaEventType.LOADEDMETADATA)
362
+ }
363
+ is CanPlayEvent -> {
364
+ jsBridge.bridgeAndroidToJavaScript_MediaEvent(MediaEventType.CANPLAY)
365
+ }
358
366
  is EndedEvent -> {
359
367
  jsBridge.bridgeAndroidToJavaScript_MediaEvent(MediaEventType.ENDED)
360
368
  }
@@ -365,6 +373,9 @@ class WebViewModel @Inject constructor(
365
373
  view?.setBlackCurtainVisibility(View.GONE)
366
374
  jsBridge.bridgeAndroidToJavaScript_MediaEvent(MediaEventType.PLAYING)
367
375
  }
376
+ is SeekingEvent -> {
377
+ jsBridge.bridgeAndroidToJavaScript_MediaEvent(MediaEventType.SEEKING)
378
+ }
368
379
  is SeekedEvent -> {
369
380
  jsBridge.bridgeAndroidToJavaScript_MediaEvent(MediaEventType.SEEKED)
370
381
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/smartapps-bigscreen-rnv-build-engine",
3
- "version": "0.17.5",
3
+ "version": "0.17.6-alpha.10",
4
4
  "description": "Package with build engine for SmartApps BIGscreen projects...",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
@@ -35,9 +35,11 @@
35
35
  }
36
36
  ],
37
37
  "dependencies": {
38
+ "fs-extra": "11.1.1",
38
39
  "xml2js": "^0.4.23"
39
40
  },
40
41
  "devDependencies": {
42
+ "@types/fs-extra": "11.0.1",
41
43
  "@types/inquirer": "8.2.1",
42
44
  "@types/ip": "1.1.0",
43
45
  "@types/mini-css-extract-plugin": "1.4.3",