create-bunli 0.8.0 → 0.8.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 (104) hide show
  1. package/README.md +18 -6
  2. package/dist/cli.js +589 -560
  3. package/dist/create-project.d.ts +4 -4
  4. package/dist/create-project.d.ts.map +1 -1
  5. package/dist/create.d.ts +3 -3
  6. package/dist/create.d.ts.map +1 -1
  7. package/dist/index.d.ts +5 -5
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +518 -512
  10. package/dist/steps.d.ts +5 -5
  11. package/dist/steps.d.ts.map +1 -1
  12. package/dist/template-engine.d.ts +2 -2
  13. package/dist/template-engine.d.ts.map +1 -1
  14. package/dist/templates/advanced/README.md +8 -4
  15. package/dist/templates/advanced/bunli.config.ts +19 -19
  16. package/dist/templates/advanced/package.json +8 -4
  17. package/dist/templates/advanced/src/commands/config.ts +129 -119
  18. package/dist/templates/advanced/src/commands/init.ts +53 -60
  19. package/dist/templates/advanced/src/commands/serve.ts +77 -83
  20. package/dist/templates/advanced/src/commands/validate.ts +58 -66
  21. package/dist/templates/advanced/src/index.ts +30 -29
  22. package/dist/templates/advanced/src/utils/config.ts +48 -47
  23. package/dist/templates/advanced/src/utils/constants.ts +6 -6
  24. package/dist/templates/advanced/src/utils/glob.ts +29 -28
  25. package/dist/templates/advanced/src/utils/validator.ts +60 -61
  26. package/dist/templates/advanced/template.json +2 -6
  27. package/dist/templates/advanced/tsconfig.json +1 -1
  28. package/dist/templates/basic/README.md +1 -1
  29. package/dist/templates/basic/bunli.config.ts +17 -17
  30. package/dist/templates/basic/package.json +3 -3
  31. package/dist/templates/basic/src/commands/hello.ts +20 -26
  32. package/dist/templates/basic/src/index.ts +9 -8
  33. package/dist/templates/basic/template.json +2 -6
  34. package/dist/templates/basic/tsconfig.json +1 -1
  35. package/dist/templates/monorepo/README.md +1 -1
  36. package/dist/templates/monorepo/bunli.config.ts +21 -21
  37. package/dist/templates/monorepo/package.json +3 -3
  38. package/dist/templates/monorepo/packages/cli/package.json +9 -5
  39. package/dist/templates/monorepo/packages/cli/src/index.ts +13 -13
  40. package/dist/templates/monorepo/packages/cli/tsconfig.json +2 -5
  41. package/dist/templates/monorepo/packages/core/package.json +4 -4
  42. package/dist/templates/monorepo/packages/core/scripts/build.ts +10 -10
  43. package/dist/templates/monorepo/packages/core/src/commands/analyze.ts +58 -57
  44. package/dist/templates/monorepo/packages/core/src/commands/process.ts +39 -47
  45. package/dist/templates/monorepo/packages/core/src/index.ts +3 -3
  46. package/dist/templates/monorepo/packages/core/src/types.ts +15 -15
  47. package/dist/templates/monorepo/packages/core/tsconfig.json +2 -4
  48. package/dist/templates/monorepo/packages/utils/package.json +4 -4
  49. package/dist/templates/monorepo/packages/utils/scripts/build.ts +10 -10
  50. package/dist/templates/monorepo/packages/utils/src/format.ts +19 -19
  51. package/dist/templates/monorepo/packages/utils/src/index.ts +3 -3
  52. package/dist/templates/monorepo/packages/utils/src/json.ts +4 -4
  53. package/dist/templates/monorepo/packages/utils/src/logger.ts +9 -9
  54. package/dist/templates/monorepo/packages/utils/tsconfig.json +1 -1
  55. package/dist/templates/monorepo/template.json +2 -6
  56. package/dist/templates/monorepo/tsconfig.json +1 -1
  57. package/dist/templates/monorepo/turbo.json +1 -1
  58. package/dist/types.d.ts +1 -1
  59. package/dist/types.d.ts.map +1 -1
  60. package/package.json +28 -28
  61. package/templates/advanced/README.md +8 -4
  62. package/templates/advanced/bunli.config.ts +19 -19
  63. package/templates/advanced/package.json +8 -4
  64. package/templates/advanced/src/commands/config.ts +129 -119
  65. package/templates/advanced/src/commands/init.ts +53 -60
  66. package/templates/advanced/src/commands/serve.ts +77 -83
  67. package/templates/advanced/src/commands/validate.ts +58 -66
  68. package/templates/advanced/src/index.ts +30 -29
  69. package/templates/advanced/src/utils/config.ts +48 -47
  70. package/templates/advanced/src/utils/constants.ts +6 -6
  71. package/templates/advanced/src/utils/glob.ts +29 -28
  72. package/templates/advanced/src/utils/validator.ts +60 -61
  73. package/templates/advanced/template.json +2 -6
  74. package/templates/advanced/tsconfig.json +1 -1
  75. package/templates/basic/README.md +1 -1
  76. package/templates/basic/bunli.config.ts +17 -17
  77. package/templates/basic/package.json +3 -3
  78. package/templates/basic/src/commands/hello.ts +20 -26
  79. package/templates/basic/src/index.ts +9 -8
  80. package/templates/basic/template.json +2 -6
  81. package/templates/basic/tsconfig.json +1 -1
  82. package/templates/monorepo/README.md +1 -1
  83. package/templates/monorepo/bunli.config.ts +21 -21
  84. package/templates/monorepo/package.json +3 -3
  85. package/templates/monorepo/packages/cli/package.json +9 -5
  86. package/templates/monorepo/packages/cli/src/index.ts +13 -13
  87. package/templates/monorepo/packages/cli/tsconfig.json +2 -5
  88. package/templates/monorepo/packages/core/package.json +4 -4
  89. package/templates/monorepo/packages/core/scripts/build.ts +10 -10
  90. package/templates/monorepo/packages/core/src/commands/analyze.ts +58 -57
  91. package/templates/monorepo/packages/core/src/commands/process.ts +39 -47
  92. package/templates/monorepo/packages/core/src/index.ts +3 -3
  93. package/templates/monorepo/packages/core/src/types.ts +15 -15
  94. package/templates/monorepo/packages/core/tsconfig.json +2 -4
  95. package/templates/monorepo/packages/utils/package.json +4 -4
  96. package/templates/monorepo/packages/utils/scripts/build.ts +10 -10
  97. package/templates/monorepo/packages/utils/src/format.ts +19 -19
  98. package/templates/monorepo/packages/utils/src/index.ts +3 -3
  99. package/templates/monorepo/packages/utils/src/json.ts +4 -4
  100. package/templates/monorepo/packages/utils/src/logger.ts +9 -9
  101. package/templates/monorepo/packages/utils/tsconfig.json +1 -1
  102. package/templates/monorepo/template.json +2 -6
  103. package/templates/monorepo/tsconfig.json +1 -1
  104. package/templates/monorepo/turbo.json +1 -1
