@veloxts/cli 0.7.1 → 0.7.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @veloxts/cli
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - chore(auth,core,create,cli,client,orm,mcp,router,validation,web): simplify code for clarity and maintainability
8
+ - Updated dependencies
9
+ - @veloxts/auth@0.7.2
10
+ - @veloxts/core@0.7.2
11
+ - @veloxts/orm@0.7.2
12
+ - @veloxts/router@0.7.2
13
+ - @veloxts/validation@0.7.2
14
+
3
15
  ## 0.7.1
4
16
 
5
17
  ### Patch Changes
@@ -10,28 +10,33 @@
10
10
  */
11
11
  import { existsSync } from 'node:fs';
12
12
  import { readdir, readFile } from 'node:fs/promises';
13
- import { join, resolve } from 'node:path';
13
+ import { join } from 'node:path';
14
14
  import { discoverProceduresVerbose, getRouteSummary, isDiscoveryError, } from '@veloxts/router';
15
15
  import { Command } from 'commander';
16
- import { config as loadEnv } from 'dotenv';
17
16
  import pc from 'picocolors';
18
17
  import { getErrorsByCategory } from '../errors/index.js';
18
+ import { loadEnvironment } from '../utils/paths.js';
19
19
  import { extractSchemaNames, extractSchemaTypes } from '../utils/schema-patterns.js';
20
20
  // ============================================================================
21
21
  // Constants
22
22
  // ============================================================================
23
23
  /** Default API prefix for REST routes */
24
24
  const DEFAULT_API_PREFIX = '/api';
25
- // ============================================================================
26
- // Helper Functions
27
- // ============================================================================
28
25
  /**
29
- * Load environment variables from .env file if present
26
+ * Get picocolors color function for an HTTP method
30
27
  */
