@24i/smartapps-bigscreen-rnv-build-engine 0.17.6-alpha.7 → 0.17.6-alpha.8

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProductionZipFileRelativePath = exports.resolveZippedPlatformBuildsRelativeFilePath = exports.resolvePackageVersions = exports.resolveBuildFileExtension = exports.resolveUsedFlavours = exports.resolveSupportedPlatforms = exports.getBaseConfig = exports.resolveBuildFileName = exports.resolveBuildFileBaseName = exports.resolveHbbtvDeployConfig = exports.resolveHbbtvDeployUrl = exports.resolveHbbtvRemoteBuildDirRelativePath = exports.resolveDeployLocations = exports.resolveBuildVersionOffset = exports.resolveBuildVersion = exports.resolveBuildEnvName = exports.resolveProductionPackagesBaseUrl = exports.resolveBaseUrl = void 0;
3
+ exports.getProductionZipFileRelativePath = exports.resolveZippedPlatformBuildsRelativeFilePath = exports.resolvePackageVersions = exports.resolveBuildFileExtension = exports.resolveUsedFlavours = exports.resolveSupportedFlavoursForPlatform = exports.resolveSupportedPlatforms = exports.getBaseConfig = exports.resolveBuildFileName = exports.resolveBuildFileBaseName = exports.resolveHbbtvDeployConfig = exports.resolveHbbtvDeployUrl = exports.resolveHbbtvRemoteBuildDirRelativePath = exports.resolveDeployLocations = exports.resolveBuildVersionOffset = exports.resolveBuildVersion = exports.resolveBuildEnvName = exports.resolveProductionPackagesBaseUrl = exports.resolveBaseUrl = void 0;
4
4
  var resolveBaseUrl_1 = require("./resolveBaseUrl");
5
5
  Object.defineProperty(exports, "resolveBaseUrl", { enumerable: true, get: function () { return resolveBaseUrl_1.resolveBaseUrl; } });
6
6
  Object.defineProperty(exports, "resolveProductionPackagesBaseUrl", { enumerable: true, get: function () { return resolveBaseUrl_1.resolveProductionPackagesBaseUrl; } });
@@ -26,6 +26,8 @@ var resolveGenericRnvConfig_1 = require("./resolveGenericRnvConfig");
26
26
  Object.defineProperty(exports, "getBaseConfig", { enumerable: true, get: function () { return resolveGenericRnvConfig_1.getBaseConfig; } });
27
27
  var resolveSupportedPlatforms_1 = require("./resolveSupportedPlatforms");
28
28
  Object.defineProperty(exports, "resolveSupportedPlatforms", { enumerable: true, get: function () { return resolveSupportedPlatforms_1.resolveSupportedPlatforms; } });
29
+ var resolveSupportedFlavoursForPlatform_1 = require("./resolveSupportedFlavoursForPlatform");
30
+ Object.defineProperty(exports, "resolveSupportedFlavoursForPlatform", { enumerable: true, get: function () { return resolveSupportedFlavoursForPlatform_1.resolveSupportedFlavoursForPlatform; } });
29
31
  var resolveUsedFlavours_1 = require("./resolveUsedFlavours");
30
32
  Object.defineProperty(exports, "resolveUsedFlavours", { enumerable: true, get: function () { return resolveUsedFlavours_1.resolveUsedFlavours; } });
31
33
  var resolveBuildFileExtension_1 = require("./resolveBuildFileExtension");
@@ -5,8 +5,9 @@ const resolveBuildVersion_1 = require("./resolveBuildVersion");
5
5
  const resolveBaseUrl_1 = require("./resolveBaseUrl");
6
6
  const resolveHbbtvDeployUrl_1 = require("./resolveHbbtvDeployUrl");
7
7
  const resolveBuildFileName_1 = require("./resolveBuildFileName");
8
- const constants_1 = require("../constants");
9
8
  const resolveSupportedPlatforms_1 = require("./resolveSupportedPlatforms");
9
+ const resolveSupportedFlavoursForPlatform_1 = require("./resolveSupportedFlavoursForPlatform");
10
+ const constants_1 = require("../constants");
10
11
  const getBuildVersion = (c) => {
11
12
  const { platform, runtime } = c;
12
13
  const { scheme, appId } = runtime;
@@ -16,10 +17,6 @@ const getBuildVersion = (c) => {
16
17
  flavour: appId,
17
18
  });