@@ -1,113 +1,107 @@
1
- import { defineCommand, option } from '@bunli/core'
2
- import { z } from 'zod'
3
- import { loadConfig } from '../utils/config.js'
1
+ import { defineCommand, option } from "@bunli/core";
2
+ import { z } from "zod";
3
+
4
+ import { loadConfig } from "../utils/config.js";
4
5
 
5
6
  const serveCommand = defineCommand({
6
- name: 'serve',
7
- description: 'Start a development server',
7
+ name: "serve",
8
+ description: "Start a development server",
8
9
  options: {
9
- port: option(
10
- z.coerce.number().int().min(1).max(65535).default(3000),
11
- {
12
- short: 'p',
13
- description: 'Port to listen on'
14
- }
15
- ),
16
- host: option(
17
- z.string().default('localhost'),
18
- {
19
- short: 'h',
20
- description: 'Host to bind to'
21
- }
22
- ),
23
- open: option(
24
- z.boolean().default(true),
25
- {
26
- description: 'Open browser on start',
27
- argumentKind: 'flag'
28
- }
29
- )
10
+ port: option(z.coerce.number().int().min(1).max(65535).default(3000), {
11
+ short: "p",
12
+ description: "Port to listen on",
13
+ }),
14
+ host: option(z.string().default("localhost"), {
15
+ short: "h",
16
+ description: "Host to bind to",
17
+ }),
18
+ open: option(z.boolean().default(true), {
19
+ description: "Open browser on start",
20
+ argumentKind: "flag",
21
+ }),
30
22
  },
31
23
  handler: async ({ flags, colors, spinner, shell }) => {
32
- const spin = spinner('Starting server...')
33
- spin.start()
34
-
24
+ const spin = spinner("Starting server...");
25
+ spin.start();
26
+
35
27
  try {
36
28
  // Load config
37
- const config = await loadConfig()
38
-
29
+ const config = await loadConfig();
30
+
39
31
  // Merge flags with config
40
- const port = flags.port || config.server?.port || 3000
41
- const host = flags.host || config.server?.host || 'localhost'
42
- const shouldOpen = flags.open ?? config.server?.open ?? true
43
-
32
+ const port = flags.port || config.server?.port || 3000;
33
+ const host = flags.host || config.server?.host || "localhost";
34
+ const shouldOpen = flags.open ?? config.server?.open ?? true;
35
+
44
36
  // Create server
45
37
  const server = Bun.serve({
46
38
  port,
47
39
  hostname: host,
48
40
  fetch(req) {
49
- const url = new URL(req.url)
50
-
41
+ const url = new URL(req.url);
42
+
51
43
  // Simple router
52
- if (url.pathname === '/') {
44
+ if (url.pathname === "/") {
53
45
  return new Response(getHomePage(), {
54
- headers: { 'Content-Type': 'text/html' }
55
- })
46
+ headers: { "Content-Type": "text/html" },
47
+ });
56
48
  }
57
-
58
- if (url.pathname === '/api/status') {
49
+
50
+ if (url.pathname === "/api/status") {
59
51
  return Response.json({
60
- status: 'ok',
61
- version: '0.1.0',
62
- uptime: process.uptime()
63
- })
52
+ status: "ok",
53
+ version: "0.1.0",
54
+ uptime: process.uptime(),
55
+ });
64
56
  }
65
-
66
- return new Response('Not Found', { status: 404 })
67
- }
68
- })
69
-
70
- spin.succeed(`Server running at http://${host}:${port}`)
71
-
57
+
58
+ return new Response("Not Found", { status: 404 });
59
+ },
60
+ });
61
+
62
+ spin.succeed(`Server running at http://${host}:${port}`);
63
+
72
64
  // Open browser
