@claude-sync/cli 0.1.3 → 0.1.5
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/dist/bin/claude-sync.js +107 -30
- package/dist/bin/claude-sync.js.map +1 -1
- package/dist/src/index.js +104 -30
- package/dist/src/index.js.map +1 -1
- package/package.json +4 -2
package/dist/bin/claude-sync.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -38,10 +39,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
39
|
mod
|
|
39
40
|
));
|
|
40
41
|
|
|
42
|
+
// ../../node_modules/tsup/assets/esm_shims.js
|
|
43
|
+
import path from "path";
|
|
44
|
+
import { fileURLToPath } from "url";
|
|
45
|
+
var init_esm_shims = __esm({
|
|
46
|
+
"../../node_modules/tsup/assets/esm_shims.js"() {
|
|
47
|
+
"use strict";
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
41
51
|
// ../../packages/utils/dist/path-encoding.js
|
|
42
52
|
var require_path_encoding = __commonJS({
|
|
43
53
|
"../../packages/utils/dist/path-encoding.js"(exports) {
|
|
44
54
|
"use strict";
|
|
55
|
+
init_esm_shims();
|
|
45
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
57
|
exports.ROOT_PATTERN = void 0;
|
|
47
58
|
exports.encodePath = encodePath3;
|
|
@@ -78,6 +89,7 @@ var require_path_encoding = __commonJS({
|
|
|
78
89
|
var require_manifest = __commonJS({
|
|
79
90
|
"../../packages/utils/dist/manifest.js"(exports) {
|
|
80
91
|
"use strict";
|
|
92
|
+
init_esm_shims();
|
|
81
93
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
82
94
|
exports.hashFile = hashFile2;
|
|
83
95
|
exports.hashManifest = hashManifest;
|
|
@@ -121,6 +133,7 @@ var require_manifest = __commonJS({
|
|
|
121
133
|
var require_constants = __commonJS({
|
|
122
134
|
"../../packages/utils/dist/constants.js"(exports) {
|
|
123
135
|
"use strict";
|
|
136
|
+
init_esm_shims();
|
|
124
137
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
125
138
|
exports.PROJECTS_DIR = exports.CLAUDE_DIR = exports.MANIFEST_FILE = exports.CONFIG_FILE = exports.CONFIG_DIR = exports.API_VERSION = exports.BUCKET_MANIFESTS = exports.BUCKET_DATA = exports.SYNC_EXCLUDE_PATTERNS = void 0;
|
|
126
139
|
exports.SYNC_EXCLUDE_PATTERNS = [
|
|
@@ -149,6 +162,7 @@ var require_constants = __commonJS({
|
|
|
149
162
|
var require_util = __commonJS({
|
|
150
163
|
"../../node_modules/zod/v3/helpers/util.cjs"(exports) {
|
|
151
164
|
"use strict";
|
|
165
|
+
init_esm_shims();
|
|
152
166
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
153
167
|
exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0;
|
|
154
168
|
var util;
|
|
@@ -291,6 +305,7 @@ var require_util = __commonJS({
|
|
|
291
305
|
var require_ZodError = __commonJS({
|
|
292
306
|
"../../node_modules/zod/v3/ZodError.cjs"(exports) {
|
|
293
307
|
"use strict";
|
|
308
|
+
init_esm_shims();
|
|
294
309
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
295
310
|
exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
|
|
296
311
|
var util_js_1 = require_util();
|
|
@@ -419,6 +434,7 @@ var require_ZodError = __commonJS({
|
|
|
419
434
|
var require_en = __commonJS({
|
|
420
435
|
"../../node_modules/zod/v3/locales/en.cjs"(exports) {
|
|
421
436
|
"use strict";
|
|
437
|
+
init_esm_shims();
|
|
422
438
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
423
439
|
var ZodError_js_1 = require_ZodError();
|
|
424
440
|
var util_js_1 = require_util();
|
|
@@ -530,6 +546,7 @@ var require_en = __commonJS({
|
|
|
530
546
|
var require_errors = __commonJS({
|
|
531
547
|
"../../node_modules/zod/v3/errors.cjs"(exports) {
|
|
532
548
|
"use strict";
|
|
549
|
+
init_esm_shims();
|
|
533
550
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
534
551
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
535
552
|
};
|
|
@@ -553,6 +570,7 @@ var require_errors = __commonJS({
|
|
|
553
570
|
var require_parseUtil = __commonJS({
|
|
554
571
|
"../../node_modules/zod/v3/helpers/parseUtil.cjs"(exports) {
|
|
555
572
|
"use strict";
|
|
573
|
+
init_esm_shims();
|
|
556
574
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
557
575
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
558
576
|
};
|
|
@@ -562,8 +580,8 @@ var require_parseUtil = __commonJS({
|
|
|
562
580
|
var errors_js_1 = require_errors();
|
|
563
581
|
var en_js_1 = __importDefault(require_en());
|
|
564
582
|
var makeIssue = (params) => {
|
|
565
|
-
const { data, path, errorMaps, issueData } = params;
|
|
566
|
-
const fullPath = [...
|
|
583
|
+
const { data, path: path2, errorMaps, issueData } = params;
|
|
584
|
+
const fullPath = [...path2, ...issueData.path || []];
|
|
567
585
|
const fullIssue = {
|
|
568
586
|
...issueData,
|
|
569
587
|
path: fullPath
|
|
@@ -684,6 +702,7 @@ var require_parseUtil = __commonJS({
|
|
|
684
702
|
var require_typeAliases = __commonJS({
|
|
685
703
|
"../../node_modules/zod/v3/helpers/typeAliases.cjs"(exports) {
|
|
686
704
|
"use strict";
|
|
705
|
+
init_esm_shims();
|
|
687
706
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
688
707
|
}
|
|
689
708
|
});
|
|
@@ -692,6 +711,7 @@ var require_typeAliases = __commonJS({
|
|
|
692
711
|
var require_errorUtil = __commonJS({
|
|
693
712
|
"../../node_modules/zod/v3/helpers/errorUtil.cjs"(exports) {
|
|
694
713
|
"use strict";
|
|
714
|
+
init_esm_shims();
|
|
695
715
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
696
716
|
exports.errorUtil = void 0;
|
|
697
717
|
var errorUtil;
|
|
@@ -706,6 +726,7 @@ var require_errorUtil = __commonJS({
|
|
|
706
726
|
var require_types = __commonJS({
|
|
707
727
|
"../../node_modules/zod/v3/types.cjs"(exports) {
|
|
708
728
|
"use strict";
|
|
729
|
+
init_esm_shims();
|
|
709
730
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
710
731
|
exports.discriminatedUnion = exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0;
|
|
711
732
|
exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = void 0;
|
|
@@ -717,11 +738,11 @@ var require_types = __commonJS({
|
|
|
717
738
|
var parseUtil_js_1 = require_parseUtil();
|
|
718
739
|
var util_js_1 = require_util();
|
|
719
740
|
var ParseInputLazyPath = class {
|
|
720
|
-
constructor(parent, value,
|
|
741
|
+
constructor(parent, value, path2, key) {
|
|
721
742
|
this._cachedPath = [];
|
|
722
743
|
this.parent = parent;
|
|
723
744
|
this.data = value;
|
|
724
|
-
this._path =
|
|
745
|
+
this._path = path2;
|
|
725
746
|
this._key = key;
|
|
726
747
|
}
|
|
727
748
|
get path() {
|
|
@@ -4248,6 +4269,7 @@ var require_types = __commonJS({
|
|
|
4248
4269
|
var require_external = __commonJS({
|
|
4249
4270
|
"../../node_modules/zod/v3/external.cjs"(exports) {
|
|
4250
4271
|
"use strict";
|
|
4272
|
+
init_esm_shims();
|
|
4251
4273
|
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
4252
4274
|
if (k2 === void 0) k2 = k;
|
|
4253
4275
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -4278,6 +4300,7 @@ var require_external = __commonJS({
|
|
|
4278
4300
|
var require_zod = __commonJS({
|
|
4279
4301
|
"../../node_modules/zod/index.cjs"(exports) {
|
|
4280
4302
|
"use strict";
|
|
4303
|
+
init_esm_shims();
|
|
4281
4304
|
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
4282
4305
|
if (k2 === void 0) k2 = k;
|
|
4283
4306
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -4321,6 +4344,7 @@ var require_zod = __commonJS({
|
|
|
4321
4344
|
var require_validation = __commonJS({
|
|
4322
4345
|
"../../packages/utils/dist/validation.js"(exports) {
|
|
4323
4346
|
"use strict";
|
|
4347
|
+
init_esm_shims();
|
|
4324
4348
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4325
4349
|
exports.updateProfileSchema = exports.refreshTokenSchema = exports.syncCompleteSchema = exports.downloadUrlSchema = exports.uploadUrlSchema = exports.pullRequestSchema = exports.pushManifestSchema = exports.updateDeviceSchema = exports.createDeviceSchema = exports.registerSchema = exports.loginSchema = void 0;
|
|
4326
4350
|
var zod_1 = require_zod();
|
|
@@ -4395,6 +4419,7 @@ var require_validation = __commonJS({
|
|
|
4395
4419
|
var require_dist = __commonJS({
|
|
4396
4420
|
"../../packages/utils/dist/index.js"(exports) {
|
|
4397
4421
|
"use strict";
|
|
4422
|
+
init_esm_shims();
|
|
4398
4423
|
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
4399
4424
|
if (k2 === void 0) k2 = k;
|
|
4400
4425
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -4485,6 +4510,7 @@ var import_utils, DEFAULT_CONFIG;
|
|
|
4485
4510
|
var init_config = __esm({
|
|
4486
4511
|
"src/lib/config.ts"() {
|
|
4487
4512
|
"use strict";
|
|
4513
|
+
init_esm_shims();
|
|
4488
4514
|
import_utils = __toESM(require_dist(), 1);
|
|
4489
4515
|
DEFAULT_CONFIG = {
|
|
4490
4516
|
apiUrl: "https://api.claude-sync.com",
|
|
@@ -4503,18 +4529,19 @@ var ApiClient;
|
|
|
4503
4529
|
var init_api_client = __esm({
|
|
4504
4530
|
"src/lib/api-client.ts"() {
|
|
4505
4531
|
"use strict";
|
|
4532
|
+
init_esm_shims();
|
|
4506
4533
|
init_auth();
|
|
4507
4534
|
ApiClient = class {
|
|
4508
4535
|
baseUrl;
|
|
4509
4536
|
constructor(baseUrl) {
|
|
4510
4537
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
4511
4538
|
}
|
|
4512
|
-
async rawRequest(
|
|
4539
|
+
async rawRequest(path2, options = {}) {
|
|
4513
4540
|
const controller = new AbortController();
|
|
4514
4541
|
const timeout = setTimeout(() => controller.abort(), 15e3);
|
|
4515
4542
|
let response;
|
|
4516
4543
|
try {
|
|
4517
|
-
response = await fetch(`${this.baseUrl}${
|
|
4544
|
+
response = await fetch(`${this.baseUrl}${path2}`, {
|
|
4518
4545
|
...options,
|
|
4519
4546
|
signal: controller.signal
|
|
4520
4547
|
});
|
|
@@ -4540,7 +4567,7 @@ var init_api_client = __esm({
|
|
|
4540
4567
|
const json = await response.json();
|
|
4541
4568
|
return json.data !== void 0 ? json.data : json;
|
|
4542
4569
|
}
|
|
4543
|
-
async request(
|
|
4570
|
+
async request(path2, options = {}) {
|
|
4544
4571
|
const token = await getValidToken();
|
|
4545
4572
|
const headers = {
|
|
4546
4573
|
"Content-Type": "application/json",
|
|
@@ -4549,32 +4576,32 @@ var init_api_client = __esm({
|
|
|
4549
4576
|
if (token) {
|
|
4550
4577
|
headers["Authorization"] = `Bearer ${token}`;
|
|
4551
4578
|
}
|
|
4552
|
-
return this.rawRequest(
|
|
4579
|
+
return this.rawRequest(path2, { ...options, headers });
|
|
4553
4580
|
}
|
|
4554
|
-
async requestNoAuth(
|
|
4581
|
+
async requestNoAuth(path2, options = {}) {
|
|
4555
4582
|
const headers = {
|
|
4556
4583
|
"Content-Type": "application/json",
|
|
4557
4584
|
...options.headers
|
|
4558
4585
|
};
|
|
4559
|
-
return this.rawRequest(
|
|
4586
|
+
return this.rawRequest(path2, { ...options, headers });
|
|
4560
4587
|
}
|
|
4561
|
-
async get(
|
|
4562
|
-
return this.request(
|
|
4588
|
+
async get(path2) {
|
|
4589
|
+
return this.request(path2, { method: "GET" });
|
|
4563
4590
|
}
|
|
4564
|
-
async post(
|
|
4565
|
-
return this.request(
|
|
4591
|
+
async post(path2, body) {
|
|
4592
|
+
return this.request(path2, {
|
|
4566
4593
|
method: "POST",
|
|
4567
4594
|
body: body ? JSON.stringify(body) : void 0
|
|
4568
4595
|
});
|
|
4569
4596
|
}
|
|
4570
|
-
async patch(
|
|
4571
|
-
return this.request(
|
|
4597
|
+
async patch(path2, body) {
|
|
4598
|
+
return this.request(path2, {
|
|
4572
4599
|
method: "PATCH",
|
|
4573
4600
|
body: body ? JSON.stringify(body) : void 0
|
|
4574
4601
|
});
|
|
4575
4602
|
}
|
|
4576
|
-
async delete(
|
|
4577
|
-
return this.request(
|
|
4603
|
+
async delete(path2) {
|
|
4604
|
+
return this.request(path2, { method: "DELETE" });
|
|
4578
4605
|
}
|
|
4579
4606
|
};
|
|
4580
4607
|
}
|
|
@@ -4624,6 +4651,7 @@ async function getValidToken() {
|
|
|
4624
4651
|
var init_auth = __esm({
|
|
4625
4652
|
"src/lib/auth.ts"() {
|
|
4626
4653
|
"use strict";
|
|
4654
|
+
init_esm_shims();
|
|
4627
4655
|
init_config();
|
|
4628
4656
|
init_api_client();
|
|
4629
4657
|
}
|
|
@@ -4632,8 +4660,8 @@ var init_auth = __esm({
|
|
|
4632
4660
|
// src/lib/progress.ts
|
|
4633
4661
|
import ora from "ora";
|
|
4634
4662
|
import chalk from "chalk";
|
|
4635
|
-
function createSpinner(
|
|
4636
|
-
return ora({ text: brandColor(
|
|
4663
|
+
function createSpinner(text4) {
|
|
4664
|
+
return ora({ text: brandColor(text4), spinner: "dots", color: "magenta" });
|
|
4637
4665
|
}
|
|
4638
4666
|
function formatBytes(bytes) {
|
|
4639
4667
|
if (bytes === 0) return "0 B";
|
|
@@ -4650,6 +4678,7 @@ var brandColor;
|
|
|
4650
4678
|
var init_progress = __esm({
|
|
4651
4679
|
"src/lib/progress.ts"() {
|
|
4652
4680
|
"use strict";
|
|
4681
|
+
init_esm_shims();
|
|
4653
4682
|
brandColor = chalk.hex("#8a8cdd");
|
|
4654
4683
|
}
|
|
4655
4684
|
});
|
|
@@ -4690,6 +4719,7 @@ var BRAND_HEX, BRAND_DIM_HEX, SUCCESS_HEX, WARN_HEX, ERROR_HEX, brand, brandBold
|
|
|
4690
4719
|
var init_theme = __esm({
|
|
4691
4720
|
"src/lib/theme.ts"() {
|
|
4692
4721
|
"use strict";
|
|
4722
|
+
init_esm_shims();
|
|
4693
4723
|
BRAND_HEX = "#8a8cdd";
|
|
4694
4724
|
BRAND_DIM_HEX = "#6b6db8";
|
|
4695
4725
|
SUCCESS_HEX = "#8adda0";
|
|
@@ -4807,6 +4837,7 @@ function loginCommand() {
|
|
|
4807
4837
|
var init_login = __esm({
|
|
4808
4838
|
"src/commands/login.ts"() {
|
|
4809
4839
|
"use strict";
|
|
4840
|
+
init_esm_shims();
|
|
4810
4841
|
init_config();
|
|
4811
4842
|
init_auth();
|
|
4812
4843
|
init_api_client();
|
|
@@ -4845,6 +4876,7 @@ function logoutCommand() {
|
|
|
4845
4876
|
var init_logout = __esm({
|
|
4846
4877
|
"src/commands/logout.ts"() {
|
|
4847
4878
|
"use strict";
|
|
4879
|
+
init_esm_shims();
|
|
4848
4880
|
init_config();
|
|
4849
4881
|
init_api_client();
|
|
4850
4882
|
init_theme();
|
|
@@ -4970,6 +5002,7 @@ function deviceCommand() {
|
|
|
4970
5002
|
var init_device = __esm({
|
|
4971
5003
|
"src/commands/device.ts"() {
|
|
4972
5004
|
"use strict";
|
|
5005
|
+
init_esm_shims();
|
|
4973
5006
|
init_config();
|
|
4974
5007
|
init_api_client();
|
|
4975
5008
|
init_progress();
|
|
@@ -5058,6 +5091,7 @@ var import_utils2;
|
|
|
5058
5091
|
var init_sync_engine = __esm({
|
|
5059
5092
|
"src/lib/sync-engine.ts"() {
|
|
5060
5093
|
"use strict";
|
|
5094
|
+
init_esm_shims();
|
|
5061
5095
|
import_utils2 = __toESM(require_dist(), 1);
|
|
5062
5096
|
}
|
|
5063
5097
|
});
|
|
@@ -5089,6 +5123,7 @@ function decompressBuffer(data) {
|
|
|
5089
5123
|
var init_compress = __esm({
|
|
5090
5124
|
"src/lib/compress.ts"() {
|
|
5091
5125
|
"use strict";
|
|
5126
|
+
init_esm_shims();
|
|
5092
5127
|
}
|
|
5093
5128
|
});
|
|
5094
5129
|
|
|
@@ -5493,6 +5528,7 @@ var import_utils3;
|
|
|
5493
5528
|
var init_sync = __esm({
|
|
5494
5529
|
"src/commands/sync.ts"() {
|
|
5495
5530
|
"use strict";
|
|
5531
|
+
init_esm_shims();
|
|
5496
5532
|
init_config();
|
|
5497
5533
|
init_api_client();
|
|
5498
5534
|
init_sync_engine();
|
|
@@ -5538,6 +5574,7 @@ function statusCommand() {
|
|
|
5538
5574
|
var init_status = __esm({
|
|
5539
5575
|
"src/commands/status.ts"() {
|
|
5540
5576
|
"use strict";
|
|
5577
|
+
init_esm_shims();
|
|
5541
5578
|
init_config();
|
|
5542
5579
|
init_sync_engine();
|
|
5543
5580
|
init_progress();
|
|
@@ -5580,6 +5617,7 @@ function whoamiCommand() {
|
|
|
5580
5617
|
var init_whoami = __esm({
|
|
5581
5618
|
"src/commands/whoami.ts"() {
|
|
5582
5619
|
"use strict";
|
|
5620
|
+
init_esm_shims();
|
|
5583
5621
|
init_config();
|
|
5584
5622
|
init_api_client();
|
|
5585
5623
|
init_progress();
|
|
@@ -5587,7 +5625,11 @@ var init_whoami = __esm({
|
|
|
5587
5625
|
}
|
|
5588
5626
|
});
|
|
5589
5627
|
|
|
5628
|
+
// bin/claude-sync.ts
|
|
5629
|
+
init_esm_shims();
|
|
5630
|
+
|
|
5590
5631
|
// src/index.ts
|
|
5632
|
+
init_esm_shims();
|
|
5591
5633
|
init_login();
|
|
5592
5634
|
init_logout();
|
|
5593
5635
|
init_device();
|
|
@@ -5597,9 +5639,11 @@ init_whoami();
|
|
|
5597
5639
|
import { Command as Command7 } from "commander";
|
|
5598
5640
|
|
|
5599
5641
|
// src/commands/tui.ts
|
|
5642
|
+
init_esm_shims();
|
|
5600
5643
|
init_theme();
|
|
5601
5644
|
init_config();
|
|
5602
|
-
|
|
5645
|
+
init_api_client();
|
|
5646
|
+
import { select as select3, text as text3, isCancel as isCancel4 } from "@clack/prompts";
|
|
5603
5647
|
import chalk3 from "chalk";
|
|
5604
5648
|
function buildMenu(loggedIn) {
|
|
5605
5649
|
if (!loggedIn) {
|
|
@@ -5654,6 +5698,30 @@ async function runTui() {
|
|
|
5654
5698
|
console.log();
|
|
5655
5699
|
}
|
|
5656
5700
|
}
|
|
5701
|
+
async function promptDeviceSelection(config) {
|
|
5702
|
+
const client = new ApiClient(config.apiUrl);
|
|
5703
|
+
let devices;
|
|
5704
|
+
try {
|
|
5705
|
+
devices = await client.get("/api/devices");
|
|
5706
|
+
} catch {
|
|
5707
|
+
printError("Failed to fetch devices.");
|
|
5708
|
+
return null;
|
|
5709
|
+
}
|
|
5710
|
+
if (devices.length === 0) {
|
|
5711
|
+
printError("No devices registered.");
|
|
5712
|
+
return null;
|
|
5713
|
+
}
|
|
5714
|
+
const choice = await select3({
|
|
5715
|
+
message: brand("Select device"),
|
|
5716
|
+
options: devices.map((d) => ({
|
|
5717
|
+
value: d.id,
|
|
5718
|
+
label: d.name,
|
|
5719
|
+
hint: d.id === config.deviceId ? dim("current") : void 0
|
|
5720
|
+
}))
|
|
5721
|
+
});
|
|
5722
|
+
if (isCancel4(choice)) return null;
|
|
5723
|
+
return choice;
|
|
5724
|
+
}
|
|
5657
5725
|
async function executeCommand(command) {
|
|
5658
5726
|
const { loginCommand: loginCommand2 } = await Promise.resolve().then(() => (init_login(), login_exports));
|
|
5659
5727
|
const { logoutCommand: logoutCommand2 } = await Promise.resolve().then(() => (init_logout(), logout_exports));
|
|
@@ -5661,16 +5729,25 @@ async function executeCommand(command) {
|
|
|
5661
5729
|
const { syncCommand: syncCommand2 } = await Promise.resolve().then(() => (init_sync(), sync_exports));
|
|
5662
5730
|
const { statusCommand: statusCommand2 } = await Promise.resolve().then(() => (init_status(), status_exports));
|
|
5663
5731
|
const { whoamiCommand: whoamiCommand2 } = await Promise.resolve().then(() => (init_whoami(), whoami_exports));
|
|
5732
|
+
const config = await loadConfig();
|
|
5664
5733
|
const handlers = {
|
|
5665
|
-
login: () => loginCommand2().parseAsync(["", ""
|
|
5666
|
-
logout: () => logoutCommand2().parseAsync(["", ""
|
|
5667
|
-
sync: () => syncCommand2().parseAsync(["", ""
|
|
5668
|
-
status: () => statusCommand2().parseAsync(["", ""
|
|
5669
|
-
whoami: () => whoamiCommand2().parseAsync(["", ""
|
|
5670
|
-
"device:add": () => deviceCommand2().parseAsync(["", "", "
|
|
5671
|
-
"device:list": () => deviceCommand2().parseAsync(["", "", "
|
|
5672
|
-
"device:remove": () =>
|
|
5673
|
-
|
|
5734
|
+
login: () => loginCommand2().parseAsync(["", ""]),
|
|
5735
|
+
logout: () => logoutCommand2().parseAsync(["", ""]),
|
|
5736
|
+
sync: () => syncCommand2().parseAsync(["", ""]),
|
|
5737
|
+
status: () => statusCommand2().parseAsync(["", ""]),
|
|
5738
|
+
whoami: () => whoamiCommand2().parseAsync(["", ""]),
|
|
5739
|
+
"device:add": () => deviceCommand2().parseAsync(["", "", "add"]),
|
|
5740
|
+
"device:list": () => deviceCommand2().parseAsync(["", "", "list"]),
|
|
5741
|
+
"device:remove": async () => {
|
|
5742
|
+
const deviceId = await promptDeviceSelection(config);
|
|
5743
|
+
if (!deviceId) return;
|
|
5744
|
+
await deviceCommand2().parseAsync(["", "", "remove", deviceId]);
|
|
5745
|
+
},
|
|
5746
|
+
"device:rename": async () => {
|
|
5747
|
+
const name = await text3({ message: `${brand("New device name")}:` });
|
|
5748
|
+
if (isCancel4(name)) return;
|
|
5749
|
+
await deviceCommand2().parseAsync(["", "", "rename", name]);
|
|
5750
|
+
}
|
|
5674
5751
|
};
|
|
5675
5752
|
const handler = handlers[command];
|
|
5676
5753
|
if (handler) {
|