@algocare/react-native-code-push 12.2.0 → 12.3.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.
@@ -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'],
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)')
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'].includes(options.app)
29
+ ) {
30
+ throw new Error('App must be either "user" or "device" or "b2c-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())
@@ -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 {
@@ -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)')
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'].includes(options.app)
61
+ ) {
62
+ throw new Error('App must be either "user" or "device" or "b2c-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())
@@ -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)')
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'].includes(options.app)
29
+ ) {
30
+ throw new Error('App must be either "user" or "device" or "b2c-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)')
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'].includes(options.app)
39
+ ) {
40
+ throw new Error('App must be either "user" or "device" or "b2c-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
+ }
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.3.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",