@capgo/cli 4.2.2 → 4.2.4
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 +14 -8
- package/package.json +1 -1
- package/src/app/add.ts +3 -2
- package/src/bundle/unlink.ts +1 -1
- package/src/bundle/upload.ts +7 -3
- package/src/channel/set.ts +1 -1
- package/src/utils.ts +3 -2
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.2.4](https://github.com/Cap-go/CLI/compare/v4.2.3...v4.2.4) (2024-03-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* make no-key works ([11eed1a](https://github.com/Cap-go/CLI/commit/11eed1a515d44800ef369303dd14c5218b2164ca))
|
|
11
|
+
|
|
12
|
+
### [4.2.3](https://github.com/Cap-go/CLI/compare/v4.2.2...v4.2.3) (2024-03-12)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* issue check plan ([ed64d10](https://github.com/Cap-go/CLI/commit/ed64d107612cfc58548dca80bf1915e90b98ec33))
|
|
18
|
+
|
|
5
19
|
### [4.2.2](https://github.com/Cap-go/CLI/compare/v4.2.1...v4.2.2) (2024-03-11)
|
|
6
20
|
|
|
7
21
|
### [4.2.1](https://github.com/Cap-go/CLI/compare/v4.2.0...v4.2.1) (2024-03-08)
|
package/dist/index.js
CHANGED
|
@@ -61137,7 +61137,7 @@ var {
|
|
|
61137
61137
|
// package.json
|
|
61138
61138
|
var package_default = {
|
|
61139
61139
|
name: "@capgo/cli",
|
|
61140
|
-
version: "4.2.
|
|
61140
|
+
version: "4.2.4",
|
|
61141
61141
|
description: "A CLI to upload to capgo servers",
|
|
61142
61142
|
main: "dist/index.js",
|
|
61143
61143
|
bin: {
|
|
@@ -62393,6 +62393,10 @@ async function isTrial(supabase, userId) {
|
|
|
62393
62393
|
const { data } = await supabase.rpc("is_trial", { userid: userId }).single();
|
|
62394
62394
|
return data || 0;
|
|
62395
62395
|
}
|
|
62396
|
+
async function isAllowedAction(supabase, userId) {
|
|
62397
|
+
const { data } = await supabase.rpc("is_allowed_action_user", { userid: userId }).single();
|
|
62398
|
+
return !!data;
|
|
62399
|
+
}
|
|
62396
62400
|
async function isAllowedActionAppIdApiKey(supabase, appId, apikey) {
|
|
62397
62401
|
const { data } = await supabase.rpc("is_allowed_action", { apikey, appid: appId }).single();
|
|
62398
62402
|
return !!data;
|
|
@@ -62494,9 +62498,9 @@ async function isAllowedAppOrg(supabase, apikey, appId) {
|
|
|
62494
62498
|
error: functionError
|
|
62495
62499
|
};
|
|
62496
62500
|
}
|
|
62497
|
-
async function checkPlanValid(supabase, userId,
|
|
62501
|
+
async function checkPlanValid(supabase, userId, apikey, appId, warning = true) {
|
|
62498
62502
|
const config = await getRemoteConfig();
|
|
62499
|
-
const validPlan = await isAllowedActionAppIdApiKey(supabase, appId, apikey);
|
|
62503
|
+
const validPlan = await (appId ? isAllowedActionAppIdApiKey(supabase, appId, apikey) : isAllowedAction(supabase, userId));
|
|
62500
62504
|
if (!validPlan) {
|
|
62501
62505
|
f2.error(`You need to upgrade your plan to continue to use capgo.
|
|
62502
62506
|
Upgrade here: ${config.hostWeb}/dashboard/settings/plans
|
|
@@ -63459,7 +63463,7 @@ async function uploadBundle(appid, options, shouldExit = true) {
|
|
|
63459
63463
|
oe(`Uploading`);
|
|
63460
63464
|
await checkLatest();
|
|
63461
63465
|
let { bundle: bundle2, path: path3, channel: channel2 } = options;
|
|
63462
|
-
const { external, key: key2
|
|
63466
|
+
const { external, key: key2, displayIvSession, autoMinUpdateVersion, ignoreMetadataCheck } = options;
|
|
63463
63467
|
let { minUpdateVersion } = options;
|
|
63464
63468
|
options.apikey = options.apikey || findSavedKey();
|
|
63465
63469
|
const snag = useLogSnag();
|
|
@@ -63504,7 +63508,7 @@ async function uploadBundle(appid, options, shouldExit = true) {
|
|
|
63504
63508
|
const supabase = await createSupabaseClient(options.apikey);
|
|
63505
63509
|
const userId = await verifyUser(supabase, options.apikey, ["write", "all", "upload"]);
|
|
63506
63510
|
const permissions = await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appid, 2 /* upload */);
|
|
63507
|
-
await checkPlanValid(supabase, userId,
|
|
63511
|
+
await checkPlanValid(supabase, userId, options.apikey, appid, true);
|
|
63508
63512
|
const updateMetadataRequired = await requireUpdateMetadata(supabase, channel2);
|
|
63509
63513
|
const { data: channelData, error: channelError } = await supabase.from("channels").select("version ( minUpdateVersion, native_packages )").eq("name", channel2).eq("app_id", appid).single();
|
|
63510
63514
|
let localDependencies = void 0;
|
|
@@ -63582,7 +63586,9 @@ Trial expires in ${isTrial2} days`);
|
|
|
63582
63586
|
s.start(`Calculating checksum`);
|
|
63583
63587
|
checksum = await (0, import_checksum2.checksum)(zipped, "crc32");
|
|
63584
63588
|
s.stop(`Checksum: ${checksum}`);
|
|
63585
|
-
if (key2
|
|
63589
|
+
if (key2 === false) {
|
|
63590
|
+
f2.info(`Encryption ignored`);
|
|
63591
|
+
} else if (key2 || (0, import_node_fs8.existsSync)(baseKeyPub)) {
|
|
63586
63592
|
const publicKey = typeof key2 === "string" ? key2 : baseKeyPub;
|
|
63587
63593
|
let keyData = options.keyData || "";
|
|
63588
63594
|
if (!keyData && !(0, import_node_fs8.existsSync)(publicKey)) {
|
|
@@ -63942,6 +63948,7 @@ async function addApp(appId, options, throwErr = true) {
|
|
|
63942
63948
|
}
|
|
63943
63949
|
const supabase = await createSupabaseClient(options.apikey);
|
|
63944
63950
|
const userId = await verifyUser(supabase, options.apikey, ["write", "all"]);
|
|
63951
|
+
await checkPlanValid(supabase, userId, options.apikey, void 0, false);
|
|
63945
63952
|
const appExist = await checkAppExists(supabase, appId);
|
|
63946
63953
|
if (throwErr && appExist) {
|
|
63947
63954
|
f2.error(`App ${appId} already exist`);
|
|
@@ -63961,7 +63968,6 @@ async function addApp(appId, options, throwErr = true) {
|
|
|
63961
63968
|
f2.info(`Adding ${appId} to Capgo`);
|
|
63962
63969
|
let iconBuff;
|
|
63963
63970
|
let iconType;
|
|
63964
|
-
await checkPlanValid(supabase, userId, appId, options.apikey, false);
|
|
63965
63971
|
if (icon && (0, import_node_fs10.existsSync)(icon)) {
|
|
63966
63972
|
iconBuff = (0, import_node_fs10.readFileSync)(icon);
|
|
63967
63973
|
const contentType = src_default.getType(icon);
|
|
@@ -64621,7 +64627,7 @@ async function setChannel(channel2, appId, options) {
|
|
|
64621
64627
|
program.error("");
|
|
64622
64628
|
}
|
|
64623
64629
|
try {
|
|
64624
|
-
await checkPlanValid(supabase, userId,
|
|
64630
|
+
await checkPlanValid(supabase, userId, options.apikey, appId);
|
|
64625
64631
|
const channelPayload = {
|
|
64626
64632
|
created_by: userId,
|
|
64627
64633
|
app_id: appId,
|
package/package.json
CHANGED
package/src/app/add.ts
CHANGED
|
@@ -38,6 +38,9 @@ export async function addApp(appId: string, options: Options, throwErr = true) {
|
|
|
38
38
|
const supabase = await createSupabaseClient(options.apikey)
|
|
39
39
|
|
|
40
40
|
const userId = await verifyUser(supabase, options.apikey, ['write', 'all'])
|
|
41
|
+
|
|
42
|
+
await checkPlanValid(supabase, userId, options.apikey, undefined, false)
|
|
43
|
+
|
|
41
44
|
// Check we have app access to this appId
|
|
42
45
|
const appExist = await checkAppExists(supabase, appId)
|
|
43
46
|
if (throwErr && appExist) {
|
|
@@ -62,8 +65,6 @@ export async function addApp(appId: string, options: Options, throwErr = true) {
|
|
|
62
65
|
let iconBuff
|
|
63
66
|
let iconType
|
|
64
67
|
|
|
65
|
-
await checkPlanValid(supabase, userId, appId, options.apikey, false)
|
|
66
|
-
|
|
67
68
|
if (icon && existsSync(icon)) {
|
|
68
69
|
iconBuff = readFileSync(icon)
|
|
69
70
|
const contentType = mime.getType(icon)
|
package/src/bundle/unlink.ts
CHANGED
|
@@ -55,7 +55,7 @@ export async function unlinkDevice(channel: string, appId: string, options: Opti
|
|
|
55
55
|
program.error('')
|
|
56
56
|
}
|
|
57
57
|
try {
|
|
58
|
-
await checkPlanValid(supabase, userId,
|
|
58
|
+
await checkPlanValid(supabase, userId, options.apikey, appId)
|
|
59
59
|
|
|
60
60
|
const versionData = await getVersionData(supabase, appId, userId, bundle)
|
|
61
61
|
await checkVersionNotUsedInChannel(supabase, appId, userId, versionData)
|
package/src/bundle/upload.ts
CHANGED
|
@@ -60,7 +60,7 @@ export async function uploadBundle(appid: string, options: Options, shouldExit =
|
|
|
60
60
|
p.intro(`Uploading`)
|
|
61
61
|
await checkLatest()
|
|
62
62
|
let { bundle, path, channel } = options
|
|
63
|
-
const { external, key
|
|
63
|
+
const { external, key, displayIvSession, autoMinUpdateVersion, ignoreMetadataCheck } = options
|
|
64
64
|
let { minUpdateVersion } = options
|
|
65
65
|
options.apikey = options.apikey || findSavedKey()
|
|
66
66
|
const snag = useLogSnag()
|
|
@@ -118,7 +118,7 @@ export async function uploadBundle(appid: string, options: Options, shouldExit =
|
|
|
118
118
|
// await checkAppExistsAndHasPermissionErr(supabase, options.apikey, appid);
|
|
119
119
|
|
|
120
120
|
const permissions = await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appid, OrganizationPerm.upload)
|
|
121
|
-
await checkPlanValid(supabase, userId,
|
|
121
|
+
await checkPlanValid(supabase, userId, options.apikey, appid, true)
|
|
122
122
|
|
|
123
123
|
const updateMetadataRequired = await requireUpdateMetadata(supabase, channel)
|
|
124
124
|
|
|
@@ -227,7 +227,11 @@ export async function uploadBundle(appid: string, options: Options, shouldExit =
|
|
|
227
227
|
s.start(`Calculating checksum`)
|
|
228
228
|
checksum = await getChecksum(zipped, 'crc32')
|
|
229
229
|
s.stop(`Checksum: ${checksum}`)
|
|
230
|
-
|
|
230
|
+
// key should be undefined or a string if false it should ingore encryption
|
|
231
|
+
if (key === false) {
|
|
232
|
+
p.log.info(`Encryption ignored`)
|
|
233
|
+
}
|
|
234
|
+
else if (key || existsSync(baseKeyPub)) {
|
|
231
235
|
const publicKey = typeof key === 'string' ? key : baseKeyPub
|
|
232
236
|
let keyData = options.keyData || ''
|
|
233
237
|
// check if publicKey exist
|
package/src/channel/set.ts
CHANGED
|
@@ -75,7 +75,7 @@ export async function setChannel(channel: string, appId: string, options: Option
|
|
|
75
75
|
program.error('')
|
|
76
76
|
}
|
|
77
77
|
try {
|
|
78
|
-
await checkPlanValid(supabase, userId,
|
|
78
|
+
await checkPlanValid(supabase, userId, options.apikey, appId)
|
|
79
79
|
const channelPayload: Database['public']['Tables']['channels']['Insert'] = {
|
|
80
80
|
created_by: userId,
|
|
81
81
|
app_id: appId,
|
package/src/utils.ts
CHANGED
|
@@ -282,9 +282,10 @@ export async function isAllowedAppOrg(supabase: SupabaseClient<Database>, apikey
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
export async function checkPlanValid(supabase: SupabaseClient<Database>, userId: string,
|
|
285
|
+
export async function checkPlanValid(supabase: SupabaseClient<Database>, userId: string, apikey: string, appId?: string, warning = true) {
|
|
286
286
|
const config = await getRemoteConfig()
|
|
287
|
-
|
|
287
|
+
|
|
288
|
+
const validPlan = await (appId ? isAllowedActionAppIdApiKey(supabase, appId, apikey) : isAllowedAction(supabase, userId))
|
|
288
289
|
if (!validPlan) {
|
|
289
290
|
p.log.error(`You need to upgrade your plan to continue to use capgo.\n Upgrade here: ${config.hostWeb}/dashboard/settings/plans\n`)
|
|
290
291
|
wait(100)
|