@brickkit/cli 0.11.0 → 0.13.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 (177) hide show
  1. package/dashboard-dist/CollapsiblePanel-CbUysOp5.js +2 -0
  2. package/dashboard-dist/CompositeRoot-D4sRkYq3.js +1 -0
  3. package/dashboard-dist/Geist-Variable.woff2 +0 -0
  4. package/dashboard-dist/GeistMono-Variable.woff2 +0 -0
  5. package/dashboard-dist/PopoverPopup-CiI2avT_.js +1 -0
  6. package/dashboard-dist/api-reference-mT9VNcPb.js +265 -0
  7. package/dashboard-dist/app.css +2 -2
  8. package/dashboard-dist/app.js +12 -13
  9. package/dashboard-dist/ccount-CcG1m-Yh.js +1 -0
  10. package/dashboard-dist/client-CwATkLJa.js +1 -0
  11. package/dashboard-dist/core-BEUWp6B5.js +1 -0
  12. package/dashboard-dist/docs-BRrtyxDB.js +4 -0
  13. package/dashboard-dist/docs.css +1 -1
  14. package/dashboard-dist/kit.js +1 -1
  15. package/dashboard-dist/popover-Bj9x-88h.js +1 -0
  16. package/dist/bin.d.ts +0 -2
  17. package/dist/bin.js +309 -211
  18. package/dist/bin.js.map +1 -1
  19. package/dist/build.js +463 -0
  20. package/dist/build.js.map +1 -0
  21. package/dist/client-contract-file.js +356 -1
  22. package/dist/client-contract-file.js.map +1 -0
  23. package/dist/compiler.d.ts +12 -3
  24. package/dist/compiler.js +1 -1
  25. package/dist/compiler2.js +13 -7
  26. package/dist/compiler2.js.map +1 -1
  27. package/dist/config.d.ts +3 -0
  28. package/dist/config.js +1 -252
  29. package/dist/config2.d.ts +122 -0
  30. package/dist/config2.js +207 -0
  31. package/dist/config2.js.map +1 -0
  32. package/dist/dashboard-extension.d.ts +3 -2
  33. package/dist/{dev-telemetry-store.js → dashboard-host.js} +1381 -1432
  34. package/dist/dashboard-host.js.map +1 -0
  35. package/dist/dashboard-protocol.js +189 -0
  36. package/dist/dashboard-protocol.js.map +1 -0
  37. package/dist/dashboard.d.ts +8 -135
  38. package/dist/definitions.js +33 -0
  39. package/dist/definitions.js.map +1 -0
  40. package/dist/dev-application.js +34 -0
  41. package/dist/dev-application.js.map +1 -0
  42. package/dist/dev-protocol.js +21 -0
  43. package/dist/dev-protocol.js.map +1 -0
  44. package/dist/dev-reporter.d.ts +0 -2
  45. package/dist/dev-reporter.js +3 -3
  46. package/dist/dev-reporter.js.map +1 -1
  47. package/dist/dev-telemetry.js +8 -24
  48. package/dist/dev-telemetry.js.map +1 -1
  49. package/dist/dev-worker.js +80 -21
  50. package/dist/dev-worker.js.map +1 -1
  51. package/dist/index.d.ts +18 -87
  52. package/dist/index.js +12 -6
  53. package/dist/index.js.map +1 -0
  54. package/dist/lint/oxlint.d.ts +0 -2
  55. package/dist/lint/oxlint.js +6 -5
  56. package/dist/lint/oxlint.js.map +1 -1
  57. package/dist/own-module.js +7 -0
  58. package/dist/own-module.js.map +1 -0
  59. package/dist/plugin.d.ts +6 -11
  60. package/dist/plugin.js +6 -42
  61. package/dist/plugin.js.map +1 -1
  62. package/dist/production-dashboard.d.ts +2 -0
  63. package/dist/production-dashboard.js +51 -0
  64. package/dist/production-dashboard.js.map +1 -0
  65. package/dist/production-dashboard2.d.ts +34 -0
  66. package/dist/{presets.js → project.js} +107 -113
  67. package/dist/project.js.map +1 -0
  68. package/dist/serve.d.ts +24 -0
  69. package/dist/serve.js +1 -0
  70. package/dist/serve2.js +49 -0
  71. package/dist/serve2.js.map +1 -0
  72. package/dist/vite.d.ts +0 -2
  73. package/dist/vite.js +28 -51
  74. package/dist/vite.js.map +1 -1
  75. package/dist/workflows.d.ts +2 -4
  76. package/dist/workflows2.js +60 -39
  77. package/dist/workflows2.js.map +1 -1
  78. package/inspector-dist/client/assets/api.rpc-BvRk9kiK.js +0 -0
  79. package/inspector-dist/client/assets/api.stream._streamId-BvRk9kiK.js +0 -0
  80. package/inspector-dist/client/assets/app-CeSwVsRm.css +2 -0
  81. package/inspector-dist/client/assets/dist-BK8w6xOr.js +3930 -0
  82. package/inspector-dist/client/assets/dist-CG2aVufI.js +197 -0
  83. package/inspector-dist/client/assets/entry.client-D9jbgmTR.js +9391 -0
  84. package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-CfRnuITN.js +34 -0
  85. package/inspector-dist/client/assets/home-hwPlkNhv.js +4034 -0
  86. package/inspector-dist/client/assets/jsx-runtime-CPEah4WQ.js +7084 -0
  87. package/inspector-dist/client/assets/manifest-0e76e9ac.js +1 -0
  88. package/inspector-dist/client/assets/mermaid-3ZIDBTTL-ZDR2PNY_.js +1 -0
  89. package/inspector-dist/client/assets/root-ChBNTZd2.css +2 -0
  90. package/inspector-dist/client/assets/root-SLeEf-sT.js +320 -0
  91. package/inspector-dist/client/assets/run-detail-DYbVkIFH.js +1871 -0
  92. package/inspector-dist/client/assets/tabs-CaJisoyb.js +73751 -0
  93. package/inspector-dist/client/assets/tabs-L5XKzOpP.css +1 -0
  94. package/inspector-dist/client/assets/zstd-browser-decoder-D94wmfAU.js +41 -0
  95. package/inspector-dist/server/assets/app-DGlfWVUI.js +99330 -0
  96. package/inspector-dist/server/assets/chunk-RLXIAIE6-F0SJZlei.js +42975 -0
  97. package/inspector-dist/server/assets/dist-BCbwm6jl.js +10325 -0
  98. package/inspector-dist/server/assets/dist-CG2aVufI.js +197 -0
  99. package/inspector-dist/server/assets/dist-Ce0I2PUv.js +1137 -0
  100. package/inspector-dist/server/assets/dist-DY0UlahA.js +1642 -0
  101. package/inspector-dist/server/assets/encryption-DdQgC8Rk.js +886 -0
  102. package/inspector-dist/server/assets/event-metadata-n7E4zEmT.js +145 -0
  103. package/inspector-dist/server/assets/functions-CNVQtbgg.js +1170 -0
  104. package/inspector-dist/server/assets/global-singleton-D8sIN5du.js +80 -0
  105. package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-CWRzMxYD.js +34 -0
  106. package/inspector-dist/server/assets/mermaid-3ZIDBTTL-D0v0ngVr.js +1 -0
  107. package/inspector-dist/server/assets/parse-Begau9cA.js +469 -0
  108. package/inspector-dist/server/assets/rolldown-runtime-C1I3wEg2.js +43 -0
  109. package/inspector-dist/server/assets/serialization-format-BbuGfHog.js +476 -0
  110. package/inspector-dist/server/assets/token-BgMmJNP5.js +60 -0
  111. package/inspector-dist/server/assets/token-BrUX0bxz.js +55 -0
  112. package/inspector-dist/server/assets/token-util-DZN32qmT.js +455 -0
  113. package/inspector-dist/server/assets/wrapper-CIC3w0oC.js +3624 -0
  114. package/inspector-dist/server/assets/ws-transport-CxTYB11n.js +29476 -0
  115. package/inspector-dist/server/assets/zstd-browser-decoder-D7bCXbGg.js +38 -0
  116. package/inspector-dist/server/index.js +1 -58
  117. package/package.json +39 -28
  118. package/vite-client.d.ts +1 -1
  119. package/dashboard-dist/CollapsiblePanel-BX79_W-b.js +0 -2
  120. package/dashboard-dist/CompositeRoot-xzybXjnx.js +0 -1
  121. package/dashboard-dist/PopoverPopup-CvlmC7EL.js +0 -1
  122. package/dashboard-dist/api-reference-BcAYVYwJ.js +0 -260
  123. package/dashboard-dist/core-BGO9JZ1r.js +0 -1
  124. package/dashboard-dist/docs-DHikPD2v.js +0 -4
  125. package/dashboard-dist/popover-DG498XHH.js +0 -1
  126. package/dist/app-entry.js +0 -1
  127. package/dist/app-entry2.js +0 -19
  128. package/dist/app-entry2.js.map +0 -1
  129. package/dist/bin.d.ts.map +0 -1
  130. package/dist/client-contract-file2.js +0 -34
  131. package/dist/client-contract-file2.js.map +0 -1
  132. package/dist/client-contract.js +0 -1
  133. package/dist/client-contract2.js +0 -294
  134. package/dist/client-contract2.js.map +0 -1
  135. package/dist/config.js.map +0 -1
  136. package/dist/dashboard-extension.d.ts.map +0 -1
  137. package/dist/dev-reporter.d.ts.map +0 -1
  138. package/dist/dev-telemetry-store.js.map +0 -1
  139. package/dist/emit.d.ts +0 -7
  140. package/dist/emit.d.ts.map +0 -1
  141. package/dist/index.d.ts.map +0 -1
  142. package/dist/lint/oxlint.d.ts.map +0 -1
  143. package/dist/plugin.d.ts.map +0 -1
  144. package/dist/presets.js.map +0 -1
  145. package/dist/runner.js +0 -523
  146. package/dist/runner.js.map +0 -1
  147. package/dist/vite.d.ts.map +0 -1
  148. package/dist/workflows.d.ts.map +0 -1
  149. package/inspector-dist/client/assets/api.rpc-l0sNRNKZ.js +0 -1
  150. package/inspector-dist/client/assets/api.stream._streamId-l0sNRNKZ.js +0 -1
  151. package/inspector-dist/client/assets/app-CvoGgWcV.css +0 -1
  152. package/inspector-dist/client/assets/entry.client-BJ6G3n5t.js +0 -11697
  153. package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-C-3wZnxf.js +0 -19
  154. package/inspector-dist/client/assets/home-CSKAS4P2.js +0 -4979
  155. package/inspector-dist/client/assets/index-DECCyMR0.js +0 -4482
  156. package/inspector-dist/client/assets/index-Dot7CgrA.js +0 -9837
  157. package/inspector-dist/client/assets/index-HqNj_XIX.js +0 -200
  158. package/inspector-dist/client/assets/manifest-139c9319.js +0 -1
  159. package/inspector-dist/client/assets/mermaid-3ZIDBTTL-DC0K8uTy.js +0 -58626
  160. package/inspector-dist/client/assets/mermaid-3ZIDBTTL-F88p7PFX.css +0 -1
  161. package/inspector-dist/client/assets/root-BMHd_XHz.css +0 -1
  162. package/inspector-dist/client/assets/root-cbi6iYwg.js +0 -305
  163. package/inspector-dist/client/assets/run-detail-CWoGxu_0.css +0 -1
  164. package/inspector-dist/client/assets/run-detail-Cc7tSGNq.js +0 -6237
  165. package/inspector-dist/client/assets/world-config-context-BAD1QCrR.js +0 -26
  166. package/inspector-dist/client/assets/zstd-browser-decoder-BQoRpP7L.js +0 -28
  167. package/inspector-dist/server/assets/app-DUP5RybL.js +0 -174880
  168. package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-D2g4hL2-.js +0 -71
  169. package/inspector-dist/server/assets/index-BfLBLRRi.js +0 -204
  170. package/inspector-dist/server/assets/index-BzrGWk7J.js +0 -1164
  171. package/inspector-dist/server/assets/index-D71yP6AL.js +0 -191
  172. package/inspector-dist/server/assets/index-wGSWRns3.js +0 -1296
  173. package/inspector-dist/server/assets/mermaid-3ZIDBTTL-DsvuKoEV.js +0 -58
  174. package/inspector-dist/server/assets/token-ClUZZwXl.js +0 -95
  175. package/inspector-dist/server/assets/token-util-DSxMZ6nI.js +0 -33
  176. package/inspector-dist/server/assets/wrapper-B3vstpCO.js +0 -67
  177. package/inspector-dist/server/assets/zstd-browser-decoder-Dn82m2BU.js +0 -77
