create-bunli 0.2.0 → 0.3.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 (33) hide show
  1. package/dist/cli.js +9 -0
  2. package/dist/index.js +9 -0
  3. package/dist/templates/advanced/.bunli/commands.gen.report.json +6 -0
  4. package/dist/templates/advanced/.bunli/commands.gen.ts +66 -0
  5. package/dist/templates/advanced/package.json +1 -0
  6. package/dist/templates/advanced/src/index.ts +1 -1
  7. package/dist/templates/advanced/template.json +8 -1
  8. package/dist/templates/basic/.bunli/commands.gen.report.json +6 -0
  9. package/dist/templates/basic/.bunli/commands.gen.ts +66 -0
  10. package/dist/templates/basic/package.json +1 -0
  11. package/dist/templates/basic/src/index.ts +1 -1
  12. package/dist/templates/monorepo/.bunli/commands.gen.report.json +6 -0
  13. package/dist/templates/monorepo/.bunli/commands.gen.ts +66 -0
  14. package/dist/templates/monorepo/package.json +1 -0
  15. package/dist/templates/monorepo/packages/cli/package.json +1 -0
  16. package/dist/templates/monorepo/packages/cli/src/index.ts +1 -1
  17. package/dist/templates/monorepo/template.json +8 -1
  18. package/package.json +2 -2
  19. package/templates/advanced/.bunli/commands.gen.report.json +6 -0
  20. package/templates/advanced/.bunli/commands.gen.ts +66 -0
  21. package/templates/advanced/package.json +1 -0
  22. package/templates/advanced/src/index.ts +1 -1
  23. package/templates/advanced/template.json +8 -1
  24. package/templates/basic/.bunli/commands.gen.report.json +6 -0
  25. package/templates/basic/.bunli/commands.gen.ts +66 -0
  26. package/templates/basic/package.json +1 -0
  27. package/templates/basic/src/index.ts +1 -1
  28. package/templates/monorepo/.bunli/commands.gen.report.json +6 -0
  29. package/templates/monorepo/.bunli/commands.gen.ts +66 -0
  30. package/templates/monorepo/package.json +1 -0
  31. package/templates/monorepo/packages/cli/package.json +1 -0
  32. package/templates/monorepo/packages/cli/src/index.ts +1 -1
  33. package/templates/monorepo/template.json +8 -1
package/dist/cli.js CHANGED
@@ -102,6 +102,15 @@ async function getFilesToProcess(dir, manifest) {
102
102
  }
103
103
  }
104
104
  await walk(dir);
105
+ if (manifest?.files?.exclude) {
106
+ return files.filter((file) => {
107
+ return !manifest.files.exclude.some((pattern) => {
108
+ const regexPattern = pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]");
109
+ const regex = new RegExp(`^${regexPattern}$`);
110
+ return regex.test(file);
111
+ });
112
+ });
113
+ }
105
114
  return files;
106
115
  }
107
116
  async function runPostInstallHooks(dir, hooks) {
package/dist/index.js CHANGED
@@ -96,6 +96,15 @@ async function getFilesToProcess(dir, manifest) {
96
96
  }
97
97
  }
98
98
  await walk(dir);
99
+ if (manifest?.files?.exclude) {
100
+ return files.filter((file) => {
101
+ return !manifest.files.exclude.some((pattern) => {
102
+ const regexPattern = pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]");
103
+ const regex = new RegExp(`^${regexPattern}$`);
104
+ return regex.test(file);
105
+ });
106
+ });
107
+ }
99
108
  return files;
100
109
  }
