@reliverse/rempts 2.2.9 → 2.3.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 +213 -1431
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +51 -0
- package/dist/create-project.d.ts +14 -0
- package/dist/create-project.js +84 -0
- package/dist/create.d.ts +11 -0
- package/dist/create.js +62 -0
- package/dist/mod.d.ts +4 -6
- package/dist/mod.js +7 -6
- package/dist/template-engine.d.ts +27 -0
- package/dist/template-engine.js +145 -0
- package/dist/types.d.ts +45 -0
- package/package.json +41 -39
- package/src/cli.ts +64 -0
- package/templates/advanced/README.md +118 -0
- package/templates/advanced/dler.config.ts +41 -0
- package/templates/advanced/package.json +42 -0
- package/templates/advanced/src/commands/config.ts +157 -0
- package/templates/advanced/src/commands/init.ts +149 -0
- package/templates/advanced/src/commands/serve.ts +172 -0
- package/templates/advanced/src/commands/validate.ts +130 -0
- package/templates/advanced/src/mod.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 +128 -0
- package/templates/advanced/template.json +40 -0
- package/templates/advanced/tsconfig.json +23 -0
- package/templates/basic/README.md +41 -0
- package/templates/basic/dler.config.ts +40 -0
- package/templates/basic/package.json +31 -0
- package/templates/basic/src/commands/hello.ts +26 -0
- package/templates/basic/src/mod.ts +13 -0
- package/templates/basic/template.json +27 -0
- package/templates/basic/tsconfig.json +19 -0
- package/templates/monorepo/README.md +74 -0
- package/templates/monorepo/dler.config.ts +45 -0
- package/templates/monorepo/package.json +30 -0
- package/templates/monorepo/packages/cli/package.json +40 -0
- package/templates/monorepo/packages/cli/src/mod.ts +22 -0
- package/templates/monorepo/packages/cli/tsconfig.json +13 -0
- package/templates/monorepo/packages/core/package.json +33 -0
- package/templates/monorepo/packages/core/scripts/build.ts +18 -0
- package/templates/monorepo/packages/core/src/commands/analyze.ts +87 -0
- package/templates/monorepo/packages/core/src/commands/process.ts +57 -0
- package/templates/monorepo/packages/core/src/mod.ts +3 -0
- package/templates/monorepo/packages/core/src/types.ts +21 -0
- package/templates/monorepo/packages/core/tsconfig.json +14 -0
- package/templates/monorepo/packages/utils/package.json +27 -0
- package/templates/monorepo/packages/utils/scripts/build.ts +17 -0
- package/templates/monorepo/packages/utils/src/format.ts +29 -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/src/mod.ts +3 -0
- package/templates/monorepo/packages/utils/tsconfig.json +13 -0
- package/templates/monorepo/template.json +27 -0
- package/templates/monorepo/tsconfig.json +14 -0
- package/templates/monorepo/turbo.json +28 -0
- package/LICENSE +0 -21
- package/cleanup.mjs +0 -33
- package/dist/cancel.d.ts +0 -31
- package/dist/cancel.js +0 -28
- package/dist/ffi.d.ts +0 -1
- package/dist/ffi.js +0 -165
- package/dist/group.d.ts +0 -16
- package/dist/group.js +0 -22
- package/dist/launcher/command.d.ts +0 -8
- package/dist/launcher/command.js +0 -10
- package/dist/launcher/discovery.d.ts +0 -3
- package/dist/launcher/discovery.js +0 -207
- package/dist/launcher/errors.d.ts +0 -15
- package/dist/launcher/errors.js +0 -31
- package/dist/launcher/help.d.ts +0 -3
- package/dist/launcher/help.js +0 -145
- package/dist/launcher/mod.d.ts +0 -12
- package/dist/launcher/mod.js +0 -222
- package/dist/launcher/parser.d.ts +0 -14
- package/dist/launcher/parser.js +0 -255
- package/dist/launcher/registry.d.ts +0 -10
- package/dist/launcher/registry.js +0 -42
- package/dist/launcher/types.d.ts +0 -78
- package/dist/launcher/validator.d.ts +0 -3
- package/dist/launcher/validator.js +0 -39
- package/dist/prompt.d.ts +0 -13
- package/dist/prompt.js +0 -53
- package/dist/selection.d.ts +0 -92
- package/dist/selection.js +0 -191
- package/dist/spinner.d.ts +0 -26
- package/dist/spinner.js +0 -141
- package/dist/utils.d.ts +0 -3
- package/dist/utils.js +0 -11
- /package/dist/{launcher/types.js → types.js} +0 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { relico } from "@reliverse/relico";
|
|
2
|
+
import { defineCommand, option } from "@reliverse/rempts-core";
|
|
3
|
+
import { type } from "arktype";
|
|
4
|
+
import { loadConfig } from "../utils/config";
|
|
5
|
+
import { glob } from "../utils/glob";
|
|
6
|
+
import { validateFiles } from "../utils/validator";
|
|
7
|
+
|
|
8
|
+
const validateCommand = defineCommand({
|
|
9
|
+
name: "validate",
|
|
10
|
+
description: "Validate files against defined rules",
|
|
11
|
+
options: {
|
|
12
|
+
config: option(
|
|
13
|
+
type("string | undefined").narrow((s, ctx) => {
|
|
14
|
+
if (!s) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return (
|
|
18
|
+
s.endsWith(".json") ||
|
|
19
|
+
s.endsWith(".ts") ||
|
|
20
|
+
s.endsWith(".js") ||
|
|
21
|
+
ctx.reject(`Config file must be .json, .ts, or .js (was "${s}")`)
|
|
22
|
+
);
|
|
23
|
+
}),
|
|
24
|
+
{
|
|
25
|
+
short: "c",
|
|
26
|
+
description: "Path to config file (.json, .ts, or .js)",
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
fix: option(
|
|
30
|
+
type("boolean").pipe((v) => v ?? false),
|
|
31
|
+
{
|
|
32
|
+
short: "f",
|
|
33
|
+
description: "Auto-fix issues",
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
cache: option(
|
|
37
|
+
type("boolean").pipe((v) => v ?? true),
|
|
38
|
+
{
|
|
39
|
+
description: "Enable caching",
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
files: option(type("string | undefined"), {
|
|
43
|
+
description: "Files to validate (if not specified, uses config patterns)",
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
handler: async ({ positional, flags, spinner }) => {
|
|
47
|
+
const spin = spinner("Loading configuration...");
|
|
48
|
+
spin.start();
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
// Load config
|
|
52
|
+
const config = await loadConfig(flags.config);
|
|
53
|
+
spin.succeed("Configuration loaded");
|
|
54
|
+
|
|
55
|
+
// Resolve files
|
|
56
|
+
const fileSpin = spinner("Resolving files...");
|
|
57
|
+
fileSpin.start();
|
|
58
|
+
|
|
59
|
+
const files = await glob(flags.files ? [flags.files] : positional, {
|
|
60
|
+
include: config.include,
|
|
61
|
+
exclude: config.exclude,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
fileSpin.succeed(`Found ${files.length} files to validate`);
|
|
65
|
+
|
|
66
|
+
if (files.length === 0) {
|
|
67
|
+
console.log(relico.yellow("No files matched the pattern"));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Run validation
|
|
72
|
+
const validateSpin = spinner("Validating files...");
|
|
73
|
+
validateSpin.start();
|
|
74
|
+
|
|
75
|
+
const results = await validateFiles(files, {
|
|
76
|
+
rules: config.rules,
|
|
77
|
+
fix: flags.fix,
|
|
78
|
+
cache: flags.cache && config.cache?.enabled,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
validateSpin.stop();
|
|
82
|
+
|
|
83
|
+
// Display results
|
|
84
|
+
let hasErrors = false;
|
|
85
|
+
|
|
86
|
+
for (const result of results) {
|
|
87
|
+
if (result.errors.length > 0 || result.warnings.length > 0) {
|
|
88
|
+
console.log();
|
|
89
|
+
console.log(relico.bold(result.file));
|
|
90
|
+
|
|
91
|
+
for (const error of result.errors) {
|
|
92
|
+
console.log(relico.red(` ✗ ${error.line}:${error.column} ${error.message}`));
|
|
93
|
+
hasErrors = true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
for (const warning of result.warnings) {
|
|
97
|
+
console.log(relico.yellow(` ⚠ ${warning.line}:${warning.column} ${warning.message}`));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Summary
|
|
103
|
+
const totalErrors = results.reduce((sum, r) => sum + r.errors.length, 0);
|
|
104
|
+
const totalWarnings = results.reduce((sum, r) => sum + r.warnings.length, 0);
|
|
105
|
+
|
|
106
|
+
console.log();
|
|
107
|
+
if (totalErrors === 0 && totalWarnings === 0) {
|
|
108
|
+
console.log(relico.green("✅ All files passed validation!"));
|
|
109
|
+
} else {
|
|
110
|
+
console.log(relico.bold("Summary:"));
|
|
111
|
+
if (totalErrors > 0) {
|
|
112
|
+
console.log(relico.red(` ${totalErrors} error${totalErrors !== 1 ? "s" : ""}`));
|
|
113
|
+
}
|
|
114
|
+
if (totalWarnings > 0) {
|
|
115
|
+
console.log(relico.yellow(` ${totalWarnings} warning${totalWarnings !== 1 ? "s" : ""}`));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (hasErrors) {
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} catch (error) {
|
|
123
|
+
spin.fail("Validation failed");
|
|
124
|
+
console.error(relico.red(String(error)));
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export default validateCommand;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { createCLI } from "@reliverse/rempts-core";
|
|
3
|
+
import configCommand from "./commands/config";
|
|
4
|
+
import initCommand from "./commands/init";
|
|
5
|
+
import serveCommand from "./commands/serve";
|
|
6
|
+
import validateCommand from "./commands/validate";
|
|
7
|
+
import { loadConfig } from "./utils/config";
|
|
8
|
+
|
|
9
|
+
const cli = await createCLI({
|
|
10
|
+
name: "{{name}}",
|
|
11
|
+
version: "0.1.0",
|
|
12
|
+
description: "{{description}}",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Global setup hook
|
|
16
|
+
cli.before(async (context) => {
|
|
17
|
+
// Set up logging based on flags (commands can define their own verbose/quiet options)
|
|
18
|
+
const logger = {
|
|
19
|
+
level: "info",
|
|
20
|
+
log: (message: string) => console.log(`[${new Date().toISOString()}] ${message}`),
|
|
21
|
+
error: (message: string) => console.error(`[ERROR] ${message}`),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
context.set("logger", logger);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Add commands
|
|
28
|
+
cli.command(initCommand);
|
|
29
|
+
cli.command(validateCommand);
|
|
30
|
+
cli.command(serveCommand);
|
|
31
|
+
cli.command(configCommand);
|
|
32
|
+
|
|
33
|
+
// Load config and run
|
|
34
|
+
async function run() {
|
|
35
|
+
try {
|
|
36
|
+
await loadConfig();
|
|
37
|
+
await cli.run();
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error("Failed to start CLI:", error);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
await run();
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { CONFIG_FILE_NAME, DEFAULT_CONFIG } from "./constants";
|
|
3
|
+
|
|
4
|
+
export interface Config {
|
|
5
|
+
rules?: Record<string, any>;
|
|
6
|
+
server?: {
|
|
7
|
+
port?: number;
|
|
8
|
+
host?: string;
|
|
9
|
+
open?: boolean;
|
|
10
|
+
cors?: boolean;
|
|
11
|
+
};
|
|
12
|
+
include?: string[];
|
|
13
|
+
exclude?: string[];
|
|
14
|
+
cache?: {
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
directory?: string;
|
|
17
|
+
};
|
|
18
|
+
hooks?: {
|
|
19
|
+
beforeValidate?: (files: string[]) => Promise<void>;
|
|
20
|
+
afterValidate?: (results: any) => Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let cachedConfig: Config | null = null;
|
|
25
|
+
|
|
26
|
+
export async function loadConfig(configPath?: string): Promise<Config> {
|
|
27
|
+
// Return cached config if available
|
|
28
|
+
if (cachedConfig && !configPath) {
|
|
29
|
+
return cachedConfig;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const finalPath = configPath || path.join(process.cwd(), CONFIG_FILE_NAME);
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
// Check if config file exists
|
|
36
|
+
const file = Bun.file(finalPath);
|
|
37
|
+
if (!(await file.exists())) {
|
|
38
|
+
return DEFAULT_CONFIG;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Import the config file
|
|
42
|
+
const configModule = await import(finalPath);
|
|
43
|
+
const config = configModule.default || configModule;
|
|
44
|
+
|
|
45
|
+
// Merge with defaults
|
|
46
|
+
cachedConfig = {
|
|
47
|
+
...DEFAULT_CONFIG,
|
|
48
|
+
...config,
|
|
49
|
+
server: {
|
|
50
|
+
...DEFAULT_CONFIG.server,
|
|
51
|
+
...config.server,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return cachedConfig;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.warn(`Failed to load config from ${finalPath}:`, error);
|
|
58
|
+
return DEFAULT_CONFIG;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function saveConfig(config: Config): Promise<void> {
|
|
63
|
+
const configPath = path.join(process.cwd(), CONFIG_FILE_NAME);
|
|
64
|
+
|
|
65
|
+
// Convert config to ES module format
|
|
66
|
+
const content = `export default ${JSON.stringify(config, null, 2)}`;
|
|
67
|
+
|
|
68
|
+
await Bun.write(configPath, content);
|
|
69
|
+
|
|
70
|
+
// Clear cache
|
|
71
|
+
cachedConfig = null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function getConfigPath(): Promise<string> {
|
|
75
|
+
const configPath = path.join(process.cwd(), CONFIG_FILE_NAME);
|
|
76
|
+
const file = Bun.file(configPath);
|
|
77
|
+
|
|
78
|
+
if (await file.exists()) {
|
|
79
|
+
return configPath;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return "No config file found";
|
|
83
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { Glob } from "bun";
|
|
3
|
+
|
|
4
|
+
export interface GlobOptions {
|
|
5
|
+
include?: string[];
|
|
6
|
+
exclude?: string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function glob(patterns: string[], options: GlobOptions = {}): Promise<string[]> {
|
|
10
|
+
const { include = [], exclude = [] } = options;
|
|
11
|
+
|
|
12
|
+
// Combine user patterns with include patterns
|
|
13
|
+
const allPatterns = [...patterns, ...include];
|
|
14
|
+
|
|
15
|
+
// Convert exclude patterns to absolute paths
|
|
16
|
+
const excludePatterns = exclude.map((pattern) => {
|
|
17
|
+
if (pattern.startsWith("/")) {
|
|
18
|
+
return pattern;
|
|
19
|
+
}
|
|
20
|
+
return path.join(process.cwd(), pattern);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const results = new Set<string>();
|
|
24
|
+
|
|
25
|
+
for (const pattern of allPatterns) {
|
|
26
|
+
const glob = new Glob(pattern);
|
|
27
|
+
|
|
28
|
+
for await (const file of glob.scan({
|
|
29
|
+
cwd: process.cwd(),
|
|
30
|
+
absolute: true,
|
|
31
|
+
})) {
|
|
32
|
+
// Check if file should be excluded
|
|
33
|
+
let shouldExclude = false;
|
|
34
|
+
|
|
35
|
+
for (const excludePattern of excludePatterns) {
|
|
36
|
+
if (file.includes(excludePattern)) {
|
|
37
|
+
shouldExclude = true;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!shouldExclude) {
|
|
43
|
+
results.add(file);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return Array.from(results).sort();
|
|
49
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
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 && !(content.startsWith("/*") || content.startsWith("//"))) {
|
|
91
|
+
errors.push({
|
|
92
|
+
line: 1,
|
|
93
|
+
column: 1,
|
|
94
|
+
message: "File must start with a header comment",
|
|
95
|
+
rule: "requireFileHeader",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Auto-fix if requested
|
|
100
|
+
if (fix && errors.length > 0) {
|
|
101
|
+
// This is a simplified example - real fix logic would be more complex
|
|
102
|
+
let fixedContent = content;
|
|
103
|
+
|
|
104
|
+
if (rules.noConsoleLog) {
|
|
105
|
+
fixedContent = fixedContent.replace(/console\.log\s*\([^)]*\);?/g, "");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (rules.noDebugger) {
|
|
109
|
+
fixedContent = fixedContent.replace(/\bdebugger\b;?/g, "");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
await Bun.write(filePath, fixedContent);
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
errors.push({
|
|
116
|
+
line: 0,
|
|
117
|
+
column: 0,
|
|
118
|
+
message: `Failed to validate file: ${error}`,
|
|
119
|
+
rule: "system",
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
file: filePath,
|
|
125
|
+
errors,
|
|
126
|
+
warnings,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reliverse/rempts-advanced",
|
|
3
|
+
"description": "Advanced Rempts CLI template with multiple commands",
|
|
4
|
+
"variables": [
|
|
5
|
+
{
|
|
6
|
+
"name": "name",
|
|
7
|
+
"message": "Project name",
|
|
8
|
+
"type": "string",
|
|
9
|
+
"default": "my-rempts-cli"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "description",
|
|
13
|
+
"message": "Project description",
|
|
14
|
+
"type": "string",
|
|
15
|
+
"default": "A powerful CLI built with Rempts"
|
|
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
|
+
"files": {
|
|
38
|
+
"exclude": ["node_modules/**", ".git/**", "template.json"]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -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"],
|
|
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
|
+
# {{name}}
|
|
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
|
+
{{name}} hello --name World
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Commands
|
|
36
|
+
|
|
37
|
+
- `hello` - A simple greeting command
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineConfig } from "@reliverse/rempts-core";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
name: "{{name}}",
|
|
5
|
+
version: "{{version}}",
|
|
6
|
+
description: "{{description}}",
|
|
7
|
+
|
|
8
|
+
build: {
|
|
9
|
+
entry: "./src/mod.ts",
|
|
10
|
+
outdir: "./dist",
|
|
11
|
+
targets: ["native"],
|
|
12
|
+
minify: true,
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
compress: false,
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
dev: {
|
|
18
|
+
watch: true,
|
|
19
|
+
inspect: true,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
test: {
|
|
23
|
+
pattern: ["**/*.test.ts", "**/*.spec.ts"],
|
|
24
|
+
coverage: true,
|
|
25
|
+
watch: false,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
plugins: [],
|
|
29
|
+
|
|
30
|
+
workspace: {
|
|
31
|
+
versionStrategy: "fixed",
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
release: {
|
|
35
|
+
npm: true,
|
|
36
|
+
github: false,
|
|
37
|
+
tagFormat: "v{{version}}",
|
|
38
|
+
conventionalCommits: true,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "{{description}}",
|
|
5
|
+
"author": "{{author}}",
|
|
6
|
+
"bin": {
|
|
7
|
+
"{{name}}": "./src/mod.ts"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"postinstall": "bun dler generate",
|
|
12
|
+
"dev": "bun run src/mod.ts",
|
|
13
|
+
"build": "bun dler build",
|
|
14
|
+
"test": "bun test",
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@reliverse/rempts-core": "workspace:*"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@reliverse/rempts-test": "workspace:*",
|
|
22
|
+
"@reliverse/tsconfig": "workspace:*",
|
|
23
|
+
"@types/bun": "catalog:",
|
|
24
|
+
"rempts": "workspace:*",
|
|
25
|
+
"typescript": "catalog:"
|
|
26
|
+
},
|
|
27
|
+
"rempts": {
|
|
28
|
+
"entry": "./src/mod.ts",
|
|
29
|
+
"outDir": "./dist"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { relico } from "@reliverse/relico";
|
|
2
|
+
import { defineCommand, option } from "@reliverse/rempts-core";
|
|
3
|
+
import { type } from "arktype";
|
|
4
|
+
|
|
5
|
+
const helloCommand = defineCommand({
|
|
6
|
+
name: "hello",
|
|
7
|
+
description: "Say hello to someone",
|
|
8
|
+
options: {
|
|
9
|
+
name: option(type("string", "=", "World"), {
|
|
10
|
+
description: "Name to greet",
|
|
11
|
+
short: "n",
|
|
12
|
+
}),
|
|
13
|
+
excited: option(type("boolean", "=", false), {
|
|
14
|
+
description: "Add excitement!",
|
|
15
|
+
short: "e",
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
handler: async ({ flags, colors }) => {
|
|
19
|
+
const greeting = `Hello, ${flags.name}`;
|
|
20
|
+
const message = flags.excited ? `${greeting}!` : `${greeting}.`;
|
|
21
|
+
|
|
22
|
+
console.log(relico.green(message));
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export default helloCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { createCLI } from "@reliverse/rempts-core";
|
|
3
|
+
import helloCommand from "./commands/hello";
|
|
4
|
+
|
|
5
|
+
const cli = await createCLI({
|
|
6
|
+
name: "{{name}}",
|
|
7
|
+
version: "0.1.0",
|
|
8
|
+
description: "{{description}}",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
cli.command(helloCommand);
|
|
12
|
+
|
|
13
|
+
await cli.run();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reliverse/rempts-basic",
|
|
3
|
+
"description": "Basic Rempts CLI template",
|
|
4
|
+
"variables": [
|
|
5
|
+
{
|
|
6
|
+
"name": "projectName",
|
|
7
|
+
"message": "Project name",
|
|
8
|
+
"type": "string",
|
|
9
|
+
"default": "my-rempts-cli"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "description",
|
|
13
|
+
"message": "Project description",
|
|
14
|
+
"type": "string",
|
|
15
|
+
"default": "A CLI built with Rempts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "author",
|
|
19
|
+
"message": "Author name",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"default": ""
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"files": {
|
|
25
|
+
"exclude": ["node_modules/**", ".git/**", "template.json"]
|
|
26
|
+
}
|
|
27
|
+
}
|