18
19
  };
19
- const getSupportedFlavoursForPlatform = (c, platformName) => {
20
- const { supportedFlavours = [] } = c.buildConfig.platforms[platformName]?.deploy || {};
21
- return supportedFlavours;
22
- };
23
20
  const makeOutputObject = (buildVersion) => ({
24
21
  versions: {
25
22
  [buildVersion]: {
@@ -66,7 +63,7 @@ const resolveDeployLocations = (c) => {
66
63
  }
67
64
  return outputFlavourData;
68
65
  };
69
- const outputPlatformData = getSupportedFlavoursForPlatform(c, platformName)
66
+ const outputPlatformData = (0, resolveSupportedFlavoursForPlatform_1.resolveSupportedFlavoursForPlatform)(c, platformName)
70
67
  .map(processPlatformFlavour);
71
68
  outputPlatforms[platformName] = Object.assign({}, ...outputPlatformData);
72
69
  if (!isRequiredPlatformSet) {
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveSupportedFlavoursForPlatform = void 0;
4
+ const resolveSupportedFlavoursForPlatform = (c, platformName) => {
5
+ const { supportedFlavours = [] } = c.buildConfig.platforms[platformName]?.deploy || {};
6
+ return supportedFlavours;
7
+ };
8
+ exports.resolveSupportedFlavoursForPlatform = resolveSupportedFlavoursForPlatform;
@@ -1,13 +1,37 @@
1
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
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.resolveZippedPlatformBuildsRelativeFilePath = void 0;
27
+ const path = __importStar(require("path"));
4
28
  const resolveZippedPlatformBuildsRelativeFilePath = (c, platformName) => {
5
29
  const { platformBuildsDir } = c.buildConfig.paths;
6
30
  const { appNameInFileName } = c.buildConfig.common;
7
31
  const buildVersion = c.buildConfig.common.packageVersion;
8
32
  const zippedFilesParentDir = 'zipped_by_platform';
9
33
  const fileExtension = 'zip';
10
- const relativePathToDir = `${platformBuildsDir}/${zippedFilesParentDir}`;
34
+ const relativePathToDir = path.join(platformBuildsDir, zippedFilesParentDir);
11
35
  const zipFileName = `${appNameInFileName}_${platformName}_${buildVersion}.${fileExtension}`;
12
36
  return `${relativePathToDir}/${zipFileName}`;
13
37
  };
@@ -0,0 +1,69 @@
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
+ const child_process_1 = require("child_process");
27
+ const fs = __importStar(require("fs"));
28
+ const path = __importStar(require("path"));
29
+ const fse = __importStar(require("fs-extra"));
30
+ const forEachSupportedPlatformFlavour_1 = require("../utils/forEachSupportedPlatformFlavour");
31
+ const getSafeSchemeString_1 = require("../utils/getSafeSchemeString");
32
+ const resolvers_1 = require("../resolvers");
33
+ const buildTask = (options, c) => {
34
+ const { scheme, platform, flavour } = options;
35
+ const { platformBuildsDir } = c.buildConfig.paths;
36
+ const buildDirName = `${flavour}_${platform}`;
37
+ const publicBuildDirName = `${flavour}_${platform}-public`;
38
+ const buildDirPath = path.join(platformBuildsDir, buildDirName);
39
+ const publicBuildDirPath = path.join(platformBuildsDir, publicBuildDirName);
40
+ ;
41
+ fs.rmSync(buildDirPath, { recursive: true, force: true });
42
+ fs.rmSync(publicBuildDirPath, { recursive: true, force: true });
43
+ const cmd = `npx rnv build -s ${scheme} -p ${platform} -c ${flavour} --ci`;
44
+ (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
45
+ const safeSchemeString = (0, getSafeSchemeString_1.getSafeSchemeString)(scheme);
46
+ const schemeBuildDir = path.join(platformBuildsDir, safeSchemeString, buildDirName);
47
+ const schemePublicBuildDir = path.join(platformBuildsDir, safeSchemeString, publicBuildDirName);
48
+ fse.copySync(buildDirPath, schemeBuildDir);
49
+ if (fs.existsSync(publicBuildDirPath)) {
50
+ fse.copySync(publicBuildDirPath, schemePublicBuildDir);
51
+ }
52
+ };
53
+ const buildAllWithSchemes = () => {
54
+ const schemes = process.argv.slice(2);
55
+ if (!schemes.length) {
56
+ throw new Error('No scheme name to use found! Please use rnv scheme names as a param.');
57
+ }
58
+ const c = (0, resolvers_1.getBaseConfig)();
59
+ schemes.forEach((scheme, schemeIndex) => {
60
+ c.runtime.scheme = scheme;
61
+ (0, forEachSupportedPlatformFlavour_1.forEachSupportedPlatformFlavour)(c, (options) => buildTask(options, c), { schemeIndex, schemes });
62
+ });
63
+ return true;
64
+ };
65
+ const startTimestamp = Date.now();
66
+ buildAllWithSchemes();
67
+ const msPerSecond = 1000;
68
+ const scriptTotalTimeInSeconds = Math.ceil((Date.now() - startTimestamp) / msPerSecond);
69
+ console.log(`buildAllWithSchemes: done in ${scriptTotalTimeInSeconds} second(s)!`);
@@ -21,7 +21,7 @@ const deployLivePlatform = () => {
21
21
  c.platform = platform;
22
22
  c.runtime.scheme = buildSchemes_1.BuildSchemes.RELEASE_PROD_DIST;
23
23
  const { scheme } = c.runtime;
24
- const { supportedFlavours = [] } = c.buildConfig.platforms[platform]?.deploy || {};
24
+ const supportedFlavours = (0, resolvers_1.resolveSupportedFlavoursForPlatform)(c, platform);
25
25
  const o = { scheme, platform };
26
26
  supportedFlavours.forEach((flavour, flavourIndex) => {
27
27
  console.log((0, forEachSupportedPlatformFlavour_1.getProgressMessage)({
@@ -26,9 +26,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.deployProductionPackagesToAppCenter = void 0;
27
27
  const child_process_1 = require("child_process");
28
28
  const fs = __importStar(require("fs"));
29
- const index_1 = require("../../../constants/index");
29
+ const constants_1 = require("../../../constants");
30
30
  const buildProductionPackages_1 = require("../../../constants/buildProductionPackages");
31
- const index_2 = require("../../../resolvers/index");
31
+ const resolvers_1 = require("../../../resolvers");
32
32
  const appCenter_1 = require("./appCenter");
33
33
  const newLine = '\r\n';
34
34
  const getAppCenterConfig = (c) => {
@@ -40,22 +40,22 @@ const getAppCenterConfig = (c) => {
40
40
  }
41
41
  };
42
42
  const getPlatformPackagesList = (c) => {
43
- const scheme = index_1.BuildSchemes.RELEASE_PROD_DIST;
43
+ const scheme = constants_1.BuildSchemes.RELEASE_PROD_DIST;
44
44
  const packagesList = [];
45
- const platforms = (0, index_2.resolveSupportedPlatforms)(c)
45
+ const platforms = (0, resolvers_1.resolveSupportedPlatforms)(c)
46
46
  .filter((platform) => buildProductionPackages_1.SUPPORTED_PACKAGE_PLATFORMS.includes(platform));
47
47
  platforms.forEach((platform) => {
48
- const { supportedFlavours = [] } = c.buildConfig.platforms[platform]?.deploy || {};
48
+ const supportedFlavours = (0, resolvers_1.resolveSupportedFlavoursForPlatform)(c, platform);
49
49
  const platformObj = {
50
50
  platformName: platform,
51
51
  packages: supportedFlavours.map((appConfigID) => {
52
- const c = (0, index_2.getBaseConfig)({
52
+ const c = (0, resolvers_1.getBaseConfig)({
53
53
  platform, scheme, appConfigID, productionPackagesHostedUrl: true
54
54
  });
55
55
  return {
56
- name: (0, index_2.resolveBuildFileName)(c),
56
+ name: (0, resolvers_1.resolveBuildFileName)(c),
57
57
  flavour: appConfigID,
58
- hostedUrl: `${(0, index_2.resolveProductionPackagesBaseUrl)(c)}/public`,
58
+ hostedUrl: `${(0, resolvers_1.resolveProductionPackagesBaseUrl)(c)}/public`,
59
59
  };
60
60
  })
61
61
  };
@@ -74,7 +74,7 @@ const deployProductionPackagesToAppCenter = (c) => {
74
74
  }
75
75
  const { appName: centerAppName } = appCenterConfig;
76
76
  const token = getAppCenterToken();
77
- const zipPath = (0, index_2.getProductionZipFileRelativePath)(c);
77
+ const zipPath = (0, resolvers_1.getProductionZipFileRelativePath)(c);
78
78
  const { appName, packageVersion } = c.buildConfig.common;
79
79
  if (!centerAppName)
80
80
  throw new Error('Missing centerAppName in appCenterConfig');
@@ -27,7 +27,7 @@ exports.deployToAppCenter = void 0;
27
27
  const child_process_1 = require("child_process");
28
28
  const fs = __importStar(require("fs"));
29
29
  const rnv_1 = require("rnv");
30
- const index_1 = require("../../../resolvers/index");
30
+ const resolvers_1 = require("../../../resolvers");
31
31
  const urlsMarkdown_1 = require("../urlsMarkdown");
32
32
  const appCenter_1 = require("./appCenter");
33
33
  const getAppCenterConfigByPlatformName = (c, platformName) => {
@@ -49,7 +49,7 @@ const processPlatform = (c, platformName) => {
49
49
  return;
50
50
  const { appName } = appCenterConfig;
51
51
  const token = getAppCenterTokenByPlatform(platformName);
52
- const zipPath = (0, index_1.resolveZippedPlatformBuildsRelativeFilePath)(c, platformName);
52
+ const zipPath = (0, resolvers_1.resolveZippedPlatformBuildsRelativeFilePath)(c, platformName);
53
53
  const buildVersion = getConfigProp(c, platformName, 'packageVersion', '');
54
54
  const releaseNotesPath = getConfigProp(c, platformName, 'releaseNotes', {}).relativePath || '';
55
55
  if (!appName || !token || !releaseNotesPath || !zipPath || !buildVersion)
@@ -71,6 +71,6 @@ const processPlatform = (c, platformName) => {
71
71
  });
72
72
  };
73
73
  const deployToAppCenter = (c) => {
74
- (0, index_1.resolveSupportedPlatforms)(c).forEach((platformName) => processPlatform(c, platformName));
74
+ (0, resolvers_1.resolveSupportedPlatforms)(c).forEach((platformName) => processPlatform(c, platformName));
75
75
  };
76
76
  exports.deployToAppCenter = deployToAppCenter;
@@ -41,13 +41,16 @@ const getSlackPayload = (c) => {
41
41
  default: throw new Error('Notify Slack: unsupported or undefined release type! Did you pass it as an argument?');
42
42
  }
43
43
  };
44
- const notifySlack = (c) => {
45
- const contentType = '"Content-type: application/json"';
46
- const data = `--data '${JSON.stringify(getSlackPayload(c))}'`;
47
- const webHookUrl = c.buildConfig.common.deploy.slack?.webhookUrl || '';
48
- if (webHookUrl) {
49
- const cmd = `curl -X POST -H ${contentType} ${data} ${webHookUrl}`;
50
- (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
51
- }
44
+ const notifySlack = (c, schemes) => {
45
+ schemes.forEach((scheme) => {
46
+ c.runtime.scheme = scheme;
47
+ const contentType = '"Content-type: application/json"';
48
+ const data = `--data '${JSON.stringify(getSlackPayload(c))}'`;
49
+ const webHookUrl = c.buildConfig.common.deploy.slack?.webhookUrl || '';
50
+ if (webHookUrl) {
51
+ const cmd = `curl -X POST -H ${contentType} ${data} ${webHookUrl}`;
52
+ (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
53
+ }
54
+ });
52
55
  };
53
56
  exports.notifySlack = notifySlack;
@@ -28,6 +28,7 @@ const child_process_1 = require("child_process");
28
28
  const fs = __importStar(require("fs"));
29
29
  const constants_1 = require("../../constants");
30
30
  const resolvers_1 = require("../../resolvers");
31
+ const getSafeSchemeString_1 = require("../../utils/getSafeSchemeString");
31
32
  const UNSUPPORTED_PLATFORMS = [constants_1.Platforms.WEBTV];
32
33
  const executeSync = (cmd) => (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
33
34
  const createNewRelease = (version) => {
@@ -54,15 +55,20 @@ const finalizeRelease = (version) => {
54
55
  };
55
56
  const processPlatform = (c, platform, version) => {
56
57
  const processFlavour = (flavour) => {
58
+ const { scheme } = c.runtime;
57
59
  const { platformBuildsDir } = c.buildConfig.paths;
58
- const mapsPath = `${platformBuildsDir}/${flavour}_${platform}-public/public/content/js`;
59
- const urlPrefix = `builds/${platform}/${flavour}/dist/${version}/public/content/js/`;
60
- if (!fs.existsSync(mapsPath))
60
+ const schemeDirName = (0, getSafeSchemeString_1.getSafeSchemeString)(scheme);
61
+ const envName = (0, resolvers_1.resolveBuildEnvName)(scheme);
62
+ const mapsPath = `${platformBuildsDir}/${schemeDirName}/${flavour}_${platform}-public/project/public/content/js`;
63
+ const urlPrefix = `builds/${platform}/${flavour}/dist/${version}/${envName}/public/content/js/`;
64
+ if (!fs.existsSync(mapsPath)) {
65
+ console.log(`Warning: non-existing mapsPath: ${mapsPath}`);
61
66
  return;
62
- console.log(`Uploading ${flavour}_${platform} sourcemaps to Sentry...`);
67
+ }
68
+ console.log(`Uploading ${schemeDirName}/${flavour}_${platform} sourcemaps to Sentry...`);
63
69
  uploadSourceMaps({ version, sourceMapsPath: mapsPath, urlPrefix });
64
70
  };
65
- const { supportedFlavours = [] } = c.buildConfig.platforms[platform]?.deploy || {};
71
+ const supportedFlavours = (0, resolvers_1.resolveSupportedFlavoursForPlatform)(c, platform);
66
72
  supportedFlavours.forEach(processFlavour);
67
73
  };
68
74
  const isSentryProjectConfigured = () => {
@@ -27,7 +27,7 @@ const doLatestDevelopmentRelease = (c) => {
27
27
  const doLatestReleaseCandidateRelease = (c) => {
28
28
  console.log('doLatestReleaseCandidateRelease');
29
29
  deployBuilds(c);
30
- (0, notifySlack_1.notifySlack)(c);
30
+ (0, notifySlack_1.notifySlack)(c, [c.runtime.scheme]);
31
31
  return true;
32
32
  };
33
33
  const doLatestRelease = (c) => {
@@ -37,7 +37,7 @@ const doLatestRelease = (c) => {
37
37
  const doStagingDistributionRelease = (c) => {
38
38
  console.log('doStagingDistributionRelease');
39
39
  deployBuilds(c);
40
- (0, notifySlack_1.notifySlack)(c);
40
+ (0, notifySlack_1.notifySlack)(c, [c.runtime.scheme]);
41
41
  return true;
42
42
  };
43
43
  const doProductionDistributionRelease = (c) => {
@@ -48,7 +48,7 @@ const doProductionDistributionRelease = (c) => {
48
48
  (0, deleteSourceMaps_1.deleteSourceMaps)(c);
49
49
  (0, githubRelease_1.githubRelease)(c);
50
50
  (0, deployToAppCenter_1.deployToAppCenter)(c);
51
- (0, notifySlack_1.notifySlack)(c);
51
+ (0, notifySlack_1.notifySlack)(c, [c.runtime.scheme]);
52
52
  return true;
53
53
  };
54
54
  const releaseAllWithScheme = () => {
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const child_process_1 = require("child_process");
4
+ const forEachSupportedPlatformFlavour_1 = require("../utils/forEachSupportedPlatformFlavour");
5
+ const resolvers_1 = require("../resolvers");
6
+ const zipStagingProdBuildsByPlatforms_1 = require("../utils/zipStagingProdBuildsByPlatforms");
7
+ const deleteSourceMaps_1 = require("./release/deleteSourceMaps");
8
+ const deployToAppCenter_1 = require("./release/appCenter/deployToAppCenter");
9
+ const githubRelease_1 = require("./release/githubRelease");
10
+ const notifySlack_1 = require("./release/notifySlack/notifySlack");
11
+ const sentryRelease_1 = require("./release/sentryRelease");
12
+ const constants_1 = require("../constants");
13
+ const deployTask = (options) => {
14
+ const { scheme, platform, flavour } = options;
15
+ const cmd = `npx rnv deploy -s ${scheme} -p ${platform} -c ${flavour} --ci --only --schemeFolder`;
16
+ (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
17
+ };
18
+ const deployBuilds = (c) => {
19
+ console.log('Deploying the builds...');
20
+ (0, forEachSupportedPlatformFlavour_1.forEachSupportedPlatformFlavour)(c, deployTask);
21
+ return true;
22
+ };
23
+ const doLatestDevelopmentRelease = (c) => {
24
+ console.log('doLatestDevelopmentRelease');
25
+ return deployBuilds(c);
26
+ };
27
+ const doLatestReleaseCandidateRelease = (c, schemes) => {
28
+ console.log('doLatestReleaseCandidateRelease', schemes);
29
+ const [stagingScheme, prodScheme] = schemes;
30
+ if (stagingScheme) {
31
+ c.runtime.scheme = stagingScheme.type;
32
+ deployBuilds(c);
33
+ }
34
+ if (prodScheme) {
35
+ c.runtime.scheme = prodScheme.type;
36
+ deployBuilds(c);
37
+ }
38
+ const schemeArr = schemes.map((scheme) => scheme?.type).filter(Boolean);
39
+ (0, notifySlack_1.notifySlack)(c, schemeArr);
40
+ return true;
41
+ };
42
+ const doLatestRelease = (c, schemes) => {
43
+ console.log('doLatestRelease', schemes);
44
+ const [stagingScheme, prodScheme] = schemes;
45
+ if (stagingScheme) {
46
+ c.runtime.scheme = stagingScheme.type;
47
+ deployBuilds(c);
48
+ }
49
+ if (prodScheme) {
50
+ c.runtime.scheme = prodScheme.type;
51
+ deployBuilds(c);
52
+ }
53
+ };
54
+ const doDistributionRelease = (c, schemes) => {
55
+ console.log('doDistributionRelease', schemes);
56
+ const [stagingScheme, prodScheme] = schemes;
57
+ if (stagingScheme) {
58
+ c.runtime.scheme = stagingScheme.type;
59
+ deployBuilds(c);
60
+ }
61
+ if (prodScheme) {
62
+ c.runtime.scheme = prodScheme.type;
63
+ (0, zipStagingProdBuildsByPlatforms_1.zipStagingProdBuildsByPlatforms)(c, [stagingScheme?.type, prodScheme.type]);
64
+ deployBuilds(c);
65
+ (0, sentryRelease_1.sentryRelease)(c);
66
+ (0, deleteSourceMaps_1.deleteSourceMaps)(c);
67
+ (0, githubRelease_1.githubRelease)(c);
68
+ (0, deployToAppCenter_1.deployToAppCenter)(c);
69
+ }
70
+ const schemeArr = schemes.map((scheme) => scheme?.type).filter(Boolean);
71
+ (0, notifySlack_1.notifySlack)(c, schemeArr);
72
+ };
73
+ const releaseAllWithSchemes = () => {
74
+ const schemes = process.argv.slice(2);
75
+ if (!schemes.length) {
76
+ throw new Error('No scheme name to use found! Please use rnv scheme names as a param.');
77
+ }
78
+ const c = (0, resolvers_1.getBaseConfig)();
79
+ const schemesArr = schemes.map((scheme) => ({ type: scheme, processed: false }));
80
+ schemesArr.forEach((schemeObj) => {
81
+ if (schemeObj.processed)
82
+ return;
83
+ switch (schemeObj.type) {
84
+ case constants_1.BuildSchemes.DEV_LATEST:
85
+ doLatestDevelopmentRelease(c);
86
+ schemeObj.processed = true;
87
+ break;
88
+ case constants_1.BuildSchemes.RC_STAGING_LATEST:
89
+ case constants_1.BuildSchemes.RC_PROD_LATEST:
90
+ {
91
+ const [staging, prod] = findSchemes(schemesArr, [
92
+ constants_1.BuildSchemes.RC_STAGING_LATEST,
93
+ constants_1.BuildSchemes.RC_PROD_LATEST,
94
+ ]);
95
+ doLatestReleaseCandidateRelease(c, [staging, prod]);
96
+ if (staging) {
97
+ staging.processed = true;
98
+ }
99
+ if (prod) {
100
+ prod.processed = true;
101
+ }
102
+ }
103
+ break;
104
+ case constants_1.BuildSchemes.RELEASE_STAGING_LATEST:
105
+ case constants_1.BuildSchemes.RELEASE_PROD_LATEST:
106
+ {
107
+ const [staging, prod] = findSchemes(schemesArr, [
108
+ constants_1.BuildSchemes.RELEASE_STAGING_LATEST,
109
+ constants_1.BuildSchemes.RELEASE_PROD_LATEST,
110
+ ]);
111
+ doLatestRelease(c, [staging, prod]);
112
+ if (staging) {
113
+ staging.processed = true;
114
+ }
115
+ if (prod) {
116
+ prod.processed = true;
117
+ }
118
+ }
119
+ break;
120
+ case constants_1.BuildSchemes.RELEASE_STAGING_DIST:
121
+ case constants_1.BuildSchemes.RELEASE_PROD_DIST:
122
+ {
123
+ const [staging, prod] = findSchemes(schemesArr, [
124
+ constants_1.BuildSchemes.RELEASE_STAGING_DIST,
125
+ constants_1.BuildSchemes.RELEASE_PROD_DIST,
126
+ ]);
127
+ doDistributionRelease(c, [staging, prod]);
128
+ if (staging) {
129
+ staging.processed = true;
130
+ }
131
+ if (prod) {
132
+ prod.processed = true;
133
+ }
134
+ }
135
+ break;
136
+ default:
137
+ throw new Error('Unsupported scheme to release!');
138
+ }
139
+ });
140
+ const deployLocations = schemesArr.reduce((acc, scheme) => {
141
+ const schemeType = scheme.type;
142
+ c.runtime.scheme = schemeType;
143
+ acc[schemeType] = (0, resolvers_1.resolveDeployLocations)(c);
144
+ return acc;
145
+ }, {});
146
+ const spacing = 2;
147
+ console.log(JSON.stringify(deployLocations, null, spacing));
148
+ return true;
149
+ };
150
+ const findSchemes = (schemesArray, schemesToFind) => {
151
+ return schemesToFind.map((schemeToFind) => (schemesArray.find((schemeObj) => schemeObj.type === schemeToFind)));
152
+ };
153
+ const startTimestamp = Date.now();
154
+ releaseAllWithSchemes();
155
+ const msPerSecond = 1000;
156
+ const scriptTotalTimeInSeconds = Math.ceil((Date.now() - startTimestamp) / msPerSecond);
157
+ console.log(`releaseAllWithSchemes: done in ${scriptTotalTimeInSeconds} second(s)!`);
@@ -29,17 +29,20 @@ 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) => {
@@ -49,8 +52,10 @@ const urlToS3Protocol = (url) => {
49
52
  };
50
53
  exports.urlToS3Protocol = urlToS3Protocol;
51
54
  const deployToS3 = async (c) => {
55
+ rnv_1.Logger.logTask(`deployToS3`);
52
56
  const { platform, runtime } = c;
53
- 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}`);
54
59
  const { isBuildHosted } = getConfigProp(c, platform, 'webpackConfig', {});
55
60
  const baseUrl = (0, resolvers_1.resolveBaseUrl)({
56
61
  platform,
@@ -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);
@@ -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;
@@ -30,7 +30,7 @@ const _forEachPlatformFlavour = (platforms, c, cb, options = {}) => {
30
30
  const { scheme } = c.runtime;
31
31
  return cb({ platform, flavour, scheme });
32
32
  };
33
- const { supportedFlavours = [] } = c.buildConfig.platforms[platform]?.deploy || {};
33
+ const supportedFlavours = (0, resolvers_1.resolveSupportedFlavoursForPlatform)(c, platform);
34
34
  supportedFlavours.forEach(processFlavour);
35
35
  };
36
36
  platforms.forEach(processPlatformFlavours);
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/smartapps-bigscreen-rnv-build-engine",
3
- "version": "0.17.6-alpha.7",
3
+ "version": "0.17.6-alpha.8",
4
4
  "description": "Package with build engine for SmartApps BIGscreen projects...",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {