@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.
- package/cli/commands/createHistoryCommand/createReleaseHistory.js +40 -28
- package/cli/commands/createHistoryCommand/index.js +48 -27
- package/cli/commands/releaseCommand/addToReleaseHistory.js +52 -36
- package/cli/commands/releaseCommand/index.js +112 -60
- package/cli/commands/releaseCommand/release.js +72 -53
- package/cli/commands/showHistoryCommand/index.js +49 -26
- package/cli/commands/updateHistoryCommand/index.js +83 -44
- package/cli/commands/updateHistoryCommand/updateReleaseHistory.js +42 -26
- package/cli/constant.js +7 -5
- package/cli/utils/fsUtils.js +35 -20
- package/code-push.config.example.supabase.ts +100 -100
- package/code-push.config.js +109 -0
- package/code-push.config.ts +16 -4
- package/package.json +3 -2
- package/tsconfig.json +16 -10
|
@@ -1,29 +1,52 @@
|
|
|
1
|
-
const { program, Option } = require(
|
|
2
|
-
const { findAndReadConfigFile } = require(
|
|
3
|
-
const {
|
|
1
|
+
const { program, Option } = require('commander')
|
|
2
|
+
const { findAndReadConfigFile } = require('../../utils/fsUtils')
|
|
3
|
+
const { COMPILED_CONFIG_FILE_NAME } = require('../../constant')
|
|
4
4
|
|
|
5
|
-
program
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
program
|
|
6
|
+
.command('show-history')
|
|
7
|
+
.description(
|
|
8
|
+
'Retrieves and prints the release history of a specific binary version.\n`getReleaseHistory` function should be implemented in the config file.'
|
|
9
|
+
)
|
|
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
|
+
.option(
|
|
28
|
+
'-c, --config <path>',
|
|
29
|
+
'configuration file name (JS/TS)',
|
|
30
|
+
COMPILED_CONFIG_FILE_NAME
|
|
31
|
+
)
|
|
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
|
+
.action(async (options) => {
|
|
42
|
+
const config = await findAndReadConfigFile(process.cwd(), options.config)
|
|
21
43
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
44
|
+
const releaseHistory = await config.getReleaseHistory(
|
|
45
|
+
options.app,
|
|
46
|
+
options.binaryVersion,
|
|
47
|
+
options.platform,
|
|
48
|
+
options.identifier
|
|
49
|
+
)
|
|
27
50
|
|
|
28
|
-
|
|
29
|
-
|
|
51
|
+
console.log(JSON.stringify(releaseHistory, null, 2))
|
|
52
|
+
})
|
|
@@ -1,50 +1,89 @@
|
|
|
1
|
-
const { program, Option } = require(
|
|
2
|
-
const { findAndReadConfigFile } = require(
|
|
3
|
-
const { updateReleaseHistory } = require(
|
|
4
|
-
const {
|
|
1
|
+
const { program, Option } = require('commander')
|
|
2
|
+
const { findAndReadConfigFile } = require('../../utils/fsUtils')
|
|
3
|
+
const { updateReleaseHistory } = require('./updateReleaseHistory')
|
|
4
|
+
const { COMPILED_CONFIG_FILE_NAME } = require('../../constant')
|
|
5
5
|
|
|
6
|
-
program
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
program
|
|
7
|
+
.command('update-history')
|
|
8
|
+
.description(
|
|
9
|
+
'Updates the release history for a specific binary version.\n`getReleaseHistory`, `setReleaseHistory` functions should be implemented in the config file.'
|
|
10
|
+
)
|
|
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
|
+
.option(
|
|
33
|
+
'-c, --config <path>',
|
|
34
|
+
'set config file name (JS/TS)',
|
|
35
|
+
COMPILED_CONFIG_FILE_NAME
|
|
36
|
+
)
|
|
37
|
+
.option(
|
|
38
|
+
'-m, --mandatory <bool>',
|
|
39
|
+
'make the release to be mandatory',
|
|
40
|
+
parseBoolean,
|
|
41
|
+
undefined
|
|
42
|
+
)
|
|
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
|
+
*/
|
|
61
|
+
.action(async (options) => {
|
|
62
|
+
const config = await findAndReadConfigFile(process.cwd(), options.config)
|
|
28
63
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
64
|
+
if (
|
|
65
|
+
typeof options.mandatory !== 'boolean' &&
|
|
66
|
+
typeof options.enable !== 'boolean'
|
|
67
|
+
) {
|
|
68
|
+
console.error('No options specified. Exiting the program.')
|
|
69
|
+
process.exit(1)
|
|
70
|
+
}
|
|
33
71
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
72
|
+
await updateReleaseHistory(
|
|
73
|
+
options.app,
|
|
74
|
+
options.appVersion,
|
|
75
|
+
options.binaryVersion,
|
|
76
|
+
config.getReleaseHistory,
|
|
77
|
+
config.setReleaseHistory,
|
|
78
|
+
options.platform,
|
|
79
|
+
options.identifier,
|
|
80
|
+
options.mandatory,
|
|
81
|
+
options.enable
|
|
82
|
+
)
|
|
83
|
+
})
|
|
45
84
|
|
|
46
85
|
function parseBoolean(value) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
86
|
+
if (value === 'true') return true
|
|
87
|
+
if (value === 'false') return false
|
|
88
|
+
else return undefined
|
|
50
89
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require('path')
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* @param app {"user" | "device"}
|
|
6
6
|
* @param appVersion {string}
|
|
7
7
|
* @param binaryVersion {string}
|
|
8
8
|
* @param getReleaseHistory {
|
|
@@ -26,37 +26,53 @@ const path = require('path');
|
|
|
26
26
|
* @returns {Promise<void>}
|
|
27
27
|
*/
|
|
28
28
|
async function updateReleaseHistory(
|
|
29
|
-
|
|
29
|
+
app,
|
|
30
|
+
appVersion,
|
|
31
|
+
binaryVersion,
|
|
32
|
+
getReleaseHistory,
|
|
33
|
+
setReleaseHistory,
|
|
34
|
+
platform,
|
|
35
|
+
identifier,
|
|
36
|
+
mandatory,
|
|
37
|
+
enable
|
|
38
|
+
) {
|
|
39
|
+
const releaseHistory = await getReleaseHistory(
|
|
40
|
+
app,
|
|
30
41
|
binaryVersion,
|
|
31
|
-
getReleaseHistory,
|
|
32
|
-
setReleaseHistory,
|
|
33
42
|
platform,
|
|
34
|
-
identifier
|
|
35
|
-
|
|
36
|
-
enable,
|
|
37
|
-
) {
|
|
38
|
-
const releaseHistory = await getReleaseHistory(binaryVersion, platform, identifier);
|
|
43
|
+
identifier
|
|
44
|
+
)
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
const updateInfo = releaseHistory[appVersion]
|
|
47
|
+
if (!updateInfo) throw new Error(`v${appVersion} is not released`)
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
if (typeof mandatory === 'boolean') updateInfo.mandatory = mandatory
|
|
50
|
+
if (typeof enable === 'boolean') updateInfo.enabled = enable
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
try {
|
|
53
|
+
const JSON_FILE_NAME = `${binaryVersion}.json`
|
|
54
|
+
const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME)
|
|
49
55
|
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
console.log(
|
|
57
|
+
`log: creating JSON file... ("${JSON_FILE_NAME}")\n`,
|
|
58
|
+
JSON.stringify(releaseHistory, null, 2)
|
|
59
|
+
)
|
|
60
|
+
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(releaseHistory))
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
await setReleaseHistory(
|
|
63
|
+
binaryVersion,
|
|
64
|
+
JSON_FILE_PATH,
|
|
65
|
+
releaseHistory,
|
|
66
|
+
app,
|
|
67
|
+
platform,
|
|
68
|
+
identifier
|
|
69
|
+
)
|
|
54
70
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
fs.unlinkSync(JSON_FILE_PATH)
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('Error occurred while updating history:', error)
|
|
74
|
+
process.exit(1)
|
|
75
|
+
}
|
|
60
76
|
}
|
|
61
77
|
|
|
62
78
|
module.exports = { updateReleaseHistory: updateReleaseHistory }
|
package/cli/constant.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
CONFIG_FILE_NAME:
|
|
3
|
-
OUTPUT_BUNDLE_DIR:
|
|
4
|
-
ROOT_OUTPUT_DIR:
|
|
5
|
-
ENTRY_FILE:
|
|
6
|
-
|
|
2
|
+
CONFIG_FILE_NAME: 'code-push.config.ts',
|
|
3
|
+
OUTPUT_BUNDLE_DIR: 'bundleOutput',
|
|
4
|
+
ROOT_OUTPUT_DIR: 'build',
|
|
5
|
+
ENTRY_FILE: 'index.js',
|
|
6
|
+
COMPILED_CONFIG_FILE_NAME: 'code-push.config.js',
|
|
7
|
+
PACKAGE_PATH: '/node_modules/@algocare/react-native-code-push/',
|
|
8
|
+
}
|
package/cli/utils/fsUtils.js
CHANGED
|
@@ -1,28 +1,42 @@
|
|
|
1
|
-
const fs = require(
|
|
2
|
-
const path = require(
|
|
3
|
-
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const { PACKAGE_PATH } = require('../constant')
|
|
4
4
|
/**
|
|
5
5
|
* allows to require a config file with .ts extension
|
|
6
6
|
* @param filePath {string}
|
|
7
7
|
* @returns {*} FIXME type
|
|
8
8
|
*/
|
|
9
|
-
function requireConfig(filePath) {
|
|
10
|
-
const ext = path.extname(filePath)
|
|
9
|
+
async function requireConfig(filePath) {
|
|
10
|
+
const ext = path.extname(filePath)
|
|
11
11
|
|
|
12
12
|
if (ext === '.ts') {
|
|
13
13
|
try {
|
|
14
|
-
require('ts-node
|
|
14
|
+
require('ts-node').register({
|
|
15
|
+
transpileOnly: true,
|
|
16
|
+
compilerOptions: {
|
|
17
|
+
module: 'CommonJS',
|
|
18
|
+
esModuleInterop: true,
|
|
19
|
+
allowJs: true,
|
|
20
|
+
resolveJsonModule: true,
|
|
21
|
+
experimentalDecorators: true,
|
|
22
|
+
emitDecoratorMetadata: true,
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const config = await import(filePath)
|
|
27
|
+
return config.default || config
|
|
15
28
|
} catch {
|
|
16
|
-
console.error(
|
|
17
|
-
|
|
29
|
+
console.error(
|
|
30
|
+
'ts-node not found. Please install ts-node as a devDependency.'
|
|
31
|
+
)
|
|
32
|
+
process.exit(1)
|
|
18
33
|
}
|
|
19
34
|
} else if (ext === '.js') {
|
|
20
35
|
// do nothing
|
|
21
36
|
} else {
|
|
22
|
-
throw new Error(`Unsupported file extension: ${ext}`)
|
|
37
|
+
throw new Error(`Unsupported file extension: ${ext}`)
|
|
23
38
|
}
|
|
24
|
-
|
|
25
|
-
return require(filePath);
|
|
39
|
+
return require(filePath)
|
|
26
40
|
}
|
|
27
41
|
|
|
28
42
|
/**
|
|
@@ -30,20 +44,21 @@ function requireConfig(filePath) {
|
|
|
30
44
|
* @param configFileName {string}
|
|
31
45
|
* @returns {*|null} FIXME type
|
|
32
46
|
*/
|
|
33
|
-
function findAndReadConfigFile(startDir, configFileName) {
|
|
34
|
-
let dir = startDir
|
|
47
|
+
async function findAndReadConfigFile(startDir, configFileName) {
|
|
48
|
+
let dir = `${startDir}${PACKAGE_PATH}`
|
|
35
49
|
|
|
36
50
|
while (dir !== path.parse(dir).root) {
|
|
37
|
-
const configPath = path.join(dir, configFileName)
|
|
51
|
+
const configPath = path.join(dir, configFileName)
|
|
52
|
+
|
|
38
53
|
if (fs.existsSync(configPath)) {
|
|
39
|
-
const config = requireConfig(configPath)
|
|
40
|
-
return config
|
|
54
|
+
const config = await requireConfig(configPath)
|
|
55
|
+
return config
|
|
41
56
|
}
|
|
42
|
-
dir = path.dirname(dir)
|
|
57
|
+
dir = path.dirname(dir)
|
|
43
58
|
}
|
|
44
59
|
|
|
45
|
-
console.error(`${configFileName} not found.`)
|
|
46
|
-
return null
|
|
60
|
+
console.error(`${configFileName} not found.`)
|
|
61
|
+
return null
|
|
47
62
|
}
|
|
48
63
|
|
|
49
|
-
module.exports = { findAndReadConfigFile }
|
|
64
|
+
module.exports = { findAndReadConfigFile }
|
|
@@ -2,113 +2,113 @@
|
|
|
2
2
|
// @ts-nocheck
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
8
|
-
import * as fs from
|
|
9
|
-
import axios from
|
|
10
|
-
import * as SupabaseSDK from
|
|
11
|
-
|
|
12
|
-
const SUPABASE_URL = process.env.SUPABASE_URL
|
|
13
|
-
const SUPABASE_KEY = process.env.SUPABASE_KEY
|
|
14
|
-
const supabase = SupabaseSDK.createClient(SUPABASE_URL!, SUPABASE_KEY!)
|
|
15
|
-
const BUCKET_NAME =
|
|
16
|
-
const STORAGE_HOST = `${SUPABASE_URL}/storage/v1/object/public
|
|
5
|
+
CliConfigInterface,
|
|
6
|
+
ReleaseHistoryInterface,
|
|
7
|
+
} from "@bravemobile/react-native-code-push";
|
|
8
|
+
import * as fs from "fs";
|
|
9
|
+
import axios from "axios"; // install as devDependency
|
|
10
|
+
import * as SupabaseSDK from "@supabase/supabase-js"; // install as devDependency
|
|
11
|
+
|
|
12
|
+
const SUPABASE_URL = process.env.SUPABASE_URL;
|
|
13
|
+
const SUPABASE_KEY = process.env.SUPABASE_KEY;
|
|
14
|
+
const supabase = SupabaseSDK.createClient(SUPABASE_URL!, SUPABASE_KEY!);
|
|
15
|
+
const BUCKET_NAME = "codePush";
|
|
16
|
+
const STORAGE_HOST = `${SUPABASE_URL}/storage/v1/object/public`;
|
|
17
17
|
|
|
18
18
|
function historyJsonFileRemotePath(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
platform: "ios" | "android",
|
|
20
|
+
identifier: string,
|
|
21
|
+
binaryVersion: string,
|
|
22
22
|
) {
|
|
23
|
-
|
|
23
|
+
return `histories/${platform}/${identifier}/${binaryVersion}.json`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function bundleFileRemotePath(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
platform: "ios" | "android",
|
|
28
|
+
identifier: string,
|
|
29
|
+
fileName: string,
|
|
30
30
|
) {
|
|
31
|
-
|
|
31
|
+
return `bundles/${platform}/${identifier}/${fileName}`;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const Config: CliConfigInterface = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
module.exports = Config
|
|
35
|
+
bundleUploader: async (
|
|
36
|
+
source: string,
|
|
37
|
+
platform: "ios" | "android",
|
|
38
|
+
identifier = "staging",
|
|
39
|
+
): Promise<{downloadUrl: string}> => {
|
|
40
|
+
const fileName = source.split("/").pop();
|
|
41
|
+
const fileStream = fs.createReadStream(source);
|
|
42
|
+
const remotePath = bundleFileRemotePath(platform, identifier, fileName!);
|
|
43
|
+
|
|
44
|
+
const {data, error} = await supabase.storage
|
|
45
|
+
.from(BUCKET_NAME)
|
|
46
|
+
.upload(remotePath, fileStream, {
|
|
47
|
+
contentType: "application/zip",
|
|
48
|
+
duplex: "half",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (error) {
|
|
52
|
+
console.error("Error uploading file:", error.message);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
console.log("Bundle File uploaded:", `${STORAGE_HOST}/${data.fullPath}`);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
downloadUrl: `${STORAGE_HOST}/${data.fullPath}`,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
getReleaseHistory: async (
|
|
64
|
+
targetBinaryVersion: string,
|
|
65
|
+
platform: "ios" | "android",
|
|
66
|
+
identifier = "staging",
|
|
67
|
+
): Promise<ReleaseHistoryInterface> => {
|
|
68
|
+
const remoteJsonPath = historyJsonFileRemotePath(
|
|
69
|
+
platform,
|
|
70
|
+
identifier,
|
|
71
|
+
targetBinaryVersion,
|
|
72
|
+
);
|
|
73
|
+
const {data} = await axios.get(
|
|
74
|
+
`${STORAGE_HOST}/${BUCKET_NAME}/${remoteJsonPath}`,
|
|
75
|
+
);
|
|
76
|
+
return data as ReleaseHistoryInterface;
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
setReleaseHistory: async (
|
|
80
|
+
targetBinaryVersion: string,
|
|
81
|
+
jsonFilePath: string,
|
|
82
|
+
releaseInfo: ReleaseHistoryInterface,
|
|
83
|
+
platform: "ios" | "android",
|
|
84
|
+
identifier = "staging",
|
|
85
|
+
): Promise<void> => {
|
|
86
|
+
// upload JSON file or call API using `releaseInfo` metadata.
|
|
87
|
+
|
|
88
|
+
const fileContent = fs.readFileSync(jsonFilePath, "utf8");
|
|
89
|
+
const remoteJsonPath = historyJsonFileRemotePath(
|
|
90
|
+
platform,
|
|
91
|
+
identifier,
|
|
92
|
+
targetBinaryVersion,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const {data, error} = await supabase.storage
|
|
96
|
+
.from(BUCKET_NAME)
|
|
97
|
+
.upload(remoteJsonPath, Buffer.from(fileContent), {
|
|
98
|
+
contentType: "application/json",
|
|
99
|
+
cacheControl: "5",
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (error) {
|
|
103
|
+
console.error("Error uploading file:", error.message);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.log(
|
|
108
|
+
"Release history File uploaded:",
|
|
109
|
+
`${STORAGE_HOST}/${data.fullPath}`,
|
|
110
|
+
);
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
module.exports = Config;
|