@algocare/react-native-code-push 9.0.0-beta.5 → 9.0.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.
@@ -1,29 +1,55 @@
1
- const { program, Option } = require("commander");
2
- const { bundleCodePush } = require("./bundleCodePush");
3
- const { OUTPUT_BUNDLE_DIR, ROOT_OUTPUT_DIR, ENTRY_FILE } = require('../../constant');
1
+ const { program } = require('commander')
2
+ const inquirer = require('inquirer').default
3
+ const { bundleCodePush } = require('./bundleCodePush')
4
+ const {
5
+ OUTPUT_BUNDLE_DIR,
6
+ ROOT_OUTPUT_DIR,
7
+ ENTRY_FILE,
8
+ } = require('../../constant')
4
9
 
5
- program.command('bundle')
6
- .description('Creates a CodePush bundle file (assumes Hermes is enabled).')
7
- .addOption(new Option('-p, --platform <type>', 'platform').choices(['ios', 'android']).default('ios'))
8
- .option('-o, --output-path <string>', 'path to output root directory', ROOT_OUTPUT_DIR)
9
- .option('-e, --entry-file <string>', 'path to JS/TS entry file', ENTRY_FILE)
10
- .option('-b, --bundle-name <string>', 'bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")')
11
- .option('--output-bundle-dir <string>', 'name of directory containing the bundle file created by the "bundle" command', OUTPUT_BUNDLE_DIR)
12
- /**
13
- * @param {Object} options
14
- * @param {string} options.platform
15
- * @param {string} options.outputPath
16
- * @param {string} options.entryFile
17
- * @param {string} options.bundleName
18
- * @param {string} options.outputBundleDir
19
- * @return {void}
20
- */
21
- .action((options) => {
22
- bundleCodePush(
23
- options.platform,
24
- options.outputPath,
25
- options.entryFile,
26
- options.bundleName,
27
- `${options.outputPath}/${options.outputBundleDir}`,
28
- )
29
- });
10
+ program
11
+ .command('bundle')
12
+ .description('Creates a CodePush bundle file (assumes Hermes is enabled).')
13
+ .option(
14
+ '-o, --output-path <string>',
15
+ 'path to output root directory',
16
+ ROOT_OUTPUT_DIR
17
+ )
18
+ .option('-e, --entry-file <string>', 'path to JS/TS entry file', ENTRY_FILE)
19
+ .option(
20
+ '-b, --bundle-name <string>',
21
+ 'bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")'
22
+ )
23
+ .option(
24
+ '--output-bundle-dir <string>',
25
+ 'name of directory containing the bundle file created by the "bundle" command',
26
+ OUTPUT_BUNDLE_DIR
27
+ )
28
+ .action(async (options) => {
29
+ const answers = await inquirer.prompt([
30
+ {
31
+ type: 'list',
32
+ name: 'app',
33
+ message: 'Select the target app',
34
+ choices: ['user', 'device'],
35
+ },
36
+ {
37
+ type: 'list',
38
+ name: 'platform',
39
+ message: 'Select the target platform',
40
+ choices: ['ios', 'android'],
41
+ when: (answers) => answers.app !== 'device',
42
+ },
43
+ ])
44
+ if (answers.app === 'device') {
45
+ answers.platform = 'android'
46
+ }
47
+
48
+ bundleCodePush(
49
+ answers.platform,
50
+ options.outputPath,
51
+ options.entryFile,
52
+ options.bundleName,
53
+ `${options.outputPath}/${options.outputBundleDir}`
54
+ )
55
+ })
@@ -1,4 +1,5 @@
1
- const { program, Option } = require('commander')
1
+ const { program } = require('commander')
2
+ const inquirer = require('inquirer').default
2
3
  const { findAndReadConfigFile } = require('../../utils/fsUtils')
3
4
  const { createReleaseHistory } = require('./createReleaseHistory')
4
5
  const { COMPILED_CONFIG_FILE_NAME } = require('../../constant')
@@ -6,45 +7,55 @@ const { COMPILED_CONFIG_FILE_NAME } = require('../../constant')
6
7
  program
7
8
  .command('create-history')
8
9
  .description('Creates a new release history for the binary app.')
