@algocare/react-native-code-push 12.2.0 → 12.4.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.
@@ -31,7 +31,7 @@ program
31
31
  type: 'list',
32
32
  name: 'app',
33
33
  message: 'Select the target app',
34
- choices: ['user', 'device'],
34
+ choices: ['user', 'device', 'b2c-device', 'home-device'],
35
35
  },
36
36
  {
37
37
  type: 'list',
@@ -8,7 +8,7 @@ async function getAppValue() {
8
8
  type: 'list',
9
9
  name: 'app',
10
10
  message: 'Select the target app',
11
- choices: ['user', 'device'],
11
+ choices: ['user', 'device', 'b2c-device', 'home-device'],
12
12
  },
13
13
  ])
14
14
  return app
@@ -21,10 +21,10 @@ async function getPlatformValue(app) {
21
21
  name: 'platform',
22
22
  message: 'Select the target platform',
23
23
  choices: ['ios', 'android'],
24
- when: () => app !== 'device',
24
+ when: () => app === 'user',
25
25
  },
26
26
  ])
27
- return app === 'device' ? 'android' : platformAnswer.platform
27
+ return app === 'user' ? platformAnswer.platform : 'android'
28
28
  }
29
29
 
30
30
  async function getIdentifierValue() {
@@ -13,7 +13,7 @@ const {
13
13
  program
14
14
  .command('create-history')
15
15
  .description('Creates a new release history for the binary app.')
16
- .option('-a, --app <string>', 'target app (user/device)')
16
+ .option('-a, --app <string>', 'target app (user/device/b2c-device/home-device)')
17
17
  .option('-p, --platform <string>', 'target platform (ios/android)')
18
18
  .option('-i, --identifier <string>', 'target env identifier (dev/stg/prd)')
19
19
  .option('-b, --binary-version <string>', 'target binary version (x.y.z)')
@@ -23,15 +23,18 @@ program
23
23
  COMPILED_CONFIG_FILE_NAME
24
24
  )
25
25
  .action(async (options) => {
26
- if (options.app && !['user', 'device'].includes(options.app)) {
27
- throw new Error('App must be either "user" or "device"')
26
+ if (
27
+ options.app &&
28
+ !['user', 'device', 'b2c-device', 'home-device'].includes(options.app)
29
+ ) {
30
+ throw new Error('App must be either "user" or "device" or "b2c-device" or "home-device"')
28
31
  }
29
32
 
30
33
  if (options.platform && !['ios', 'android'].includes(options.platform)) {
31
34
  throw new Error('Platform must be either "ios" or "android"')
32
35
  }
33
36
 
34
- if (options.app === 'device' && options.platform === 'ios') {
37
+ if (options.app !== 'user' && options.platform === 'ios') {
35
38
  throw new Error('Device app is not supported on iOS')
36
39
  }
37
40
 
@@ -54,7 +57,7 @@ program
54
57
 
55
58
  const platform =
56
59
  options.platform ||
57
- (app === 'device' && 'android') ||
60
+ (app !== 'user' && 'android') ||
58
61
  (await getPlatformValue(app))
59
62
 
60
63
  const identifier = options.identifier || (await getIdentifierValue())
@@ -6,7 +6,7 @@ const { createPullRequestHistory } = require('./createPullRequestHistory')
6
6
  program
7
7
  .command('create-pr-history')
8
8
  .description('Creates a new pull request history.')
9
- .option('-a, --app <string>', 'target app (user/device)')
9
+ .option('-a, --app <string>', 'target app (user/device/b2c-device/home-device)')
10
10
  .option('-p, --platform <string>', 'target platform (ios/android)')
11
11
  .option('-b, --binary-version <string>', 'target binary version (x.y.z)')
12
12
  .option(
@@ -1,5 +1,6 @@
1
1
  const path = require('path')
2
2
  const fs = require('fs')
3
+ const { getTimestamp } = require('../../utils/datetime')
3
4
 
4
5
  async function addToPullRequestRelease(
5
6
  app,
@@ -32,6 +33,7 @@ async function addToPullRequestRelease(
32
33
  mandatory,
33
34
  downloadUrl: bundleDownloadUrl,
34
35
  packageHash,
36
+ createdAt: getTimestamp(),
35
37
  }
36
38
 
37
39
  try {
@@ -11,7 +11,7 @@ const { createPullRequestRelease } = require('./createPullRequestRelease')
11
11
  program
12
12
  .command('create-pr-release')
13
13
  .description('Creates a new pull request release.')
14
- .option('-a, --app <string>', 'target app (user/device)')
14
+ .option('-a, --app <string>', 'target app (user/device/b2c-device/home-device)')
15
15
  .option('-p, --platform <string>', 'target platform (ios/android)')
16
16
  .option('-b, --binary-version <string>', 'target binary version (x.y.z)')
17
17
  .option('-r, --pr-number <number>', 'pull request number')
@@ -1,5 +1,6 @@
1
1
  const path = require('path')
2
2
  const fs = require('fs')
3
+ const { getTimestamp } = require('../../utils/datetime')
3
4
 
4
5
  /**
5
6
  * @param app {"user" | "device"}
@@ -52,6 +53,8 @@ async function addToReleaseHistory(
52
53
  mandatory: mandatory,
53
54
  downloadUrl: bundleDownloadUrl,
54
55
  packageHash: packageHash,
56
+ createdAt: getTimestamp(),
57
+ updatedAt: '-',
55
58
  }
56
59
 
57
60
  try {
@@ -20,7 +20,7 @@ program
20
20
  .description(
21
21
  '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.'
22
22
  )
23
- .option('-a, --app <string>', 'target app (user/device)')
23
+ .option('-a, --app <string>', 'target app (user/device/b2c-device/home-device)')
24
24
  .option('-p, --platform <string>', 'target platform (ios/android)')
25
25
  .option('-i, --identifier <string>', 'target env identifier (dev/stg/prd)')
26
26
  .option('-b, --binary-version <string>', 'target binary version (x.y.z)')
@@ -55,15 +55,18 @@ program
55
55
  OUTPUT_BUNDLE_DIR
56
56
  )
57
57
  .action(async (options) => {
58
- if (options.app && !['user', 'device'].includes(options.app)) {
59
- throw new Error('App must be either "user" or "device"')
58
+ if (
59
+ options.app &&
60
+ !['user', 'device', 'b2c-device', 'home-device'].includes(options.app)
61
+ ) {
62
+ throw new Error('App must be either "user" or "device" or "b2c-device" or "home-device"')
60
63
  }
61
64
 
62
65
  if (options.platform && !['ios', 'android'].includes(options.platform)) {
63
66
  throw new Error('Platform must be either "ios" or "android"')
64
67
  }
65
68
 
66
- if (options.app === 'device' && options.platform === 'ios') {
69
+ if (options.app !== 'user' && options.platform === 'ios') {
67
70
  throw new Error('Device app is not supported on iOS')
68
71
  }
69
72
 
@@ -94,7 +97,7 @@ program
94
97
 
95
98
  const platform =
96
99
  options.platform ||
97
- (app === 'device' && 'android') ||
100
+ (app !== 'user' && 'android') ||
98
101
  (await getPlatformValue(app))
99
102
 
100
103
  const identifier = options.identifier || (await getIdentifierValue())
@@ -6,7 +6,7 @@ const { removePullRequestHistory } = require('./removePullRequestHistory')
6
6
  program
7
7
  .command('remove-pr-history')
8
8
  .description('Removes a pull request history.')
9
- .option('-a, --app <string>', 'target app (user/device)')
9
+ .option('-a, --app <string>', 'target app (user/device/b2c-device/home-device)')
10
10
  .option('-p, --platform <string>', 'target platform (ios/android)')
11
11
  .option('-r, --pr-number <number>', 'pull request number')
12
12
  .option(
@@ -13,7 +13,7 @@ program
13
13
  .description(
14
14
  'Retrieves and prints the release history of a specific binary version.\n`getReleaseHistory` function should be implemented in the config file.'
15
15
  )
16
- .option('-a, --app <string>', 'target app (user/device)')
16
+ .option('-a, --app <string>', 'target app (user/device/b2c-device/home-device)')
17
17
  .option('-p, --platform <string>', 'target platform (ios/android)')
18
18
  .option('-i, --identifier <string>', 'target env identifier (dev/stg/prd)')
19
19
  .option('-b, --binary-version <string>', 'target binary version (x.y.z)')
@@ -23,15 +23,18 @@ program
23
23
  COMPILED_CONFIG_FILE_NAME
24
24
  )
25
25
  .action(async (options) => {
26
- if (options.app && !['user', 'device'].includes(options.app)) {
27
- throw new Error('App must be either "user" or "device"')
26
+ if (
27
+ options.app &&
28
+ !['user', 'device', 'b2c-device', 'home-device'].includes(options.app)
29
+ ) {
30
+ throw new Error('App must be either "user" or "device" or "b2c-device" or "home-device"')
28
31
  }
29
32
 
30
33
  if (options.platform && !['ios', 'android'].includes(options.platform)) {
31
34
  throw new Error('Platform must be either "ios" or "android"')
32
35
  }
33
36
 
34
- if (options.app === 'device' && options.platform === 'ios') {
37
+ if (options.app !== 'user' && options.platform === 'ios') {
35
38
  throw new Error('Device app is not supported on iOS')
36
39
  }
37
40
 
@@ -54,7 +57,7 @@ program
54
57
 
55
58
  const platform =
56
59
  options.platform ||
57
- (app === 'device' && 'android') ||
60
+ (app !== 'user' && 'android') ||
58
61
  (await getPlatformValue(app))
59
62
 
60
63
  const identifier = options.identifier || (await getIdentifierValue())
@@ -15,7 +15,7 @@ program
15
15
  .description(
16
16
  'Updates the release history for a specific binary version.\n`getReleaseHistory`, `setReleaseHistory` functions should be implemented in the config file.'
17
17
  )
18
- .option('-a, --app <string>', 'target app (user/device)')
18
+ .option('-a, --app <string>', 'target app (user/device/b2c-device/home-device)')
19
19
  .option('-p, --platform <string>', 'target platform (ios/android)')
20
20
  .option('-i, --identifier <string>', 'target env identifier (dev/stg/prd)')
21
21
  .option('-b, --binary-version <string>', 'target binary version (x.y.z)')
@@ -33,15 +33,18 @@ program
33
33
  )
34
34
  .option('--no-enable', 'make the release to be disabled')
35
35
  .action(async (options) => {
36
- if (options.app && !['user', 'device'].includes(options.app)) {
37
- throw new Error('App must be either "user" or "device"')
36
+ if (
37
+ options.app &&
38
+ !['user', 'device', 'b2c-device', 'home-device'].includes(options.app)
39
+ ) {
40
+ throw new Error('App must be either "user" or "device" or "b2c-device" or "home-device"')
38
41
  }
39
42
 
40
43
  if (options.platform && !['ios', 'android'].includes(options.platform)) {
41
44
  throw new Error('Platform must be either "ios" or "android"')
42
45
  }
43
46
 
44
- if (options.app === 'device' && options.platform === 'ios') {
47
+ if (options.app !== 'user' && options.platform === 'ios') {
45
48
  throw new Error('Device app is not supported on iOS')
46
49
  }
47
50
 
@@ -68,7 +71,7 @@ program
68
71
 
69
72
  const platform =
70
73
  options.platform ||
71
- (app === 'device' && 'android') ||
74
+ (app !== 'user' && 'android') ||
72
75
  (await getPlatformValue(app))
73
76
 
74
77
  const identifier = options.identifier || (await getIdentifierValue())
@@ -1,6 +1,6 @@
1
1
  const fs = require('fs')
2
2
  const path = require('path')
3
-
3
+ const { getTimestamp } = require('../../utils/datetime')
4
4
  /**
5
5
  * @param app {"user" | "device"}
6
6
  * @param appVersion {string}
@@ -39,6 +39,7 @@ async function updateReleaseHistory(
39
39
 
40
40
  if (typeof mandatory === 'boolean') updateInfo.mandatory = mandatory
41
41
  if (typeof enable === 'boolean') updateInfo.enabled = enable
42
+ updateInfo.updatedAt = getTimestamp()
42
43
 
43
44
  try {
44
45
  const JSON_FILE_NAME = `${binaryVersion}.json`
@@ -0,0 +1,22 @@
1
+ const getTimestamp = () => {
2
+ const date = new Date()
3
+ const year = date.getFullYear()
4
+ const month = padWithZero(date.getMonth() + 1)
5
+ const day = padWithZero(date.getDate())
6
+ const hour = padWithZero(date.getHours())
7
+ const minute = padWithZero(date.getMinutes())
8
+ const second = padWithZero(date.getSeconds())
9
+
10
+ return `${year}-${month}-${day} ${hour}:${minute}:${second}`
11
+ }
12
+
13
+ const padWithZero = (value) => {
14
+ if (value < 10) {
15
+ return `0${value}`
16
+ }
17
+ return value
18
+ }
19
+
20
+ module.exports = {
21
+ getTimestamp,
22
+ }
@@ -31,7 +31,7 @@ function getCDNUrl(identifier: 'stg' | 'prd') {
31
31
  }
32
32
 
33
33
  function historyJsonFileRemotePath(
34
- app: 'user' | 'device',
34
+ app: 'user' | 'device' | 'b2c-device' | 'home-device',
35
35
  platform: 'ios' | 'android',
36
36
  binaryVersion: string
37
37
  ) {
@@ -39,7 +39,7 @@ function historyJsonFileRemotePath(
39
39
  }
40
40
 
41
41
  function bundleFileRemotePath(
42
- app: 'user' | 'device',
42
+ app: 'user' | 'device' | 'b2c-device' | 'home-device',
43
43
  platform: 'ios' | 'android',
44
44
  fileName: string
45
45
  ) {
@@ -49,7 +49,7 @@ function bundleFileRemotePath(
49
49
  const Config: CliConfigInterface = {
50
50
  bundleUploader: async (
51
51
  source: string,
52
- app: 'user' | 'device',
52
+ app: 'user' | 'device' | 'b2c-device' | 'home-device',
53
53
  platform: 'ios' | 'android',
54
54
  identifier: 'stg' | 'prd'
55
55
  ): Promise<{ downloadUrl: string }> => {
@@ -81,7 +81,7 @@ const Config: CliConfigInterface = {
81
81
  },
82
82
 
83
83
  getReleaseHistory: async (
84
- app: 'user' | 'device',
84
+ app: 'user' | 'device' | 'b2c-device' | 'home-device',
85
85
  targetBinaryVersion: string,
86
86
  platform: 'ios' | 'android',
87
87
  identifier: 'stg' | 'prd'
@@ -101,7 +101,7 @@ const Config: CliConfigInterface = {
101
101
  targetBinaryVersion: string,
102
102
  jsonFilePath: string,
103
103
  releaseInfo: ReleaseHistoryInterface,
104
- app: 'user' | 'device',
104
+ app: 'user' | 'device' | 'b2c-device' | 'home-device',
105
105
  platform: 'ios' | 'android',
106
106
  identifier: 'stg' | 'prd'
107
107
  ): Promise<void> => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algocare/react-native-code-push",
3
- "version": "12.2.0",
3
+ "version": "12.4.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",