@gadmin2n/cli 0.0.97 → 0.0.100

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.
@@ -41,7 +41,8 @@ const DEFAULT_EXCLUDES = [
41
41
  '.pnp.cjs',
42
42
  '.pnp.loader.mjs',
43
43
  ];
44
- const CLAUDE_CONTEXT_REPO = 'https://git.tencent.com/OIT-OMC/erp-ai-coding-context.git';
44
+ const CLAUDE_CONTEXT_REPO_HTTPS = 'https://git.tencent.com/OIT-OMC/erp-ai-coding-context.git';
45
+ const CLAUDE_CONTEXT_REPO_SSH = 'git@git.tencent.com:OIT-OMC/erp-ai-coding-context.git';
45
46
  const CLAUDE_CONTEXT_BRANCH = 'master';
46
47
  const CLAUDE_SOURCE_SUBDIR = '.claude';
47
48
  const CLAUDE_TARGET_DIRS = ['.claude-internal', '.agent'];
@@ -310,11 +311,11 @@ function tryAutoMerge(instanceContent, templateContent) {
310
311
  * the absolute path to the `.claude` subfolder. Returns null on failure
311
312
  * (e.g. no network, repo private, credentials missing, etc.).
312
313
  */
313
- function fetchClaudeContextRepo() {
314
+ function fetchClaudeContextRepo(repoUrl, branch) {
314
315
  var _a, _b;
315
316
  const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gadmin-claude-ctx-'));
316
317
  try {
317
- (0, child_process_1.execSync)(`git clone --depth 1 --branch ${CLAUDE_CONTEXT_BRANCH} ${CLAUDE_CONTEXT_REPO} "${tmpDir}"`, { stdio: 'pipe' });
318
+ (0, child_process_1.execSync)(`git clone --depth 1 --branch ${branch} ${repoUrl} "${tmpDir}"`, { stdio: 'pipe' });
318
319
  const claudeSrc = path.join(tmpDir, CLAUDE_SOURCE_SUBDIR);
319
320
  if (!fs.existsSync(claudeSrc)) {
320
321
  // Repo cloned, but the .claude dir is missing — treat as no-op
@@ -338,7 +339,7 @@ function fetchClaudeContextRepo() {
338
339
  catch (err) {
339
340
  fs.rmSync(tmpDir, { recursive: true, force: true });
340
341
  const msg = ((_b = (_a = err === null || err === void 0 ? void 0 : err.stderr) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a)) || (err === null || err === void 0 ? void 0 : err.message) || String(err);
341
- console.warn(chalk.yellow(`⚠️ Skipping .claude context sync: failed to clone ${CLAUDE_CONTEXT_REPO}\n ${msg
342
+ console.warn(chalk.yellow(`⚠️ Skipping .claude context sync: failed to clone ${repoUrl}\n ${msg
342
343
  .trim()
343
344
  .split('\n')
344
345
  .join('\n ')}`));
@@ -383,18 +384,82 @@ function copyTreeOverwrite(srcDir, destDir) {
383
384
  walk('');
384
385
  return { added, updated };
385
386
  }
386
- function syncClaudeContext(instanceDir, dryRun) {
387
+ /**
388
+ * Resolve which git URL + branch to use for the .claude context sync.
389
+ *
390
+ * Priority (highest first):
391
+ * 1. CLI --claude-context-repo (full URL override)
392
+ * 2. CLI --claude-context-protocol (https | ssh | skip)
393
+ * 3. Env var GADMIN2_CLAUDE_CONTEXT_REPO (full URL)
394
+ * 4. Env var GADMIN2_CLAUDE_CONTEXT_PROTOCOL (https | ssh | skip)
395
+ * 5. --yes (auto mode): default to built-in HTTPS, no prompt
396
+ * 6. Interactive prompt: pick https / ssh / skip
397
+ *
398
+ * Returns null when the user / CI explicitly chose to skip the stage.
399
+ */
400
+ function resolveClaudeContextSource(cliRepo, cliProtocol, autoYes) {
401
+ return __awaiter(this, void 0, void 0, function* () {
402
+ const branch = process.env.GADMIN2_CLAUDE_CONTEXT_BRANCH || CLAUDE_CONTEXT_BRANCH;
403
+ // 1. CLI full-URL override
404
+ if (cliRepo) {
405
+ return { repo: cliRepo, branch };
406
+ }
407
+ // 2. CLI protocol override
408
+ const cliProto = (cliProtocol || '').toLowerCase();
409
+ if (cliProto === 'skip')
410
+ return null;
411
+ if (cliProto === 'ssh')
412
+ return { repo: CLAUDE_CONTEXT_REPO_SSH, branch };
413
+ if (cliProto === 'https')
414
+ return { repo: CLAUDE_CONTEXT_REPO_HTTPS, branch };
415
+ // 3. Env var full-URL
416
+ const envRepo = process.env.GADMIN2_CLAUDE_CONTEXT_REPO;
417
+ if (envRepo)
418
+ return { repo: envRepo, branch };
419
+ // 4. Env var protocol
420
+ const envProto = (process.env.GADMIN2_CLAUDE_CONTEXT_PROTOCOL || '').toLowerCase();
421
+ if (envProto === 'skip')
422
+ return null;
423
+ if (envProto === 'ssh')
424
+ return { repo: CLAUDE_CONTEXT_REPO_SSH, branch };
425
+ if (envProto === 'https')
426
+ return { repo: CLAUDE_CONTEXT_REPO_HTTPS, branch };
427
+ // 5. CI / auto-yes mode → silent default
428
+ if (autoYes)
429
+ return { repo: CLAUDE_CONTEXT_REPO_HTTPS, branch };
430
+ // 6. Interactive prompt
431
+ const { proto } = yield inquirer.prompt([
432
+ {
433
+ type: 'list',
434
+ name: 'proto',
435
+ message: 'Choose git access method for .claude context sync:',
436
+ choices: [
437
+ { name: `HTTPS (${CLAUDE_CONTEXT_REPO_HTTPS})`, value: 'https' },
438
+ { name: `SSH (${CLAUDE_CONTEXT_REPO_SSH})`, value: 'ssh' },
439
+ { name: 'Skip this stage', value: 'skip' },
440
+ ],
441
+ default: 'https',
442
+ },
443
+ ]);
444
+ if (proto === 'skip')
445
+ return null;
446
+ if (proto === 'ssh')
447
+ return { repo: CLAUDE_CONTEXT_REPO_SSH, branch };
448
+ return { repo: CLAUDE_CONTEXT_REPO_HTTPS, branch };
449
+ });
450
+ }
451
+ function syncClaudeContext(instanceDir, dryRun, source) {
387
452
  return __awaiter(this, void 0, void 0, function* () {
388
453
  console.info(chalk.bold('\n═══════════════════════════════════════════════════'));
389
454
  console.info(chalk.bold(' Sync .claude context'));
390
455
  console.info(chalk.bold('═══════════════════════════════════════════════════'));
391
- console.info(`${chalk.gray('Source: ')} ${CLAUDE_CONTEXT_REPO} (${CLAUDE_CONTEXT_BRANCH}) :: ${CLAUDE_SOURCE_SUBDIR}/`);
456
+ console.info(`${chalk.gray('Source: ')} ${source.repo} (${source.branch}) :: ${CLAUDE_SOURCE_SUBDIR}/`);
392
457
  console.info(`${chalk.gray('Targets:')} ${CLAUDE_TARGET_DIRS.map((d) => `${d}/`).join(', ')}\n`);
393
458
  if (dryRun) {
394
459
  console.info(chalk.gray('(dry-run mode — would clone the repo and copy remote files into target dirs, overwriting existing files; instance-only files are kept)\n'));
395
460
  return;
396
461
  }
397
- const claudeSrc = fetchClaudeContextRepo();
462
+ const claudeSrc = fetchClaudeContextRepo(source.repo, source.branch);
398
463
  if (!claudeSrc) {
399
464
  return;
400
465
  }
@@ -682,7 +747,7 @@ class UpdateAction extends abstract_action_1.AbstractAction {
682
747
  });
683
748
  }
684
749
  handleUpdate(options) {
685
- var _a, _b, _c, _d;
750
+ var _a, _b, _c, _d, _e, _f, _g;
686
751
  return __awaiter(this, void 0, void 0, function* () {
687
752
  const dryRun = (_a = options.find((o) => o.name === 'dry-run')) === null || _a === void 0 ? void 0 : _a.value;
688
753
  const autoYes = (_b = options.find((o) => o.name === 'yes')) === null || _b === void 0 ? void 0 : _b.value;
@@ -970,7 +1035,23 @@ class UpdateAction extends abstract_action_1.AbstractAction {
970
1035
  }
971
1036
  }
972
1037
  // 2. Sync .claude context (regardless of whether template had changes)
973
- yield syncClaudeContext(instanceDir, dryRun);
1038
+ const claudeEnabled = ((_e = options.find((o) => o.name === 'claude-context')) === null || _e === void 0 ? void 0 : _e.value) !==
1039
+ false;
1040
+ if (claudeEnabled) {
1041
+ const cliRepo = ((_f = options.find((o) => o.name === 'claude-context-repo')) === null || _f === void 0 ? void 0 : _f.value) ||
1042
+ '';
1043
+ const cliProtocol = ((_g = options.find((o) => o.name === 'claude-context-protocol')) === null || _g === void 0 ? void 0 : _g.value) || '';
1044
+ const claudeSource = yield resolveClaudeContextSource(cliRepo, cliProtocol, autoYes);
1045
+ if (claudeSource) {
1046
+ yield syncClaudeContext(instanceDir, dryRun, claudeSource);
1047
+ }
1048
+ else {
1049
+ console.info(chalk.gray('\nSkipping .claude context sync (per user choice / --no-claude-context).\n'));
1050
+ }
1051
+ }
1052
+ else {
1053
+ console.info(chalk.gray('\nSkipping .claude context sync (--no-claude-context).\n'));
1054
+ }
974
1055
  // 3. If web/server package.json changed during template update, install deps
975
1056
  yield maybeInstallChangedDeps(pkgSnapshots, dryRun);
976
1057
  });
@@ -31,6 +31,9 @@ class UpdateCommand extends abstract_command_1.AbstractCommand {
31
31
  .option('-y, --yes', '[update] Skip per-file prompt, use conflict markers for all.')
32
32
  .option('--no-smart-merge', '[update] Disable smart structural mergers; use line-level prompt for every file.')
33
33
  .option('--no-version-check', '[update | diff] Skip the npm registry version check at startup.')
34
+ .option('--claude-context-repo <url>', '[update] Fully override the .claude context repo URL (highest priority).')
35
+ .option('--claude-context-protocol <proto>', '[update] Force protocol for the built-in context repo. One of: https | ssh | skip.')
36
+ .option('--no-claude-context', '[update] Skip the .claude context sync stage entirely.')
34
37
  .action((subcommand, command) => __awaiter(this, void 0, void 0, function* () {
35
38
  const inputs = [];
36
39
  inputs.push({ name: 'subcommand', value: subcommand || '' });
@@ -40,6 +43,18 @@ class UpdateCommand extends abstract_command_1.AbstractCommand {
40
43
  options.push({ name: 'yes', value: !!command.yes });
41
44
  options.push({ name: 'smart-merge', value: command.smartMerge !== false });
42
45
  options.push({ name: 'version-check', value: command.versionCheck !== false });
46
+ options.push({
47
+ name: 'claude-context-repo',
48
+ value: command.claudeContextRepo || '',
49
+ });
50
+ options.push({
51
+ name: 'claude-context-protocol',
52
+ value: command.claudeContextProtocol || '',
53
+ });
54
+ options.push({
55
+ name: 'claude-context',
56
+ value: command.claudeContext !== false,
57
+ });
43
58
  yield this.action.handle(inputs, options);
44
59
  }));
45
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gadmin2n/cli",
3
- "version": "0.0.97",
3
+ "version": "0.0.100",
4
4
  "description": "Gadmin - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -47,7 +47,7 @@
47
47
  "@angular-devkit/core": "13.3.2",
48
48
  "@angular-devkit/schematics": "13.3.2",
49
49
  "@angular-devkit/schematics-cli": "13.3.2",
50
- "@gadmin2n/schematics": "^0.0.79",
50
+ "@gadmin2n/schematics": "^0.0.82",
51
51
  "abc": "^0.6.1",
52
52
  "chalk": "3.0.0",
53
53
  "chokidar": "3.5.3",