@algocare/react-native-code-push 9.0.0-beta.4 → 9.0.0-beta.6

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.
@@ -0,0 +1,109 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
3
+
4
+ const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3')
5
+ const fs = require('fs')
6
+ const axios = require('axios')
7
+ require('dotenv').config()
8
+
9
+ const s3Client = new S3Client({
10
+ region: process.env.AWS_REGION,
11
+ credentials: {
12
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
13
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
14
+ },
15
+ })
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`
19
+
20
+ function historyJsonFileRemotePath(app, platform, identifier, binaryVersion) {
21
+ return `histories/${app}/${platform}/${identifier}/${binaryVersion}.json`
22
+ }
23
+
24
+ function bundleFileRemotePath(app, platform, identifier, fileName) {
25
+ return `bundles/${app}/${platform}/${identifier}/${fileName}`
26
+ }
27
+
28
+ const Config = {
29
+ bundleUploader: async (source, app, platform, identifier = 'staging') => {
30
+ const fileName = source.split('/').pop()
31
+ const fileContent = fs.readFileSync(source)
32
+ const remotePath = bundleFileRemotePath(app, platform, identifier, fileName)
33
+
34
+ try {
35
+ await s3Client.send(
36
+ new PutObjectCommand({
37
+ Bucket: BUCKET_NAME,
38
+ Key: remotePath,
39
+ Body: fileContent,
40
+ ContentType: 'application/zip',
41
+ })
42
+ )
43
+
44
+ console.log('Bundle File uploaded:', `${CDN_URL}/${remotePath}`)
45
+
46
+ return {
47
+ downloadUrl: `${CDN_URL}/${remotePath}`,
48
+ }
49
+ } catch (error) {
50
+ console.error('Error uploading bundle:', error)
51
+ throw error
52
+ }
53
+ },
54
+
55
+ getReleaseHistory: async (
56
+ app,
57
+ targetBinaryVersion,
58
+ platform,
59
+ identifier = 'staging'
60
+ ) => {
61
+ const remoteJsonPath = historyJsonFileRemotePath(
62
+ app,
63
+ platform,
64
+ identifier,
65
+ targetBinaryVersion
66
+ )
67
+ const { data } = await axios.get(`${CDN_URL}/${remoteJsonPath}`)
68
+ return data
69
+ },
70
+
71
+ setReleaseHistory: async (
72
+ targetBinaryVersion,
73
+ jsonFilePath,
74
+ releaseInfo,
75
+ app,
76
+ platform,
77
+ identifier = 'staging'
78
+ ) => {
79
+ const fileContent = fs.readFileSync(jsonFilePath, 'utf8')
80
+ const remoteJsonPath = historyJsonFileRemotePath(
81
+ app,
82
+ platform,
83
+ identifier,
84
+ targetBinaryVersion
85
+ )
86
+
87
+ try {
88
+ await s3Client.send(
89
+ new PutObjectCommand({
90
+ Bucket: BUCKET_NAME,
91
+ Key: remoteJsonPath,
92
+ Body: fileContent,
93
+ ContentType: 'application/json',
94
+ CacheControl: 'max-age=5',
95
+ })
96
+ )
97
+
98
+ console.log(
99
+ 'Release history File uploaded:',
100
+ `${CDN_URL}/${remoteJsonPath}`
101
+ )
102
+ } catch (error) {
103
+ console.error('Error uploading release history:', error)
104
+ throw error
105
+ }
106
+ },
107
+ }
108
+
109
+ module.exports = Config
@@ -7,7 +7,7 @@ import {
7
7
  } from '@algocare/react-native-code-push'
8
8
  import * as fs from 'fs'
9
9
  import axios from 'axios'
10
- import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3' // AWS SDK v3
10
+ import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'
11
11
 
12
12
  const s3Client = new S3Client({
13
13
  region: process.env.AWS_REGION,
@@ -21,30 +21,38 @@ const BUCKET_NAME = process.env.AWS_S3_BUCKET || 'codepush-bucket'
21
21
  const CDN_URL = process.env.CDN_URL || `https://${BUCKET_NAME}.s3.amazonaws.com`
22
22
 
23
23
  function historyJsonFileRemotePath(
24
+ app: 'user' | 'device',
24
25
  platform: 'ios' | 'android',
25
26
  identifier: string,
26
27
  binaryVersion: string
27
28
  ) {
28
- return `histories/${platform}/${identifier}/${binaryVersion}.json`
29
+ return `histories/${app}/${platform}/${identifier}/${binaryVersion}.json`
29
30
  }
