@donotdev/cli 0.0.11 → 0.0.12

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.
@@ -255,7 +255,7 @@ function m(e2, u2) {
255
255
  const t = e2;
256
256
  t.isTTY && t.setRawMode(u2);
257
257
  }
258
- var import_sisteransi, uD, W, tD, eD, FD, sD, w, N, I, R, r, iD, CD, ED, d, oD, y, V, nD, G, _, z, K, aD, k, hD, lD, xD, B, AD, S, gD, vD, h, x, dD, A, kD, $D, H, SD;
258
+ var import_sisteransi, uD, W, tD, eD, FD, sD, w, N, I, R, r, iD, CD, ED, d, oD, y, V, nD, G, _, z, K, aD, k, hD, lD, xD, B, AD, S, gD, vD, h, x, dD, A, OD, PD, J, LD;
259
259
  var init_dist = __esm({
260
260
  "node_modules/.bun/@clack+prompts@0.11.0/node_modules/@clack/prompts/node_modules/@clack/core/dist/index.mjs"() {
261
261
  init_utils();
@@ -492,14 +492,12 @@ var init_dist = __esm({
492
492
  }
493
493
  };
494
494
  A = /* @__PURE__ */ new WeakMap();
495
- kD = Object.defineProperty;
496
- $D = (e2, u2, t) => u2 in e2 ? kD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
497
- H = (e2, u2, t) => ($D(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
498
- SD = class extends x {
495
+ OD = Object.defineProperty;
496
+ PD = (e2, u2, t) => u2 in e2 ? OD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
497
+ J = (e2, u2, t) => (PD(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
498
+ LD = class extends x {
499
499
  constructor(u2) {
500
- super(u2, false), H(this, "options"), H(this, "cursor", 0), this.options = u2.options, this.value = [...u2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: t }) => t === u2.cursorAt), 0), this.on("key", (t) => {
501
- t === "a" && this.toggleAll();
502
- }), this.on("cursor", (t) => {
500
+ super(u2, false), J(this, "options"), J(this, "cursor", 0), this.options = u2.options, this.cursor = this.options.findIndex(({ value: t }) => t === u2.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (t) => {
503
501
  switch (t) {
504
502
  case "left":
505
503
  case "up":
@@ -509,22 +507,15 @@ var init_dist = __esm({
509
507
  case "right":
510
508
  this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
511
509
  break;
512
- case "space":
513
- this.toggleValue();
514
- break;
515
510
  }
511
+ this.changeValue();
516
512
  });
517
513
  }
518
514
  get _value() {
519
- return this.options[this.cursor].value;
520
- }
521
- toggleAll() {
522
- const u2 = this.value.length === this.options.length;
523
- this.value = u2 ? [] : this.options.map((t) => t.value);
515
+ return this.options[this.cursor];
524
516
  }
525
- toggleValue() {
526
- const u2 = this.value.includes(this._value);
527
- this.value = u2 ? this.value.filter((t) => t !== this._value) : [...this.value, this._value];
517
+ changeValue() {
518
+ this.value = this._value.value;
528
519
  }
529
520
  };
530
521
  }
@@ -536,7 +527,7 @@ import y2 from "node:process";
536
527
  function ce() {
537
528
  return y2.platform !== "win32" ? y2.env.TERM !== "linux" : !!y2.env.CI || !!y2.env.WT_SESSION || !!y2.env.TERMINUS_SUBLIME || y2.env.ConEmuTask === "{cmd::Cmder}" || y2.env.TERM_PROGRAM === "Terminus-Sublime" || y2.env.TERM_PROGRAM === "vscode" || y2.env.TERM === "xterm-256color" || y2.env.TERM === "alacritty" || y2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
538
529
  }
539
- var import_picocolors, import_sisteransi2, V2, u, le, L2, W2, C, ue, o, d2, k2, P2, A2, T, F, $e, _2, me, de, pe, q, D, U, K2, b2, G2, ye, fe, xe, Ie, Se, M2, J;
530
+ var import_picocolors, import_sisteransi2, V2, u, le, L2, W2, C, ue, o, d2, k2, P2, A2, T, F, $e, _2, me, de, pe, q, D, U, K2, b2, G2, ye, ve, xe, Ie, Se, M2, J2;
540
531
  var init_dist2 = __esm({
541
532
  "node_modules/.bun/@clack+prompts@0.11.0/node_modules/@clack/prompts/dist/index.mjs"() {
542
533
  init_utils();
@@ -609,40 +600,32 @@ ${import_picocolors.default.cyan(d2)}
609
600
  }
610
601
  } }).prompt();
611
602
  };
612
- fe = (t) => {
603
+ ve = (t) => {
613
604
  const n = (r2, i) => {
614
605
  const s = r2.label ?? String(r2.value);
615
- return i === "active" ? `${import_picocolors.default.cyan(A2)} ${s} ${r2.hint ? import_picocolors.default.dim(`(${r2.hint})`) : ""}` : i === "selected" ? `${import_picocolors.default.green(T)} ${import_picocolors.default.dim(s)} ${r2.hint ? import_picocolors.default.dim(`(${r2.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}` : i === "active-selected" ? `${import_picocolors.default.green(T)} ${s} ${r2.hint ? import_picocolors.default.dim(`(${r2.hint})`) : ""}` : i === "submitted" ? `${import_picocolors.default.dim(s)}` : `${import_picocolors.default.dim(F)} ${import_picocolors.default.dim(s)}`;
606
+ switch (i) {
607
+ case "selected":
608
+ return `${import_picocolors.default.dim(s)}`;
609
+ case "active":
610
+ return `${import_picocolors.default.green(k2)} ${s} ${r2.hint ? import_picocolors.default.dim(`(${r2.hint})`) : ""}`;
611
+ case "cancelled":
612
+ return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}`;
613
+ default:
614
+ return `${import_picocolors.default.dim(P2)} ${import_picocolors.default.dim(s)}`;
615
+ }
616
616
  };
617
- return new SD({ options: t.options, initialValues: t.initialValues, required: t.required ?? true, cursorAt: t.cursorAt, validate(r2) {
618
- if (this.required && r2.length === 0) return `Please select at least one option.
619
- ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
620
- }, render() {
617
+ return new LD({ options: t.options, initialValue: t.initialValue, render() {
621
618
  const r2 = `${import_picocolors.default.gray(o)}
622
619
  ${b2(this.state)} ${t.message}
623
- `, i = (s, c) => {
624
- const a = this.value.includes(s.value);
625
- return c && a ? n(s, "active-selected") : a ? n(s, "selected") : n(s, c ? "active" : "inactive");
626
- };
620
+ `;
627
621
  switch (this.state) {
628
622
  case "submit":
629
- return `${r2}${import_picocolors.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none")}`;
630
- case "cancel": {
631
- const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors.default.dim(", "));
632
- return `${r2}${import_picocolors.default.gray(o)} ${s.trim() ? `${s}
633
- ${import_picocolors.default.gray(o)}` : ""}`;
634
- }
635
- case "error": {
636
- const s = this.error.split(`
637
- `).map((c, a) => a === 0 ? `${import_picocolors.default.yellow(d2)} ${import_picocolors.default.yellow(c)}` : ` ${c}`).join(`
638
- `);
639
- return `${r2 + import_picocolors.default.yellow(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
640
- ${import_picocolors.default.yellow(o)} `)}
641
- ${s}
642
- `;
643
- }
623
+ return `${r2}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
624
+ case "cancel":
625
+ return `${r2}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
626
+ ${import_picocolors.default.gray(o)}`;
644
627
  default:
645
- return `${r2}${import_picocolors.default.cyan(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
628
+ return `${r2}${import_picocolors.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
646
629
  ${import_picocolors.default.cyan(o)} `)}
647
630
  ${import_picocolors.default.cyan(d2)}
648
631
  `;
@@ -687,7 +670,7 @@ ${import_picocolors.default.gray(d2)} ${t}
687
670
  }, error: (t) => {
688
671
  M2.message(t, { symbol: import_picocolors.default.red(K2) });
689
672
  } };
690
- J = `${import_picocolors.default.gray(o)} `;
673
+ J2 = `${import_picocolors.default.gray(o)} `;
691
674
  }
692
675
  });
693
676
 
@@ -7706,6 +7689,9 @@ import {
7706
7689
  isAbsolute as pathIsAbsolute
7707
7690
  } from "node:path";
7708
7691
  import { fileURLToPath as fileURLToPath2 } from "node:url";
7692
+ function getDirnameFromUrl(importMetaUrl) {
7693
+ return dirname2(fileURLToPath2(importMetaUrl));
7694
+ }
7709
7695
  function detectExecutionMode() {
7710
7696
  const currentDir = process.cwd();
7711
7697
  const toolingPath = joinPath(currentDir, PACKAGE_PATHS.TOOLING);
@@ -7718,6 +7704,40 @@ function detectExecutionMode() {
7718
7704
  }
7719
7705
  return "published";
7720
7706
  }
7707
+ function getTemplatesRoot() {
7708
+ const mode = detectExecutionMode();
7709
+ if (mode === "development") {
7710
+ const repoRoot = getRepoRoot();
7711
+ return normalizePath(repoRoot, PACKAGE_PATHS.CLI, "templates");
7712
+ } else {
7713
+ try {
7714
+ const cliRoot2 = resolveFrameworkPackage("@donotdev/cli");
7715
+ if (cliRoot2) {
7716
+ const templatesPath = normalizePath(cliRoot2, "templates");
7717
+ if (pathExists(templatesPath)) {
7718
+ return templatesPath;
7719
+ }
7720
+ }
7721
+ } catch {
7722
+ }
7723
+ try {
7724
+ const req = createRequire2(import.meta.url);
7725
+ const cliPackageJsonPath = req.resolve("@donotdev/cli/package.json");
7726
+ const cliRoot2 = normalizePath(dirname2(cliPackageJsonPath));
7727
+ const templatesPath = normalizePath(cliRoot2, "templates");
7728
+ if (pathExists(templatesPath)) {
7729
+ return templatesPath;
7730
+ }
7731
+ } catch {
7732
+ }
7733
+ const cliRoot = getCliRootFromBundle();
7734
+ return normalizePath(cliRoot, "templates");
7735
+ }
7736
+ }
7737
+ function getCliRootFromBundle() {
7738
+ const currentDir = getDirnameFromUrl(import.meta.url);
7739
+ return normalizePath(currentDir, "..", "..", "..");
7740
+ }
7721
7741
  async function glob(pattern, options = {}) {
7722
7742
  const patterns = Array.isArray(pattern) ? pattern : [pattern];
7723
7743
  const cwd = options.cwd || pathResolverInstance.getAppRoot() || process.cwd();
@@ -7776,7 +7796,7 @@ function globSync(pattern, options = {}) {
7776
7796
  });
7777
7797
  return results.map((p2) => pathResolverInstance.normalizePath(p2));
7778
7798
  }
7779
- var pathResolverInstance, getRepoRoot, getAppRoot, normalizePath, pathExists, read, readSync, write, writeSync, ensureDir, getRelativePathBetween, getDirname, joinPath;
7799
+ var pathResolverInstance, getRepoRoot, getAppRoot, resolveFrameworkPackage, normalizePath, pathExists, read, readSync, write, writeSync, ensureDir, getRelativePathBetween, getDirname, joinPath;
7780
7800
  var init_pathResolver = __esm({
7781
7801
  "packages/tooling/src/utils/pathResolver.ts"() {
7782
7802
  "use strict";
@@ -7785,6 +7805,7 @@ var init_pathResolver = __esm({
7785
7805
  pathResolverInstance = PathResolver.getInstance({ debug: false });
7786
7806
  getRepoRoot = () => pathResolverInstance.getRepoRoot();
7787
7807
  getAppRoot = () => pathResolverInstance.getAppRoot();
7808
+ resolveFrameworkPackage = (name, from) => pathResolverInstance.resolveFrameworkPackage(name, from || null);
7788
7809
  normalizePath = (...pathSegments) => {
7789
7810
  return pathResolverInstance.normalizePath(join2(...pathSegments));
7790
7811
  };
@@ -7856,17 +7877,16 @@ async function askForConfirmation(message, defaultValue = false) {
7856
7877
  }
7857
7878
  return result;
7858
7879
  }
7859
- async function askForMultiSelection(message, choices, defaultIndices = []) {
7880
+ async function askForSelection(message, choices, defaultValue = 0) {
7860
7881
  const options = choices.map((choice) => ({
7861
7882
  value: choice.value,
7862
7883
  label: choice.title,
7863
7884
  hint: choice.hint
7864
7885
  }));
7865
- const initialValues = defaultIndices.map((i) => choices[i]?.value).filter(Boolean);
7866
- const result = await fe({
7886
+ const result = await ve({
7867
7887
  message,
7868
7888
  options,
7869
- initialValues: initialValues.length > 0 ? initialValues : void 0
7889
+ initialValue: choices[defaultValue]?.value
7870
7890
  });
7871
7891
  if (pD(result)) {
7872
7892
  xe("Operation cancelled.");
@@ -8047,40 +8067,17 @@ var PRESERVE_IF_EXISTS = [
8047
8067
  "CLAUDE.md"
8048
8068
  // User may have customized
8049
8069
  ];
8050
- function getInstalledCliTemplatesPath() {
8051
- const appRoot = getAppRoot();
8052
- if (!appRoot) return null;
8053
- const cliTemplatesPath = joinPath(
8054
- appRoot,
8055
- "node_modules",
8056
- "@donotdev",
8057
- "cli",
8058
- "templates",
8059
- "root-consumer"
8060
- );
8061
- if (pathExists(cliTemplatesPath)) {
8062
- return normalizePath(cliTemplatesPath);
8063
- }
8064
- return null;
8065
- }
8066
- function getFrameworkTemplatesPath() {
8067
- const possiblePaths = [
8068
- joinPath(process.cwd(), "..", "packages", "cli", "templates", "root-consumer"),
8069
- joinPath(process.cwd(), "packages", "cli", "templates", "root-consumer")
8070
- ];
8071
- for (const path of possiblePaths) {
8072
- if (pathExists(path)) {
8073
- return normalizePath(path);
8070
+ function getSourceTemplatesPath() {
8071
+ try {
8072
+ const templatesRoot = getTemplatesRoot();
8073
+ const rootConsumerPath = joinPath(templatesRoot, "root-consumer");
8074
+ if (pathExists(rootConsumerPath)) {
8075
+ return normalizePath(rootConsumerPath);
8074
8076
  }
8077
+ return null;
8078
+ } catch (error2) {
8079
+ return null;
8075
8080
  }
8076
- return null;
8077
- }
8078
- function getSourceTemplatesPath() {
8079
- const installed = getInstalledCliTemplatesPath();
8080
- if (installed) return installed;
8081
- const framework = getFrameworkTemplatesPath();
8082
- if (framework) return framework;
8083
- return null;
8084
8081
  }
8085
8082
  async function syncFile(sourcePath, destPath, preserveIfExists, appRoot) {
8086
8083
  const destPathWithoutExample = destPath.endsWith(".example") ? destPath.slice(0, -8) : destPath;
@@ -8190,10 +8187,16 @@ async function syncDocumentation(options = {}) {
8190
8187
  }
8191
8188
  const sourceRoot = getSourceTemplatesPath();
8192
8189
  if (!sourceRoot) {
8193
- log.error(
8194
- "Could not find framework templates. Make sure @donotdev/cli is installed."
8195
- );
8196
- return 1;
8190
+ log.warn("Could not find framework templates. Documentation sync skipped.");
8191
+ log.info("");
8192
+ log.info(" Templates are looked up the same way as create-project:");
8193
+ log.info(" \u2022 Published mode: node_modules/@donotdev/cli/templates");
8194
+ log.info(" \u2022 Dev mode: packages/cli/templates (from monorepo)");
8195
+ log.info("");
8196
+ log.info(" To enable docs sync:");
8197
+ log.info(" \u2022 Install @donotdev/cli: bun add -D @donotdev/cli");
8198
+ log.info(" \u2022 Or run from framework monorepo (dev mode)");
8199
+ return 0;
8197
8200
  }
8198
8201
  log.info(`Source templates: ${sourceRoot}`);
8199
8202
  log.info(`Destination: ${appRoot}`);
@@ -8287,20 +8290,24 @@ async function main(options = {}) {
8287
8290
  updatePackages = true;
8288
8291
  updateDocs = true;
8289
8292
  } else {
8290
- const selections = await askForMultiSelection(
8293
+ const choices = [
8294
+ { title: "Update packages", value: "packages", hint: "Update @donotdev/* packages and dependencies" },
8295
+ { title: "Sync documentation", value: "docs", hint: "Sync guides, commands, and agents from framework" },
8296
+ { title: "Both", value: "both", hint: "Update packages and sync documentation" }
8297
+ ];
8298
+ const selection = await askForSelection(
8291
8299
  "What would you like to update?",
8292
- [
8293
- { title: "Update packages", value: "packages", hint: "Update @donotdev/* packages and dependencies" },
8294
- { title: "Sync documentation", value: "docs", hint: "Sync guides, commands, and agents from framework" }
8295
- ],
8296
- [0, 1]
8297
- // Both selected by default
8300
+ choices,
8301
+ 2
8302
+ // Default to "Both"
8298
8303
  );
8299
- updatePackages = selections.includes("packages");
8300
- updateDocs = selections.includes("docs");
8301
- if (!updatePackages && !updateDocs) {
8302
- log.info("Nothing selected. Exiting.");
8303
- return 0;
8304
+ if (selection === "packages") {
8305
+ updatePackages = true;
8306
+ } else if (selection === "docs") {
8307
+ updateDocs = true;
8308
+ } else if (selection === "both") {
8309
+ updatePackages = true;
8310
+ updateDocs = true;
8304
8311
  }
8305
8312
  }
8306
8313
  if (updatePackages) {
@@ -8027,6 +8027,26 @@ function getTemplatesRoot() {
8027
8027
  const repoRoot = getRepoRoot();
8028
8028
  return normalizePath(repoRoot, PACKAGE_PATHS.CLI, "templates");
8029
8029
  } else {
8030
+ try {
8031
+ const cliRoot2 = resolveFrameworkPackage("@donotdev/cli");
8032
+ if (cliRoot2) {
8033
+ const templatesPath = normalizePath(cliRoot2, "templates");
8034
+ if (pathExists(templatesPath)) {
8035
+ return templatesPath;
8036
+ }
8037
+ }
8038
+ } catch {
8039
+ }
8040
+ try {
8041
+ const req = createRequire2(import.meta.url);
8042
+ const cliPackageJsonPath = req.resolve("@donotdev/cli/package.json");
8043
+ const cliRoot2 = normalizePath(dirname2(cliPackageJsonPath));
8044
+ const templatesPath = normalizePath(cliRoot2, "templates");
8045
+ if (pathExists(templatesPath)) {
8046
+ return templatesPath;
8047
+ }
8048
+ } catch {
8049
+ }
8030
8050
  const cliRoot = getCliRootFromBundle();
8031
8051
  return normalizePath(cliRoot, "templates");
8032
8052
  }
@@ -8027,6 +8027,26 @@ function getTemplatesRoot() {
8027
8027
  const repoRoot = getRepoRoot();
8028
8028
  return normalizePath(repoRoot, PACKAGE_PATHS.CLI, "templates");
8029
8029
  } else {
8030
+ try {
8031
+ const cliRoot2 = resolveFrameworkPackage("@donotdev/cli");
8032
+ if (cliRoot2) {
8033
+ const templatesPath = normalizePath(cliRoot2, "templates");
8034
+ if (pathExists(templatesPath)) {
8035
+ return templatesPath;
8036
+ }
8037
+ }
8038
+ } catch {
8039
+ }
8040
+ try {
8041
+ const req = createRequire2(import.meta.url);
8042
+ const cliPackageJsonPath = req.resolve("@donotdev/cli/package.json");
8043
+ const cliRoot2 = normalizePath(dirname2(cliPackageJsonPath));
8044
+ const templatesPath = normalizePath(cliRoot2, "templates");
8045
+ if (pathExists(templatesPath)) {
8046
+ return templatesPath;
8047
+ }
8048
+ } catch {
8049
+ }
8030
8050
  const cliRoot = getCliRootFromBundle();
8031
8051
  return normalizePath(cliRoot, "templates");
8032
8052
  }
package/dist/index.js CHANGED
@@ -8102,6 +8102,26 @@ function getTemplatesRoot() {
8102
8102
  const repoRoot = getRepoRoot();
8103
8103
  return normalizePath(repoRoot, PACKAGE_PATHS.CLI, "templates");
8104
8104
  } else {
8105
+ try {
8106
+ const cliRoot2 = resolveFrameworkPackage("@donotdev/cli");
8107
+ if (cliRoot2) {
8108
+ const templatesPath = normalizePath(cliRoot2, "templates");
8109
+ if (pathExists(templatesPath)) {
8110
+ return templatesPath;
8111
+ }
8112
+ }
8113
+ } catch {
8114
+ }
8115
+ try {
8116
+ const req = createRequire2(import.meta.url);
8117
+ const cliPackageJsonPath = req.resolve("@donotdev/cli/package.json");
8118
+ const cliRoot2 = normalizePath(dirname2(cliPackageJsonPath));
8119
+ const templatesPath = normalizePath(cliRoot2, "templates");
8120
+ if (pathExists(templatesPath)) {
8121
+ return templatesPath;
8122
+ }
8123
+ } catch {
8124
+ }
8105
8125
  const cliRoot = getCliRootFromBundle();
8106
8126
  return normalizePath(cliRoot, "templates");
8107
8127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/cli",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Command-line interface for DoNotDev Framework",
5
5
  "type": "module",
6
6
  "private": false,
@@ -68,7 +68,7 @@ export default function HomePage() {
68
68
  <RadioGroup
69
69
  value={currentPreset || 'landing'}
70
70
  onValueChange={(value) => setLayoutPreset(value as LayoutPreset)}
71
- gridCols={3}
71
+ gridCols={[1,1,3,3]}
72
72
  items={LAYOUT_PRESETS.map((preset) => ({
73
73
  value: preset,
74
74
  label: preset.charAt(0).toUpperCase() + preset.slice(1),