9
- .requiredOption(
10
- '-a, --app <string>',
11
- '(Required) The target app: user or device'
12
- )
13
- .requiredOption(
14
- '-b, --binary-version <string>',
15
- '(Required) The target binary version'
16
- )
17
- .addOption(
18
- new Option('-p, --platform <type>', 'platform')
19
- .choices(['ios', 'android'])
20
- .default('ios')
21
- )
22
- .option(
23
- '-i, --identifier <string>',
24
- 'reserved characters to distinguish the release.'
25
- )
26
10
  .option(
27
11
  '-c, --config <path>',
28
12
  'set config file name (JS/TS)',
29
13
  COMPILED_CONFIG_FILE_NAME
30
14
  )
31
- /**
32
- * @param {Object} options
33
- * @param {string} options.app
34
- * @param {string} options.binaryVersion
35
- * @param {string} options.platform
36
- * @param {string} options.identifier
37
- * @param {string} options.config
38
- * @return {void}
39
- */
40
15
  .action(async (options) => {
16
+ const answers = await inquirer.prompt([
17
+ {
18
+ type: 'list',
19
+ name: 'app',
20
+ message: 'Select the target app',
21
+ choices: ['user', 'device'],
22
+ },
23
+ {
24
+ type: 'list',
25
+ name: 'platform',
26
+ message: 'Select the target platform',
27
+ choices: ['ios', 'android'],
28
+ when: (answers) => answers.app !== 'device',
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
+ ])
47
+
48
+ if (answers.app === 'device') {
49
+ answers.platform = 'android'
50
+ }
51
+
41
52
  const config = await findAndReadConfigFile(process.cwd(), options.config)
42
53
 
43
54
  await createReleaseHistory(
44
- options.app,
45
- options.binaryVersion,
55
+ answers.app,
56
+ answers.binaryVersion,
46
57
  config.setReleaseHistory,
47
- options.platform,
48
- options.identifier
58
+ answers.platform,
59
+ answers.identifier
49
60
  )
50
61
  })
@@ -1,4 +1,5 @@
1
- const { program, Option } = require('commander')
1
+ const { program } = require('commander')
2
+ const inquirer = require('inquirer').default
2
3
  const { findAndReadConfigFile } = require('../../utils/fsUtils')
3
4
  const { release } = require('./release')
4
5
  const {
@@ -13,27 +14,6 @@ program
13
14
  .description(
14
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.'
15
16
  )
16
- .requiredOption(
17
- '-a, --app <string>',
18
- '(Required) The target app: user or device'
19
- )
20
- .requiredOption(
21
- '-b, --binary-version <string>',
22
- '(Required) The target binary version'
23
- )
24
- .requiredOption(
25
- '-v, --app-version <string>',
26
- '(Required) The app version to be released. It must be greater than the binary version.'
27
- )
28
- .addOption(
29
- new Option('-p, --platform <type>', 'platform')
30
- .choices(['ios', 'android'])
31
- .default('ios')
32
- )
33
- .option(
34
- '-i, --identifier <string>',
35
- 'reserved characters to distinguish the release.'
36
- )
37
17
  .option(
38
18
  '-c, --config <path>',
39
19
  'set config file name (JS/TS)',
@@ -49,55 +29,78 @@ program
49
29
  '-j, --js-bundle-name <string>',
50
30
  'JS bundle file name (default-ios: "main.jsbundle" / default-android: "index.android.bundle")'
51
31
  )
32
+ .option('-m, --mandatory', 'make the release to be mandatory', false)
52
33
  .option(
53
- '-m, --mandatory <bool>',
54
- 'make the release to be mandatory',
55
- parseBoolean,
56
- false
57
- )
58
- .option(
59
- '--enable <bool>',
60
- 'make the release to be enabled',
61
- parseBoolean,
34
+ '--enable',
35
+ 'make the release to be enabled (use --no-enable to disable)',
62
36
  true
63
37
  )
64
- .option('--skip-bundle <bool>', 'skip bundle process', parseBoolean, false)
65
- .option('--skip-cleanup <bool>', 'skip cleanup process', parseBoolean, false)
38
+ .option('--no-enable', 'make the release to be disabled')
39
+ .option('--skip-bundle', 'skip bundle process', false)
40
+ .option('--skip-cleanup', 'skip cleanup process', false)
66
41
  .option(
67
42
  '--output-bundle-dir <string>',
68
43
  'name of directory containing the bundle file created by the "bundle" command',
69
44
  OUTPUT_BUNDLE_DIR
70
45
  )
71
- /**
72
- * @param {Object} options
73
- * @param {string} options.app
74
- * @param {string} options.binaryVersion
75
- * @param {string} options.appVersion
76
- * @param {string} options.platform
77
- * @param {string} options.identifier
78
- * @param {string} options.config
79
- * @param {string} options.outputPath
80
- * @param {string} options.entryFile
81
- * @param {string} options.bundleName
82
- * @param {string} options.mandatory
83
- * @param {string} options.enable
84
- * @param {string} options.skipBundle
85
- * @param {string} options.skipCleanup
86
- * @param {string} options.outputBundleDir
87
- * @return {void}
88
- */
89
46
  .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)'
75
+ },
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)'
85
+ },
86
+ },
87
+ ])
88
+
89
+ if (answers.app === 'device') {
90
+ answers.platform = 'android'
91
+ }
92
+
90
93
  const config = await findAndReadConfigFile(process.cwd(), options.config)