package/dist/plugin.js CHANGED
@@ -1,31 +1,6 @@
1
- import { a as rules, i as resolveRules, n as PRESETS, r as fileRules } from "./presets.js";
2
- import { pathToFileURL } from "node:url";
3
- import { dirname, join, resolve } from "node:path";
4
- import { existsSync } from "node:fs";
5
- //#region src/lint/project.ts
6
- /** Read the nearest brick.config.ts (or `config`), with Brick's default paths. */
7
- async function readProject(options = {}) {
8
- const cwd = resolve(options.cwd ?? process.cwd());
9
- let file = options.config ? resolve(cwd, options.config) : void 0;
10
- for (let dir = cwd; !file; dir = dirname(dir)) if (existsSync(join(dir, "brick.config.ts"))) file = join(dir, "brick.config.ts");
11
- else if (dirname(dir) === dir) break;
12
- const config = file ? (await import(pathToFileURL(file).href)).default ?? {} : {};
13
- const root = file ? dirname(file) : cwd;
14
- return {
15
- root,
16
- file,
17
- config,
18
- settings: {
19
- root,
20
- services: config.services ?? "src/services",
21
- entry: config.entry ?? "src/app.ts",
22
- generated: config.generated ?? "_brick",
23
- web: "web"
24
- }
25
- };
26
- }
27
- //#endregion
28
- //#region src/lint/plugin.ts
1
+ import { a as rules, i as resolveRules, n as PRESETS, r as fileRules, t as projectRules } from "./project.js";
2
+ import { p as resolveProject } from "./config2.js";
3
+ // src/lint/plugin.ts
29
4
  const FILES = ["**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}"];
