@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,118 @@
|
|
|
1
|
+
# {{name}}
|
|
2
|
+
|
|
3
|
+
{{description}}
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install globally
|
|
9
|
+
bun add -g {{name}}
|
|
10
|
+
|
|
11
|
+
# Or use directly with bunx
|
|
12
|
+
bunx {{name}} [command]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
{{name}} <command> [options]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Commands
|
|
22
|
+
|
|
23
|
+
#### `init`
|
|
24
|
+
|
|
25
|
+
Initialize a new configuration file in the current directory.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
{{name}} init [options]
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
-f, --force Overwrite existing config
|
|
32
|
+
-t, --template Config template to use
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### `validate`
|
|
36
|
+
|
|
37
|
+
Validate files against defined rules.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
{{name}} validate <files...> [options]
|
|
41
|
+
|
|
42
|
+
Options:
|
|
43
|
+
-c, --config Path to config file
|
|
44
|
+
-f, --fix Auto-fix issues
|
|
45
|
+
--no-cache Disable caching
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### `serve`
|
|
49
|
+
|
|
50
|
+
Start a development server.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
{{name}} serve [options]
|
|
54
|
+
|
|
55
|
+
Options:
|
|
56
|
+
-p, --port Port to listen on (default: 3000)
|
|
57
|
+
-h, --host Host to bind to (default: localhost)
|
|
58
|
+
--no-open Don't open browser
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### `config`
|
|
62
|
+
|
|
63
|
+
Manage configuration settings.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
{{name}} config <action> [key] [value]
|
|
67
|
+
|
|
68
|
+
Actions:
|
|
69
|
+
get <key> Get a config value
|
|
70
|
+
set <key> <value> Set a config value
|
|
71
|
+
list List all config values
|
|
72
|
+
reset Reset to defaults
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Global Options
|
|
76
|
+
|
|
77
|
+
- `-v, --version` - Show version
|
|
78
|
+
- `-h, --help` - Show help
|
|
79
|
+
- `--verbose` - Enable verbose output
|
|
80
|
+
- `--quiet` - Suppress output
|
|
81
|
+
- `--no-color` - Disable colored output
|
|
82
|
+
|
|
83
|
+
## Configuration
|
|
84
|
+
|
|
85
|
+
Create a `{{name}}.config.js` file in your project root:
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
export default {
|
|
89
|
+
// Configuration options
|
|
90
|
+
rules: {
|
|
91
|
+
// Define your rules
|
|
92
|
+
},
|
|
93
|
+
server: {
|
|
94
|
+
port: 3000,
|
|
95
|
+
host: 'localhost'
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Development
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Install dependencies
|
|
104
|
+
bun install
|
|
105
|
+
|
|
106
|
+
# Run in development
|
|
107
|
+
bun dev
|
|
108
|
+
|
|
109
|
+
# Run tests
|
|
110
|
+
bun test
|
|
111
|
+
|
|
112
|
+
# Build for production
|
|
113
|
+
bun run build
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
{{license}}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defineConfig } from "@reliverse/rempts-core";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
name: "{{name}}",
|
|
5
|
+
version: "{{version}}",
|
|
6
|
+
description: "{{description}}",
|
|
7
|
+
|
|
8
|
+
plugins: [],
|
|
9
|
+
|
|
10
|
+
build: {
|
|
11
|
+
entry: "./src/mod.ts",
|
|
12
|
+
outdir: "./dist",
|
|
13
|
+
targets: ["darwin-arm64", "darwin-x64", "linux-x64", "windows-x64"],
|
|
14
|
+
minify: true,
|
|
15
|
+
sourcemap: true,
|
|
16
|
+
compress: true,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
dev: {
|
|
20
|
+
watch: true,
|
|
21
|
+
inspect: false,
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
test: {
|
|
25
|
+
pattern: ["**/*.test.ts", "**/*.spec.ts"],
|
|
26
|
+
coverage: true,
|
|
27
|
+
watch: false,
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
workspace: {
|
|
31
|
+
packages: ["./packages/*"],
|
|
32
|
+
versionStrategy: "fixed",
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
release: {
|
|
36
|
+
npm: true,
|
|
37
|
+
github: false,
|
|
38
|
+
tagFormat: "v{{version}}",
|
|
39
|
+
conventionalCommits: true,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "{{description}}",
|
|
5
|
+
"license": "{{license}}",
|
|
6
|
+
"author": "{{author}}",
|
|
7
|
+
"bin": {
|
|
8
|
+
"{{name}}": "./src/mod.ts"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"postinstall": "bun dler generate",
|
|
13
|
+
"dev": "bun run src/mod.ts",
|
|
14
|
+
"build": "bun dler build",
|
|
15
|
+
"test": "bun test",
|
|
16
|
+
"test:watch": "bun test --watch",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"lint": "tsc --noEmit",
|
|
19
|
+
"prepare": "bun run build"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@reliverse/rempts-core": "workspace:*",
|
|
23
|
+
"@reliverse/rempts-utils": "workspace:*",
|
|
24
|
+
"arktype": "catalog:"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@reliverse/rempts-test": "workspace:*",
|
|
28
|
+
"@reliverse/tsconfig": "workspace:*",
|
|
29
|
+
"@types/bun": "catalog:",
|
|
30
|
+
"rempts": "workspace:*",
|
|
31
|
+
"typescript": "catalog:"
|
|
32
|
+
},
|
|
33
|
+
"rempts": {
|
|
34
|
+
"entry": "./src/mod.ts",
|
|
35
|
+
"outDir": "./dist",
|
|
36
|
+
"external": [
|
|
37
|
+
"@reliverse/rempts-core",
|
|
38
|
+
"@reliverse/rempts-utils",
|
|
39
|
+
"zod"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { relico } from "@reliverse/relico";
|
|
2
|
+
import { defineCommand, option } from "@reliverse/rempts-core";
|
|
3
|
+
import { type } from "arktype";
|
|
4
|
+
import { getConfigPath, loadConfig, saveConfig } from "../utils/config";
|
|
5
|
+
|
|
6
|
+
const configCommand = defineCommand({
|
|
7
|
+
name: "config",
|
|
8
|
+
description: "Manage configuration",
|
|
9
|
+
commands: [
|
|
10
|
+
defineCommand({
|
|
11
|
+
name: "get",
|
|
12
|
+
description: "Get a config value",
|
|
13
|
+
options: {
|
|
14
|
+
key: option(type("string | undefined"), {
|
|
15
|
+
description: "Config key to get",
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
handler: async ({ flags }) => {
|
|
19
|
+
const key = flags.key;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const config = await loadConfig();
|
|
23
|
+
const value = getNestedValue(config, key);
|
|
24
|
+
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
console.log(relico.yellow(`Config key '${key}' not found`));
|
|
27
|
+
} else {
|
|
28
|
+
console.log(JSON.stringify(value, null, 2));
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error(relico.red(`Failed to load config: ${error}`));
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
|
|
37
|
+
defineCommand({
|
|
38
|
+
name: "set",
|
|
39
|
+
description: "Set a config value",
|
|
40
|
+
options: {
|
|
41
|
+
key: option(type("string | undefined"), {
|
|
42
|
+
description: "Config key to set",
|
|
43
|
+
}),
|
|
44
|
+
value: option(type("string | undefined"), {
|
|
45
|
+
description: "Value to set",
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
handler: async ({ flags, spinner }) => {
|
|
49
|
+
const key = flags.key;
|
|
50
|
+
const value = flags.value;
|
|
51
|
+
|
|
52
|
+
const spin = spinner("Updating config...");
|
|
53
|
+
spin.start();
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
const config = await loadConfig();
|
|
57
|
+
setNestedValue(config, key, JSON.parse(value));
|
|
58
|
+
await saveConfig(config);
|
|
59
|
+
|
|
60
|
+
spin.succeed(`Config '${key}' updated`);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
spin.fail("Failed to update config");
|
|
63
|
+
console.error(relico.red(String(error)));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
|
|
69
|
+
defineCommand({
|
|
70
|
+
name: "list",
|
|
71
|
+
description: "List all config values",
|
|
72
|
+
handler: async () => {
|
|
73
|
+
try {
|
|
74
|
+
const config = await loadConfig();
|
|
75
|
+
const configPath = await getConfigPath();
|
|
76
|
+
|
|
77
|
+
console.log(relico.bold("Configuration:"));
|
|
78
|
+
console.log(relico.dim(` File: ${configPath}`));
|
|
79
|
+
console.log();
|
|
80
|
+
console.log(JSON.stringify(config, null, 2));
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error(relico.red(`Failed to load config: ${error}`));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
87
|
+
|
|
88
|
+
defineCommand({
|
|
89
|
+
name: "reset",
|
|
90
|
+
description: "Reset config to defaults",
|
|
91
|
+
options: {
|
|
92
|
+
force: option(type("boolean", "=", false), {
|
|
93
|
+
short: "f",
|
|
94
|
+
description: "Skip confirmation",
|
|
95
|
+
}),
|
|
96
|
+
},
|
|
97
|
+
handler: async ({ flags, prompt, spinner }) => {
|
|
98
|
+
if (!flags.force) {
|
|
99
|
+
const confirmed = await prompt.confirm(
|
|
100
|
+
"This will reset all config to defaults. Continue?",
|
|
101
|
+
{ default: false }
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
if (!confirmed) {
|
|
105
|
+
console.log(relico.yellow("Reset cancelled"));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const spin = spinner("Resetting config...");
|
|
111
|
+
spin.start();
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
const { DEFAULT_CONFIG } = await import("../utils/constants.js");
|
|
115
|
+
await saveConfig(DEFAULT_CONFIG);
|
|
116
|
+
|
|
117
|
+
spin.succeed("Config reset to defaults");
|
|
118
|
+
} catch (error) {
|
|
119
|
+
spin.fail("Failed to reset config");
|
|
120
|
+
console.error(relico.red(String(error)));
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
}),
|
|
125
|
+
],
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
function getNestedValue(obj: any, path: string): any {
|
|
129
|
+
const keys = path.split(".");
|
|
130
|
+
let current = obj;
|
|
131
|
+
|
|
132
|
+
for (const key of keys) {
|
|
133
|
+
if (current === null || current === undefined) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
current = current[key];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return current;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function setNestedValue(obj: any, path: string, value: any): void {
|
|
143
|
+
const keys = path.split(".");
|
|
144
|
+
const lastKey = keys.pop()!;
|
|
145
|
+
let current = obj;
|
|
146
|
+
|
|
147
|
+
for (const key of keys) {
|
|
148
|
+
if (!(key in current) || typeof current[key] !== "object") {
|
|
149
|
+
current[key] = {};
|
|
150
|
+
}
|
|
151
|
+
current = current[key];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
current[lastKey] = value;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export default configCommand;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { relico } from "@reliverse/relico";
|
|
2
|
+
import { defineCommand, option } from "@reliverse/rempts-core";
|
|
3
|
+
import { type } from "arktype";
|
|
4
|
+
import { CONFIG_FILE_NAME, DEFAULT_CONFIG } from "../utils/constants";
|
|
5
|
+
|
|
6
|
+
const initCommand = defineCommand({
|
|
7
|
+
name: "init",
|
|
8
|
+
description: "Initialize a new configuration file",
|
|
9
|
+
options: {
|
|
10
|
+
force: option(type("boolean", "=", false), {
|
|
11
|
+
short: "f",
|
|
12
|
+
description: "Overwrite existing config",
|
|
13
|
+
}),
|
|
14
|
+
template: option(type("'minimal'|'default'|'full'", "=", "default"), {
|
|
15
|
+
short: "t",
|
|
16
|
+
description: "Config template to use",
|
|
17
|
+
}),
|
|
18
|
+
},
|
|
19
|
+
handler: async ({ flags, prompt, spinner, hooks }) => {
|
|
20
|
+
const logger = hooks?.logger;
|
|
21
|
+
const configPath = `${process.cwd()}/${CONFIG_FILE_NAME}`;
|
|
22
|
+
|
|
23
|
+
// Check if config already exists
|
|
24
|
+
const configFile = Bun.file(configPath);
|
|
25
|
+
if ((await configFile.exists()) && !flags.force) {
|
|
26
|
+
const overwrite = await prompt.confirm("Config file already exists. Overwrite?", {
|
|
27
|
+
default: false,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (!overwrite) {
|
|
31
|
+
logger?.log("Init cancelled");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const spin = spinner("Creating config file...");
|
|
37
|
+
spin.start();
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
// Get template content
|
|
41
|
+
const configContent = getConfigTemplate(flags.template);
|
|
42
|
+
|
|
43
|
+
// Write config file
|
|
44
|
+
await Bun.write(configPath, configContent);
|
|
45
|
+
|
|
46
|
+
spin.succeed("Config file created");
|
|
47
|
+
logger?.log(`Created ${CONFIG_FILE_NAME}`);
|
|
48
|
+
|
|
49
|
+
// Next steps
|
|
50
|
+
console.log();
|
|
51
|
+
console.log("Next steps:");
|
|
52
|
+
console.log(relico.gray(` 1. Edit ${CONFIG_FILE_NAME} to customize your configuration`));
|
|
53
|
+
console.log(relico.gray(` 2. Run '{{name}} validate' to check your files`));
|
|
54
|
+
} catch (error) {
|
|
55
|
+
spin.fail("Failed to create config file");
|
|
56
|
+
logger?.error(String(error));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
function getConfigTemplate(template: "minimal" | "default" | "full"): string {
|
|
63
|
+
const templates = {
|
|
64
|
+
minimal: `export default ${JSON.stringify(DEFAULT_CONFIG, null, 2)}`,
|
|
65
|
+
|
|
66
|
+
default: `export default {
|
|
67
|
+
// Validation rules
|
|
68
|
+
rules: {
|
|
69
|
+
// Add your validation rules here
|
|
70
|
+
noConsoleLog: true,
|
|
71
|
+
requireFileHeader: false,
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
// Server configuration
|
|
75
|
+
server: {
|
|
76
|
+
port: 3000,
|
|
77
|
+
host: 'localhost',
|
|
78
|
+
open: true,
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
// File patterns
|
|
82
|
+
include: ['src/**/*.{js,ts}'],
|
|
83
|
+
exclude: ['node_modules', 'dist', 'test'],
|
|
84
|
+
}`,
|
|
85
|
+
|
|
86
|
+
full: `import { defineConfig } from '{{name}}'
|
|
87
|
+
|
|
88
|
+
export default defineConfig({
|
|
89
|
+
// Validation rules
|
|
90
|
+
rules: {
|
|
91
|
+
// Code style rules
|
|
92
|
+
noConsoleLog: true,
|
|
93
|
+
noDebugger: true,
|
|
94
|
+
requireFileHeader: true,
|
|
95
|
+
maxLineLength: 100,
|
|
96
|
+
|
|
97
|
+
// Import rules
|
|
98
|
+
noUnusedImports: true,
|
|
99
|
+
sortImports: true,
|
|
100
|
+
|
|
101
|
+
// Function rules
|
|
102
|
+
maxFunctionLength: 50,
|
|
103
|
+
maxComplexity: 10,
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
// Server configuration
|
|
107
|
+
server: {
|
|
108
|
+
port: process.env.PORT || 3000,
|
|
109
|
+
host: process.env.HOST || 'localhost',
|
|
110
|
+
open: !process.env.CI,
|
|
111
|
+
cors: true,
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
// File patterns
|
|
115
|
+
include: [
|
|
116
|
+
'src/**/*.{js,ts,jsx,tsx}',
|
|
117
|
+
'scripts/**/*.{js,ts}',
|
|
118
|
+
],
|
|
119
|
+
exclude: [
|
|
120
|
+
'node_modules',
|
|
121
|
+
'dist',
|
|
122
|
+
'build',
|
|
123
|
+
'coverage',
|
|
124
|
+
'**/*.test.{js,ts}',
|
|
125
|
+
'**/*.spec.{js,ts}',
|
|
126
|
+
],
|
|
127
|
+
|
|
128
|
+
// Caching
|
|
129
|
+
cache: {
|
|
130
|
+
enabled: true,
|
|
131
|
+
directory: '.cache',
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
// Hooks
|
|
135
|
+
hooks: {
|
|
136
|
+
beforeValidate: async (files) => {
|
|
137
|
+
console.log(\`Validating \${files.length} files...\`)
|
|
138
|
+
},
|
|
139
|
+
afterValidate: async (results) => {
|
|
140
|
+
console.log(\`Found \${results.errors} errors and \${results.warnings} warnings\`)
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
})`,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
return templates[template];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export default initCommand;
|
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
|
|
6
|
+
const serveCommand = defineCommand({
|
|
7
|
+
name: "serve",
|
|
8
|
+
description: "Start a development server",
|
|
9
|
+
options: {
|
|
10
|
+
port: option(type("number", { divisor: 1, min: 1, max: 65_535 }, "=", 3000), {
|
|
11
|
+
short: "p",
|
|
12
|
+
description: "Port to listen on",
|
|
13
|
+
}),
|
|
14
|
+
host: option(type("string", "=", "localhost"), {
|
|
15
|
+
short: "h",
|
|
16
|
+
description: "Host to bind to",
|
|
17
|
+
}),
|
|
18
|
+
open: option(type("boolean", "=", true), {
|
|
19
|
+
description: "Open browser on start",
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
handler: async ({ flags, spinner, shell }) => {
|
|
23
|
+
const spin = spinner("Starting server...");
|
|
24
|
+
spin.start();
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
// Load config
|
|
28
|
+
const config = await loadConfig();
|
|
29
|
+
|
|
30
|
+
// Merge flags with config
|
|
31
|
+
const port = flags.port || config.server?.port || 3000;
|
|
32
|
+
const host = flags.host || config.server?.host || "localhost";
|
|
33
|
+
const shouldOpen = flags.open ?? config.server?.open ?? true;
|
|
34
|
+
|
|
35
|
+
// Create server
|
|
36
|
+
const server = Bun.serve({
|
|
37
|
+
port,
|
|
38
|
+
hostname: host,
|
|
39
|
+
fetch(req) {
|
|
40
|
+
const url = new URL(req.url);
|
|
41
|
+
|
|
42
|
+
// Simple router
|
|
43
|
+
if (url.pathname === "/") {
|
|
44
|
+
return new Response(getHomePage(), {
|
|
45
|
+
headers: { "Content-Type": "text/html" },
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (url.pathname === "/api/status") {
|
|
50
|
+
return Response.json({
|
|
51
|
+
status: "ok",
|
|
52
|
+
version: "0.1.0",
|
|
53
|
+
uptime: process.uptime(),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return new Response("Not Found", { status: 404 });
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
spin.succeed(`Server running at http://${host}:${port}`);
|
|
62
|
+
|
|
63
|
+
// Open browser
|
|
64
|
+
if (shouldOpen) {
|
|
65
|
+
const openSpin = spinner("Opening browser...");
|
|
66
|
+
openSpin.start();
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const url = `http://${host === "0.0.0.0" ? "localhost" : host}:${port}`;
|
|
70
|
+
|
|
71
|
+
// Platform-specific open commands
|
|
72
|
+
const openCommand =
|
|
73
|
+
process.platform === "darwin"
|
|
74
|
+
? "open"
|
|
75
|
+
: process.platform === "win32"
|
|
76
|
+
? "start"
|
|
77
|
+
: "xdg-open";
|
|
78
|
+
|
|
79
|
+
await shell`${openCommand} ${url}`.quiet();
|
|
80
|
+
openSpin.succeed("Browser opened");
|
|
81
|
+
} catch {
|
|
82
|
+
openSpin.fail("Failed to open browser");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Keep server running
|
|
87
|
+
console.log();
|
|
88
|
+
console.log(relico.dim("Press Ctrl+C to stop the server"));
|
|
89
|
+
|
|
90
|
+
// Handle shutdown
|
|
91
|
+
process.on("SIGINT", () => {
|
|
92
|
+
console.log();
|
|
93
|
+
console.log(relico.yellow("Shutting down server..."));
|
|
94
|
+
server.stop();
|
|
95
|
+
process.exit(0);
|
|
96
|
+
});
|
|
97
|
+
} catch (error) {
|
|
98
|
+
spin.fail("Failed to start server");
|
|
99
|
+
console.error(relico.red(String(error)));
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
function getHomePage(): string {
|
|
106
|
+
return `
|
|
107
|
+
<!DOCTYPE html>
|
|
108
|
+
<html>
|
|
109
|
+
<head>
|
|
110
|
+
<title>{{name}}</title>
|
|
111
|
+
<style>
|
|
112
|
+
body {
|
|
113
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
114
|
+
max-width: 800px;
|
|
115
|
+
margin: 0 auto;
|
|
116
|
+
padding: 2rem;
|
|
117
|
+
background: #f5f5f5;
|
|
118
|
+
}
|
|
119
|
+
.container {
|
|
120
|
+
background: white;
|
|
121
|
+
padding: 2rem;
|
|
122
|
+
border-radius: 8px;
|
|
123
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
124
|
+
}
|
|
125
|
+
h1 {
|
|
126
|
+
color: #333;
|
|
127
|
+
margin-top: 0;
|
|
128
|
+
}
|
|
129
|
+
.status {
|
|
130
|
+
display: inline-block;
|
|
131
|
+
padding: 0.25rem 0.5rem;
|
|
132
|
+
background: #10b981;
|
|
133
|
+
color: white;
|
|
134
|
+
border-radius: 4px;
|
|
135
|
+
font-size: 0.875rem;
|
|
136
|
+
}
|
|
137
|
+
code {
|
|
138
|
+
background: #f3f4f6;
|
|
139
|
+
padding: 0.125rem 0.25rem;
|
|
140
|
+
border-radius: 3px;
|
|
141
|
+
font-family: monospace;
|
|
142
|
+
}
|
|
143
|
+
.endpoints {
|
|
144
|
+
margin-top: 2rem;
|
|
145
|
+
padding: 1rem;
|
|
146
|
+
background: #f9fafb;
|
|
147
|
+
border-radius: 4px;
|
|
148
|
+
}
|
|
149
|
+
</style>
|
|
150
|
+
</head>
|
|
151
|
+
<body>
|
|
152
|
+
<div class="container">
|
|
153
|
+
<h1>{{name}}</h1>
|
|
154
|
+
<p>{{description}}</p>
|
|
155
|
+
<p><span class="status">Running</span></p>
|
|
156
|
+
|
|
157
|
+
<div class="endpoints">
|
|
158
|
+
<h3>API Endpoints</h3>
|
|
159
|
+
<ul>
|
|
160
|
+
<li><code>GET /</code> - This page</li>
|
|
161
|
+
<li><code>GET /api/status</code> - Server status</li>
|
|
162
|
+
</ul>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<p>To get started, check out the <a href="https://github.com/reliverse/dler">documentation</a>.</p>
|
|
166
|
+
</div>
|
|
167
|
+
</body>
|
|
168
|
+
</html>
|
|
169
|
+
`.trim();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export default serveCommand;
|