@lytjs/cli 6.6.0 → 6.8.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.
@@ -0,0 +1,208 @@
1
+ /**
2
+ * @lytjs/cli - CLI runner
3
+ *
4
+ * Main entry point for the CLI. Parses arguments and routes to commands.
5
+ */
6
+ declare function runCli(rawArgs?: string[]): Promise<void>;
7
+
8
+ /**
9
+ * @lytjs/cli - Type definitions
10
+ */
11
+ interface CliOptions {
12
+ command: string;
13
+ args: string[];
14
+ options: Record<string, unknown>;
15
+ }
16
+ interface CreateOptions {
17
+ template?: string;
18
+ force?: boolean;
19
+ }
20
+ interface DevOptions {
21
+ port?: number;
22
+ host?: string;
23
+ open?: boolean;
24
+ }
25
+ interface BuildOptions {
26
+ outDir?: string;
27
+ ssr?: boolean;
28
+ minify?: boolean;
29
+ }
30
+ interface TestOptions {
31
+ watch?: boolean;
32
+ coverage?: boolean;
33
+ grep?: string;
34
+ }
35
+ interface AddOptions {
36
+ force?: boolean;
37
+ typescript?: boolean;
38
+ scoped?: boolean;
39
+ }
40
+ interface PackageJson {
41
+ name: string;
42
+ version: string;
43
+ dependencies?: Record<string, string>;
44
+ devDependencies?: Record<string, string>;
45
+ scripts?: Record<string, string>;
46
+ }
47
+
48
+ /**
49
+ * @lytjs/cli - create command
50
+ *
51
+ * Creates a new LytJS project from a template.
52
+ */
53
+
54
+ /**
55
+ * Create a new LytJS project
56
+ */
57
+ declare function create(projectName?: string, options?: Partial<CreateOptions>): Promise<void>;
58
+ /**
59
+ * List available templates
60
+ */
61
+ declare function listTemplates(): void;
62
+
63
+ /**
64
+ * @lytjs/cli - dev command
65
+ *
66
+ * Starts the development server.
67
+ */
68
+
69
+ /**
70
+ * Start the development server
71
+ */
72
+ declare function dev(options?: DevOptions): Promise<void>;
73
+
74
+ /**
75
+ * @lytjs/cli - build command
76
+ *
77
+ * Builds the project for production.
78
+ */
79
+
80
+ /**
81
+ * Build the project for production
82
+ */
83
+ declare function build(options?: BuildOptions): Promise<void>;
84
+
85
+ /**
86
+ * @lytjs/cli - test command
87
+ *
88
+ * Runs the test suite.
89
+ */
90
+
91
+ /**
92
+ * Run tests
93
+ */
94
+ declare function test(options?: TestOptions): Promise<void>;
95
+
96
+ /**
97
+ * @lytjs/cli - add command
98
+ *
99
+ * Generate components, pages, and stores.
100
+ */
101
+
102
+ type AddType = 'component' | 'page' | 'store' | 'directive' | 'composable' | 'util' | 'middleware' | 'hook';
103
+ /**
104
+ * Add a component, page, or store
105
+ */
106
+ declare function add(type: AddType, name: string, options?: AddOptions): Promise<void>;
107
+
108
+ /**
109
+ * @lytjs/cli - 代码生成器命令
110
+ *
111
+ * 提供组件、页面、服务等代码生成功能
112
+ */
113
+ interface GenerateOptions {
114
+ type: 'component' | 'page' | 'service' | 'hook' | 'store' | 'layout' | 'middleware';
115
+ name: string;
116
+ path?: string;
117
+ withStyles?: boolean;
118
+ withTest?: boolean;
119
+ withStorybook?: boolean;
120
+ description?: string;
121
+ template?: 'default' | 'sfc' | 'functional';
122
+ language?: 'ts' | 'js';
123
+ }
124
+ declare function generate(options: GenerateOptions): Promise<void>;
125
+
126
+ /**
127
+ * @lytjs/cli - plugin command
128
+ *
129
+ * Plugin development CLI commands: create, build, validate, publish.
130
+ */
131
+ interface PluginCreateOptions {
132
+ template?: string;
133
+ force?: boolean;
134
+ skipInstall?: boolean;
135
+ }
136
+ interface PluginBuildOptions {
137
+ outDir?: string;
138
+ minify?: boolean;
139
+ sourcemap?: boolean;
140
+ }
141
+ interface PluginValidateOptions {
142
+ strict?: boolean;
143
+ warningsAsErrors?: boolean;
144
+ }
145
+ interface PluginPublishOptions {
146
+ registry?: string;
147
+ access?: 'public' | 'restricted';
148
+ otp?: string;
149
+ }
150
+ declare function createPlugin(name: string, options?: PluginCreateOptions): Promise<void>;
151
+ declare function buildPlugin(options?: PluginBuildOptions): Promise<void>;
152
+ declare function validatePlugin(options?: PluginValidateOptions): Promise<void>;
153
+ declare function listPluginTemplates(): void;
154
+
155
+ /**
156
+ * @lytjs/cli - Logger utilities
157
+ */
158
+ declare const logger: {
159
+ info(message: string): void;
160
+ success(message: string): void;
161
+ warning(message: string): void;
162
+ error(message: string): void;
163
+ dim(message: string): void;
164
+ bold(message: string): string;
165
+ };
166
+
167
+ /**
168
+ * @lytjs/cli - File system utilities
169
+ */
170
+ /**
171
+ * Ensure directory exists (create if not)
172
+ */
173
+ declare function ensureDir(dir: string): void;
174
+ /**
175
+ * Write a file with content, creating parent directories if needed
176
+ */
177
+ declare function writeFile(filePath: string, content: string): void;
178
+ /**
179
+ * Read a file as string
180
+ */
181
+ declare function readFile(filePath: string): string;
182
+ /**
183
+ * Check if path exists
184
+ */
185
+ declare function exists(path: string): boolean;
186
+
187
+ /**
188
+ * @lytjs/cli - Package manager utilities
189
+ */
190
+ type PackageManager = 'npm' | 'yarn' | 'pnpm';
191
+ /**
192
+ * Detect which package manager to use
193
+ */
194
+ declare function detectPackageManager(cwd?: string): PackageManager;
195
+ /**
196
+ * Get install command for package manager
197
+ */
198
+ declare function getInstallCommand(pm: PackageManager): string;
199
+ /**
200
+ * Get run command for package manager
201
+ */
202
+ declare function getRunCommand(pm: PackageManager, script: string): string;
203
+ /**
204
+ * Get add dependency command
205
+ */
206
+ declare function getAddCommand(pm: PackageManager, dep: string, dev?: boolean): string;
207
+
208
+ export { type BuildOptions, type CliOptions, type CreateOptions, type DevOptions, type GenerateOptions, type PackageJson, type PluginBuildOptions, type PluginCreateOptions, type PluginPublishOptions, type PluginValidateOptions, type TestOptions, add, build, buildPlugin, create, createPlugin, detectPackageManager, dev, ensureDir, exists, generate, getAddCommand, getInstallCommand, getRunCommand, listPluginTemplates, listTemplates, logger, readFile, runCli, test, validatePlugin, writeFile };
@@ -0,0 +1,208 @@
1
+ /**
2
+ * @lytjs/cli - CLI runner
3
+ *
4
+ * Main entry point for the CLI. Parses arguments and routes to commands.
5
+ */
6
+ declare function runCli(rawArgs?: string[]): Promise<void>;
7
+
8
+ /**
9
+ * @lytjs/cli - Type definitions
10
+ */
11
+ interface CliOptions {
12
+ command: string;
13
+ args: string[];
14
+ options: Record<string, unknown>;
15
+ }
16
+ interface CreateOptions {
17
+ template?: string;
18
+ force?: boolean;
19
+ }
20
+ interface DevOptions {
21
+ port?: number;
22
+ host?: string;
23
+ open?: boolean;
24
+ }
25
+ interface BuildOptions {
26
+ outDir?: string;
27
+ ssr?: boolean;
28
+ minify?: boolean;
29
+ }
30
+ interface TestOptions {
31
+ watch?: boolean;
32
+ coverage?: boolean;
33
+ grep?: string;
34
+ }
35
+ interface AddOptions {
36
+ force?: boolean;
37
+ typescript?: boolean;
38
+ scoped?: boolean;
39
+ }
40
+ interface PackageJson {
41
+ name: string;
42
+ version: string;
43
+ dependencies?: Record<string, string>;
44
+ devDependencies?: Record<string, string>;
45
+ scripts?: Record<string, string>;
46
+ }
47
+
48
+ /**
49
+ * @lytjs/cli - create command
50
+ *
51
+ * Creates a new LytJS project from a template.
52
+ */
53
+
54
+ /**
55
+ * Create a new LytJS project
56
+ */
57
+ declare function create(projectName?: string, options?: Partial<CreateOptions>): Promise<void>;
58
+ /**
59
+ * List available templates
60
+ */
61
+ declare function listTemplates(): void;
62
+
63
+ /**
64
+ * @lytjs/cli - dev command
65
+ *
66
+ * Starts the development server.
67
+ */
68
+
69
+ /**
70
+ * Start the development server
71
+ */
72
+ declare function dev(options?: DevOptions): Promise<void>;
73
+
74
+ /**
75
+ * @lytjs/cli - build command
76
+ *
77
+ * Builds the project for production.
78
+ */
79
+
80
+ /**
81
+ * Build the project for production
82
+ */
83
+ declare function build(options?: BuildOptions): Promise<void>;
84
+
85
+ /**
86
+ * @lytjs/cli - test command
87
+ *
88
+ * Runs the test suite.
89
+ */
90
+
91
+ /**
92
+ * Run tests
93
+ */
94
+ declare function test(options?: TestOptions): Promise<void>;
95
+
96
+ /**
97
+ * @lytjs/cli - add command
98
+ *
99
+ * Generate components, pages, and stores.
100
+ */
101
+
102
+ type AddType = 'component' | 'page' | 'store' | 'directive' | 'composable' | 'util' | 'middleware' | 'hook';
103
+ /**
104
+ * Add a component, page, or store
105
+ */
106
+ declare function add(type: AddType, name: string, options?: AddOptions): Promise<void>;
107
+
108
+ /**
109
+ * @lytjs/cli - 代码生成器命令
110
+ *
111
+ * 提供组件、页面、服务等代码生成功能
112
+ */
113
+ interface GenerateOptions {
114
+ type: 'component' | 'page' | 'service' | 'hook' | 'store' | 'layout' | 'middleware';
115
+ name: string;
116
+ path?: string;
117
+ withStyles?: boolean;
118
+ withTest?: boolean;
119
+ withStorybook?: boolean;
120
+ description?: string;
121
+ template?: 'default' | 'sfc' | 'functional';
122
+ language?: 'ts' | 'js';
123
+ }
124
+ declare function generate(options: GenerateOptions): Promise<void>;
125
+
126
+ /**
127
+ * @lytjs/cli - plugin command
128
+ *
129
+ * Plugin development CLI commands: create, build, validate, publish.
130
+ */
131
+ interface PluginCreateOptions {
132
+ template?: string;
133
+ force?: boolean;
134
+ skipInstall?: boolean;
135
+ }
136
+ interface PluginBuildOptions {
137
+ outDir?: string;
138
+ minify?: boolean;
139
+ sourcemap?: boolean;
140
+ }
141
+ interface PluginValidateOptions {
142
+ strict?: boolean;
143
+ warningsAsErrors?: boolean;
144
+ }
145
+ interface PluginPublishOptions {
146
+ registry?: string;
147
+ access?: 'public' | 'restricted';
148
+ otp?: string;
149
+ }
150
+ declare function createPlugin(name: string, options?: PluginCreateOptions): Promise<void>;
151
+ declare function buildPlugin(options?: PluginBuildOptions): Promise<void>;
152
+ declare function validatePlugin(options?: PluginValidateOptions): Promise<void>;
153
+ declare function listPluginTemplates(): void;
154
+
155
+ /**
156
+ * @lytjs/cli - Logger utilities
157
+ */
158
+ declare const logger: {
159
+ info(message: string): void;
160
+ success(message: string): void;
161
+ warning(message: string): void;
162
+ error(message: string): void;
163
+ dim(message: string): void;
164
+ bold(message: string): string;
165
+ };
166
+
167
+ /**
168
+ * @lytjs/cli - File system utilities
169
+ */
170
+ /**
171
+ * Ensure directory exists (create if not)
172
+ */
173
+ declare function ensureDir(dir: string): void;
174
+ /**
175
+ * Write a file with content, creating parent directories if needed
176
+ */
177
+ declare function writeFile(filePath: string, content: string): void;
178
+ /**
179
+ * Read a file as string
180
+ */
181
+ declare function readFile(filePath: string): string;
182
+ /**
183
+ * Check if path exists
184
+ */
185
+ declare function exists(path: string): boolean;
186
+
187
+ /**
188
+ * @lytjs/cli - Package manager utilities
189
+ */
190
+ type PackageManager = 'npm' | 'yarn' | 'pnpm';
191
+ /**
192
+ * Detect which package manager to use
193
+ */
194
+ declare function detectPackageManager(cwd?: string): PackageManager;
195
+ /**
196
+ * Get install command for package manager
197
+ */
198
+ declare function getInstallCommand(pm: PackageManager): string;
199
+ /**
200
+ * Get run command for package manager
201
+ */
202
+ declare function getRunCommand(pm: PackageManager, script: string): string;
203
+ /**
204
+ * Get add dependency command
205
+ */
206
+ declare function getAddCommand(pm: PackageManager, dep: string, dev?: boolean): string;
207
+
208
+ export { type BuildOptions, type CliOptions, type CreateOptions, type DevOptions, type GenerateOptions, type PackageJson, type PluginBuildOptions, type PluginCreateOptions, type PluginPublishOptions, type PluginValidateOptions, type TestOptions, add, build, buildPlugin, create, createPlugin, detectPackageManager, dev, ensureDir, exists, generate, getAddCommand, getInstallCommand, getRunCommand, listPluginTemplates, listTemplates, logger, readFile, runCli, test, validatePlugin, writeFile };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync, readFileSync, mkdirSync, writeFileSync, readdirSync as readdirSync$1 } from 'fs';
2
+ import { existsSync, readFileSync, mkdirSync, writeFileSync, readdirSync } from 'fs';
3
3
  import * as path from 'path';
4
4
  import { join, resolve, dirname } from 'path';
5
5
  import { execSync, spawn } from 'child_process';
@@ -66,7 +66,7 @@ function exists(path2) {
66
66
  }
67
67
  function isEmptyDir(dir) {
68
68
  if (!existsSync(dir)) return true;
69
- const files = readdirSync$1(dir);
69
+ const files = readdirSync(dir);
70
70
  return files.length === 0;
71
71
  }
72
72
  function detectPackageManager(cwd = process.cwd()) {
@@ -2020,10 +2020,10 @@ async function runCli(rawArgs = process.argv.slice(2)) {
2020
2020
  }
2021
2021
  case "generate":
2022
2022
  case "g": {
2023
- const genTypes = ["component", "page", "service", "hook", "store"];
2023
+ const genTypes = ["component", "page", "service", "hook", "store", "layout", "middleware"];
2024
2024
  if (!args[0] || !genTypes.includes(args[0])) {
2025
2025
  logger.error("Usage: lyt generate <type> <name>");
2026
- logger.info("Types: component, page, service, hook, store");
2026
+ logger.info("Types: component, page, service, hook, store, layout, middleware");
2027
2027
  logger.info("Example: lyt generate component Button");
2028
2028
  process.exit(1);
2029
2029
  }