@jvittechs/j 1.0.60 → 1.0.61

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.
@@ -1115,6 +1115,7 @@ function createTaskSummaryCommand() {
1115
1115
  }
1116
1116
 
1117
1117
  export {
1118
+ CloudTaskProvider,
1118
1119
  STATUS_ICONS,
1119
1120
  BLOCKED_ICON,
1120
1121
  PRIORITY_ICONS,
@@ -1123,4 +1124,4 @@ export {
1123
1124
  handleTaskSummary,
1124
1125
  createTaskSummaryCommand
1125
1126
  };
1126
- //# sourceMappingURL=chunk-22FXNN76.js.map
1127
+ //# sourceMappingURL=chunk-F6GY6L6O.js.map
package/dist/cli.js CHANGED
@@ -11,12 +11,13 @@ import {
11
11
  } from "./chunk-5RDBJYO2.js";
12
12
  import {
13
13
  BLOCKED_ICON,
14
+ CloudTaskProvider,
14
15
  PRIORITY_ICONS,
15
16
  PRIORITY_LABELS,
16
17
  STATUS_ICONS,
17
18
  TaskService,
18
19
  createTaskSummaryCommand
19
- } from "./chunk-22FXNN76.js";
20
+ } from "./chunk-F6GY6L6O.js";
20
21
  import {
21
22
  ConfigService,
22
23
  SettingsService
@@ -156,7 +157,7 @@ import { basename as basename5 } from "path";
156
157
  // package.json
157
158
  var package_default = {
158
159
  name: "@jvittechs/j",
159
- version: "1.0.60",
160
+ version: "1.0.61",
160
161
  description: "A unified CLI tool for JV-IT TECHS developers to manage Jai1 Framework. Supports both `j` and `jai1` commands. Please contact TeamAI for usage instructions.",
161
162
  type: "module",
162
163
  bin: {
@@ -11366,13 +11367,30 @@ async function checkAuthStatus() {
11366
11367
  try {
11367
11368
  const config = await new ConfigService().load();
11368
11369
  if (config?.apiUrl && config?.accessKey) {
11369
- return { ok: true, apiUrl: config.apiUrl, accessKey: config.accessKey };
11370
+ return { ok: true, config };
11370
11371
  }
11371
11372
  return { ok: false };
11372
11373
  } catch {
11373
11374
  return { ok: false };
11374
11375
  }
11375
11376
  }
11377
+ async function registerProject(config, projectId, repoUrl, silent) {
11378
+ try {
11379
+ const provider = new CloudTaskProvider(config, projectId);
11380
+ const registeredId = await provider.ensureProjectRegistered(repoUrl);
11381
+ if (!silent) {
11382
+ console.log(chalk31.green(" \u2713 Project registered on server"));
11383
+ }
11384
+ return registeredId;
11385
+ } catch (error) {
11386
+ if (!silent) {
11387
+ const msg = error instanceof Error ? error.message : String(error);
11388
+ console.log(chalk31.yellow(` \u26A0\uFE0F Register failed: ${msg}`));
11389
+ console.log(chalk31.dim(" Project s\u1EBD \u0111\u01B0\u1EE3c \u0111\u0103ng k\xFD l\u1EA1i khi ch\u1EA1y l\u1EC7nh task \u0111\u1EA7u ti\xEAn."));
11390
+ }
11391
+ return null;
11392
+ }
11393
+ }
11376
11394
  function createSettingsInitCommand() {
11377
11395
  return new Command58("init").description("Kh\u1EDFi t\u1EA1o .jai1/settings.yaml").option("-f, --force", "Ghi \u0111\xE8 file c\u0169 n\u1EBFu \u0111\xE3 t\u1ED3n t\u1EA1i").option("--cloud", "Enable cloud task sync (non-interactive)").option("--no-interactive", "Kh\xF4ng h\u1ECFi, d\xF9ng flags/defaults").option("-j, --json", "Output JSON").action(async (options) => {
11378
11396
  try {
@@ -11381,6 +11399,7 @@ function createSettingsInitCommand() {
11381
11399
  throw new Error("Settings file \u0111\xE3 t\u1ED3n t\u1EA1i. D\xF9ng --force \u0111\u1EC3 ghi \u0111\xE8.");
11382
11400
  }
11383
11401
  let enableCloud = options.cloud || false;
11402
+ let authResult = { ok: false };
11384
11403
  if (options.interactive !== false && !options.json) {
11385
11404
  const repoUrl = service.resolveGitRepoUrl();
11386
11405
  console.log(chalk31.bold("\u{1F4CB} Kh\u1EDFi t\u1EA1o Project Settings"));
@@ -11394,8 +11413,8 @@ function createSettingsInitCommand() {
11394
11413
  default: false
11395
11414
  });
11396
11415
  if (enableCloud) {
11397
- const auth = await checkAuthStatus();
11398
- if (!auth.ok) {
11416
+ authResult = await checkAuthStatus();
11417
+ if (!authResult.ok) {
11399
11418
  console.log("");
11400
11419
  console.log(chalk31.yellow("\u26A0\uFE0F Ch\u01B0a \u0111\u0103ng nh\u1EADp Jai1."));
11401
11420
  console.log(chalk31.dim(" Ch\u1EA1y: j auth"));
@@ -11409,22 +11428,39 @@ function createSettingsInitCommand() {
11409
11428
  console.log(chalk31.green(" \u2713 Auth OK"));
11410
11429
  }
11411
11430
  }
11412
- } else if (enableCloud && !options.json) {
11413
- const auth = await checkAuthStatus();
11414
- if (!auth.ok) {
11431
+ } else if (enableCloud) {
11432
+ authResult = await checkAuthStatus();
11433
+ if (!authResult.ok && !options.json) {
11415
11434
  console.log(chalk31.yellow("\u26A0\uFE0F Ch\u01B0a \u0111\u0103ng nh\u1EADp. Ch\u1EA1y j auth tr\u01B0\u1EDBc khi d\xF9ng cloud tasks."));
11416
11435
  }
11417
11436
  }
11418
- const settings = await service.init(true);
11437
+ await service.init(true);
11419
11438
  if (enableCloud) {
11420
11439
  await service.set("tasks.cloud", true);
11421
11440
  }
11441
+ let registeredProjectId = null;
11442
+ if (enableCloud && authResult.ok && authResult.config) {
11443
+ const repoUrl = service.resolveGitRepoUrl();
11444
+ const projectId = service.getProjectId();
11445
+ if (repoUrl && projectId) {
11446
+ registeredProjectId = await registerProject(
11447
+ authResult.config,
11448
+ projectId,
11449
+ repoUrl,
11450
+ !!options.json
11451
+ );
11452
+ if (registeredProjectId && registeredProjectId !== projectId) {
11453
+ await service.set("tasks.projectId", registeredProjectId);
11454
+ }
11455
+ }
11456
+ }
11422
11457
  const finalSettings = service.load();
11423
11458
  if (options.json) {
11424
11459
  console.log(JSON.stringify({
11425
11460
  success: true,
11426
11461
  path: service.getSettingsPath(),
11427
- settings: finalSettings
11462
+ settings: finalSettings,
11463
+ registered: !!registeredProjectId
11428
11464
  }, null, 2));
11429
11465
  return;
11430
11466
  }
@@ -11437,8 +11473,6 @@ function createSettingsInitCommand() {
11437
11473
  if (projectId) {
11438
11474
  console.log(` ${chalk31.dim("Project ID:")} ${projectId}`);
11439
11475
  }
11440
- console.log("");
11441
- console.log(chalk31.dim(" Cloud tasks s\u1EBD t\u1EF1 \u0111\u0103ng k\xFD project khi ch\u1EA1y l\u1EC7nh task \u0111\u1EA7u ti\xEAn."));
11442
11476
  }
11443
11477
  } catch (error) {
11444
11478
  if (options.json) {
@@ -11476,9 +11510,24 @@ function createSettingsSetCommand() {
11476
11510
  console.log(chalk32.yellow("\u26A0\uFE0F Ch\u01B0a \u0111\u0103ng nh\u1EADp. Ch\u1EA1y j auth tr\u01B0\u1EDBc khi d\xF9ng cloud tasks."));
11477
11511
  } else {
11478
11512
  console.log(chalk32.dim(" Auth: \u2713 OK"));
11513
+ const repoUrl = service.resolveGitRepoUrl();
11479
11514
  const projectId = service.getProjectId();
11480
- if (projectId) {
11481
- console.log(chalk32.dim(` Project: ${projectId}`));
11515
+ if (repoUrl && projectId) {
11516
+ try {
11517
+ const provider = new CloudTaskProvider(config, projectId);
11518
+ const registeredId = await provider.ensureProjectRegistered(repoUrl);
11519
+ console.log(chalk32.green(" \u2713 Project registered on server"));
11520
+ if (registeredId && registeredId !== projectId) {
11521
+ await service.set("tasks.projectId", registeredId);
11522
+ console.log(chalk32.dim(` Project ID: ${registeredId}`));
11523
+ } else {
11524
+ console.log(chalk32.dim(` Project: ${projectId}`));
11525
+ }
11526
+ } catch (error) {
11527
+ const msg = error instanceof Error ? error.message : String(error);
11528
+ console.log(chalk32.yellow(` \u26A0\uFE0F Register failed: ${msg}`));
11529
+ console.log(chalk32.dim(" Project s\u1EBD \u0111\u01B0\u1EE3c \u0111\u0103ng k\xFD l\u1EA1i khi ch\u1EA1y l\u1EC7nh task \u0111\u1EA7u ti\xEAn."));
11530
+ }
11482
11531
  }
11483
11532
  }
11484
11533
  }
@@ -12347,7 +12396,7 @@ function createTasksCommand() {
12347
12396
  cmd.addCommand(createTaskDeleteCommand());
12348
12397
  cmd.addCommand(createTaskGuideCommand());
12349
12398
  cmd.action(async () => {
12350
- const { handleTaskSummary } = await import("./summary-4ZVFN4XV.js");
12399
+ const { handleTaskSummary } = await import("./summary-KFXQDFG6.js");
12351
12400
  await handleTaskSummary({ json: false });
12352
12401
  });
12353
12402
  return cmd;