@intelligo-dev/cli 1.0.0-beta.13 → 1.0.0-beta.14

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.
Files changed (171) hide show
  1. package/README.md +41 -2
  2. package/dist/bin.js +37 -0
  3. package/dist/bin.js.map +1 -1
  4. package/dist/commands/add.d.ts +4 -0
  5. package/dist/commands/add.d.ts.map +1 -1
  6. package/dist/commands/add.js +9 -0
  7. package/dist/commands/add.js.map +1 -1
  8. package/dist/commands/create-flow.d.ts +4 -1
  9. package/dist/commands/create-flow.d.ts.map +1 -1
  10. package/dist/commands/create-flow.js +63 -31
  11. package/dist/commands/create-flow.js.map +1 -1
  12. package/dist/commands/create.d.ts +8 -4
  13. package/dist/commands/create.d.ts.map +1 -1
  14. package/dist/commands/create.js +15 -7
  15. package/dist/commands/create.js.map +1 -1
  16. package/dist/commands/doctor.d.ts.map +1 -1
  17. package/dist/commands/doctor.js +21 -19
  18. package/dist/commands/doctor.js.map +1 -1
  19. package/dist/commands/migrate-check.d.ts +20 -1
  20. package/dist/commands/migrate-check.d.ts.map +1 -1
  21. package/dist/commands/migrate-check.js +35 -6
  22. package/dist/commands/migrate-check.js.map +1 -1
  23. package/dist/commands/migrate.d.ts.map +1 -1
  24. package/dist/commands/migrate.js +2 -8
  25. package/dist/commands/migrate.js.map +1 -1
  26. package/dist/commands/sync-messages.d.ts +37 -0
  27. package/dist/commands/sync-messages.d.ts.map +1 -0
  28. package/dist/commands/sync-messages.js +88 -0
  29. package/dist/commands/sync-messages.js.map +1 -0
  30. package/dist/commands/sync-scaffold.d.ts +36 -0
  31. package/dist/commands/sync-scaffold.d.ts.map +1 -0
  32. package/dist/commands/sync-scaffold.js +53 -0
  33. package/dist/commands/sync-scaffold.js.map +1 -0
  34. package/dist/commands/sync.d.ts +103 -0
  35. package/dist/commands/sync.d.ts.map +1 -0
  36. package/dist/commands/sync.js +361 -0
  37. package/dist/commands/sync.js.map +1 -0
  38. package/dist/commands/upgrade-check.d.ts.map +1 -1
  39. package/dist/commands/upgrade-check.js +4 -1
  40. package/dist/commands/upgrade-check.js.map +1 -1
  41. package/dist/manifest.d.ts +27 -0
  42. package/dist/manifest.d.ts.map +1 -1
  43. package/dist/manifest.js +30 -3
  44. package/dist/manifest.js.map +1 -1
  45. package/dist/module-exports.d.ts +63 -0
  46. package/dist/module-exports.d.ts.map +1 -0
  47. package/dist/module-exports.js +231 -0
  48. package/dist/module-exports.js.map +1 -0
  49. package/dist/registry-bundle.d.ts +43 -0
  50. package/dist/registry-bundle.d.ts.map +1 -0
  51. package/dist/registry-bundle.js +74 -0
  52. package/dist/registry-bundle.js.map +1 -0
  53. package/dist/registry-items.d.ts +41 -13
  54. package/dist/registry-items.d.ts.map +1 -1
  55. package/dist/registry-items.js +117 -33
  56. package/dist/registry-items.js.map +1 -1
  57. package/package.json +1 -1
  58. package/src/bin.ts +52 -0
  59. package/src/commands/add.ts +11 -0
  60. package/src/commands/create-flow.ts +82 -26
  61. package/src/commands/create.ts +17 -7
  62. package/src/commands/doctor.ts +27 -27
  63. package/src/commands/migrate-check.ts +51 -10
  64. package/src/commands/migrate.ts +2 -8
  65. package/src/commands/sync-messages.ts +114 -0
  66. package/src/commands/sync-scaffold.ts +83 -0
  67. package/src/commands/sync.ts +534 -0
  68. package/src/commands/upgrade-check.ts +4 -1
  69. package/src/manifest.ts +57 -3
  70. package/src/module-exports.ts +266 -0
  71. package/src/registry-bundle.ts +103 -0
  72. package/src/registry-items.ts +141 -36
  73. package/templates/app-scaffold/intelligo.ts.tpl +6 -47
  74. package/templates/manifest.json +19 -0
  75. package/templates/registry/ai-agent-activity.json +23 -0
  76. package/templates/registry/ai-agent-progress.json +21 -0
  77. package/templates/registry/ai-approval-card.json +27 -0
  78. package/templates/registry/ai-artifact.json +22 -0
  79. package/templates/registry/ai-branch.json +21 -0
  80. package/templates/registry/ai-citations.json +24 -0
  81. package/templates/registry/ai-code-block.json +23 -0
  82. package/templates/registry/ai-composer-menu.json +19 -0
  83. package/templates/registry/ai-file-diff.json +25 -0
  84. package/templates/registry/ai-image-generation.json +23 -0
  85. package/templates/registry/ai-markdown.json +23 -0
  86. package/templates/registry/ai-message-bubble.json +23 -0
  87. package/templates/registry/ai-message-scroller.json +22 -0
  88. package/templates/registry/ai-message.json +21 -0
  89. package/templates/registry/ai-motion.json +19 -0
  90. package/templates/registry/ai-prompt-input.json +28 -0
  91. package/templates/registry/ai-reasoning-text.json +22 -0
  92. package/templates/registry/ai-reasoning.json +22 -0
  93. package/templates/registry/ai-shimmer-text.json +19 -0
  94. package/templates/registry/ai-sidebar.json +25 -0
  95. package/templates/registry/ai-speech-input.json +21 -0
  96. package/templates/registry/ai-streaming-response.json +24 -0
  97. package/templates/registry/ai-suggestion.json +19 -0
  98. package/templates/registry/ai-todo-list.json +22 -0
  99. package/templates/registry/ai-tool-approval.json +26 -0
  100. package/templates/registry/ai-tool-result.json +25 -0
  101. package/templates/registry/alert-dialog.json +23 -0
  102. package/templates/registry/animated-list.json +21 -0
  103. package/templates/registry/app-shell.json +93 -0
  104. package/templates/registry/artifacts.json +82 -0
  105. package/templates/registry/attachment.json +22 -0
  106. package/templates/registry/auth-email-verification.json +39 -0
  107. package/templates/registry/auth-login.json +72 -0
  108. package/templates/registry/auth-password-reset.json +53 -0
  109. package/templates/registry/auth-signup.json +41 -0
  110. package/templates/registry/billing-settings.json +60 -0
  111. package/templates/registry/button.json +22 -0
  112. package/templates/registry/chat-eve.json +19 -0
  113. package/templates/registry/chat-panel.json +30 -0
  114. package/templates/registry/chat-share.json +42 -0
  115. package/templates/registry/chat-widget.json +34 -0
  116. package/templates/registry/chat.json +326 -0
  117. package/templates/registry/checkbox.json +22 -0
  118. package/templates/registry/checkout.json +40 -0
  119. package/templates/registry/collapsible.json +19 -0
  120. package/templates/registry/command.json +23 -0
  121. package/templates/registry/copy-button.json +21 -0
  122. package/templates/registry/dashboard.json +69 -0
  123. package/templates/registry/dialog.json +24 -0
  124. package/templates/registry/document-viewer.json +22 -0
  125. package/templates/registry/dropdown-menu.json +23 -0
  126. package/templates/registry/expandable-tabs.json +22 -0
  127. package/templates/registry/feature-gating.json +73 -0
  128. package/templates/registry/file-upload.json +24 -0
  129. package/templates/registry/hold-action-button.json +22 -0
  130. package/templates/registry/input-group.json +23 -0
  131. package/templates/registry/input.json +19 -0
  132. package/templates/registry/intelligo.json +187 -0
  133. package/templates/registry/invitation-accept.json +64 -0
  134. package/templates/registry/language-switcher.json +29 -0
  135. package/templates/registry/morphing-modal.json +24 -0
  136. package/templates/registry/notification-stack.json +24 -0
  137. package/templates/registry/notifications.json +87 -0
  138. package/templates/registry/onboarding.json +83 -0
  139. package/templates/registry/otp-input.json +22 -0
  140. package/templates/registry/page-header.json +15 -0
  141. package/templates/registry/payment-poll.json +52 -0
  142. package/templates/registry/popover-morph.json +22 -0
  143. package/templates/registry/popover.json +22 -0
  144. package/templates/registry/pricing.json +111 -0
  145. package/templates/registry/privacy-settings.json +65 -0
  146. package/templates/registry/profile-settings.json +68 -0
  147. package/templates/registry/progress.json +19 -0
  148. package/templates/registry/radio-group.json +22 -0
  149. package/templates/registry/registry.json +2945 -0
  150. package/templates/registry/route-error.json +65 -0
  151. package/templates/registry/select-morph.json +23 -0
  152. package/templates/registry/select.json +23 -0
  153. package/templates/registry/settings-shell.json +47 -0
  154. package/templates/registry/sheet.json +24 -0
  155. package/templates/registry/sidebar.json +28 -0
  156. package/templates/registry/smoke.json +34 -0
  157. package/templates/registry/spinner.json +16 -0
  158. package/templates/registry/stat-card.json +18 -0
  159. package/templates/registry/status-badge.json +18 -0
  160. package/templates/registry/switch.json +20 -0
  161. package/templates/registry/tabs.json +23 -0
  162. package/templates/registry/team-settings.json +97 -0
  163. package/templates/registry/textarea.json +16 -0
  164. package/templates/registry/tooltip.json +22 -0
  165. package/templates/registry/trial-banner.json +43 -0
  166. package/templates/registry/usage.json +84 -0
  167. package/templates/registry/workspace-settings.json +71 -0
  168. package/templates/registry-items.json +1 -1
  169. package/templates/registry-requires.json +26 -2
  170. package/templates/vitest/server-only.ts.tpl +7 -0
  171. package/templates/vitest/vitest.config.ts.tpl +37 -0