30
5
  /** The ESLint flat-config plugin; oxlint loads the same object through `jsPlugins`. */
31
6
  const brick = {
@@ -38,29 +13,18 @@ for (const name of Object.keys(PRESETS)) brick.configs[name] = {
38
13
  plugins: { brick },
39
14
  rules: fileRules(resolveRules([name]))
40
15
  };
41
- /** Rules, settings and ignores from brick.config.ts, shared by both linters. */
42
- async function projectRules(options) {
43
- const project = await readProject(options);
44
- const lint = project.config.lint ?? {};
45
- return {
46
- rules: fileRules(resolveRules(lint.presets, lint.rules)),
47
- settings: { brick: project.settings },
48
- ignore: [...lint.ignore ?? [], `${project.settings.generated.replace(/\/$/, "")}/**`]
49
- };
50
- }
51
16
  async function fromProject(options = {}) {
52
- const { rules, settings, ignore } = await projectRules(options);
17
+ const { rules, settings, ignore } = projectRules(await resolveProject(options.config, options.cwd));
53
18
  return [{
54
19
  name: "brick/project",
55
20
  files: FILES,
56
21
  ignores: ignore,
57
22
  plugins: { brick },
58
- settings,
23
+ settings: { brick: settings },
59
24
  rules
60
25
  }];
61
26
  }
62
27
  brick.configs.fromProject = fromProject;
63
- //#endregion
64
- export { projectRules as n, brick as t };
28
+ export { brick as t };
65
29
 
66
30
  //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","names":[],"sources":["../src/lint/project.ts","../src/lint/plugin.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { BrickSettings } from \"./ast\";\nimport type { PresetName, Severity } from \"./presets\";\n\n/** The parts of brick.config.ts lint reads. `defineConfig` in @brickkit/cli types the whole file. */\nexport interface ProjectConfig {\n entry?: string;\n services?: string;\n generated?: string;\n lint?: {\n presets?: PresetName[];\n rules?: Record<string, Severity>;\n ignore?: string[];\n };\n}\n\nexport interface Project {\n /** Folder of brick.config.ts, or the working directory without one. */\n root: string;\n file?: string;\n config: ProjectConfig;\n settings: BrickSettings;\n}\n\n/** Read the nearest brick.config.ts (or `config`), with Brick's default paths. */\nexport async function readProject(\n options: { cwd?: string; config?: string } = {},\n): Promise<Project> {\n const cwd = resolve(options.cwd ?? process.cwd());\n let file = options.config ? resolve(cwd, options.config) : undefined;\n for (let dir = cwd; !file; dir = dirname(dir)) {\n if (existsSync(join(dir, \"brick.config.ts\")))\n file = join(dir, \"brick.config.ts\");\n else if (dirname(dir) === dir) break;\n }\n const config: ProjectConfig = file\n ? ((await import(pathToFileURL(file).href)).default ?? {})\n : {};\n const root = file ? dirname(file) : cwd;\n return {\n root,\n file,\n config,\n settings: {\n root,\n services: config.services ?? \"src/services\",\n entry: config.entry ?? \"src/app.ts\",\n generated: config.generated ?? \"_brick\",\n web: \"web\",\n },\n };\n}\n","import type { Rule } from \"./ast\";\nimport {\n fileRules,\n PRESETS,\n resolveRules,\n rules,\n type PresetName,\n type Severity,\n} from \"./presets\";\nimport { readProject } from \"./project\";\n\nconst FILES = [\"**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}\"];\n\ninterface FlatConfig {\n name: string;\n files?: string[];\n ignores?: string[];\n plugins: Record<string, unknown>;\n settings?: Record<string, unknown>;\n rules: Record<string, Severity>;\n}\n\n/** The ESLint flat-config plugin; oxlint loads the same object through `jsPlugins`. */\nexport const brick = {\n meta: { name: \"brick\" },\n rules: rules as Record<string, Rule>,\n configs: {} as Record<PresetName, FlatConfig> & {\n /** Presets, rule settings, ignores and paths from brick.config.ts, as an ESLint flat-config array. */\n fromProject: typeof fromProject;\n },\n};\n\nfor (const name of Object.keys(PRESETS) as PresetName[])\n brick.configs[name] = {\n name: `brick/${name}`,\n plugins: { brick },\n rules: fileRules(resolveRules([name])),\n };\n\n/** Rules, settings and ignores from brick.config.ts, shared by both linters. */\nexport async function projectRules(options: { cwd?: string; config?: string }) {\n const project = await readProject(options);\n const lint = project.config.lint ?? {};\n return {\n rules: fileRules(resolveRules(lint.presets, lint.rules)),\n settings: { brick: project.settings },\n ignore: [\n ...(lint.ignore ?? []),\n `${project.settings.generated.replace(/\\/$/, \"\")}/**`,\n ],\n };\n}\n\nasync function fromProject(\n options: { cwd?: string; config?: string } = {},\n): Promise<FlatConfig[]> {\n const { rules, settings, ignore } = await projectRules(options);\n return [\n {\n name: \"brick/project\",\n files: FILES,\n ignores: ignore,\n plugins: { brick },\n settings,\n rules,\n },\n ];\n}\nbrick.configs.fromProject = fromProject;\n"],"mappings":";;;;;;AA2BA,eAAsB,YACpB,UAA6C,CAAC,GAC5B;CAClB,MAAM,MAAM,QAAQ,QAAQ,OAAO,QAAQ,IAAI,CAAC;CAChD,IAAI,OAAO,QAAQ,SAAS,QAAQ,KAAK,QAAQ,MAAM,IAAI,KAAA;CAC3D,KAAK,IAAI,MAAM,KAAK,CAAC,MAAM,MAAM,QAAQ,GAAG,GAC1C,IAAI,WAAW,KAAK,KAAK,iBAAiB,CAAC,GACzC,OAAO,KAAK,KAAK,iBAAiB;MAC/B,IAAI,QAAQ,GAAG,MAAM,KAAK;CAEjC,MAAM,SAAwB,QACxB,MAAM,OAAO,cAAc,IAAI,CAAC,CAAC,MAAA,CAAO,WAAW,CAAC,IACtD,CAAC;CACL,MAAM,OAAO,OAAO,QAAQ,IAAI,IAAI;CACpC,OAAO;EACL;EACA;EACA;EACA,UAAU;GACR;GACA,UAAU,OAAO,YAAY;GAC7B,OAAO,OAAO,SAAS;GACvB,WAAW,OAAO,aAAa;GAC/B,KAAK;EACP;CACF;AACF;;;AC1CA,MAAM,QAAQ,CAAC,sCAAsC;;AAYrD,MAAa,QAAQ;CACnB,MAAM,EAAE,MAAM,QAAQ;CACf;CACP,SAAS,CAAC;AAIZ;AAEA,KAAK,MAAM,QAAQ,OAAO,KAAK,OAAO,GACpC,MAAM,QAAQ,QAAQ;CACpB,MAAM,SAAS;CACf,SAAS,EAAE,MAAM;CACjB,OAAO,UAAU,aAAa,CAAC,IAAI,CAAC,CAAC;AACvC;;AAGF,eAAsB,aAAa,SAA4C;CAC7E,MAAM,UAAU,MAAM,YAAY,OAAO;CACzC,MAAM,OAAO,QAAQ,OAAO,QAAQ,CAAC;CACrC,OAAO;EACL,OAAO,UAAU,aAAa,KAAK,SAAS,KAAK,KAAK,CAAC;EACvD,UAAU,EAAE,OAAO,QAAQ,SAAS;EACpC,QAAQ,CACN,GAAI,KAAK,UAAU,CAAC,GACpB,GAAG,QAAQ,SAAS,UAAU,QAAQ,OAAO,EAAE,EAAE,IACnD;CACF;AACF;AAEA,eAAe,YACb,UAA6C,CAAC,GACvB;CACvB,MAAM,EAAE,OAAO,UAAU,WAAW,MAAM,aAAa,OAAO;CAC9D,OAAO,CACL;EACE,MAAM;EACN,OAAO;EACP,SAAS;EACT,SAAS,EAAE,MAAM;EACjB;EACA;CACF,CACF;AACF;AACA,MAAM,QAAQ,cAAc"}
1
+ {"version":3,"file":"plugin.js","names":[],"sources":["../src/lint/plugin.ts"],"sourcesContent":["import {\n fileRules,\n PRESETS,\n resolveRules,\n rules,\n type PresetName,\n type Severity,\n} from \"./presets\";\nimport { resolveProject } from \"../config\";\nimport { projectRules } from \"./project\";\n\nconst FILES = [\"**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}\"];\n\ninterface FlatConfig {\n name: string;\n files?: string[];\n ignores?: string[];\n plugins: Record<string, unknown>;\n settings?: Record<string, unknown>;\n rules: Record<string, Severity>;\n}\n\n/** The ESLint flat-config plugin; oxlint loads the same object through `jsPlugins`. */\nexport const brick = {\n meta: { name: \"brick\" },\n rules,\n configs: {} as Record<PresetName, FlatConfig> & {\n /** Presets, rule settings, ignores and paths from brick.config.ts, as an ESLint flat-config array. */\n fromProject: typeof fromProject;\n },\n};\n\nfor (const name of Object.keys(PRESETS) as PresetName[])\n brick.configs[name] = {\n name: `brick/${name}`,\n plugins: { brick },\n rules: fileRules(resolveRules([name])),\n };\n\nasync function fromProject(\n options: { cwd?: string; config?: string } = {},\n): Promise<FlatConfig[]> {\n const { rules, settings, ignore } = projectRules(\n await resolveProject(options.config, options.cwd),\n );\n return [\n {\n name: \"brick/project\",\n files: FILES,\n ignores: ignore,\n plugins: { brick },\n settings: { brick: settings },\n rules,\n },\n ];\n}\nbrick.configs.fromProject = fromProject;\n"],"mappings":";;;AAWA,MAAM,QAAQ,CAAC,sCAAsC;;AAYrD,MAAa,QAAQ;CACnB,MAAM,EAAE,MAAM,QAAQ;CACtB;CACA,SAAS,CAAC;AAIZ;AAEA,KAAK,MAAM,QAAQ,OAAO,KAAK,OAAO,GACpC,MAAM,QAAQ,QAAQ;CACpB,MAAM,SAAS;CACf,SAAS,EAAE,MAAM;CACjB,OAAO,UAAU,aAAa,CAAC,IAAI,CAAC,CAAC;AACvC;AAEF,eAAe,YACb,UAA6C,CAAC,GACvB;CACvB,MAAM,EAAE,OAAO,UAAU,WAAW,aAClC,MAAM,eAAe,QAAQ,QAAQ,QAAQ,GAAG,CAClD;CACA,OAAO,CACL;EACE,MAAM;EACN,OAAO;EACP,SAAS;EACT,SAAS,EAAE,MAAM;EACjB,UAAU,EAAE,OAAO,SAAS;EAC5B;CACF,CACF;AACF;AACA,MAAM,QAAQ,cAAc"}
@@ -0,0 +1,2 @@
1
+ import { n as startProductionDashboard, t as ProductionDashboard } from "./production-dashboard2.js";
2
+ export { ProductionDashboard, startProductionDashboard };
@@ -0,0 +1,51 @@
1
+ import { t as openDashboard } from "./dashboard-host.js";
2
+ import { t as installTracing } from "./dev-telemetry.js";
3
+ import { getGlobalRegistry } from "@brickkit/core";
4
+ // src/production-dashboard.ts
5
+ /**
6
+ * Serve the monitoring dashboard an app asks for with `brick({ dashboard })`,
7
+ * in the process that serves the app. It listens on a port of its own, so it
8
+ * stays up when the app's routes do not answer, and its `/_health` tells an
9
+ * uptime monitor whether the app does. From here on `ctx.logger` and `console`
10
+ * lines written during a request go to the dashboard, not the console.
11
+ *
12
+ * Call it before the app starts listening. Returns undefined when the app
13
+ * asks for no dashboard, or when it cannot start (the app runs on without it,
14
+ * and says so). A configuration that would leave the dashboard open to others
15
+ * throws instead: the app must not start unprotected.
16
+ */
17
+ async function startProductionDashboard(app, options) {
18
+ const config = app.definition.dashboard;
19
+ if (!config) return void 0;
20
+ const warn = options.warn ?? ((message) => console.warn(message));
21
+ const host = config.host ?? "127.0.0.1";
22
+ const started = await openDashboard({
23
+ directory: options.directory ?? process.cwd(),
24
+ historyDays: config.historyDays ?? 0,
25
+ warn,
26
+ port: config.port,
27
+ host,
28
+ mode: "production",
29
+ portHint: "Set dashboard.port in brick() to another.",
30
+ auth: config.auth,
31
+ dashboard: options.dashboard,
32
+ plugins: app.definition.plugins,
33
+ appUrl: `http://127.0.0.1:${options.appPort}`,
34
+ probe: async () => {
35
+ return (await fetch(`http://127.0.0.1:${options.appPort}/_health`, { signal: AbortSignal.timeout(2e3) })).ok;
36
+ }
37
+ });
38
+ if (!started) return void 0;
39
+ const { store } = started;
40
+ if (!installTracing((records) => store.ingest(records, store.latestGeneration))) warn("[Brick-TS] Another tracer provider is already registered, so the dashboard will show no requests or logs.");
41
+ const generation = store.startGeneration("application started");
42
+ store.setArchitecture(getGlobalRegistry().exportArchitecture(app.definition), generation);
43
+ return {
44
+ host,
45
+ port: started.port,
46
+ stop: () => started.stop()
47
+ };
48
+ }
49
+ export { startProductionDashboard };
50
+
51
+ //# sourceMappingURL=production-dashboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"production-dashboard.js","names":[],"sources":["../src/production-dashboard.ts"],"sourcesContent":["import { getGlobalRegistry, type BrickApp } from \"@brickkit/core\";\nimport type { DashboardExtensionOptions } from \"./dashboard-extension\";\nimport { openDashboard } from \"./dashboard-host\";\nimport { installTracing } from \"./dev-telemetry\";\n\nexport interface ProductionDashboard {\n readonly host: string;\n readonly port: number;\n stop(): void;\n}\n\n/**\n * Serve the monitoring dashboard an app asks for with `brick({ dashboard })`,\n * in the process that serves the app. It listens on a port of its own, so it\n * stays up when the app's routes do not answer, and its `/_health` tells an\n * uptime monitor whether the app does. From here on `ctx.logger` and `console`\n * lines written during a request go to the dashboard, not the console.\n *\n * Call it before the app starts listening. Returns undefined when the app\n * asks for no dashboard, or when it cannot start (the app runs on without it,\n * and says so). A configuration that would leave the dashboard open to others\n * throws instead: the app must not start unprotected.\n */\nexport async function startProductionDashboard(\n app: BrickApp,\n options: {\n /** The port the app listens on, for the health probe. */\n appPort: number;\n /** Where `.brick/` history is kept; the working folder by default. */\n directory?: string;\n warn?: (message: string) => void;\n /**\n * The project's extension (source, or the folder `brick build` wrote) and\n * theme. The app's plugins' extensions join it, from source or as the\n * folder holds them. Only pages marked `production: true` are shown.\n */\n dashboard?: DashboardExtensionOptions;\n },\n): Promise<ProductionDashboard | undefined> {\n const config = app.definition.dashboard;\n if (!config) return undefined;\n const warn = options.warn ?? ((message) => console.warn(message));\n const host = config.host ?? \"127.0.0.1\";\n const started = await openDashboard({\n directory: options.directory ?? process.cwd(),\n historyDays: config.historyDays ?? 0,\n warn,\n port: config.port,\n host,\n mode: \"production\",\n portHint: \"Set dashboard.port in brick() to another.\",\n auth: config.auth,\n dashboard: options.dashboard,\n plugins: app.definition.plugins,\n appUrl: `http://127.0.0.1:${options.appPort}`,\n probe: async () => {\n const response = await fetch(\n `http://127.0.0.1:${options.appPort}/_health`,\n { signal: AbortSignal.timeout(2000) },\n );\n return response.ok;\n },\n });\n if (!started) return undefined;\n const { store } = started;\n\n const registered = installTracing((records) =>\n store.ingest(records, store.latestGeneration),\n );\n if (!registered) {\n warn(\n \"[Brick-TS] Another tracer provider is already registered, so the dashboard will show no requests or logs.\",\n );\n }\n const generation = store.startGeneration(\"application started\");\n store.setArchitecture(\n getGlobalRegistry().exportArchitecture(app.definition),\n generation,\n );\n return { host, port: started.port, stop: () => started.stop() };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,eAAsB,yBACpB,KACA,SAa0C;CAC1C,MAAM,SAAS,IAAI,WAAW;CAC9B,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,MAAM,OAAO,QAAQ,UAAU,YAAY,QAAQ,KAAK,OAAO;CAC/D,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,UAAU,MAAM,cAAc;EAClC,WAAW,QAAQ,aAAa,QAAQ,IAAI;EAC5C,aAAa,OAAO,eAAe;EACnC;EACA,MAAM,OAAO;EACb;EACA,MAAM;EACN,UAAU;EACV,MAAM,OAAO;EACb,WAAW,QAAQ;EACnB,SAAS,IAAI,WAAW;EACxB,QAAQ,oBAAoB,QAAQ;EACpC,OAAO,YAAY;GAKjB,QAAO,MAJgB,MACrB,oBAAoB,QAAQ,QAAQ,WACpC,EAAE,QAAQ,YAAY,QAAQ,GAAI,EAAE,CACtC,EAAA,CACgB;EAClB;CACF,CAAC;CACD,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,MAAM,EAAE,UAAU;CAKlB,IAAI,CAHe,gBAAgB,YACjC,MAAM,OAAO,SAAS,MAAM,gBAAgB,CAEhC,GACZ,KACE,2GACF;CAEF,MAAM,aAAa,MAAM,gBAAgB,qBAAqB;CAC9D,MAAM,gBACJ,kBAAkB,CAAC,CAAC,mBAAmB,IAAI,UAAU,GACrD,UACF;CACA,OAAO;EAAE;EAAM,MAAM,QAAQ;EAAM,YAAY,QAAQ,KAAK;CAAE;AAChE"}
@@ -0,0 +1,34 @@
1
+ import { t as DashboardExtensionOptions } from "./dashboard-extension.js";
2
+ import { BrickApp } from "@brickkit/core";
3
+ interface ProductionDashboard {
4
+ readonly host: string;
5
+ readonly port: number;
6
+ stop(): void;
7
+ }
8
+ /**
9
+ * Serve the monitoring dashboard an app asks for with `brick({ dashboard })`,
10
+ * in the process that serves the app. It listens on a port of its own, so it
11
+ * stays up when the app's routes do not answer, and its `/_health` tells an
12
+ * uptime monitor whether the app does. From here on `ctx.logger` and `console`
13
+ * lines written during a request go to the dashboard, not the console.
14
+ *
15
+ * Call it before the app starts listening. Returns undefined when the app
16
+ * asks for no dashboard, or when it cannot start (the app runs on without it,
17
+ * and says so). A configuration that would leave the dashboard open to others
18
+ * throws instead: the app must not start unprotected.
19
+ */
20
+ declare function startProductionDashboard(app: BrickApp, options: {
21
+ /** The port the app listens on, for the health probe. */
22
+ appPort: number;
23
+ /** Where `.brick/` history is kept; the working folder by default. */
24
+ directory?: string;
25
+ warn?: (message: string) => void;
26
+ /**
27
+ * The project's extension (source, or the folder `brick build` wrote) and
28
+ * theme. The app's plugins' extensions join it, from source or as the
29
+ * folder holds them. Only pages marked `production: true` are shown.
30
+ */
31
+ dashboard?: DashboardExtensionOptions;
32
+ }): Promise<ProductionDashboard | undefined>;
33
+ export { startProductionDashboard as n, ProductionDashboard as t };
34
+ //# sourceMappingURL=production-dashboard2.d.ts.map
@@ -1,55 +1,58 @@
1
- import { basename, dirname, relative, resolve, sep } from "node:path";
1
+ import { n as ConfigError, s as PROJECT_DEFAULTS } from "./config2.js";
2
+ import { a as TEST_FILE, i as MANIFEST_FILE, n as DEFINITION_FILE } from "./definitions.js";
2
3
  import { readdirSync } from "node:fs";
3
- const SUFFIX = new RegExp(`^(.*)\\.(${[
4
- "service",
5
- "events",
6
- "resource",
7
- "table",
8
- "action",
9
- "command",
10
- "tool",
11
- "socket",
12
- "listener",
13
- "workflow",
14
- "step"
15
- ].join("|")})\\.(ts|tsx|mts|js|jsx|mjs)$`);
4
+ import { basename, dirname, relative, resolve, sep } from "node:path";
5
+ import { STANDARD_ERRORS, isControlEvent, kebabCase } from "@brickkit/core/client";
6
+ // src/lint/ast.ts
7
+ function defineRule(type, description, create, options = {}) {
8
+ return {
9
+ meta: {
10
+ type,
11
+ docs: { description },
12
+ fixable: options.fixable,
13
+ schema: options.schema ?? []
14
+ },
15
+ create
16
+ };
17
+ }
16
18
  const posix$1 = (path) => path.split(sep).join("/");
19
+ /** The settings with Brick's default paths, each relative to the root without a trailing slash. */
17
20
  function brickSettings(context) {
18
21
  const given = context.settings?.brick ?? {};
22
+ const root = given.root ?? context.cwd ?? process.cwd();
23
+ const from = (path) => posix$1(relative(root, resolve(root, path)));
19
24
  return {
20
- root: given.root ?? context.cwd ?? process.cwd(),
21
- services: given.services ?? "src/services",
22
- entry: given.entry ?? "src/app.ts",
23
- generated: given.generated ?? "_brick",
24
- web: given.web ?? "web"
25
+ root,
26
+ services: from(given.services ?? PROJECT_DEFAULTS.services),
27
+ entry: from(given.entry ?? PROJECT_DEFAULTS.entry),
28
+ generated: from(given.generated ?? PROJECT_DEFAULTS.generated)
25
29
  };
26
30
  }
31
+ /** The folders a service may live in: its kebab-case name, or the name itself. */
32
+ const serviceFolders = (name) => [kebabCase(name), name];
27
33
  function fileInfo(context) {
28
34
  const settings = brickSettings(context);
29
35
  const rel = posix$1(relative(settings.root, context.filename));
30
- const servicesDir = posix$1(relative(settings.root, resolve(settings.root, settings.services)));
31
- const generated = posix$1(relative(settings.root, resolve(settings.root, settings.generated)));
36
+ const { services: servicesDir, generated } = settings;
32
37
  const base = basename(rel);
33
38
  const inServices = rel.startsWith(`${servicesDir}/`);
34
39
  const parts = inServices ? rel.slice(servicesDir.length + 1).split("/") : [];
35
- const match = SUFFIX.exec(base);
40
+ const match = DEFINITION_FILE.exec(base);
36
41
  const segments = rel.split("/");
42
+ const ignored = TEST_FILE.test(base) || segments.includes("test") || segments.includes("tests") || segments.includes("__tests__") || segments.includes("node_modules") || rel.startsWith(`${generated}/`);
37
43
  return {
38
44
  settings,
39
45
  rel,
40
46
  base,
41
- servicesDir,
42
47
  inServices,
43
48
  service: parts.length > 1 ? parts[0] : void 0,
44
49
  rest: parts.slice(1),
45
50
  kind: match?.[2],
46
51
  stem: match?.[1],
47
- exempt: /\.(test|spec)\.[cm]?[jt]sx?$/.test(base) || segments.includes("test") || segments.includes("tests") || segments.includes("__tests__") || segments.includes("plugins") || segments.includes("node_modules") || rel.startsWith(`${generated}/`)
52
+ ignored,
53
+ exempt: ignored || segments.includes("plugins")
48
54
  };
49
55
  }
50
- function kebab(name) {
51
- return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[_\s.]+/g, "-").toLowerCase();
52
- }
53
56
  /** A string literal's value, or a template literal's text when it has no expressions. */