101
110
  async function runPostInstallHooks(dir, hooks) {
@@ -0,0 +1,6 @@
1
+ {
2
+ "commandsParsed": 0,
3
+ "filesScanned": 0,
4
+ "skipped": [],
5
+ "names": []
6
+ }
@@ -0,0 +1,66 @@
1
+ // This file was automatically generated by Bunli.
2
+ // You should NOT make any changes in this file as it will be overwritten.
3
+
4
+ import type { Command, CLI, GeneratedOptionMeta, RegisteredCommands, CommandOptions, GeneratedCommandMeta } from '@bunli/core'
5
+ import { createGeneratedHelpers, registerGeneratedStore } from '@bunli/core'
6
+
7
+
8
+
9
+ // Narrow list of command names to avoid typeof-cycles in types
10
+ const names = [] as const
11
+ type GeneratedNames = typeof names[number]
12
+
13
+ const modules: Record<GeneratedNames, Command<any>> = {
14
+
15
+ } as const
16
+
17
+ const metadata: Record<GeneratedNames, GeneratedCommandMeta> = {
18
+
19
+ } as const
20
+
21
+ export const generated = registerGeneratedStore(createGeneratedHelpers(modules, metadata))
22
+
23
+ export const commands = generated.commands
24
+ export const commandMeta = generated.metadata
25
+
26
+ export interface GeneratedCLI {
27
+ register(cli?: CLI<any>): GeneratedCLI
28
+ list(): Array<{
29
+ name: GeneratedNames
30
+ command: (typeof modules)[GeneratedNames]
31
+ metadata: (typeof metadata)[GeneratedNames]
32
+ }>
33
+ get<Name extends GeneratedNames>(name: Name): (typeof modules)[Name]
34
+ getMetadata<Name extends GeneratedNames>(name: Name): (typeof metadata)[Name]
35
+ getFlags<Name extends keyof RegisteredCommands & string>(name: Name): CommandOptions<Name>
36
+ getFlagsMeta<Name extends GeneratedNames>(name: Name): Record<string, GeneratedOptionMeta>
37
+ withCLI(cli: CLI<any>): { execute(name: string, options: unknown): Promise<void> }
38
+ }
39
+
40
+ export const cli: GeneratedCLI = {
41
+ register: (cliInstance?: CLI<any>) => { generated.register(cliInstance); return cli },
42
+ list: () => generated.list(),
43
+ get: <Name extends GeneratedNames>(name: Name) => generated.get(name),
44
+ getMetadata: <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name),
45
+ getFlags: <Name extends keyof RegisteredCommands & string>(name: Name) => generated.getFlags(name) as CommandOptions<Name>,
46
+ getFlagsMeta: <Name extends GeneratedNames>(name: Name) => generated.getFlagsMeta(name),
47
+ withCLI: (cliInstance) => generated.withCLI(cliInstance)
48
+ }
49
+
50
+ // Enhanced helper functions
51
+ export const listCommands = () => generated.list().map(c => c.name)
52
+ export const getCommandApi = <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name)
53
+ export const getTypedFlags = <Name extends GeneratedNames>(name: Name) => generated.getFlags(name) as CommandOptions<Name>
54
+ export const validateCommand = <Name extends GeneratedNames>(name: Name, flags: Record<string, unknown>) => generated.validateCommand(name, flags)
55
+ export const findCommandByName = <Name extends GeneratedNames>(name: Name) => generated.findByName(name)
56
+ export const findCommandsByDescription = (searchTerm: string) => generated.findByDescription(searchTerm)
57
+ export const getCommandNames = () => generated.getCommandNames()
58
+
59
+ // Auto-register on import for zero-config usage
60
+ export default cli
61
+
62
+ // Ensure module augmentation happens on import
63
+ declare module '@bunli/core' {
64
+ // Precise key mapping without typeof cycles
65
+ interface RegisteredCommands extends Record<GeneratedNames, Command<any>> {}
66
+ }
@@ -9,6 +9,7 @@
9
9
  "{{projectName}}": "./dist/index.js"
10
10
  },
11
11
  "scripts": {
12
+ "postinstall": "bunli generate",
12
13
  "dev": "bun run src/index.ts",
13
14
  "build": "bunli build",
14
15
  "test": "bun test",
@@ -6,7 +6,7 @@ import { serveCommand } from './commands/serve.js'
6
6
  import { configCommand } from './commands/config.js'
7
7
  import { loadConfig } from './utils/config.js'
8
8
 
9
- const cli = createCLI({
9
+ const cli = await createCLI({
10
10
  name: '{{projectName}}',
11
11
  version: '0.1.0',
12
12
  description: '{{description}}'
@@ -33,5 +33,12 @@
33
33
  { "label": "Unlicense", "value": "Unlicense" }
34
34
  ]
35
35
  }
36
- ]
36
+ ],
37
+ "files": {
38
+ "exclude": [
39
+ "node_modules/**",
40
+ ".git/**",
41
+ "template.json"
42
+ ]
43
+ }
37
44
  }