@@ -0,0 +1,231 @@
1
+ /**
2
+ * What a TypeScript module exports, read from its text — enough for
3
+ * `doctor` to confirm an app provides the names an installed item
4
+ * imports, without compiling or running the app.
5
+ *
6
+ * It understands declarations (`export const|function|class|type|
7
+ * interface|enum …`), export lists with aliases (`export { a as b }`),
8
+ * re-exports (`export { x } from "…"`, `export * from "…"`) and the
9
+ * imports a bare export list re-exports. Modules are resolved the way
10
+ * the app would: relative paths, the `@/` alias, and packages through
11
+ * node resolution from the app's root (a workspace package included).
12
+ */
13
+ import { existsSync, readFileSync, statSync } from "node:fs";
14
+ import { createRequire } from "node:module";
15
+ import path from "node:path";
16
+ /**
17
+ * Block and line comments removed, so a check cannot be satisfied — or
18
+ * defeated — by prose.
19
+ */
20
+ export function stripComments(text) {
21
+ return text
22
+ .replace(/\/\*[\s\S]*?\*\//g, "")
23
+ .replace(/(^|[^:])\/\/.*$/gm, "$1");
24
+ }
25
+ export function escapeRegExp(text) {
26
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
27
+ }
28
+ const DECLARATION = /\bexport\s+(?:declare\s+)?(?:default\s+)?(?:abstract\s+)?(?:async\s+)?(?:const|let|var|function\s*\*?|class|type|interface|enum)\s+([A-Za-z_$][\w$]*)/g;
29
+ const EXPORT_LIST = /\bexport\s+(?:type\s+)?\{([^}]*)\}(?:\s*from\s*["']([^"']+)["'])?/g;
30
+ const EXPORT_STAR = /\bexport\s+(?:type\s+)?\*\s*(?:as\s+([A-Za-z_$][\w$]*)\s+)?from\s*["']([^"']+)["']/g;
31
+ const IMPORT = /\bimport\s+(?:type\s+)?([\w$]+\s*,?\s*)?(?:\{([^}]*)\}|\*\s*as\s+([\w$]+))?\s*from\s*["']([^"']+)["']/g;
32
+ /** `a`, `type a`, `a as b` → [local, exported]. */
33
+ function specifiers(list) {
34
+ return list
35
+ .split(",")
36
+ .map((s) => s.trim().replace(/^type\s+/, ""))
37
+ .filter(Boolean)
38
+ .map((s) => {
39
+ const [local, exported] = s.split(/\s+as\s+/).map((x) => x.trim());
40
+ return [local, exported ?? local];
41
+ });
42
+ }
43
+ /** The shape of a module's text; comments are stripped first. */
44
+ export function moduleShape(source) {
45
+ const text = stripComments(source);
46
+ const shape = {
47
+ names: new Set(),
48
+ reexports: new Map(),
49
+ stars: [],
50
+ imports: new Map(),
51
+ };
52
+ for (const m of text.matchAll(IMPORT)) {
53
+ const from = m[4];
54
+ const defaultName = m[1]?.replace(/[\s,]/g, "");
55
+ if (defaultName)
56
+ shape.imports.set(defaultName, from);
57
+ if (m[3])
58
+ shape.imports.set(m[3], from);
59
+ for (const [, local] of specifiers(m[2] ?? "")) {
60
+ shape.imports.set(local, from);
61
+ }
62
+ }
63
+ for (const m of text.matchAll(DECLARATION))
64
+ shape.names.add(m[1]);
65
+ for (const m of text.matchAll(EXPORT_LIST)) {
66
+ for (const [local, exported] of specifiers(m[1])) {
67
+ shape.names.add(exported);
68
+ const from = m[2] ?? shape.imports.get(local);
69
+ if (from)
70
+ shape.reexports.set(exported, from);
71
+ }
72
+ }
73
+ for (const m of text.matchAll(EXPORT_STAR)) {
74
+ if (m[1])
75
+ shape.names.add(m[1]);
76
+ else
77
+ shape.stars.push(m[2]);
78
+ }
79
+ return shape;
80
+ }
81
+ const EXTENSIONS = [".ts", ".tsx", ".mts", ".d.ts", ".js", ".mjs", ".jsx"];
82
+ function resolveFile(base) {
83
+ const isFile = (p) => existsSync(p) && statSync(p).isFile();
84
+ if (isFile(base))
85
+ return base;
86
+ // TypeScript sources import siblings with the `.js` they compile to.
87
+ const stem = base.replace(/\.(?:m?js|jsx)$/, "");
88
+ for (const ext of EXTENSIONS)
89
+ if (isFile(stem + ext))
90
+ return stem + ext;
91
+ for (const ext of EXTENSIONS) {
92
+ const index = path.join(base, `index${ext}`);
93
+ if (isFile(index))
94
+ return index;
95
+ }
96
+ return null;
97
+ }
98
+ /** The first file path an `exports` condition object leads to. */
99
+ function pickCondition(entry) {
100
+ if (typeof entry === "string")
101
+ return entry;
102
+ if (!entry || typeof entry !== "object")
103
+ return null;
104
+ const record = entry;
105
+ for (const key of ["import", "default", "node", "require", "types"]) {
106
+ const hit = key in record ? pickCondition(record[key]) : null;
107
+ if (hit)
108
+ return hit;
109
+ }
110
+ return null;
111
+ }
112
+ /** A package's module file from its package.json `exports`, `module` or `main`. */
113
+ function packageFile(specifier, appRoot) {
114
+ const parts = specifier.split("/");
115
+ const name = specifier.startsWith("@")
116
+ ? parts.slice(0, 2).join("/")
117
+ : parts[0];
118
+ const subpath = `.${specifier.slice(name.length)}`;
119
+ let dir = path.resolve(appRoot);
120
+ for (;;) {
121
+ const manifestFile = path.join(dir, "node_modules", name, "package.json");
122
+ if (existsSync(manifestFile)) {
123
+ const pkgDir = path.dirname(manifestFile);
124
+ const manifest = JSON.parse(readFileSync(manifestFile, "utf8"));
125
+ const exp = manifest.exports;
126
+ let target = null;
127
+ if (typeof exp === "string")
128
+ target = subpath === "." ? exp : null;
129
+ else if (exp && typeof exp === "object") {
130
+ const map = exp;
131
+ const keyed = Object.keys(map).some((k) => k.startsWith("."));
132
+ target = pickCondition(keyed ? map[subpath] : subpath === "." ? map : null);
133
+ }
134
+ if (!target && subpath === ".")
135
+ target = manifest.module ?? manifest.main ?? "index";
136
+ if (!target && subpath !== ".")
137
+ target = subpath;
138
+ return target ? resolveFile(path.join(pkgDir, target)) : null;
139
+ }
140
+ const parent = path.dirname(dir);
141
+ if (parent === dir)
142
+ return null;
143
+ dir = parent;
144
+ }
145
+ }
146
+ /**
147
+ * The file a module specifier leads to from `fromFile`, or null when it
148
+ * cannot be found: relative, the `@/` alias, then node resolution from
149
+ * the app's root.
150
+ */
151
+ export function resolveModule(specifier, fromFile, appRoot) {
152
+ if (specifier.startsWith(".")) {
153
+ return resolveFile(path.resolve(path.dirname(fromFile), specifier));
154
+ }
155
+ if (specifier.startsWith("@/")) {
156
+ return resolveFile(path.join(appRoot, specifier.slice(2)));
157
+ }
158
+ const fromPackage = packageFile(specifier, appRoot);
159
+ if (fromPackage)
160
+ return fromPackage;
161
+ try {
162
+ const resolved = createRequire(path.join(appRoot, "package.json")).resolve(specifier);
163
+ return existsSync(resolved) ? resolved : null;
164
+ }
165
+ catch {
166
+ return null;
167
+ }
168
+ }
169
+ /**
170
+ * Which of `names` the module at `file` does not export, following
171
+ * `export * from` into the modules it can resolve.
172
+ */
173
+ export function checkExports(file, names, appRoot, seen = new Set()) {
174
+ seen.add(file);
175
+ const shape = moduleShape(readFileSync(file, "utf8"));
176
+ let missing = names.filter((n) => !shape.names.has(n));
177
+ const unresolved = [];
178
+ for (const star of shape.stars) {
179
+ if (missing.length === 0)
180
+ break;
181
+ const target = resolveModule(star, file, appRoot);
182
+ if (!target) {
183
+ unresolved.push(star);
184
+ continue;
185
+ }
186
+ if (seen.has(target))
187
+ continue;
188
+ const inner = checkExports(target, missing, appRoot, seen);
189
+ missing = inner.missing;
190
+ unresolved.push(...inner.unresolved);
191
+ }
192
+ return unresolved.length > 0
193
+ ? { missing: [], unresolved }
194
+ : { missing, unresolved };
195
+ }
196
+ /**
197
+ * The text of a module and of every module it re-exports from —
198
+ * `export … from`, `export * from`, and imports a bare export list
199
+ * passes on — comments stripped. What a `lib/plans.ts` that re-exports
200
+ * a workspace package's catalogue actually defines.
201
+ */
202
+ export function reexportedSource(file, appRoot, depth = 3) {
203
+ const seen = new Set();
204
+ const unresolved = [];
205
+ const texts = [];
206
+ const visit = (current, left) => {
207
+ if (seen.has(current))
208
+ return;
209
+ seen.add(current);
210
+ const source = readFileSync(current, "utf8");
211
+ texts.push(stripComments(source));
212
+ if (left === 0)
213
+ return;
214
+ const shape = moduleShape(source);
215
+ for (const spec of new Set([...shape.reexports.values(), ...shape.stars])) {
216
+ const target = resolveModule(spec, current, appRoot);
217
+ if (target)
218
+ visit(target, left - 1);
219
+ else
220
+ unresolved.push(spec);
221
+ }
222
+ };
223
+ visit(file, depth);
224
+ return { text: texts.join("\n"), unresolved };
225
+ }
226
+ /** An object key `key:` or `"key":`, not a longer identifier ending in it. */
227
+ export function hasObjectKey(text, key) {
228
+ const k = escapeRegExp(key);
229
+ return new RegExp(`(?:(?<![\\w$-])${k}|["'\`]${k}["'\`])\\s*:`).test(text);
230
+ }
231
+ //# sourceMappingURL=module-exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-exports.js","sourceRoot":"","sources":["../src/module-exports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI;SACR,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;SAChC,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAaD,MAAM,WAAW,GACf,wJAAwJ,CAAC;AAC3J,MAAM,WAAW,GACf,oEAAoE,CAAC;AACvE,MAAM,WAAW,GACf,qFAAqF,CAAC;AACxF,MAAM,MAAM,GACV,wGAAwG,CAAC;AAE3G,mDAAmD;AACnD,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI;SACR,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;SAC5C,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;Q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,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC;AAChD,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,MAAM,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,IAAI,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The page registry as this CLI ships it.
3
+ *
4
+ * The build copies packages/registry/public/r — the same shadcn-schema
5
+ * JSON intelligo.dev/r serves — into templates/registry, so the items a
6
+ * CLI installs are the ones built with the packages of its own version:
7
+ * `@intelligo-dev/cli@X` syncs the pages of framework X, never whatever
8
+ * the site deployed last. In the framework repository, before a build,
9
+ * the freshly built registry stands in for the bundle.
10
+ */
11
+ export type RegistryFile = {
12
+ path: string;
13
+ type: string;
14
+ target?: string;
15
+ content?: string;
16
+ };
17
+ export type RegistryItemJson = {
18
+ name: string;
19
+ type: string;
20
+ files?: RegistryFile[];
21
+ registryDependencies?: string[];
22
+ };
23
+ /** How items name each other; resolved against this registry. */
24
+ export declare const NAMESPACE = "@intelligo/";
25
+ export declare function resolveRegistryDir(templatesDir: string): string | null;
26
+ export declare function hasRegistryItem(dir: string, name: string): boolean;
27
+ export declare function readRegistryItem(dir: string, name: string): RegistryItemJson;
28
+ /** Where shadcn writes a file of an item. */
29
+ export declare function installedPath(item: Pick<RegistryItemJson, "type">, file: RegistryFile): string | null;
30
+ /**
31
+ * A file as `shadcn add` writes it: the CLI drops the comment block that
32
+ * opens a file, so that header is not part of any comparison.
33
+ */
34
+ export declare function asInstalled(source: string): string;
35
+ /**
36
+ * The named items and every Intelligo item they pull in through
37
+ * `@intelligo/<name>`, transitively, dependencies first — the set of
38
+ * files one `shadcn add` of each name writes. Dependencies outside the
39
+ * namespace (shadcn's own `utils`, `skeleton`…) are not this registry's
40
+ * to check.
41
+ */
42
+ export declare function registryClosure(dir: string, names: readonly string[]): string[];
43
+ //# sourceMappingURL=registry-bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-bundle.d.ts","sourceRoot":"","sources":["../src/registry-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,SAAS,gBAAgB,CAAC;AAEvC,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUtE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAIlE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAO5E;AAED,6CAA6C;AAC7C,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,EACpC,IAAI,EAAE,YAAY,GACjB,MAAM,GAAG,IAAI,CAMf;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,MAAM,EAAE,CAcV"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The page registry as this CLI ships it.
3
+ *
4
+ * The build copies packages/registry/public/r — the same shadcn-schema
5
+ * JSON intelligo.dev/r serves — into templates/registry, so the items a
6
+ * CLI installs are the ones built with the packages of its own version:
7
+ * `@intelligo-dev/cli@X` syncs the pages of framework X, never whatever
8
+ * the site deployed last. In the framework repository, before a build,
9
+ * the freshly built registry stands in for the bundle.
10
+ */
11
+ import { existsSync, readFileSync } from "node:fs";
12
+ import path from "node:path";
13
+ /** How items name each other; resolved against this registry. */
14
+ export const NAMESPACE = "@intelligo/";
15
+ export function resolveRegistryDir(templatesDir) {
16
+ const candidates = [
17
+ path.join(templatesDir, "registry"),
18
+ // packages/cli/templates → packages/registry/public/r
19
+ path.resolve(templatesDir, "..", "..", "registry", "public", "r"),
20
+ ];
21
+ return (candidates.find((dir) => existsSync(path.join(dir, "intelligo.json"))) ??
22
+ null);
23
+ }
24
+ export function hasRegistryItem(dir, name) {
25
+ return (/^[a-z0-9-]+$/.test(name) && existsSync(path.join(dir, `${name}.json`)));
26
+ }
27
+ export function readRegistryItem(dir, name) {
28
+ if (!hasRegistryItem(dir, name)) {
29
+ throw new Error(`Unknown registry item "${name}".`);
30
+ }
31
+ return JSON.parse(readFileSync(path.join(dir, `${name}.json`), "utf8"));
32
+ }
33
+ /** Where shadcn writes a file of an item. */
34
+ export function installedPath(item, file) {
35
+ if (file.target)
36
+ return file.target;
37
+ if (item.type === "registry:ui") {
38
+ return `components/ui/${path.basename(file.path)}`;
39
+ }
40
+ return null;
41
+ }
42
+ /**
43
+ * A file as `shadcn add` writes it: the CLI drops the comment block that
44
+ * opens a file, so that header is not part of any comparison.
45
+ */
46
+ export function asInstalled(source) {
47
+ return source.replace(/^(?:\s*(?:\/\*[\s\S]*?\*\/|\/\/[^\n]*))*\s*/, "");
48
+ }
49
+ /**
50
+ * The named items and every Intelligo item they pull in through
51
+ * `@intelligo/<name>`, transitively, dependencies first — the set of
52
+ * files one `shadcn add` of each name writes. Dependencies outside the
53
+ * namespace (shadcn's own `utils`, `skeleton`…) are not this registry's
54
+ * to check.
55
+ */
56
+ export function registryClosure(dir, names) {
57
+ const order = [];
58
+ const seen = new Set();
59
+ const visit = (name) => {
60
+ if (seen.has(name))
61
+ return;
62
+ seen.add(name);
63
+ const item = readRegistryItem(dir, name);
64
+ for (const dep of item.registryDependencies ?? []) {
65
+ if (dep.startsWith(NAMESPACE))
66
+ visit(dep.slice(NAMESPACE.length));
67
+ }
68
+ order.push(name);
69
+ };
70
+ for (const name of names)
71
+ visit(name);
72
+ return order;
73
+ }
74
+ //# sourceMappingURL=registry-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-bundle.js","sourceRoot":"","sources":["../src/registry-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAgB7B,iEAAiE;AACjE,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC;AAEvC,MAAM,UAAU,kBAAkB,CAAC,YAAoB;IACrD,MAAM,UAAU,GAAG;QACjB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;QACnC,sDAAsD;QACtD,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,CAAC;KAClE,CAAC;IACF,OAAO,CACL,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC;QACtE,IAAI,CACL,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,IAAY;IACvD,OAAO,CACL,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,IAA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C;QACzC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,oBAAoB,IAAI,EAAE,EAAE,CAAC;YAClD,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;gBAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACpE,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -3,11 +3,10 @@
3
3
  * is, what else it needs installed first, and the commands that install