91
94
 
92
95
  await release(
93
96
  config.bundleUploader,
94
97
  config.getReleaseHistory,
95
98
  config.setReleaseHistory,
96
- options.app,
97
- options.binaryVersion,
98
- options.appVersion,
99
- options.platform,
100
- options.identifier,
99
+ answers.app,
100
+ answers.binaryVersion,
101
+ answers.appVersion,
102
+ answers.platform,
103
+ answers.identifier,
101
104
  options.outputPath,
102
105
  options.entryFile,
103
106
  options.bundleName,
@@ -110,9 +113,3 @@ program
110
113
 
111
114
  console.log('🚀 Release completed.')
112
115
  })
113
-
114
- function parseBoolean(value) {
115
- if (value === 'true') return true
116
- if (value === 'false') return false
117
- else return undefined
118
- }
@@ -1,4 +1,5 @@
1
- const { program, Option } = require('commander')
1
+ const { program } = require('commander')
2
+ const inquirer = require('inquirer').default
2
3
  const { findAndReadConfigFile } = require('../../utils/fsUtils')
3
4
  const { COMPILED_CONFIG_FILE_NAME } = require('../../constant')
4
5
 
@@ -7,45 +8,55 @@ program
7
8
  .description(
8
9
  'Retrieves and prints the release history of a specific binary version.\n`getReleaseHistory` function should be implemented in the config file.'
9
10
  )
10
- .requiredOption(
11
- '-a, --app <string>',
12
- '(Required) The target app: user or device'
13
- )
14
- .requiredOption(
15
- '-b, --binary-version <string>',
16
- '(Required) The target binary version for retrieving the release history.'
17
- )
18
- .addOption(
19
- new Option('-p, --platform <type>', 'platform')
20
- .choices(['ios', 'android'])
21
- .default('ios')
22
- )
23
- .option(
24
- '-i, --identifier <string>',
25
- 'reserved characters to distinguish the release.'
26
- )
27
11
  .option(
28
12
  '-c, --config <path>',
29
13
  'configuration file name (JS/TS)',
30
14
  COMPILED_CONFIG_FILE_NAME
31
15
  )
