@databricks/appkit 0.2.0 → 0.4.0

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 (248) hide show
  1. package/CLAUDE.md +121 -1228
  2. package/NOTICE.md +1 -1
  3. package/bin/appkit.js +3 -0
  4. package/dist/analytics/analytics.d.ts.map +1 -1
  5. package/dist/analytics/analytics.js +17 -30
  6. package/dist/analytics/analytics.js.map +1 -1
  7. package/dist/app/index.d.ts +5 -1
  8. package/dist/app/index.d.ts.map +1 -1
  9. package/dist/app/index.js +38 -9
  10. package/dist/app/index.js.map +1 -1
  11. package/dist/appkit/package.js +1 -1
  12. package/dist/cache/index.js +3 -3
  13. package/dist/cache/index.js.map +1 -1
  14. package/dist/cli/commands/docs.js +47 -0
  15. package/dist/cli/commands/docs.js.map +1 -0
  16. package/dist/cli/commands/generate-types.js +38 -0
  17. package/dist/cli/commands/generate-types.js.map +1 -0
  18. package/dist/cli/commands/lint.js +104 -0
  19. package/dist/cli/commands/lint.js.map +1 -0
  20. package/dist/cli/commands/setup.js +121 -0
  21. package/dist/cli/commands/setup.js.map +1 -0
  22. package/dist/cli/index.d.ts +1 -0
  23. package/dist/cli/index.js +24 -0
  24. package/dist/cli/index.js.map +1 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/plugin/plugin.d.ts +1 -0
  27. package/dist/plugin/plugin.d.ts.map +1 -1
  28. package/dist/plugin/plugin.js +1 -0
  29. package/dist/plugin/plugin.js.map +1 -1
  30. package/dist/server/remote-tunnel/remote-tunnel-manager.js +9 -9
  31. package/dist/server/remote-tunnel/remote-tunnel-manager.js.map +1 -1
  32. package/dist/server/utils.js +6 -6
  33. package/dist/server/utils.js.map +1 -1
  34. package/dist/shared/src/execute.d.ts +1 -0
  35. package/dist/shared/src/execute.d.ts.map +1 -1
  36. package/dist/shared/src/plugin.d.ts +3 -0
  37. package/dist/shared/src/plugin.d.ts.map +1 -1
  38. package/dist/telemetry/types.d.ts +1 -0
  39. package/dist/telemetry/types.d.ts.map +1 -1
  40. package/dist/type-generator/index.js +1 -1
  41. package/dist/type-generator/index.js.map +1 -1
  42. package/dist/type-generator/query-registry.js +9 -1
  43. package/dist/type-generator/query-registry.js.map +1 -1
  44. package/docs/docs/api/appkit/Class.AppKitError/index.html +77 -0
  45. package/docs/docs/api/appkit/Class.AppKitError.md +154 -0
  46. package/docs/docs/api/appkit/Class.AuthenticationError/index.html +110 -0
  47. package/docs/docs/api/appkit/Class.AuthenticationError.md +236 -0
  48. package/docs/docs/api/appkit/Class.ConfigurationError/index.html +112 -0
  49. package/docs/docs/api/appkit/Class.ConfigurationError.md +243 -0
  50. package/docs/docs/api/appkit/Class.ConnectionError/index.html +120 -0
  51. package/docs/docs/api/appkit/Class.ConnectionError.md +265 -0
  52. package/docs/docs/api/appkit/Class.ExecutionError/index.html +116 -0
  53. package/docs/docs/api/appkit/Class.ExecutionError.md +250 -0
  54. package/docs/docs/api/appkit/Class.InitializationError/index.html +104 -0
  55. package/docs/docs/api/appkit/Class.InitializationError.md +222 -0
  56. package/docs/docs/api/appkit/Class.Plugin/index.html +149 -0
  57. package/docs/docs/api/appkit/Class.Plugin.md +392 -0
  58. package/docs/docs/api/appkit/Class.ServerError/index.html +108 -0
  59. package/docs/docs/api/appkit/Class.ServerError.md +229 -0
  60. package/docs/docs/api/appkit/Class.TunnelError/index.html +108 -0
  61. package/docs/docs/api/appkit/Class.TunnelError.md +231 -0
  62. package/docs/docs/api/appkit/Class.ValidationError/index.html +106 -0
  63. package/docs/docs/api/appkit/Class.ValidationError.md +225 -0
  64. package/docs/docs/api/appkit/Function.appKitTypesPlugin/index.html +24 -0
  65. package/docs/docs/api/appkit/Function.appKitTypesPlugin.md +20 -0
  66. package/docs/docs/api/appkit/Function.createApp/index.html +24 -0
  67. package/docs/docs/api/appkit/Function.createApp.md +31 -0
  68. package/docs/docs/api/appkit/Function.isSQLTypeMarker/index.html +25 -0
  69. package/docs/docs/api/appkit/Function.isSQLTypeMarker.md +32 -0
  70. package/docs/docs/api/appkit/Interface.BasePluginConfig/index.html +28 -0
  71. package/docs/docs/api/appkit/Interface.BasePluginConfig.md +37 -0
  72. package/docs/docs/api/appkit/Interface.CacheConfig/index.html +63 -0
  73. package/docs/docs/api/appkit/Interface.CacheConfig.md +131 -0
  74. package/docs/docs/api/appkit/Interface.ITelemetry/index.html +73 -0
  75. package/docs/docs/api/appkit/Interface.ITelemetry.md +144 -0
  76. package/docs/docs/api/appkit/Interface.StreamExecutionSettings/index.html +26 -0
  77. package/docs/docs/api/appkit/Interface.StreamExecutionSettings.md +30 -0
  78. package/docs/docs/api/appkit/Interface.TelemetryConfig/index.html +32 -0
  79. package/docs/docs/api/appkit/Interface.TelemetryConfig.md +48 -0
  80. package/docs/docs/api/appkit/TypeAlias.IAppRouter/index.html +18 -0
  81. package/docs/docs/api/appkit/TypeAlias.IAppRouter.md +8 -0
  82. package/docs/docs/api/appkit/Variable.sql/index.html +98 -0
  83. package/docs/docs/api/appkit/Variable.sql.md +260 -0
  84. package/docs/docs/api/appkit/index.html +28 -0
  85. package/docs/docs/api/appkit-ui/data/AreaChart/index.html +29 -0
  86. package/docs/docs/api/appkit-ui/data/AreaChart.md +79 -0
  87. package/docs/docs/api/appkit-ui/data/BarChart/index.html +29 -0
  88. package/docs/docs/api/appkit-ui/data/BarChart.md +74 -0
  89. package/docs/docs/api/appkit-ui/data/DataTable/index.html +36 -0
  90. package/docs/docs/api/appkit-ui/data/DataTable.md +69 -0
  91. package/docs/docs/api/appkit-ui/data/DonutChart/index.html +29 -0
  92. package/docs/docs/api/appkit-ui/data/DonutChart.md +72 -0
  93. package/docs/docs/api/appkit-ui/data/HeatmapChart/index.html +35 -0
  94. package/docs/docs/api/appkit-ui/data/HeatmapChart.md +91 -0
  95. package/docs/docs/api/appkit-ui/data/LineChart/index.html +29 -0
  96. package/docs/docs/api/appkit-ui/data/LineChart.md +77 -0
  97. package/docs/docs/api/appkit-ui/data/PieChart/index.html +29 -0
  98. package/docs/docs/api/appkit-ui/data/PieChart.md +72 -0
  99. package/docs/docs/api/appkit-ui/data/RadarChart/index.html +29 -0
  100. package/docs/docs/api/appkit-ui/data/RadarChart.md +74 -0
  101. package/docs/docs/api/appkit-ui/data/ScatterChart/index.html +29 -0
  102. package/docs/docs/api/appkit-ui/data/ScatterChart.md +76 -0
  103. package/docs/docs/api/appkit-ui/index.html +23 -0
  104. package/docs/docs/api/appkit-ui/styling/index.html +74 -0
  105. package/docs/docs/api/appkit-ui/styling.md +81 -0
  106. package/docs/docs/api/appkit-ui/ui/Accordion/index.html +48 -0
  107. package/docs/docs/api/appkit-ui/ui/Accordion.md +139 -0
  108. package/docs/docs/api/appkit-ui/ui/Alert/index.html +41 -0
  109. package/docs/docs/api/appkit-ui/ui/Alert.md +89 -0
  110. package/docs/docs/api/appkit-ui/ui/AlertDialog/index.html +97 -0
  111. package/docs/docs/api/appkit-ui/ui/AlertDialog.md +282 -0
  112. package/docs/docs/api/appkit-ui/ui/AspectRatio/index.html +27 -0
  113. package/docs/docs/api/appkit-ui/ui/AspectRatio.md +46 -0
  114. package/docs/docs/api/appkit-ui/ui/Avatar/index.html +41 -0
  115. package/docs/docs/api/appkit-ui/ui/Avatar.md +90 -0
  116. package/docs/docs/api/appkit-ui/ui/Badge/index.html +27 -0
  117. package/docs/docs/api/appkit-ui/ui/Badge.md +38 -0
  118. package/docs/docs/api/appkit-ui/ui/Breadcrumb/index.html +69 -0
  119. package/docs/docs/api/appkit-ui/ui/Breadcrumb.md +193 -0
  120. package/docs/docs/api/appkit-ui/ui/Button/index.html +27 -0
  121. package/docs/docs/api/appkit-ui/ui/Button.md +39 -0
  122. package/docs/docs/api/appkit-ui/ui/ButtonGroup/index.html +38 -0
  123. package/docs/docs/api/appkit-ui/ui/ButtonGroup.md +68 -0
  124. package/docs/docs/api/appkit-ui/ui/Calendar/index.html +34 -0
  125. package/docs/docs/api/appkit-ui/ui/Calendar.md +154 -0
  126. package/docs/docs/api/appkit-ui/ui/Card/index.html +69 -0
  127. package/docs/docs/api/appkit-ui/ui/Card.md +222 -0
  128. package/docs/docs/api/appkit-ui/ui/Carousel/index.html +55 -0
  129. package/docs/docs/api/appkit-ui/ui/Carousel.md +152 -0
  130. package/docs/docs/api/appkit-ui/ui/ChartContainer/index.html +58 -0
  131. package/docs/docs/api/appkit-ui/ui/ChartContainer.md +343 -0
  132. package/docs/docs/api/appkit-ui/ui/Checkbox/index.html +27 -0
  133. package/docs/docs/api/appkit-ui/ui/Checkbox.md +53 -0
  134. package/docs/docs/api/appkit-ui/ui/Collapsible/index.html +41 -0
  135. package/docs/docs/api/appkit-ui/ui/Collapsible.md +125 -0
  136. package/docs/docs/api/appkit-ui/ui/Command/index.html +83 -0
  137. package/docs/docs/api/appkit-ui/ui/Command.md +287 -0
  138. package/docs/docs/api/appkit-ui/ui/ContextMenu/index.html +111 -0
  139. package/docs/docs/api/appkit-ui/ui/ContextMenu.md +419 -0
  140. package/docs/docs/api/appkit-ui/ui/Dialog/index.html +90 -0
  141. package/docs/docs/api/appkit-ui/ui/Dialog.md +285 -0
  142. package/docs/docs/api/appkit-ui/ui/Drawer/index.html +90 -0
  143. package/docs/docs/api/appkit-ui/ui/Drawer.md +387 -0
  144. package/docs/docs/api/appkit-ui/ui/DropdownMenu/index.html +111 -0
  145. package/docs/docs/api/appkit-ui/ui/DropdownMenu.md +478 -0
  146. package/docs/docs/api/appkit-ui/ui/Empty/index.html +54 -0
  147. package/docs/docs/api/appkit-ui/ui/Empty.md +109 -0
  148. package/docs/docs/api/appkit-ui/ui/Field/index.html +87 -0
  149. package/docs/docs/api/appkit-ui/ui/Field.md +201 -0
  150. package/docs/docs/api/appkit-ui/ui/FormControl/index.html +59 -0
  151. package/docs/docs/api/appkit-ui/ui/FormControl.md +128 -0
  152. package/docs/docs/api/appkit-ui/ui/HoverCard/index.html +39 -0
  153. package/docs/docs/api/appkit-ui/ui/HoverCard.md +131 -0
  154. package/docs/docs/api/appkit-ui/ui/Input/index.html +27 -0
  155. package/docs/docs/api/appkit-ui/ui/Input.md +35 -0
  156. package/docs/docs/api/appkit-ui/ui/InputGroup/index.html +59 -0
  157. package/docs/docs/api/appkit-ui/ui/InputGroup.md +123 -0
  158. package/docs/docs/api/appkit-ui/ui/InputOTP/index.html +48 -0
  159. package/docs/docs/api/appkit-ui/ui/InputOTP.md +124 -0
  160. package/docs/docs/api/appkit-ui/ui/Item/index.html +78 -0
  161. package/docs/docs/api/appkit-ui/ui/Item.md +185 -0
  162. package/docs/docs/api/appkit-ui/ui/Kbd/index.html +30 -0
  163. package/docs/docs/api/appkit-ui/ui/Kbd.md +39 -0
  164. package/docs/docs/api/appkit-ui/ui/Label/index.html +27 -0
  165. package/docs/docs/api/appkit-ui/ui/Label.md +44 -0
  166. package/docs/docs/api/appkit-ui/ui/Menubar/index.html +117 -0
  167. package/docs/docs/api/appkit-ui/ui/Menubar.md +484 -0
  168. package/docs/docs/api/appkit-ui/ui/NavigationMenu/index.html +76 -0
  169. package/docs/docs/api/appkit-ui/ui/NavigationMenu.md +338 -0
  170. package/docs/docs/api/appkit-ui/ui/Pagination/index.html +69 -0
  171. package/docs/docs/api/appkit-ui/ui/Pagination.md +191 -0
  172. package/docs/docs/api/appkit-ui/ui/Popover/index.html +45 -0
  173. package/docs/docs/api/appkit-ui/ui/Popover.md +173 -0
  174. package/docs/docs/api/appkit-ui/ui/Progress/index.html +27 -0
  175. package/docs/docs/api/appkit-ui/ui/Progress.md +51 -0
  176. package/docs/docs/api/appkit-ui/ui/RadioGroup/index.html +33 -0
  177. package/docs/docs/api/appkit-ui/ui/RadioGroup.md +83 -0
  178. package/docs/docs/api/appkit-ui/ui/ResizableHandle/index.html +41 -0
  179. package/docs/docs/api/appkit-ui/ui/ResizableHandle.md +136 -0
  180. package/docs/docs/api/appkit-ui/ui/ScrollArea/index.html +34 -0
  181. package/docs/docs/api/appkit-ui/ui/ScrollArea.md +83 -0
  182. package/docs/docs/api/appkit-ui/ui/Select/index.html +82 -0
  183. package/docs/docs/api/appkit-ui/ui/Select.md +267 -0
  184. package/docs/docs/api/appkit-ui/ui/Separator/index.html +27 -0
  185. package/docs/docs/api/appkit-ui/ui/Separator.md +56 -0
  186. package/docs/docs/api/appkit-ui/ui/Sheet/index.html +76 -0
  187. package/docs/docs/api/appkit-ui/ui/Sheet.md +236 -0
  188. package/docs/docs/api/appkit-ui/ui/Sidebar/index.html +183 -0
  189. package/docs/docs/api/appkit-ui/ui/Sidebar.md +490 -0
  190. package/docs/docs/api/appkit-ui/ui/Skeleton/index.html +27 -0
  191. package/docs/docs/api/appkit-ui/ui/Skeleton.md +43 -0
  192. package/docs/docs/api/appkit-ui/ui/Slider/index.html +27 -0
  193. package/docs/docs/api/appkit-ui/ui/Slider.md +61 -0
  194. package/docs/docs/api/appkit-ui/ui/Spinner/index.html +24 -0
  195. package/docs/docs/api/appkit-ui/ui/Spinner.md +22 -0
  196. package/docs/docs/api/appkit-ui/ui/Switch/index.html +27 -0
  197. package/docs/docs/api/appkit-ui/ui/Switch.md +46 -0
  198. package/docs/docs/api/appkit-ui/ui/Table/index.html +69 -0
  199. package/docs/docs/api/appkit-ui/ui/Table.md +236 -0
  200. package/docs/docs/api/appkit-ui/ui/Tabs/index.html +48 -0
  201. package/docs/docs/api/appkit-ui/ui/Tabs.md +177 -0
  202. package/docs/docs/api/appkit-ui/ui/Textarea/index.html +27 -0
  203. package/docs/docs/api/appkit-ui/ui/Textarea.md +35 -0
  204. package/docs/docs/api/appkit-ui/ui/Toaster/index.html +27 -0
  205. package/docs/docs/api/appkit-ui/ui/Toaster.md +75 -0
  206. package/docs/docs/api/appkit-ui/ui/Toggle/index.html +27 -0
  207. package/docs/docs/api/appkit-ui/ui/Toggle.md +48 -0
  208. package/docs/docs/api/appkit-ui/ui/ToggleGroup/index.html +33 -0
  209. package/docs/docs/api/appkit-ui/ui/ToggleGroup.md +88 -0
  210. package/docs/docs/api/appkit-ui/ui/Tooltip/index.html +46 -0
  211. package/docs/docs/api/appkit-ui/ui/Tooltip.md +134 -0
  212. package/docs/docs/api/appkit-ui.md +15 -0
  213. package/docs/docs/api/appkit.md +48 -0
  214. package/docs/docs/api/index.html +28 -0
  215. package/docs/docs/api.md +24 -0
  216. package/docs/docs/app-management/index.html +106 -0
  217. package/docs/docs/app-management.md +171 -0
  218. package/docs/docs/architecture/index.html +71 -0
  219. package/docs/docs/architecture.md +69 -0
  220. package/docs/docs/category/development/index.html +16 -0
  221. package/docs/docs/category/development.md +3 -0
  222. package/docs/docs/configuration/index.html +66 -0
  223. package/docs/docs/configuration.md +150 -0
  224. package/docs/docs/core-principles/index.html +38 -0
  225. package/docs/docs/core-principles.md +31 -0
  226. package/docs/docs/development/index.html +34 -0
  227. package/docs/docs/development/llm-guide/index.html +74 -0
  228. package/docs/docs/development/llm-guide.md +74 -0
  229. package/docs/docs/development/local-development/index.html +27 -0
  230. package/docs/docs/development/local-development.md +20 -0
  231. package/docs/docs/development/project-setup/index.html +69 -0
  232. package/docs/docs/development/project-setup.md +246 -0
  233. package/docs/docs/development/remote-bridge/index.html +76 -0
  234. package/docs/docs/development/remote-bridge.md +80 -0
  235. package/docs/docs/development/type-generation/index.html +65 -0
  236. package/docs/docs/development/type-generation.md +110 -0
  237. package/docs/docs/development.md +21 -0
  238. package/docs/docs/index.html +58 -0
  239. package/docs/docs/plugins/index.html +151 -0
  240. package/docs/docs/plugins.md +313 -0
  241. package/docs/docs.md +64 -0
  242. package/llms.txt +121 -1228
  243. package/package.json +11 -11
  244. package/scripts/postinstall.js +1 -1
  245. package/AGENTS.md +0 -1231
  246. package/bin/appkit-lint.js +0 -129
  247. package/bin/generate-types.js +0 -27
  248. package/bin/setup-claude.js +0 -190