30
31
 
31
32
  function bundleFileRemotePath(
33
+ app: 'user' | 'device',
32
34
  platform: 'ios' | 'android',
33
35
  identifier: string,
34
36
  fileName: string
35
37
  ) {
36
- return `bundles/${platform}/${identifier}/${fileName}`
38
+ return `bundles/${app}/${platform}/${identifier}/${fileName}`
37
39
  }
38
40
 
39
41
  const Config: CliConfigInterface = {
40
42
  bundleUploader: async (
41
43
  source: string,
44
+ app: 'user' | 'device',
42
45
  platform: 'ios' | 'android',
43
46
  identifier = 'staging'
44
47
  ): Promise<{ downloadUrl: string }> => {
45
48
  const fileName = source.split('/').pop()
46
49
  const fileContent = fs.readFileSync(source)
47
- const remotePath = bundleFileRemotePath(platform, identifier, fileName!)
50
+ const remotePath = bundleFileRemotePath(
51
+ app,
52
+ platform,
53
+ identifier,
54
+ fileName!
55
+ )
48
56
 
49
57
  try {
50
58
  await s3Client.send(
@@ -68,11 +76,13 @@ const Config: CliConfigInterface = {
68
76
  },
69
77
 
70
78
  getReleaseHistory: async (
79
+ app: 'user' | 'device',
71
80
  targetBinaryVersion: string,
72
81
  platform: 'ios' | 'android',
73
82
  identifier = 'staging'
74
83
  ): Promise<ReleaseHistoryInterface> => {
75
84
  const remoteJsonPath = historyJsonFileRemotePath(
85
+ app,
76
86
  platform,
77
87
  identifier,
78
88
  targetBinaryVersion
@@ -85,11 +95,13 @@ const Config: CliConfigInterface = {
85
95
  targetBinaryVersion: string,
86
96
  jsonFilePath: string,
87
97
  releaseInfo: ReleaseHistoryInterface,
98
+ app: 'user' | 'device',
88
99
  platform: 'ios' | 'android',
89
100
  identifier = 'staging'
90
101
  ): Promise<void> => {
91
102
  const fileContent = fs.readFileSync(jsonFilePath, 'utf8')
92
103
  const remoteJsonPath = historyJsonFileRemotePath(
104
+ app,
93
105
  platform,
94
106
  identifier,
95
107
  targetBinaryVersion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algocare/react-native-code-push",
3
- "version": "9.0.0-beta.4",
3
+ "version": "9.0.0-beta.6",
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",
@@ -45,6 +45,7 @@
45
45
  "axios": "^1.7.9",
46
46
  "commander": "^12.1.0",
47
47
  "hoist-non-react-statics": "^3.3.2",
48
+ "inquirer": "^12.4.2",
48
49
  "semver": "^7.3.5",
49
50
  "shelljs": "^0.8.5",
50
51
  "yazl": "^3.3.1"
@@ -56,7 +57,7 @@
56
57
  "@types/assert": "^1.5.2",
57
58
  "@types/mkdirp": "^1.0.1",
58
59
  "@types/mocha": "^9.0.0",
59
- "@types/node": "^14.0.27",
60
+ "@types/node": "^18.0.0",
60
61
  "@types/q": "^1.5.4",
61
62
  "@types/semver": "^7.5.8",
62
63
  "@types/shelljs": "^0.8.15",
package/tsconfig.json CHANGED
@@ -1,14 +1,20 @@
1
1
  {
2
+ "compilerOptions": {
3
+ "target": "ES5",
4
+ "module": "CommonJS",
5
+ "lib": ["es6"],
6
+ "noImplicitAny": true,
7
+ "noEmitOnError": true,
8
+ "moduleResolution": "node",
9
+ "sourceMap": true,
10
+ "rootDir": "test",
11
+ "outDir": "bin",
12
+ "removeComments": true,
13
+ "esModuleInterop": true
14
+ },
15
+ "ts-node": {
2
16
  "compilerOptions": {
3
- "target": "ES5",
4
- "module": "commonjs",
5
- "lib": ["es6"],
6
- "noImplicitAny": true,
7
- "noEmitOnError": true,
8
- "moduleResolution": "node",
9
- "sourceMap": true,
10
- "rootDir": "test",
11
- "outDir": "bin",
12
- "removeComments": true
17
+ "module": "commonjs"
13
18
  }
19
+ }
14
20
  }