@bamboocss/dev 1.11.1 → 1.11.2

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 (43) hide show
  1. package/bin.js +1 -1
  2. package/dist/chunk-C2EiDwsr.cjs +35 -0
  3. package/dist/cli-default.cjs +7512 -0
  4. package/dist/cli-default.d.cts +1 -0
  5. package/dist/cli-default.d.mts +1 -0
  6. package/dist/cli-default.mjs +7322 -9871
  7. package/dist/cli-main-BJ1ZEm4m.mjs +404 -0
  8. package/dist/cli-main.cjs +381 -0
  9. package/dist/cli-main.d.cts +4 -0
  10. package/dist/cli-main.d.mts +4 -0
  11. package/dist/cli-main.mjs +2 -524
  12. package/dist/errors-BhazEH_W.cjs +125 -0
  13. package/dist/errors-DyRfueHt.mjs +119 -0
  14. package/dist/errors.cjs +3 -0
  15. package/dist/errors.d.cts +4 -0
  16. package/dist/errors.d.mts +4 -0
  17. package/dist/errors.mjs +2 -137
  18. package/dist/index.cjs +89 -0
  19. package/dist/index.d.cts +29 -0
  20. package/dist/index.d.mts +29 -0
  21. package/dist/index.mjs +34 -62
  22. package/dist/interactive-CaIz3nIj.mjs +115 -0
  23. package/dist/interactive-D7Vh3spN.cjs +134 -0
  24. package/dist/interactive.cjs +3 -0
  25. package/dist/interactive.d.cts +11 -0
  26. package/dist/interactive.d.mts +11 -0
  27. package/dist/interactive.mjs +2 -94
  28. package/dist/presets.cjs +7 -0
  29. package/dist/presets.d.cts +2 -0
  30. package/dist/presets.d.mts +2 -0
  31. package/dist/presets.mjs +3 -4
  32. package/dist/types.cjs +0 -0
  33. package/dist/types.d.cts +107 -0
  34. package/dist/types.d.mts +107 -0
  35. package/dist/types.mjs +1 -0
  36. package/package.json +20 -20
  37. package/dist/cli-default.js +0 -10022
  38. package/dist/cli-main.js +0 -537
  39. package/dist/errors.js +0 -162
  40. package/dist/index.js +0 -140
  41. package/dist/interactive.js +0 -129
  42. package/dist/presets.js +0 -37
  43. package/dist/types.js +0 -18
