@algocare/react-native-code-push 9.1.0 → 10.0.1
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 +249 -0
- package/cli/commands/createHistoryCommand/createReleaseHistory.js +0 -13
- package/cli/commands/createHistoryCommand/createReleaseHistoryList.js +62 -0
- package/cli/commands/createHistoryCommand/index.js +35 -36
- package/cli/commands/releaseCommand/index.js +43 -47
- package/cli/commands/showHistoryCommand/index.js +25 -36
- package/cli/commands/updateHistoryCommand/index.js +35 -45
- package/cli/utils/version.js +37 -0
- package/code-push.config.js +57 -1
- package/package.json +1 -1
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
const inquirer = require('inquirer').default
|
|
2
|
+
const { getBinaryVersions, getAppVersions } = require('../utils/version')
|
|
3
|
+
const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
|
|
4
|
+
|
|
5
|
+
async function getAppValue() {
|
|
6
|
+
const { app } = await inquirer.prompt([
|
|
7
|
+
{
|
|
8
|
+
type: 'list',
|
|
9
|
+
name: 'app',
|
|
10
|
+
message: 'Select the target app',
|
|
11
|
+
choices: ['user', 'device'],
|
|
12
|
+
},
|
|
13
|
+
])
|
|
14
|
+
return app
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function getPlatformValue(app) {
|
|
18
|
+
const platformAnswer = await inquirer.prompt([
|
|
19
|
+
{
|
|
20
|
+
type: 'list',
|
|
21
|
+
name: 'platform',
|
|
22
|
+
message: 'Select the target platform',
|
|
23
|
+
choices: ['ios', 'android'],
|
|
24
|
+
when: () => app !== 'device',
|
|
25
|
+
},
|
|
26
|
+
])
|
|
27
|
+
return app === 'device' ? 'android' : platformAnswer.platform
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function getIdentifierValue() {
|
|
31
|
+
const { identifier } = await inquirer.prompt([
|
|
32
|
+
{
|
|
33
|
+
type: 'list',
|
|
34
|
+
name: 'identifier',
|
|
35
|
+
message: 'Select the target env identifier',
|
|
36
|
+
choices: ['stg', 'prd'],
|
|
37
|
+
},
|
|
38
|
+
])
|
|
39
|
+
return identifier
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function getBinaryVersionValueFromList(
|
|
43
|
+
getBinaryVersionList,
|
|
44
|
+
app,
|
|
45
|
+
platform,
|
|
46
|
+
identifier,
|
|
47
|
+
count = 5
|
|
48
|
+
) {
|
|
49
|
+
const [currentBinaryVersionList] = await getBinaryVersions(
|
|
50
|
+
getBinaryVersionList,
|
|
51
|
+
app,
|
|
52
|
+
platform,
|
|
53
|
+
identifier
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
if (!currentBinaryVersionList.length) {
|
|
57
|
+
console.log('There is no binary version list')
|
|
58
|
+
return []
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (typeof count !== 'number' || count < 1) {
|
|
62
|
+
console.warn('count must be a number and greater than 1')
|
|
63
|
+
return []
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const latestBinaryVersion = currentBinaryVersionList.slice(-count)
|
|
67
|
+
const binaryVersionChoices = [
|
|
68
|
+
...latestBinaryVersion,
|
|
69
|
+
new inquirer.Separator(),
|
|
70
|
+
'Enter manually',
|
|
71
|
+
]
|
|
72
|
+
const binaryVersionSelectionAnswer = await inquirer.prompt([
|
|
73
|
+
{
|
|
74
|
+
type: 'list',
|
|
75
|
+
name: 'versionChoice',
|
|
76
|
+
message:
|
|
77
|
+
'This is last 5 versions. Select a binary version or enter manually',
|
|
78
|
+
choices: binaryVersionChoices,
|
|
79
|
+
},
|
|
80
|
+
])
|
|
81
|
+
let binaryVersion
|
|
82
|
+
if (binaryVersionSelectionAnswer.versionChoice === 'Enter manually') {
|
|
83
|
+
const binaryVersionAnswer = await inquirer.prompt([
|
|
84
|
+
{
|
|
85
|
+
type: 'input',
|
|
86
|
+
name: 'binaryVersion',
|
|
87
|
+
message: 'Enter the target binary version',
|
|
88
|
+
validate: (input) => {
|
|
89
|
+
if (!semverRegex.test(input)) {
|
|
90
|
+
return 'Please enter a valid version number (x.y.z)'
|
|
91
|
+
}
|
|
92
|
+
return true
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
])
|
|
96
|
+
binaryVersion = binaryVersionAnswer.binaryVersion
|
|
97
|
+
} else {
|
|
98
|
+
binaryVersion = binaryVersionSelectionAnswer.versionChoice
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return binaryVersion
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function getAppVersionValueFromList(
|
|
105
|
+
getReleaseHistory,
|
|
106
|
+
binaryVersion,
|
|
107
|
+
app,
|
|
108
|
+
platform,
|
|
109
|
+
identifier,
|
|
110
|
+
count = 5
|
|
111
|
+
) {
|
|
112
|
+
const [currentAppVersionList] = await getAppVersions(
|
|
113
|
+
getReleaseHistory,
|
|
114
|
+
binaryVersion,
|
|
115
|
+
app,
|
|
116
|
+
platform,
|
|
117
|
+
identifier
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
if (!currentAppVersionList.length) {
|
|
121
|
+
console.log('There is no app version list')
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (typeof count !== 'number' || count < 1) {
|
|
126
|
+
console.warn('count must be a number and greater than 1')
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const latestAppVersion = currentAppVersionList.slice(-count)
|
|
131
|
+
const appVersionChoices = [
|
|
132
|
+
...latestAppVersion,
|
|
133
|
+
new inquirer.Separator(),
|
|
134
|
+
'Enter manually',
|
|
135
|
+
]
|
|
136
|
+
const appVersionSelectionAnswer = await inquirer.prompt([
|
|
137
|
+
{
|
|
138
|
+
type: 'list',
|
|
139
|
+
name: 'appVersionChoice',
|
|
140
|
+
message:
|
|
141
|
+
'This is last 5 versions. Select a binary version or enter manually',
|
|
142
|
+
choices: appVersionChoices,
|
|
143
|
+
},
|
|
144
|
+
])
|
|
145
|
+
let appVersion
|
|
146
|
+
if (appVersionSelectionAnswer.versionChoice === 'Enter manually') {
|
|
147
|
+
const appVersionAnswer = await inquirer.prompt([
|
|
148
|
+
{
|
|
149
|
+
type: 'input',
|
|
150
|
+
name: 'appVersion',
|
|
151
|
+
message: 'Enter the target app version',
|
|
152
|
+
validate: (input) => {
|
|
153
|
+
if (!semverRegex.test(input)) {
|
|
154
|
+
return 'Please enter a valid version number (x.y.z)'
|
|
155
|
+
}
|
|
156
|
+
return true
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
])
|
|
160
|
+
appVersion = appVersionAnswer.appVersion
|
|
161
|
+
} else {
|
|
162
|
+
appVersion = appVersionSelectionAnswer.appVersion
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return appVersion
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function getBinaryVersionValueFromInput(
|
|
169
|
+
getBinaryVersionList,
|
|
170
|
+
app,
|
|
171
|
+
platform,
|
|
172
|
+
identifier
|
|
173
|
+
) {
|
|
174
|
+
const [, lastBinaryVersion] = await getBinaryVersions(
|
|
175
|
+
getBinaryVersionList,
|
|
176
|
+
app,
|
|
177
|
+
platform,
|
|
178
|
+
identifier
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
const message = lastBinaryVersion
|
|
182
|
+
? `Enter the target binary version (current latest: ${lastBinaryVersion})`
|
|
183
|
+
: 'Enter the target binary version (there is no latest version)'
|
|
184
|
+
|
|
185
|
+
const { binaryVersion } = await inquirer.prompt([
|
|
186
|
+
{
|
|
187
|
+
type: 'input',
|
|
188
|
+
name: 'binaryVersion',
|
|
189
|
+
message,
|
|
190
|
+
validate: (input) => {
|
|
191
|
+
if (!semverRegex.test(input)) {
|
|
192
|
+
return 'Please enter a valid version number (x.y.z)'
|
|
193
|
+
}
|
|
194
|
+
return true
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
])
|
|
198
|
+
|
|
199
|
+
return binaryVersion
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async function getAppVersionValueFromInput(
|
|
203
|
+
getReleaseHistory,
|
|
204
|
+
binaryVersion,
|
|
205
|
+
app,
|
|
206
|
+
platform,
|
|
207
|
+
identifier
|
|
208
|
+
) {
|
|
209
|
+
const [currentAppVersionList, lastAppVersion] = await getAppVersions(
|
|
210
|
+
getReleaseHistory,
|
|
211
|
+
binaryVersion,
|
|
212
|
+
app,
|
|
213
|
+
platform,
|
|
214
|
+
identifier
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
const message = lastAppVersion
|
|
218
|
+
? `Enter the target app version (current latest: ${lastAppVersion})`
|
|
219
|
+
: 'Enter the target app version (there is no latest version)'
|
|
220
|
+
|
|
221
|
+
const { appVersion } = await inquirer.prompt([
|
|
222
|
+
{
|
|
223
|
+
type: 'input',
|
|
224
|
+
name: 'appVersion',
|
|
225
|
+
message,
|
|
226
|
+
validate: (input) => {
|
|
227
|
+
if (!semverRegex.test(input)) {
|
|
228
|
+
return 'Please enter a valid version number (x.y.z)'
|
|
229
|
+
}
|
|
230
|
+
if (currentAppVersionList.includes(input)) {
|
|
231
|
+
return `Version ${input} already exists`
|
|
232
|
+
}
|
|
233
|
+
return true
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
])
|
|
237
|
+
|
|
238
|
+
return appVersion
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
module.exports = {
|
|
242
|
+
getAppValue,
|
|
243
|
+
getPlatformValue,
|
|
244
|
+
getIdentifierValue,
|
|
245
|
+
getBinaryVersionValueFromList,
|
|
246
|
+
getAppVersionValueFromList,
|
|
247
|
+
getBinaryVersionValueFromInput,
|
|
248
|
+
getAppVersionValueFromInput,
|
|
249
|
+
}
|
|
@@ -23,19 +23,6 @@ async function createReleaseHistory(
|
|
|
23
23
|
platform,
|
|
24
24
|
identifier
|
|
25
25
|
) {
|
|
26
|
-
const BINARY_RELEASE = {
|
|
27
|
-
enabled: true,
|
|
28
|
-
mandatory: false,
|
|
29
|
-
downloadUrl: '',
|
|
30
|
-
packageHash: '',
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** @type {ReleaseHistoryInterface} */
|
|
34
|
-
// not use
|
|
35
|
-
const INITIAL_HISTORY = {
|
|
36
|
-
[targetVersion]: BINARY_RELEASE,
|
|
37
|
-
}
|
|
38
|
-
|
|
39
26
|
try {
|
|
40
27
|
const JSON_FILE_NAME = `${targetVersion}.json`
|
|
41
28
|
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param app {"user" | "device"}
|
|
6
|
+
* @param targetVersion {string}
|
|
7
|
+
* @param platform {"ios" | "android"}
|
|
8
|
+
* @param identifier {string}
|
|
9
|
+
* @param getBinaryVersionList {
|
|
10
|
+
* function(
|
|
11
|
+
* app: string,
|
|
12
|
+
* platform: string,
|
|
13
|
+
* identifier: string
|
|
14
|
+
* ): Promise<{ [version: string]: string }>
|
|
15
|
+
* }
|
|
16
|
+
* @param setBinaryVersionList {
|
|
17
|
+
* function(
|
|
18
|
+
* targetVersion: string,
|
|
19
|
+
* app: string,
|
|
20
|
+
* platform: string,
|
|
21
|
+
* identifier: string
|
|
22
|
+
* ): Promise<void>
|
|
23
|
+
* }
|
|
24
|
+
* @returns {Promise<void>}
|
|
25
|
+
*/
|
|
26
|
+
async function createReleaseHistoryList(
|
|
27
|
+
app,
|
|
28
|
+
targetVersion,
|
|
29
|
+
platform,
|
|
30
|
+
identifier,
|
|
31
|
+
getBinaryVersionList,
|
|
32
|
+
setBinaryVersionList
|
|
33
|
+
) {
|
|
34
|
+
try {
|
|
35
|
+
const JSON_FILE_NAME = 'list.json'
|
|
36
|
+
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME)
|
|
37
|
+
|
|
38
|
+
const currentList = await getBinaryVersionList(app, platform, identifier)
|
|
39
|
+
|
|
40
|
+
if (currentList[targetVersion]) {
|
|
41
|
+
console.error(`Version ${targetVersion} is already released`)
|
|
42
|
+
process.exit(1)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(currentList))
|
|
46
|
+
|
|
47
|
+
await setBinaryVersionList(
|
|
48
|
+
targetVersion,
|
|
49
|
+
JSON_FILE_PATH,
|
|
50
|
+
app,
|
|
51
|
+
platform,
|
|
52
|
+
identifier
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
fs.unlinkSync(JSON_FILE_PATH)
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error('Error occurred while creating new history list:', error)
|
|
58
|
+
process.exit(1)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = { createReleaseHistoryList }
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
const { program } = require('commander')
|
|
2
|
-
const inquirer = require('inquirer').default
|
|
3
2
|
const { findAndReadConfigFile } = require('../../utils/fsUtils')
|
|
4
3
|
const { createReleaseHistory } = require('./createReleaseHistory')
|
|
4
|
+
const { createReleaseHistoryList } = require('./createReleaseHistoryList')
|
|
5
5
|
const { COMPILED_CONFIG_FILE_NAME } = require('../../constant')
|
|
6
|
+
const {
|
|
7
|
+
getAppValue,
|
|
8
|
+
getPlatformValue,
|
|
9
|
+
getIdentifierValue,
|
|
10
|
+
getBinaryVersionValueFromInput,
|
|
11
|
+
} = require('../common')
|
|
6
12
|
|
|
7
13
|
program
|
|
8
14
|
.command('create-history')
|
|
@@ -13,44 +19,28 @@ program
|
|
|
13
19
|
COMPILED_CONFIG_FILE_NAME
|
|
14
20
|
)
|
|
15
21
|
.action(async (options) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
type: 'list',
|
|
32
|
-
name: 'identifier',
|
|
33
|
-
message: 'Select the target env identifier',
|
|
34
|
-
choices: ['stg', 'prd'],
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
type: 'input',
|
|
38
|
-
name: 'binaryVersion',
|
|
39
|
-
message: 'Enter the target binary version',
|
|
40
|
-
validate: (input) => {
|
|
41
|
-
const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
|
|
42
|
-
if (semverRegex.test(input)) return true
|
|
43
|
-
return 'Please enter a valid version number (x.y.z)'
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
])
|
|
22
|
+
const config = await findAndReadConfigFile(process.cwd(), options.config)
|
|
23
|
+
// app
|
|
24
|
+
const app = await getAppValue()
|
|
25
|
+
// platform
|
|
26
|
+
const platform = await getPlatformValue(app)
|
|
27
|
+
// identifier
|
|
28
|
+
const identifier = await getIdentifierValue()
|
|
29
|
+
// binaryVersion
|
|
30
|
+
const binaryVersion = await getBinaryVersionValueFromInput(
|
|
31
|
+
config.getBinaryVersionList,
|
|
32
|
+
app,
|
|
33
|
+
platform,
|
|
34
|
+
identifier
|
|
35
|
+
)
|
|
47
36
|
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
const answers = {
|
|
38
|
+
app,
|
|
39
|
+
platform,
|
|
40
|
+
identifier,
|
|
41
|
+
binaryVersion,
|
|
50
42
|
}
|
|
51
43
|
|
|
52
|
-
const config = await findAndReadConfigFile(process.cwd(), options.config)
|
|
53
|
-
|
|
54
44
|
await createReleaseHistory(
|
|
55
45
|
answers.app,
|
|
56
46
|
answers.binaryVersion,
|
|
@@ -58,4 +48,13 @@ program
|
|
|
58
48
|
answers.platform,
|
|
59
49
|
answers.identifier
|
|
60
50
|
)
|
|
51
|
+
|
|
52
|
+
await createReleaseHistoryList(
|
|
53
|
+
answers.app,
|
|
54
|
+
answers.binaryVersion,
|
|
55
|
+
answers.platform,
|
|
56
|
+
answers.identifier,
|
|
57
|
+
config.getBinaryVersionList,
|
|
58
|
+
config.setBinaryVersionList
|
|
59
|
+
)
|
|
61
60
|
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { program } = require('commander')
|
|
2
|
-
const inquirer = require('inquirer').default
|
|
3
2
|
const { findAndReadConfigFile } = require('../../utils/fsUtils')
|
|
4
3
|
const { release } = require('./release')
|
|
5
4
|
const {
|
|
@@ -8,6 +7,13 @@ const {
|
|
|
8
7
|
ROOT_OUTPUT_DIR,
|
|
9
8
|
ENTRY_FILE,
|
|
10
9
|
} = require('../../constant')
|
|
10
|
+
const {
|
|
11
|
+
getAppValue,
|
|
12
|
+
getPlatformValue,
|
|
13
|
+
getIdentifierValue,
|
|
14
|
+
getBinaryVersionValueFromInput,
|
|
15
|
+
getAppVersionValueFromInput,
|
|
16
|
+
} = require('../common')
|
|
11
17
|
|
|
12
18
|
program
|
|
13
19
|
.command('release')
|
|
@@ -75,6 +81,12 @@ program
|
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
let answers = {}
|
|
84
|
+
const {
|
|
85
|
+
bundleUploader,
|
|
86
|
+
getReleaseHistory,
|
|
87
|
+
setReleaseHistory,
|
|
88
|
+
getBinaryVersionList,
|
|
89
|
+
} = await findAndReadConfigFile(process.cwd(), options.config)
|
|
78
90
|
|
|
79
91
|
if (
|
|
80
92
|
options.app &&
|
|
@@ -91,57 +103,41 @@ program
|
|
|
91
103
|
appVersion: options.appVersion,
|
|
92
104
|
}
|
|
93
105
|
} else {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
type: 'input',
|
|
116
|
-
name: 'binaryVersion',
|
|
117
|
-
message: 'Enter the target binary version',
|
|
118
|
-
validate: (input) => {
|
|
119
|
-
if (semverRegex.test(input)) return true
|
|
120
|
-
return 'Please enter a valid version number (x.y.z)'
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
type: 'input',
|
|
125
|
-
name: 'appVersion',
|
|
126
|
-
message: 'Enter the target codepush version',
|
|
127
|
-
validate: (input) => {
|
|
128
|
-
if (semverRegex.test(input)) return true
|
|
129
|
-
return 'Please enter a valid version number (x.y.z)'
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
])
|
|
106
|
+
// app
|
|
107
|
+
const app = await getAppValue()
|
|
108
|
+
// platform
|
|
109
|
+
const platform = await getPlatformValue(app)
|
|
110
|
+
// identifier
|
|
111
|
+
const identifier = await getIdentifierValue()
|
|
112
|
+
// binaryVersion
|
|
113
|
+
const binaryVersion = await getBinaryVersionValueFromInput(
|
|
114
|
+
getBinaryVersionList,
|
|
115
|
+
app,
|
|
116
|
+
platform,
|
|
117
|
+
identifier
|
|
118
|
+
)
|
|
119
|
+
// appVersion
|
|
120
|
+
const appVersion = await getAppVersionValueFromInput(
|
|
121
|
+
getReleaseHistory,
|
|
122
|
+
binaryVersion,
|
|
123
|
+
app,
|
|
124
|
+
platform,
|
|
125
|
+
identifier
|
|
126
|
+
)
|
|
133
127
|
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
answers = {
|
|
129
|
+
app,
|
|
130
|
+
platform,
|
|
131
|
+
identifier,
|
|
132
|
+
binaryVersion,
|
|
133
|
+
appVersion,
|
|
136
134
|
}
|
|
137
135
|
}
|
|
138
136
|
|
|
139
|
-
const config = await findAndReadConfigFile(process.cwd(), options.config)
|
|
140
|
-
|
|
141
137
|
await release(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
138
|
+
bundleUploader,
|
|
139
|
+
getReleaseHistory,
|
|
140
|
+
setReleaseHistory,
|
|
145
141
|
answers.app,
|
|
146
142
|
answers.binaryVersion,
|
|
147
143
|
answers.appVersion,
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
const { program } = require('commander')
|
|
2
|
-
const inquirer = require('inquirer').default
|
|
3
2
|
const { findAndReadConfigFile } = require('../../utils/fsUtils')
|
|
4
3
|
const { COMPILED_CONFIG_FILE_NAME } = require('../../constant')
|
|
4
|
+
const {
|
|
5
|
+
getAppValue,
|
|
6
|
+
getPlatformValue,
|
|
7
|
+
getIdentifierValue,
|
|
8
|
+
getBinaryVersionValueFromList,
|
|
9
|
+
} = require('../common')
|
|
5
10
|
|
|
6
11
|
program
|
|
7
12
|
.command('show-history')
|
|
@@ -14,44 +19,28 @@ program
|
|
|
14
19
|
COMPILED_CONFIG_FILE_NAME
|
|
15
20
|
)
|
|
16
21
|
.action(async (options) => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
type: 'list',
|
|
33
|
-
name: 'identifier',
|
|
34
|
-
message: 'Select the target env identifier',
|
|
35
|
-
choices: ['stg', 'prd'],
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
type: 'input',
|
|
39
|
-
name: 'binaryVersion',
|
|
40
|
-
message: 'Enter the target binary version',
|
|
41
|
-
validate: (input) => {
|
|
42
|
-
const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
|
|
43
|
-
if (semverRegex.test(input)) return true
|
|
44
|
-
return 'Please enter a valid version number (x.y.z)'
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
])
|
|
22
|
+
const config = await findAndReadConfigFile(process.cwd(), options.config)
|
|
23
|
+
// app
|
|
24
|
+
const app = await getAppValue()
|
|
25
|
+
// platform
|
|
26
|
+
const platform = await getPlatformValue(app)
|
|
27
|
+
// identifier
|
|
28
|
+
const identifier = await getIdentifierValue()
|
|
29
|
+
// binaryVersion
|
|
30
|
+
const binaryVersion = await getBinaryVersionValueFromList(
|
|
31
|
+
config.getBinaryVersionList,
|
|
32
|
+
app,
|
|
33
|
+
platform,
|
|
34
|
+
identifier
|
|
35
|
+
)
|
|
48
36
|
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
const answers = {
|
|
38
|
+
app,
|
|
39
|
+
platform,
|
|
40
|
+
identifier,
|
|
41
|
+
binaryVersion,
|
|
51
42
|
}
|
|
52
43
|
|
|
53
|
-
const config = await findAndReadConfigFile(process.cwd(), options.config)
|
|
54
|
-
|
|
55
44
|
const releaseHistory = await config.getReleaseHistory(
|
|
56
45
|
answers.app,
|
|
57
46
|
answers.binaryVersion,
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
const { program } = require('commander')
|
|
2
|
-
const inquirer = require('inquirer').default
|
|
3
2
|
const { findAndReadConfigFile } = require('../../utils/fsUtils')
|
|
4
3
|
const { updateReleaseHistory } = require('./updateReleaseHistory')
|
|
5
4
|
const { COMPILED_CONFIG_FILE_NAME } = require('../../constant')
|
|
5
|
+
const {
|
|
6
|
+
getAppValue,
|
|
7
|
+
getPlatformValue,
|
|
8
|
+
getIdentifierValue,
|
|
9
|
+
getBinaryVersionValueFromList,
|
|
10
|
+
getAppVersionValueFromList,
|
|
11
|
+
} = require('../common')
|
|
6
12
|
|
|
7
13
|
program
|
|
8
14
|
.command('update-history')
|
|
@@ -22,53 +28,37 @@ program
|
|
|
22
28
|
)
|
|
23
29
|
.option('--no-enable', 'make the release to be disabled')
|
|
24
30
|
.action(async (options) => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
type: 'input',
|
|
48
|
-
name: 'binaryVersion',
|
|
49
|
-
message: 'Enter the target binary version',
|
|
50
|
-
validate: (input) => {
|
|
51
|
-
if (semverRegex.test(input)) return true
|
|
52
|
-
return 'Please enter a valid version number (x.y.z)'
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
type: 'input',
|
|
57
|
-
name: 'appVersion',
|
|
58
|
-
message: 'Enter the target codepush version',
|
|
59
|
-
validate: (input) => {
|
|
60
|
-
if (semverRegex.test(input)) return true
|
|
61
|
-
return 'Please enter a valid version number (x.y.z)'
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
])
|
|
31
|
+
const config = await findAndReadConfigFile(process.cwd(), options.config)
|
|
32
|
+
// app
|
|
33
|
+
const app = await getAppValue()
|
|
34
|
+
// platform
|
|
35
|
+
const platform = await getPlatformValue(app)
|
|
36
|
+
// identifier
|
|
37
|
+
const identifier = await getIdentifierValue()
|
|
38
|
+
// binaryVersion
|
|
39
|
+
const binaryVersion = await getBinaryVersionValueFromList(
|
|
40
|
+
config.getBinaryVersionList,
|
|
41
|
+
app,
|
|
42
|
+
platform,
|
|
43
|
+
identifier
|
|
44
|
+
)
|
|
45
|
+
// appVersion
|
|
46
|
+
const appVersion = await getAppVersionValueFromList(
|
|
47
|
+
config.getReleaseHistory,
|
|
48
|
+
binaryVersion,
|
|
49
|
+
app,
|
|
50
|
+
platform,
|
|
51
|
+
identifier
|
|
52
|
+
)
|
|
65
53
|
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
const answers = {
|
|
55
|
+
app,
|
|
56
|
+
platform,
|
|
57
|
+
identifier,
|
|
58
|
+
binaryVersion,
|
|
59
|
+
appVersion,
|
|
68
60
|
}
|
|
69
61
|
|
|
70
|
-
const config = await findAndReadConfigFile(process.cwd(), options.config)
|
|
71
|
-
|
|
72
62
|
if (
|
|
73
63
|
typeof options.mandatory !== 'boolean' &&
|
|
74
64
|
typeof options.enable !== 'boolean'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
async function getBinaryVersions(
|
|
2
|
+
getBinaryVersionList,
|
|
3
|
+
app,
|
|
4
|
+
platform,
|
|
5
|
+
identifier
|
|
6
|
+
) {
|
|
7
|
+
const currentVersionList = await getBinaryVersionList(
|
|
8
|
+
app,
|
|
9
|
+
platform,
|
|
10
|
+
identifier
|
|
11
|
+
)
|
|
12
|
+
return [
|
|
13
|
+
Object.keys(currentVersionList),
|
|
14
|
+
Object.keys(currentVersionList).pop(),
|
|
15
|
+
]
|
|
16
|
+
}
|
|
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
|
+
)
|
|
31
|
+
return [Object.keys(releaseHistory), Object.keys(releaseHistory).pop()]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = {
|
|
35
|
+
getBinaryVersions,
|
|
36
|
+
getAppVersions,
|
|
37
|
+
}
|
package/code-push.config.js
CHANGED
|
@@ -63,7 +63,6 @@ const Config = {
|
|
|
63
63
|
throw error
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
|
|
67
66
|
getReleaseHistory: async (app, targetBinaryVersion, platform, identifier) => {
|
|
68
67
|
const CDN_URL = getCDNUrl(identifier)
|
|
69
68
|
const remoteJsonPath = historyJsonFileRemotePath(
|
|
@@ -112,6 +111,63 @@ const Config = {
|
|
|
112
111
|
throw error
|
|
113
112
|
}
|
|
114
113
|
},
|
|
114
|
+
getBinaryVersionList: async (app, platform, identifier) => {
|
|
115
|
+
const CDN_URL = getCDNUrl(identifier)
|
|
116
|
+
const remoteJsonPath = `histories/${app}/${platform}/list.json`
|
|
117
|
+
let currentList = {}
|
|
118
|
+
try {
|
|
119
|
+
console.log('Getting existing version list file')
|
|
120
|
+
const { data } = await axios.get(`${CDN_URL}/${remoteJsonPath}`)
|
|
121
|
+
currentList = { ...data }
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error(
|
|
124
|
+
'Error occurred while getting existing version list file, maybe it is not exist.',
|
|
125
|
+
error.status
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
return currentList
|
|
129
|
+
},
|
|
130
|
+
setBinaryVersionList: async (
|
|
131
|
+
targetVersion,
|
|
132
|
+
jsonFilePath,
|
|
133
|
+
app,
|
|
134
|
+
platform,
|
|
135
|
+
identifier
|
|
136
|
+
) => {
|
|
137
|
+
const remoteJsonPath = `histories/${app}/${platform}/list.json`
|
|
138
|
+
const BUCKET_NAME = getBucketName(identifier)
|
|
139
|
+
const CDN_URL = getCDNUrl(identifier)
|
|
140
|
+
|
|
141
|
+
const currentList = JSON.parse(fs.readFileSync(jsonFilePath, 'utf8'))
|
|
142
|
+
const targetVersionPath = historyJsonFileRemotePath(
|
|
143
|
+
app,
|
|
144
|
+
platform,
|
|
145
|
+
targetVersion
|
|
146
|
+
)
|
|
147
|
+
currentList[targetVersion] = `${CDN_URL}/${targetVersionPath}`
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
await s3Client.send(
|
|
151
|
+
new PutObjectCommand({
|
|
152
|
+
Bucket: BUCKET_NAME,
|
|
153
|
+
Key: remoteJsonPath,
|
|
154
|
+
Body: JSON.stringify(currentList),
|
|
155
|
+
ContentType: 'application/json',
|
|
156
|
+
CacheControl: 'max-age=5',
|
|
157
|
+
})
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
console.log(
|
|
161
|
+
'Binary version list uploaded:',
|
|
162
|
+
`${CDN_URL}/${remoteJsonPath}`,
|
|
163
|
+
'\nContent:',
|
|
164
|
+
JSON.stringify(currentList, null, 2)
|
|
165
|
+
)
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error('Error uploading binary version list:', error)
|
|
168
|
+
throw error
|
|
169
|
+
}
|
|
170
|
+
},
|
|
115
171
|
}
|
|
116
172
|
|
|
117
173
|
module.exports = Config
|