@capgo/cli 4.11.5 → 4.12.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.
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
 
package/src/key.ts CHANGED
@@ -105,6 +105,11 @@ export async function createKey(options: Options, log = true) {
105
105
  CapacitorUpdater: {},
106
106
  }
107
107
  }
108
+
109
+ if (!extConfig.plugins.CapacitorUpdater) {
110
+ extConfig.plugins.CapacitorUpdater = {}
111
+ }
112
+
108
113
  extConfig.plugins.CapacitorUpdater.privateKey = privateKey
109
114
  // console.log('extConfig', extConfig)
110
115
  writeConfig(extConfig, config.app.extConfigFilePath)
package/src/utils.ts CHANGED
@@ -917,6 +917,29 @@ 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 ( checksum )`)
924
+ .eq('name', channel)
925
+ .eq('app_id', appId)
926
+ .single()
927
+
928
+ if (error
929
+ || data === null
930
+ || !data.version
931
+ || !data.version.checksum
932
+ ) {
933
+ p.log.error(`Cannot get remote checksum for channel ${channel}`)
934
+ p.log.error(`Error: ${error?.message}`)
935
+
936
+ program.error('')
937
+ return null
938
+ }
939
+
940
+ return data.version.checksum
941
+ }
942
+
920
943
  export async function getRemoteDepenencies(supabase: SupabaseClient<Database>, appId: string, channel: string) {
921
944
  const { data: remoteNativePackages, error } = await supabase
922
945
  .from('channels')
@@ -972,6 +995,19 @@ export async function getRemoteDepenencies(supabase: SupabaseClient<Database>, a
972
995
  return mappedRemoteNativePackages
973
996
  }
974
997
 
998
+ export async function checkChecksum(supabase: SupabaseClient<Database>, appId: string, channel: string, currentChecksum: string) {
999
+ const s = p.spinner()
1000
+ s.start(`Checking bundle checksum compatibility with channel ${channel}`)
1001
+ const remoteChecksum = await getRemoteChecksums(supabase, appId, channel)
1002
+
1003
+ if (remoteChecksum === currentChecksum) {
1004
+ // cannot upload the same bundle
1005
+ 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 ?`)
1006
+ program.error('')
1007
+ }
1008
+ s.stop(`Checksum compatible with ${channel} channel`)
1009
+ }
1010
+
975
1011
  export async function checkCompatibility(supabase: SupabaseClient<Database>, appId: string, channel: string) {
976
1012
  const dependenciesObject = await getLocalDepenencies()
977
1013
  const mappedRemoteNativePackages = await getRemoteDepenencies(supabase, appId, channel)