@brickkit/cli 0.9.1 → 0.11.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 (76) hide show
  1. package/README.md +1 -1
  2. package/dashboard-dist/CollapsiblePanel-BX79_W-b.js +2 -0
  3. package/dashboard-dist/CompositeRoot-xzybXjnx.js +1 -0
  4. package/dashboard-dist/PopoverPopup-CvlmC7EL.js +1 -0
  5. package/dashboard-dist/{api-reference-r893F8zi.js → api-reference-BcAYVYwJ.js} +8 -8
  6. package/dashboard-dist/app.css +1 -1
  7. package/dashboard-dist/app.js +13 -13
  8. package/dashboard-dist/core-BGO9JZ1r.js +1 -0
  9. package/dashboard-dist/docs-DHikPD2v.js +4 -0
  10. package/dashboard-dist/kit.js +1 -0
  11. package/dashboard-dist/popover-DG498XHH.js +1 -0
  12. package/dashboard-dist/react-dom-client.js +3 -0
  13. package/dashboard-dist/react-dom.js +3 -0
  14. package/dashboard-dist/react-jsx-runtime.js +1 -1
  15. package/dashboard-dist/react.js +3 -3
  16. package/dashboard-dist/theme.css +123 -0
  17. package/dist/bin.d.ts.map +1 -1
  18. package/dist/bin.js +440 -44
  19. package/dist/bin.js.map +1 -1
  20. package/dist/client-contract-file2.js +1 -1
  21. package/dist/client-contract2.js +34 -8
  22. package/dist/client-contract2.js.map +1 -1
  23. package/dist/config.js +252 -0
  24. package/dist/config.js.map +1 -0
  25. package/dist/dashboard-extension.d.ts +27 -0
  26. package/dist/dashboard-extension.d.ts.map +1 -0
  27. package/dist/dashboard.d.ts +3127 -0
  28. package/dist/dev-telemetry-store.js +1407 -952
  29. package/dist/dev-telemetry-store.js.map +1 -1
  30. package/dist/dev-worker.js +2 -2
  31. package/dist/index.d.ts +95 -6
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +4 -4
  34. package/dist/lint/eslint.d.ts +2 -0
  35. package/dist/lint/eslint.js +1 -0
  36. package/dist/lint/oxlint.d.ts +19 -0
  37. package/dist/lint/oxlint.d.ts.map +1 -0
  38. package/dist/lint/oxlint.js +19 -0
  39. package/dist/lint/oxlint.js.map +1 -0
  40. package/dist/plugin.d.ts +76 -0
  41. package/dist/plugin.d.ts.map +1 -0
  42. package/dist/plugin.js +66 -0
  43. package/dist/plugin.js.map +1 -0
  44. package/dist/presets.js +1070 -0
  45. package/dist/presets.js.map +1 -0
  46. package/dist/runner.js +112 -26
  47. package/dist/runner.js.map +1 -1
  48. package/dist/vite.d.ts +6 -3
  49. package/dist/vite.d.ts.map +1 -1
  50. package/dist/vite.js +9 -3
  51. package/dist/vite.js.map +1 -1
  52. package/dist/workflows2.js +1 -1
  53. package/inspector-dist/client/assets/app-CvoGgWcV.css +1 -0
  54. package/inspector-dist/client/assets/{manifest-4baa7c6f.js → manifest-139c9319.js} +1 -1
  55. package/inspector-dist/client/assets/root-BMHd_XHz.css +1 -0
  56. package/inspector-dist/server/assets/{app-C-ZVJtic.js → app-DUP5RybL.js} +11 -11
  57. package/inspector-dist/server/assets/{highlighted-body-B3W2YXNL-C8sq8F_D.js → highlighted-body-B3W2YXNL-D2g4hL2-.js} +1 -1
  58. package/inspector-dist/server/assets/{index-CYlmUaKx.js → index-D71yP6AL.js} +2 -2
  59. package/inspector-dist/server/assets/{index-CWJr34WJ.js → index-wGSWRns3.js} +1 -1
  60. package/inspector-dist/server/assets/{mermaid-3ZIDBTTL-Dv5rjfMN.js → mermaid-3ZIDBTTL-DsvuKoEV.js} +1 -1
  61. package/inspector-dist/server/assets/{token-DnLp3wBO.js → token-ClUZZwXl.js} +1 -1
  62. package/inspector-dist/server/assets/{token-util-Bpfp-B0w.js → token-util-DSxMZ6nI.js} +1 -1
  63. package/inspector-dist/server/assets/{wrapper-D5LIcZ_u.js → wrapper-B3vstpCO.js} +2 -2
  64. package/inspector-dist/server/assets/{zstd-browser-decoder-BM8GpVB8.js → zstd-browser-decoder-Dn82m2BU.js} +1 -1
  65. package/inspector-dist/server/index.js +1 -1
  66. package/package.json +30 -6
  67. package/dashboard-dist/CollapsiblePanel-a54TwMKb.js +0 -2
  68. package/dashboard-dist/PopoverPopup-BLzjTqsi.js +0 -1
  69. package/dashboard-dist/core-BWAwhSFf.js +0 -1
  70. package/dashboard-dist/docs-CkMy3Y5i.js +0 -4
  71. package/dashboard-dist/preload-helper-CjQDFR0M.js +0 -1
  72. package/dist/build.js +0 -88
  73. package/dist/build.js.map +0 -1
  74. package/inspector-dist/client/assets/app-CY7CQBRo.css +0 -1
  75. package/inspector-dist/client/assets/root-CfCr265_.css +0 -1
  76. /package/inspector-dist/client/assets/{root-Bmn5n3jF.js → root-cbi6iYwg.js} +0 -0
