@capgo/cli 4.6.3 → 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 +7 -0
- package/bun.lockb +0 -0
- package/dist/index.js +61 -33
- package/package.json +2 -2
- package/src/bundle/upload.ts +15 -5
- package/src/init.ts +2 -2
- package/src/utils.ts +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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
|
+
|
|
5
12
|
### [4.6.3](https://github.com/Cap-go/CLI/compare/v4.6.2...v4.6.3) (2024-05-10)
|
|
6
13
|
|
|
7
14
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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: options.timeout ||
|
|
95041
|
+
timeout: options.timeout || UPLOAD_TIMEOUT,
|
|
95021
95042
|
retry: 5,
|
|
95022
95043
|
body: zipped,
|
|
95023
95044
|
headers: !localS3 ? {
|
|
@@ -95027,7 +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) {
|
|
95030
|
-
|
|
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)`);
|
|
95031
95054
|
f2.error(`Cannot upload bundle ${formatError(errorUpload)}`);
|
|
95032
95055
|
await deletedFailedVersion(supabase, appid, bundle2);
|
|
95033
95056
|
program.error("");
|
|
@@ -95038,7 +95061,9 @@ The app size is ${mbSize} Mb, this may take a while to download for users
|
|
|
95038
95061
|
f2.error(`Cannot update bundle ${formatError(dbError2)}`);
|
|
95039
95062
|
program.error("");
|
|
95040
95063
|
}
|
|
95041
|
-
|
|
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)`);
|
|
95042
95067
|
} else if (useS3 && zipped && s3Client) {
|
|
95043
95068
|
const spinner = de();
|
|
95044
95069
|
spinner.start(`Uploading Bundle`);
|
|
@@ -95049,6 +95074,7 @@ The app size is ${mbSize} Mb, this may take a while to download for users
|
|
|
95049
95074
|
Key: fileName,
|
|
95050
95075
|
Body: zipped
|
|
95051
95076
|
});
|
|
95077
|
+
const startTime = import_node_perf_hooks.performance.now();
|
|
95052
95078
|
const response = await s3Client.send(command);
|
|
95053
95079
|
if (response.$metadata.httpStatusCode !== 200) {
|
|
95054
95080
|
f2.error(`Cannot upload to S3`);
|
|
@@ -95061,7 +95087,9 @@ The app size is ${mbSize} Mb, this may take a while to download for users
|
|
|
95061
95087
|
f2.error(`Cannot update bundle ${formatError(dbError2)}`);
|
|
95062
95088
|
program.error("");
|
|
95063
95089
|
}
|
|
95064
|
-
|
|
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)`);
|
|
95065
95093
|
}
|
|
95066
95094
|
const { data: versionId } = await supabase.rpc("get_app_versions", { apikey: options.apikey, name_version: bundle2, appid }).single();
|
|
95067
95095
|
if (versionId && hasOrganizationPerm(permissions, 3 /* write */)) {
|
|
@@ -95506,7 +95534,7 @@ async function step4(userId, snag, apikey, appId) {
|
|
|
95506
95534
|
$e(`Bye \u{1F44B}`);
|
|
95507
95535
|
import_node_process16.default.exit();
|
|
95508
95536
|
}
|
|
95509
|
-
const installCmd = pm
|
|
95537
|
+
const installCmd = findInstallCommand(pm);
|
|
95510
95538
|
if (pack.dependencies["@capgo/capacitor-updater"]) {
|
|
95511
95539
|
s.stop(`Capgo already installed \u2705`);
|
|
95512
95540
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/cli",
|
|
3
|
-
"version": "4.
|
|
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.
|
|
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",
|
package/src/bundle/upload.ts
CHANGED
|
@@ -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'
|
|
@@ -66,6 +67,8 @@ interface Options extends OptionsBase {
|
|
|
66
67
|
timeout?: number
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
const UPLOAD_TIMEOUT = 120000
|
|
71
|
+
|
|
69
72
|
export async function uploadBundle(appid: string, options: Options, shouldExit = true) {
|
|
70
73
|
p.intro(`Uploading`)
|
|
71
74
|
await checkLatest()
|
|
@@ -384,9 +387,10 @@ It will be also visible in your dashboard\n`)
|
|
|
384
387
|
p.log.error(`Cannot get upload url`)
|
|
385
388
|
program.error('')
|
|
386
389
|
}
|
|
390
|
+
const startTime = performance.now()
|
|
387
391
|
try {
|
|
388
392
|
await ky.put(url, {
|
|
389
|
-
timeout: options.timeout ||
|
|
393
|
+
timeout: options.timeout || UPLOAD_TIMEOUT,
|
|
390
394
|
retry: 5,
|
|
391
395
|
body: zipped,
|
|
392
396
|
headers: (!localS3
|
|
@@ -399,7 +403,9 @@ It will be also visible in your dashboard\n`)
|
|
|
399
403
|
})
|
|
400
404
|
}
|
|
401
405
|
catch (errorUpload) {
|
|
402
|
-
|
|
406
|
+
const endTime = performance.now()
|
|
407
|
+
const uploadTime = ((endTime - startTime) / 1000).toFixed(2)
|
|
408
|
+
spinner.stop(`Failed to upload bundle ( after ${uploadTime} seconds)`)
|
|
403
409
|
p.log.error(`Cannot upload bundle ${formatError(errorUpload)}`)
|
|
404
410
|
// call delete version on path /delete_failed_version to delete the version
|
|
405
411
|
await deletedFailedVersion(supabase, appid, bundle)
|
|
@@ -411,7 +417,9 @@ It will be also visible in your dashboard\n`)
|
|
|
411
417
|
p.log.error(`Cannot update bundle ${formatError(dbError2)}`)
|
|
412
418
|
program.error('')
|
|
413
419
|
}
|
|
414
|
-
|
|
420
|
+
const endTime = performance.now()
|
|
421
|
+
const uploadTime = ((endTime - startTime) / 1000).toFixed(2)
|
|
422
|
+
spinner.stop(`Bundle Uploaded 💪 (${uploadTime} seconds)`)
|
|
415
423
|
}
|
|
416
424
|
else if (useS3 && zipped && s3Client) {
|
|
417
425
|
const spinner = p.spinner()
|
|
@@ -424,7 +432,7 @@ It will be also visible in your dashboard\n`)
|
|
|
424
432
|
Key: fileName,
|
|
425
433
|
Body: zipped,
|
|
426
434
|
})
|
|
427
|
-
|
|
435
|
+
const startTime = performance.now()
|
|
428
436
|
const response = await s3Client.send(command)
|
|
429
437
|
if (response.$metadata.httpStatusCode !== 200) {
|
|
430
438
|
p.log.error(`Cannot upload to S3`)
|
|
@@ -438,7 +446,9 @@ It will be also visible in your dashboard\n`)
|
|
|
438
446
|
p.log.error(`Cannot update bundle ${formatError(dbError2)}`)
|
|
439
447
|
program.error('')
|
|
440
448
|
}
|
|
441
|
-
|
|
449
|
+
const endTime = performance.now()
|
|
450
|
+
const uploadTime = ((endTime - startTime) / 1000).toFixed(2)
|
|
451
|
+
spinner.stop(`Bundle Uploaded 💪 (${uploadTime} seconds)`)
|
|
442
452
|
}
|
|
443
453
|
const { data: versionId } = await supabase
|
|
444
454
|
.rpc('get_app_versions', { apikey: options.apikey, name_version: bundle, 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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|