@capgo/cli 4.2.1 → 4.2.2

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 CHANGED
@@ -2,6 +2,8 @@
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.2](https://github.com/Cap-go/CLI/compare/v4.2.1...v4.2.2) (2024-03-11)
6
+
5
7
  ### [4.2.1](https://github.com/Cap-go/CLI/compare/v4.2.0...v4.2.1) (2024-03-08)
6
8
 
7
9
 
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.1",
61140
+ version: "4.2.2",
61141
61141
  description: "A CLI to upload to capgo servers",
61142
61142
  main: "dist/index.js",
61143
61143
  bin: {
@@ -62312,6 +62312,11 @@ var defaultHostWeb = "https://web.capgo.app";
62312
62312
  var regexSemver = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
62313
62313
  var formatError = (error) => error ? `
62314
62314
  ${import_prettyjson.default.render(error)}` : "";
62315
+ function wait(ms) {
62316
+ return new Promise((resolve2) => {
62317
+ setTimeout(resolve2, ms);
62318
+ });
62319
+ }
62315
62320
  async function getConfig() {
62316
62321
  let config;
62317
62322
  try {
@@ -62496,12 +62501,12 @@ async function checkPlanValid(supabase, userId, appId, apikey, warning = true) {
62496
62501
  f2.error(`You need to upgrade your plan to continue to use capgo.
62497
62502
  Upgrade here: ${config.hostWeb}/dashboard/settings/plans
62498
62503
  `);
62499
- setTimeout(() => {
62500
- Promise.resolve().then(() => (init_open(), open_exports)).then((module2) => {
62501
- module2.default(`${config.hostWeb}/dashboard/settings/plans`);
62502
- });
62503
- program.error("");
62504
- }, 1e3);
62504
+ wait(100);
62505
+ Promise.resolve().then(() => (init_open(), open_exports)).then((module2) => {
62506
+ module2.default(`${config.hostWeb}/dashboard/settings/plans`);
62507
+ });
62508
+ wait(500);
62509
+ program.error("");
62505
62510
  }
62506
62511
  const trialDays = await isTrial(supabase, userId);
62507
62512
  const ispaying = await isPaying(supabase, userId);
@@ -62979,11 +62984,6 @@ async function checkAppExistsAndHasPermissionOrgErr(supabase, apikey, appid, req
62979
62984
  var newIconPath = "assets/icon.png";
62980
62985
 
62981
62986
  // src/app/debug.ts
62982
- function wait(ms) {
62983
- return new Promise((resolve2) => {
62984
- setTimeout(resolve2, ms);
62985
- });
62986
- }
62987
62987
  async function markSnag(channel2, userId, snag, event, icon = "\u2705") {
62988
62988
  await snag.track({
62989
62989
  channel: channel2,
@@ -63504,7 +63504,7 @@ async function uploadBundle(appid, options, shouldExit = true) {
63504
63504
  const supabase = await createSupabaseClient(options.apikey);
63505
63505
  const userId = await verifyUser(supabase, options.apikey, ["write", "all", "upload"]);
63506
63506
  const permissions = await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appid, 2 /* upload */);
63507
- await checkPlanValid(supabase, userId, appid, options.apikey, false);
63507
+ await checkPlanValid(supabase, userId, appid, options.apikey, true);
63508
63508
  const updateMetadataRequired = await requireUpdateMetadata(supabase, channel2);
63509
63509
  const { data: channelData, error: channelError } = await supabase.from("channels").select("version ( minUpdateVersion, native_packages )").eq("name", channel2).eq("app_id", appid).single();
63510
63510
  let localDependencies = void 0;
@@ -63961,6 +63961,7 @@ async function addApp(appId, options, throwErr = true) {
63961
63961
  f2.info(`Adding ${appId} to Capgo`);
63962
63962
  let iconBuff;
63963
63963
  let iconType;
63964
+ await checkPlanValid(supabase, userId, appId, options.apikey, false);
63964
63965
  if (icon && (0, import_node_fs10.existsSync)(icon)) {
63965
63966
  iconBuff = (0, import_node_fs10.readFileSync)(icon);
63966
63967
  const contentType = src_default.getType(icon);
@@ -64990,7 +64991,7 @@ async function setApp(appId, options) {
64990
64991
  contentType: iconType
64991
64992
  });
64992
64993
  if (error) {
64993
- f2.error(`Could not add app ${formatError(error)}`);
64994
+ f2.error(`Could not set app ${formatError(error)}`);
64994
64995
  program.error(``);
64995
64996
  }
64996
64997
  const { data: signedURLData } = await supabase.storage.from(`images/${userId}/${appId}`).getPublicUrl(fileName);
@@ -65002,7 +65003,7 @@ async function setApp(appId, options) {
65002
65003
  retention: !retention ? void 0 : retention * 24 * 60 * 60
65003
65004
  }).eq("app_id", appId).eq("user_id", userId);
65004
65005
  if (dbError) {
65005
- f2.error(`Could not add app ${formatError(dbError)}`);
65006
+ f2.error(`Could not set app ${formatError(dbError)}`);
65006
65007
  program.error(``);
65007
65008
  }
65008
65009
  $e(`Done \u2705`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
- "version": "4.2.1",
3
+ "version": "4.2.2",
4
4
  "description": "A CLI to upload to capgo servers",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/app/add.ts CHANGED
@@ -8,6 +8,7 @@ import { checkLatest } from '../api/update'
8
8
  import type { Options } from '../api/app'
9
9
  import { checkAppExists, newIconPath } from '../api/app'
10
10
  import {
11
+ checkPlanValid,
11
12
  createSupabaseClient,
12
13
  findSavedKey,
13
14
  formatError,
@@ -61,6 +62,8 @@ export async function addApp(appId: string, options: Options, throwErr = true) {
61
62
  let iconBuff
62
63
  let iconType
63
64
 
65
+ await checkPlanValid(supabase, userId, appId, options.apikey, false)
66
+
64
67
  if (icon && existsSync(icon)) {
65
68
  iconBuff = readFileSync(icon)
66
69
  const contentType = mime.getType(icon)
package/src/app/debug.ts CHANGED
@@ -6,13 +6,7 @@ import type LogSnag from 'logsnag'
6
6
  import type { Database } from '../types/supabase.types'
7
7
  import { checkAppExistsAndHasPermissionErr } from '../api/app'
8
8
  import { checkLatest } from '../api/update'
9
- import { convertAppName, createSupabaseClient, findSavedKey, formatError, getConfig, getLocalConfig, useLogSnag, verifyUser } from '../utils'
10
-
11
- function wait(ms: number) {
12
- return new Promise((resolve) => {
13
- setTimeout(resolve, ms)
14
- })
15
- }
9
+ import { convertAppName, createSupabaseClient, findSavedKey, formatError, getConfig, getLocalConfig, useLogSnag, verifyUser, wait } from '../utils'
16
10
 
17
11
  export interface OptionsBaseDebug {
18
12
  apikey: string
package/src/app/set.ts CHANGED
@@ -66,7 +66,7 @@ export async function setApp(appId: string, options: Options) {
66
66
  contentType: iconType,
67
67
  })
68
68
  if (error) {
69
- p.log.error(`Could not add app ${formatError(error)}`)
69
+ p.log.error(`Could not set app ${formatError(error)}`)
70
70
  program.error(``)
71
71
  }
72
72
  const { data: signedURLData } = await supabase
@@ -86,7 +86,7 @@ export async function setApp(appId: string, options: Options) {
86
86
  .eq('app_id', appId)
87
87
  .eq('user_id', userId)
88
88
  if (dbError) {
89
- p.log.error(`Could not add app ${formatError(dbError)}`)
89
+ p.log.error(`Could not set app ${formatError(dbError)}`)
90
90
  program.error(``)
91
91
  }
92
92
  p.outro(`Done ✅`)
@@ -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, appid, options.apikey, false)
121
+ await checkPlanValid(supabase, userId, appid, options.apikey, true)
122
122
 
123
123
  const updateMetadataRequired = await requireUpdateMetadata(supabase, channel)
124
124
 
@@ -1280,6 +1280,13 @@ export interface Database {
1280
1280
  count: number
1281
1281
  }[]
1282
1282
  }
1283
+ count_all_plans_v2: {
1284
+ Args: Record<PropertyKey, never>
1285
+ Returns: {
1286
+ plan_name: string
1287
+ count: number
1288
+ }[]
1289
+ }
1283
1290
  count_all_trial: {
1284
1291
  Args: Record<PropertyKey, never>
1285
1292
  Returns: number
@@ -1299,13 +1306,6 @@ export interface Database {
1299
1306
  Args: Record<PropertyKey, never>
1300
1307
  Returns: undefined
1301
1308
  }
1302
- exist_app: {
1303
- Args: {
1304
- appid: string
1305
- apikey: string
1306
- }
1307
- Returns: boolean
1308
- }
1309
1309
  exist_app_v2: {
1310
1310
  Args: {
1311
1311
  appid: string
@@ -1474,16 +1474,6 @@ export interface Database {
1474
1474
  }
1475
1475
  Returns: string
1476
1476
  }
1477
- get_orgs: {
1478
- Args: {
1479
- userid: string
1480
- }
1481
- Returns: {
1482
- id: string
1483
- logo: string
1484
- name: string
1485
- }[]
1486
- }
1487
1477
  get_orgs_v2: {
1488
1478
  Args: {
1489
1479
  userid: string
@@ -1512,17 +1502,12 @@ export interface Database {
1512
1502
  is_canceled: boolean
1513
1503
  }[]
1514
1504
  }
1515
- get_plan_usage_percent:
1516
- | {
1517
- Args: Record<PropertyKey, never>
1518
- Returns: number
1519
- }
1520
- | {
1521
- Args: {
1522
- userid: string
1523
- }
1524
- Returns: number
1505
+ get_plan_usage_percent: {
1506
+ Args: {
1507
+ userid: string
1525
1508
  }
1509
+ Returns: number
1510
+ }
1526
1511
  get_total_app_storage_size:
1527
1512
  | {
1528
1513
  Args: {
@@ -1537,57 +1522,6 @@ export interface Database {
1537
1522
  }
1538
1523
  Returns: number
1539
1524
  }
1540
- get_total_stats_v2:
1541
- | {
1542
- Args: {
1543
- dateid: string
1544
- }
1545
- Returns: {
1546
- mau: number
1547
- bandwidth: number
1548
- storage: number
1549
- }[]
1550
- }
1551
- | {
1552
- Args: {
1553
- userid: string
1554
- dateid: string
1555
- }
1556
- Returns: {
1557
- mau: number
1558
- bandwidth: number
1559
- storage: number
1560
- }[]
1561
- }
1562
- get_total_stats_v3:
1563
- | {
1564
- Args: Record<PropertyKey, never>
1565
- Returns: {
1566
- mau: number
1567
- bandwidth: number
1568
- storage: number
1569
- }[]
1570
- }
1571
- | {
1572
- Args: {
1573
- userid: string
1574
- }
1575
- Returns: {
1576
- mau: number
1577
- bandwidth: number
1578
- storage: number
1579
- }[]
1580
- }
1581
- get_total_stats_v4: {
1582
- Args: {
1583
- userid: string
1584
- }
1585
- Returns: {
1586
- mau: number
1587
- bandwidth: number
1588
- storage: number
1589
- }[]
1590
- }
1591
1525
  get_total_stats_v5: {
1592
1526
  Args: {
1593
1527
  userid: string
@@ -1827,28 +1761,18 @@ export interface Database {
1827
1761
  }
1828
1762
  Returns: boolean
1829
1763
  }
1830
- is_good_plan_v3:
1831
- | {
1832
- Args: Record<PropertyKey, never>
1833
- Returns: boolean
1834
- }
1835
- | {
1836
- Args: {
1837
- userid: string
1838
- }
1839
- Returns: boolean
1840
- }
1841
- is_good_plan_v4:
1842
- | {
1843
- Args: Record<PropertyKey, never>
1844
- Returns: boolean
1764
+ is_good_plan_v3: {
1765
+ Args: {
1766
+ userid: string
1845
1767
  }
1846
- | {
1847
- Args: {
1848
- userid: string
1849
- }
1850
- Returns: boolean
1768
+ Returns: boolean
1769
+ }
1770
+ is_good_plan_v5: {
1771
+ Args: {
1772
+ userid: string
1851
1773
  }
1774
+ Returns: boolean
1775
+ }
1852
1776
  is_member_of_org: {
1853
1777
  Args: {
1854
1778
  user_id: string
@@ -1862,12 +1786,6 @@ export interface Database {
1862
1786
  }
1863
1787
  Returns: boolean
1864
1788
  }
1865
- is_not_deleted_v2: {
1866
- Args: {
1867
- email_check: string
1868
- }
1869
- Returns: boolean
1870
- }
1871
1789
  is_onboarded:
1872
1790
  | {
1873
1791
  Args: Record<PropertyKey, never>
package/src/utils.ts CHANGED
@@ -26,6 +26,12 @@ export interface OptionsBase {
26
26
  apikey: string
27
27
  }
28
28
 
29
+ export function wait(ms: number) {
30
+ return new Promise((resolve) => {
31
+ setTimeout(resolve, ms)
32
+ })
33
+ }
34
+
29
35
  export async function getConfig() {
30
36
  let config: Config
31
37
  try {
@@ -281,13 +287,13 @@ export async function checkPlanValid(supabase: SupabaseClient<Database>, userId:
281
287
  const validPlan = await isAllowedActionAppIdApiKey(supabase, appId, apikey)
282
288
  if (!validPlan) {
283
289
  p.log.error(`You need to upgrade your plan to continue to use capgo.\n Upgrade here: ${config.hostWeb}/dashboard/settings/plans\n`)
284
- setTimeout(() => {
285
- import('open')
286
- .then((module) => {
287
- module.default(`${config.hostWeb}/dashboard/settings/plans`)
288
- })
289
- program.error('')
290
- }, 1000)
290
+ wait(100)
291
+ import('open')
292
+ .then((module) => {
293
+ module.default(`${config.hostWeb}/dashboard/settings/plans`)
294
+ })
295
+ wait(500)
296
+ program.error('')
291
297
  }
292
298
  const trialDays = await isTrial(supabase, userId)
293
299
  const ispaying = await isPaying(supabase, userId)