73
65
  if (shouldOpen) {
74
- const openSpin = spinner('Opening browser...')
75
- openSpin.start()
76
-
66
+ const openSpin = spinner("Opening browser...");
67
+ openSpin.start();
68
+
77
69
  try {
78
- const url = `http://${host === '0.0.0.0' ? 'localhost' : host}:${port}`
79
-
70
+ const url = `http://${host === "0.0.0.0" ? "localhost" : host}:${port}`;
71
+
80
72
  // Platform-specific open commands
81
- const openCommand = process.platform === 'darwin' ? 'open' :
82
- process.platform === 'win32' ? 'start' :
83
- 'xdg-open'
84
-
85
- await shell`${openCommand} ${url}`.quiet()
86
- openSpin.succeed('Browser opened')
73
+ const openCommand =
74
+ process.platform === "darwin"
75
+ ? "open"
76
+ : process.platform === "win32"
77
+ ? "start"
78
+ : "xdg-open";
79
+
80
+ await shell`${openCommand} ${url}`.quiet();
81
+ openSpin.succeed("Browser opened");
87
82
  } catch {
88
- openSpin.fail('Failed to open browser')
83
+ openSpin.fail("Failed to open browser");
89
84
  }
90
85
  }
91
-
86
+
92
87
  // Keep server running
93
- console.log()
94
- console.log(colors.dim('Press Ctrl+C to stop the server'))
95
-
88
+ console.log();
89
+ console.log(colors.dim("Press Ctrl+C to stop the server"));
90
+
96
91
  // Handle shutdown