@@ -0,0 +1,6 @@
1
+ {
2
+ "commandsParsed": 0,
3
+ "filesScanned": 0,
4
+ "skipped": [],
5
+ "names": []
6
+ }
@@ -0,0 +1,66 @@
1
+ // This file was automatically generated by Bunli.
2
+ // You should NOT make any changes in this file as it will be overwritten.
3
+
4
+ import type { Command, CLI, GeneratedOptionMeta, RegisteredCommands, CommandOptions, GeneratedCommandMeta } from '@bunli/core'
5
+ import { createGeneratedHelpers, registerGeneratedStore } from '@bunli/core'
6
+
7
+
8
+
9
+ // Narrow list of command names to avoid typeof-cycles in types
10
+ const names = [] as const
11
+ type GeneratedNames = typeof names[number]
12
+
13
+ const modules: Record<GeneratedNames, Command<any>> = {
14
+
15
+ } as const
16
+
17
+ const metadata: Record<GeneratedNames, GeneratedCommandMeta> = {
18
+
19
+ } as const
20
+
21
+ export const generated = registerGeneratedStore(createGeneratedHelpers(modules, metadata))
22
+
23
+ export const commands = generated.commands
24
+ export const commandMeta = generated.metadata
25
+
26
+ export interface GeneratedCLI {
27
+ register(cli?: CLI<any>): GeneratedCLI
28
+ list(): Array<{
29
+ name: GeneratedNames
30
+ command: (typeof modules)[GeneratedNames]
31
+ metadata: (typeof metadata)[GeneratedNames]
32
+ }>
33
+ get<Name extends GeneratedNames>(name: Name): (typeof modules)[Name]
34
+ getMetadata<Name extends GeneratedNames>(name: Name): (typeof metadata)[Name]
35
+ getFlags<Name extends keyof RegisteredCommands & string>(name: Name): CommandOptions<Name>
36
+ getFlagsMeta<Name extends GeneratedNames>(name: Name): Record<string, GeneratedOptionMeta>
37
+ withCLI(cli: CLI<any>): { execute(name: string, options: unknown): Promise<void> }
38
+ }
39
+
40
+ export const cli: GeneratedCLI = {
41
+ register: (cliInstance?: CLI<any>) => { generated.register(cliInstance); return cli },
42
+ list: () => generated.list(),
43
+ get: <Name extends GeneratedNames>(name: Name) => generated.get(name),
44
+ getMetadata: <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name),
45
+ getFlags: <Name extends keyof RegisteredCommands & string>(name: Name) => generated.getFlags(name) as CommandOptions<Name>,
46
+ getFlagsMeta: <Name extends GeneratedNames>(name: Name) => generated.getFlagsMeta(name),
47
+ withCLI: (cliInstance) => generated.withCLI(cliInstance)
48
+ }
49
+
50
+ // Enhanced helper functions
51
+ export const listCommands = () => generated.list().map(c => c.name)
52
+ export const getCommandApi = <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name)
53
+ export const getTypedFlags = <Name extends GeneratedNames>(name: Name) => generated.getFlags(name) as CommandOptions<Name>
54
+ export const validateCommand = <Name extends GeneratedNames>(name: Name, flags: Record<string, unknown>) => generated.validateCommand(name, flags)
55
+ export const findCommandByName = <Name extends GeneratedNames>(name: Name) => generated.findByName(name)
56
+ export const findCommandsByDescription = (searchTerm: string) => generated.findByDescription(searchTerm)
57
+ export const getCommandNames = () => generated.getCommandNames()
58
+
59
+ // Auto-register on import for zero-config usage
60
+ export default cli
61
+
62
+ // Ensure module augmentation happens on import
63
+ declare module '@bunli/core' {
64
+ // Precise key mapping without typeof cycles
65
+ interface RegisteredCommands extends Record<GeneratedNames, Command<any>> {}
66
+ }
@@ -8,6 +8,7 @@
8
8
  "{{projectName}}": "./dist/index.js"
9
9
  },
