@algocare/react-native-code-push 10.0.1 → 10.2.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/cli/commands/common.js +3 -7
- package/cli/commands/createHistoryCommand/createReleaseHistory.js +2 -12
- package/cli/commands/createHistoryCommand/createReleaseHistoryList.js +2 -12
- package/cli/commands/createHistoryCommand/index.js +1 -3
- package/cli/commands/createPullRequestHistoryCommand/createPullRequestHistory.js +34 -0
- package/cli/commands/createPullRequestHistoryCommand/index.js +29 -0
- package/cli/commands/createPullRequestReleaseCommand/addToPullRequestRelease.js +57 -0
- package/cli/commands/createPullRequestReleaseCommand/createPullRequestRelease.js +91 -0
- package/cli/commands/createPullRequestReleaseCommand/index.js +68 -0
- package/cli/commands/releaseCommand/addToReleaseHistory.js +2 -11
- package/cli/commands/releaseCommand/index.js +1 -3
- package/cli/commands/releaseCommand/release.js +1 -8
- package/cli/commands/removePullRequestHistoryCommand/index.js +28 -0
- package/cli/commands/removePullRequestHistoryCommand/removePullRequestHistory.js +23 -0
- package/cli/commands/showHistoryCommand/index.js +1 -2
- package/cli/commands/updateHistoryCommand/index.js +1 -3
- package/cli/commands/updateHistoryCommand/updateReleaseHistory.js +2 -12
- package/cli/utils/version.js +2 -13
- package/code-push.config.js +31 -34
- package/package.json +1 -1
package/cli/commands/common.js
CHANGED
|
@@ -106,15 +106,13 @@ async function getAppVersionValueFromList(
|
|
|
106
106
|
binaryVersion,
|
|
107
107
|
app,
|
|
108
108
|
platform,
|
|
109
|
-
identifier,
|
|
110
109
|
count = 5
|
|
111
110
|
) {
|
|
112
111
|
const [currentAppVersionList] = await getAppVersions(
|
|
113
112
|
getReleaseHistory,
|
|
114
113
|
binaryVersion,
|
|
115
114
|
app,
|
|
116
|
-
platform
|
|
117
|
-
identifier
|
|
115
|
+
platform
|
|
118
116
|
)
|
|
119
117
|
|
|
120
118
|
if (!currentAppVersionList.length) {
|
|
@@ -203,15 +201,13 @@ async function getAppVersionValueFromInput(
|
|
|
203
201
|
getReleaseHistory,
|
|
204
202
|
binaryVersion,
|
|
205
203
|
app,
|
|
206
|
-
platform
|
|
207
|
-
identifier
|
|
204
|
+
platform
|
|
208
205
|
) {
|
|
209
206
|
const [currentAppVersionList, lastAppVersion] = await getAppVersions(
|
|
210
207
|
getReleaseHistory,
|
|
211
208
|
binaryVersion,
|
|
212
209
|
app,
|
|
213
|
-
platform
|
|
214
|
-
identifier
|
|
210
|
+
platform
|
|
215
211
|
)
|
|
216
212
|
|
|
217
213
|
const message = lastAppVersion
|
|
@@ -10,18 +10,15 @@ const path = require('path')
|
|
|
10
10
|
* jsonFilePath: string,
|
|
11
11
|
* releaseInfo: ReleaseHistoryInterface,
|
|
12
12
|
* platform: string,
|
|
13
|
-
* identifier: string
|
|
14
13
|
* ): Promise<void>}
|
|
15
14
|
* @param platform {"ios" | "android"}
|
|
16
|
-
* @param identifier {string}
|
|
17
15
|
* @returns {Promise<void>}
|
|
18
16
|
*/
|
|
19
17
|
async function createReleaseHistory(
|
|
20
18
|
app,
|
|
21
19
|
targetVersion,
|
|
22
20
|
setReleaseHistory,
|
|
23
|
-
platform
|
|
24
|
-
identifier
|
|
21
|
+
platform
|
|
25
22
|
) {
|
|
26
23
|
try {
|
|
27
24
|
const JSON_FILE_NAME = `${targetVersion}.json`
|
|
@@ -33,14 +30,7 @@ async function createReleaseHistory(
|
|
|
33
30
|
)
|
|
34
31
|
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify({}))
|
|
35
32
|
|
|
36
|
-
await setReleaseHistory(
|
|
37
|
-
targetVersion,
|
|
38
|
-
JSON_FILE_PATH,
|
|
39
|
-
{},
|
|
40
|
-
app,
|
|
41
|
-
platform,
|
|
42
|
-
identifier
|
|
43
|
-
)
|
|
33
|
+
await setReleaseHistory(targetVersion, JSON_FILE_PATH, {}, app, platform)
|
|
44
34
|
|
|
45
35
|
fs.unlinkSync(JSON_FILE_PATH)
|
|
46
36
|
} catch (error) {
|
|
@@ -5,12 +5,10 @@ const path = require('path')
|
|
|
5
5
|
* @param app {"user" | "device"}
|
|
6
6
|
* @param targetVersion {string}
|
|
7
7
|
* @param platform {"ios" | "android"}
|
|
8
|
-
* @param identifier {string}
|
|
9
8
|
* @param getBinaryVersionList {
|
|
10
9
|
* function(
|
|
11
10
|
* app: string,
|
|
12
11
|
* platform: string,
|
|
13
|
-
* identifier: string
|
|
14
12
|
* ): Promise<{ [version: string]: string }>
|
|
15
13
|
* }
|
|
16
14
|
* @param setBinaryVersionList {
|
|
@@ -18,7 +16,6 @@ const path = require('path')
|
|
|
18
16
|
* targetVersion: string,
|
|
19
17
|
* app: string,
|
|
20
18
|
* platform: string,
|
|
21
|
-
* identifier: string
|
|
22
19
|
* ): Promise<void>
|
|
23
20
|
* }
|
|
24
21
|
* @returns {Promise<void>}
|
|
@@ -27,7 +24,6 @@ async function createReleaseHistoryList(
|
|
|
27
24
|
app,
|
|
28
25
|
targetVersion,
|
|
29
26
|
platform,
|
|
30
|
-
identifier,
|
|
31
27
|
getBinaryVersionList,
|
|
32
28
|
setBinaryVersionList
|
|
33
29
|
) {
|
|
@@ -35,7 +31,7 @@ async function createReleaseHistoryList(
|
|
|
35
31
|
const JSON_FILE_NAME = 'list.json'
|
|
36
32
|
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME)
|
|
37
33
|
|
|
38
|
-
const currentList = await getBinaryVersionList(app, platform
|
|
34
|
+
const currentList = await getBinaryVersionList(app, platform)
|
|
39
35
|
|
|
40
36
|
if (currentList[targetVersion]) {
|
|
41
37
|
console.error(`Version ${targetVersion} is already released`)
|
|
@@ -44,13 +40,7 @@ async function createReleaseHistoryList(
|
|
|
44
40
|
|
|
45
41
|
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(currentList))
|
|
46
42
|
|
|
47
|
-
await setBinaryVersionList(
|
|
48
|
-
targetVersion,
|
|
49
|
-
JSON_FILE_PATH,
|
|
50
|
-
app,
|
|
51
|
-
platform,
|
|
52
|
-
identifier
|
|
53
|
-
)
|
|
43
|
+
await setBinaryVersionList(targetVersion, JSON_FILE_PATH, app, platform)
|
|
54
44
|
|
|
55
45
|
fs.unlinkSync(JSON_FILE_PATH)
|
|
56
46
|
} catch (error) {
|
|
@@ -45,15 +45,13 @@ program
|
|
|
45
45
|
answers.app,
|
|
46
46
|
answers.binaryVersion,
|
|
47
47
|
config.setReleaseHistory,
|
|
48
|
-
answers.platform
|
|
49
|
-
answers.identifier
|
|
48
|
+
answers.platform
|
|
50
49
|
)
|
|
51
50
|
|
|
52
51
|
await createReleaseHistoryList(
|
|
53
52
|
answers.app,
|
|
54
53
|
answers.binaryVersion,
|
|
55
54
|
answers.platform,
|
|
56
|
-
answers.identifier,
|
|
57
55
|
config.getBinaryVersionList,
|
|
58
56
|
config.setBinaryVersionList
|
|
59
57
|
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
|
|
4
|
+
async function createPullRequestHistory(
|
|
5
|
+
setReleaseHistory,
|
|
6
|
+
prNumber,
|
|
7
|
+
app,
|
|
8
|
+
platform
|
|
9
|
+
) {
|
|
10
|
+
try {
|
|
11
|
+
const JSON_FILE_NAME = `${prNumber}.json`
|
|
12
|
+
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME)
|
|
13
|
+
|
|
14
|
+
console.log(
|
|
15
|
+
`log: creating JSON file... ("${JSON_FILE_NAME}")\n`,
|
|
16
|
+
JSON.stringify({}, null, 2)
|
|
17
|
+
)
|
|
18
|
+
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify({}))
|
|
19
|
+
|
|
20
|
+
await setReleaseHistory(prNumber, JSON_FILE_PATH, {}, app, platform)
|
|
21
|
+
|
|
22
|
+
fs.unlinkSync(JSON_FILE_PATH)
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error(
|
|
25
|
+
'Error occurred while creating new pull request history:',
|
|
26
|
+
error
|
|
27
|
+
)
|
|
28
|
+
process.exit(1)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
createPullRequestHistory,
|
|
34
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { program } = require('commander')
|
|
2
|
+
const { COMPILED_CONFIG_FILE_NAME } = require('../../constant')
|
|
3
|
+
const { findAndReadConfigFile } = require('../../utils/fsUtils')
|
|
4
|
+
const { createPullRequestHistory } = require('./createPullRequestHistory')
|
|
5
|
+
|
|
6
|
+
program
|
|
7
|
+
.command('create-pr-history')
|
|
8
|
+
.description('Creates a new pull request history.')
|
|
9
|
+
.option('-a, --app <string>', 'target app (user/device)')
|
|
10
|
+
.option('-p, --platform <string>', 'target platform (ios/android)')
|
|
11
|
+
.option('-r, --pr-number <number>', 'pull request number')
|
|
12
|
+
.option(
|
|
13
|
+
'-c, --config <path>',
|
|
14
|
+
'set config file name (JS/TS)',
|
|
15
|
+
COMPILED_CONFIG_FILE_NAME
|
|
16
|
+
)
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
const { setReleaseHistory } = await findAndReadConfigFile(
|
|
19
|
+
process.cwd(),
|
|
20
|
+
options.config
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
await createPullRequestHistory(
|
|
24
|
+
setReleaseHistory,
|
|
25
|
+
options.prNumber,
|
|
26
|
+
options.app,
|
|
27
|
+
options.platform
|
|
28
|
+
)
|
|
29
|
+
})
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
|
|
4
|
+
async function addToPullRequestRelease(
|
|
5
|
+
app,
|
|
6
|
+
binaryVersion,
|
|
7
|
+
prNumber,
|
|
8
|
+
bundleDownloadUrl,
|
|
9
|
+
packageHash,
|
|
10
|
+
platform,
|
|
11
|
+
mandatory,
|
|
12
|
+
enable,
|
|
13
|
+
setReleaseHistory,
|
|
14
|
+
getReleaseHistory
|
|
15
|
+
) {
|
|
16
|
+
const releaseHistory = await getReleaseHistory(app, prNumber, platform)
|
|
17
|
+
const latestReleaseHistoryNumber = Object.keys(releaseHistory).at(-1)
|
|
18
|
+
|
|
19
|
+
const newReleaseHistoryNumber = latestReleaseHistoryNumber
|
|
20
|
+
? latestReleaseHistoryNumber + 1
|
|
21
|
+
: 1
|
|
22
|
+
const newReleaseHistory = structuredClone(releaseHistory)
|
|
23
|
+
|
|
24
|
+
newReleaseHistory[newReleaseHistoryNumber] = {
|
|
25
|
+
binaryVersion,
|
|
26
|
+
enabled: enable,
|
|
27
|
+
mandatory,
|
|
28
|
+
downloadUrl: bundleDownloadUrl,
|
|
29
|
+
packageHash,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const JSON_FILE_NAME = `${prNumber}.json`
|
|
34
|
+
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME)
|
|
35
|
+
|
|
36
|
+
console.log(
|
|
37
|
+
`log: creating JSON file... ("${JSON_FILE_NAME}")\n`,
|
|
38
|
+
JSON.stringify(newReleaseHistory, null, 2)
|
|
39
|
+
)
|
|
40
|
+
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(newReleaseHistory))
|
|
41
|
+
|
|
42
|
+
await setReleaseHistory(
|
|
43
|
+
prNumber,
|
|
44
|
+
JSON_FILE_PATH,
|
|
45
|
+
newReleaseHistory,
|
|
46
|
+
app,
|
|
47
|
+
platform
|
|
48
|
+
)
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('Error occurred while updating history:', error)
|
|
51
|
+
process.exit(1)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
addToPullRequestRelease,
|
|
57
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const { bundleCodePush } = require('../bundleCommand/bundleCodePush')
|
|
3
|
+
const { addToPullRequestRelease } = require('./addToPullRequestRelease')
|
|
4
|
+
|
|
5
|
+
async function createPullRequestRelease(
|
|
6
|
+
bundleUploader,
|
|
7
|
+
getReleaseHistory,
|
|
8
|
+
setReleaseHistory,
|
|
9
|
+
app,
|
|
10
|
+
binaryVersion,
|
|
11
|
+
prNumber,
|
|
12
|
+
platform,
|
|
13
|
+
outputPath,
|
|
14
|
+
entryFile,
|
|
15
|
+
jsBundleName,
|
|
16
|
+
mandatory,
|
|
17
|
+
enable,
|
|
18
|
+
skipBundle,
|
|
19
|
+
skipCleanup,
|
|
20
|
+
bundleDirectory
|
|
21
|
+
) {
|
|
22
|
+
const bundleFileName = skipBundle
|
|
23
|
+
? readBundleFileNameFrom(bundleDirectory)
|
|
24
|
+
: await bundleCodePush(
|
|
25
|
+
platform,
|
|
26
|
+
outputPath,
|
|
27
|
+
entryFile,
|
|
28
|
+
jsBundleName,
|
|
29
|
+
bundleDirectory
|
|
30
|
+
)
|
|
31
|
+
const bundleFilePath = `${bundleDirectory}/${bundleFileName}`
|
|
32
|
+
|
|
33
|
+
const downloadUrl = await (async () => {
|
|
34
|
+
try {
|
|
35
|
+
console.log('Uploading Bundle File...')
|
|
36
|
+
const { downloadUrl } = await bundleUploader(
|
|
37
|
+
bundleFilePath,
|
|
38
|
+
app,
|
|
39
|
+
platform
|
|
40
|
+
)
|
|
41
|
+
console.log('Bundle File uploaded:', downloadUrl)
|
|
42
|
+
return downloadUrl
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error(
|
|
45
|
+
'Failed to upload the bundle file. Exiting the program.',
|
|
46
|
+
error
|
|
47
|
+
)
|
|
48
|
+
process.exit(1)
|
|
49
|
+
}
|
|
50
|
+
})()
|
|
51
|
+
|
|
52
|
+
await addToPullRequestRelease(
|
|
53
|
+
app,
|
|
54
|
+
binaryVersion,
|
|
55
|
+
prNumber,
|
|
56
|
+
downloadUrl,
|
|
57
|
+
bundleFileName,
|
|
58
|
+
platform,
|
|
59
|
+
mandatory,
|
|
60
|
+
enable,
|
|
61
|
+
setReleaseHistory,
|
|
62
|
+
getReleaseHistory
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if (!skipCleanup) {
|
|
66
|
+
cleanUpOutputs(outputPath)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function cleanUpOutputs(dir) {
|
|
71
|
+
fs.rmSync(dir, { recursive: true })
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param bundleDirectory {string}
|
|
76
|
+
* @return {string}
|
|
77
|
+
*/
|
|
78
|
+
function readBundleFileNameFrom(bundleDirectory) {
|
|
79
|
+
const files = fs.readdirSync(bundleDirectory)
|
|
80
|
+
if (files.length !== 1) {
|
|
81
|
+
console.error('The bundlePath must contain only one file.')
|
|
82
|
+
process.exit(1)
|
|
83
|
+
}
|
|
84
|
+
const path = require('path')
|
|
85
|
+
const bundleFilePath = path.join(bundleDirectory, files[0])
|
|
86
|
+
return path.basename(bundleFilePath)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = {
|
|
90
|
+
createPullRequestRelease,
|
|
91
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const { program } = require('commander')
|
|
2
|
+
const {
|
|
3
|
+
OUTPUT_BUNDLE_DIR,
|
|
4
|
+
COMPILED_CONFIG_FILE_NAME,
|
|
5
|
+
ROOT_OUTPUT_DIR,
|
|
6
|
+
ENTRY_FILE,
|
|
7
|
+
} = require('../../constant')
|
|
8
|
+
const { findAndReadConfigFile } = require('../../utils/fsUtils')
|
|
9
|
+
const { createPullRequestRelease } = require('./createPullRequestRelease')
|
|
10
|
+
|
|
11
|
+
program
|
|
12
|
+
.command('create-pr-release')
|
|
13
|
+
.description('Creates a new pull request release.')
|
|
14
|
+
.option('-a, --app <string>', 'target app (user/device)')
|
|
15
|
+
.option('-p, --platform <string>', 'target platform (ios/android)')
|
|
16
|
+
.option('-b, --binary-version <string>', 'target binary version (x.y.z)')
|
|
17
|
+
.option('-r, --pr-number <number>', 'pull request number')
|
|
18
|
+
.option(
|
|
19
|
+
'-c, --config <path>',
|
|
20
|
+
'set config file name (JS/TS)',
|
|
21
|
+
COMPILED_CONFIG_FILE_NAME
|
|
22
|
+
)
|
|
23
|
+
.option(
|
|
24
|
+
'-o, --output-path <string>',
|
|
25
|
+
'path to output root directory',
|
|
26
|
+
ROOT_OUTPUT_DIR
|
|
27
|
+
)
|
|
28
|
+
.option('-e, --entry-file <string>', 'path to JS/TS entry file', ENTRY_FILE)
|
|
29
|
+
.option(
|
|
30
|
+
'-j, --js-bundle-name <string>',
|
|
31
|
+
'JS bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")'
|
|
32
|
+
)
|
|
33
|
+
.option('-m, --mandatory', 'make the release to be mandatory', false)
|
|
34
|
+
.option(
|
|
35
|
+
'--enable',
|
|
36
|
+
'make the release to be enabled (use --no-enable to disable)',
|
|
37
|
+
true
|
|
38
|
+
)
|
|
39
|
+
.option('--no-enable', 'make the release to be disabled')
|
|
40
|
+
.option('--skip-bundle', 'skip bundle process', false)
|
|
41
|
+
.option('--skip-cleanup', 'skip cleanup process', false)
|
|
42
|
+
.option(
|
|
43
|
+
'--output-bundle-dir <string>',
|
|
44
|
+
'name of directory containing the bundle file created by the "bundle" command',
|
|
45
|
+
OUTPUT_BUNDLE_DIR
|
|
46
|
+
)
|
|
47
|
+
.action(async (options) => {
|
|
48
|
+
const { bundleUploader, setReleaseHistory, getReleaseHistory } =
|
|
49
|
+
await findAndReadConfigFile(process.cwd(), options.config)
|
|
50
|
+
|
|
51
|
+
await createPullRequestRelease(
|
|
52
|
+
bundleUploader,
|
|
53
|
+
setReleaseHistory,
|
|
54
|
+
getReleaseHistory,
|
|
55
|
+
options.app,
|
|
56
|
+
options.binaryVersion,
|
|
57
|
+
options.prNumber,
|
|
58
|
+
options.platform,
|
|
59
|
+
options.outputPath,
|
|
60
|
+
options.entryFile,
|
|
61
|
+
options.jsBundleName,
|
|
62
|
+
options.mandatory,
|
|
63
|
+
options.enable,
|
|
64
|
+
options.skipBundle,
|
|
65
|
+
options.skipCleanup,
|
|
66
|
+
options.outputBundleDir
|
|
67
|
+
)
|
|
68
|
+
})
|
|
@@ -19,10 +19,8 @@ const fs = require('fs')
|
|
|
19
19
|
* jsonFilePath: string,
|
|
20
20
|
* releaseInfo: ReleaseHistoryInterface,
|
|
21
21
|
* platform: string,
|
|
22
|
-
* identifier?: string
|
|
23
22
|
* ): Promise<void>}
|
|
24
23
|
* @param platform {"ios" | "android"}
|
|
25
|
-
* @param identifier {string?}
|
|
26
24
|
* @param mandatory {boolean?}
|
|
27
25
|
* @param enable {boolean?}
|
|
28
26
|
* @returns {Promise<void>}
|
|
@@ -36,16 +34,10 @@ async function addToReleaseHistory(
|
|
|
36
34
|
getReleaseHistory,
|
|
37
35
|
setReleaseHistory,
|
|
38
36
|
platform,
|
|
39
|
-
identifier,
|
|
40
37
|
mandatory,
|
|
41
38
|
enable
|
|
42
39
|
) {
|
|
43
|
-
const releaseHistory = await getReleaseHistory(
|
|
44
|
-
app,
|
|
45
|
-
binaryVersion,
|
|
46
|
-
platform,
|
|
47
|
-
identifier
|
|
48
|
-
)
|
|
40
|
+
const releaseHistory = await getReleaseHistory(app, binaryVersion, platform)
|
|
49
41
|
|
|
50
42
|
const updateInfo = releaseHistory[appVersion]
|
|
51
43
|
if (updateInfo) {
|
|
@@ -77,8 +69,7 @@ async function addToReleaseHistory(
|
|
|
77
69
|
JSON_FILE_PATH,
|
|
78
70
|
newReleaseHistory,
|
|
79
71
|
app,
|
|
80
|
-
platform
|
|
81
|
-
identifier
|
|
72
|
+
platform
|
|
82
73
|
)
|
|
83
74
|
|
|
84
75
|
fs.unlinkSync(JSON_FILE_PATH)
|
|
@@ -121,8 +121,7 @@ program
|
|
|
121
121
|
getReleaseHistory,
|
|
122
122
|
binaryVersion,
|
|
123
123
|
app,
|
|
124
|
-
platform
|
|
125
|
-
identifier
|
|
124
|
+
platform
|
|
126
125
|
)
|
|
127
126
|
|
|
128
127
|
answers = {
|
|
@@ -142,7 +141,6 @@ program
|
|
|
142
141
|
answers.binaryVersion,
|
|
143
142
|
answers.appVersion,
|
|
144
143
|
answers.platform,
|
|
145
|
-
answers.identifier,
|
|
146
144
|
options.outputPath,
|
|
147
145
|
options.entryFile,
|
|
148
146
|
options.bundleName,
|
|
@@ -7,13 +7,11 @@ const { addToReleaseHistory } = require('./addToReleaseHistory')
|
|
|
7
7
|
* function(
|
|
8
8
|
* source: string,
|
|
9
9
|
* platform: "ios" | "android",
|
|
10
|
-
* identifier?: string
|
|
11
10
|
* ): Promise<{ downloadUrl: string }>}
|
|
12
11
|
* @param getReleaseHistory {
|
|
13
12
|
* function(
|
|
14
13
|
* targetBinaryVersion: string,
|
|
15
14
|
* platform: "ios" | "android",
|
|
16
|
-
* identifier?: string
|
|
17
15
|
* ): Promise<ReleaseHistoryInterface>}
|
|
18
16
|
* @param setReleaseHistory {
|
|
19
17
|
* function(
|
|
@@ -21,13 +19,11 @@ const { addToReleaseHistory } = require('./addToReleaseHistory')
|
|
|
21
19
|
* jsonFilePath: string,
|
|
22
20
|
* releaseInfo: ReleaseHistoryInterface,
|
|
23
21
|
* platform: "ios" | "android",
|
|
24
|
-
* identifier?: string
|
|
25
22
|
* ): Promise<void>}
|
|
26
23
|
* @param app {"user" | "device"}
|
|
27
24
|
* @param binaryVersion {string}
|
|
28
25
|
* @param appVersion {string}
|
|
29
26
|
* @param platform {"ios" | "android"}
|
|
30
|
-
* @param identifier {string?}
|
|
31
27
|
* @param outputPath {string}
|
|
32
28
|
* @param entryFile {string}
|
|
33
29
|
* @param jsBundleName {string}
|
|
@@ -46,7 +42,6 @@ async function release(
|
|
|
46
42
|
binaryVersion,
|
|
47
43
|
appVersion,
|
|
48
44
|
platform,
|
|
49
|
-
identifier,
|
|
50
45
|
outputPath,
|
|
51
46
|
entryFile,
|
|
52
47
|
jsBundleName,
|
|
@@ -73,8 +68,7 @@ async function release(
|
|
|
73
68
|
const { downloadUrl } = await bundleUploader(
|
|
74
69
|
bundleFilePath,
|
|
75
70
|
app,
|
|
76
|
-
platform
|
|
77
|
-
identifier
|
|
71
|
+
platform
|
|
78
72
|
)
|
|
79
73
|
console.log('Bundle File uploaded:', downloadUrl)
|
|
80
74
|
return downloadUrl
|
|
@@ -96,7 +90,6 @@ async function release(
|
|
|
96
90
|
getReleaseHistory,
|
|
97
91
|
setReleaseHistory,
|
|
98
92
|
platform,
|
|
99
|
-
identifier,
|
|
100
93
|
mandatory,
|
|
101
94
|
enable
|
|
102
95
|
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { program } = require('commander')
|
|
2
|
+
const { COMPILED_CONFIG_FILE_NAME } = require('../../constant')
|
|
3
|
+
const { findAndReadConfigFile } = require('../../utils/fsUtils')
|
|
4
|
+
const { removePullRequestHistory } = require('./removePullRequestHistory')
|
|
5
|
+
|
|
6
|
+
program
|
|
7
|
+
.command('remove-pr-history')
|
|
8
|
+
.description('Removes a pull request history.')
|
|
9
|
+
.option('-a, --app <string>', 'target app (user/device)')
|
|
10
|
+
.option('-p, --platform <string>', 'target platform (ios/android)')
|
|
11
|
+
.option('-r, --pr-number <number>', 'pull request number')
|
|
12
|
+
.option(
|
|
13
|
+
'-c, --config <path>',
|
|
14
|
+
'set config file name (JS/TS)',
|
|
15
|
+
COMPILED_CONFIG_FILE_NAME
|
|
16
|
+
)
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
const { getReleaseHistory, removeReleaseHistory } =
|
|
19
|
+
await findAndReadConfigFile(process.cwd(), options.config)
|
|
20
|
+
|
|
21
|
+
await removePullRequestHistory(
|
|
22
|
+
getReleaseHistory,
|
|
23
|
+
removeReleaseHistory,
|
|
24
|
+
options.app,
|
|
25
|
+
options.prNumber,
|
|
26
|
+
options.platform
|
|
27
|
+
)
|
|
28
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
async function removePullRequestHistory(
|
|
2
|
+
getReleaseHistory,
|
|
3
|
+
removeReleaseHistory,
|
|
4
|
+
app,
|
|
5
|
+
prNumber,
|
|
6
|
+
platform
|
|
7
|
+
) {
|
|
8
|
+
const releaseHistory = await getReleaseHistory(app, prNumber, platform)
|
|
9
|
+
|
|
10
|
+
if (!releaseHistory) {
|
|
11
|
+
console.error(`v${prNumber} is already removed or is not released.`)
|
|
12
|
+
process.exit(1)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
await removeReleaseHistory(app, prNumber, platform)
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('Error occurred while removing history:', error)
|
|
19
|
+
process.exit(1)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = { removePullRequestHistory }
|
|
@@ -47,8 +47,7 @@ program
|
|
|
47
47
|
config.getReleaseHistory,
|
|
48
48
|
binaryVersion,
|
|
49
49
|
app,
|
|
50
|
-
platform
|
|
51
|
-
identifier
|
|
50
|
+
platform
|
|
52
51
|
)
|
|
53
52
|
|
|
54
53
|
const answers = {
|
|
@@ -74,7 +73,6 @@ program
|
|
|
74
73
|
config.getReleaseHistory,
|
|
75
74
|
config.setReleaseHistory,
|
|
76
75
|
answers.platform,
|
|
77
|
-
answers.identifier,
|
|
78
76
|
options.mandatory,
|
|
79
77
|
options.enable
|
|
80
78
|
)
|
|
@@ -9,7 +9,6 @@ const path = require('path')
|
|
|
9
9
|
* function(
|
|
10
10
|
* targetBinaryVersion: string,
|
|
11
11
|
* platform: string,
|
|
12
|
-
* identifier?: string
|
|
13
12
|
* ): Promise<ReleaseHistoryInterface>}
|
|
14
13
|
* @param setReleaseHistory {
|
|
15
14
|
* function(
|
|
@@ -17,10 +16,8 @@ const path = require('path')
|
|
|
17
16
|
* jsonFilePath: string,
|
|
18
17
|
* releaseInfo: ReleaseHistoryInterface,
|
|
19
18
|
* platform: string,
|
|
20
|
-
* identifier?: string
|
|
21
19
|
* ): Promise<void>}
|
|
22
20
|
* @param platform {"ios" | "android"}
|
|
23
|
-
* @param identifier {string?}
|
|
24
21
|
* @param mandatory {boolean?}
|
|
25
22
|
* @param enable {boolean?}
|
|
26
23
|
* @returns {Promise<void>}
|
|
@@ -32,16 +29,10 @@ async function updateReleaseHistory(
|
|
|
32
29
|
getReleaseHistory,
|
|
33
30
|
setReleaseHistory,
|
|
34
31
|
platform,
|
|
35
|
-
identifier,
|
|
36
32
|
mandatory,
|
|
37
33
|
enable
|
|
38
34
|
) {
|
|
39
|
-
const releaseHistory = await getReleaseHistory(
|
|
40
|
-
app,
|
|
41
|
-
binaryVersion,
|
|
42
|
-
platform,
|
|
43
|
-
identifier
|
|
44
|
-
)
|
|
35
|
+
const releaseHistory = await getReleaseHistory(app, binaryVersion, platform)
|
|
45
36
|
|
|
46
37
|
const updateInfo = releaseHistory[appVersion]
|
|
47
38
|
if (!updateInfo) throw new Error(`v${appVersion} is not released`)
|
|
@@ -64,8 +55,7 @@ async function updateReleaseHistory(
|
|
|
64
55
|
JSON_FILE_PATH,
|
|
65
56
|
releaseHistory,
|
|
66
57
|
app,
|
|
67
|
-
platform
|
|
68
|
-
identifier
|
|
58
|
+
platform
|
|
69
59
|
)
|
|
70
60
|
|
|
71
61
|
fs.unlinkSync(JSON_FILE_PATH)
|
package/cli/utils/version.js
CHANGED
|
@@ -15,19 +15,8 @@ async function getBinaryVersions(
|
|
|
15
15
|
]
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async function getAppVersions(
|
|
19
|
-
getReleaseHistory,
|
|
20
|
-
binaryVersion,
|
|
21
|
-
app,
|
|
22
|
-
platform,
|
|
23
|
-
identifier
|
|
24
|
-
) {
|
|
25
|
-
const releaseHistory = await getReleaseHistory(
|
|
26
|
-
app,
|
|
27
|
-
binaryVersion,
|
|
28
|
-
platform,
|
|
29
|
-
identifier
|
|
30
|
-
)
|
|
18
|
+
async function getAppVersions(getReleaseHistory, binaryVersion, app, platform) {
|
|
19
|
+
const releaseHistory = await getReleaseHistory(app, binaryVersion, platform)
|
|
31
20
|
return [Object.keys(releaseHistory), Object.keys(releaseHistory).pop()]
|
|
32
21
|
}
|
|
33
22
|
|
package/code-push.config.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
2
|
// @ts-nocheck
|
|
3
3
|
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
S3Client,
|
|
6
|
+
PutObjectCommand,
|
|
7
|
+
DeleteObjectCommand,
|
|
8
|
+
} = require('@aws-sdk/client-s3')
|
|
5
9
|
const fs = require('fs')
|
|
6
10
|
const axios = require('axios')
|
|
7
11
|
require('dotenv').config()
|
|
@@ -14,18 +18,8 @@ const s3Client = new S3Client({
|
|
|
14
18
|
},
|
|
15
19
|
})
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
? process.env.AWS_S3_BUCKET_PRD || 'codepush-bucket'
|
|
20
|
-
: process.env.AWS_S3_BUCKET_STG || 'codepush-bucket'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getCDNUrl(identifier) {
|
|
24
|
-
const BUCKET_NAME = getBucketName(identifier)
|
|
25
|
-
return identifier === 'prd'
|
|
26
|
-
? process.env.CDN_URL_PRD || `https://${BUCKET_NAME}.s3.amazonaws.com`
|
|
27
|
-
: process.env.CDN_URL_STG || `https://${BUCKET_NAME}.s3.amazonaws.com`
|
|
28
|
-
}
|
|
21
|
+
const BUCKET_NAME = process.env.AWS_S3_BUCKET || 'codepush-bucket'
|
|
22
|
+
const CDN_URL = process.env.CDN_URL || `https://${BUCKET_NAME}.s3.amazonaws.com`
|
|
29
23
|
|
|
30
24
|
function historyJsonFileRemotePath(app, platform, binaryVersion) {
|
|
31
25
|
return `histories/${app}/${platform}/${binaryVersion}.json`
|
|
@@ -36,12 +30,10 @@ function bundleFileRemotePath(app, platform, fileName) {
|
|
|
36
30
|
}
|
|
37
31
|
|
|
38
32
|
const Config = {
|
|
39
|
-
bundleUploader: async (source, app, platform
|
|
33
|
+
bundleUploader: async (source, app, platform) => {
|
|
40
34
|
const fileName = source.split('/').pop()
|
|
41
35
|
const fileContent = fs.readFileSync(source)
|
|
42
36
|
const remotePath = bundleFileRemotePath(app, platform, fileName)
|
|
43
|
-
const BUCKET_NAME = getBucketName(identifier)
|
|
44
|
-
const CDN_URL = getCDNUrl(identifier)
|
|
45
37
|
|
|
46
38
|
try {
|
|
47
39
|
await s3Client.send(
|
|
@@ -63,8 +55,7 @@ const Config = {
|
|
|
63
55
|
throw error
|
|
64
56
|
}
|
|
65
57
|
},
|
|
66
|
-
getReleaseHistory: async (app, targetBinaryVersion, platform
|
|
67
|
-
const CDN_URL = getCDNUrl(identifier)
|
|
58
|
+
getReleaseHistory: async (app, targetBinaryVersion, platform) => {
|
|
68
59
|
const remoteJsonPath = historyJsonFileRemotePath(
|
|
69
60
|
app,
|
|
70
61
|
platform,
|
|
@@ -73,14 +64,12 @@ const Config = {
|
|
|
73
64
|
const { data } = await axios.get(`${CDN_URL}/${remoteJsonPath}`)
|
|
74
65
|
return data
|
|
75
66
|
},
|
|
76
|
-
|
|
77
67
|
setReleaseHistory: async (
|
|
78
68
|
targetBinaryVersion,
|
|
79
69
|
jsonFilePath,
|
|
80
70
|
releaseInfo,
|
|
81
71
|
app,
|
|
82
|
-
platform
|
|
83
|
-
identifier
|
|
72
|
+
platform
|
|
84
73
|
) => {
|
|
85
74
|
const fileContent = fs.readFileSync(jsonFilePath, 'utf8')
|
|
86
75
|
const remoteJsonPath = historyJsonFileRemotePath(
|
|
@@ -88,8 +77,6 @@ const Config = {
|
|
|
88
77
|
platform,
|
|
89
78
|
targetBinaryVersion
|
|
90
79
|
)
|
|
91
|
-
const BUCKET_NAME = getBucketName(identifier)
|
|
92
|
-
const CDN_URL = getCDNUrl(identifier)
|
|
93
80
|
|
|
94
81
|
try {
|
|
95
82
|
await s3Client.send(
|
|
@@ -111,8 +98,7 @@ const Config = {
|
|
|
111
98
|
throw error
|
|
112
99
|
}
|
|
113
100
|
},
|
|
114
|
-
getBinaryVersionList: async (app, platform
|
|
115
|
-
const CDN_URL = getCDNUrl(identifier)
|
|
101
|
+
getBinaryVersionList: async (app, platform) => {
|
|
116
102
|
const remoteJsonPath = `histories/${app}/${platform}/list.json`
|
|
117
103
|
let currentList = {}
|
|
118
104
|
try {
|
|
@@ -127,16 +113,8 @@ const Config = {
|
|
|
127
113
|
}
|
|
128
114
|
return currentList
|
|
129
115
|
},
|
|
130
|
-
setBinaryVersionList: async (
|
|
131
|
-
targetVersion,
|
|
132
|
-
jsonFilePath,
|
|
133
|
-
app,
|
|
134
|
-
platform,
|
|
135
|
-
identifier
|
|
136
|
-
) => {
|
|
116
|
+
setBinaryVersionList: async (targetVersion, jsonFilePath, app, platform) => {
|
|
137
117
|
const remoteJsonPath = `histories/${app}/${platform}/list.json`
|
|
138
|
-
const BUCKET_NAME = getBucketName(identifier)
|
|
139
|
-
const CDN_URL = getCDNUrl(identifier)
|
|
140
118
|
|
|
141
119
|
const currentList = JSON.parse(fs.readFileSync(jsonFilePath, 'utf8'))
|
|
142
120
|
const targetVersionPath = historyJsonFileRemotePath(
|
|
@@ -168,6 +146,25 @@ const Config = {
|
|
|
168
146
|
throw error
|
|
169
147
|
}
|
|
170
148
|
},
|
|
149
|
+
removeReleaseHistory: async (app, targetBinaryVersion, platform) => {
|
|
150
|
+
const remoteJsonPath = historyJsonFileRemotePath(
|
|
151
|
+
app,
|
|
152
|
+
platform,
|
|
153
|
+
targetBinaryVersion
|
|
154
|
+
)
|
|
155
|
+
try {
|
|
156
|
+
await s3Client.send(
|
|
157
|
+
new DeleteObjectCommand({
|
|
158
|
+
Bucket: BUCKET_NAME,
|
|
159
|
+
Key: remoteJsonPath,
|
|
160
|
+
})
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
console.log('Release history removed:', `${CDN_URL}/${remoteJsonPath}`)
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.error('Error removing release history:', error)
|
|
166
|
+
}
|
|
167
|
+
},
|
|
171
168
|
}
|
|
172
169
|
|
|
173
170
|
module.exports = Config
|