@capgo/cli 4.10.15 → 4.10.17
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 +14 -0
- package/dist/index.js +13 -14
- package/package.json +1 -1
- package/src/api/versions.ts +2 -3
- package/src/bundle/cleanup.ts +5 -5
- package/src/bundle/delete.ts +2 -2
- package/src/bundle/list.ts +2 -2
- package/src/bundle/upload.ts +0 -1
- package/src/utils.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [4.10.17](https://github.com/Cap-go/CLI/compare/v4.10.16...v4.10.17) (2024-06-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* remove old userId ([b263deb](https://github.com/Cap-go/CLI/commit/b263debe9b13fd68841c3a176f660863160a3872))
|
|
11
|
+
|
|
12
|
+
### [4.10.16](https://github.com/Cap-go/CLI/compare/v4.10.15...v4.10.16) (2024-06-13)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* issue auto delete failed ([62fef1d](https://github.com/Cap-go/CLI/commit/62fef1dd5816c9c9781002d68f9566bbcace8e0f))
|
|
18
|
+
|
|
5
19
|
### [4.10.15](https://github.com/Cap-go/CLI/compare/v4.10.14...v4.10.15) (2024-06-12)
|
|
6
20
|
|
|
7
21
|
|
package/dist/index.js
CHANGED
|
@@ -110243,7 +110243,7 @@ async function deletedFailedVersion(supabase, appId, name) {
|
|
|
110243
110243
|
try {
|
|
110244
110244
|
const pathFailed = "private/delete_failed_version";
|
|
110245
110245
|
const res = await supabase.functions.invoke(pathFailed, { body: JSON.stringify(data), method: "DELETE" });
|
|
110246
|
-
return res.data.
|
|
110246
|
+
return res.data.status;
|
|
110247
110247
|
} catch (error) {
|
|
110248
110248
|
f2.error(`Cannot delete failed version ${formatError(error)}`);
|
|
110249
110249
|
return Promise.reject(new Error("Cannot delete failed version"));
|
|
@@ -110508,7 +110508,7 @@ async function getUserId(options) {
|
|
|
110508
110508
|
// package.json
|
|
110509
110509
|
var package_default = {
|
|
110510
110510
|
name: "@capgo/cli",
|
|
110511
|
-
version: "4.10.
|
|
110511
|
+
version: "4.10.17",
|
|
110512
110512
|
description: "A CLI to upload to capgo servers",
|
|
110513
110513
|
author: "github.com/riderx",
|
|
110514
110514
|
license: "Apache 2.0",
|
|
@@ -111576,7 +111576,6 @@ The app size is ${mbSize} Mb, this may take a while to download for users
|
|
|
111576
111576
|
if (errorUpload instanceof HTTPError) {
|
|
111577
111577
|
const body = await errorUpload.response.text();
|
|
111578
111578
|
f2.error(`Response: ${formatError(body)}`);
|
|
111579
|
-
program.error("");
|
|
111580
111579
|
}
|
|
111581
111580
|
await deletedFailedVersion(supabase, appid, bundle2);
|
|
111582
111581
|
program.error("");
|
|
@@ -112289,7 +112288,7 @@ async function deleteAppVersion(supabase, appid, bundle2) {
|
|
|
112289
112288
|
program.error("");
|
|
112290
112289
|
}
|
|
112291
112290
|
}
|
|
112292
|
-
async function deleteSpecificVersion(supabase, appid,
|
|
112291
|
+
async function deleteSpecificVersion(supabase, appid, bundle2) {
|
|
112293
112292
|
const versionData = await getVersionData(supabase, appid, bundle2);
|
|
112294
112293
|
await checkVersionNotUsedInChannel(supabase, appid, versionData);
|
|
112295
112294
|
await checkVersionNotUsedInDeviceOverride(supabase, appid, versionData);
|
|
@@ -112313,7 +112312,7 @@ function displayBundles(data) {
|
|
|
112313
112312
|
});
|
|
112314
112313
|
f2.success(t.render());
|
|
112315
112314
|
}
|
|
112316
|
-
async function getActiveAppVersions(supabase, appid
|
|
112315
|
+
async function getActiveAppVersions(supabase, appid) {
|
|
112317
112316
|
const { data, error: vError } = await supabase.from("app_versions").select().eq("app_id", appid).eq("deleted", false).order("created_at", { ascending: false });
|
|
112318
112317
|
if (vError) {
|
|
112319
112318
|
f2.error(`App ${appid} not found in database`);
|
|
@@ -112354,10 +112353,10 @@ async function listBundle(appId, options) {
|
|
|
112354
112353
|
program.error("");
|
|
112355
112354
|
}
|
|
112356
112355
|
const supabase = await createSupabaseClient(options.apikey);
|
|
112357
|
-
|
|
112356
|
+
await verifyUser(supabase, options.apikey, ["write", "all", "read", "upload"]);
|
|
112358
112357
|
f2.info(`Querying available versions of: ${appId} in Capgo`);
|
|
112359
112358
|
await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, 1 /* read */);
|
|
112360
|
-
const allVersions = await getActiveAppVersions(supabase, appId
|
|
112359
|
+
const allVersions = await getActiveAppVersions(supabase, appId);
|
|
112361
112360
|
f2.info(`Active versions in Capgo: ${allVersions?.length}`);
|
|
112362
112361
|
displayBundles(allVersions);
|
|
112363
112362
|
$e(`Done \u2705`);
|
|
@@ -112530,7 +112529,7 @@ async function deleteBundle(bundleId, appId, options) {
|
|
|
112530
112529
|
program.error("");
|
|
112531
112530
|
}
|
|
112532
112531
|
const supabase = await createSupabaseClient(options.apikey);
|
|
112533
|
-
|
|
112532
|
+
await verifyUser(supabase, options.apikey, ["write", "all"]);
|
|
112534
112533
|
await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, 3 /* write */);
|
|
112535
112534
|
appId = appId || config?.app?.appId;
|
|
112536
112535
|
if (!options.apikey) {
|
|
@@ -112546,7 +112545,7 @@ async function deleteBundle(bundleId, appId, options) {
|
|
|
112546
112545
|
program.error("");
|
|
112547
112546
|
}
|
|
112548
112547
|
f2.info(`Deleting bundle ${appId}@${bundleId} from Capgo`);
|
|
112549
|
-
await deleteSpecificVersion(supabase, appId,
|
|
112548
|
+
await deleteSpecificVersion(supabase, appId, bundleId);
|
|
112550
112549
|
f2.success(`Bundle ${appId}@${bundleId} deleted in Capgo`);
|
|
112551
112550
|
$e(`Done`);
|
|
112552
112551
|
import_node_process22.default.exit();
|
|
@@ -112755,10 +112754,10 @@ var import_node_process26 = __toESM(require("node:process"));
|
|
|
112755
112754
|
var import_preload = __toESM(require_preload());
|
|
112756
112755
|
var import_prompt_sync = __toESM(require_prompt_sync());
|
|
112757
112756
|
var prompt = (0, import_prompt_sync.default)();
|
|
112758
|
-
async function removeVersions(toRemove, supabase, appid
|
|
112757
|
+
async function removeVersions(toRemove, supabase, appid) {
|
|
112759
112758
|
for await (const row of toRemove) {
|
|
112760
112759
|
f2.warn(`Removing ${row.name} created on ${getHumanDate(row.created_at)}`);
|
|
112761
|
-
await deleteSpecificVersion(supabase, appid,
|
|
112760
|
+
await deleteSpecificVersion(supabase, appid, row.name);
|
|
112762
112761
|
}
|
|
112763
112762
|
}
|
|
112764
112763
|
function getRemovableVersionsInSemverRange(data, bundle2, nextMajor) {
|
|
@@ -112786,10 +112785,10 @@ async function cleanupBundle(appid, options) {
|
|
|
112786
112785
|
program.error("");
|
|
112787
112786
|
}
|
|
112788
112787
|
const supabase = await createSupabaseClient(options.apikey);
|
|
112789
|
-
|
|
112788
|
+
await verifyUser(supabase, options.apikey, ["write", "all"]);
|
|
112790
112789
|
await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appid, 3 /* write */);
|
|
112791
112790
|
f2.info(`Querying all available versions in Capgo`);
|
|
112792
|
-
let allVersions = await getActiveAppVersions(supabase, appid
|
|
112791
|
+
let allVersions = await getActiveAppVersions(supabase, appid);
|
|
112793
112792
|
const versionInUse = await getChannelsVersion(supabase, appid);
|
|
112794
112793
|
f2.info(`Total active versions in Capgo: ${allVersions?.length}`);
|
|
112795
112794
|
if (allVersions?.length === 0) {
|
|
@@ -112830,7 +112829,7 @@ async function cleanupBundle(appid, options) {
|
|
|
112830
112829
|
}
|
|
112831
112830
|
}
|
|
112832
112831
|
f2.success("You have confirmed removal, removing versions now");
|
|
112833
|
-
await removeVersions(toRemove, supabase, appid
|
|
112832
|
+
await removeVersions(toRemove, supabase, appid);
|
|
112834
112833
|
$e(`Done \u2705`);
|
|
112835
112834
|
import_node_process26.default.exit();
|
|
112836
112835
|
}
|
package/package.json
CHANGED
package/src/api/versions.ts
CHANGED
|
@@ -24,7 +24,7 @@ export async function deleteAppVersion(supabase: SupabaseClient<Database>, appid
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export async function deleteSpecificVersion(supabase: SupabaseClient<Database>, appid: string,
|
|
27
|
+
export async function deleteSpecificVersion(supabase: SupabaseClient<Database>, appid: string, bundle: string) {
|
|
28
28
|
const versionData = await getVersionData(supabase, appid, bundle)
|
|
29
29
|
await checkVersionNotUsedInChannel(supabase, appid, versionData)
|
|
30
30
|
await checkVersionNotUsedInDeviceOverride(supabase, appid, versionData)
|
|
@@ -55,12 +55,11 @@ export function displayBundles(data: (Database['public']['Tables']['app_versions
|
|
|
55
55
|
p.log.success(t.render())
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
export async function getActiveAppVersions(supabase: SupabaseClient<Database>, appid: string
|
|
58
|
+
export async function getActiveAppVersions(supabase: SupabaseClient<Database>, appid: string) {
|
|
59
59
|
const { data, error: vError } = await supabase
|
|
60
60
|
.from('app_versions')
|
|
61
61
|
.select()
|
|
62
62
|
.eq('app_id', appid)
|
|
63
|
-
// .eq('user_id', userId)
|
|
64
63
|
.eq('deleted', false)
|
|
65
64
|
.order('created_at', { ascending: false })
|
|
66
65
|
|
package/src/bundle/cleanup.ts
CHANGED
|
@@ -20,11 +20,11 @@ interface Options extends OptionsBase {
|
|
|
20
20
|
|
|
21
21
|
const prompt = promptSync()
|
|
22
22
|
|
|
23
|
-
async function removeVersions(toRemove: Database['public']['Tables']['app_versions']['Row'][], supabase: SupabaseClient<Database>, appid: string
|
|
23
|
+
async function removeVersions(toRemove: Database['public']['Tables']['app_versions']['Row'][], supabase: SupabaseClient<Database>, appid: string) {
|
|
24
24
|
// call deleteSpecificVersion one by one from toRemove sync
|
|
25
25
|
for await (const row of toRemove) {
|
|
26
26
|
p.log.warn(`Removing ${row.name} created on ${(getHumanDate(row.created_at))}`)
|
|
27
|
-
await deleteSpecificVersion(supabase, appid,
|
|
27
|
+
await deleteSpecificVersion(supabase, appid, row.name)
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -57,14 +57,14 @@ export async function cleanupBundle(appid: string, options: Options) {
|
|
|
57
57
|
}
|
|
58
58
|
const supabase = await createSupabaseClient(options.apikey)
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
await verifyUser(supabase, options.apikey, ['write', 'all'])
|
|
61
61
|
|
|
62
62
|
// Check we have app access to this appId
|
|
63
63
|
await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appid, OrganizationPerm.write)
|
|
64
64
|
p.log.info(`Querying all available versions in Capgo`)
|
|
65
65
|
|
|
66
66
|
// Get all active app versions we might possibly be able to cleanup
|
|
67
|
-
let allVersions: (Database['public']['Tables']['app_versions']['Row'] & { keep?: string })[] = await getActiveAppVersions(supabase, appid
|
|
67
|
+
let allVersions: (Database['public']['Tables']['app_versions']['Row'] & { keep?: string })[] = await getActiveAppVersions(supabase, appid)
|
|
68
68
|
|
|
69
69
|
const versionInUse = await getChannelsVersion(supabase, appid)
|
|
70
70
|
|
|
@@ -121,7 +121,7 @@ export async function cleanupBundle(appid: string, options: Options) {
|
|
|
121
121
|
|
|
122
122
|
// Yes, lets clean it up
|
|
123
123
|
p.log.success('You have confirmed removal, removing versions now')
|
|
124
|
-
await removeVersions(toRemove, supabase, appid
|
|
124
|
+
await removeVersions(toRemove, supabase, appid)
|
|
125
125
|
p.outro(`Done ✅`)
|
|
126
126
|
process.exit()
|
|
127
127
|
}
|
package/src/bundle/delete.ts
CHANGED
|
@@ -26,7 +26,7 @@ export async function deleteBundle(bundleId: string, appId: string, options: Opt
|
|
|
26
26
|
}
|
|
27
27
|
const supabase = await createSupabaseClient(options.apikey)
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
await verifyUser(supabase, options.apikey, ['write', 'all'])
|
|
30
30
|
// Check we have app access to this appId
|
|
31
31
|
await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, OrganizationPerm.write)
|
|
32
32
|
|
|
@@ -46,7 +46,7 @@ export async function deleteBundle(bundleId: string, appId: string, options: Opt
|
|
|
46
46
|
|
|
47
47
|
p.log.info(`Deleting bundle ${appId}@${bundleId} from Capgo`)
|
|
48
48
|
|
|
49
|
-
await deleteSpecificVersion(supabase, appId,
|
|
49
|
+
await deleteSpecificVersion(supabase, appId, bundleId)
|
|
50
50
|
p.log.success(`Bundle ${appId}@${bundleId} deleted in Capgo`)
|
|
51
51
|
p.outro(`Done`)
|
|
52
52
|
process.exit()
|
package/src/bundle/list.ts
CHANGED
|
@@ -25,7 +25,7 @@ export async function listBundle(appId: string, options: OptionsBase) {
|
|
|
25
25
|
|
|
26
26
|
const supabase = await createSupabaseClient(options.apikey)
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
await verifyUser(supabase, options.apikey, ['write', 'all', 'read', 'upload'])
|
|
29
29
|
|
|
30
30
|
p.log.info(`Querying available versions of: ${appId} in Capgo`)
|
|
31
31
|
|
|
@@ -33,7 +33,7 @@ export async function listBundle(appId: string, options: OptionsBase) {
|
|
|
33
33
|
await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, OrganizationPerm.read)
|
|
34
34
|
|
|
35
35
|
// Get all active app versions we might possibly be able to cleanup
|
|
36
|
-
const allVersions = await getActiveAppVersions(supabase, appId
|
|
36
|
+
const allVersions = await getActiveAppVersions(supabase, appId)
|
|
37
37
|
|
|
38
38
|
p.log.info(`Active versions in Capgo: ${allVersions?.length}`)
|
|
39
39
|
|
package/src/bundle/upload.ts
CHANGED
|
@@ -416,7 +416,6 @@ It will be also visible in your dashboard\n`)
|
|
|
416
416
|
if (errorUpload instanceof HTTPError) {
|
|
417
417
|
const body = await errorUpload.response.text()
|
|
418
418
|
p.log.error(`Response: ${formatError(body)}`)
|
|
419
|
-
program.error('')
|
|
420
419
|
}
|
|
421
420
|
// call delete version on path /delete_failed_version to delete the version
|
|
422
421
|
await deletedFailedVersion(supabase, appid, bundle)
|
package/src/utils.ts
CHANGED
|
@@ -589,7 +589,7 @@ export async function deletedFailedVersion(supabase: SupabaseClient<Database>, a
|
|
|
589
589
|
try {
|
|
590
590
|
const pathFailed = 'private/delete_failed_version'
|
|
591
591
|
const res = await supabase.functions.invoke(pathFailed, { body: JSON.stringify(data), method: 'DELETE' })
|
|
592
|
-
return res.data.
|
|
592
|
+
return res.data.status
|
|
593
593
|
}
|
|
594
594
|
catch (error) {
|
|
595
595
|
p.log.error(`Cannot delete failed version ${formatError(error)}`)
|