@algocare/react-native-code-push 9.0.0 → 9.1.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.
@@ -14,6 +14,11 @@ program
14
14
  .description(
15
15
  '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.'
16
16
  )
17
+ .option('-a, --app <string>', 'target app (user/device)')
18
+ .option('-p, --platform <string>', 'target platform (ios/android)')
19
+ .option('-i, --identifier <string>', 'target env identifier (stg/prd)')
20
+ .option('-b, --binary-version <string>', 'target binary version (x.y.z)')
21
+ .option('-v, --app-version <string>', 'target codepush version (x.y.z)')
17
22
  .option(
18
23
  '-c, --config <path>',
19
24
  'set config file name (JS/TS)',
@@ -44,50 +49,91 @@ program
44
49
  OUTPUT_BUNDLE_DIR
45
50
  )
46
51
  .action(async (options) => {
47
- const answers = await inquirer.prompt([
48
- {
49
- type: 'list',
50
- name: 'app',
51
- message: 'Select the target app',
52
- choices: ['user', 'device'],
53
- },
54
- {
55
- type: 'list',
56
- name: 'platform',
57
- message: 'Select the target platform',
58
- choices: ['ios', 'android'],
59
- when: (answers) => answers.app !== 'device',
60
- },
61
- {
62
- type: 'list',
63
- name: 'identifier',
64
- message: 'Select the target env identifier',
65
- choices: ['stg', 'prd'],
66
- },
67
- {
68
- type: 'input',
69
- name: 'binaryVersion',
70
- message: 'Enter the target binary version',
71
- validate: (input) => {
72
- const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
73
- if (semverRegex.test(input)) return true
74
- return 'Please enter a valid version number (x.y.z)'
52
+ if (options.app && !['user', 'device'].includes(options.app)) {
53
+ throw new Error('App must be either "user" or "device"')
54
+ }
55
+
56
+ if (options.platform && !['ios', 'android'].includes(options.platform)) {
57
+ throw new Error('Platform must be either "ios" or "android"')
58
+ }
59
+
60
+ if (options.app === 'device' && options.platform === 'ios') {
61
+ throw new Error('Device app is not supported on iOS')
62
+ }
63
+
64
+ if (options.identifier && !['stg', 'prd'].includes(options.identifier)) {
65
+ throw new Error('Identifier must be either "stg" or "prd"')
66
+ }
67
+
68
+ const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
69
+ if (options.binaryVersion && !semverRegex.test(options.binaryVersion)) {
70
+ throw new Error('Binary version must be a valid semver format (x.y.z)')
71
+ }
72
+
73
+ if (options.appVersion && !semverRegex.test(options.appVersion)) {
74
+ throw new Error('App version must be a valid semver format (x.y.z)')
75
+ }
76
+
77
+ let answers = {}
78
+
79
+ if (
80
+ options.app &&
81
+ options.identifier &&
82
+ options.binaryVersion &&
83
+ options.appVersion &&
84
+ (options.app === 'device' || options.platform)
85
+ ) {
86
+ answers = {
87
+ app: options.app,
88
+ platform: options.platform || (options.app === 'device' && 'android'),
89
+ identifier: options.identifier,
90
+ binaryVersion: options.binaryVersion,
91
+ appVersion: options.appVersion,
92
+ }
93
+ } else {
94
+ answers = await inquirer.prompt([
95
+ {
96
+ type: 'list',
97
+ name: 'app',
98
+ message: 'Select the target app',
99
+ choices: ['user', 'device'],
100
+ },
101
+ {
102
+ type: 'list',
103
+ name: 'platform',
104
+ message: 'Select the target platform',
105
+ choices: ['ios', 'android'],
106
+ when: (answers) => answers.app !== 'device',
107
+ },
108
+ {
109
+ type: 'list',
110
+ name: 'identifier',
111
+ message: 'Select the target env identifier',
112
+ choices: ['stg', 'prd'],
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
+ },
75
122
  },
76
- },
77
- {
78
- type: 'input',
79
- name: 'appVersion',
80
- message: 'Enter the target codepush version',
81
- validate: (input) => {
82
- const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
83
- if (semverRegex.test(input)) return true
84
- return 'Please enter a valid version number (x.y.z)'
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
+ },
85
131
  },
86
- },
87
- ])
132
+ ])
88
133
 
89
- if (answers.app === 'device') {
90
- answers.platform = 'android'
134
+ if (answers.app === 'device') {
135
+ answers.platform = 'android'
136
+ }
91
137
  }
92
138
 
93
139
  const config = await findAndReadConfigFile(process.cwd(), options.config)
@@ -22,6 +22,7 @@ program
22
22
  )
23
23
  .option('--no-enable', 'make the release to be disabled')
24
24
  .action(async (options) => {
25
+ const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
25
26
  const answers = await inquirer.prompt([
26
27
  {
27
28
  type: 'list',
@@ -47,7 +48,6 @@ program
47
48
  name: 'binaryVersion',
48
49
  message: 'Enter the target binary version',
49
50
  validate: (input) => {
50
- const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
51
51
  if (semverRegex.test(input)) return true
52
52
  return 'Please enter a valid version number (x.y.z)'
53
53
  },
@@ -57,7 +57,6 @@ program
57
57
  name: 'appVersion',
58
58
  message: 'Enter the target codepush version',
59
59
  validate: (input) => {
60
- const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
61
60
  if (semverRegex.test(input)) return true
62
61
  return 'Please enter a valid version number (x.y.z)'
63
62
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algocare/react-native-code-push",
3
- "version": "9.0.0",
3
+ "version": "9.1.0",
4
4
  "description": "React Native plugin for the CodePush service",
5
5
  "main": "CodePush.js",
6
6
  "typings": "typings/react-native-code-push.d.ts",