@ctxo/cli 0.9.0 → 0.9.2

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/README.md CHANGED
@@ -11,8 +11,9 @@
11
11
  </picture>
12
12
 
13
13
  ```Shell
14
- npx @ctxo/cli init
15
- npx @ctxo/cli index
14
+ npm install -g @ctxo/cli # one-time global install (gives you the `ctxo` command)
15
+ ctxo init
16
+ ctxo index
16
17
  ```
17
18
 
18
19
  <a href="https://alperhankendi.github.io/Ctxo/docs/">
@@ -494,6 +494,20 @@ function detectFromLockfileWalkUp(startDir) {
494
494
  }
495
495
  return null;
496
496
  }
497
+ function isWorkspaceRoot(projectRoot) {
498
+ if (existsSync4(join3(projectRoot, "pnpm-workspace.yaml"))) return true;
499
+ const pkgPath = join3(projectRoot, "package.json");
500
+ if (!existsSync4(pkgPath)) return false;
501
+ try {
502
+ const pkg = JSON.parse(readFileSync3(pkgPath, "utf-8"));
503
+ const ws = pkg.workspaces;
504
+ if (Array.isArray(ws) && ws.length > 0) return true;
505
+ if (ws && typeof ws === "object" && Array.isArray(ws.packages)) return true;
506
+ return false;
507
+ } catch {
508
+ return false;
509
+ }
510
+ }
497
511
  function buildInstallCommand(manager, packages, options = {}) {
498
512
  if (packages.length === 0) {
499
513
  throw new Error("buildInstallCommand requires at least one package");
@@ -505,10 +519,13 @@ function buildInstallCommand(manager, packages, options = {}) {
505
519
  args: options.global ? ["install", "-g", ...packages] : ["install", "-D", ...packages]
506
520
  };
507
521
  case "pnpm":
508
- return {
509
- command: "pnpm",
510
- args: options.global ? ["add", "-g", ...packages] : ["add", "-D", ...packages]
511
- };
522
+ if (options.global) {
523
+ return { command: "pnpm", args: ["add", "-g", ...packages] };
524
+ }
525
+ if (options.workspaceRoot) {
526
+ return { command: "pnpm", args: ["add", "-D", "-w", ...packages] };
527
+ }
528
+ return { command: "pnpm", args: ["add", "-D", ...packages] };
512
529
  case "yarn":
513
530
  return {
514
531
  command: "yarn",
@@ -525,12 +542,18 @@ function buildInstallCommand(manager, packages, options = {}) {
525
542
  // src/core/install/run-package-manager.ts
526
543
  import { spawn } from "child_process";
527
544
  function runPackageManager(command, args, cwd) {
545
+ const resolved = resolveBinary(command);
528
546
  return new Promise((resolve4, reject) => {
529
- const child = spawn(command, [...args], { cwd, stdio: "inherit", shell: process.platform === "win32" });
547
+ const child = spawn(resolved, [...args], { cwd, stdio: "inherit", shell: false });
530
548
  child.on("exit", (code) => resolve4(code ?? 0));
531
549
  child.on("error", (err) => reject(err));
532
550
  });
533
551
  }
552
+ function resolveBinary(command) {
553
+ if (process.platform !== "win32") return command;
554
+ if (command === "bun") return "bun.exe";
555
+ return `${command}.cmd`;
556
+ }
534
557
 
535
558
  // src/cli/install-command.ts
536
559
  var InstallCommand = class {
@@ -570,7 +593,8 @@ var InstallCommand = class {
570
593
  (lang) => options.version ? `${officialPluginFor(lang)}@${options.version}` : officialPluginFor(lang)
571
594
  );
572
595
  const invocation = buildInstallCommand(resolution.manager, specifiers, {
573
- global: options.global
596
+ global: options.global,
597
+ workspaceRoot: !options.global && isWorkspaceRoot(this.projectRoot)
574
598
  });
575
599
  const plan = {
576
600
  languages: resolvedLangs,
@@ -2210,8 +2234,8 @@ var InitCommand = class {
2210
2234
  const hasWork = selectedTools.length > 0 || installGitHooks;
2211
2235
  if (hasWork) {
2212
2236
  const steps = [
2213
- `${pc.cyan("\u25B6")} npx ctxo index ${pc.dim("\u2500 build codebase index")}`,
2214
- `${pc.cyan("\u25B6")} npx ctxo doctor ${pc.dim("\u2500 verify everything works")}`
2237
+ `${pc.cyan("\u25B6")} ctxo index ${pc.dim("\u2500 build codebase index")}`,
2238
+ `${pc.cyan("\u25B6")} ctxo doctor ${pc.dim("\u2500 verify everything works")}`
2215
2239
  ];
2216
2240
  console.error("");
2217
2241
  console.error(box(steps, { title: pc.cyan("\u2192 Next steps"), border: pc.cyan }, pc));
@@ -3608,7 +3632,7 @@ var DoctorCommand = class {
3608
3632
  this.ctxoRoot = join22(projectRoot, ".ctxo");
3609
3633
  }
3610
3634
  async run(options = {}) {
3611
- const { getVersion: getVersion2 } = await import("./cli-router-L34BRMXQ.js");
3635
+ const { getVersion: getVersion2 } = await import("./cli-router-IK3NJEKJ.js");
3612
3636
  console.error(`ctxo v${getVersion2()} \u2014 health check
3613
3637
  `);
3614
3638
  const checks = [
@@ -4158,7 +4182,10 @@ var UpdateCommand = class {
4158
4182
  });
4159
4183
  const specifiers = targets.map((t) => `${t.name}@${t.version}`);
4160
4184
  const useGlobal = options.global || !this.projectHasCtxoDep();
4161
- const invocation = buildInstallCommand(resolution.manager, specifiers, { global: useGlobal });
4185
+ const invocation = buildInstallCommand(resolution.manager, specifiers, {
4186
+ global: useGlobal,
4187
+ workspaceRoot: !useGlobal && isWorkspaceRoot(this.projectRoot)
4188
+ });
4162
4189
  return {
4163
4190
  manager: resolution.manager,
4164
4191
  managerSource: resolution.source,
@@ -4491,4 +4518,4 @@ export {
4491
4518
  getVersion,
4492
4519
  locateGitRoot
4493
4520
  };
4494
- //# sourceMappingURL=cli-router-L34BRMXQ.js.map
4521
+ //# sourceMappingURL=cli-router-IK3NJEKJ.js.map