54
57
  function stringValue(node) {
55
58
  if (node?.type === "Literal" && typeof node.value === "string") return node.value;
@@ -85,10 +88,10 @@ const DEFINE_FUNCTIONS = {
85
88
  defineTool: "tool",
86
89
  defineListener: "listener",
87
90
  definePlugin: "plugin",
91
+ defineResource: "resource",
88
92
  crud: "crud",
89
93
  sqliteTable: "table",
90
- pgTable: "table",
91
- mysqlTable: "table"
94
+ pgTable: "table"
92
95
  };
93
96
  const ATTACH_METHODS = {
94
97
  action: "action",
@@ -104,6 +107,7 @@ function definitionOf(call) {
104
107
  const callee = call.callee;
105
108
  if (callee.type === "Identifier" && DEFINE_FUNCTIONS[callee.name]) {
106
109
  const kind = DEFINE_FUNCTIONS[callee.name];
110
+ if (kind === "resource") return first?.type === "Identifier" ? attached(call, kind, first.name, second) : void 0;
107
111
  if (kind === "service" || kind === "table") {
108
112
  const name = stringValue(first);
109
113
  if (name === void 0) return void 0;
@@ -141,15 +145,18 @@ function definitionOf(call) {
141
145
  config: second
142
146
  };
143
147
  }
144
- if (first?.type !== "ObjectExpression") return void 0;
145
- const nameNode = getProperty(first, "name")?.value;
148
+ return attached(call, kind, owner, first);
149
+ }
150
+ function attached(call, kind, owner, config) {
151
+ if (config?.type !== "ObjectExpression") return void 0;
152
+ const nameNode = getProperty(config, "name")?.value;
146
153
  const name = stringValue(nameNode);
147
154
  if (kind === "resource" && name === void 0) return void 0;
148
155
  return {
149
156
  kind,
150
157
  call,
151
158
  owner,
152
- config: first,
159
+ config,
153
160
  name,
154
161
  nameNode
155
162
  };
@@ -193,7 +200,7 @@ function resolveImport(info, context, source) {
193
200
  if (!source.startsWith(".")) return void 0;
194
201
  return posix$1(relative(info.settings.root, resolve(dirname(context.filename), source)));
195
202
  }
196
- /** `name.method(...)` with a non-computed property. */
203
+ /** `name.method(...)` with a non-computed property, or a bare `fn(...)` (no `object`). */
197
204
  function memberCall(node) {
198
205
  if (node?.type !== "CallExpression") return void 0;
199
206
  const callee = node.callee;
@@ -204,38 +211,27 @@ function memberCall(node) {
204
211
  property: callee.property.name
205
212
  };
206
213
  }
207
- //#endregion
208
- //#region src/lint/rules/checks.ts
209
- function rule$1(description, create, options = {}) {
210
- return {
211
- meta: {
212
- type: "problem",
213
- docs: { description },
214
- fixable: options.fixable,
215
- schema: options.schema ?? []
216
- },
217
- create
218
- };
219
- }
214
+ // package.json
215
+ var version = "0.13.0";
216
+ // src/lint/rules/checks.ts
217
+ const MANIFEST_STEM = MANIFEST_FILE.replace(/\.ts$/, "");
218
+ /** This release's range, for the `brick` field example: `^0.12.0`. */
219
+ const BRICK_RANGE = `^${version.split(".").slice(0, 2).join(".")}.0`;
220
+ const rule$1 = (description, create, options) => defineRule("problem", description, create, options);
220
221
  /** Skip tests and generated files; local plugins are checked like app code. */
221
- function skip(context) {
222
- const info = fileInfo(context);
223
- return info.exempt && !info.rel.split("/").includes("plugins");
224
- }
222
+ const skip = (context) => fileInfo(context).ignored;
225
223
  const HANDLERS = [
226
224
  "action",
227
225
  "command",
228
226
  "tool"
229
227
  ];
230
- const BUILT_IN_ERRORS = /* @__PURE__ */ new Set([
231
- "BAD_REQUEST",
232
- "UNAUTHORIZED",
233
- "FORBIDDEN",
234
- "NOT_FOUND",
235
- "CONFLICT",
236
- "INTERNAL_SERVER_ERROR"
237
- ]);
238
- /** `error.NAME(...)`, the error helper handlers receive. */
228
+ /** What clients call: described in OpenAPI, MCP and the dashboard. */
229
+ const ENDPOINTS = [...HANDLERS, "socket"];
230
+ /** What gets the error helpers. */
231
+ const ERROR_KINDS = [...ENDPOINTS, "crud"];
232
+ /** What runs with a request or delivery context. */
233
+ const CTX_KINDS = [...ERROR_KINDS, "listener"];
234
+ const BUILT_IN_ERRORS = new Set(Object.keys(STANDARD_ERRORS));
239
235
  function errorHelper(node) {
240
236
  const call = memberCall(node);
241
237
  return call?.object === "error" ? call.property : void 0;
@@ -251,6 +247,7 @@ const WRITE_METHODS = /* @__PURE__ */ new Set([
251
247
  "update",
252
248
  "delete"
253
249
  ]);
250
+ const WRITE_CALL = new RegExp(`\\.(${[...WRITE_METHODS].join("|")})\\s*\\(`);
254
251
  const VERBS = new Set(`get list find search query count read load fetch check validate verify preview render export download
255
252
  create add insert import upload register invite book place submit send post publish issue open start schedule
256
253
  update set edit change rename move copy clone merge assign attach link mark toggle enable disable approve reject
@@ -276,15 +273,14 @@ const ROOM = /^[a-z][a-zA-Z0-9_-]*:./;
276
273
  const checkRules = {
277
274
  "no-server-in-client": rule$1("Browser code imports only @brickkit/core/client and the generated contract.", (context) => {
278
275
  const info = fileInfo(context);
279
- const web = info.settings.web.replace(/\/$/, "");
280
- if (!info.rel.startsWith(`${web}/`)) return {};
281
- const generated = info.settings.generated.replace(/\/$/, "");
276
+ if (!info.rel.startsWith(`web/`)) return {};
277
+ const { generated } = info.settings;
282
278
  const check = (node, source) => {
283
279
  if (typeof source !== "string") return;
284
280
  let allowed;
285
281
  if (source.startsWith(".")) {
286
282
  const path = resolveImport(info, context, source);
287
- allowed = path.startsWith(`${web}/`) || path.startsWith(`${generated}/`) && !path.endsWith("services.gen") && !path.endsWith("services.gen.ts");
283
+ allowed = path.startsWith(`web/`) || path.startsWith(`${generated}/`) && !path.endsWith(MANIFEST_STEM) && !path.endsWith("services.gen.ts");
288
284
  } else allowed = !/^(@brickkit\/|bun:|node:)/.test(source) || source === "@brickkit/core/client" || source === "@brickkit/core/tanstack-query";
289
285
  if (!allowed) context.report({
290
286
  node,
@@ -327,7 +323,7 @@ const checkRules = {
327
323
  }),
328
324
  "no-env-outside-secrets": rule$1("process.env and Bun.env are read only through defineSecret or config files.", (context) => {
329
325
  const info = fileInfo(context);
330
- if (info.exempt || /(^|\.)secrets\.[cm]?[jt]s$/.test(info.base) || /\.config\.[cm]?[jt]s$/.test(info.base)) return {};
326
+ if (info.ignored || /(^|\.)secrets\.[cm]?[jt]s$/.test(info.base) || /\.config\.[cm]?[jt]s$/.test(info.base)) return {};
331
327
  return { MemberExpression(node) {
332
328
  const object = node.object;
333
329
  const property = node.computed ? void 0 : node.property.name;
@@ -370,11 +366,7 @@ const checkRules = {
370
366
  return { CallExpression(node) {
371
367
  const name = errorHelper(node);
372
368
  if (!name || node.parent?.type !== "ExpressionStatement") return;
373
- if (!enclosingDefinition(node, [
374
- ...HANDLERS,
375
- "crud",
376
- "socket"
377
- ])) return;
369
+ if (!enclosingDefinition(node, ERROR_KINDS)) return;
378
370
  context.report({
379
371
  node,
380
372
  message: `Return the error: return error.${name}(...).`,
@@ -478,7 +470,7 @@ const checkRules = {
478
470
  const definition = definitionOf(node);
479
471
  if (definition?.kind !== "listener") return;
480
472
  const text = context.sourceCode.getText(definition.config);
481
- if (/\.(insert|update|delete)\s*\(/.test(text) && !/deliveryId|onConflictDo(Nothing|Update)/.test(text)) context.report({
473
+ if (WRITE_CALL.test(text) && !/deliveryId|onConflictDo(Nothing|Update)/.test(text)) context.report({
482
474
  node: definition.nameNode ?? node,
483
475
  message: "This listener writes without deliveryId or onConflictDoNothing; a redelivered event would write twice."
484
476
  });
@@ -494,7 +486,7 @@ const checkRules = {
494
486
  if (schemas?.type !== "ObjectExpression") continue;
495
487
  for (const property of schemas.properties) {
496
488
  const name = propertyName(property);
497
- if (name?.startsWith("$")) context.report({
489
+ if (name !== void 0 && isControlEvent(name)) context.report({
498
490
  node: property.key,
499
491
  message: `Socket ${key} event "${name}" starts with $, which is reserved for control messages.`
500
492
  });
@@ -632,12 +624,7 @@ const checkRules = {
632
624
  return { CallExpression(node) {
633
625
  const definition = definitionOf(node);
634
626
  if (!definition) return;
635
- if ([
636
- "action",
637
- "command",
638
- "tool",
639
- "socket"
640
- ].includes(definition.kind) && !getProperty(definition.config, "description")) context.report({
627
+ if (ENDPOINTS.includes(definition.kind) && !getProperty(definition.config, "description")) context.report({
641
628
  node: definition.nameNode ?? node,
642
629
  message: `Describe this ${definition.kind}: the description feeds OpenAPI, MCP and the dashboard.`
643
630
  });
@@ -701,12 +688,7 @@ const checkRules = {
701
688
  if (skip(context)) return {};
702
689
  return { CallExpression(node) {
703
690
  if (memberCall(node)?.object !== "console") return;
704
- if (!enclosingDefinition(node, [
705
- ...HANDLERS,
706
- "socket",
707
- "listener",
708
- "crud"
709
- ])) return;
691
+ if (!enclosingDefinition(node, CTX_KINDS)) return;
710
692
  context.report({
711
693
  node,
712
694
  message: "Log through ctx.logger, so the line carries the request and trace ids."
@@ -738,7 +720,7 @@ const checkRules = {
738
720
  });
739
721
  if (!stringValue(getProperty(config, "brick")?.value)) context.report({
740
722
  node: node.callee,
741
- message: "Declare the Brick versions this plugin supports: brick: \"^0.11.0\"."
723
+ message: `Declare the Brick versions this plugin supports: brick: "${BRICK_RANGE}".`
742
724
  });
743
725
  const options = getProperty(config, "options")?.value;
744
726
  if (!options) context.report({
@@ -763,19 +745,8 @@ const checkRules = {
763
745
  };
764
746
  })
765
747
  };
766
- //#endregion
767
- //#region src/lint/rules/layout.ts
768
- function rule(description, create, fixable) {
769
- return {
770
- meta: {
771
- type: "suggestion",
772
- docs: { description },
773
- fixable,
774
- schema: []
775
- },
776
- create
777
- };
778
- }
748
+ // src/lint/rules/layout.ts
749
+ const rule = (description, create, fixable) => defineRule("suggestion", description, create, { fixable });
779
750
  /** Collect every definition in the file, then check them once the file is read. */
780
751
  function onDefinitions(check) {
781
752
  const definitions = [];
@@ -798,8 +769,7 @@ const SERVICE_FOLDERS = {
798
769
  step: "workflows",
799
770
  table: "tables"
800
771
  };
801
- //#endregion
802
- //#region src/lint/presets.ts
772
+ // src/lint/presets.ts
803
773
  /** Rules that check one file at a time, in ESLint, oxlint or brick lint. */
804
774
  const rules = {
805
775
  "one-action-per-file": rule("A *.action.ts file defines exactly one action, and actions are defined nowhere else.", (context) => {
@@ -848,8 +818,8 @@ const rules = {
848
818
  message: `Move ${info.base} to ${where}.`
849
819
  });
850
820
  const kind = info.kind;
851
- if (!info.inServices || !info.service) return report(`${info.servicesDir}/<service>/, where it is registered`);
852
- const service = `${info.servicesDir}/${info.service}`;
821
+ if (!info.inServices || !info.service) return report(`${info.settings.services}/<service>/, where it is registered`);
822
+ const service = `${info.settings.services}/${info.service}`;
853
823
  const rest = info.rest;
854
824
  if (kind === "service" || kind === "events") {
855
825
  if (rest.length !== 1) report(`${service}/`);
@@ -878,11 +848,11 @@ const rules = {
878
848
  for (const definition of definitions) {
879
849
  if (definition.kind === "resource" && info.kind === "resource") {
880
850
  if (!folder || info.rest.length !== 3) continue;
881
- if (definition.name && kebab(definition.name) !== folder) context.report({
851
+ if (definition.name && kebabCase(definition.name) !== folder) context.report({
882
852
  node: definition.nameNode,
883
- message: `Resource "${definition.name}" lives in resources/${kebab(definition.name)}/, not resources/${folder}/.`
853
+ message: `Resource "${definition.name}" lives in resources/${kebabCase(definition.name)}/, not resources/${folder}/.`
884
854
  });
885
- const siblings = readdirSync(dirname(context.filename)).filter((file) => /\.resource\.[cm]?[jt]sx?$/.test(file));
855
+ const siblings = readdirSync(dirname(context.filename)).filter((file) => DEFINITION_FILE.exec(file)?.[2] === "resource");
886
856
  if (siblings.length > 1) context.report({
887
857
  node: definition.call,
888
858
  message: `resources/${folder}/ holds ${siblings.length} resources; give each its own folder.`
@@ -909,7 +879,7 @@ const rules = {
909
879
  return onDefinitions((definitions) => {
910
880
  for (const definition of definitions) {
911
881
  if (definition.kind !== info.kind || !definition.name) continue;
912
- const expected = kebab(definition.name.split(".").pop());
882
+ const expected = kebabCase(definition.name.split(".").pop());
913
883
  if (expected !== info.stem) context.report({
914
884
  node: definition.nameNode,
915
885
  message: `"${definition.name}" belongs in ${expected}.${info.kind}.ts, not ${info.base}.`
@@ -933,9 +903,9 @@ const rules = {
933
903
  const service = services[0];
934
904
  if (!service?.name || !info.inServices) return;
935
905
  const folder = info.rest.length === 1 ? info.service : void 0;
936
- if (folder !== kebab(service.name) && folder !== service.name) context.report({
906
+ if (!serviceFolders(service.name).includes(folder)) context.report({
937
907
  node: service.nameNode,
938
- message: `Service "${service.name}" lives in ${info.servicesDir}/${kebab(service.name)}/${kebab(service.name)}.service.ts.`
908
+ message: `Service "${service.name}" lives in ${info.settings.services}/${kebabCase(service.name)}/${kebabCase(service.name)}.service.ts.`
939
909
  });
940
910
  });
941
911
  }),
@@ -948,11 +918,11 @@ const rules = {
948
918
  if (!definition.owner) continue;
949
919
  const source = imports.get(definition.owner);
950
920
  const path = source && resolveImport(info, context, source);
951
- if (!path?.startsWith(`${info.servicesDir}/`)) continue;
952
- const owner = path.slice(info.servicesDir.length + 1).split("/")[0];
921
+ if (!path?.startsWith(`${info.settings.services}/`)) continue;
922
+ const owner = path.slice(info.settings.services.length + 1).split("/")[0];
953
923
  if (owner !== info.service) context.report({
954
924
  node: definition.call.callee,
955
- message: `This file is in ${info.service}/ but attaches to ${owner}; move it to ${info.servicesDir}/${owner}/.`
925
+ message: `This file is in ${info.service}/ but attaches to ${owner}; move it to ${info.settings.services}/${owner}/.`
956
926
  });
957
927
  }
958
928
  });
@@ -1058,13 +1028,37 @@ function resolveRules(presets = ["recommended"], overrides = {}) {
1058
1028
  if (name === "no-cross-service-tables" && severity !== "error") throw new Error(`Brick: brick/${ALWAYS_ERROR} is always an error and cannot be turned off`);
1059
1029
  resolved[`brick/${name}`] = severity;
1060
1030
  }
1031
+ resolved[`brick/${ALWAYS_ERROR}`] = "error";
1061
1032
  return resolved;
1062
1033
  }
1063
1034
  /** The file rules of a resolved rule set, as ESLint and oxlint take them. */
1064
1035
  function fileRules(resolved) {
1065
1036
  return Object.fromEntries(Object.entries(resolved).filter(([key]) => key.replace(/^brick\//, "") in rules));
1066
1037
  }
1067
- //#endregion
1068
- export { rules as a, resolveRules as i, PRESETS as n, fileRules as r, ALWAYS_ERROR as t };
1038
+ // src/lint/project.ts
1039
+ /** Rules, settings and ignores of a project, shared by brick lint and both linters. */
1040
+ function projectRules(project) {
1041
+ const lint = project.config.lint ?? {};
1042
+ let resolved;
1043
+ try {
1044
+ resolved = resolveRules(lint.presets, lint.rules);
1045
+ } catch (error) {
1046
+ throw new ConfigError(`brick.config.ts: lint.rules: ${error.message}`);
1047
+ }
1048
+ const from = (path) => relative(project.root, path).split(sep).join("/") || ".";
1049
+ const settings = {
1050
+ root: project.root,
1051
+ services: from(project.services),
1052
+ entry: from(project.entry),
1053
+ generated: from(project.generated)
1054
+ };
1055
+ return {
1056
+ resolved,
1057
+ rules: fileRules(resolved),
1058
+ settings,
1059
+ ignore: [...lint.ignore ?? [], `${settings.generated}/**`]
1060
+ };
1061
+ }
1062
+ export { rules as a, resolveRules as i, PRESETS as n, version as o, fileRules as r, serviceFolders as s, projectRules as t };
1069
1063
 
1070
- //# sourceMappingURL=presets.js.map
1064
+ //# sourceMappingURL=project.js.map