@@ -0,0 +1,381 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./chunk-C2EiDwsr.cjs");
3
+ const require_interactive = require("./interactive-D7Vh3spN.cjs");
4
+ let path = require("path");
5
+ let _bamboocss_shared = require("@bamboocss/shared");
6
+ let _bamboocss_config = require("@bamboocss/config");
7
+ let _bamboocss_logger = require("@bamboocss/logger");
8
+ let _bamboocss_node = require("@bamboocss/node");
9
+ let cac = require("cac");
10
+ //#region src/cli-main.ts
11
+ async function main() {
12
+ const cli = (0, cac.cac)("bamboo");
13
+ const cwd = process.cwd();
14
+ cli.command("init", "Initialize the bamboo config file").option("-i, --interactive", "Run in interactive mode", { default: false }).option("-f, --force", "Force overwrite existing config file").option("-p, --postcss", "Emit postcss config file").option("-c, --config <path>", "Path to bamboo config file").option("--cwd <cwd>", "Current working directory", { default: cwd }).option("--silent", "Suppress all messages except errors").option("--no-gitignore", "Don't update the .gitignore").option("--no-codegen", "Don't run the codegen logic").option("--out-extension <ext>", "The extension of the generated js files (default: 'mjs')").option("--outdir <dir>", "The output directory for the generated files").option("--jsx-framework <framework>", "The jsx framework to use").option("--syntax <syntax>", "The css syntax preference").option("--strict-tokens", "Using strictTokens: true").option("--logfile <file>", "Outputs logs to a file").action(async (initFlags = {}) => {
15
+ let options = {};
16
+ if (initFlags.interactive) options = await require_interactive.interactive();
17
+ const flags = {
18
+ ...initFlags,
19
+ ...options
20
+ };
21
+ const { force, postcss, silent, gitignore, outExtension, jsxFramework, config: configPath, syntax } = flags;
22
+ const cwd = (0, path.resolve)(flags.cwd ?? "");
23
+ if (silent) _bamboocss_logger.logger.level = "silent";
24
+ const stream = (0, _bamboocss_node.setLogStream)({
25
+ cwd,
26
+ logfile: flags.logfile
27
+ });
28
+ _bamboocss_logger.logger.info("cli", `Bamboo v${require_interactive.version}\n`);
29
+ const done = _bamboocss_logger.logger.time.info("✨ Bamboo initialized");
30
+ if (postcss) await (0, _bamboocss_node.setupPostcss)(cwd);
31
+ await (0, _bamboocss_node.setupConfig)(cwd, (0, _bamboocss_shared.compact)({
32
+ force,
33
+ outExtension,
34
+ jsxFramework,
35
+ syntax,
36
+ outdir: flags.outdir
37
+ }));
38
+ const ctx = await (0, _bamboocss_node.loadConfigAndCreateContext)({
39
+ cwd,
40
+ configPath,
41
+ config: (0, _bamboocss_shared.compact)({
42
+ gitignore,
43
+ outdir: flags.outdir
44
+ })
45
+ });
46
+ if (gitignore) (0, _bamboocss_node.setupGitIgnore)(ctx);
47
+ if (flags.codegen) {
48
+ const { msg, box } = await (0, _bamboocss_node.codegen)(ctx);
49
+ _bamboocss_logger.logger.log(msg + box);
50
+ } else _bamboocss_logger.logger.log(ctx.initMessage());
51
+ done();
52
+ stream.end();
53
+ });
54
+ cli.command("codegen", "Generate the bamboo system").option("--silent", "Don't print any logs").option("--clean", "Clean the output directory before generating").option("-c, --config <path>", "Path to bamboo config file").option("-w, --watch", "Watch files and rebuild").option("-p, --poll", "Use polling instead of filesystem events when watching").option("--cwd <cwd>", "Current working directory", { default: cwd }).option("--cpu-prof", "Generates a `.cpuprofile` to help debug performance issues").option("--logfile <file>", "Outputs logs to a file").action(async (flags) => {
55
+ const { silent, clean, config: configPath, watch, poll } = flags;
56
+ const cwd = (0, path.resolve)(flags.cwd ?? "");
57
+ const stream = (0, _bamboocss_node.setLogStream)({
58
+ cwd,
59
+ logfile: flags.logfile
60
+ });
61
+ let stopProfiling = () => void 0;
62
+ if (flags.cpuProf) stopProfiling = await (0, _bamboocss_node.startProfiling)(cwd, "codegen", flags.watch);
63
+ if (silent) _bamboocss_logger.logger.level = "silent";
64
+ let ctx = await (0, _bamboocss_node.loadConfigAndCreateContext)({
65
+ cwd,
66
+ config: { clean },
67
+ configPath
68
+ });
69
+ const { msg } = await (0, _bamboocss_node.codegen)(ctx);
70
+ _bamboocss_logger.logger.log(msg);
71
+ if (watch) ctx.watchConfig(async () => {
72
+ const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
73
+ ctx = new _bamboocss_node.BambooContext(conf);
74
+ });
75
+ await ctx.hooks["config:change"]?.({
76
+ config: ctx.config,
77
+ changes: affecteds
78
+ });
79
+ await (0, _bamboocss_node.codegen)(ctx, Array.from(affecteds.artifacts));
80
+ _bamboocss_logger.logger.info("ctx:updated", "config rebuilt ✅");
81
+ }, {
82
+ cwd,
83
+ poll
84
+ });
85
+ else stream.end();
86
+ stopProfiling();
87
+ });
88
+ cli.command("cssgen [globOrType]", "Generate the css from files, or generate the css from the specified type which can be: preflight, tokens, static, global, keyframes").option("--silent", "Don't print any logs").option("-m, --minify", "Minify generated code").option("--clean", "Clean the output before generating").option("-c, --config <path>", "Path to bamboo config file").option("-w, --watch", "Watch files and rebuild").option("--minimal", "Do not include CSS generation for theme tokens, preflight, keyframes, static and global css").option("--lightningcss", "Use `lightningcss` instead of `postcss` for css optimization.").option("--polyfill", "Polyfill CSS @layers at-rules for older browsers.").option("-p, --poll", "Use polling instead of filesystem events when watching").option("-o, --outfile [file]", "Output file for extracted css, default to './styled-system/styles.css'").option("--splitting", "Emit CSS as separate files per layer (reset, global, tokens, utilities) and per recipe").option("--cwd <cwd>", "Current working directory", { default: cwd }).option("--cpu-prof", "Generates a `.cpuprofile` to help debug performance issues").option("--logfile <file>", "Outputs logs to a file").action(async (maybeGlob, flags = {}) => {
89
+ const { silent, config: configPath, outfile, watch, poll, minimal, splitting, ...rest } = flags;
90
+ const cwd = (0, path.resolve)(flags.cwd ?? "");
91
+ const stream = (0, _bamboocss_node.setLogStream)({
92
+ cwd,
93
+ logfile: flags.logfile
94
+ });
95
+ let stopProfiling = () => void 0;
96
+ if (flags.cpuProf) stopProfiling = await (0, _bamboocss_node.startProfiling)(cwd, "cssgen", flags.watch);
97
+ const cssArtifact = [
98
+ "preflight",
99
+ "tokens",
100
+ "static",
101
+ "global",
102
+ "keyframes"
103
+ ].find((type) => type === maybeGlob);
104
+ const glob = cssArtifact ? void 0 : maybeGlob;
105
+ if (silent) _bamboocss_logger.logger.level = "silent";
106
+ let ctx = await (0, _bamboocss_node.loadConfigAndCreateContext)({
107
+ cwd,
108
+ config: {
109
+ ...rest,
110
+ ...glob ? { include: [glob] } : void 0
111
+ },
112
+ configPath
113
+ });
114
+ const options = {
115
+ cwd,
116
+ outfile,
117
+ type: cssArtifact,
118
+ minimal,
119
+ splitting
120
+ };
121
+ await (0, _bamboocss_node.cssgen)(ctx, options);
122
+ if (watch) {
123
+ ctx.watchConfig(async () => {
124
+ const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
125
+ ctx = new _bamboocss_node.BambooContext(conf);
126
+ });
127
+ await ctx.hooks["config:change"]?.({
128
+ config: ctx.config,
129
+ changes: affecteds
130
+ });
131
+ await (0, _bamboocss_node.cssgen)(ctx, options);
132
+ _bamboocss_logger.logger.info("ctx:updated", "config rebuilt ✅");
133
+ }, {
134
+ cwd,
135
+ poll
136
+ });
137
+ ctx.watchFiles(async (event, file) => {
138
+ if (event === "unlink") ctx.project.removeSourceFile(ctx.runtime.path.abs(cwd, file));
139
+ else if (event === "change") {
140
+ ctx.project.reloadSourceFile(file);
141
+ await (0, _bamboocss_node.cssgen)(ctx, options);
142
+ } else if (event === "add") {
143
+ ctx.project.createSourceFile(file);
144
+ await (0, _bamboocss_node.cssgen)(ctx, options);
145
+ }
146
+ });
147
+ } else {
148
+ stream.end();
149
+ stopProfiling();
150
+ }
151
+ });
152
+ cli.command("[files]", "Include file glob", { ignoreOptionDefaultValue: true }).option("-o, --outdir <dir>", "Output directory", { default: "styled-system" }).option("-m, --minify", "Minify generated code").option("-w, --watch", "Watch files and rebuild").option("-p, --poll", "Use polling instead of filesystem events when watching").option("-c, --config <path>", "Path to bamboo config file").option("--cwd <cwd>", "Current working directory", { default: cwd }).option("--preflight", "Enable css reset").option("--silent", "Suppress all messages except errors").option("-e, --exclude <files>", "Exclude files", { default: [] }).option("--clean", "Clean output directory").option("--hash", "Hash the generated classnames to make them shorter").option("--lightningcss", "Use `lightningcss` instead of `postcss` for css optimization.").option("--polyfill", "Polyfill CSS @layers at-rules for older browsers.").option("--emitTokensOnly", "Whether to only emit the `tokens` directory").option("--cpu-prof", "Generates a `.cpuprofile` to help debug performance issues").option("--logfile <file>", "Outputs logs to a file").action(async (files, flags) => {
153
+ const { config: configPath, silent, ...rest } = flags;
154
+ const cwd = (0, path.resolve)(flags.cwd ?? "");
155
+ const stream = (0, _bamboocss_node.setLogStream)({
156
+ cwd,
157
+ logfile: flags.logfile
158
+ });
159
+ let stopProfiling = () => void 0;
160
+ if (flags.cpuProf) stopProfiling = await (0, _bamboocss_node.startProfiling)(cwd, "cli", flags.watch);
161
+ if (silent) _bamboocss_logger.logger.level = "silent";
162
+ await (0, _bamboocss_node.generate)((0, _bamboocss_shared.compact)({
163
+ include: files,
164
+ ...rest,
165
+ cwd
166
+ }), configPath);
167
+ stopProfiling();
168
+ if (!flags.watch) stream.end();
169
+ });
170
+ cli.command("spec", "Generate spec files for your theme (useful for documentation)").option("--silent", "Don't print any logs").option("--outdir <dir>", "Output directory for spec files").option("-c, --config <path>", "Path to bamboo config file").option("--cwd <cwd>", "Current working directory", { default: cwd }).action(async (flags) => {
171
+ const { silent, config: configPath, outdir } = flags;
172
+ const cwd = (0, path.resolve)(flags.cwd ?? "");
173
+ if (silent) _bamboocss_logger.logger.level = "silent";
174
+ await (0, _bamboocss_node.spec)(await (0, _bamboocss_node.loadConfigAndCreateContext)({
175
+ cwd,
176
+ configPath,
177
+ config: { cwd }
178
+ }), { outdir });
179
+ });
180
+ cli.command("studio", "Realtime documentation for your design tokens").option("--build", "Build").option("--preview", "Preview").option("--port <port>", "Port").option("--host", "Host").option("-c, --config <path>", "Path to bamboo config file").option("--cwd <cwd>", "Current working directory", { default: cwd }).option("--outdir <dir>", "Output directory for static files").option("--base <path>", "Base path of project").action(async (flags) => {
181
+ const { build, preview, port, host, outdir, config, base } = flags;
182
+ const cwd = (0, path.resolve)(flags.cwd ?? "");
183
+ const ctx = await (0, _bamboocss_node.loadConfigAndCreateContext)({
184
+ cwd,
185
+ configPath: config
186
+ });
187
+ const buildOpts = {
188
+ configPath: (0, _bamboocss_config.findConfig)({
189
+ cwd,
190
+ file: config
191
+ }),
192
+ outDir: (0, path.resolve)(outdir || ctx.studio.outdir),
193
+ port,
194
+ host,
195
+ base
196
+ };
197
+ let studio;
198
+ try {
199
+ const studioPath = require.resolve("@bamboocss/studio", { paths: [cwd] });
200
+ studio = require(studioPath);
201
+ } catch (error) {
202
+ throw new _bamboocss_shared.BambooError("MISSING_STUDIO", "You need to install '@bamboocss/studio' to use this command", { cause: error });
203
+ }
204
+ if (preview) await studio.previewStudio(buildOpts);
205
+ else if (build) await studio.buildStudio(buildOpts);
206
+ else {
207
+ await studio.serveStudio(buildOpts);
208
+ const note = `use ${_bamboocss_logger.colors.reset(_bamboocss_logger.colors.bold("--build"))} to build`;
209
+ const port = `use ${_bamboocss_logger.colors.reset(_bamboocss_logger.colors.bold("--port"))} for a different port`;
210
+ _bamboocss_logger.logger.log(_bamboocss_logger.colors.dim(` ${_bamboocss_logger.colors.green("➜")} ${_bamboocss_logger.colors.bold("Build")}: ${note}`));
211
+ _bamboocss_logger.logger.log(_bamboocss_logger.colors.dim(` ${_bamboocss_logger.colors.green("➜")} ${_bamboocss_logger.colors.bold("Port")}: ${port}`));
212
+ }
213
+ });
214
+ cli.command("analyze [glob]", "Analyze design token usage in glob").option("--outfile [filepath]", "Output analyze report in JSON").option("--silent", "Don't print any logs").option("--scope <type>", "Select analysis scope (token or recipe)").option("-c, --config <path>", "Path to bamboo config file").option("--cwd <cwd>", "Current working directory", { default: cwd }).action(async (maybeGlob, flags = {}) => {
215
+ const { silent, config: configPath, scope } = flags;
216
+ const tokenScope = scope == null || scope === "token";
217
+ const recipeScope = scope == null || scope === "recipe";
218
+ const cwd = (0, path.resolve)(flags.cwd);
219
+ if (silent) _bamboocss_logger.logger.level = "silent";
220
+ const ctx = await (0, _bamboocss_node.loadConfigAndCreateContext)({
221
+ cwd,
222
+ config: maybeGlob ? { include: [maybeGlob] } : void 0,
223
+ configPath
224
+ });
225
+ const result = (0, _bamboocss_node.analyze)(ctx);
226
+ if (flags?.outfile && typeof flags.outfile === "string") {
227
+ await result.writeReport(flags.outfile);
228
+ _bamboocss_logger.logger.info("cli", `JSON report saved to ${(0, path.resolve)(flags.outfile)}`);
229
+ return;
230
+ }
231
+ if (tokenScope) if (!ctx.tokens.isEmpty) {
232
+ const tokenAnalysis = result.getTokenReport();
233
+ _bamboocss_logger.logger.info("analyze:tokens", `Token usage report 🎨 \n${tokenAnalysis.formatted}`);
234
+ } else _bamboocss_logger.logger.info("analyze:tokens", "No tokens found");
235
+ if (recipeScope) if (!ctx.recipes.isEmpty()) {
236
+ const recipeAnalysis = result.getRecipeReport();
237
+ _bamboocss_logger.logger.info("analyze:recipes", `Config recipes usage report 🎛️ \n${recipeAnalysis.formatted}`);
238
+ } else _bamboocss_logger.logger.info("analyze:recipes", "No config recipes found");
239
+ });
240
+ cli.command("debug [glob]", "Debug design token extraction & css generated from files in glob").option("--silent", "Don't print any logs").option("--dry", "Output debug files in stdout without writing to disk").option("--outdir [dir]", "Output directory for debug files, default to './styled-system/debug'").option("--only-config", "Should only output the config file, default to 'false'").option("-c, --config <path>", "Path to bamboo config file").option("--cwd <cwd>", "Current working directory", { default: cwd }).option("--cpu-prof", "Generates a `.cpuprofile` to help debug performance issues").option("--logfile <file>", "Outputs logs to a file").action(async (maybeGlob, flags = {}) => {
241
+ const { silent, dry = false, outdir: outdirFlag, config: configPath } = flags ?? {};
242
+ const cwd = (0, path.resolve)(flags.cwd);
243
+ const stream = (0, _bamboocss_node.setLogStream)({
244
+ cwd,
245
+ logfile: flags.logfile
246
+ });
247
+ let stopProfiling = () => void 0;
248
+ if (flags.cpuProf) stopProfiling = await (0, _bamboocss_node.startProfiling)(cwd, "debug");
249
+ if (silent) _bamboocss_logger.logger.level = "silent";
250
+ const ctx = await (0, _bamboocss_node.loadConfigAndCreateContext)({
251
+ cwd,
252
+ config: maybeGlob ? { include: [maybeGlob] } : void 0,
253
+ configPath
254
+ });
255
+ await (0, _bamboocss_node.debug)(ctx, {
256
+ outdir: outdirFlag ?? (0, path.join)(...ctx.paths.root, "debug"),
257
+ dry,
258
+ onlyConfig: flags.onlyConfig
259
+ });
260
+ stopProfiling();
261
+ stream.end();
262
+ });
263
+ cli.command("ship [glob]", "Ship extract result from files in glob").option("--silent", "Don't print any logs").option("--o, --outfile [file]", "Output path for the build info file, default to './styled-system/bamboo.buildinfo.json'").option("-m, --minify", "Minify generated JSON file").option("-c, --config <path>", "Path to bamboo config file").option("--cwd <cwd>", "Current working directory", { default: cwd }).option("-w, --watch", "Watch files and rebuild").option("-p, --poll", "Use polling instead of filesystem events when watching").action(async (maybeGlob, flags = {}) => {
264
+ const { silent, outfile: outfileFlag, minify, config: configPath, watch, poll } = flags;
265
+ const cwd = (0, path.resolve)(flags.cwd);
266
+ if (silent) _bamboocss_logger.logger.level = "silent";
267
+ let ctx = await (0, _bamboocss_node.loadConfigAndCreateContext)({
268
+ cwd,
269
+ config: maybeGlob ? { include: [maybeGlob] } : void 0,
270
+ configPath
271
+ });
272
+ const outfile = outfileFlag ?? (0, path.join)(...ctx.paths.root, "bamboo.buildinfo.json");
273
+ if (minify) ctx.config.minify = true;
274
+ await (0, _bamboocss_node.buildInfo)(ctx, outfile);
275
+ if (watch) {
276
+ ctx.watchConfig(async () => {
277
+ const affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
278
+ ctx = new _bamboocss_node.BambooContext(conf);
279
+ });
280
+ await ctx.hooks["config:change"]?.({
281
+ config: ctx.config,
282
+ changes: affecteds
283
+ });
284
+ await (0, _bamboocss_node.buildInfo)(ctx, outfile);
285
+ _bamboocss_logger.logger.info("ctx:updated", "config rebuilt ✅");
286
+ }, {
287
+ cwd,
288
+ poll
289
+ });
290
+ ctx.watchFiles(async (event, file) => {
291
+ if (event === "unlink") ctx.project.removeSourceFile(ctx.runtime.path.abs(cwd, file));
292
+ else if (event === "change") {
293
+ ctx.project.reloadSourceFile(file);
294
+ await (0, _bamboocss_node.buildInfo)(ctx, outfile);
295
+ } else if (event === "add") {
296
+ ctx.project.createSourceFile(file);
297
+ await (0, _bamboocss_node.buildInfo)(ctx, outfile);
298
+ }
299
+ });
300
+ }
301
+ });
302
+ cli.command("emit-pkg", "Emit package.json with entrypoints").option("--outdir <dir>", "Output directory", { default: "." }).option("--base <source>", "The base directory of the package.json entrypoints").option("--silent", "Don't print any logs").option("--cwd <cwd>", "Current working directory", { default: cwd }).action(async (flags) => {
303
+ const { outdir, silent, base } = flags;
304
+ if (silent) _bamboocss_logger.logger.level = "silent";
305
+ const cwd = (0, path.resolve)(flags.cwd);
306
+ const ctx = await (0, _bamboocss_node.loadConfigAndCreateContext)({
307
+ cwd,
308
+ config: { cwd }
309
+ });
310
+ const pkgPath = (0, path.resolve)(cwd, outdir, "package.json");
311
+ const exists = ctx.runtime.fs.existsSync(pkgPath);
312
+ const exports = [];
313
+ const createDir = (...dir) => {
314
+ return [
315
+ ".",
316
+ base,
317
+ ...dir
318
+ ].filter(Boolean).join("/");
319
+ };
320
+ const createEntry = (dir) => ({
321
+ types: ctx.file.extDts(createDir(dir, "index")),
322
+ require: ctx.file.ext(createDir(dir, "index")),
323
+ import: ctx.file.ext(createDir(dir, "index"))
324
+ });
325
+ exports.push(["./css", createEntry("css")], ["./tokens", createEntry("tokens")], ["./types", createEntry("types")]);
326
+ if (!ctx.patterns.isEmpty()) exports.push(["./patterns", createEntry("patterns")]);
327
+ if (!ctx.recipes.isEmpty()) exports.push(["./recipes", createEntry("recipes")]);
328
+ if (!ctx.patterns.isEmpty()) exports.push(["./jsx", createEntry("jsx")]);
329
+ if (ctx.config.themes) exports.push(["./themes", createEntry("themes")]);
330
+ const stylesDir = createDir("styles.css");
331
+ if (!exists) {
332
+ const content = {
333
+ name: outdir,
334
+ description: "This package is auto-generated by Bamboo CSS",
335
+ version: "0.1.0",
336
+ type: "module",
337
+ keywords: [
338
+ "bamboocss",
339
+ "styled-system",
340
+ "codegen"
341
+ ],
342
+ license: "ISC",
343
+ exports: {
344
+ ...Object.fromEntries(exports),
345
+ "./styles.css": stylesDir
346
+ },
347
+ scripts: { prepare: "bamboo codegen --clean" }
348
+ };
349
+ await ctx.runtime.fs.writeFile(pkgPath, JSON.stringify(content, null, 2));
350
+ } else {
351
+ const content = JSON.parse(ctx.runtime.fs.readFileSync(pkgPath));
352
+ content.exports = {
353
+ ...content.exports,
354
+ ...Object.fromEntries(exports),
355
+ "./styles.css": stylesDir
356
+ };
357
+ await ctx.runtime.fs.writeFile(pkgPath, JSON.stringify(content, null, 2));
358
+ }
359
+ _bamboocss_logger.logger.info("cli", `Emit package.json to ${pkgPath}`);
360
+ });
361
+ cli.command("mcp", "Start MCP server for AI assistants").option("-c, --config <path>", "Path to bamboo config file").option("--cwd <cwd>", "Current working directory", { default: cwd }).action(async (mcpFlags) => {
362
+ const { startMcpServer } = await import("@bamboocss/mcp");
363
+ await startMcpServer(mcpFlags);
364
+ });
365
+ cli.command("init-mcp", "Initialize MCP configuration for AI clients").option("--cwd <cwd>", "Current working directory", { default: cwd }).option("--client <clients>", "AI clients to configure (claude, cursor, vscode, windsurf, codex)").action(async (mcpInitFlags) => {
366
+ const { initMcpConfig } = await import("@bamboocss/mcp");
367
+ const resolvedCwd = (0, path.resolve)(mcpInitFlags.cwd ?? cwd);
368
+ let clients;
369
+ if (mcpInitFlags.client) clients = (Array.isArray(mcpInitFlags.client) ? mcpInitFlags.client : [mcpInitFlags.client]).flatMap((c) => c.split(",")).map((c) => c.trim());
370
+ await initMcpConfig({
371
+ cwd: resolvedCwd,
372
+ clients
373
+ });
374
+ });
375
+ cli.help();
376
+ cli.version(require_interactive.version);
377
+ cli.parse(process.argv, { run: false });
378
+ await cli.runMatchedCommand();
379
+ }
380
+ //#endregion
381
+ exports.main = main;
@@ -0,0 +1,4 @@
1
+ //#region src/cli-main.d.ts
2
+ declare function main(): Promise<void>;
3
+ //#endregion
4
+ export { main };
@@ -0,0 +1,4 @@
1
+ //#region src/cli-main.d.ts
2
+ declare function main(): Promise<void>;
3
+ //#endregion
4
+ export { main };