@@ -1,5 +1,5 @@
1
- import { s as startInspector } from "./dev-telemetry-store.js";
2
- import { a as parsePort, t as startDevApplication } from "./runner.js";
1
+ import { l as startInspector } from "./dev-telemetry-store.js";
2
+ import { s as parsePort, t as startDevApplication } from "./runner.js";
3
3
  import { i as sendToSupervisor, n as installWorkerTelemetry, r as reportWorkerError } from "./dev-telemetry.js";
4
4
  import { getGlobalRegistry, stopAllEvents } from "@brickkit/core";
5
5
  //#region src/dev-worker.ts
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { n as emitHandlerFactory, t as emitCompiledApplication } from "./emit.js";
2
+ import { n as DashboardTheme, t as DashboardExtensionOptions } from "./dashboard-extension.js";
2
3
  import { BrickApp, BrickApp as BrickApp$1, BrickApp as BrickApp$2, BrickIR, CompiledApplication, CompiledHandler, CompiledRoute, CreateServerOptions, EndpointContext, EndpointDefinition, EndpointLogger, EndpointMethod, HandlerFactory, ReferenceOptions, RequestLoggingOptions, RouteIR, RouteMethod, bindCompiledApplication, brick, compileBrickApplication, loadCompiledBrickApp, referencePlugin, registerReferenceRoute, requestLoggingPlugin, scalarDocsHTML } from "@brickkit/core";
3
4
  //#region src/runner.d.ts
4
5
  interface DevServerOptions {
@@ -11,13 +12,23 @@ interface DevServerOptions {
11
12
  frontend?: string;
12
13
  /**
13
14
  * Local dashboard with live requests, traces, errors, and reloads. Needs an
14
- * entry. `historyDays` is how long finished requests are kept on disk
15
- * (default 90); zero keeps live data only.
15
+ * entry. `port` defaults to 9400. `historyDays` is how long finished
16
+ * requests are kept on disk (default 90); zero keeps live data only.
17
+ * `extension` and `theme` customise it (see `DashboardExtensionOptions`);
18
+ * `brick start` reads only those two, for the production dashboard.
16
19
  */
17
- dashboard?: {
18
- port: number;
20
+ dashboard?: ({
21
+ port?: number;
19
22
  historyDays?: number;
20
- } | false;
23
+ } & DashboardExtensionOptions) | false;
24
+ /**
25
+ * Keep `<generated>/services.gen.ts` importing every definition file under
26
+ * `services`: written before the app starts and again when files change.
27
+ */
28
+ manifest?: {
29
+ services: string;
30
+ generated: string;
31
+ };
21
32
  }
22
33
  /**
23
34
  * What `brick worker` runs: load the app and deliver its events from this
@@ -60,17 +71,95 @@ interface BuildApplicationOptions {
60
71
  port?: number;
61
72
  /** Precompile Elysia's HTTP handlers at build time (default true). */
62
73
  aot?: boolean;
74
+ /**
75
+ * The dashboard's extension, built into `<outdir>/dashboard` with those of
76
+ * the app's plugins for the production dashboard to serve; its theme is
77
+ * checked here too.
78
+ */
79
+ dashboard?: DashboardExtensionOptions;
63
80
  }