4
4
  * a selection into a fresh app.
5
5
  *
6
- * Installing is the shadcn CLI's job, not this package's — the items
7
- * are shadcn-schema JSON served at intelligo.dev/r, and the scaffold's
8
- * components.json already names that registry as `@intelligo`. What the
9
- * CLI adds is the order: an item that imports a sibling's files
10
- * (requires.json `items`) has to land after it.
6
+ * Installing goes through `intelligo sync` (commands/sync.ts): one
7
+ * `shadcn add` per item from the registry bundled with this CLI, in the
8
+ * order requires.json `items` implies — an item that imports a
9
+ * sibling's files lands after it.
11
10
  */
12
11
  import type { RegistryRequires } from "./commands/doctor.js";
13
12
  export type RegistryItem = {
@@ -37,20 +36,49 @@ export declare function detectPackageManager(userAgent?: string | undefined): Pa
37
36
  export type Command = {
38
37
  command: string;
39
38
  args: string[];
39
+ /** Where it runs, when not the app itself (a parent workspace's root). */
40
+ cwd?: string;
40
41
  };
41
- export declare function formatCommand(c: Command): string;
42
+ /**
43
+ * The command as a reader pastes it from `from` (the app's directory):
44
+ * a command that runs elsewhere is wrapped in a `cd`.
45
+ */
46
+ export declare function formatCommand(c: Command, from?: string): string;
42
47
  /** Whether the app has its own shadcn binary, i.e. dependencies are installed. */
43
48
  export declare function hasLocalShadcn(appRoot: string): boolean;
49
+ /** The `packages:` globs of a pnpm-workspace.yaml (`!` exclusions kept). */
50
+ export declare function workspaceGlobs(yaml: string): string[];
51
+ /**
52
+ * The root of the pnpm workspace that has `appRoot` as a member, if
53
+ * any: the nearest pnpm-workspace.yaml above the app, when one of its
54
+ * `packages` globs matches the app's path and no `!` glob excludes it.
55
+ * Installing from there updates the workspace's one lockfile instead of
56
+ * starting a nested one in the app.
57
+ */
58
+ export declare function findWorkspaceRoot(appRoot: string): string | null;
59
+ export type InstallPlan = {
60
+ /**
61
+ * The dependency install, when shadcn is not there yet (the scaffold
62
+ * declares it) — run from the parent workspace's root when the app is
63
+ * a member of one.
64
+ */
65
+ install: Command | null;
66
+ /** The items `intelligo sync` installs: the base first, then the pages in dependency order. */
67
+ items: string[];
68
+ /** The same sync as a command, for a reader to run by hand. */
69
+ sync: Command;
70
+ };
44
71
  /**
45
- * The commands that put `items` into the app at `appRoot`: install the
46
- * dependencies when shadcn is not there yet (the scaffold declares it),
47
- * then the design-system base, then the items in dependency order.
48
- * `--overwrite` because the base replaces the scaffold's globals.css,
49
- * and items that share a file agree on it — the same flags the
50
- * reference app is regenerated with.
72
+ * How `items` get into the app at `appRoot`: the dependencies first
73
+ * when shadcn is missing, then `intelligo sync` of the base and every
74
+ * item — one `shadcn add` per item in dependency order, from the
75
+ * registry bundled with this CLI, with `--force` because a fresh
76
+ * scaffold's files (globals.css, the theme provider) are the registry's
77
+ * to replace. Null when nothing was picked.
51
78
  */
52
79
  export declare function installPlan(items: readonly string[], options: {
53
80
  appRoot: string;
54
81
  packageManager: PackageManager;
55
- }): Command[];
82
+ workspaceRoot?: string | null;
83
+ }): InstallPlan | null;
56
84
  //# sourceMappingURL=registry-items.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry-items.d.ts","sourceRoot":"","sources":["../src/registry-items.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,MAAM,CA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AE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoBhE;AAKD,MAAM,MAAM,WAAW,GAAG;IACxB;;;;OAIG;IACH,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,+FAA+F;IAC/F,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,+DAA+D;IAC/D,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,GACA,WAAW,GAAG,IAAI,CAsBpB"}