97
- process.on('SIGINT', () => {
98
- console.log()
99
- console.log(colors.yellow('Shutting down server...'))
100
- server.stop()
101
- process.exit(0)
102
- })
103
-
92
+ process.on("SIGINT", () => {
93
+ console.log();
94
+ console.log(colors.yellow("Shutting down server..."));
95
+ server.stop();
96
+ process.exit(0);
97
+ });
104
98
  } catch (error) {
105
- spin.fail('Failed to start server')
106
- console.error(colors.red(String(error)))
107
- process.exit(1)
99
+ spin.fail("Failed to start server");
100
+ console.error(colors.red(String(error)));
101
+ process.exit(1);
108
102
  }
109
- }
110
- })
103
+ },
104
+ });
111
105
 
112
106
  function getHomePage(): string {
113
107
  return `
@@ -173,7 +167,7 @@ function getHomePage(): string {
173
167
  </div>
174
168
  </body>
175
169
  </html>
176
- `.trim()
170
+ `.trim();
177
171
  }
178
172
 
179
- export default serveCommand
173
+ export default serveCommand;
@@ -1,115 +1,107 @@
1
- import { defineCommand, option } from '@bunli/core'
2
- import { z } from 'zod'
3
- import { loadConfig } from '../utils/config.js'
4
- import { validateFiles } from '../utils/validator.js'
5
- import { glob } from '../utils/glob.js'
1
+ import { defineCommand, option } from "@bunli/core";
2
+ import { z } from "zod";
3
+
4
+ import { loadConfig } from "../utils/config.js";
5
+ import { glob } from "../utils/glob.js";
6
+ import { validateFiles } from "../utils/validator.js";
6
7
 
7
8
  const validateCommand = defineCommand({
8
- name: 'validate',
9
- description: 'Validate files against defined rules',
9
+ name: "validate",
10
+ description: "Validate files against defined rules",
10
11
  options: {
11
- config: option(
12
- z.string().optional(),
13
- {
14
- short: 'c',
15
- description: 'Path to config file'
16
- }
17
- ),
18
- fix: option(
19
- z.boolean().default(false),
20
- {
21
- short: 'f',
22
- description: 'Auto-fix issues',
23
- argumentKind: 'flag'
24
- }
25
- ),
26
- cache: option(
27
- z.boolean().default(true),
28
- {
29
- description: 'Enable caching',
30
- argumentKind: 'flag'
31
- }
32
- )
12
+ config: option(z.string().optional(), {
13
+ short: "c",
14
+ description: "Path to config file",
15
+ }),
16
+ fix: option(z.boolean().default(false), {
17
+ short: "f",
18
+ description: "Auto-fix issues",
19
+ argumentKind: "flag",
20
+ }),
21
+ cache: option(z.boolean().default(true), {
22
+ description: "Enable caching",
23
+ argumentKind: "flag",
24
+ }),
33
25
  },
34
26
  handler: async ({ positional, flags, colors, spinner }) => {
35
- const spin = spinner('Loading configuration...')
36
- spin.start()
27
+ const spin = spinner("Loading configuration...");
28
+ spin.start();
37
29
 
38
30
  try {
39
- const config = await loadConfig(flags.config)
40
- spin.succeed('Configuration loaded')
31
+ const config = await loadConfig(flags.config);
32
+ spin.succeed("Configuration loaded");
41
33
 
42
- const patterns = positional.length > 0 ? positional : config.include || ['src/**/*.{js,ts}']
34
+ const patterns = positional.length > 0 ? positional : config.include || ["src/**/*.{js,ts}"];
43
35
 
44
- const fileSpin = spinner('Resolving files...')
45
- fileSpin.start()
36
+ const fileSpin = spinner("Resolving files...");
37
+ fileSpin.start();
46
38
 
47
39
  const files = await glob(patterns, {
48
40
  include: config.include,
49
- exclude: config.exclude
50
- })
41
+ exclude: config.exclude,
42
+ });
51
43
 
52
- fileSpin.succeed(`Found ${files.length} files to validate`)
44
+ fileSpin.succeed(`Found ${files.length} files to validate`);
53
45
 
54
46
  if (files.length === 0) {
55
- console.log(colors.yellow('No files matched the pattern'))
56
- return
47
+ console.log(colors.yellow("No files matched the pattern"));
48
+ return;
57
49
  }
58
50
 
59
- const validateSpin = spinner('Validating files...')
60
- validateSpin.start()
51
+ const validateSpin = spinner("Validating files...");
52
+ validateSpin.start();
61
53
 
62
54
  const results = await validateFiles(files, {
63
55
  rules: config.rules,
64
56
  fix: flags.fix,
65
- cache: flags.cache && config.cache?.enabled
66
- })
57
+ cache: flags.cache && config.cache?.enabled,
58
+ });
67
59
 
68
- validateSpin.stop()
60
+ validateSpin.stop();
69
61
 
70
- let hasErrors = false
62
+ let hasErrors = false;
71
63
 
72
64
  for (const result of results) {
73
65
  if (result.errors.length > 0 || result.warnings.length > 0) {
74
- console.log()
75
- console.log(colors.bold(result.file))
66
+ console.log();
67
+ console.log(colors.bold(result.file));
76
68
 
77
69
  for (const error of result.errors) {
78
- console.log(colors.red(` ✗ ${error.line}:${error.column} ${error.message}`))
79
- hasErrors = true
70
+ console.log(colors.red(` ✗ ${error.line}:${error.column} ${error.message}`));
71
+ hasErrors = true;
80
72
  }
81
73
 
82
74
  for (const warning of result.warnings) {
83
- console.log(colors.yellow(` ⚠ ${warning.line}:${warning.column} ${warning.message}`))
75
+ console.log(colors.yellow(` ⚠ ${warning.line}:${warning.column} ${warning.message}`));
84
76
  }
85
77
  }
86
78
  }
87
79
 
88
- const totalErrors = results.reduce((sum, r) => sum + r.errors.length, 0)
89
- const totalWarnings = results.reduce((sum, r) => sum + r.warnings.length, 0)
80
+ const totalErrors = results.reduce((sum, r) => sum + r.errors.length, 0);
81
+ const totalWarnings = results.reduce((sum, r) => sum + r.warnings.length, 0);
90
82
 
91
- console.log()
83
+ console.log();
92
84
  if (totalErrors === 0 && totalWarnings === 0) {
93
- console.log(colors.green('✅ All files passed validation!'))
85
+ console.log(colors.green("✅ All files passed validation!"));
94
86
  } else {
95
- console.log(colors.bold('Summary:'))
87
+ console.log(colors.bold("Summary:"));
96
88
  if (totalErrors > 0) {
97
- console.log(colors.red(` ${totalErrors} error${totalErrors !== 1 ? 's' : ''}`))
89
+ console.log(colors.red(` ${totalErrors} error${totalErrors !== 1 ? "s" : ""}`));
98
90
  }
99
91
  if (totalWarnings > 0) {
100
- console.log(colors.yellow(` ${totalWarnings} warning${totalWarnings !== 1 ? 's' : ''}`))
92
+ console.log(colors.yellow(` ${totalWarnings} warning${totalWarnings !== 1 ? "s" : ""}`));
101
93
  }
102
94
 
103
95
  if (hasErrors) {
104
- process.exit(1)
96
+ process.exit(1);
105
97
  }
106
98
  }
107
99
  } catch (error) {
108
- spin.fail('Validation failed')
109
- console.error(colors.red(String(error)))
110
- process.exit(1)
100
+ spin.fail("Validation failed");
101
+ console.error(colors.red(String(error)));
102
+ process.exit(1);
111
103
  }
112
- }
113
- })
104
+ },
105
+ });
114
106
 
115
- export default validateCommand
107
+ export default validateCommand;
@@ -1,55 +1,56 @@
1
1
  #!/usr/bin/env bun
2
- import { createCLI } from '@bunli/core'
3
- import { Result, TaggedError } from 'better-result'
4
- import initCommand from './commands/init.js'
5
- import validateCommand from './commands/validate.js'
6
- import serveCommand from './commands/serve.js'
7
- import configCommand from './commands/config.js'
8
- import { loadConfig } from './utils/config.js'
2
+ import { createCLI } from "@bunli/core";
3
+ import { Result, TaggedError } from "better-result";
4
+
5
+ import configCommand from "./commands/config.js";
6
+ import initCommand from "./commands/init.js";
7
+ import serveCommand from "./commands/serve.js";
8
+ import validateCommand from "./commands/validate.js";
9
+ import { loadConfig } from "./utils/config.js";
9
10
 
10
11
  const toErrorMessage = (error: unknown): string =>
11
- error instanceof Error ? error.message : String(error)
12
+ error instanceof Error ? error.message : String(error);
12
13
 
13
- class CliStartupError extends TaggedError('CliStartupError')<{
14
- message: string
15
- cause: unknown
14
+ class CliStartupError extends TaggedError("CliStartupError")<{
15
+ message: string;
16
+ cause: unknown;
16
17
  }>() {
17
18
  constructor(cause: unknown) {
18
- super({ message: `Failed to start CLI: ${toErrorMessage(cause)}`, cause })
19
+ super({ message: `Failed to start CLI: ${toErrorMessage(cause)}`, cause });
19
20
  }
20
21
  }
21
22
 
22
23
  const cli = await createCLI({
23
- name: '{{name}}',
24
- version: '0.1.0',
25
- description: '{{description}}'
26
- })
24
+ name: "{{name}}",
25
+ version: "0.1.0",
26
+ description: "{{description}}",
27
+ });
27
28
 
28
- cli.command(initCommand)
29
- cli.command(validateCommand)
30
- cli.command(serveCommand)
31
- cli.command(configCommand)
29
+ cli.command(initCommand);
30
+ cli.command(validateCommand);
31
+ cli.command(serveCommand);
32
+ cli.command(configCommand);
32
33
 
33
34
  async function run(): Promise<Result<void, CliStartupError>> {
34
35
  const configResult = await Result.tryPromise({
35
36
  try: () => loadConfig(),
36
- catch: (cause) => new CliStartupError(cause)
37
- })
37
+ catch: (cause) => new CliStartupError(cause),
38
+ });
38
39
 
39
40
  if (Result.isError(configResult)) {
40
- return configResult
41
+ return configResult;
41
42
  }
42
43
 
43
44
  return Result.tryPromise({
44
45
  try: async () => {
45
- await cli.run()
46
+ await cli.run();
46
47
  },
47
- catch: (cause) => new CliStartupError(cause)
48
- })
48
+ catch: (cause) => new CliStartupError(cause),
49
+ });
49
50
  }
50
51
 
51
- const result = await run()
52
+ const result = await run();
52
53
  if (Result.isError(result)) {
53
- console.error(result.error.message)
54
- process.exit(1)
54
+ console.error(result.error.message);
55
+ process.exit(1);
55
56
  }
@@ -1,84 +1,85 @@
1
- import { CONFIG_FILE_NAME, DEFAULT_CONFIG } from './constants.js'
2
- import path from 'node:path'
1
+ import path from "node:path";
2
+
3
+ import { CONFIG_FILE_NAME, DEFAULT_CONFIG } from "./constants.js";
3
4
 
4
5
  export interface Config {
5
- rules?: Record<string, any>
6
+ rules?: Record<string, any>;
6
7
  server?: {
7
- port?: number
8
- host?: string
9
- open?: boolean
10
- cors?: boolean
11
- }
12
- include?: string[]
13
- exclude?: string[]
8
+ port?: number;
9
+ host?: string;
10
+ open?: boolean;
11
+ cors?: boolean;
12
+ };
13
+ include?: string[];
14
+ exclude?: string[];
14
15
  cache?: {
15
- enabled?: boolean
16
- directory?: string
17
- }
16
+ enabled?: boolean;
17
+ directory?: string;
18
+ };
18
19
  hooks?: {
19
- beforeValidate?: (files: string[]) => Promise<void>
20
- afterValidate?: (results: any) => Promise<void>
21
- }
20
+ beforeValidate?: (files: string[]) => Promise<void>;
21
+ afterValidate?: (results: any) => Promise<void>;
22
+ };
22
23
  }
23
24
 
24
- let cachedConfig: Config | null = null
25
+ let cachedConfig: Config | null = null;
25
26
 
26
27
  export async function loadConfig(configPath?: string): Promise<Config> {
27
28
  // Return cached config if available
28
29
  if (cachedConfig && !configPath) {
29
- return cachedConfig
30
+ return cachedConfig;
30
31
  }
31
-
32
- const finalPath = configPath || path.join(process.cwd(), CONFIG_FILE_NAME)
33
-
32
+
33
+ const finalPath = configPath || path.join(process.cwd(), CONFIG_FILE_NAME);
34
+
34
35
  try {
35
36
  // Check if config file exists
36
- const file = Bun.file(finalPath)
37
+ const file = Bun.file(finalPath);
37
38
  if (!(await file.exists())) {
38
- return DEFAULT_CONFIG
39
+ return DEFAULT_CONFIG;
39
40
  }
40
-
41
+
41
42
  // Import the config file
42
- const configModule = await import(finalPath)
43
- const config = configModule.default || configModule
44
-
43
+ const configModule = await import(finalPath);
44
+ const config = configModule.default || configModule;
45
+
45
46
  // Merge with defaults
46
47
  const mergedConfig: Config = {
47
48
  ...DEFAULT_CONFIG,
48
49
  ...config,
49
50
  server: {
50
51
  ...DEFAULT_CONFIG.server,
51
- ...(config.server || {})
52
- }
53
- }
52
+ ...(config.server || {}),
53
+ },
54
+ };
54
55
 
55
- cachedConfig = mergedConfig
56
- return mergedConfig
56
+ cachedConfig = mergedConfig;
57
+ return mergedConfig;
57
58
  } catch (error) {
58
- console.warn(`Failed to load config from ${finalPath}:`, error)
59
- return DEFAULT_CONFIG
59
+ console.warn(`Failed to load config from ${finalPath}:`, error);
60
+ return DEFAULT_CONFIG;
60
61
  }
61
62
  }
62
63
 
63
64
  export async function saveConfig(config: Config): Promise<void> {
64
- const configPath = path.join(process.cwd(), CONFIG_FILE_NAME)
65
-
65
+ const configPath = path.join(process.cwd(), CONFIG_FILE_NAME);
66
+
66
67
  // Convert config to ES module format
67
- const content = `export default ${JSON.stringify(config, null, 2)}`
68
-
69
- await Bun.write(configPath, content)
70
-
68
+ const content = `export default ${JSON.stringify(config, null, 2)}`;
69
+
70
+ await Bun.write(configPath, content);
71
+
71
72
  // Clear cache
72
- cachedConfig = null
73
+ cachedConfig = null;
73
74
  }
74
75
 
75
76
  export async function getConfigPath(): Promise<string> {
76
- const configPath = path.join(process.cwd(), CONFIG_FILE_NAME)
77
- const file = Bun.file(configPath)
78
-
77
+ const configPath = path.join(process.cwd(), CONFIG_FILE_NAME);
78
+ const file = Bun.file(configPath);
79
+
79
80
  if (await file.exists()) {
80
- return configPath
81
+ return configPath;
81
82
  }
82
-
83
- return 'No config file found'
83
+
84
+ return "No config file found";
84
85
  }
@@ -1,12 +1,12 @@
1
- export const CONFIG_FILE_NAME = '{{name}}.config.js'
1
+ export const CONFIG_FILE_NAME = "{{name}}.config.js";
2
2
 
3
3
  export const DEFAULT_CONFIG = {
4
4
  rules: {},
5
5
  server: {
6
6
  port: 3000,
7
- host: 'localhost',
8
- open: true
7
+ host: "localhost",
8
+ open: true,
9
9
  },
10
- include: ['src/**/*.{js,ts}'],
11
- exclude: ['node_modules', 'dist']
12
- }
10
+ include: ["src/**/*.{js,ts}"],
11
+ exclude: ["node_modules", "dist"],
12
+ };