@capgo/cli 4.12.1 → 4.12.3
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 +23 -20
- package/package.json +1 -1
- package/src/bundle/upload.ts +10 -9
- package/src/utils.ts +17 -15
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.12.3](https://github.com/Cap-go/CLI/compare/v4.12.2...v4.12.3) (2024-07-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* getLocalDepenencies for windows ([ca7bf4e](https://github.com/Cap-go/CLI/commit/ca7bf4e97c6a2ff766978ed61089fd805126dde1))
|
|
11
|
+
|
|
12
|
+
### [4.12.2](https://github.com/Cap-go/CLI/compare/v4.12.1...v4.12.2) (2024-07-08)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* issue with upload ([ca08aec](https://github.com/Cap-go/CLI/commit/ca08aec7f38e1ae9c431ba35764f8659b23692e1))
|
|
18
|
+
|
|
5
19
|
### [4.12.1](https://github.com/Cap-go/CLI/compare/v4.12.0...v4.12.1) (2024-07-08)
|
|
6
20
|
|
|
7
21
|
|
package/dist/index.js
CHANGED
|
@@ -87381,7 +87381,7 @@ var {
|
|
|
87381
87381
|
// package.json
|
|
87382
87382
|
var package_default = {
|
|
87383
87383
|
name: "@capgo/cli",
|
|
87384
|
-
version: "4.12.
|
|
87384
|
+
version: "4.12.3",
|
|
87385
87385
|
description: "A CLI to upload to capgo servers",
|
|
87386
87386
|
author: "github.com/riderx",
|
|
87387
87387
|
license: "Apache 2.0",
|
|
@@ -89129,13 +89129,14 @@ function getPMAndCommand() {
|
|
|
89129
89129
|
}
|
|
89130
89130
|
async function getLocalDepenencies() {
|
|
89131
89131
|
const dir = (0, import_find_root.findRootSync)(import_node_process8.default.cwd());
|
|
89132
|
-
|
|
89132
|
+
const packageJsonPath = (0, import_node_path2.join)(import_node_process8.default.cwd(), "package.json");
|
|
89133
|
+
if (!(0, import_node_fs4.existsSync)(packageJsonPath)) {
|
|
89133
89134
|
f2.error("Missing package.json, you need to be in a capacitor project");
|
|
89134
89135
|
program.error("");
|
|
89135
89136
|
}
|
|
89136
89137
|
let packageJson;
|
|
89137
89138
|
try {
|
|
89138
|
-
packageJson = JSON.parse((0, import_node_fs4.readFileSync)(
|
|
89139
|
+
packageJson = JSON.parse((0, import_node_fs4.readFileSync)(packageJsonPath, "utf8"));
|
|
89139
89140
|
} catch (err) {
|
|
89140
89141
|
f2.error("Invalid package.json, JSON parsing failed");
|
|
89141
89142
|
console.error("json parse error: ", err);
|
|
@@ -89152,7 +89153,8 @@ async function getLocalDepenencies() {
|
|
|
89152
89153
|
program.error("");
|
|
89153
89154
|
}
|
|
89154
89155
|
}
|
|
89155
|
-
|
|
89156
|
+
const nodeModulesPath = (0, import_node_path2.join)(import_node_process8.default.cwd(), "node_modules");
|
|
89157
|
+
if (!(0, import_node_fs4.existsSync)(nodeModulesPath)) {
|
|
89156
89158
|
const pm2 = findPackageManagerType(dir.rootDir, "npm");
|
|
89157
89159
|
const installCmd = findInstallCommand(pm2);
|
|
89158
89160
|
f2.error(`Missing node_modules folder, please run ${pm2} ${installCmd}`);
|
|
@@ -89160,7 +89162,8 @@ async function getLocalDepenencies() {
|
|
|
89160
89162
|
}
|
|
89161
89163
|
let anyInvalid = false;
|
|
89162
89164
|
const dependenciesObject = await Promise.all(Object.entries(dependencies).map(async ([key2, value]) => {
|
|
89163
|
-
const
|
|
89165
|
+
const dependencyFolderPath = (0, import_node_path2.join)(nodeModulesPath, key2);
|
|
89166
|
+
const dependencyFolderExists = (0, import_node_fs4.existsSync)(dependencyFolderPath);
|
|
89164
89167
|
if (!dependencyFolderExists) {
|
|
89165
89168
|
anyInvalid = true;
|
|
89166
89169
|
const pm2 = findPackageManagerType(dir.rootDir, "npm");
|
|
@@ -89169,14 +89172,14 @@ async function getLocalDepenencies() {
|
|
|
89169
89172
|
return { name: key2, version: value };
|
|
89170
89173
|
}
|
|
89171
89174
|
let hasNativeFiles = false;
|
|
89172
|
-
|
|
89173
|
-
|
|
89174
|
-
|
|
89175
|
-
}
|
|
89176
|
-
f2.error(`Error reading
|
|
89175
|
+
try {
|
|
89176
|
+
const files = await (0, import_node_dir.promiseFiles)(dependencyFolderPath);
|
|
89177
|
+
hasNativeFiles = files.some((fileName) => nativeFileRegex.test(fileName));
|
|
89178
|
+
} catch (error) {
|
|
89179
|
+
f2.error(`Error reading node_modules files for ${key2} package`);
|
|
89177
89180
|
console.error(error);
|
|
89178
89181
|
program.error("");
|
|
89179
|
-
}
|
|
89182
|
+
}
|
|
89180
89183
|
return {
|
|
89181
89184
|
name: key2,
|
|
89182
89185
|
version: value,
|
|
@@ -90225,8 +90228,8 @@ async function uploadBundleToCapgoCloud(supabase, appid, bundle2, orgId, zipped,
|
|
|
90225
90228
|
const uploadTime = ((endTime - startTime) / 1e3).toFixed(2);
|
|
90226
90229
|
spinner.stop(`Bundle Uploaded \u{1F4AA} (${uploadTime} seconds)`);
|
|
90227
90230
|
}
|
|
90228
|
-
async function setVersionInChannel(supabase,
|
|
90229
|
-
const { data: versionId } = await supabase.rpc("get_app_versions", { apikey
|
|
90231
|
+
async function setVersionInChannel(supabase, apikey, displayBundleUrl, bundle2, channel2, userId, orgId, appid, localConfig, permissions) {
|
|
90232
|
+
const { data: versionId } = await supabase.rpc("get_app_versions", { apikey, name_version: bundle2, appid }).single();
|
|
90230
90233
|
if (versionId && hasOrganizationPerm(permissions, 3 /* write */)) {
|
|
90231
90234
|
const { error: dbError3, data } = await updateOrCreateChannel(supabase, {
|
|
90232
90235
|
name: channel2,
|
|
@@ -90245,7 +90248,7 @@ async function setVersionInChannel(supabase, options, bundle2, channel2, userId,
|
|
|
90245
90248
|
f2.info("Your update is now available in your public channel \u{1F389}");
|
|
90246
90249
|
else if (data?.id)
|
|
90247
90250
|
f2.info(`Link device to this bundle to try it: ${bundleUrl}`);
|
|
90248
|
-
if (
|
|
90251
|
+
if (displayBundleUrl) {
|
|
90249
90252
|
f2.info(`Bundle url: ${bundleUrl}`);
|
|
90250
90253
|
} else if (!versionId) {
|
|
90251
90254
|
f2.warn("Cannot set bundle with upload key, use key with more rights for that");
|
|
@@ -90285,7 +90288,7 @@ async function uploadBundle(preAppid, options, shouldExit = true) {
|
|
|
90285
90288
|
const userId = await verifyUser(supabase, apikey, ["write", "all", "upload"]);
|
|
90286
90289
|
const permissions = await checkAppExistsAndHasPermissionOrgErr(supabase, apikey, appid, 2 /* upload */);
|
|
90287
90290
|
const orgId = await getOrganizationId(supabase, appid);
|
|
90288
|
-
await checkPlanValid(supabase, orgId,
|
|
90291
|
+
await checkPlanValid(supabase, orgId, apikey, appid, true);
|
|
90289
90292
|
await checkTrial(supabase, orgId, localConfig);
|
|
90290
90293
|
const { nativePackages, minUpdateVersion } = await verifyCompatibility(supabase, pm2, options, channel2, appid, bundle2);
|
|
90291
90294
|
await checkVersionExists(supabase, appid, bundle2);
|
|
@@ -90330,7 +90333,7 @@ async function uploadBundle(preAppid, options, shouldExit = true) {
|
|
|
90330
90333
|
program.error("");
|
|
90331
90334
|
}
|
|
90332
90335
|
}
|
|
90333
|
-
await setVersionInChannel(supabase, options, bundle2, channel2, userId, orgId, appid, localConfig, permissions);
|
|
90336
|
+
await setVersionInChannel(supabase, apikey, !!options.bundleUrl, bundle2, channel2, userId, orgId, appid, localConfig, permissions);
|
|
90334
90337
|
await snag.track({
|
|
90335
90338
|
channel: "app",
|
|
90336
90339
|
event: "App Uploaded",
|
|
@@ -90347,19 +90350,19 @@ async function uploadBundle(preAppid, options, shouldExit = true) {
|
|
|
90347
90350
|
}
|
|
90348
90351
|
return true;
|
|
90349
90352
|
}
|
|
90350
|
-
async function uploadCommand(
|
|
90353
|
+
async function uploadCommand(appid, options) {
|
|
90351
90354
|
try {
|
|
90352
|
-
await uploadBundle(
|
|
90355
|
+
await uploadBundle(appid, options, true);
|
|
90353
90356
|
} catch (error) {
|
|
90354
90357
|
f2.error(formatError(error));
|
|
90355
90358
|
program.error("");
|
|
90356
90359
|
}
|
|
90357
90360
|
}
|
|
90358
|
-
async function uploadDeprecatedCommand(
|
|
90361
|
+
async function uploadDeprecatedCommand(appid, options) {
|
|
90359
90362
|
const pm2 = getPMAndCommand();
|
|
90360
90363
|
f2.warn(`\u26A0\uFE0F This command is deprecated, use "${pm2.runner} @capgo/cli bundle upload" instead \u26A0\uFE0F`);
|
|
90361
90364
|
try {
|
|
90362
|
-
await uploadBundle(
|
|
90365
|
+
await uploadBundle(appid, options, true);
|
|
90363
90366
|
} catch (error) {
|
|
90364
90367
|
f2.error(formatError(error));
|
|
90365
90368
|
program.error("");
|
package/package.json
CHANGED
package/src/bundle/upload.ts
CHANGED
|
@@ -343,7 +343,8 @@ async function uploadBundleToCapgoCloud(supabase: SupabaseType, appid: string, b
|
|
|
343
343
|
|
|
344
344
|
async function setVersionInChannel(
|
|
345
345
|
supabase: SupabaseType,
|
|
346
|
-
|
|
346
|
+
apikey: string,
|
|
347
|
+
displayBundleUrl: boolean,
|
|
347
348
|
bundle: string,
|
|
348
349
|
channel: string,
|
|
349
350
|
userId: string,
|
|
@@ -353,7 +354,7 @@ async function setVersionInChannel(
|
|
|
353
354
|
permissions: OrganizationPerm,
|
|
354
355
|
) {
|
|
355
356
|
const { data: versionId } = await supabase
|
|
356
|
-
.rpc('get_app_versions', { apikey
|
|
357
|
+
.rpc('get_app_versions', { apikey, name_version: bundle, appid })
|
|
357
358
|
.single()
|
|
358
359
|
|
|
359
360
|
if (versionId && hasOrganizationPerm(permissions, OrganizationPerm.write)) {
|
|
@@ -375,7 +376,7 @@ async function setVersionInChannel(
|
|
|
375
376
|
else if (data?.id)
|
|
376
377
|
p.log.info(`Link device to this bundle to try it: ${bundleUrl}`)
|
|
377
378
|
|
|
378
|
-
if (
|
|
379
|
+
if (displayBundleUrl) {
|
|
379
380
|
p.log.info(`Bundle url: ${bundleUrl}`)
|
|
380
381
|
}
|
|
381
382
|
else if (!versionId) {
|
|
@@ -436,7 +437,7 @@ export async function uploadBundle(preAppid: string, options: Options, shouldExi
|
|
|
436
437
|
|
|
437
438
|
// Now if it does exist we will fetch the org id
|
|
438
439
|
const orgId = await getOrganizationId(supabase, appid)
|
|
439
|
-
await checkPlanValid(supabase, orgId,
|
|
440
|
+
await checkPlanValid(supabase, orgId, apikey, appid, true)
|
|
440
441
|
await checkTrial(supabase, orgId, localConfig)
|
|
441
442
|
const { nativePackages, minUpdateVersion } = await verifyCompatibility(supabase, pm, options, channel, appid, bundle)
|
|
442
443
|
await checkVersionExists(supabase, appid, bundle)
|
|
@@ -488,7 +489,7 @@ export async function uploadBundle(preAppid: string, options: Options, shouldExi
|
|
|
488
489
|
}
|
|
489
490
|
}
|
|
490
491
|
|
|
491
|
-
await setVersionInChannel(supabase, options, bundle, channel, userId, orgId, appid, localConfig, permissions)
|
|
492
|
+
await setVersionInChannel(supabase, apikey, !!options.bundleUrl, bundle, channel, userId, orgId, appid, localConfig, permissions)
|
|
492
493
|
|
|
493
494
|
await snag.track({
|
|
494
495
|
channel: 'app',
|
|
@@ -507,9 +508,9 @@ export async function uploadBundle(preAppid: string, options: Options, shouldExi
|
|
|
507
508
|
return true
|
|
508
509
|
}
|
|
509
510
|
|
|
510
|
-
export async function uploadCommand(
|
|
511
|
+
export async function uploadCommand(appid: string, options: Options) {
|
|
511
512
|
try {
|
|
512
|
-
await uploadBundle(
|
|
513
|
+
await uploadBundle(appid, options, true)
|
|
513
514
|
}
|
|
514
515
|
catch (error) {
|
|
515
516
|
p.log.error(formatError(error))
|
|
@@ -517,11 +518,11 @@ export async function uploadCommand(apikey: string, options: Options) {
|
|
|
517
518
|
}
|
|
518
519
|
}
|
|
519
520
|
|
|
520
|
-
export async function uploadDeprecatedCommand(
|
|
521
|
+
export async function uploadDeprecatedCommand(appid: string, options: Options) {
|
|
521
522
|
const pm = getPMAndCommand()
|
|
522
523
|
p.log.warn(`⚠️ This command is deprecated, use "${pm.runner} @capgo/cli bundle upload" instead ⚠️`)
|
|
523
524
|
try {
|
|
524
|
-
await uploadBundle(
|
|
525
|
+
await uploadBundle(appid, options, true)
|
|
525
526
|
}
|
|
526
527
|
catch (error) {
|
|
527
528
|
p.log.error(formatError(error))
|
package/src/utils.ts
CHANGED
|
@@ -842,14 +842,16 @@ export function getPMAndCommand() {
|
|
|
842
842
|
|
|
843
843
|
export async function getLocalDepenencies() {
|
|
844
844
|
const dir = findRootSync(process.cwd())
|
|
845
|
-
|
|
845
|
+
const packageJsonPath = join(process.cwd(), 'package.json')
|
|
846
|
+
|
|
847
|
+
if (!existsSync(packageJsonPath)) {
|
|
846
848
|
p.log.error('Missing package.json, you need to be in a capacitor project')
|
|
847
849
|
program.error('')
|
|
848
850
|
}
|
|
849
851
|
|
|
850
852
|
let packageJson
|
|
851
853
|
try {
|
|
852
|
-
packageJson = JSON.parse(readFileSync(
|
|
854
|
+
packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
|
|
853
855
|
}
|
|
854
856
|
catch (err) {
|
|
855
857
|
p.log.error('Invalid package.json, JSON parsing failed')
|
|
@@ -870,7 +872,8 @@ export async function getLocalDepenencies() {
|
|
|
870
872
|
}
|
|
871
873
|
}
|
|
872
874
|
|
|
873
|
-
|
|
875
|
+
const nodeModulesPath = join(process.cwd(), 'node_modules')
|
|
876
|
+
if (!existsSync(nodeModulesPath)) {
|
|
874
877
|
const pm = findPackageManagerType(dir.rootDir, 'npm')
|
|
875
878
|
const installCmd = findInstallCommand(pm)
|
|
876
879
|
p.log.error(`Missing node_modules folder, please run ${pm} ${installCmd}`)
|
|
@@ -880,9 +883,9 @@ export async function getLocalDepenencies() {
|
|
|
880
883
|
let anyInvalid = false
|
|
881
884
|
|
|
882
885
|
const dependenciesObject = await Promise.all(Object.entries(dependencies as Record<string, string>)
|
|
883
|
-
|
|
884
886
|
.map(async ([key, value]) => {
|
|
885
|
-
const
|
|
887
|
+
const dependencyFolderPath = join(nodeModulesPath, key)
|
|
888
|
+
const dependencyFolderExists = existsSync(dependencyFolderPath)
|
|
886
889
|
|
|
887
890
|
if (!dependencyFolderExists) {
|
|
888
891
|
anyInvalid = true
|
|
@@ -893,16 +896,15 @@ export async function getLocalDepenencies() {
|
|
|
893
896
|
}
|
|
894
897
|
|
|
895
898
|
let hasNativeFiles = false
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
.
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
})
|
|
899
|
+
try {
|
|
900
|
+
const files = await promiseFiles(dependencyFolderPath)
|
|
901
|
+
hasNativeFiles = files.some(fileName => nativeFileRegex.test(fileName))
|
|
902
|
+
}
|
|
903
|
+
catch (error) {
|
|
904
|
+
p.log.error(`Error reading node_modules files for ${key} package`)
|
|
905
|
+
console.error(error)
|
|
906
|
+
program.error('')
|
|
907
|
+
}
|
|
906
908
|
|
|
907
909
|
return {
|
|
908
910
|
name: key,
|