10
10
  "scripts": {
11
+ "postinstall": "bunli generate",
11
12
  "dev": "bun run src/index.ts",
12
13
  "build": "bunli build",
13
14
  "test": "bun test",
@@ -2,7 +2,7 @@
2
2
  import { createCLI } from '@bunli/core'
3
3
  import { helloCommand } from './commands/hello.js'
4
4
 
5
- const cli = createCLI({
5
+ const cli = await createCLI({
6
6
  name: '{{projectName}}',
7
7
  version: '0.1.0',
8
8
  description: '{{description}}'
@@ -0,0 +1,6 @@
1
+ {
2
+ "commandsParsed": 0,
3
+ "filesScanned": 0,
4
+ "skipped": [],
5
+ "names": []
6
+ }
@@ -0,0 +1,66 @@
1
+ // This file was automatically generated by Bunli.
2
+ // You should NOT make any changes in this file as it will be overwritten.
3
+
4
+ import type { Command, CLI, GeneratedOptionMeta, RegisteredCommands, CommandOptions, GeneratedCommandMeta } from '@bunli/core'
5
+ import { createGeneratedHelpers, registerGeneratedStore } from '@bunli/core'
6
+
7
+
8
+
9
+ // Narrow list of command names to avoid typeof-cycles in types
10
+ const names = [] as const
11
+ type GeneratedNames = typeof names[number]
12
+
13
+ const modules: Record<GeneratedNames, Command<any>> = {
14
+
15
+ } as const
16
+
17
+ const metadata: Record<GeneratedNames, GeneratedCommandMeta> = {
18
+
19
+ } as const
20
+
21
+ export const generated = registerGeneratedStore(createGeneratedHelpers(modules, metadata))
22
+
23
+ export const commands = generated.commands
24
+ export const commandMeta = generated.metadata
25
+
26
+ export interface GeneratedCLI {
27
+ register(cli?: CLI<any>): GeneratedCLI
28
+ list(): Array<{
29
+ name: GeneratedNames
30
+ command: (typeof modules)[GeneratedNames]
31
+ metadata: (typeof metadata)[GeneratedNames]
32
+ }>
33
+ get<Name extends GeneratedNames>(name: Name): (typeof modules)[Name]
34
+ getMetadata<Name extends GeneratedNames>(name: Name): (typeof metadata)[Name]
35
+ getFlags<Name extends keyof RegisteredCommands & string>(name: Name): CommandOptions<Name>
36
+ getFlagsMeta<Name extends GeneratedNames>(name: Name): Record<string, GeneratedOptionMeta>
37
+ withCLI(cli: CLI<any>): { execute(name: string, options: unknown): Promise<void> }
38
+ }
39
+
40
+ export const cli: GeneratedCLI = {
41
+ register: (cliInstance?: CLI<any>) => { generated.register(cliInstance); return cli },
42
+ list: () => generated.list(),
43
+ get: <Name extends GeneratedNames>(name: Name) => generated.get(name),
44
+ getMetadata: <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name),
45
+ getFlags: <Name extends keyof RegisteredCommands & string>(name: Name) => generated.getFlags(name) as CommandOptions<Name>,
46
+ getFlagsMeta: <Name extends GeneratedNames>(name: Name) => generated.getFlagsMeta(name),
47
+ withCLI: (cliInstance) => generated.withCLI(cliInstance)
48
+ }
49
+
50
+ // Enhanced helper functions
51
+ export const listCommands = () => generated.list().map(c => c.name)
52
+ export const getCommandApi = <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name)
53
+ export const getTypedFlags = <Name extends GeneratedNames>(name: Name) => generated.getFlags(name) as CommandOptions<Name>
54
+ export const validateCommand = <Name extends GeneratedNames>(name: Name, flags: Record<string, unknown>) => generated.validateCommand(name, flags)
55
+ export const findCommandByName = <Name extends GeneratedNames>(name: Name) => generated.findByName(name)
56
+ export const findCommandsByDescription = (searchTerm: string) => generated.findByDescription(searchTerm)
57
+ export const getCommandNames = () => generated.getCommandNames()
58
+
59
+ // Auto-register on import for zero-config usage
60
+ export default cli
61
+
62
+ // Ensure module augmentation happens on import
63
+ declare module '@bunli/core' {
64
+ // Precise key mapping without typeof cycles
65
+ interface RegisteredCommands extends Record<GeneratedNames, Command<any>> {}
66
+ }
@@ -9,6 +9,7 @@
9
9
  "packages/*"
10
10
  ],
11
11
  "scripts": {
12
+ "postinstall": "bunli generate",
12
13
  "dev": "turbo run dev",
13
14
  "build": "turbo run build",
14
15
  "test": "turbo run test",
@@ -9,6 +9,7 @@
9
9
  "{{projectName}}": "./dist/index.js"
10
10
  },
11
11
  "scripts": {
12
+ "postinstall": "bunli generate",
12
13
  "dev": "bun run src/index.ts",
13
14
  "build": "bunli build",
14
15
  "test": "bun test",
@@ -3,7 +3,7 @@ import { createCLI } from '@bunli/core'
3
3
  import { logger } from '@{{projectName}}/utils'
4
4
  import { processCommand, analyzeCommand } from '@{{projectName}}/core'
5
5
 
6
- const cli = createCLI({
6
+ const cli = await createCLI({
7
7
  name: '{{projectName}}',
8
8
  version: '0.1.0',
9
9
  description: '{{description}}'
@@ -20,5 +20,12 @@
20
20
  "type": "string",
21
21
  "default": ""
22
22
  }
23
- ]
23
+ ],
24
+ "files": {
25
+ "exclude": [
26
+ "node_modules/**",
27
+ ".git/**",
28
+ "template.json"
29
+ ]
30
+ }
24
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bunli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Scaffold new Bunli CLI projects",
6
6
  "bin": {
@@ -47,7 +47,7 @@
47
47
  "prepublishOnly": "bun run build"
48
48
  },
49
49
  "dependencies": {
50
- "@bunli/core": "0.2.0",
50
+ "@bunli/core": "0.3.0",
51
51
  "@bunli/utils": "0.2.0",
52
52
  "@bunli/test": "0.2.0",
53
53
  "giget": "^2.0.0",
@@ -0,0 +1,6 @@
1
+ {
2
+ "commandsParsed": 0,
3
+ "filesScanned": 0,
4
+ "skipped": [],
5
+ "names": []
6
+ }
@@ -0,0 +1,66 @@
1
+ // This file was automatically generated by Bunli.
2
+ // You should NOT make any changes in this file as it will be overwritten.
3
+
4
+ import type { Command, CLI, GeneratedOptionMeta, RegisteredCommands, CommandOptions, GeneratedCommandMeta } from '@bunli/core'
5
+ import { createGeneratedHelpers, registerGeneratedStore } from '@bunli/core'
6
+
7
+
8
+
9
+ // Narrow list of command names to avoid typeof-cycles in types
10
+ const names = [] as const
11
+ type GeneratedNames = typeof names[number]
12
+
13
+ const modules: Record<GeneratedNames, Command<any>> = {
14
+
15
+ } as const
16
+
17
+ const metadata: Record<GeneratedNames, GeneratedCommandMeta> = {
18
+
19
+ } as const
20
+
21
+ export const generated = registerGeneratedStore(createGeneratedHelpers(modules, metadata))
22
+
23
+ export const commands = generated.commands
24
+ export const commandMeta = generated.metadata
25
+
26
+ export interface GeneratedCLI {
27
+ register(cli?: CLI<any>): GeneratedCLI
28
+ list(): Array<{
29
+ name: GeneratedNames
30
+ command: (typeof modules)[GeneratedNames]
31
+ metadata: (typeof metadata)[GeneratedNames]
32
+ }>
33
+ get<Name extends GeneratedNames>(name: Name): (typeof modules)[Name]
34
+ getMetadata<Name extends GeneratedNames>(name: Name): (typeof metadata)[Name]
35
+ getFlags<Name extends keyof RegisteredCommands & string>(name: Name): CommandOptions<Name>
36
+ getFlagsMeta<Name extends GeneratedNames>(name: Name): Record<string, GeneratedOptionMeta>
37
+ withCLI(cli: CLI<any>): { execute(name: string, options: unknown): Promise<void> }
38
+ }
39
+
40
+ export const cli: GeneratedCLI = {
41
+ register: (cliInstance?: CLI<any>) => { generated.register(cliInstance); return cli },
42
+ list: () => generated.list(),
43
+ get: <Name extends GeneratedNames>(name: Name) => generated.get(name),
44
+ getMetadata: <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name),
45
+ getFlags: <Name extends keyof RegisteredCommands & string>(name: Name) => generated.getFlags(name) as CommandOptions<Name>,
46
+ getFlagsMeta: <Name extends GeneratedNames>(name: Name) => generated.getFlagsMeta(name),
47
+ withCLI: (cliInstance) => generated.withCLI(cliInstance)
48
+ }
49
+
50
+ // Enhanced helper functions
51
+ export const listCommands = () => generated.list().map(c => c.name)
52
+ export const getCommandApi = <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name)
53
+ export const getTypedFlags = <Name extends GeneratedNames>(name: Name) => generated.getFlags(name) as CommandOptions<Name>
54
+ export const validateCommand = <Name extends GeneratedNames>(name: Name, flags: Record<string, unknown>) => generated.validateCommand(name, flags)
55
+ export const findCommandByName = <Name extends GeneratedNames>(name: Name) => generated.findByName(name)
56
+ export const findCommandsByDescription = (searchTerm: string) => generated.findByDescription(searchTerm)
57
+ export const getCommandNames = () => generated.getCommandNames()
58
+
59
+ // Auto-register on import for zero-config usage
60
+ export default cli
61
+
62
+ // Ensure module augmentation happens on import
63
+ declare module '@bunli/core' {
64
+ // Precise key mapping without typeof cycles
65
+ interface RegisteredCommands extends Record<GeneratedNames, Command<any>> {}
66
+ }
@@ -9,6 +9,7 @@
9
9
  "{{projectName}}": "./dist/index.js"
10
10
  },
11
11
  "scripts": {
12
+ "postinstall": "bunli generate",
12
13
  "dev": "bun run src/index.ts",
13
14
  "build": "bunli build",
14
15
  "test": "bun test",
@@ -6,7 +6,7 @@ import { serveCommand } from './commands/serve.js'
6
6
  import { configCommand } from './commands/config.js'
7
7
  import { loadConfig } from './utils/config.js'
8
8
 
9
- const cli = createCLI({
9
+ const cli = await createCLI({
10
10
  name: '{{projectName}}',
11
11
  version: '0.1.0',
12
12
  description: '{{description}}'
@@ -33,5 +33,12 @@
33
33
  { "label": "Unlicense", "value": "Unlicense" }
34
34
  ]
35
35
  }
36
- ]
36
+ ],
37
+ "files": {
38
+ "exclude": [
39
+ "node_modules/**",
40
+ ".git/**",
41
+ "template.json"
42
+ ]
43
+ }
37
44
  }
@@ -0,0 +1,6 @@
1
+ {
2
+ "commandsParsed": 0,
3
+ "filesScanned": 0,
4
+ "skipped": [],
5
+ "names": []
6
+ }
@@ -0,0 +1,66 @@
1
+ // This file was automatically generated by Bunli.
2
+ // You should NOT make any changes in this file as it will be overwritten.
3
+
4
+ import type { Command, CLI, GeneratedOptionMeta, RegisteredCommands, CommandOptions, GeneratedCommandMeta } from '@bunli/core'
5
+ import { createGeneratedHelpers, registerGeneratedStore } from '@bunli/core'
6
+
7
+
8
+
9
+ // Narrow list of command names to avoid typeof-cycles in types
10
+ const names = [] as const
11
+ type GeneratedNames = typeof names[number]
12
+
13
+ const modules: Record<GeneratedNames, Command<any>> = {
14
+
15
+ } as const
16
+
17
+ const metadata: Record<GeneratedNames, GeneratedCommandMeta> = {
18
+
19
+ } as const
20
+
21
+ export const generated = registerGeneratedStore(createGeneratedHelpers(modules, metadata))
22
+
23
+ export const commands = generated.commands
24
+ export const commandMeta = generated.metadata
25
+
26
+ export interface GeneratedCLI {
27
+ register(cli?: CLI<any>): GeneratedCLI
28
+ list(): Array<{
29
+ name: GeneratedNames
30
+ command: (typeof modules)[GeneratedNames]
31
+ metadata: (typeof metadata)[GeneratedNames]
32
+ }>
33
+ get<Name extends GeneratedNames>(name: Name): (typeof modules)[Name]
34
+ getMetadata<Name extends GeneratedNames>(name: Name): (typeof metadata)[Name]
35
+ getFlags<Name extends keyof RegisteredCommands & string>(name: Name): CommandOptions<Name>
36
+ getFlagsMeta<Name extends GeneratedNames>(name: Name): Record<string, GeneratedOptionMeta>
37
+ withCLI(cli: CLI<any>): { execute(name: string, options: unknown): Promise<void> }
38
+ }
39
+
40
+ export const cli: GeneratedCLI = {
41
+ register: (cliInstance?: CLI<any>) => { generated.register(cliInstance); return cli },
42
+ list: () => generated.list(),
43
+ get: <Name extends GeneratedNames>(name: Name) => generated.get(name),
44
+ getMetadata: <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name),
45
+ getFlags: <Name extends keyof RegisteredCommands & string>(name: Name) => generated.getFlags(name) as CommandOptions<Name>,
46
+ getFlagsMeta: <Name extends GeneratedNames>(name: Name) => generated.getFlagsMeta(name),
47
+ withCLI: (cliInstance) => generated.withCLI(cliInstance)
48
+ }
49
+
50
+ // Enhanced helper functions
51
+ export const listCommands = () => generated.list().map(c => c.name)
52
+ export const getCommandApi = <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name)
53
+ export const getTypedFlags = <Name extends GeneratedNames>(name: Name) => generated.getFlags(name) as CommandOptions<Name>
54
+ export const validateCommand = <Name extends GeneratedNames>(name: Name, flags: Record<string, unknown>) => generated.validateCommand(name, flags)
55
+ export const findCommandByName = <Name extends GeneratedNames>(name: Name) => generated.findByName(name)
56
+ export const findCommandsByDescription = (searchTerm: string) => generated.findByDescription(searchTerm)
57
+ export const getCommandNames = () => generated.getCommandNames()
58
+
59
+ // Auto-register on import for zero-config usage
60
+ export default cli
61
+
62
+ // Ensure module augmentation happens on import
63
+ declare module '@bunli/core' {
64
+ // Precise key mapping without typeof cycles
65
+ interface RegisteredCommands extends Record<GeneratedNames, Command<any>> {}
66
+ }
@@ -8,6 +8,7 @@
8
8
  "{{projectName}}": "./dist/index.js"