@@ -1,129 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * AST-based linting using ast-grep.
4
- * Catches patterns that ESLint/TypeScript miss or handle poorly.
5
- * Usage: npx appkit-lint
6
- */
7
- import { parse, Lang } from "@ast-grep/napi";
8
- import fs from "node:fs";
9
- import path from "node:path";
10
-
11
- const rules = [
12
- {
13
- id: "no-double-type-assertion",
14
- pattern: "$X as unknown as $Y",
15
- message:
16
- "Avoid double type assertion (as unknown as). Use proper type guards or fix the source type.",
17
- },
18
- {
19
- id: "no-as-any",
20
- pattern: "$X as any",
21
- message:
22
- 'Avoid "as any" type assertion. Use proper typing or unknown with type guards.',
23
- includeTests: false, // acceptable in test mocks
24
- },
25
- {
26
- id: "no-array-index-key",
27
- pattern: "key={$IDX}",
28
- message:
29
- "Avoid using array index as React key. Use a stable unique identifier.",
30
- filter: (code) => /key=\{(idx|index|i)\}/.test(code),
31
- },
32
- {
33
- id: "no-parse-float-without-validation",
34
- pattern: "parseFloat($X).toFixed($Y)",
35
- message:
36
- "parseFloat can return NaN. Validate input or use toNumber() helper from shared/types.ts.",
37
- },
38
- ];
39
-
40
- function isTestFile(filePath) {
41
- return (
42
- /\.(test|spec)\.(ts|tsx)$/.test(filePath) || filePath.includes("/tests/")
43
- );
44
- }
45
-
46
- function findTsFiles(dir, files = []) {
47
- const entries = fs.readdirSync(dir, { withFileTypes: true });
48
-
49
- for (const entry of entries) {
50
- const fullPath = path.join(dir, entry.name);
51
-
52
- if (entry.isDirectory()) {
53
- if (["node_modules", "dist", "build", ".git"].includes(entry.name))
54
- continue;
55
- findTsFiles(fullPath, files);
56
- } else if (entry.isFile() && /\.(ts|tsx)$/.test(entry.name)) {
57
- files.push(fullPath);
58
- }
59
- }
60
-
61
- return files;
62
- }
63
-
64
- function lintFile(filePath, rules) {
65
- const violations = [];
66
- const content = fs.readFileSync(filePath, "utf-8");
67
- const lang = filePath.endsWith(".tsx") ? Lang.Tsx : Lang.TypeScript;
68
- const testFile = isTestFile(filePath);
69
-
70
- const ast = parse(lang, content);
71
- const root = ast.root();
72
-
73
- for (const rule of rules) {
74
- // skip rules that don't apply to test files
75
- if (testFile && rule.includeTests === false) continue;
76
-
77
- const matches = root.findAll(rule.pattern);
78
-
79
- for (const match of matches) {
80
- const code = match.text();
81
-
82
- if (rule.filter && !rule.filter(code)) continue;
83
-
84
- const range = match.range();
85
- violations.push({
86
- file: filePath,
87
- line: range.start.line + 1,
88
- column: range.start.column + 1,
89
- rule: rule.id,
90
- message: rule.message,
91
- code: code.length > 80 ? `${code.slice(0, 77)}...` : code,
92
- });
93
- }
94
- }
95
-
96
- return violations;
97
- }
98
-
99
- function main() {
100
- const rootDir = process.cwd();
101
- const files = findTsFiles(rootDir);
102
-
103
- console.log(`Scanning ${files.length} TypeScript files...\n`);
104
-
105
- const allViolations = [];
106
-
107
- for (const file of files) {
108
- const violations = lintFile(file, rules);
109
- allViolations.push(...violations);
110
- }
111
-
112
- if (allViolations.length === 0) {
113
- console.log("No ast-grep lint violations found.");
114
- process.exit(0);
115
- }
116
-
117
- console.log(`Found ${allViolations.length} violation(s):\n`);
118
-
119
- for (const v of allViolations) {
120
- const relPath = path.relative(rootDir, v.file);
121
- console.log(`${relPath}:${v.line}:${v.column}`);
122
- console.log(` ${v.rule}: ${v.message}`);
123
- console.log(` > ${v.code}\n`);
124
- }
125
-
126
- process.exit(1);
127
- }
128
-
129
- main();
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
- import path from "node:path";
3
-
4
- import { generateFromEntryPoint } from "../dist/type-generator/index.js";
5
-
6
- // Parse arguments
7
- const args = process.argv.slice(2);
8
- const noCache = args.includes("--no-cache");
9
- const positionalArgs = args.filter((arg) => !arg.startsWith("--"));
10
-
11
- const rootDir = positionalArgs[0] || process.cwd();
12
- const outFile =
13
- positionalArgs[1] || path.join(process.cwd(), "client/src/appKitTypes.d.ts");
14
-
15
- const queryFolder = path.join(rootDir, "config/queries");
16
-
17
- const warehouseId = positionalArgs[2] || process.env.DATABRICKS_WAREHOUSE_ID;
18
- if (!warehouseId) {
19
- throw new Error("DATABRICKS_WAREHOUSE_ID is not set");
20
- }
21
-
22
- await generateFromEntryPoint({
23
- queryFolder,
24
- outFile,
25
- warehouseId,
26
- noCache,
27
- });
@@ -1,190 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * CLI tool to setup CLAUDE.md for Databricks AppKit packages.
5
- *
6
- * This bin is included in both @databricks/appkit and @databricks/appkit-ui
7
- * so it's available regardless of which package the user installs.
8
- *
9
- * Usage:
10
- * npx appkit-setup # Show detected packages and content
11
- * npx appkit-setup --write # Create or update CLAUDE.md file
12
- */
13
-
14
- import fs from "node:fs";
15
- import path from "node:path";
16
-
17
- const PACKAGES = [
18
- { name: "@databricks/appkit", description: "Backend SDK" },
19
- {
20
- name: "@databricks/appkit-ui",
21
- description: "UI Integration, Charts, Tables, SSE, and more.",
22
- },
23
- ];
24
-
25
- const SECTION_START = "<!-- appkit-instructions-start -->";
26
- const SECTION_END = "<!-- appkit-instructions-end -->";
27
-
28
- /**
29
- * Find which AppKit packages are installed by checking for CLAUDE.md
30
- */
31
- function findInstalledPackages() {
32
- const cwd = process.cwd();
33
- const installed = [];
34
-
35
- for (const pkg of PACKAGES) {
36
- const claudePath = path.join(cwd, "node_modules", pkg.name, "package.json");
37
- if (fs.existsSync(claudePath)) {
38
- installed.push(pkg);
39
- }
40
- }
41
-
42
- return installed;
43
- }
44
-
45
- /**
46
- * Generate the AppKit section content
47
- */
48
- function generateSection(packages) {
49
- const links = packages
50
- .map((pkg) => {
51
- const docPath = `./node_modules/${pkg.name}/CLAUDE.md`;
52
- return `- **${pkg.name}** (${pkg.description}): [${docPath}](${docPath})`;
53
- })
54
- .join("\n");
55
-
56
- return `${SECTION_START}
57
- ## Databricks AppKit
58
-
59
- This project uses Databricks AppKit packages. For AI assistant guidance on using these packages, refer to:
60
-
61
- ${links}
62
- ${SECTION_END}`;
63
- }
64
-
65
- /**
66
- * Generate standalone CLAUDE.md content (when no existing file)
67
- */
68
- function generateStandalone(packages) {
69
- const links = packages
70
- .map((pkg) => {
71
- const docPath = `./node_modules/${pkg.name}/CLAUDE.md`;
72
- return `- **${pkg.name}** (${pkg.description}): [${docPath}](${docPath})`;
73
- })
74
- .join("\n");
75
-
76
- return `# AI Assistant Instructions
77
-
78
- ${SECTION_START}
79
- ## Databricks AppKit
80
-
81
- This project uses Databricks AppKit packages. For AI assistant guidance on using these packages, refer to:
82
-
83
- ${links}
84
- ${SECTION_END}
85
- `;
86
- }
87
-
88
- /**
89
- * Update existing content with AppKit section
90
- */
91
- function updateContent(existingContent, packages) {
92
- const newSection = generateSection(packages);
93
-
94
- // Check if AppKit section already exists
95
- const startIndex = existingContent.indexOf(SECTION_START);
96
- const endIndex = existingContent.indexOf(SECTION_END);
97
-
98
- if (startIndex !== -1 && endIndex !== -1) {
99
- // Replace existing section
100
- const before = existingContent.substring(0, startIndex);
101
- const after = existingContent.substring(endIndex + SECTION_END.length);
102
- return before + newSection + after;
103
- }
104
-
105
- // Append section to end
106
- return `${existingContent.trimEnd()}\n\n${newSection}\n`;
107
- }
108
-
109
- /**
110
- * Main CLI logic
111
- */
112
- function main() {
113
- const args = process.argv.slice(2);
114
- const shouldWrite = args.includes("--write") || args.includes("-w");
115
- const help = args.includes("--help") || args.includes("-h");
116
-
117
- if (help) {
118
- console.log(`
119
- Usage: npx appkit-setup [options]
120
-
121
- Options:
122
- --write, -w Create or update CLAUDE.md file in current directory
123
- --help, -h Show this help message
124
-
125
- Examples:
126
- npx appkit-setup # Show detected packages and preview content
127
- npx appkit-setup --write # Create or update CLAUDE.md
128
- `);
129
- return;
130
- }
131
-
132
- // Find installed packages
133
- const installed = findInstalledPackages();
134
-
135
- if (installed.length === 0) {
136
- console.log("No @databricks/appkit packages found in node_modules.");
137
- console.log("\nMake sure you've installed at least one of:");
138
- PACKAGES.forEach((pkg) => {
139
- console.log(` - ${pkg.name}`);
140
- });
141
- process.exit(1);
142
- }
143
-
144
- console.log("Detected packages:");
145
- installed.forEach((pkg) => {
146
- console.log(` ✓ ${pkg.name}`);
147
- });
148
-
149
- const claudePath = path.join(process.cwd(), "CLAUDE.md");
150
- const existingContent = fs.existsSync(claudePath)
151
- ? fs.readFileSync(claudePath, "utf-8")
152
- : null;
153
-
154
- let finalContent;
155
- let action;
156
-
157
- if (existingContent) {
158
- finalContent = updateContent(existingContent, installed);
159
- action = existingContent.includes(SECTION_START) ? "Updated" : "Added to";
160
- } else {
161
- finalContent = generateStandalone(installed);
162
- action = "Created";
163
- }
164
-
165
- if (shouldWrite) {
166
- fs.writeFileSync(claudePath, finalContent);
167
- console.log(`\n✓ ${action} CLAUDE.md`);
168
- console.log(` Path: ${claudePath}`);
169
- } else {
170
- console.log("\nTo create/update CLAUDE.md, run:");
171
- console.log(" npx appkit-setup --write\n");
172
-
173
- if (existingContent) {
174
- console.log(
175
- `This will ${
176
- existingContent.includes(SECTION_START)
177
- ? "update the existing"
178
- : "add a new"
179
- } AppKit section.\n`,
180
- );
181
- }
182
-
183
- console.log("Preview of AppKit section:\n");
184
- console.log("─".repeat(50));
185
- console.log(generateSection(installed));
186
- console.log("─".repeat(50));
187
- }
188
- }
189
-
190
- main();