@@ -3,11 +3,10 @@
3
3
  * is, what else it needs installed first, and the commands that install
4
4
  * a selection into a fresh app.
5
5
  *
6
- * Installing is the shadcn CLI's job, not this package's — the items
7
- * are shadcn-schema JSON served at intelligo.dev/r, and the scaffold's
8
- * components.json already names that registry as `@intelligo`. What the
9
- * CLI adds is the order: an item that imports a sibling's files
10
- * (requires.json `items`) has to land after it.
6
+ * Installing goes through `intelligo sync` (commands/sync.ts): one
7
+ * `shadcn add` per item from the registry bundled with this CLI, in the
8
+ * order requires.json `items` implies — an item that imports a
9
+ * sibling's files lands after it.
11
10
  */
12
11
  import { existsSync, readFileSync } from "node:fs";
13
12
  import path from "node:path";
@@ -56,8 +55,16 @@ export function detectPackageManager(userAgent = process.env.npm_config_user_age
56
55
  const name = userAgent?.split("/")[0];
57
56
  return name === "npm" || name === "yarn" || name === "bun" ? name : "pnpm";
58
57
  }
59
- export function formatCommand(c) {
60
- return [c.command, ...c.args].join(" ");
58
+ /**
59
+ * The command as a reader pastes it from `from` (the app's directory):
60
+ * a command that runs elsewhere is wrapped in a `cd`.
61
+ */
62
+ export function formatCommand(c, from) {
63
+ const line = [c.command, ...c.args].join(" ");
64
+ if (!c.cwd || !from || path.resolve(c.cwd) === path.resolve(from)) {
65
+ return line;
66
+ }
67
+ return `(cd ${path.relative(from, c.cwd) || "."} && ${line})`;
61
68
  }
62
69
  const EXEC = {
63
70
  pnpm: ["pnpm", "exec"],
@@ -69,35 +76,112 @@ const EXEC = {
69
76
  export function hasLocalShadcn(appRoot) {
70
77
  return existsSync(path.join(appRoot, "node_modules", ".bin", "shadcn"));
71
78
  }
79
+ /** The `packages:` globs of a pnpm-workspace.yaml (`!` exclusions kept). */
80
+ export function workspaceGlobs(yaml) {
81
+ const globs = [];
82
+ let inPackages = false;
83
+ for (const raw of yaml.split(/\r?\n/)) {
84
+ const line = raw.replace(/\s+#.*$/, "");
85
+ const key = /^packages\s*:\s*(.*)$/.exec(line);
86
+ if (key) {
87
+ const flow = /^\[(.*)\]$/.exec(key[1].trim());
88
+ if (flow) {
89
+ for (const g of flow[1].split(",")) {
90
+ const glob = g.trim().replace(/^["']|["']$/g, "");
91
+ if (glob)
92
+ globs.push(glob);
93
+ }
94
+ }
95
+ else
96
+ inPackages = true;
97
+ continue;
98
+ }
99
+ if (!inPackages)
100
+ continue;
101
+ const entry = /^\s+-\s*(.+?)\s*$/.exec(line);
102
+ if (entry)
103
+ globs.push(entry[1].replace(/^["']|["']$/g, ""));
104
+ else if (/^\S/.test(line))
105
+ inPackages = false;
106
+ }
107
+ return globs;
108
+ }
109
+ function globToRegExp(glob) {
110
+ const pattern = glob
111
+ .replace(/^\.\//, "")
112
+ .replace(/\/+$/, "")
113
+ .split(/(\*\*|\*|\?)/)
114
+ .map((part) => part === "**"
115
+ ? ".*"
116
+ : part === "*"
117
+ ? "[^/]*"
118
+ : part === "?"
119
+ ? "[^/]"
120
+ : part.replace(/[.+^${}()|[\]\\]/g, "\\$&"))
121
+ .join("");
122
+ return new RegExp(`^${pattern}$`);
123
+ }
72
124
  /**
73
- * The commands that put `items` into the app at `appRoot`: install the
74
- * dependencies when shadcn is not there yet (the scaffold declares it),
75
- * then the design-system base, then the items in dependency order.
76
- * `--overwrite` because the base replaces the scaffold's globals.css,
77
- * and items that share a file agree on it — the same flags the
78
- * reference app is regenerated with.
125
+ * The root of the pnpm workspace that has `appRoot` as a member, if
126
+ * any: the nearest pnpm-workspace.yaml above the app, when one of its
127
+ * `packages` globs matches the app's path and no `!` glob excludes it.
128
+ * Installing from there updates the workspace's one lockfile instead of
129
+ * starting a nested one in the app.
130
+ */
131
+ export function findWorkspaceRoot(appRoot) {
132
+ const app = path.resolve(appRoot);
133
+ let dir = path.dirname(app);
134
+ for (;;) {
135
+ const file = path.join(dir, "pnpm-workspace.yaml");
136
+ if (existsSync(file)) {
137
+ const rel = path.relative(dir, app).split(path.sep).join("/");
138
+ const globs = workspaceGlobs(readFileSync(file, "utf8"));
139
+ const included = globs
140
+ .filter((g) => !g.startsWith("!"))
141
+ .some((g) => globToRegExp(g).test(rel));
142
+ const excluded = globs
143
+ .filter((g) => g.startsWith("!"))
144
+ .some((g) => globToRegExp(g.slice(1)).test(rel));
145
+ return included && !excluded ? dir : null;
146
+ }
147
+ const parent = path.dirname(dir);
148
+ if (parent === dir)
149
+ return null;
150
+ dir = parent;
151
+ }
152
+ }
153
+ /** The design-system base, installed before any page. */
154
+ const BASE = "intelligo";
155
+ /**
156
+ * How `items` get into the app at `appRoot`: the dependencies first
157
+ * when shadcn is missing, then `intelligo sync` of the base and every
158
+ * item — one `shadcn add` per item in dependency order, from the
159
+ * registry bundled with this CLI, with `--force` because a fresh
160
+ * scaffold's files (globals.css, the theme provider) are the registry's
161
+ * to replace. Null when nothing was picked.
79
162
  */
80
163
  export function installPlan(items, options) {
81
164
  if (items.length === 0)
82
- return [];
83
- const [command, ...exec] = EXEC[options.packageManager];
84
- const add = (names) => ({
85
- command: command,
86
- args: [
87
- ...exec,
88
- "shadcn",
89
- "add",
90
- ...names.map((n) => `@intelligo/${n}`),
91
- "--yes",
92
- "--overwrite",
93
- ],
94
- });
95
- return [
96
- ...(hasLocalShadcn(options.appRoot)
97
- ? []
98
- : [{ command: options.packageManager, args: ["install"] }]),
99
- add(["intelligo"]),
100
- add([...items]),
101
- ];
165
+ return null;
166
+ const packageManager = options.workspaceRoot
167
+ ? "pnpm"
168
+ : options.packageManager;
169
+ const [command, ...exec] = EXEC[packageManager];
170
+ const synced = [BASE, ...items.filter((n) => n !== BASE)];
171
+ return {
172
+ install: hasLocalShadcn(options.appRoot)
173
+ ? null
174
+ : {
175
+ command: packageManager,
176
+ args: ["install"],
177
+ cwd: options.workspaceRoot ?? options.appRoot,
178
+ },
179
+ items: synced,
180
+ sync: {
181
+ command: command,
182
+ args: [...exec, "intelligo", "sync", ...synced, "--force"],
183
+ cwd: options.appRoot,
184
+ },
185
+ };
102
186
  }
103
187
  //# sourceMappingURL=registry-items.js.map