64
81
  /** Bundle an exported BrickApp with generated handlers and its original configuration. */
65
82
  export declare function buildApplication(options: BuildApplicationOptions): Promise<{
66
83
  outdir: string;
67
84
  entry: string;
68
85
  ir: import("@brickkit/core").BrickIR;
86
+ /** The built dashboard extension's folder, when there is one. */
87
+ dashboard: string | undefined;
69
88
  }>;
70
89
  //#endregion
71
90
  //#region src/client-contract.d.ts
72
91
  /** Generate browser metadata and transport types from the app's selected services. */
73
92
  export declare function generateClientContract(app: BrickApp$2): string;
74
93
  //#endregion
75
- export { type BrickApp, type BrickIR, type BuildApplicationOptions, type CompiledApplication, type CompiledHandler, type CompiledRoute, type CreateServerOptions, type DevServerOptions, type EndpointContext, type EndpointDefinition, type EndpointLogger, type EndpointMethod, type HandlerFactory, type ReferenceOptions, type RequestLoggingOptions, type RouteIR, type RouteMethod, bindCompiledApplication, brick, compileBrickApplication, emitCompiledApplication, emitHandlerFactory, loadCompiledBrickApp, referencePlugin, registerReferenceRoute, requestLoggingPlugin, scalarDocsHTML };
94
+ //#region src/config.d.ts
95
+ type LintSeverity = "error" | "warn" | "off";
96
+ type LintPreset = "recommended" | "layout" | "strict" | "plugin";
97
+ /**
98
+ * Project and tooling settings read by the `brick` CLI and its lint rules.
99
+ * Paths are relative to the folder that holds `brick.config.ts`. Runtime
100
+ * behaviour (prefix, docs, telemetry, events, sockets) stays in `brick()`.
101
+ */
102
+ interface BrickConfig {
103
+ /** App entry whose default export is the BrickApp (default `src/app.ts`). */
104
+ entry?: string;
105
+ /** Folder scanned for definition files (default `src/services`). */
106
+ services?: string;
107
+ /** Folder for `services.gen.ts` and the default contract (default `_brick`). */
108
+ generated?: string;
109
+ client?: {
110
+ output?: string;
111
+ };
112
+ openapi?: {
113
+ output?: string;
114
+ };
115
+ dev?: {
116
+ port?: number;
117
+ /** Frontend command, started once the client contract exists. Needs `client.output`. */
118
+ frontend?: string;
119
+ dashboard?: {
120
+ port?: number;
121
+ historyDays?: number;
122
+ } | false;
123
+ };
124
+ build?: {
125
+ outdir?: string;
126
+ aot?: boolean;
127
+ requestLogging?: boolean;
128
+ };
129
+ dashboard?: DashboardExtensionOptions;
130
+ lint?: {
131
+ presets?: LintPreset[];
132
+ rules?: Record<string, LintSeverity>;
133
+ ignore?: string[];
134
+ };
135
+ }
136
+ /** Types the config file in the editor; the CLI validates it at load. */
137
+ export declare function defineConfig(config: BrickConfig): BrickConfig;
138
+ interface LoadedConfig {
139
+ /** Absolute path of the config file. */
140
+ file: string;
141
+ /** Folder the config's paths are relative to. */
142
+ root: string;
143
+ config: BrickConfig;
144
+ /** Absolute paths with defaults applied. */
145
+ entry: string;
146
+ services: string;
147
+ generated: string;
148
+ }
149
+ /**
150
+ * Load and validate the project's config: `explicit` (`--config`) when given,
151
+ * else the nearest `brick.config.ts`. Returns undefined when there is none.
152
+ */
153
+ export declare function loadConfig(explicit?: string, cwd?: string): Promise<LoadedConfig | undefined>;
154
+ //#endregion
155
+ //#region src/manifest.d.ts
156
+ /** The source of `services.gen.ts`, which imports every definition file so each registers itself. */
157
+ export declare function renderManifest(services: string, generated: string): string;
158
+ /** Write `<generated>/services.gen.ts`, leaving it untouched when nothing changed. */
159
+ export declare function writeServiceManifest(options: {
160
+ services: string;
161
+ generated: string;
162
+ }): Promise<string>;
163
+ //#endregion
164
+ export { type BrickApp, type BrickConfig, type BrickIR, type BuildApplicationOptions, type CompiledApplication, type CompiledHandler, type CompiledRoute, type CreateServerOptions, type DashboardExtensionOptions, type DashboardTheme, type DevServerOptions, type EndpointContext, type EndpointDefinition, type EndpointLogger, type EndpointMethod, type HandlerFactory, type LintPreset, type LintSeverity, type LoadedConfig, type ReferenceOptions, type RequestLoggingOptions, type RouteIR, type RouteMethod, bindCompiledApplication, brick, compileBrickApplication, emitCompiledApplication, emitHandlerFactory, loadCompiledBrickApp, referencePlugin, registerReferenceRoute, requestLoggingPlugin, scalarDocsHTML };
76
165
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["BrickApp","BrickApp"],"sources":["../src/runner.ts","../src/build.ts","../src/client-contract.ts"],"mappings":";;;UA2BiB;EACf;EACA;EACA;;EAEA;;EAEA;;;;;;EAMA;IAAc;IAAc;;;;;;;;;;;;;;wBAyLR,YAAY;EAAW;IAAe,QAAAA;;;;;;;;;;;;;;;;wBAmFtC,eAAe,UAAS,mBAAqB,QAAAA;;;;;UC7SlD;;EAEf;EACA;EACA;;EAEA;;;wBAIoB,iBAAiB,SAAS,0BAAuB;;;;;;;;wBCXvD,uBAAuB,KAAKC"}
1
+ {"version":3,"file":"index.d.ts","names":["BrickApp","BrickApp"],"sources":["../src/runner.ts","../src/build.ts","../src/client-contract.ts","../src/config.ts","../src/manifest.ts"],"mappings":";;;;UAiCiB;EACf;EACA;EACA;;EAEA;;EAEA;;;;;;;;EAQA;IACO;IAAe;MAAyB;;;;;EAM/C;IAAa;IAAkB;;;;;;;;;;;;;;wBAyLX,YAAY;EAAW;IAAe,QAAAA;;;;;;;;;;;;;;;;wBA0FtC,eAAe,UAAS,mBAAqB,QAAAA;;;;;UC9TlD;;EAEf;EACA;EACA;;EAEA;;;;;;EAMA,YAAY;;;wBAIQ,iBAAiB,SAAS,0BAAuB;;;;;;;;;;wBCdvD,uBAAuB,KAAKC;;;KCHhC;KACA;;;;;;UAOK;;EAEf;;EAEA;;EAEA;EACA;IAAW;;EACX;IAAY;;EACZ;IACE;;IAEA;IACA;MAAc;MAAe;;;EAE/B;IAAU;IAAiB;IAAe;;EAC1C,YAAY;EACZ;IACE,UAAU;IACV,QAAQ,eAAe;IACvB;;;;wBAKY,aAAa,QAAQ,cAAc;UASlC;;EAEf;;EAEA;EACA,QAAQ;;EAER;EACA;EACA;;;;;;wBAgBoB,WACpB,mBACA,eACC,QAAQ;;;;wBCrCK,eAAe,kBAAkB;;wBAkB3B,qBAAqB;EACzC;EACA;IACE"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { i as startWorker, n as startDevServer } from "./runner.js";
2
- import { a as emitHandlerFactory, i as emitCompiledApplication } from "./compiler2.js";
3
- import { t as buildApplication } from "./build.js";
1
+ import { a as renderManifest, i as startWorker, n as startDevServer, o as writeServiceManifest } from "./runner.js";
4
2
  import { t as generateClientContract } from "./client-contract2.js";
3
+ import { a as emitHandlerFactory, i as emitCompiledApplication } from "./compiler2.js";
4
+ import { i as buildApplication, n as defineConfig, r as loadConfig } from "./config.js";
5
5
  import { bindCompiledApplication, brick, compileBrickApplication, loadCompiledBrickApp, referencePlugin, registerReferenceRoute, requestLoggingPlugin, scalarDocsHTML } from "@brickkit/core";
6
- export { bindCompiledApplication, brick, buildApplication, compileBrickApplication, emitCompiledApplication, emitHandlerFactory, generateClientContract, loadCompiledBrickApp, referencePlugin, registerReferenceRoute, requestLoggingPlugin, scalarDocsHTML, startDevServer, startWorker };
6
+ export { bindCompiledApplication, brick, buildApplication, compileBrickApplication, defineConfig, emitCompiledApplication, emitHandlerFactory, generateClientContract, loadCompiledBrickApp, loadConfig, referencePlugin, registerReferenceRoute, renderManifest, requestLoggingPlugin, scalarDocsHTML, startDevServer, startWorker, writeServiceManifest };
@@ -0,0 +1,2 @@
1
+ import { t as brick } from "../plugin.js";
2
+ export { brick as default };
@@ -0,0 +1 @@
1
+ export { t as default } from "../plugin.js";
@@ -0,0 +1,19 @@
1
+ import { n as Severity, t as brick } from "../plugin.js";
2
+ //#region src/lint/oxlint.d.ts
3
+ export interface OxlintConfig {
4
+ jsPlugins: {
5
+ name: string;
6
+ specifier: string;
7
+ }[];
8
+ settings: Record<string, unknown>;
9
+ rules: Record<string, Severity>;
10
+ ignorePatterns: string[];
11
+ }
12
+ /** Presets, rule settings, ignores and paths from brick.config.ts, as the fields of an oxlint config. */
13
+ export declare function fromProject(options?: {
14
+ cwd?: string;
15
+ config?: string;
16
+ }): Promise<OxlintConfig>;
17
+ //#endregion
18
+ export { brick as default };
19
+ //# sourceMappingURL=oxlint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oxlint.d.ts","names":[],"sources":["../../src/lint/oxlint.ts"],"mappings":";;iBAMiB;EACf;IAAa;IAAc;;EAC3B,UAAU;EACV,OAAO,eAAe;EACtB;;;wBAIoB,YACpB;EAAW;EAAc;IACxB,QAAQ"}
@@ -0,0 +1,19 @@
1
+ import { n as projectRules, t as brick } from "../plugin.js";
2
+ //#region src/lint/oxlint.ts
3
+ /** Presets, rule settings, ignores and paths from brick.config.ts, as the fields of an oxlint config. */
4
+ async function fromProject(options = {}) {
5
+ const { rules, settings, ignore } = await projectRules(options);
6
+ return {
7
+ jsPlugins: [{
8
+ name: "brick",
9
+ specifier: "@brickkit/cli/lint/oxlint"
10
+ }],
11
+ settings,
12
+ rules,
13
+ ignorePatterns: ignore
14
+ };
15
+ }
16
+ //#endregion
17
+ export { brick as default, fromProject };
18
+
19
+ //# sourceMappingURL=oxlint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oxlint.js","names":[],"sources":["../../src/lint/oxlint.ts"],"sourcesContent":["// @brickkit/cli/lint/oxlint: the plugin for oxlint's jsPlugins, plus a config from brick.config.ts.\nimport type { Severity } from \"./presets\";\nimport { projectRules } from \"./plugin\";\n\nexport { brick as default } from \"./plugin\";\n\nexport interface OxlintConfig {\n jsPlugins: { name: string; specifier: string }[];\n settings: Record<string, unknown>;\n rules: Record<string, Severity>;\n ignorePatterns: string[];\n}\n\n/** Presets, rule settings, ignores and paths from brick.config.ts, as the fields of an oxlint config. */\nexport async function fromProject(\n options: { cwd?: string; config?: string } = {},\n): Promise<OxlintConfig> {\n const { rules, settings, ignore } = await projectRules(options);\n return {\n jsPlugins: [{ name: \"brick\", specifier: \"@brickkit/cli/lint/oxlint\" }],\n settings,\n rules,\n ignorePatterns: ignore,\n };\n}\n"],"mappings":";;;AAcA,eAAsB,YACpB,UAA6C,CAAC,GACvB;CACvB,MAAM,EAAE,OAAO,UAAU,WAAW,MAAM,aAAa,OAAO;CAC9D,OAAO;EACL,WAAW,CAAC;GAAE,MAAM;GAAS,WAAW;EAA4B,CAAC;EACrE;EACA;EACA,gBAAgB;CAClB;AACF"}
@@ -0,0 +1,76 @@
1
+ //#region src/lint/ast.d.ts
2
+ type Node = any;
3
+ interface RuleContext {
4
+ filename: string;
5
+ cwd?: string;
6
+ settings?: {
7
+ brick?: Partial<BrickSettings>;
8
+ };
9
+ options?: unknown[];
10
+ sourceCode: {
11
+ getText(node?: Node): string;
12
+ };
13
+ report(descriptor: {
14
+ node: Node;
15
+ message: string;
16
+ fix?: (fixer: Fixer) => unknown;
17
+ }): void;
18
+ }
19
+ interface Fixer {
20
+ insertTextBefore(node: Node, text: string): unknown;
21
+ insertTextAfter(node: Node, text: string): unknown;
22
+ insertTextBeforeRange(range: [number, number], text: string): unknown;
23
+ replaceText(node: Node, text: string): unknown;
24
+ }
25
+ interface Rule {
26
+ meta: {
27
+ type: "problem" | "suggestion" | "layout";
28
+ docs: {
29
+ description: string;
30
+ };
31
+ fixable?: "code";
32
+ schema: unknown[];
33
+ };
34
+ create(context: RuleContext): Record<string, ((node: Node) => void) | undefined>;
35
+ }
36
+ /** Paths from brick.config.ts, relative to `root`. Linters pass them in `settings.brick`. */
37
+ interface BrickSettings {
38
+ root: string;
39
+ services: string;
40
+ entry: string;
41
+ generated: string;
42
+ /** Browser code folder, which may import only the client and the contract. */
43
+ web: string;
44
+ }
45
+ //#endregion
46
+ //#region src/lint/presets.d.ts
47
+ type Severity = "error" | "warn" | "off";
48
+ type PresetName = "recommended" | "layout" | "strict" | "plugin";
49
+ //#endregion
50
+ //#region src/lint/plugin.d.ts
51
+ interface FlatConfig {
52
+ name: string;
53
+ files?: string[];
54
+ ignores?: string[];
55
+ plugins: Record<string, unknown>;
56
+ settings?: Record<string, unknown>;
57
+ rules: Record<string, Severity>;
58
+ }
59
+ /** The ESLint flat-config plugin; oxlint loads the same object through `jsPlugins`. */
60
+ declare const brick: {
61
+ meta: {
62
+ name: string;
63
+ };
64
+ rules: Record<string, Rule>;
65
+ configs: Record<PresetName, FlatConfig> & {
66
+ /** Presets, rule settings, ignores and paths from brick.config.ts, as an ESLint flat-config array. */
67
+ fromProject: typeof fromProject;
68
+ };
69
+ };
70
+ declare function fromProject(options?: {
71
+ cwd?: string;
72
+ config?: string;
73
+ }): Promise<FlatConfig[]>;
74
+ //#endregion
75
+ export { Severity as n, brick as t };
76
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","names":[],"sources":["../src/lint/ast.ts","../src/lint/presets.ts","../src/lint/plugin.ts"],"mappings":";KAKY;UAEK;EACf;EACA;EACA;IAAa,QAAQ,QAAQ;;EAC7B;EACA;IAAc,QAAQ,OAAO;;EAC7B,OAAO;IACL,MAAM;IACN;IACA,OAAO,OAAO;;;UAID;EACf,iBAAiB,MAAM,MAAM;EAC7B,gBAAgB,MAAM,MAAM;EAC5B,sBAAsB,yBAAyB;EAC/C,YAAY,MAAM,MAAM;;UAGT;EACf;IACE;IACA;MAAQ;;IACR;IACA;;EAEF,OACE,SAAS,cACR,iBAAiB,MAAM;;;UAIX;EACf;EACA;EACA;EACA;;EAEA;;;;KC3CU;KACA;;;UCSF;EACR;EACA;EACA;EACA,SAAS;EACT,WAAW;EACX,OAAO,eAAe;;;cAIX;;;;EAEK,OAAA,eAAe;EAChB,SAAA,OAAO,YAAY;;IAEhC,oBAAoB;;;iBAyBT,YACb;EAAW;EAAc;IACxB,QAAQ"}
package/dist/plugin.js ADDED
@@ -0,0 +1,66 @@
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
29
+ const FILES = ["**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}"];
30
+ /** The ESLint flat-config plugin; oxlint loads the same object through `jsPlugins`. */
31
+ const brick = {
32
+ meta: { name: "brick" },
33
+ rules,
34
+ configs: {}
35
+ };
36
+ for (const name of Object.keys(PRESETS)) brick.configs[name] = {
37
+ name: `brick/${name}`,
38
+ plugins: { brick },
39
+ rules: fileRules(resolveRules([name]))
40
+ };
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
+ async function fromProject(options = {}) {
52
+ const { rules, settings, ignore } = await projectRules(options);
53
+ return [{
54
+ name: "brick/project",
55
+ files: FILES,
56
+ ignores: ignore,
57
+ plugins: { brick },
58
+ settings,
59
+ rules
60
+ }];
61
+ }
62
+ brick.configs.fromProject = fromProject;
63
+ //#endregion
64
+ export { projectRules as n, brick as t };
65
+
66
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +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"}