@capgo/cli 4.6.2 → 4.7.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/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.7.0](https://github.com/Cap-go/CLI/compare/v4.6.3...v4.7.0) (2024-05-10)
6
+
7
+
8
+ ### Features
9
+
10
+ * add upload time + correct PM name ([af61757](https://github.com/Cap-go/CLI/commit/af6175751d92070088d4569b892a333a3e1a1063))
11
+
12
+ ### [4.6.3](https://github.com/Cap-go/CLI/compare/v4.6.2...v4.6.3) (2024-05-10)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * add timeout option ([e8c8890](https://github.com/Cap-go/CLI/commit/e8c8890204bc327443a58b303c5fe8ae132dab2d))
18
+
5
19
  ### [4.6.2](https://github.com/Cap-go/CLI/compare/v4.6.1...v4.6.2) (2024-05-08)
6
20
 
7
21
 
package/bun.lockb CHANGED
Binary file
package/dist/index.js CHANGED
@@ -92373,7 +92373,7 @@ var {
92373
92373
  // package.json
92374
92374
  var package_default = {
92375
92375
  name: "@capgo/cli",
92376
- version: "4.6.2",
92376
+ version: "4.7.0",
92377
92377
  description: "A CLI to upload to capgo servers",
92378
92378
  author: "github.com/riderx",
92379
92379
  license: "Apache 2.0",
@@ -92418,7 +92418,7 @@ var package_default = {
92418
92418
  dependencies: {
92419
92419
  "@aws-sdk/client-s3": "^3.563.0",
92420
92420
  "@capacitor/cli": "6.0.0",
92421
- "@capgo/find-package-manager": "0.0.11",
92421
+ "@capgo/find-package-manager": "^0.0.13",
92422
92422
  "@clack/prompts": "^0.7.0",
92423
92423
  "@supabase/supabase-js": "^2.42.7",
92424
92424
  "@tomasklaen/checksum": "^1.1.0",
@@ -93536,6 +93536,44 @@ var distribution_default = ky;
93536
93536
 
93537
93537
  // src/utils.ts
93538
93538
  var import_node_dir = __toESM(require_node_dir());
93539
+
93540
+ // node_modules/@capgo/find-package-manager/main.js
93541
+ var import_fs = require("fs");
93542
+ var findPackageManagerType = (path3 = ".", defaultPackageManager = "unknown") => {
93543
+ const bunPath = `${path3}/bun.lockb`;
93544
+ const pnpmPath = `${path3}/pnpm-lock.yaml`;
93545
+ const yarnPath = `${path3}/yarn.lock`;
93546
+ const npmPath = `${path3}/package-lock.json`;
93547
+ if ((0, import_fs.existsSync)(bunPath)) {
93548
+ return "bun";
93549
+ }
93550
+ if ((0, import_fs.existsSync)(pnpmPath)) {
93551
+ return "pnpm";
93552
+ }
93553
+ if ((0, import_fs.existsSync)(yarnPath)) {
93554
+ return "yarn";
93555
+ }
93556
+ if ((0, import_fs.existsSync)(npmPath)) {
93557
+ return "npm";
93558
+ }
93559
+ return defaultPm;
93560
+ };
93561
+ var findInstallCommand = (packageManagerType = findPackageManagerType()) => {
93562
+ switch (packageManagerType) {
93563
+ case "bun":
93564
+ return "install";
93565
+ case "pnpm":
93566
+ return "install";
93567
+ case "yarn":
93568
+ return "add";
93569
+ case "npm":
93570
+ return "install";
93571
+ default:
93572
+ return "install";
93573
+ }
93574
+ };
93575
+
93576
+ // src/utils.ts
93539
93577
  var baseKey = ".capgo_key";
93540
93578
  var baseKeyPub = `${baseKey}.pub`;
93541
93579
  var defaultHost = "https://capgo.app";
@@ -93973,7 +94011,9 @@ async function getLocalDepenencies() {
93973
94011
  }
93974
94012
  }
93975
94013
  if (!(0, import_node_fs4.existsSync)("./node_modules/")) {
93976
- f2.error("Missing node_modules folder, please run npm install");
94014
+ const pm = findPackageManagerType(".", "npm");
94015
+ const installCmd = findInstallCommand(pm);
94016
+ f2.error(`Missing node_modules folder, please run ${pm} ${installCmd}`);
93977
94017
  program.error("");
93978
94018
  }
93979
94019
  let anyInvalid = false;
@@ -93981,7 +94021,9 @@ async function getLocalDepenencies() {
93981
94021
  const dependencyFolderExists = (0, import_node_fs4.existsSync)(`./node_modules/${key2}`);
93982
94022
  if (!dependencyFolderExists) {
93983
94023
  anyInvalid = true;
93984
- f2.error(`Missing dependency ${key2}, please run npm install`);
94024
+ const pm = findPackageManagerType(".", "npm");
94025
+ const installCmd = findInstallCommand(pm);
94026
+ f2.error(`Missing dependency ${key2}, please run ${pm} ${installCmd}`);
93985
94027
  return { name: key2, version: value };
93986
94028
  }
93987
94029
  let hasNativeFiles = false;
@@ -94213,30 +94255,6 @@ The app size is ${mbSize} Mb, this may take a while to download for users
94213
94255
  var import_node_fs11 = require("node:fs");
94214
94256
  var import_node_child_process6 = require("node:child_process");
94215
94257
  var import_node_process16 = __toESM(require("node:process"));
94216
-
94217
- // node_modules/@capgo/find-package-manager/main.js
94218
- var import_fs = require("fs");
94219
- var findPackageManagerType = (path3 = ".") => {
94220
- const bunPath = `${path3}/bun.lockb`;
94221
- const pnpmPath = `${path3}/pnpm-lock.yaml`;
94222
- const yarnPath = `${path3}/yarn.lock`;
94223
- const npmPath = `${path3}/package-lock.json`;
94224
- if ((0, import_fs.existsSync)(bunPath)) {
94225
- return "bun";
94226
- }
94227
- if ((0, import_fs.existsSync)(pnpmPath)) {
94228
- return "pnpm";
94229
- }
94230
- if ((0, import_fs.existsSync)(yarnPath)) {
94231
- return "yarn";
94232
- }
94233
- if ((0, import_fs.existsSync)(npmPath)) {
94234
- return "npm";
94235
- }
94236
- return "unknown";
94237
- };
94238
-
94239
- // src/init.ts
94240
94258
  var import_semver = __toESM(require_semver4());
94241
94259
 
94242
94260
  // src/app/debug.ts
@@ -94752,11 +94770,13 @@ async function addChannelCommand(apikey, appId, options) {
94752
94770
  var import_node_crypto3 = require("node:crypto");
94753
94771
  var import_node_fs8 = require("node:fs");
94754
94772
  var import_node_process13 = __toESM(require("node:process"));
94773
+ var import_node_perf_hooks = require("node:perf_hooks");
94755
94774
  var import_adm_zip2 = __toESM(require_adm_zip());
94756
94775
  var import_checksum2 = __toESM(require_dist());
94757
94776
  var import_ci_info = __toESM(require_ci_info());
94758
94777
  var import_client_s3 = __toESM(require_dist_cjs71());
94759
94778
  var alertMb2 = 20;
94779
+ var UPLOAD_TIMEOUT = 12e4;
94760
94780
  async function uploadBundle(appid, options, shouldExit = true) {
94761
94781
  oe(`Uploading`);
94762
94782
  await checkLatest();
@@ -95015,9 +95035,10 @@ The app size is ${mbSize} Mb, this may take a while to download for users
95015
95035
  f2.error(`Cannot get upload url`);
95016
95036
  program.error("");
95017
95037
  }
95038
+ const startTime = import_node_perf_hooks.performance.now();
95018
95039
  try {
95019
95040
  await distribution_default.put(url, {
95020
- timeout: 2e4,
95041
+ timeout: options.timeout || UPLOAD_TIMEOUT,
95021
95042
  retry: 5,
95022
95043
  body: zipped,
95023
95044
  headers: !localS3 ? {
@@ -95027,6 +95048,9 @@ The app size is ${mbSize} Mb, this may take a while to download for users
95027
95048
  } : void 0
95028
95049
  });
95029
95050
  } catch (errorUpload) {
95051
+ const endTime2 = import_node_perf_hooks.performance.now();
95052
+ const uploadTime2 = ((endTime2 - startTime) / 1e3).toFixed(2);
95053
+ spinner.stop(`Failed to upload bundle ( after ${uploadTime2} seconds)`);
95030
95054
  f2.error(`Cannot upload bundle ${formatError(errorUpload)}`);
95031
95055
  await deletedFailedVersion(supabase, appid, bundle2);
95032
95056
  program.error("");
@@ -95037,7 +95061,9 @@ The app size is ${mbSize} Mb, this may take a while to download for users
95037
95061
  f2.error(`Cannot update bundle ${formatError(dbError2)}`);
95038
95062
  program.error("");
95039
95063
  }
95040
- spinner.stop("Bundle Uploaded \u{1F4AA}");
95064
+ const endTime = import_node_perf_hooks.performance.now();
95065
+ const uploadTime = ((endTime - startTime) / 1e3).toFixed(2);
95066
+ spinner.stop(`Bundle Uploaded \u{1F4AA} (${uploadTime} seconds)`);
95041
95067
  } else if (useS3 && zipped && s3Client) {
95042
95068
  const spinner = de();
95043
95069
  spinner.start(`Uploading Bundle`);
@@ -95048,6 +95074,7 @@ The app size is ${mbSize} Mb, this may take a while to download for users
95048
95074
  Key: fileName,
95049
95075
  Body: zipped
95050
95076
  });
95077
+ const startTime = import_node_perf_hooks.performance.now();
95051
95078
  const response = await s3Client.send(command);
95052
95079
  if (response.$metadata.httpStatusCode !== 200) {
95053
95080
  f2.error(`Cannot upload to S3`);
@@ -95060,7 +95087,9 @@ The app size is ${mbSize} Mb, this may take a while to download for users
95060
95087
  f2.error(`Cannot update bundle ${formatError(dbError2)}`);
95061
95088
  program.error("");
95062
95089
  }
95063
- spinner.stop("Bundle Uploaded \u{1F4AA}");
95090
+ const endTime = import_node_perf_hooks.performance.now();
95091
+ const uploadTime = ((endTime - startTime) / 1e3).toFixed(2);
95092
+ spinner.stop(`Bundle Uploaded \u{1F4AA} (${uploadTime} seconds)`);
95064
95093
  }
95065
95094
  const { data: versionId } = await supabase.rpc("get_app_versions", { apikey: options.apikey, name_version: bundle2, appid }).single();
95066
95095
  if (versionId && hasOrganizationPerm(permissions, 3 /* write */)) {
@@ -95505,7 +95534,7 @@ async function step4(userId, snag, apikey, appId) {
95505
95534
  $e(`Bye \u{1F44B}`);
95506
95535
  import_node_process16.default.exit();
95507
95536
  }
95508
- const installCmd = pm === "yarn" ? "add" : "install";
95537
+ const installCmd = findInstallCommand(pm);
95509
95538
  if (pack.dependencies["@capgo/capacitor-updater"]) {
95510
95539
  s.stop(`Capgo already installed \u2705`);
95511
95540
  } else {
@@ -96566,7 +96595,7 @@ var bundle = program.command("bundle").description("Manage bundle");
96566
96595
  bundle.command("upload [appId]").alias("u").description("Upload a new bundle in Capgo Cloud").action(uploadCommand).option("-a, --apikey <apikey>", "apikey to link to your account").option("-p, --path <path>", "path of the folder to upload").option("-c, --channel <channel>", "channel to link to").option("-e, --external <url>", "link to external url intead of upload to Capgo Cloud").option("--iv-session-key <key>", "Set the iv and session key for bundle url external").option("--s3-region <region>", "Region for your AWS S3 bucket").option("--s3-apikey <apikey>", "apikey for your AWS S3 account").option("--s3-apisecret <apisecret>", "api secret for your AWS S3 account").option("--s3-bucket-name <bucketName>", "Name for your AWS S3 bucket").option("--key <key>", "custom path for public signing key").option("--key-data <keyData>", "base64 public signing key").option("--bundle-url", "prints bundle url into stdout").option("--no-key", "ignore signing key and send clear update").option("--no-code-check", "Ignore checking if notifyAppReady() is called in soure code and index present in root folder").option("--display-iv-session", "Show in the console the iv and session key used to encrypt the update").option("-b, --bundle <bundle>", "bundle version number of the bundle to upload").option(
96567
96596
  "--min-update-version <minUpdateVersion>",
96568
96597
  "Minimal version required to update to this version. Used only if the disable auto update is set to metadata in channel"
96569
- ).option("--auto-min-update-version", "Set the min update version based on native packages").option("--ignore-metadata-check", "Ignores the metadata (node_modules) check when uploading");
96598
+ ).option("--auto-min-update-version", "Set the min update version based on native packages").option("--ignore-metadata-check", "Ignores the metadata (node_modules) check when uploading").option("--timeout <timeout>", "Timeout for the upload process in seconds");
96570
96599
  bundle.command("compatibility [appId]").action(checkCompatibilityCommand).option("-a, --apikey <apikey>", "apikey to link to your account").option("-c, --channel <channel>", "channel to check the compatibility with").option("--text", "output text instead of emojis");
96571
96600
  bundle.command("delete [bundleId] [appId]").alias("d").description("Delete a bundle in Capgo Cloud").action(deleteBundle).option("-a, --apikey <apikey>", "apikey to link to your account");
96572
96601
  bundle.command("list [appId]").alias("l").description("List bundle in Capgo Cloud").action(listBundle).option("-a, --apikey <apikey>", "apikey to link to your account");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
- "version": "4.6.2",
3
+ "version": "4.7.0",
4
4
  "description": "A CLI to upload to capgo servers",
5
5
  "author": "github.com/riderx",
6
6
  "license": "Apache 2.0",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@aws-sdk/client-s3": "^3.563.0",
47
47
  "@capacitor/cli": "6.0.0",
48
- "@capgo/find-package-manager": "0.0.11",
48
+ "@capgo/find-package-manager": "^0.0.13",
49
49
  "@clack/prompts": "^0.7.0",
50
50
  "@supabase/supabase-js": "^2.42.7",
51
51
  "@tomasklaen/checksum": "^1.1.0",
@@ -2,6 +2,7 @@ import { randomUUID } from 'node:crypto'
2
2
  import { existsSync, readFileSync } from 'node:fs'
3
3
  import process from 'node:process'
4
4
  import type { Buffer } from 'node:buffer'
5
+ import { performance } from 'node:perf_hooks'
5
6
  import AdmZip from 'adm-zip'
6
7
  import { program } from 'commander'
7
8
  import * as p from '@clack/prompts'
@@ -63,8 +64,11 @@ interface Options extends OptionsBase {
63
64
  minUpdateVersion?: string
64
65
  autoMinUpdateVersion?: boolean
65
66
  ignoreMetadataCheck?: boolean
67
+ timeout?: number
66
68
  }
67
69
 
70
+ const UPLOAD_TIMEOUT = 120000
71
+
68
72
  export async function uploadBundle(appid: string, options: Options, shouldExit = true) {
69
73
  p.intro(`Uploading`)
70
74
  await checkLatest()
@@ -383,9 +387,10 @@ It will be also visible in your dashboard\n`)
383
387
  p.log.error(`Cannot get upload url`)
384
388
  program.error('')
385
389
  }
390
+ const startTime = performance.now()
386
391
  try {
387
392
  await ky.put(url, {
388
- timeout: 20000,
393
+ timeout: options.timeout || UPLOAD_TIMEOUT,
389
394
  retry: 5,
390
395
  body: zipped,
391
396
  headers: (!localS3
@@ -398,6 +403,9 @@ It will be also visible in your dashboard\n`)
398
403
  })
399
404
  }
400
405
  catch (errorUpload) {
406
+ const endTime = performance.now()
407
+ const uploadTime = ((endTime - startTime) / 1000).toFixed(2)
408
+ spinner.stop(`Failed to upload bundle ( after ${uploadTime} seconds)`)
401
409
  p.log.error(`Cannot upload bundle ${formatError(errorUpload)}`)
402
410
  // call delete version on path /delete_failed_version to delete the version
403
411
  await deletedFailedVersion(supabase, appid, bundle)
@@ -409,7 +417,9 @@ It will be also visible in your dashboard\n`)
409
417
  p.log.error(`Cannot update bundle ${formatError(dbError2)}`)
410
418
  program.error('')
411
419
  }
412
- spinner.stop('Bundle Uploaded 💪')
420
+ const endTime = performance.now()
421
+ const uploadTime = ((endTime - startTime) / 1000).toFixed(2)
422
+ spinner.stop(`Bundle Uploaded 💪 (${uploadTime} seconds)`)
413
423
  }
414
424
  else if (useS3 && zipped && s3Client) {
415
425
  const spinner = p.spinner()
@@ -422,7 +432,7 @@ It will be also visible in your dashboard\n`)
422
432
  Key: fileName,
423
433
  Body: zipped,
424
434
  })
425
-
435
+ const startTime = performance.now()
426
436
  const response = await s3Client.send(command)
427
437
  if (response.$metadata.httpStatusCode !== 200) {
428
438
  p.log.error(`Cannot upload to S3`)
@@ -436,7 +446,9 @@ It will be also visible in your dashboard\n`)
436
446
  p.log.error(`Cannot update bundle ${formatError(dbError2)}`)
437
447
  program.error('')
438
448
  }
439
- spinner.stop('Bundle Uploaded 💪')
449
+ const endTime = performance.now()
450
+ const uploadTime = ((endTime - startTime) / 1000).toFixed(2)
451
+ spinner.stop(`Bundle Uploaded 💪 (${uploadTime} seconds)`)
440
452
  }
441
453
  const { data: versionId } = await supabase
442
454
  .rpc('get_app_versions', { apikey: options.apikey, name_version: bundle, appid })
package/src/index.ts CHANGED
@@ -130,6 +130,7 @@ bundle
130
130
  )
131
131
  .option('--auto-min-update-version', 'Set the min update version based on native packages')
132
132
  .option('--ignore-metadata-check', 'Ignores the metadata (node_modules) check when uploading')
133
+ .option('--timeout <timeout>', 'Timeout for the upload process in seconds')
133
134
 
134
135
  bundle
135
136
  .command('compatibility [appId]')
package/src/init.ts CHANGED
@@ -2,7 +2,7 @@ import { readFileSync, writeFileSync } from 'node:fs'
2
2
  import type { ExecSyncOptions } from 'node:child_process'
3
3
  import { execSync, spawnSync } from 'node:child_process'
4
4
  import process from 'node:process'
5
- import { findPackageManagerType } from '@capgo/find-package-manager'
5
+ import { findInstallCommand, findPackageManagerType } from '@capgo/find-package-manager'
6
6
  import * as p from '@clack/prompts'
7
7
  import type { SupabaseClient } from '@supabase/supabase-js'
8
8
  import type LogSnag from 'logsnag'
@@ -116,7 +116,7 @@ async function step4(userId: string, snag: LogSnag, apikey: string, appId: strin
116
116
  }
117
117
  // // use pm to install capgo
118
118
  // // run command pm install @capgo/capacitor-updater@latest
119
- const installCmd = pm === 'yarn' ? 'add' : 'install'
119
+ const installCmd = findInstallCommand(pm)
120
120
  // check if capgo is already installed in package.json
121
121
  if (pack.dependencies['@capgo/capacitor-updater']) {
122
122
  s.stop(`Capgo already installed ✅`)
package/src/utils.ts CHANGED
@@ -11,6 +11,7 @@ import { LogSnag } from 'logsnag'
11
11
  import * as p from '@clack/prompts'
12
12
  import ky from 'ky'
13
13
  import { promiseFiles } from 'node-dir'
14
+ import { findInstallCommand, findPackageManagerType } from '@capgo/find-package-manager'
14
15
  import type { Database } from './types/supabase.types'
15
16
 
16
17
  export const baseKey = '.capgo_key'
@@ -654,7 +655,9 @@ export async function getLocalDepenencies() {
654
655
  }
655
656
 
656
657
  if (!existsSync('./node_modules/')) {
657
- p.log.error('Missing node_modules folder, please run npm install')
658
+ const pm = findPackageManagerType('.', 'npm')
659
+ const installCmd = findInstallCommand(pm)
660
+ p.log.error(`Missing node_modules folder, please run ${pm} ${installCmd}`)
658
661
  program.error('')
659
662
  }
660
663
 
@@ -667,7 +670,9 @@ export async function getLocalDepenencies() {
667
670
 
668
671
  if (!dependencyFolderExists) {
669
672
  anyInvalid = true
670
- p.log.error(`Missing dependency ${key}, please run npm install`)
673
+ const pm = findPackageManagerType('.', 'npm')
674
+ const installCmd = findInstallCommand(pm)
675
+ p.log.error(`Missing dependency ${key}, please run ${pm} ${installCmd}`)
671
676
  return { name: key, version: value }
672
677
  }
673
678