@algocare/react-native-code-push 10.3.2 → 11.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.
@@ -33,7 +33,7 @@ async function getIdentifierValue() {
33
33
  type: 'list',
34
34
  name: 'identifier',
35
35
  message: 'Select the target env identifier',
36
- choices: ['stg', 'prd'],
36
+ choices: ['dev', 'stg', 'prd'],
37
37
  },
38
38
  ])
39
39
  return identifier
@@ -3,12 +3,12 @@ const path = require('path')
3
3
 
4
4
  async function createPullRequestHistory(
5
5
  setReleaseHistory,
6
- prNumber,
6
+ binaryVersion,
7
7
  app,
8
8
  platform
9
9
  ) {
10
10
  try {
11
- const JSON_FILE_NAME = `${prNumber}.json`
11
+ const JSON_FILE_NAME = `${binaryVersion}.json`
12
12
  const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME)
13
13
 
14
14
  console.log(
@@ -17,7 +17,7 @@ async function createPullRequestHistory(
17
17
  )
18
18
  fs.writeFileSync(JSON_FILE_PATH, JSON.stringify({}))
19
19
 
20
- await setReleaseHistory(prNumber, JSON_FILE_PATH, {}, app, platform)
20
+ await setReleaseHistory(binaryVersion, JSON_FILE_PATH, {}, app, platform)
21
21
 
22
22
  fs.unlinkSync(JSON_FILE_PATH)
23
23
  } catch (error) {
@@ -8,7 +8,6 @@ program
8
8
  .description('Creates a new pull request history.')
9
9
  .option('-a, --app <string>', 'target app (user/device)')
10
10
  .option('-p, --platform <string>', 'target platform (ios/android)')
11
- .option('-r, --pr-number <number>', 'pull request number')
12
11
  .option(
13
12
  '-c, --config <path>',
14
13
  'set config file name (JS/TS)',
@@ -22,7 +21,7 @@ program
22
21
 
23
22
  await createPullRequestHistory(
24
23
  setReleaseHistory,
25
- options.prNumber,
24
+ options.binaryVersion,
26
25
  options.app,
27
26
  options.platform
28
27
  )
@@ -13,12 +13,17 @@ async function addToPullRequestRelease(
13
13
  setReleaseHistory,
14
14
  getReleaseHistory
15
15
  ) {
16
- const releaseHistory = await getReleaseHistory(app, prNumber, platform)
17
- const latestReleaseHistoryNumber = Object.keys(releaseHistory).at(-1)
16
+ const releaseHistory = await getReleaseHistory(app, binaryVersion, platform)
18
17
 
19
- const newReleaseHistoryNumber = latestReleaseHistoryNumber
20
- ? `${Number(latestReleaseHistoryNumber[0]) + 1}.0.0`
21
- : '1.0.0'
18
+ const latestReleaseHistoryKeys = Object.keys(releaseHistory)
19
+ const releaseHistoryWithPRNumber = latestReleaseHistoryKeys.filter((key) =>
20
+ key.includes(prNumber)
21
+ )
22
+
23
+ const newReleaseHistoryNumber = getNewReleaseHistoryNumber(
24
+ releaseHistoryWithPRNumber,
25
+ prNumber
26
+ )
22
27
  const newReleaseHistory = structuredClone(releaseHistory)
23
28
 
24
29
  newReleaseHistory[newReleaseHistoryNumber] = {
@@ -30,7 +35,7 @@ async function addToPullRequestRelease(
30
35
  }
31
36
 
32
37
  try {
33
- const JSON_FILE_NAME = `${prNumber}.json`
38
+ const JSON_FILE_NAME = `${binaryVersion}.json`
34
39
  const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME)
35
40
 
36
41
  console.log(
@@ -40,12 +45,13 @@ async function addToPullRequestRelease(
40
45
  fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(newReleaseHistory))
41
46
 
42
47
  await setReleaseHistory(
43
- prNumber,
48
+ binaryVersion,
44
49
  JSON_FILE_PATH,
45
50
  newReleaseHistory,
46
51
  app,
47
52
  platform
48
53
  )
54
+ process.stdout.write(packageHash)
49
55
  } catch (error) {
50
56
  console.error('Error occurred while updating history:', error)
51
57
  process.exit(1)
@@ -55,3 +61,13 @@ async function addToPullRequestRelease(
55
61
  module.exports = {
56
62
  addToPullRequestRelease,
57
63
  }
64
+
65
+ function getNewReleaseHistoryNumber(releaseHistoryWithPRNumber, prNumber) {
66
+ if (releaseHistoryWithPRNumber.length) {
67
+ const [, latestVersion] = releaseHistoryWithPRNumber.at(-1).split('-')
68
+ const newVersion = `${prNumber}-${Number(latestVersion[0]) + 1}.0.0`
69
+ return newVersion
70
+ } else {
71
+ return `${prNumber}-1.0.0`
72
+ }
73
+ }
@@ -22,7 +22,7 @@ program
22
22
  )
23
23
  .option('-a, --app <string>', 'target app (user/device)')
24
24
  .option('-p, --platform <string>', 'target platform (ios/android)')
25
- .option('-i, --identifier <string>', 'target env identifier (stg/prd)')
25
+ .option('-i, --identifier <string>', 'target env identifier (dev/stg/prd)')
26
26
  .option('-b, --binary-version <string>', 'target binary version (x.y.z)')
27
27
  .option('-v, --app-version <string>', 'target codepush version (x.y.z)')
28
28
  .option(
@@ -67,8 +67,11 @@ program
67
67
  throw new Error('Device app is not supported on iOS')
68
68
  }
69
69
 
70
- if (options.identifier && !['stg', 'prd'].includes(options.identifier)) {
71
- throw new Error('Identifier must be either "stg" or "prd"')
70
+ if (
71
+ options.identifier &&
72
+ !['dev', 'stg', 'prd'].includes(options.identifier)
73
+ ) {
74
+ throw new Error('Identifier must be either "dev" or "stg" or "prd"')
72
75
  }
73
76
 
74
77
  const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
package/cli/index.js CHANGED
@@ -55,9 +55,4 @@ require('./commands/createPullRequestReleaseCommand')
55
55
  */
56
56
  require('./commands/removePullRequestHistoryCommand')
57
57
 
58
- /**
59
- * npx code-push get-development-key
60
- */
61
- require('./commands/getDevelopmentKeyCommand')
62
-
63
58
  program.parse()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algocare/react-native-code-push",
3
- "version": "10.3.2",
3
+ "version": "11.0.1",
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",