31
- function loadEnvironment() {
32
- const envPath = resolve(process.cwd(), '.env');
33
- if (existsSync(envPath)) {
34
- loadEnv({ path: envPath });
28
+ function getMethodColor(method) {
29
+ switch (method) {
30
+ case 'GET':
31
+ return pc.green;
32
+ case 'POST':
33
+ return pc.yellow;
34
+ case 'PUT':
35
+ return pc.blue;
36
+ case 'PATCH':
37
+ return pc.cyan;
38
+ default:
39
+ return pc.red;
35
40
  }
36
41
  }
37
42
  /**
@@ -139,9 +144,9 @@ function getErrorIntrospection() {
139
144
  for (const prefix of categories) {
140
145
  const categoryErrors = getErrorsByCategory(prefix);
141
146
  const categoryName = categoryNames[prefix] ?? 'Unknown';
142
- for (const [code, def] of Object.entries(categoryErrors)) {
147
+ for (const def of categoryErrors) {
143
148
  errors.push({
144
- code,
149
+ code: def.code,
145
150
  name: def.name,
146
151
  message: def.message,
147
152
  fix: def.fix,
@@ -172,15 +177,7 @@ function printProcedures(procedures) {
172
177
  console.log(pc.bold(pc.cyan(`/${currentNs}`)));
173
178
  }
174
179
  const method = proc.route?.method ?? (proc.type === 'query' ? 'GET' : 'POST');
175
- const methodColor = method === 'GET'
176
- ? pc.green
177
- : method === 'POST'
178
- ? pc.yellow
179
- : method === 'PUT'
180
- ? pc.blue
181
- : method === 'PATCH'
182
- ? pc.cyan
183
- : pc.red;
180
+ const methodColor = getMethodColor(method);
184
181
  const schemas = [];
185
182
  if (proc.hasInput)
186
183
  schemas.push('in');
@@ -226,15 +223,7 @@ function printRoutes(routes) {
226
223
  console.log(pc.bold('REST Routes'));
227
224
  console.log(pc.dim('─'.repeat(60)));
228
225
  for (const route of routes) {
229
- const methodColor = route.method === 'GET'
230
- ? pc.green
231
- : route.method === 'POST'
232
- ? pc.yellow
233
- : route.method === 'PUT'
234
- ? pc.blue
235
- : route.method === 'PATCH'
236
- ? pc.cyan
237
- : pc.red;
226
+ const methodColor = getMethodColor(route.method);
238
227
  console.log(` ${methodColor(route.method.padEnd(7))} ${route.path}`);
239
228
  console.log(pc.dim(` → ${route.namespace}.${route.procedure}`));
240
229
  }
@@ -95,8 +95,7 @@ async function readClaudeConfig(configPath) {
95
95
  return null;
96
96
  }
97
97
  try {
98
- const config = await readJsonFile(configPath);
99
- return config;
98
+ return await readJsonFile(configPath);
100
99
  }
101
100
  catch (err) {
102
101
  throw new Error(`Failed to parse Claude Desktop configuration: ${err instanceof Error ? err.message : String(err)}`);
@@ -301,7 +300,7 @@ async function runMcpInit(options) {
301
300
  process.exit(1);
302
301
  }
303
302
  // Success!
304
- const action = isAlreadyConfigured ? 'updated' : configExists ? 'updated' : 'created';
303
+ const action = configExists ? 'updated' : 'created';
305
304
  const result = {
306
305
  success: true,
307
306
  action,
@@ -11,18 +11,9 @@ import { createServer } from 'node:http';
11
11
  import { dirname, extname, resolve } from 'node:path';
12
12
  import { discoverProceduresVerbose, generateOpenApiSpec, generateSwaggerUIHtml, isDiscoveryError, validateOpenApiSpec, } from '@veloxts/router';
13
13
  import { Command } from 'commander';
14
- import { config as loadEnv } from 'dotenv';
15
14
  import pc from 'picocolors';
16
15
  import YAML from 'yaml';
17
- /**
18
- * Load environment variables from .env file if present
19
- */
20
- function loadEnvironment() {
21
- const envPath = resolve(process.cwd(), '.env');
22
- if (existsSync(envPath)) {
23
- loadEnv({ path: envPath });
24
- }
25
- }
16
+ import { loadEnvironment } from '../utils/paths.js';
26
17
  // ============================================================================
27
18
  // Helper Functions
28
19
  // ============================================================================
@@ -4,21 +4,10 @@
4
4
  * Provides subcommands for managing procedures:
5
5
  * - procedures:list - List all discovered procedures
6
6
  */
7
- import { existsSync } from 'node:fs';
8
- import { resolve } from 'node:path';
9
7
  import { discoverProceduresVerbose, isDiscoveryError, } from '@veloxts/router';
10
8
  import { Command } from 'commander';
11
- import { config as loadEnv } from 'dotenv';
12
9
  import pc from 'picocolors';
13
- /**
14
- * Load environment variables from .env file if present
15
- */
16
- function loadEnvironment() {
17
- const envPath = resolve(process.cwd(), '.env');
18
- if (existsSync(envPath)) {
19
- loadEnv({ path: envPath });
20
- }
21
- }
10
+ import { loadEnvironment } from '../utils/paths.js';
22
11
  // ============================================================================
23
12
  // Helper Functions
24
13
  // ============================================================================
@@ -264,9 +264,6 @@ function generateSuggestion(type, errorText) {
264
264
  if (moduleName.startsWith('.') || moduleName.startsWith('/')) {
265
265
  suggestion = `Check that the file '${moduleName}' exists and the path is correct relative to the importing file.`;
266
266
  }
267
- else if (moduleName.startsWith('@')) {
268
- suggestion = `Install the package: pnpm add ${moduleName}`;
269
- }
270
267
  else {
271
268
  suggestion = `Install the package: pnpm add ${moduleName}`;
272
269
  }
@@ -101,3 +101,7 @@ export declare function writeJsonFile(filePath: string, data: unknown): Promise<
101
101
  * Create a directory recursively
102
102
  */
103
103
  export declare function createDirectory(dirPath: string): void;
104
+ /**
105
+ * Load environment variables from .env file if present
106
+ */
107
+ export declare function loadEnvironment(cwd?: string): void;
@@ -4,6 +4,7 @@
4
4
  import { existsSync, mkdirSync, readdirSync, readFileSync } from 'node:fs';
5
5
  import { readFile, writeFile } from 'node:fs/promises';
6
6
  import path from 'node:path';
7
+ import { config as loadEnv } from 'dotenv';
7
8
  /** Common entry point file names, ordered by preference */
8
9
  const ENTRY_POINT_PATTERNS = [
9
10
  'src/index.ts',
@@ -252,8 +253,7 @@ export async function isVeloxProject(cwd = process.cwd()) {
252
253
  return false;
253
254
  }
254
255
  try {
255
- const fs = await import('node:fs/promises');
256
- const content = await fs.readFile(packageJsonPath, 'utf-8');
256
+ const content = await readFile(packageJsonPath, 'utf-8');
257
257
  const pkg = JSON.parse(content);
258
258
  // Check if any @veloxts packages are in dependencies
259
259
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
@@ -289,8 +289,7 @@ export async function detectProjectType(cwd = process.cwd()) {
289
289
  return result;
290
290
  }
291
291
  try {
292
- const fs = await import('node:fs/promises');
293
- const content = await fs.readFile(packageJsonPath, 'utf-8');
292
+ const content = await readFile(packageJsonPath, 'utf-8');
294
293
  const pkg = JSON.parse(content);
295
294
  // Collect all dependencies
296
295
  result.dependencies = { ...pkg.dependencies, ...pkg.devDependencies };
@@ -328,3 +327,12 @@ export async function writeJsonFile(filePath, data) {
328
327
  export function createDirectory(dirPath) {
329
328
  mkdirSync(dirPath, { recursive: true });
330
329
  }
330
+ /**
331
+ * Load environment variables from .env file if present
332
+ */
333
+ export function loadEnvironment(cwd = process.cwd()) {
334
+ const envPath = path.resolve(cwd, '.env');
335
+ if (existsSync(envPath)) {
336
+ loadEnv({ path: envPath });
337
+ }
338
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/cli",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Developer tooling and CLI commands for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -41,11 +41,11 @@
41
41
  "pluralize": "8.0.0",
42
42
  "tsx": "4.21.0",
43
43
  "yaml": "2.8.2",
44
- "@veloxts/core": "0.7.1",
45
- "@veloxts/router": "0.7.1",
46
- "@veloxts/validation": "0.7.1",
47
- "@veloxts/orm": "0.7.1",
48
- "@veloxts/auth": "0.7.1"
44
+ "@veloxts/core": "0.7.2",
45
+ "@veloxts/auth": "0.7.2",
46
+ "@veloxts/orm": "0.7.2",
47
+ "@veloxts/router": "0.7.2",
48
+ "@veloxts/validation": "0.7.2"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@prisma/client": ">=7.0.0"