9
9
  },
10
10
  "scripts": {
11
+ "postinstall": "bunli generate",
11
12
  "dev": "bun run src/index.ts",
12
13
  "build": "bunli build",
13
14
  "test": "bun test",
@@ -2,7 +2,7 @@
2
2
  import { createCLI } from '@bunli/core'
3
3
  import { helloCommand } from './commands/hello.js'
4
4
 
5
- const cli = createCLI({
5
+ const cli = await createCLI({
6
6
  name: '{{projectName}}',
7
7
  version: '0.1.0',
8
8
  description: '{{description}}'
@@ -0,0 +1,6 @@
1
+ {
2
+ "commandsParsed": 0,
3
+ "filesScanned": 0,
4
+ "skipped": [],
5
+ "names": []
6
+ }
@@ -0,0 +1,66 @@
1
+ // This file was automatically generated by Bunli.
2
+ // You should NOT make any changes in this file as it will be overwritten.
3
+
4
+ import type { Command, CLI, GeneratedOptionMeta, RegisteredCommands, CommandOptions, GeneratedCommandMeta } from '@bunli/core'
5
+ import { createGeneratedHelpers, registerGeneratedStore } from '@bunli/core'
6
+
7
+
8
+
9
+ // Narrow list of command names to avoid typeof-cycles in types
10
+ const names = [] as const
11
+ type GeneratedNames = typeof names[number]
12
+
13
+ const modules: Record<GeneratedNames, Command<any>> = {
14
+
15
+ } as const
16
+
17
+ const metadata: Record<GeneratedNames, GeneratedCommandMeta> = {
18
+
19
+ } as const
20
+
21
+ export const generated = registerGeneratedStore(createGeneratedHelpers(modules, metadata))
22
+
23
+ export const commands = generated.commands
24
+ export const commandMeta = generated.metadata
25
+
26
+ export interface GeneratedCLI {
27
+ register(cli?: CLI<any>): GeneratedCLI
28
+ list(): Array<{
29
+ name: GeneratedNames
30
+ command: (typeof modules)[GeneratedNames]
31
+ metadata: (typeof metadata)[GeneratedNames]
32
+ }>
33
+ get<Name extends GeneratedNames>(name: Name): (typeof modules)[Name]
34
+ getMetadata<Name extends GeneratedNames>(name: Name): (typeof metadata)[Name]
35
+ getFlags<Name extends keyof RegisteredCommands & string>(name: Name): CommandOptions<Name>
36
+ getFlagsMeta<Name extends GeneratedNames>(name: Name): Record<string, GeneratedOptionMeta>
37
+ withCLI(cli: CLI<any>): { execute(name: string, options: unknown): Promise<void> }
38
+ }
39
+
40
+ export const cli: GeneratedCLI = {
41
+ register: (cliInstance?: CLI<any>) => { generated.register(cliInstance); return cli },
42
+ list: () => generated.list(),
43
+ get: <Name extends GeneratedNames>(name: Name) => generated.get(name),
44
+ getMetadata: <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name),
45
+ getFlags: <Name extends keyof RegisteredCommands & string>(name: Name) => generated.getFlags(name) as CommandOptions<Name>,
46
+ getFlagsMeta: <Name extends GeneratedNames>(name: Name) => generated.getFlagsMeta(name),
47
+ withCLI: (cliInstance) => generated.withCLI(cliInstance)
48
+ }
49
+
50
+ // Enhanced helper functions
51
+ export const listCommands = () => generated.list().map(c => c.name)
52
+ export const getCommandApi = <Name extends GeneratedNames>(name: Name) => generated.getMetadata(name)
53
+ export const getTypedFlags = <Name extends GeneratedNames>(name: Name) => generated.getFlags(name) as CommandOptions<Name>
54
+ export const validateCommand = <Name extends GeneratedNames>(name: Name, flags: Record<string, unknown>) => generated.validateCommand(name, flags)
55
+ export const findCommandByName = <Name extends GeneratedNames>(name: Name) => generated.findByName(name)
56
+ export const findCommandsByDescription = (searchTerm: string) => generated.findByDescription(searchTerm)
57
+ export const getCommandNames = () => generated.getCommandNames()
58
+
59
+ // Auto-register on import for zero-config usage
60
+ export default cli
61
+
62
+ // Ensure module augmentation happens on import
63
+ declare module '@bunli/core' {
64
+ // Precise key mapping without typeof cycles
65
+ interface RegisteredCommands extends Record<GeneratedNames, Command<any>> {}
66
+ }
@@ -9,6 +9,7 @@
9
9
  "packages/*"
10
10
  ],
11
11
  "scripts": {
12
+ "postinstall": "bunli generate",
12
13
  "dev": "turbo run dev",
13
14
  "build": "turbo run build",
14
15
  "test": "turbo run test",
@@ -9,6 +9,7 @@
9
9
  "{{projectName}}": "./dist/index.js"
10
10
  },
11
11
  "scripts": {
12
+ "postinstall": "bunli generate",
12
13
  "dev": "bun run src/index.ts",
13
14
  "build": "bunli build",
14
15
  "test": "bun test",
@@ -3,7 +3,7 @@ import { createCLI } from '@bunli/core'
3
3
  import { logger } from '@{{projectName}}/utils'
4
4
  import { processCommand, analyzeCommand } from '@{{projectName}}/core'
5
5
 
6
- const cli = createCLI({
6
+ const cli = await createCLI({
7
7
  name: '{{projectName}}',
8
8
  version: '0.1.0',
9
9
  description: '{{description}}'
@@ -20,5 +20,12 @@
20
20
  "type": "string",
21
21
  "default": ""
22
22
  }
23
- ]
23
+ ],
24
+ "files": {
25
+ "exclude": [
26
+ "node_modules/**",
27
+ ".git/**",
28
+ "template.json"
29
+ ]
30
+ }
24
31
  }