32
- /**
33
- * @param {Object} options
34
- * @param {string} options.app
35
- * @param {string} options.binaryVersion
36
- * @param {string} options.platform
37
- * @param {string} options.identifier
38
- * @param {string} options.config
39
- * @return {void}
40
- */
41
16
  .action(async (options) => {
17
+ const answers = await inquirer.prompt([
18
+ {
19
+ type: 'list',
20
+ name: 'app',
21
+ message: 'Select the target app',
22
+ choices: ['user', 'device'],
23
+ },
24
+ {
25
+ type: 'list',
26
+ name: 'platform',
27
+ message: 'Select the target platform',
28
+ choices: ['ios', 'android'],
29
+ when: (answers) => answers.app !== 'device',
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
+ ])
48
+
49
+ if (answers.app === 'device') {
50
+ answers.platform = 'android'
51
+ }
52
+
42
53
  const config = await findAndReadConfigFile(process.cwd(), options.config)
43
54
 
44
55
  const releaseHistory = await config.getReleaseHistory(
45
- options.app,
46
- options.binaryVersion,
47
- options.platform,
48
- options.identifier
56
+ answers.app,
57
+ answers.binaryVersion,
58
+ answers.platform,
59
+ answers.identifier
49
60
  )
50
61
 
51
62
  console.log(JSON.stringify(releaseHistory, null, 2))
@@ -1,4 +1,5 @@
1
- const { program, Option } = require('commander')
1
+ const { program } = require('commander')
2
+ const inquirer = require('inquirer').default
2
3
  const { findAndReadConfigFile } = require('../../utils/fsUtils')
3
4
  const { updateReleaseHistory } = require('./updateReleaseHistory')
4
5
  const { COMPILED_CONFIG_FILE_NAME } = require('../../constant')
@@ -8,57 +9,65 @@ program
8
9
  .description(
9
10
  'Updates the release history for a specific binary version.\n`getReleaseHistory`, `setReleaseHistory` functions should be implemented in the config file.'
10
11
  )
11
- .requiredOption(
12
- '-a, --app <string>',
13
- '(Required) The target app: user or device'
14
- )
15
- .requiredOption(
16
- '-v, --app-version <string>',
17
- '(Required) The app version for which update information is to be modified.'
18
- )
19
- .requiredOption(
20
- '-b, --binary-version <string>',
21
- '(Required) The target binary version of the app for which update information is to be modified.'
22
- )
23
- .addOption(
24
- new Option('-p, --platform <type>', 'platform')
25
- .choices(['ios', 'android'])
26
- .default('ios')
27
- )
28
- .option(
29
- '-i, --identifier <string>',
30
- 'reserved characters to distinguish the release.'
31
- )
32
12
  .option(
33
13
  '-c, --config <path>',
34
14
  'set config file name (JS/TS)',
35
15
  COMPILED_CONFIG_FILE_NAME
36
16
  )
17
+ .option('-m, --mandatory', 'make the release to be mandatory', false)
37
18
  .option(
38
- '-m, --mandatory <bool>',
39
- 'make the release to be mandatory',
40
- parseBoolean,
41
- undefined
19
+ '-e, --enable',
20
+ 'make the release to be enabled (use --no-enable to disable)',
21
+ true
42
22
  )
43
- .option(
44
- '-e, --enable <bool>',
45
- 'make the release to be enabled',
46
- parseBoolean,
47
- undefined
48
- )
49
- /**
50
- * @param {Object} options
51
- * @param {string} options.app
52
- * @param {string} options.appVersion
53
- * @param {string} options.binaryVersion
54
- * @param {string} options.platform
55
- * @param {string} options.identifier
56
- * @param {string} options.config
57
- * @param {string} options.mandatory
58
- * @param {string} options.enable
59
- * @return {void}
60
- */
23
+ .option('--no-enable', 'make the release to be disabled')
61
24
  .action(async (options) => {
25
+ const answers = await inquirer.prompt([
26
+ {
27
+ type: 'list',
28
+ name: 'app',
29
+ message: 'Select the target app',
30
+ choices: ['user', 'device'],
31
+ },
32
+ {
33
+ type: 'list',
34
+ name: 'platform',
35
+ message: 'Select the target platform',
36
+ choices: ['ios', 'android'],
37
+ when: (answers) => answers.app !== 'device',
38
+ },
39
+ {
40
+ type: 'list',
41
+ name: 'identifier',
42
+ message: 'Select the target env identifier',
43
+ choices: ['stg', 'prd'],
44
+ },
45
+ {
46
+ type: 'input',
47
+ name: 'binaryVersion',
48
+ message: 'Enter the target binary version',
49
+ validate: (input) => {
50
+ const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
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
+ const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
61
+ if (semverRegex.test(input)) return true
62
+ return 'Please enter a valid version number (x.y.z)'
63
+ },
64
+ },
65
+ ])
66
+
67
+ if (answers.app === 'device') {
68
+ answers.platform = 'android'
69
+ }
70
+
62
71
  const config = await findAndReadConfigFile(process.cwd(), options.config)
63
72
 
64
73
  if (
@@ -70,20 +79,14 @@ program
70
79
  }
71
80
 
72
81
  await updateReleaseHistory(
73
- options.app,
74
- options.appVersion,
75
- options.binaryVersion,
82
+ answers.app,
83
+ answers.appVersion,
84
+ answers.binaryVersion,
76
85
  config.getReleaseHistory,
77
86
  config.setReleaseHistory,
78
- options.platform,
79
- options.identifier,
87
+ answers.platform,
88
+ answers.identifier,
80
89
  options.mandatory,
81
90
  options.enable
82
91
  )
83
92
  })
84
-
85
- function parseBoolean(value) {
86
- if (value === 'true') return true
87
- if (value === 'false') return false
88
- else return undefined
89
- }
@@ -14,22 +14,34 @@ const s3Client = new S3Client({
14
14
  },
15
15
  })
16
16
 
17
- const BUCKET_NAME = process.env.AWS_S3_BUCKET || 'codepush-bucket'
18
- const CDN_URL = process.env.CDN_URL || `https://${BUCKET_NAME}.s3.amazonaws.com`
17
+ function getBucketName(identifier) {
18
+ return identifier === 'prd'
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
+ }
19
29
 
20
- function historyJsonFileRemotePath(app, platform, identifier, binaryVersion) {
21
- return `histories/${app}/${platform}/${identifier}/${binaryVersion}.json`
30
+ function historyJsonFileRemotePath(app, platform, binaryVersion) {
31
+ return `histories/${app}/${platform}/${binaryVersion}.json`
22
32
  }
23
33
 
24
- function bundleFileRemotePath(app, platform, identifier, fileName) {
25
- return `bundles/${app}/${platform}/${identifier}/${fileName}`
34
+ function bundleFileRemotePath(app, platform, fileName) {
35
+ return `bundles/${app}/${platform}/${fileName}`
26
36
  }
27
37
 
28
38
  const Config = {
29
- bundleUploader: async (source, app, platform, identifier = 'staging') => {
39
+ bundleUploader: async (source, app, platform, identifier) => {
30
40
  const fileName = source.split('/').pop()
31
41
  const fileContent = fs.readFileSync(source)
32
- const remotePath = bundleFileRemotePath(app, platform, identifier, fileName)
42
+ const remotePath = bundleFileRemotePath(app, platform, fileName)
43
+ const BUCKET_NAME = getBucketName(identifier)
44
+ const CDN_URL = getCDNUrl(identifier)
33
45
 
34
46
  try {
35
47
  await s3Client.send(
@@ -52,16 +64,11 @@ const Config = {
52
64
  }
53
65
  },
54
66
 
55
- getReleaseHistory: async (
56
- targetBinaryVersion,
57
- app,
58
- platform,
59
- identifier = 'staging'
60
- ) => {
67
+ getReleaseHistory: async (app, targetBinaryVersion, platform, identifier) => {
68
+ const CDN_URL = getCDNUrl(identifier)
61
69
  const remoteJsonPath = historyJsonFileRemotePath(
62
70
  app,
63
71
  platform,
64
- identifier,
65
72
  targetBinaryVersion
66
73
  )
67
74
  const { data } = await axios.get(`${CDN_URL}/${remoteJsonPath}`)
@@ -74,15 +81,16 @@ const Config = {
74
81
  releaseInfo,
75
82
  app,
76
83
  platform,
77
- identifier = 'staging'
84
+ identifier
78
85
  ) => {
79
86
  const fileContent = fs.readFileSync(jsonFilePath, 'utf8')
80
87
  const remoteJsonPath = historyJsonFileRemotePath(
81
88
  app,
82
89
  platform,
83
- identifier,
84
90
  targetBinaryVersion
85
91
  )
92
+ const BUCKET_NAME = getBucketName(identifier)
93
+ const CDN_URL = getCDNUrl(identifier)
86
94
 
87
95
  try {
88
96
  await s3Client.send(
@@ -17,25 +17,33 @@ const s3Client = new S3Client({
17
17
  },
18
18
  })
19
19
 
20
- const BUCKET_NAME = process.env.AWS_S3_BUCKET || 'codepush-bucket'
21
- const CDN_URL = process.env.CDN_URL || `https://${BUCKET_NAME}.s3.amazonaws.com`
20
+ function getBucketName(identifier: 'stg' | 'prd') {
21
+ return identifier === 'prd'
22
+ ? process.env.AWS_S3_BUCKET_PRD || 'codepush-bucket'
23
+ : process.env.AWS_S3_BUCKET_STG || 'codepush-bucket'
24
+ }
25
+
26
+ function getCDNUrl(identifier: 'stg' | 'prd') {
27
+ const BUCKET_NAME = getBucketName(identifier)
28
+ return identifier === 'prd'
29
+ ? process.env.CDN_URL_PRD || `https://${BUCKET_NAME}.s3.amazonaws.com`
30
+ : process.env.CDN_URL_STG || `https://${BUCKET_NAME}.s3.amazonaws.com`
31
+ }
22
32
 
23
33
  function historyJsonFileRemotePath(
24
34
  app: 'user' | 'device',
25
35
  platform: 'ios' | 'android',
26
- identifier: string,
27
36
  binaryVersion: string
28
37
  ) {
29
- return `histories/${app}/${platform}/${identifier}/${binaryVersion}.json`
38
+ return `histories/${app}/${platform}/${binaryVersion}.json`
30
39
  }
31
40
 
32
41
  function bundleFileRemotePath(
33
42
  app: 'user' | 'device',
34
43
  platform: 'ios' | 'android',
35
- identifier: string,
36
44
  fileName: string
37
45
  ) {
38
- return `bundles/${app}/${platform}/${identifier}/${fileName}`
46
+ return `bundles/${app}/${platform}/${fileName}`
39
47
  }
40
48
 
41
49
  const Config: CliConfigInterface = {
@@ -43,16 +51,13 @@ const Config: CliConfigInterface = {
43
51
  source: string,
44
52
  app: 'user' | 'device',
45
53
  platform: 'ios' | 'android',
46
- identifier = 'staging'
54
+ identifier: 'stg' | 'prd'
47
55
  ): Promise<{ downloadUrl: string }> => {
48
56
  const fileName = source.split('/').pop()
49
57
  const fileContent = fs.readFileSync(source)
50
- const remotePath = bundleFileRemotePath(
51
- app,
52
- platform,
53
- identifier,
54
- fileName!
55
- )
58
+ const remotePath = bundleFileRemotePath(app, platform, fileName!)
59
+ const BUCKET_NAME = getBucketName(identifier)
60
+ const CDN_URL = getCDNUrl(identifier)
56
61
 
57
62
  try {
58
63
  await s3Client.send(
@@ -79,14 +84,15 @@ const Config: CliConfigInterface = {
79
84
  app: 'user' | 'device',
80
85
  targetBinaryVersion: string,
81
86
  platform: 'ios' | 'android',
82
- identifier = 'staging'
87
+ identifier: 'stg' | 'prd'
83
88
  ): Promise<ReleaseHistoryInterface> => {
84
89
  const remoteJsonPath = historyJsonFileRemotePath(
85
90
  app,
86
91
  platform,
87
- identifier,
88
92
  targetBinaryVersion
89
93
  )
94
+ const CDN_URL = getCDNUrl(identifier)
95
+
90
96
  const { data } = await axios.get(`${CDN_URL}/${remoteJsonPath}`)
91
97
  return data as ReleaseHistoryInterface
92
98
  },
@@ -97,15 +103,16 @@ const Config: CliConfigInterface = {
97
103
  releaseInfo: ReleaseHistoryInterface,
98
104
  app: 'user' | 'device',
99
105
  platform: 'ios' | 'android',
100
- identifier = 'staging'
106
+ identifier: 'stg' | 'prd'
101
107
  ): Promise<void> => {
102
108
  const fileContent = fs.readFileSync(jsonFilePath, 'utf8')
103
109
  const remoteJsonPath = historyJsonFileRemotePath(
104
110
  app,
105
111
  platform,
106
- identifier,
107
112
  targetBinaryVersion
108
113
  )
114
+ const BUCKET_NAME = getBucketName(identifier)
115
+ const CDN_URL = getCDNUrl(identifier)
109
116
 
110
117
  try {
111
118
  await s3Client.send(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algocare/react-native-code-push",
3
- "version": "9.0.0-beta.5",
3
+ "version": "9.0.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",