@capgo/cli 4.11.6 → 4.12.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.
- package/CHANGELOG.md +16 -0
- package/dist/index.js +975 -31421
- package/package.json +1 -1
- package/src/bundle/upload.ts +287 -280
- package/src/index.ts +1 -0
- package/src/types/supabase.types.ts +5 -0
- package/src/utils.ts +38 -0
package/src/index.ts
CHANGED
|
@@ -131,6 +131,7 @@ bundle
|
|
|
131
131
|
)
|
|
132
132
|
.option('--auto-min-update-version', 'Set the min update version based on native packages')
|
|
133
133
|
.option('--ignore-metadata-check', 'Ignores the metadata (node_modules) check when uploading')
|
|
134
|
+
.option('--ignore-checksum-check', 'Ignores the checksum check when uploading')
|
|
134
135
|
.option('--timeout <timeout>', 'Timeout for the upload process in seconds')
|
|
135
136
|
.option('--multipart', 'Uses multipart protocol to upload data to S3')
|
|
136
137
|
|
|
@@ -1053,6 +1053,7 @@ export interface Database {
|
|
|
1053
1053
|
}
|
|
1054
1054
|
users: {
|
|
1055
1055
|
Row: {
|
|
1056
|
+
ban_time: string | null
|
|
1056
1057
|
billing_email: string | null
|
|
1057
1058
|
country: string | null
|
|
1058
1059
|
created_at: string | null
|
|
@@ -1068,6 +1069,7 @@ export interface Database {
|
|
|
1068
1069
|
updated_at: string | null
|
|
1069
1070
|
}
|
|
1070
1071
|
Insert: {
|
|
1072
|
+
ban_time?: string | null
|
|
1071
1073
|
billing_email?: string | null
|
|
1072
1074
|
country?: string | null
|
|
1073
1075
|
created_at?: string | null
|
|
@@ -1083,6 +1085,7 @@ export interface Database {
|
|
|
1083
1085
|
updated_at?: string | null
|
|
1084
1086
|
}
|
|
1085
1087
|
Update: {
|
|
1088
|
+
ban_time?: string | null
|
|
1086
1089
|
billing_email?: string | null
|
|
1087
1090
|
country?: string | null
|
|
1088
1091
|
created_at?: string | null
|
|
@@ -1985,6 +1988,8 @@ export interface Database {
|
|
|
1985
1988
|
| 'cannotGetBundle'
|
|
1986
1989
|
| 'checksum_fail'
|
|
1987
1990
|
| 'NoChannelOrOverride'
|
|
1991
|
+
| 'setChannel'
|
|
1992
|
+
| 'getChannel'
|
|
1988
1993
|
stripe_status:
|
|
1989
1994
|
| 'created'
|
|
1990
1995
|
| 'succeeded'
|
package/src/utils.ts
CHANGED
|
@@ -917,6 +917,31 @@ export async function getLocalDepenencies() {
|
|
|
917
917
|
return dependenciesObject as { name: string, version: string, native: boolean }[]
|
|
918
918
|
}
|
|
919
919
|
|
|
920
|
+
export async function getRemoteChecksums(supabase: SupabaseClient<Database>, appId: string, channel: string) {
|
|
921
|
+
const { data, error } = await supabase
|
|
922
|
+
.from('channels')
|
|
923
|
+
.select(`version (
|
|
924
|
+
checksum
|
|
925
|
+
)`)
|
|
926
|
+
.eq('name', channel)
|
|
927
|
+
.eq('app_id', appId)
|
|
928
|
+
.single()
|
|
929
|
+
|
|
930
|
+
if (error
|
|
931
|
+
|| data === null
|
|
932
|
+
|| !data.version
|
|
933
|
+
|| !data.version.checksum
|
|
934
|
+
) {
|
|
935
|
+
p.log.error(`Cannot get remote checksum for channel ${channel}`)
|
|
936
|
+
p.log.error(`Error: ${error?.message}`)
|
|
937
|
+
|
|
938
|
+
program.error('')
|
|
939
|
+
return null
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
return data.version.checksum
|
|
943
|
+
}
|
|
944
|
+
|
|
920
945
|
export async function getRemoteDepenencies(supabase: SupabaseClient<Database>, appId: string, channel: string) {
|
|
921
946
|
const { data: remoteNativePackages, error } = await supabase
|
|
922
947
|
.from('channels')
|
|
@@ -972,6 +997,19 @@ export async function getRemoteDepenencies(supabase: SupabaseClient<Database>, a
|
|
|
972
997
|
return mappedRemoteNativePackages
|
|
973
998
|
}
|
|
974
999
|
|
|
1000
|
+
export async function checkChecksum(supabase: SupabaseClient<Database>, appId: string, channel: string, currentChecksum: string) {
|
|
1001
|
+
const s = p.spinner()
|
|
1002
|
+
s.start(`Checking bundle checksum compatibility with channel ${channel}`)
|
|
1003
|
+
const remoteChecksum = await getRemoteChecksums(supabase, appId, channel)
|
|
1004
|
+
|
|
1005
|
+
if (remoteChecksum === currentChecksum) {
|
|
1006
|
+
// cannot upload the same bundle
|
|
1007
|
+
p.log.error(`Cannot upload the same bundle content.\nCurrent bundle checksum matches remote bundle for channel ${channel}\nDid you builded your app before uploading ?`)
|
|
1008
|
+
program.error('')
|
|
1009
|
+
}
|
|
1010
|
+
s.stop(`Checksum compatible with ${channel} channel`)
|
|
1011
|
+
}
|
|
1012
|
+
|
|
975
1013
|
export async function checkCompatibility(supabase: SupabaseClient<Database>, appId: string, channel: string) {
|
|
976
1014
|
const dependenciesObject = await getLocalDepenencies()
|
|
977
1015
|
const mappedRemoteNativePackages = await getRemoteDepenencies(supabase, appId, channel)
|