@bravemobile/react-native-code-push 8.3.0 → 9.0.0-alpha.0
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.
- package/CodePush.js +107 -136
- package/README.md +0 -5
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +1 -4
- package/babel-plugin-code-push/index.js +197 -0
- package/babel-plugin-code-push/package-lock.json +10463 -0
- package/babel-plugin-code-push/package.json +26 -0
- package/babel-plugin-code-push/test/.babelrc.js +12 -0
- package/babel-plugin-code-push/test/cases/test1-config +15 -0
- package/babel-plugin-code-push/test/cases/test1-input +3 -0
- package/babel-plugin-code-push/test/cases/test1-output +11 -0
- package/babel-plugin-code-push/test/cases/test2-config +9 -0
- package/babel-plugin-code-push/test/cases/test2-input +3 -0
- package/babel-plugin-code-push/test/cases/test2-output +7 -0
- package/babel-plugin-code-push/test/codepush.config.js +15 -0
- package/babel-plugin-code-push/test/plugin.test.js +44 -0
- package/babel.config.js +3 -0
- package/cli/commands/bundleCommand/bundleCodePush.js +49 -0
- package/cli/commands/bundleCommand/index.js +25 -0
- package/cli/commands/createHistoryCommand/createReleaseHistory.js +53 -0
- package/cli/commands/createHistoryCommand/index.js +28 -0
- package/cli/commands/releaseCommand/addToReleaseHistory.js +75 -0
- package/cli/commands/releaseCommand/index.js +61 -0
- package/cli/commands/releaseCommand/release.js +88 -0
- package/cli/commands/showHistoryCommand/index.js +28 -0
- package/cli/commands/updateHistoryCommand/index.js +49 -0
- package/cli/commands/updateHistoryCommand/updateReleaseHistory.js +62 -0
- package/cli/constant.js +3 -0
- package/cli/functions/getReactTempDir.js +16 -0
- package/cli/functions/makeCodePushBundle.js +27 -0
- package/cli/functions/prepareToBundleJS.js +12 -0
- package/cli/functions/runHermesEmitBinaryCommand.js +213 -0
- package/cli/functions/runReactNativeBundleCommand.js +59 -0
- package/cli/index.js +43 -0
- package/cli/utils/file-utils.js +42 -0
- package/cli/utils/fsUtils.js +49 -0
- package/cli/utils/hash-utils.js +227 -0
- package/cli/utils/promisfied-fs.js +29 -0
- package/cli/utils/showLogo.js +23 -0
- package/cli/utils/zip.js +89 -0
- package/code-push.config.example.supabase.ts +114 -0
- package/docs/setup-android.md +3 -11
- package/eslint.config.mjs +32 -0
- package/package-mixins.js +1 -8
- package/package.json +26 -23
- package/react-native.config.js +3 -1
- package/typings/react-native-code-push.d.ts +91 -16
- package/versioning/BaseVersioning.js +126 -0
- package/versioning/BaseVersioning.test.js +15 -0
- package/versioning/IncrementalVersioning.js +9 -0
- package/versioning/IncrementalVersioning.test.js +186 -0
- package/versioning/SemverVersioning.js +10 -0
- package/versioning/SemverVersioning.test.js +205 -0
- package/versioning/index.js +7 -0
- package/.azurepipelines/build-rn-code-push-1es.yml +0 -104
- package/.azurepipelines/test-rn-code-push.yml +0 -94
- package/.config/CredScanSuppressions.json +0 -14
- package/docs/setup-windows.md +0 -121
- package/request-fetch-adapter.js +0 -52
- package/scripts/postlink/android/postlink.js +0 -87
- package/scripts/postlink/ios/postlink.js +0 -116
- package/scripts/postlink/run.js +0 -11
- package/scripts/postunlink/android/postunlink.js +0 -74
- package/scripts/postunlink/ios/postunlink.js +0 -87
- package/scripts/postunlink/run.js +0 -11
- package/scripts/tools/linkToolsAndroid.js +0 -57
- package/scripts/tools/linkToolsIos.js +0 -130
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bravemobile/babel-plugin-code-push",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Babel plugin for @bravemobile/react-native-code-push",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "cd test && jest"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@bravemobile/react-native-code-push": "../"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@babel/cli": "^7.25.9",
|
|
17
|
+
"@babel/core": "^7.26.0",
|
|
18
|
+
"@babel/node": "^7.26.0",
|
|
19
|
+
"@babel/preset-env": "^7.26.0",
|
|
20
|
+
"@types/shelljs": "^0.8.15",
|
|
21
|
+
"babel-cli": "^6.26.0",
|
|
22
|
+
"babel-jest": "^29.7.0",
|
|
23
|
+
"jest": "^29.7.0",
|
|
24
|
+
"shelljs": "^0.8.5"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const {
|
|
2
|
+
SemverVersioning,
|
|
3
|
+
} = require("@bravemobile/react-native-code-push/versioning");
|
|
4
|
+
|
|
5
|
+
class CustomVersioning extends SemverVersioning {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
bundleHost: "bundleHost",
|
|
13
|
+
runtimeVersion: "runtimeVersion",
|
|
14
|
+
versioning: CustomVersioning,
|
|
15
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SemverVersioning } from "@bravemobile/react-native-code-push/versioning";
|
|
2
|
+
import codePush from "@bravemobile/react-native-code-push";
|
|
3
|
+
codePush({
|
|
4
|
+
bundleHost: "bundleHost",
|
|
5
|
+
runtimeVersion: "runtimeVersion",
|
|
6
|
+
versioning: class CustomVersioning extends SemverVersioning {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const {
|
|
2
|
+
SemverVersioning,
|
|
3
|
+
} = require("@bravemobile/react-native-code-push/versioning");
|
|
4
|
+
|
|
5
|
+
class CustomVersioning extends SemverVersioning {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
bundleHost: "bundleHost",
|
|
13
|
+
runtimeVersion: "runtimeVersion",
|
|
14
|
+
versioning: CustomVersioning,
|
|
15
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { transformSync } from "@babel/core";
|
|
3
|
+
|
|
4
|
+
describe("babel plugin", () => {
|
|
5
|
+
test("case1: using custom Versioning class", () => {
|
|
6
|
+
const input = fs.readFileSync("./cases/test1-input", { encoding: "utf-8" });
|
|
7
|
+
const expected = fs.readFileSync("./cases/test1-output", {
|
|
8
|
+
encoding: "utf-8",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const generated = transformSync(input, {
|
|
12
|
+
plugins: [
|
|
13
|
+
[
|
|
14
|
+
"../index.js",
|
|
15
|
+
{
|
|
16
|
+
configPath: "./cases/test1-config",
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(generated.code).toBe(expected);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("case2: using provided Versioning class", () => {
|
|
26
|
+
const input = fs.readFileSync("./cases/test2-input", { encoding: "utf-8" });
|
|
27
|
+
const expected = fs.readFileSync("./cases/test2-output", {
|
|
28
|
+
encoding: "utf-8",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const generated = transformSync(input, {
|
|
32
|
+
plugins: [
|
|
33
|
+
[
|
|
34
|
+
"../index.js",
|
|
35
|
+
{
|
|
36
|
+
configPath: "./cases/test2-config",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
expect(generated.code).toBe(expected);
|
|
43
|
+
});
|
|
44
|
+
});
|
package/babel.config.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const { prepareToBundleJS } = require('../../functions/prepareToBundleJS');
|
|
2
|
+
const { runReactNativeBundleCommand } = require('../../functions/runReactNativeBundleCommand');
|
|
3
|
+
const { getReactTempDir } = require('../../functions/getReactTempDir');
|
|
4
|
+
const { runHermesEmitBinaryCommand } = require('../../functions/runHermesEmitBinaryCommand');
|
|
5
|
+
const { makeCodePushBundle } = require('../../functions/makeCodePushBundle');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param platform {string} 'ios' | 'android'
|
|
9
|
+
* @param outputRootPath {string}
|
|
10
|
+
* @param entryFile {string}
|
|
11
|
+
* @param bundleName {string|undefined}
|
|
12
|
+
* @return {Promise<{bundleFileName: string, packageHash: string}>}
|
|
13
|
+
*/
|
|
14
|
+
async function bundleCodePush(
|
|
15
|
+
platform = 'ios',
|
|
16
|
+
outputRootPath = 'build',
|
|
17
|
+
entryFile = 'index.ts',
|
|
18
|
+
bundleName,
|
|
19
|
+
) {
|
|
20
|
+
const OUTPUT_CONTENT_PATH = `${outputRootPath}/CodePush`;
|
|
21
|
+
const BUNDLE_NAME_DEFAULT = platform === 'ios' ? 'main.jsbundle' : 'index.android.bundle';
|
|
22
|
+
const _bundleName = bundleName ? bundleName : BUNDLE_NAME_DEFAULT;
|
|
23
|
+
const SOURCEMAP_OUTPUT = `${outputRootPath}/${_bundleName}.map`;
|
|
24
|
+
|
|
25
|
+
prepareToBundleJS({ deleteDirs: [outputRootPath, getReactTempDir()], makeDir: OUTPUT_CONTENT_PATH });
|
|
26
|
+
|
|
27
|
+
runReactNativeBundleCommand(
|
|
28
|
+
_bundleName,
|
|
29
|
+
OUTPUT_CONTENT_PATH,
|
|
30
|
+
platform,
|
|
31
|
+
SOURCEMAP_OUTPUT,
|
|
32
|
+
entryFile,
|
|
33
|
+
);
|
|
34
|
+
console.log('log: JS bundling complete');
|
|
35
|
+
|
|
36
|
+
await runHermesEmitBinaryCommand(
|
|
37
|
+
_bundleName,
|
|
38
|
+
OUTPUT_CONTENT_PATH,
|
|
39
|
+
SOURCEMAP_OUTPUT,
|
|
40
|
+
);
|
|
41
|
+
console.log('log: Hermes compilation complete');
|
|
42
|
+
|
|
43
|
+
const { bundleFileName, packageHash } = await makeCodePushBundle(OUTPUT_CONTENT_PATH);
|
|
44
|
+
console.log(`log: CodePush bundle created (file name: ${bundleFileName})`);
|
|
45
|
+
|
|
46
|
+
return { bundleFileName, packageHash }; // returns for release command implementation
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = { bundleCodePush: bundleCodePush };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { program, Option } = require("commander");
|
|
2
|
+
const { bundleCodePush } = require("./bundleCodePush");
|
|
3
|
+
|
|
4
|
+
program.command('bundle')
|
|
5
|
+
.description('Creates a CodePush bundle file (assumes Hermes is enabled).')
|
|
6
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
7
|
+
.option('-o, --output-path <string>', 'path to output root directory', 'build')
|
|
8
|
+
.option('-e, --entry-file <string>', 'path to JS/TS entry file', 'index.ts')
|
|
9
|
+
.option('-b, --bundle-name <string>', 'bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")')
|
|
10
|
+
/**
|
|
11
|
+
* @param {Object} options
|
|
12
|
+
* @param {string} options.platform
|
|
13
|
+
* @param {string} options.outputPath
|
|
14
|
+
* @param {string} options.entryFile
|
|
15
|
+
* @param {string} options.bundleName
|
|
16
|
+
* @return {void}
|
|
17
|
+
*/
|
|
18
|
+
.action((options) => {
|
|
19
|
+
bundleCodePush(
|
|
20
|
+
options.platform,
|
|
21
|
+
options.outputPath,
|
|
22
|
+
options.entryFile,
|
|
23
|
+
options.bundleName,
|
|
24
|
+
)
|
|
25
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param targetVersion {string}
|
|
7
|
+
* @param setReleaseHistory {
|
|
8
|
+
* function(
|
|
9
|
+
* targetBinaryVersion: string,
|
|
10
|
+
* jsonFilePath: string,
|
|
11
|
+
* releaseInfo: ReleaseHistoryInterface,
|
|
12
|
+
* platform: string,
|
|
13
|
+
* identifier: string
|
|
14
|
+
* ): Promise<void>}
|
|
15
|
+
* @param platform {"ios" | "android"}
|
|
16
|
+
* @param identifier {string}
|
|
17
|
+
* @returns {Promise<void>}
|
|
18
|
+
*/
|
|
19
|
+
async function createReleaseHistory(
|
|
20
|
+
targetVersion,
|
|
21
|
+
setReleaseHistory,
|
|
22
|
+
platform,
|
|
23
|
+
identifier,
|
|
24
|
+
) {
|
|
25
|
+
const BINARY_RELEASE = {
|
|
26
|
+
enabled: true,
|
|
27
|
+
mandatory: false,
|
|
28
|
+
downloadUrl: "",
|
|
29
|
+
packageHash: "",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** @type {ReleaseHistoryInterface} */
|
|
33
|
+
const INITIAL_HISTORY = {
|
|
34
|
+
[targetVersion]: BINARY_RELEASE
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const JSON_FILE_NAME = `${targetVersion}.json`;
|
|
39
|
+
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
|
|
40
|
+
|
|
41
|
+
console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify(INITIAL_HISTORY, null, 2));
|
|
42
|
+
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(INITIAL_HISTORY));
|
|
43
|
+
|
|
44
|
+
await setReleaseHistory(targetVersion, JSON_FILE_PATH, INITIAL_HISTORY, platform, identifier)
|
|
45
|
+
|
|
46
|
+
fs.unlinkSync(JSON_FILE_PATH);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error('Error occurred while creating new history:', error);
|
|
49
|
+
process.exit(1)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = { createReleaseHistory: createReleaseHistory }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { program, Option } = require("commander");
|
|
2
|
+
const { findAndReadConfigFile } = require("../../utils/fsUtils");
|
|
3
|
+
const { createReleaseHistory } = require("./createReleaseHistory");
|
|
4
|
+
|
|
5
|
+
program.command('create-history')
|
|
6
|
+
.description('Creates a new release history for the binary app.')
|
|
7
|
+
.requiredOption('-b, --binary-version <string>', '(Required) The target binary version')
|
|
8
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
9
|
+
.option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
|
|
10
|
+
.option('-c, --config <path>', 'set config file name (JS/TS)', 'code-push.config.ts')
|
|
11
|
+
/**
|
|
12
|
+
* @param {Object} options
|
|
13
|
+
* @param {string} options.binaryVersion
|
|
14
|
+
* @param {string} options.platform
|
|
15
|
+
* @param {string} options.identifier
|
|
16
|
+
* @param {string} options.config
|
|
17
|
+
* @return {void}
|
|
18
|
+
*/
|
|
19
|
+
.action(async (options) => {
|
|
20
|
+
const config = findAndReadConfigFile(process.cwd(), options.config);
|
|
21
|
+
|
|
22
|
+
await createReleaseHistory(
|
|
23
|
+
options.binaryVersion,
|
|
24
|
+
config.setReleaseHistory,
|
|
25
|
+
options.platform,
|
|
26
|
+
options.identifier
|
|
27
|
+
);
|
|
28
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param appVersion {string}
|
|
7
|
+
* @param binaryVersion {string}
|
|
8
|
+
* @param bundleDownloadUrl {string}
|
|
9
|
+
* @param packageHash {string}
|
|
10
|
+
* @param getReleaseHistory {
|
|
11
|
+
* function(
|
|
12
|
+
* targetBinaryVersion: string,
|
|
13
|
+
* platform: string,
|
|
14
|
+
* identifier?: string
|
|
15
|
+
* ): Promise<ReleaseHistoryInterface>}
|
|
16
|
+
* @param setReleaseHistory {
|
|
17
|
+
* function(
|
|
18
|
+
* targetBinaryVersion: string,
|
|
19
|
+
* jsonFilePath: string,
|
|
20
|
+
* releaseInfo: ReleaseHistoryInterface,
|
|
21
|
+
* platform: string,
|
|
22
|
+
* identifier?: string
|
|
23
|
+
* ): Promise<void>}
|
|
24
|
+
* @param platform {"ios" | "android"}
|
|
25
|
+
* @param identifier {string?}
|
|
26
|
+
* @param mandatory {boolean?}
|
|
27
|
+
* @param enable {boolean?}
|
|
28
|
+
* @returns {Promise<void>}
|
|
29
|
+
*/
|
|
30
|
+
async function addToReleaseHistory(
|
|
31
|
+
appVersion,
|
|
32
|
+
binaryVersion,
|
|
33
|
+
bundleDownloadUrl,
|
|
34
|
+
packageHash,
|
|
35
|
+
getReleaseHistory,
|
|
36
|
+
setReleaseHistory,
|
|
37
|
+
platform,
|
|
38
|
+
identifier,
|
|
39
|
+
mandatory,
|
|
40
|
+
enable,
|
|
41
|
+
) {
|
|
42
|
+
const releaseHistory = await getReleaseHistory(binaryVersion, platform, identifier);
|
|
43
|
+
|
|
44
|
+
const updateInfo = releaseHistory[appVersion]
|
|
45
|
+
if (updateInfo) {
|
|
46
|
+
console.error(`v${appVersion} is already released`)
|
|
47
|
+
process.exit(1)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const newReleaseHistory = structuredClone(releaseHistory);
|
|
51
|
+
|
|
52
|
+
newReleaseHistory[appVersion] = {
|
|
53
|
+
enabled: enable,
|
|
54
|
+
mandatory: mandatory,
|
|
55
|
+
downloadUrl: bundleDownloadUrl,
|
|
56
|
+
packageHash: packageHash,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const JSON_FILE_NAME = `${binaryVersion}.json`;
|
|
61
|
+
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME);
|
|
62
|
+
|
|
63
|
+
console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify(newReleaseHistory, null, 2));
|
|
64
|
+
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(newReleaseHistory));
|
|
65
|
+
|
|
66
|
+
await setReleaseHistory(binaryVersion, JSON_FILE_PATH, newReleaseHistory, platform, identifier)
|
|
67
|
+
|
|
68
|
+
fs.unlinkSync(JSON_FILE_PATH);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error('Error occurred while updating history:', error);
|
|
71
|
+
process.exit(1)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = { addToReleaseHistory: addToReleaseHistory }
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const { program, Option } = require("commander");
|
|
2
|
+
const SemVer = require('semver');
|
|
3
|
+
const { findAndReadConfigFile } = require("../../utils/fsUtils");
|
|
4
|
+
const { release } = require("./release");
|
|
5
|
+
|
|
6
|
+
program.command('release')
|
|
7
|
+
.description('Deploys a new CodePush update for a target binary app.\nAfter creating the CodePush bundle, it uploads the file and updates the ReleaseHistory information.\n`bundleUploader`, `getReleaseHistory`, and `setReleaseHistory` functions should be implemented in the config file.')
|
|
8
|
+
.requiredOption('-v, --app-version <string>', '(Required) The app version to be released. It must be greater than the binary version.')
|
|
9
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
10
|
+
.option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
|
|
11
|
+
.option('-c, --config <path>', 'set config file name (JS/TS)', 'code-push.config.ts')
|
|
12
|
+
.option('-o, --output-path <string>', 'path to output root directory', 'build')
|
|
13
|
+
.option('-e, --entry-file <string>', 'path to JS/TS entry file', 'index.ts')
|
|
14
|
+
.option('-j, --js-bundle-name <string>', 'JS bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")')
|
|
15
|
+
.option('-m, --mandatory <bool>', 'make the release to be mandatory', parseBoolean, false)
|
|
16
|
+
.option('--enable <bool>', 'make the release to be enabled', parseBoolean, true)
|
|
17
|
+
/**
|
|
18
|
+
* @param {Object} options
|
|
19
|
+
* @param {string} options.binaryVersion
|
|
20
|
+
* @param {string} options.appVersion
|
|
21
|
+
* @param {string} options.platform
|
|
22
|
+
* @param {string} options.identifier
|
|
23
|
+
* @param {string} options.config
|
|
24
|
+
* @param {string} options.outputPath
|
|
25
|
+
* @param {string} options.entryFile
|
|
26
|
+
* @param {string} options.bundleName
|
|
27
|
+
* @param {string} options.mandatory
|
|
28
|
+
* @param {string} options.enable
|
|
29
|
+
* @return {void}
|
|
30
|
+
*/
|
|
31
|
+
.action(async (options) => {
|
|
32
|
+
if (SemVer.lte(options.appVersion, options.binaryVersion)) {
|
|
33
|
+
console.error('The app version must be greater than the binary version.');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const config = findAndReadConfigFile(process.cwd(), options.config);
|
|
38
|
+
|
|
39
|
+
await release(
|
|
40
|
+
config.bundleUploader,
|
|
41
|
+
config.getReleaseHistory,
|
|
42
|
+
config.setReleaseHistory,
|
|
43
|
+
options.binaryVersion,
|
|
44
|
+
options.appVersion,
|
|
45
|
+
options.platform,
|
|
46
|
+
options.identifier,
|
|
47
|
+
options.outputPath,
|
|
48
|
+
options.entryFile,
|
|
49
|
+
options.bundleName,
|
|
50
|
+
options.mandatory,
|
|
51
|
+
options.enable,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
console.log('🚀 Release completed.')
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
function parseBoolean(value) {
|
|
58
|
+
if (value === 'true') return true;
|
|
59
|
+
if (value === 'false') return false;
|
|
60
|
+
else return undefined;
|
|
61
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const { bundleCodePush } = require("../bundleCommand/bundleCodePush");
|
|
2
|
+
const { addToReleaseHistory } = require("./addToReleaseHistory");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param bundleUploader {
|
|
6
|
+
* function(
|
|
7
|
+
* source: string,
|
|
8
|
+
* platform: "ios" | "android",
|
|
9
|
+
* identifier?: string
|
|
10
|
+
* ): Promise<{ downloadUrl: string }>}
|
|
11
|
+
* @param getReleaseHistory {
|
|
12
|
+
* function(
|
|
13
|
+
* targetBinaryVersion: string,
|
|
14
|
+
* platform: "ios" | "android",
|
|
15
|
+
* identifier?: string
|
|
16
|
+
* ): Promise<ReleaseHistoryInterface>}
|
|
17
|
+
* @param setReleaseHistory {
|
|
18
|
+
* function(
|
|
19
|
+
* targetBinaryVersion: string,
|
|
20
|
+
* jsonFilePath: string,
|
|
21
|
+
* releaseInfo: ReleaseHistoryInterface,
|
|
22
|
+
* platform: "ios" | "android",
|
|
23
|
+
* identifier?: string
|
|
24
|
+
* ): Promise<void>}
|
|
25
|
+
* @param binaryVersion {string}
|
|
26
|
+
* @param appVersion {string}
|
|
27
|
+
* @param platform {"ios" | "android"}
|
|
28
|
+
* @param identifier {string?}
|
|
29
|
+
* @param outputPath {string}
|
|
30
|
+
* @param entryFile {string}
|
|
31
|
+
* @param jsBundleName {string}
|
|
32
|
+
* @param mandatory {boolean}
|
|
33
|
+
* @param enable {boolean}
|
|
34
|
+
* @return {Promise<void>}
|
|
35
|
+
*/
|
|
36
|
+
async function release(
|
|
37
|
+
bundleUploader,
|
|
38
|
+
getReleaseHistory,
|
|
39
|
+
setReleaseHistory,
|
|
40
|
+
binaryVersion,
|
|
41
|
+
appVersion,
|
|
42
|
+
platform,
|
|
43
|
+
identifier,
|
|
44
|
+
outputPath,
|
|
45
|
+
entryFile,
|
|
46
|
+
jsBundleName,
|
|
47
|
+
mandatory,
|
|
48
|
+
enable,
|
|
49
|
+
) {
|
|
50
|
+
const { bundleFileName, packageHash } = await bundleCodePush(
|
|
51
|
+
platform,
|
|
52
|
+
outputPath,
|
|
53
|
+
entryFile,
|
|
54
|
+
jsBundleName,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const downloadUrl = await (async () => {
|
|
58
|
+
try {
|
|
59
|
+
const { downloadUrl } = await bundleUploader(`./${bundleFileName}`, platform, identifier);
|
|
60
|
+
return downloadUrl
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('Failed to upload the bundle file. Exiting the program.', error)
|
|
63
|
+
process.exit(1)
|
|
64
|
+
}
|
|
65
|
+
})();
|
|
66
|
+
|
|
67
|
+
await addToReleaseHistory(
|
|
68
|
+
appVersion,
|
|
69
|
+
binaryVersion,
|
|
70
|
+
downloadUrl,
|
|
71
|
+
packageHash,
|
|
72
|
+
getReleaseHistory,
|
|
73
|
+
setReleaseHistory,
|
|
74
|
+
platform,
|
|
75
|
+
identifier,
|
|
76
|
+
mandatory,
|
|
77
|
+
enable,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
deleteUploadedBundleFile(bundleFileName);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function deleteUploadedBundleFile(bundleFileName) {
|
|
84
|
+
const fs = require('fs');
|
|
85
|
+
fs.unlinkSync(`./${bundleFileName}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
module.exports = { release: release }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { program, Option } = require("commander");
|
|
2
|
+
const { findAndReadConfigFile } = require("../../utils/fsUtils");
|
|
3
|
+
|
|
4
|
+
program.command('show-history')
|
|
5
|
+
.description('Retrieves and prints the release history of a specific binary version.\n`getReleaseHistory` function should be implemented in the config file.')
|
|
6
|
+
.requiredOption('-b, --binary-version <string>', '(Required) The target binary version for retrieving the release history.')
|
|
7
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
8
|
+
.option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
|
|
9
|
+
.option('-c, --config <path>', 'configuration file name (JS/TS)', 'code-push.config.ts')
|
|
10
|
+
/**
|
|
11
|
+
* @param {Object} options
|
|
12
|
+
* @param {string} options.binaryVersion
|
|
13
|
+
* @param {string} options.platform
|
|
14
|
+
* @param {string} options.identifier
|
|
15
|
+
* @param {string} options.config
|
|
16
|
+
* @return {void}
|
|
17
|
+
*/
|
|
18
|
+
.action(async (options) => {
|
|
19
|
+
const config = findAndReadConfigFile(process.cwd(), options.config);
|
|
20
|
+
|
|
21
|
+
const releaseHistory = await config.getReleaseHistory(
|
|
22
|
+
options.binaryVersion,
|
|
23
|
+
options.platform,
|
|
24
|
+
options.identifier
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
console.log(JSON.stringify(releaseHistory, null, 2));
|
|
28
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const { program, Option } = require("commander");
|
|
2
|
+
const { findAndReadConfigFile } = require("../../utils/fsUtils");
|
|
3
|
+
const { updateReleaseHistory } = require("./updateReleaseHistory");
|
|
4
|
+
|
|
5
|
+
program.command('update-history')
|
|
6
|
+
.description('Updates the release history for a specific binary version.\n`getReleaseHistory`, `setReleaseHistory` functions should be implemented in the config file.')
|
|
7
|
+
.requiredOption('-v, --app-version <string>', '(Required) The app version for which update information is to be modified.')
|
|
8
|
+
.requiredOption('-b, --binary-version <string>', '(Required) The target binary version of the app for which update information is to be modified.')
|
|
9
|
+
.addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
|
|
10
|
+
.option('-i, --identifier <string>', 'reserved characters to distinguish the release.')
|
|
11
|
+
.option('-c, --config <path>', 'set config file name (JS/TS)', 'code-push.config.ts')
|
|
12
|
+
.option('-m, --mandatory <bool>', 'make the release to be mandatory', parseBoolean, undefined)
|
|
13
|
+
.option('-e, --enable <bool>', 'make the release to be enabled', parseBoolean, undefined)
|
|
14
|
+
/**
|
|
15
|
+
* @param {Object} options
|
|
16
|
+
* @param {string} options.appVersion
|
|
17
|
+
* @param {string} options.binaryVersion
|
|
18
|
+
* @param {string} options.platform
|
|
19
|
+
* @param {string} options.identifier
|
|
20
|
+
* @param {string} options.config
|
|
21
|
+
* @param {string} options.mandatory
|
|
22
|
+
* @param {string} options.enable
|
|
23
|
+
* @return {void}
|
|
24
|
+
*/
|
|
25
|
+
.action(async (options) => {
|
|
26
|
+
const config = findAndReadConfigFile(process.cwd(), options.config);
|
|
27
|
+
|
|
28
|
+
if (typeof options.mandatory !== "boolean" && typeof options.enable !== "boolean") {
|
|
29
|
+
console.error('No options specified. Exiting the program.')
|
|
30
|
+
process.exit(1)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
await updateReleaseHistory(
|
|
34
|
+
options.appVersion,
|
|
35
|
+
options.binaryVersion,
|
|
36
|
+
config.getReleaseHistory,
|
|
37
|
+
config.setReleaseHistory,
|
|
38
|
+
options.platform,
|
|
39
|
+
options.identifier,
|
|
40
|
+
options.mandatory,
|
|
41
|
+
options.enable,
|
|
42
|
+
)
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
function parseBoolean(value) {
|
|
46
|
+
if (value === 'true') return true;
|
|
47
|
+
if (value === 'false') return false;
|
|
48
|
+
else return undefined;
|
|
49
|
+
}
|