create-bunli 0.7.0 → 0.8.1
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 +18 -6
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +372 -195
- package/dist/create-project.d.ts +5 -4
- package/dist/create-project.d.ts.map +1 -0
- package/dist/create.d.ts +4 -3
- package/dist/create.d.ts.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +344 -187
- package/dist/steps.d.ts +36 -0
- package/dist/steps.d.ts.map +1 -0
- package/dist/template-engine.d.ts +3 -2
- package/dist/template-engine.d.ts.map +1 -0
- package/dist/templates/advanced/README.md +8 -4
- package/dist/templates/advanced/bunli.config.ts +19 -19
- package/dist/templates/advanced/package.json +9 -4
- package/dist/templates/advanced/src/commands/config.ts +129 -118
- package/dist/templates/advanced/src/commands/init.ts +53 -59
- package/dist/templates/advanced/src/commands/serve.ts +77 -82
- package/dist/templates/advanced/src/commands/validate.ts +58 -64
- package/dist/templates/advanced/src/index.ts +30 -29
- package/dist/templates/advanced/src/utils/config.ts +48 -47
- package/dist/templates/advanced/src/utils/constants.ts +6 -6
- package/dist/templates/advanced/src/utils/glob.ts +29 -28
- package/dist/templates/advanced/src/utils/validator.ts +60 -61
- package/dist/templates/advanced/template.json +2 -6
- package/dist/templates/advanced/tsconfig.json +1 -1
- package/dist/templates/basic/README.md +1 -1
- package/dist/templates/basic/bunli.config.ts +17 -17
- package/dist/templates/basic/package.json +4 -3
- package/dist/templates/basic/src/commands/hello.ts +20 -25
- package/dist/templates/basic/src/index.ts +9 -8
- package/dist/templates/basic/template.json +2 -6
- package/dist/templates/basic/tsconfig.json +1 -1
- package/dist/templates/monorepo/README.md +1 -1
- package/dist/templates/monorepo/bunli.config.ts +21 -21
- package/dist/templates/monorepo/package.json +3 -2
- package/dist/templates/monorepo/packages/cli/package.json +10 -5
- package/dist/templates/monorepo/packages/cli/src/index.ts +13 -13
- package/dist/templates/monorepo/packages/cli/tsconfig.json +3 -6
- package/dist/templates/monorepo/packages/core/package.json +6 -5
- package/dist/templates/monorepo/packages/core/scripts/build.ts +10 -10
- package/dist/templates/monorepo/packages/core/src/commands/analyze.ts +58 -56
- package/dist/templates/monorepo/packages/core/src/commands/process.ts +39 -46
- package/dist/templates/monorepo/packages/core/src/index.ts +3 -3
- package/dist/templates/monorepo/packages/core/src/types.ts +15 -15
- package/dist/templates/monorepo/packages/core/tsconfig.json +3 -5
- package/dist/templates/monorepo/packages/utils/package.json +6 -5
- package/dist/templates/monorepo/packages/utils/scripts/build.ts +10 -10
- package/dist/templates/monorepo/packages/utils/src/format.ts +19 -19
- package/dist/templates/monorepo/packages/utils/src/index.ts +3 -3
- package/dist/templates/monorepo/packages/utils/src/json.ts +4 -4
- package/dist/templates/monorepo/packages/utils/src/logger.ts +9 -9
- package/dist/templates/monorepo/packages/utils/tsconfig.json +2 -2
- package/dist/templates/monorepo/template.json +2 -6
- package/dist/templates/monorepo/tsconfig.json +1 -1
- package/dist/templates/monorepo/turbo.json +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -0
- package/package.json +35 -34
- package/templates/advanced/README.md +8 -4
- package/templates/advanced/bunli.config.ts +19 -19
- package/templates/advanced/package.json +9 -4
- package/templates/advanced/src/commands/config.ts +129 -118
- package/templates/advanced/src/commands/init.ts +53 -59
- package/templates/advanced/src/commands/serve.ts +77 -82
- package/templates/advanced/src/commands/validate.ts +58 -64
- package/templates/advanced/src/index.ts +30 -29
- package/templates/advanced/src/utils/config.ts +48 -47
- package/templates/advanced/src/utils/constants.ts +6 -6
- package/templates/advanced/src/utils/glob.ts +29 -28
- package/templates/advanced/src/utils/validator.ts +60 -61
- package/templates/advanced/template.json +2 -6
- package/templates/advanced/tsconfig.json +1 -1
- package/templates/basic/README.md +1 -1
- package/templates/basic/bunli.config.ts +17 -17
- package/templates/basic/package.json +4 -3
- package/templates/basic/src/commands/hello.ts +20 -25
- package/templates/basic/src/index.ts +9 -8
- package/templates/basic/template.json +2 -6
- package/templates/basic/tsconfig.json +1 -1
- package/templates/monorepo/README.md +1 -1
- package/templates/monorepo/bunli.config.ts +21 -21
- package/templates/monorepo/package.json +3 -2
- package/templates/monorepo/packages/cli/package.json +10 -5
- package/templates/monorepo/packages/cli/src/index.ts +13 -13
- package/templates/monorepo/packages/cli/tsconfig.json +3 -6
- package/templates/monorepo/packages/core/package.json +6 -5
- package/templates/monorepo/packages/core/scripts/build.ts +10 -10
- package/templates/monorepo/packages/core/src/commands/analyze.ts +58 -56
- package/templates/monorepo/packages/core/src/commands/process.ts +39 -46
- package/templates/monorepo/packages/core/src/index.ts +3 -3
- package/templates/monorepo/packages/core/src/types.ts +15 -15
- package/templates/monorepo/packages/core/tsconfig.json +3 -5
- package/templates/monorepo/packages/utils/package.json +6 -5
- package/templates/monorepo/packages/utils/scripts/build.ts +10 -10
- package/templates/monorepo/packages/utils/src/format.ts +19 -19
- package/templates/monorepo/packages/utils/src/index.ts +3 -3
- package/templates/monorepo/packages/utils/src/json.ts +4 -4
- package/templates/monorepo/packages/utils/src/logger.ts +9 -9
- package/templates/monorepo/packages/utils/tsconfig.json +2 -2
- package/templates/monorepo/template.json +2 -6
- package/templates/monorepo/tsconfig.json +1 -1
- package/templates/monorepo/turbo.json +1 -1
|
@@ -1,84 +1,85 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
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
|
|
83
|
+
|
|
84
|
+
return "No config file found";
|
|
84
85
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export const CONFIG_FILE_NAME =
|
|
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:
|
|
8
|
-
open: true
|
|
7
|
+
host: "localhost",
|
|
8
|
+
open: true,
|
|
9
9
|
},
|
|
10
|
-
include: [
|
|
11
|
-
exclude: [
|
|
12
|
-
}
|
|
10
|
+
include: ["src/**/*.{js,ts}"],
|
|
11
|
+
exclude: ["node_modules", "dist"],
|
|
12
|
+
};
|
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { Glob } from "bun";
|
|
3
4
|
|
|
4
5
|
export interface GlobOptions {
|
|
5
|
-
include?: string[]
|
|
6
|
-
exclude?: string[]
|
|
6
|
+
include?: string[];
|
|
7
|
+
exclude?: string[];
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export async function glob(patterns: string[], options: GlobOptions = {}): Promise<string[]> {
|
|
10
|
-
const { include = [], exclude = [] } = options
|
|
11
|
-
|
|
11
|
+
const { include = [], exclude = [] } = options;
|
|
12
|
+
|
|
12
13
|
// Combine user patterns with include patterns
|
|
13
|
-
const allPatterns = [...patterns, ...include]
|
|
14
|
-
|
|
14
|
+
const allPatterns = [...patterns, ...include];
|
|
15
|
+
|
|
15
16
|
// Convert exclude patterns to absolute paths
|
|
16
|
-
const excludePatterns = exclude.map(pattern => {
|
|
17
|
-
if (pattern.startsWith(
|
|
18
|
-
return pattern
|
|
17
|
+
const excludePatterns = exclude.map((pattern) => {
|
|
18
|
+
if (pattern.startsWith("/")) {
|
|
19
|
+
return pattern;
|
|
19
20
|
}
|
|
20
|
-
return path.join(process.cwd(), pattern)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const results = new Set<string>()
|
|
24
|
-
|
|
21
|
+
return path.join(process.cwd(), pattern);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const results = new Set<string>();
|
|
25
|
+
|
|
25
26
|
for (const pattern of allPatterns) {
|
|
26
|
-
const glob = new Glob(pattern)
|
|
27
|
-
|
|
27
|
+
const glob = new Glob(pattern);
|
|
28
|
+
|
|
28
29
|
for await (const file of glob.scan({
|
|
29
30
|
cwd: process.cwd(),
|
|
30
|
-
absolute: true
|
|
31
|
+
absolute: true,
|
|
31
32
|
})) {
|
|
32
33
|
// Check if file should be excluded
|
|
33
|
-
let shouldExclude = false
|
|
34
|
-
|
|
34
|
+
let shouldExclude = false;
|
|
35
|
+
|
|
35
36
|
for (const excludePattern of excludePatterns) {
|
|
36
37
|
if (file.includes(excludePattern)) {
|
|
37
|
-
shouldExclude = true
|
|
38
|
-
break
|
|
38
|
+
shouldExclude = true;
|
|
39
|
+
break;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
|
|
42
43
|
if (!shouldExclude) {
|
|
43
|
-
results.add(file)
|
|
44
|
+
results.add(file);
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
return Array.from(results).sort()
|
|
49
|
-
}
|
|
48
|
+
|
|
49
|
+
return Array.from(results).sort();
|
|
50
|
+
}
|
|
@@ -1,131 +1,130 @@
|
|
|
1
1
|
export interface ValidationResult {
|
|
2
|
-
file: string
|
|
3
|
-
errors: ValidationIssue[]
|
|
4
|
-
warnings: ValidationIssue[]
|
|
2
|
+
file: string;
|
|
3
|
+
errors: ValidationIssue[];
|
|
4
|
+
warnings: ValidationIssue[];
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export interface ValidationIssue {
|
|
8
|
-
line: number
|
|
9
|
-
column: number
|
|
10
|
-
message: string
|
|
11
|
-
rule: string
|
|
8
|
+
line: number;
|
|
9
|
+
column: number;
|
|
10
|
+
message: string;
|
|
11
|
+
rule: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface ValidateOptions {
|
|
15
|
-
rules?: Record<string, any
|
|
16
|
-
fix?: boolean
|
|
17
|
-
cache?: boolean
|
|
15
|
+
rules?: Record<string, any>;
|
|
16
|
+
fix?: boolean;
|
|
17
|
+
cache?: boolean;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export async function validateFiles(
|
|
21
21
|
files: string[],
|
|
22
|
-
options: ValidateOptions = {}
|
|
22
|
+
options: ValidateOptions = {},
|
|
23
23
|
): Promise<ValidationResult[]> {
|
|
24
|
-
const { rules = {}, fix = false } = options
|
|
25
|
-
const results: ValidationResult[] = []
|
|
26
|
-
|
|
24
|
+
const { rules = {}, fix = false } = options;
|
|
25
|
+
const results: ValidationResult[] = [];
|
|
26
|
+
|
|
27
27
|
for (const file of files) {
|
|
28
|
-
const result = await validateFile(file, rules, fix)
|
|
29
|
-
results.push(result)
|
|
28
|
+
const result = await validateFile(file, rules, fix);
|
|
29
|
+
results.push(result);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
return results
|
|
31
|
+
|
|
32
|
+
return results;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
async function validateFile(
|
|
36
36
|
filePath: string,
|
|
37
37
|
rules: Record<string, any>,
|
|
38
|
-
fix: boolean
|
|
38
|
+
fix: boolean,
|
|
39
39
|
): Promise<ValidationResult> {
|
|
40
|
-
const errors: ValidationIssue[] = []
|
|
41
|
-
const warnings: ValidationIssue[] = []
|
|
42
|
-
|
|
40
|
+
const errors: ValidationIssue[] = [];
|
|
41
|
+
const warnings: ValidationIssue[] = [];
|
|
42
|
+
|
|
43
43
|
try {
|
|
44
|
-
const content = await Bun.file(filePath).text()
|
|
45
|
-
const lines = content.split(
|
|
46
|
-
|
|
44
|
+
const content = await Bun.file(filePath).text();
|
|
45
|
+
const lines = content.split("\n");
|
|
46
|
+
|
|
47
47
|
// Example rule implementations
|
|
48
48
|
if (rules.noConsoleLog) {
|
|
49
49
|
lines.forEach((line, index) => {
|
|
50
|
-
const match = line.match(/console\.log\s*\(/)
|
|
50
|
+
const match = line.match(/console\.log\s*\(/);
|
|
51
51
|
if (match) {
|
|
52
52
|
errors.push({
|
|
53
53
|
line: index + 1,
|
|
54
54
|
column: match.index! + 1,
|
|
55
|
-
message:
|
|
56
|
-
rule:
|
|
57
|
-
})
|
|
55
|
+
message: "console.log is not allowed",
|
|
56
|
+
rule: "noConsoleLog",
|
|
57
|
+
});
|
|
58
58
|
}
|
|
59
|
-
})
|
|
59
|
+
});
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
if (rules.noDebugger) {
|
|
63
63
|
lines.forEach((line, index) => {
|
|
64
|
-
const match = line.match(/\bdebugger\b/)
|
|
64
|
+
const match = line.match(/\bdebugger\b/);
|
|
65
65
|
if (match) {
|
|
66
66
|
errors.push({
|
|
67
67
|
line: index + 1,
|
|
68
68
|
column: match.index! + 1,
|
|
69
|
-
message:
|
|
70
|
-
rule:
|
|
71
|
-
})
|
|
69
|
+
message: "debugger statement is not allowed",
|
|
70
|
+
rule: "noDebugger",
|
|
71
|
+
});
|
|
72
72
|
}
|
|
73
|
-
})
|
|
73
|
+
});
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
if (rules.maxLineLength) {
|
|
77
|
-
const maxLength = typeof rules.maxLineLength ===
|
|
77
|
+
const maxLength = typeof rules.maxLineLength === "number" ? rules.maxLineLength : 100;
|
|
78
78
|
lines.forEach((line, index) => {
|
|
79
79
|
if (line.length > maxLength) {
|
|
80
80
|
warnings.push({
|
|
81
81
|
line: index + 1,
|
|
82
82
|
column: maxLength + 1,
|
|
83
83
|
message: `Line exceeds maximum length of ${maxLength}`,
|
|
84
|
-
rule:
|
|
85
|
-
})
|
|
84
|
+
rule: "maxLineLength",
|
|
85
|
+
});
|
|
86
86
|
}
|
|
87
|
-
})
|
|
87
|
+
});
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
if (rules.requireFileHeader) {
|
|
91
|
-
if (!content.startsWith(
|
|
91
|
+
if (!content.startsWith("/*") && !content.startsWith("//")) {
|
|
92
92
|
errors.push({
|
|
93
93
|
line: 1,
|
|
94
94
|
column: 1,
|
|
95
|
-
message:
|
|
96
|
-
rule:
|
|
97
|
-
})
|
|
95
|
+
message: "File must start with a header comment",
|
|
96
|
+
rule: "requireFileHeader",
|
|
97
|
+
});
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
// Auto-fix if requested
|
|
102
102
|
if (fix && errors.length > 0) {
|
|
103
103
|
// This is a simplified example - real fix logic would be more complex
|
|
104
|
-
let fixedContent = content
|
|
105
|
-
|
|
104
|
+
let fixedContent = content;
|
|
105
|
+
|
|
106
106
|
if (rules.noConsoleLog) {
|
|
107
|
-
fixedContent = fixedContent.replace(/console\.log\s*\([^)]*\);?/g,
|
|
107
|
+
fixedContent = fixedContent.replace(/console\.log\s*\([^)]*\);?/g, "");
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
if (rules.noDebugger) {
|
|
111
|
-
fixedContent = fixedContent.replace(/\bdebugger\b;?/g,
|
|
111
|
+
fixedContent = fixedContent.replace(/\bdebugger\b;?/g, "");
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
await Bun.write(filePath, fixedContent)
|
|
113
|
+
|
|
114
|
+
await Bun.write(filePath, fixedContent);
|
|
115
115
|
}
|
|
116
|
-
|
|
117
116
|
} catch (error) {
|
|
118
117
|
errors.push({
|
|
119
118
|
line: 0,
|
|
120
119
|
column: 0,
|
|
121
120
|
message: `Failed to validate file: ${error}`,
|
|
122
|
-
rule:
|
|
123
|
-
})
|
|
121
|
+
rule: "system",
|
|
122
|
+
});
|
|
124
123
|
}
|
|
125
|
-
|
|
124
|
+
|
|
126
125
|
return {
|
|
127
126
|
file: filePath,
|
|
128
127
|
errors,
|
|
129
|
-
warnings
|
|
130
|
-
}
|
|
131
|
-
}
|
|
128
|
+
warnings,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { defineConfig } from
|
|
1
|
+
import { defineConfig } from "@bunli/core";
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
|
-
name:
|
|
5
|
-
version:
|
|
6
|
-
description:
|
|
7
|
-
|
|
4
|
+
name: "{{name}}",
|
|
5
|
+
version: "{{version}}",
|
|
6
|
+
description: "{{description}}",
|
|
7
|
+
|
|
8
8
|
commands: {
|
|
9
|
-
directory:
|
|
9
|
+
directory: "./src/commands",
|
|
10
10
|
},
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
build: {
|
|
13
|
-
entry:
|
|
14
|
-
outdir:
|
|
15
|
-
targets: [
|
|
13
|
+
entry: "./src/index.ts",
|
|
14
|
+
outdir: "./dist",
|
|
15
|
+
targets: ["native"],
|
|
16
16
|
minify: true,
|
|
17
17
|
sourcemap: true,
|
|
18
|
-
compress: false
|
|
18
|
+
compress: false,
|
|
19
19
|
},
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
dev: {
|
|
22
22
|
watch: true,
|
|
23
|
-
inspect: true
|
|
23
|
+
inspect: true,
|
|
24
24
|
},
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
test: {
|
|
27
|
-
pattern: [
|
|
27
|
+
pattern: ["**/*.test.ts", "**/*.spec.ts"],
|
|
28
28
|
coverage: true,
|
|
29
|
-
watch: false
|
|
29
|
+
watch: false,
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
plugins: [],
|
|
33
|
-
})
|
|
33
|
+
});
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{name}}",
|
|
3
3
|
"version": "0.1.0",
|
|
4
|
-
"type": "module",
|
|
5
4
|
"description": "{{description}}",
|
|
6
5
|
"author": "{{author}}",
|
|
7
6
|
"bin": {
|
|
8
7
|
"{{name}}": "./dist/index.js"
|
|
9
8
|
},
|
|
9
|
+
"type": "module",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"postinstall": "bunli generate",
|
|
12
12
|
"dev": "bun run src/index.ts",
|
|
13
13
|
"build": "bunli build",
|
|
14
14
|
"test": "bun test",
|
|
15
|
-
"typecheck": "
|
|
15
|
+
"typecheck": "tsgo --noEmit"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@bunli/core": "latest"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@bunli/test": "latest",
|
|
22
|
+
"@tsconfig/bun": "catalog:",
|
|
22
23
|
"@types/bun": "latest",
|
|
23
24
|
"bunli": "latest",
|
|
24
25
|
"typescript": "^5.0.0"
|
|
@@ -27,4 +28,4 @@
|
|
|
27
28
|
"entry": "./src/index.ts",
|
|
28
29
|
"outDir": "./dist"
|
|
29
30
|
}
|
|
30
|
-
}
|
|
31
|
+
}
|
|
@@ -1,31 +1,26 @@
|
|
|
1
|
-
import { defineCommand, option } from
|
|
2
|
-
import { z } from
|
|
1
|
+
import { defineCommand, option } from "@bunli/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
const helloCommand = defineCommand({
|
|
5
|
-
name:
|
|
6
|
-
description:
|
|
5
|
+
name: "hello",
|
|
6
|
+
description: "Say hello to someone",
|
|
7
7
|
options: {
|
|
8
|
-
name: option(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
description: 'Add excitement!',
|
|
19
|
-
short: 'e'
|
|
20
|
-
}
|
|
21
|
-
)
|
|
8
|
+
name: option(z.string().default("World"), {
|
|
9
|
+
description: "Name to greet",
|
|
10
|
+
short: "n",
|
|
11
|
+
}),
|
|
12
|
+
excited: option(z.boolean().default(false), {
|
|
13
|
+
description: "Add excitement!",
|
|
14
|
+
short: "e",
|
|
15
|
+
argumentKind: "flag",
|
|
16
|
+
}),
|
|
22
17
|
},
|
|
23
18
|
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
|
-
})
|
|
19
|
+
const greeting = `Hello, ${flags.name}`;
|
|
20
|
+
const message = flags.excited ? `${greeting}!` : `${greeting}.`;
|
|
30
21
|
|
|
31
|
-
|
|
22
|
+
console.log(colors.green(message));
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export default helloCommand;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { createCLI } from
|
|
3
|
-
|
|
2
|
+
import { createCLI } from "@bunli/core";
|
|
3
|
+
|
|
4
|
+
import helloCommand from "./commands/hello.js";
|
|
4
5
|
|
|
5
6
|
const cli = await createCLI({
|
|
6
|
-
name:
|
|
7
|
-
version:
|
|
8
|
-
description:
|
|
9
|
-
})
|
|
7
|
+
name: "{{name}}",
|
|
8
|
+
version: "0.1.0",
|
|
9
|
+
description: "{{description}}",
|
|
10
|
+
});
|
|
10
11
|
|
|
11
|
-
cli.command(helloCommand)
|
|
12
|
+
cli.command(helloCommand);
|
|
12
13
|
|
|
13
|
-
await cli.run()
|
|
14
|
+
await cli.run();
|