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,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')
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { defineCommand, option } from '@bunli/core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
import { logger, formatTable } from '@{{projectName}}/utils'
|
|
4
|
+
import type { AnalyzeResult } from '../types.js'
|
|
5
|
+
|
|
6
|
+
export const analyzeCommand = defineCommand({
|
|
7
|
+
name: 'analyze',
|
|
8
|
+
description: 'Analyze files and generate reports',
|
|
9
|
+
args: z.array(z.string()).min(1).describe('Files to analyze'),
|
|
10
|
+
options: {
|
|
11
|
+
detailed: option(
|
|
12
|
+
z.boolean().default(false),
|
|
13
|
+
{
|
|
14
|
+
short: 'd',
|
|
15
|
+
description: 'Show detailed analysis'
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
},
|
|
19
|
+
handler: async ({ args, flags, colors }) => {
|
|
20
|
+
logger.info('Starting analysis...')
|
|
21
|
+
|
|
22
|
+
const results: AnalyzeResult[] = []
|
|
23
|
+
|
|
24
|
+
for (const file of args) {
|
|
25
|
+
try {
|
|
26
|
+
const result = await analyzeFile(file)
|
|
27
|
+
results.push(result)
|
|
28
|
+
} catch (error) {
|
|
29
|
+
logger.error(`Failed to analyze ${file}:`, error)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Display results
|
|
34
|
+
console.log()
|
|
35
|
+
console.log(colors.bold('Analysis Results:'))
|
|
36
|
+
console.log()
|
|
37
|
+
|
|
38
|
+
const tableData = results.map(r => ({
|
|
39
|
+
File: r.file,
|
|
40
|
+
Lines: r.metrics.lines,
|
|
41
|
+
Words: r.metrics.words,
|
|
42
|
+
Issues: r.issues.length
|
|
43
|
+
}))
|
|
44
|
+
|
|
45
|
+
console.log(formatTable(tableData))
|
|
46
|
+
|
|
47
|
+
if (flags.detailed) {
|
|
48
|
+
console.log()
|
|
49
|
+
console.log(colors.bold('Detailed Issues:'))
|
|
50
|
+
|
|
51
|
+
for (const result of results) {
|
|
52
|
+
if (result.issues.length > 0) {
|
|
53
|
+
console.log()
|
|
54
|
+
console.log(colors.underline(result.file))
|
|
55
|
+
|
|
56
|
+
for (const issue of result.issues) {
|
|
57
|
+
const icon = issue.type === 'error' ? '✗' :
|
|
58
|
+
issue.type === 'warning' ? '⚠' : 'ℹ'
|
|
59
|
+
const color = issue.type === 'error' ? colors.red :
|
|
60
|
+
issue.type === 'warning' ? colors.yellow : colors.blue
|
|
61
|
+
|
|
62
|
+
console.log(color(` ${icon} ${issue.line}:${issue.column} ${issue.message}`))
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
async function analyzeFile(file: string): Promise<AnalyzeResult> {
|
|
71
|
+
const content = await Bun.file(file).text()
|
|
72
|
+
const lines = content.split('\n')
|
|
73
|
+
const words = content.split(/\\s+/).filter(w => w.length > 0)
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
file,
|
|
77
|
+
metrics: {
|
|
78
|
+
lines: lines.length,
|
|
79
|
+
characters: content.length,
|
|
80
|
+
words: words.length
|
|
81
|
+
},
|
|
82
|
+
issues: []
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { defineCommand, option } from '@bunli/core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
import { logger } from '@{{projectName}}/utils'
|
|
4
|
+
import type { ProcessOptions } from '../types.js'
|
|
5
|
+
|
|
6
|
+
export const processCommand = defineCommand({
|
|
7
|
+
name: 'process',
|
|
8
|
+
description: 'Process input files',
|
|
9
|
+
args: z.array(z.string()).min(1).describe('Files to process'),
|
|
10
|
+
options: {
|
|
11
|
+
output: option(
|
|
12
|
+
z.string().optional(),
|
|
13
|
+
{
|
|
14
|
+
short: 'o',
|
|
15
|
+
description: 'Output directory'
|
|
16
|
+
}
|
|
17
|
+
),
|
|
18
|
+
format: option(
|
|
19
|
+
z.enum(['json', 'yaml', 'text']).default('json'),
|
|
20
|
+
{
|
|
21
|
+
short: 'f',
|
|
22
|
+
description: 'Output format'
|
|
23
|
+
}
|
|
24
|
+
),
|
|
25
|
+
verbose: option(
|
|
26
|
+
z.boolean().default(false),
|
|
27
|
+
{
|
|
28
|
+
short: 'v',
|
|
29
|
+
description: 'Verbose output'
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
},
|
|
33
|
+
handler: async ({ args, flags, spinner }) => {
|
|
34
|
+
const spin = spinner('Processing files...')
|
|
35
|
+
spin.start()
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
for (const file of args) {
|
|
39
|
+
if (flags.verbose) {
|
|
40
|
+
logger.info(`Processing ${file}`)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Process logic here
|
|
44
|
+
await processFile(file, {
|
|
45
|
+
input: file,
|
|
46
|
+
output: flags.output,
|
|
47
|
+
format: flags.format,
|
|
48
|
+
verbose: flags.verbose
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
spin.succeed(`Processed ${args.length} files`)
|
|
53
|
+
} catch (error) {
|
|
54
|
+
spin.fail('Processing failed')
|
|
55
|
+
logger.error(error)
|
|
56
|
+
process.exit(1)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
async function processFile(file: string, options: ProcessOptions): Promise<void> {
|
|
62
|
+
// Implementation here
|
|
63
|
+
logger.debug(`Processing ${file} with options:`, options)
|
|
64
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ProcessOptions {
|
|
2
|
+
input: string
|
|
3
|
+
output?: string
|
|
4
|
+
format?: 'json' | 'yaml' | 'text'
|
|
5
|
+
verbose?: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface AnalyzeResult {
|
|
9
|
+
file: string
|
|
10
|
+
metrics: {
|
|
11
|
+
lines: number
|
|
12
|
+
characters: number
|
|
13
|
+
words: number
|
|
14
|
+
}
|
|
15
|
+
issues: Array<{
|
|
16
|
+
type: 'error' | 'warning' | 'info'
|
|
17
|
+
line: number
|
|
18
|
+
column: number
|
|
19
|
+
message: string
|
|
20
|
+
}>
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"composite": true
|
|
9
|
+
},
|
|
10
|
+
"include": ["src/**/*"],
|
|
11
|
+
"exclude": ["node_modules", "dist", "test/**/*"],
|
|
12
|
+
"references": [
|
|
13
|
+
{ "path": "../utils" }
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@{{projectName}}/utils",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Shared utilities 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
|
+
"devDependencies": {
|
|
23
|
+
"@types/bun": "latest",
|
|
24
|
+
"typescript": "^5.0.0"
|
|
25
|
+
}
|
|
26
|
+
}
|