create-bunli 0.1.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.
- package/README.md +302 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +310 -0
- package/dist/create-project.d.ts +13 -0
- package/dist/create.d.ts +13 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +217 -0
- package/dist/template-engine.d.ts +27 -0
- package/dist/templates/advanced/README.md +114 -0
- package/dist/templates/advanced/package.json +36 -0
- package/dist/templates/advanced/src/commands/config.ts +145 -0
- package/dist/templates/advanced/src/commands/init.ts +153 -0
- package/dist/templates/advanced/src/commands/serve.ts +176 -0
- package/dist/templates/advanced/src/commands/validate.ts +116 -0
- package/dist/templates/advanced/src/index.ts +44 -0
- package/dist/templates/advanced/src/utils/config.ts +83 -0
- package/dist/templates/advanced/src/utils/constants.ts +12 -0
- package/dist/templates/advanced/src/utils/glob.ts +49 -0
- package/dist/templates/advanced/src/utils/validator.ts +131 -0
- package/dist/templates/advanced/template.json +37 -0
- package/dist/templates/advanced/test/commands.test.ts +34 -0
- package/dist/templates/advanced/tsconfig.json +23 -0
- package/dist/templates/basic/README.md +41 -0
- package/dist/templates/basic/package.json +29 -0
- package/dist/templates/basic/src/commands/hello.ts +29 -0
- package/dist/templates/basic/src/index.ts +13 -0
- package/dist/templates/basic/template.json +31 -0
- package/dist/templates/basic/test/hello.test.ts +26 -0
- package/dist/templates/basic/tsconfig.json +19 -0
- package/dist/templates/monorepo/README.md +74 -0
- package/dist/templates/monorepo/package.json +28 -0
- package/dist/templates/monorepo/packages/cli/package.json +34 -0
- package/dist/templates/monorepo/packages/cli/src/index.ts +22 -0
- package/dist/templates/monorepo/packages/cli/tsconfig.json +15 -0
- package/dist/templates/monorepo/packages/core/package.json +32 -0
- package/dist/templates/monorepo/packages/core/scripts/build.ts +18 -0
- package/dist/templates/monorepo/packages/core/src/commands/analyze.ts +84 -0
- package/dist/templates/monorepo/packages/core/src/commands/process.ts +64 -0
- package/dist/templates/monorepo/packages/core/src/index.ts +3 -0
- package/dist/templates/monorepo/packages/core/src/types.ts +21 -0
- package/dist/templates/monorepo/packages/core/tsconfig.json +15 -0
- package/dist/templates/monorepo/packages/utils/package.json +26 -0
- package/dist/templates/monorepo/packages/utils/scripts/build.ts +17 -0
- package/dist/templates/monorepo/packages/utils/src/format.ts +27 -0
- package/dist/templates/monorepo/packages/utils/src/index.ts +3 -0
- package/dist/templates/monorepo/packages/utils/src/json.ts +11 -0
- package/dist/templates/monorepo/packages/utils/src/logger.ts +19 -0
- package/dist/templates/monorepo/packages/utils/tsconfig.json +12 -0
- package/dist/templates/monorepo/template.json +24 -0
- package/dist/templates/monorepo/tsconfig.json +14 -0
- package/dist/templates/monorepo/turbo.json +28 -0
- package/dist/types.d.ts +48 -0
- package/package.json +57 -0
- package/templates/advanced/README.md +114 -0
- package/templates/advanced/package.json +36 -0
- package/templates/advanced/src/commands/config.ts +145 -0
- package/templates/advanced/src/commands/init.ts +153 -0
- package/templates/advanced/src/commands/serve.ts +176 -0
- package/templates/advanced/src/commands/validate.ts +116 -0
- package/templates/advanced/src/index.ts +44 -0
- package/templates/advanced/src/utils/config.ts +83 -0
- package/templates/advanced/src/utils/constants.ts +12 -0
- package/templates/advanced/src/utils/glob.ts +49 -0
- package/templates/advanced/src/utils/validator.ts +131 -0
- package/templates/advanced/template.json +37 -0
- package/templates/advanced/test/commands.test.ts +34 -0
- package/templates/advanced/tsconfig.json +23 -0
- package/templates/basic/README.md +41 -0
- package/templates/basic/package.json +29 -0
- package/templates/basic/src/commands/hello.ts +29 -0
- package/templates/basic/src/index.ts +13 -0
- package/templates/basic/template.json +31 -0
- package/templates/basic/test/hello.test.ts +26 -0
- package/templates/basic/tsconfig.json +19 -0
- package/templates/monorepo/README.md +74 -0
- package/templates/monorepo/package.json +28 -0
- package/templates/monorepo/packages/cli/package.json +34 -0
- package/templates/monorepo/packages/cli/src/index.ts +22 -0
- package/templates/monorepo/packages/cli/tsconfig.json +15 -0
- package/templates/monorepo/packages/core/package.json +32 -0
- package/templates/monorepo/packages/core/scripts/build.ts +18 -0
- package/templates/monorepo/packages/core/src/commands/analyze.ts +84 -0
- package/templates/monorepo/packages/core/src/commands/process.ts +64 -0
- package/templates/monorepo/packages/core/src/index.ts +3 -0
- package/templates/monorepo/packages/core/src/types.ts +21 -0
- package/templates/monorepo/packages/core/tsconfig.json +15 -0
- package/templates/monorepo/packages/utils/package.json +26 -0
- package/templates/monorepo/packages/utils/scripts/build.ts +17 -0
- package/templates/monorepo/packages/utils/src/format.ts +27 -0
- package/templates/monorepo/packages/utils/src/index.ts +3 -0
- package/templates/monorepo/packages/utils/src/json.ts +11 -0
- package/templates/monorepo/packages/utils/src/logger.ts +19 -0
- package/templates/monorepo/packages/utils/tsconfig.json +12 -0
- package/templates/monorepo/template.json +24 -0
- package/templates/monorepo/tsconfig.json +14 -0
- package/templates/monorepo/turbo.json +28 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export interface ValidationResult {
|
|
2
|
+
file: string
|
|
3
|
+
errors: ValidationIssue[]
|
|
4
|
+
warnings: ValidationIssue[]
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface ValidationIssue {
|
|
8
|
+
line: number
|
|
9
|
+
column: number
|
|
10
|
+
message: string
|
|
11
|
+
rule: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ValidateOptions {
|
|
15
|
+
rules?: Record<string, any>
|
|
16
|
+
fix?: boolean
|
|
17
|
+
cache?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function validateFiles(
|
|
21
|
+
files: string[],
|
|
22
|
+
options: ValidateOptions = {}
|
|
23
|
+
): Promise<ValidationResult[]> {
|
|
24
|
+
const { rules = {}, fix = false } = options
|
|
25
|
+
const results: ValidationResult[] = []
|
|
26
|
+
|
|
27
|
+
for (const file of files) {
|
|
28
|
+
const result = await validateFile(file, rules, fix)
|
|
29
|
+
results.push(result)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return results
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function validateFile(
|
|
36
|
+
filePath: string,
|
|
37
|
+
rules: Record<string, any>,
|
|
38
|
+
fix: boolean
|
|
39
|
+
): Promise<ValidationResult> {
|
|
40
|
+
const errors: ValidationIssue[] = []
|
|
41
|
+
const warnings: ValidationIssue[] = []
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const content = await Bun.file(filePath).text()
|
|
45
|
+
const lines = content.split('\n')
|
|
46
|
+
|
|
47
|
+
// Example rule implementations
|
|
48
|
+
if (rules.noConsoleLog) {
|
|
49
|
+
lines.forEach((line, index) => {
|
|
50
|
+
const match = line.match(/console\.log\s*\(/)
|
|
51
|
+
if (match) {
|
|
52
|
+
errors.push({
|
|
53
|
+
line: index + 1,
|
|
54
|
+
column: match.index! + 1,
|
|
55
|
+
message: 'console.log is not allowed',
|
|
56
|
+
rule: 'noConsoleLog'
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (rules.noDebugger) {
|
|
63
|
+
lines.forEach((line, index) => {
|
|
64
|
+
const match = line.match(/\bdebugger\b/)
|
|
65
|
+
if (match) {
|
|
66
|
+
errors.push({
|
|
67
|
+
line: index + 1,
|
|
68
|
+
column: match.index! + 1,
|
|
69
|
+
message: 'debugger statement is not allowed',
|
|
70
|
+
rule: 'noDebugger'
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (rules.maxLineLength) {
|
|
77
|
+
const maxLength = typeof rules.maxLineLength === 'number' ? rules.maxLineLength : 100
|
|
78
|
+
lines.forEach((line, index) => {
|
|
79
|
+
if (line.length > maxLength) {
|
|
80
|
+
warnings.push({
|
|
81
|
+
line: index + 1,
|
|
82
|
+
column: maxLength + 1,
|
|
83
|
+
message: `Line exceeds maximum length of ${maxLength}`,
|
|
84
|
+
rule: 'maxLineLength'
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (rules.requireFileHeader) {
|
|
91
|
+
if (!content.startsWith('/*') && !content.startsWith('//')) {
|
|
92
|
+
errors.push({
|
|
93
|
+
line: 1,
|
|
94
|
+
column: 1,
|
|
95
|
+
message: 'File must start with a header comment',
|
|
96
|
+
rule: 'requireFileHeader'
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Auto-fix if requested
|
|
102
|
+
if (fix && errors.length > 0) {
|
|
103
|
+
// This is a simplified example - real fix logic would be more complex
|
|
104
|
+
let fixedContent = content
|
|
105
|
+
|
|
106
|
+
if (rules.noConsoleLog) {
|
|
107
|
+
fixedContent = fixedContent.replace(/console\.log\s*\([^)]*\);?/g, '')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (rules.noDebugger) {
|
|
111
|
+
fixedContent = fixedContent.replace(/\bdebugger\b;?/g, '')
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
await Bun.write(filePath, fixedContent)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
} catch (error) {
|
|
118
|
+
errors.push({
|
|
119
|
+
line: 0,
|
|
120
|
+
column: 0,
|
|
121
|
+
message: `Failed to validate file: ${error}`,
|
|
122
|
+
rule: 'system'
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
file: filePath,
|
|
128
|
+
errors,
|
|
129
|
+
warnings
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bunli-advanced",
|
|
3
|
+
"description": "Advanced Bunli CLI template with multiple commands",
|
|
4
|
+
"variables": [
|
|
5
|
+
{
|
|
6
|
+
"name": "projectName",
|
|
7
|
+
"message": "Project name",
|
|
8
|
+
"type": "string",
|
|
9
|
+
"default": "my-bunli-cli"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "description",
|
|
13
|
+
"message": "Project description",
|
|
14
|
+
"type": "string",
|
|
15
|
+
"default": "A powerful CLI built with Bunli"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "author",
|
|
19
|
+
"message": "Author name",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"default": ""
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "license",
|
|
25
|
+
"message": "License",
|
|
26
|
+
"type": "select",
|
|
27
|
+
"default": "MIT",
|
|
28
|
+
"choices": [
|
|
29
|
+
{ "label": "MIT", "value": "MIT" },
|
|
30
|
+
{ "label": "Apache-2.0", "value": "Apache-2.0" },
|
|
31
|
+
{ "label": "GPL-3.0", "value": "GPL-3.0" },
|
|
32
|
+
{ "label": "BSD-3-Clause", "value": "BSD-3-Clause" },
|
|
33
|
+
{ "label": "Unlicense", "value": "Unlicense" }
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { test, expect } from 'bun:test'
|
|
2
|
+
import { testCommand, expectCommand } from '@bunli/test'
|
|
3
|
+
import { initCommand } from '../src/commands/init.js'
|
|
4
|
+
import { validateCommand } from '../src/commands/validate.js'
|
|
5
|
+
import { configCommand } from '../src/commands/config.js'
|
|
6
|
+
|
|
7
|
+
test('init command - creates config file', async () => {
|
|
8
|
+
const result = await testCommand(initCommand, {
|
|
9
|
+
flags: { template: 'minimal', force: true }
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
expectCommand(result).toHaveSucceeded()
|
|
13
|
+
expectCommand(result).toContainInStdout('Config file created')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('validate command - reports errors', async () => {
|
|
17
|
+
const result = await testCommand(validateCommand, {
|
|
18
|
+
args: ['src/**/*.ts'],
|
|
19
|
+
flags: { fix: false }
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
// Result depends on actual files, but command should run
|
|
23
|
+
expect(result.exitCode).toBeDefined()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('config list command', async () => {
|
|
27
|
+
const listCommand = configCommand.subcommands?.find(cmd => cmd.name === 'list')
|
|
28
|
+
expect(listCommand).toBeDefined()
|
|
29
|
+
|
|
30
|
+
const result = await testCommand(listCommand!, {})
|
|
31
|
+
|
|
32
|
+
expectCommand(result).toHaveSucceeded()
|
|
33
|
+
expectCommand(result).toContainInStdout('Configuration:')
|
|
34
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"declarationMap": true,
|
|
13
|
+
"outDir": "./dist",
|
|
14
|
+
"rootDir": "./src",
|
|
15
|
+
"types": ["bun-types"],
|
|
16
|
+
"noUnusedLocals": true,
|
|
17
|
+
"noUnusedParameters": true,
|
|
18
|
+
"noImplicitReturns": true,
|
|
19
|
+
"noFallthroughCasesInSwitch": true
|
|
20
|
+
},
|
|
21
|
+
"include": ["src/**/*"],
|
|
22
|
+
"exclude": ["node_modules", "dist", "test/**/*"]
|
|
23
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
{{description}}
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Development
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
bun dev -- [command]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Building
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bun run build
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Testing
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
bun test
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
{{projectName}} hello --name World
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Commands
|
|
36
|
+
|
|
37
|
+
- `hello` - A simple greeting command
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "{{description}}",
|
|
6
|
+
"author": "{{author}}",
|
|
7
|
+
"bin": {
|
|
8
|
+
"{{projectName}}": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "bun run src/index.ts",
|
|
12
|
+
"build": "bunli build",
|
|
13
|
+
"test": "bun test",
|
|
14
|
+
"type-check": "tsc --noEmit"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@bunli/core": "latest"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@bunli/test": "latest",
|
|
21
|
+
"@types/bun": "latest",
|
|
22
|
+
"bunli": "latest",
|
|
23
|
+
"typescript": "^5.0.0"
|
|
24
|
+
},
|
|
25
|
+
"bunli": {
|
|
26
|
+
"entry": "./src/index.ts",
|
|
27
|
+
"outDir": "./dist"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineCommand, option } from '@bunli/core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
export const helloCommand = defineCommand({
|
|
5
|
+
name: 'hello',
|
|
6
|
+
description: 'Say hello to someone',
|
|
7
|
+
options: {
|
|
8
|
+
name: option(
|
|
9
|
+
z.string().default('World'),
|
|
10
|
+
{
|
|
11
|
+
description: 'Name to greet',
|
|
12
|
+
short: 'n'
|
|
13
|
+
}
|
|
14
|
+
),
|
|
15
|
+
excited: option(
|
|
16
|
+
z.boolean().default(false),
|
|
17
|
+
{
|
|
18
|
+
description: 'Add excitement!',
|
|
19
|
+
short: 'e'
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
},
|
|
23
|
+
handler: async ({ flags, colors }) => {
|
|
24
|
+
const greeting = `Hello, ${flags.name}`
|
|
25
|
+
const message = flags.excited ? `${greeting}!` : `${greeting}.`
|
|
26
|
+
|
|
27
|
+
console.log(colors.green(message))
|
|
28
|
+
}
|
|
29
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { createCLI } from '@bunli/core'
|
|
3
|
+
import { helloCommand } from './commands/hello.js'
|
|
4
|
+
|
|
5
|
+
const cli = createCLI({
|
|
6
|
+
name: '{{projectName}}',
|
|
7
|
+
version: '0.1.0',
|
|
8
|
+
description: '{{description}}'
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
cli.command(helloCommand)
|
|
12
|
+
|
|
13
|
+
await cli.run()
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bunli-basic",
|
|
3
|
+
"description": "Basic Bunli CLI template",
|
|
4
|
+
"variables": [
|
|
5
|
+
{
|
|
6
|
+
"name": "projectName",
|
|
7
|
+
"message": "Project name",
|
|
8
|
+
"type": "string",
|
|
9
|
+
"default": "my-bunli-cli"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "description",
|
|
13
|
+
"message": "Project description",
|
|
14
|
+
"type": "string",
|
|
15
|
+
"default": "A CLI built with Bunli"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "author",
|
|
19
|
+
"message": "Author name",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"default": ""
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"files": {
|
|
25
|
+
"exclude": [
|
|
26
|
+
"node_modules/**",
|
|
27
|
+
".git/**",
|
|
28
|
+
"template.json"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { test, expect } from 'bun:test'
|
|
2
|
+
import { testCommand, expectCommand } from '@bunli/test'
|
|
3
|
+
import { helloCommand } from '../src/commands/hello.js'
|
|
4
|
+
|
|
5
|
+
test('hello command - default name', async () => {
|
|
6
|
+
const result = await testCommand(helloCommand)
|
|
7
|
+
|
|
8
|
+
expectCommand(result).toHaveSucceeded()
|
|
9
|
+
expectCommand(result).toContainInStdout('Hello, World.')
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('hello command - custom name', async () => {
|
|
13
|
+
const result = await testCommand(helloCommand, {
|
|
14
|
+
flags: { name: 'Alice' }
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
expectCommand(result).toContainInStdout('Hello, Alice.')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test('hello command - excited flag', async () => {
|
|
21
|
+
const result = await testCommand(helloCommand, {
|
|
22
|
+
flags: { name: 'Bob', excited: true }
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
expectCommand(result).toContainInStdout('Hello, Bob!')
|
|
26
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"declarationMap": true,
|
|
13
|
+
"outDir": "./dist",
|
|
14
|
+
"rootDir": "./src",
|
|
15
|
+
"types": ["bun-types"]
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*"],
|
|
18
|
+
"exclude": ["node_modules", "dist", "test/**/*"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
{{description}}
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
This is a monorepo managed with Bun workspaces and Turborepo.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
.
|
|
11
|
+
├── packages/
|
|
12
|
+
│ ├── cli/ # Main CLI package
|
|
13
|
+
│ ├── core/ # Core functionality
|
|
14
|
+
│ └── utils/ # Shared utilities
|
|
15
|
+
├── package.json # Root package.json
|
|
16
|
+
└── turbo.json # Turborepo configuration
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Development
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Install dependencies
|
|
23
|
+
bun install
|
|
24
|
+
|
|
25
|
+
# Run all packages in development mode
|
|
26
|
+
bun dev
|
|
27
|
+
|
|
28
|
+
# Build all packages
|
|
29
|
+
bun run build
|
|
30
|
+
|
|
31
|
+
# Run tests
|
|
32
|
+
bun test
|
|
33
|
+
|
|
34
|
+
# Type check
|
|
35
|
+
bun run type-check
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Creating a New Package
|
|
39
|
+
|
|
40
|
+
1. Create a new directory under `packages/`
|
|
41
|
+
2. Add a `package.json` with the package name and dependencies
|
|
42
|
+
3. Add the package to the workspace in root `package.json` if needed
|
|
43
|
+
4. Run `bun install` to link the workspace
|
|
44
|
+
|
|
45
|
+
## Publishing
|
|
46
|
+
|
|
47
|
+
This monorepo uses [Changesets](https://github.com/changesets/changesets) for version management.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Create a changeset
|
|
51
|
+
bun run changeset
|
|
52
|
+
|
|
53
|
+
# Version packages
|
|
54
|
+
bun run version
|
|
55
|
+
|
|
56
|
+
# Publish to npm
|
|
57
|
+
bun run release
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Scripts
|
|
61
|
+
|
|
62
|
+
- `dev` - Run all packages in development mode
|
|
63
|
+
- `build` - Build all packages
|
|
64
|
+
- `test` - Run all tests
|
|
65
|
+
- `type-check` - Type check all packages
|
|
66
|
+
- `lint` - Lint all packages
|
|
67
|
+
- `clean` - Clean all build artifacts
|
|
68
|
+
- `changeset` - Create a new changeset
|
|
69
|
+
- `version` - Update versions based on changesets
|
|
70
|
+
- `release` - Build and publish packages
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "{{description}}",
|
|
7
|
+
"author": "{{author}}",
|
|
8
|
+
"workspaces": [
|
|
9
|
+
"packages/*"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "turbo run dev",
|
|
13
|
+
"build": "turbo run build",
|
|
14
|
+
"test": "turbo run test",
|
|
15
|
+
"type-check": "turbo run type-check",
|
|
16
|
+
"lint": "turbo run lint",
|
|
17
|
+
"clean": "turbo run clean && rm -rf node_modules",
|
|
18
|
+
"changeset": "changeset",
|
|
19
|
+
"version": "changeset version",
|
|
20
|
+
"release": "turbo run build && changeset publish"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@changesets/cli": "^2.27.0",
|
|
24
|
+
"@types/bun": "latest",
|
|
25
|
+
"turbo": "latest",
|
|
26
|
+
"typescript": "^5.0.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@{{projectName}}/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "CLI for {{projectName}}",
|
|
6
|
+
"author": "{{author}}",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"bin": {
|
|
9
|
+
"{{projectName}}": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "bun run src/index.ts",
|
|
13
|
+
"build": "bunli build",
|
|
14
|
+
"test": "bun test",
|
|
15
|
+
"type-check": "tsc --noEmit",
|
|
16
|
+
"clean": "rm -rf dist"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@bunli/core": "latest",
|
|
20
|
+
"@{{projectName}}/core": "workspace:*",
|
|
21
|
+
"@{{projectName}}/utils": "workspace:*"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@bunli/test": "latest",
|
|
25
|
+
"@types/bun": "latest",
|
|
26
|
+
"bunli": "latest",
|
|
27
|
+
"typescript": "^5.0.0"
|
|
28
|
+
},
|
|
29
|
+
"bunli": {
|
|
30
|
+
"entry": "./src/index.ts",
|
|
31
|
+
"outDir": "./dist",
|
|
32
|
+
"external": ["@bunli/core", "@{{projectName}}/core", "@{{projectName}}/utils"]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { createCLI } from '@bunli/core'
|
|
3
|
+
import { logger } from '@{{projectName}}/utils'
|
|
4
|
+
import { processCommand, analyzeCommand } from '@{{projectName}}/core'
|
|
5
|
+
|
|
6
|
+
const cli = createCLI({
|
|
7
|
+
name: '{{projectName}}',
|
|
8
|
+
version: '0.1.0',
|
|
9
|
+
description: '{{description}}'
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
// Add commands
|
|
13
|
+
cli.command(processCommand)
|
|
14
|
+
cli.command(analyzeCommand)
|
|
15
|
+
|
|
16
|
+
// Run CLI
|
|
17
|
+
try {
|
|
18
|
+
await cli.run()
|
|
19
|
+
} catch (error) {
|
|
20
|
+
logger.error('CLI failed:', error)
|
|
21
|
+
process.exit(1)
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*"],
|
|
10
|
+
"exclude": ["node_modules", "dist", "test/**/*"],
|
|
11
|
+
"references": [
|
|
12
|
+
{ "path": "../core" },
|
|
13
|
+
{ "path": "../utils" }
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@{{projectName}}/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Core functionality for {{projectName}}",
|
|
6
|
+
"author": "{{author}}",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "bun scripts/build.ts && bun run tsc",
|
|
18
|
+
"test": "bun test",
|
|
19
|
+
"type-check": "tsc --noEmit",
|
|
20
|
+
"clean": "rm -rf dist"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@bunli/core": "latest",
|
|
24
|
+
"@{{projectName}}/utils": "workspace:*",
|
|
25
|
+
"zod": "^3.22.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@bunli/test": "latest",
|
|
29
|
+
"@types/bun": "latest",
|
|
30
|
+
"typescript": "^5.0.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { $ } from 'bun'
|
|
3
|
+
|
|
4
|
+
// Clean dist directory
|
|
5
|
+
await $`rm -rf dist`
|
|
6
|
+
await $`mkdir -p dist`
|
|
7
|
+
|
|
8
|
+
// Build TypeScript files
|
|
9
|
+
await Bun.build({
|
|
10
|
+
entrypoints: ['./src/index.ts'],
|
|
11
|
+
outdir: './dist',
|
|
12
|
+
target: 'bun',
|
|
13
|
+
format: 'esm',
|
|
14
|
+
minify: false,
|
|
15
|
+
external: ['@bunli/core', '@{{projectName}}/utils', 'zod']
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
console.log('✅ @{{projectName}}/core built successfully')
|