@aiready/core 0.3.1 → 0.3.3

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/dist/index.d.mts CHANGED
@@ -116,4 +116,32 @@ declare function similarityScore(str1: string, str2: string): number;
116
116
  declare function loadConfig(rootDir: string): AIReadyConfig | null;
117
117
  declare function mergeConfigWithDefaults(userConfig: AIReadyConfig | null, defaults: any): any;
118
118
 
119
- export { type AIReadyConfig, type ASTNode, type AnalysisResult, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getFileExtension, isSourceFile, levenshteinDistance, loadConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles, similarityScore };
119
+ /**
120
+ * Common CLI configuration interface
121
+ */
122
+ interface CLIOptions {
123
+ rootDir: string;
124
+ include?: string[];
125
+ exclude?: string[];
126
+ [key: string]: any;
127
+ }
128
+ /**
129
+ * Load and merge configuration with CLI options
130
+ */
131
+ declare function loadMergedConfig<T extends Record<string, any>>(directory: string, defaults: T, cliOptions: Partial<T>): T & {
132
+ rootDir: string;
133
+ };
134
+ /**
135
+ * Handle JSON output for CLI commands
136
+ */
137
+ declare function handleJSONOutput(data: any, outputFile?: string, successMessage?: string): void;
138
+ /**
139
+ * Common error handler for CLI commands
140
+ */
141
+ declare function handleCLIError(error: unknown, commandName: string): never;
142
+ /**
143
+ * Calculate elapsed time and format for display
144
+ */
145
+ declare function getElapsedTime(startTime: number): string;
146
+
147
+ export { type AIReadyConfig, type ASTNode, type AnalysisResult, type CLIOptions, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getElapsedTime, getFileExtension, handleCLIError, handleJSONOutput, isSourceFile, levenshteinDistance, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles, similarityScore };
package/dist/index.d.ts CHANGED
@@ -116,4 +116,32 @@ declare function similarityScore(str1: string, str2: string): number;
116
116
  declare function loadConfig(rootDir: string): AIReadyConfig | null;
117
117
  declare function mergeConfigWithDefaults(userConfig: AIReadyConfig | null, defaults: any): any;
118
118
 
119
- export { type AIReadyConfig, type ASTNode, type AnalysisResult, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getFileExtension, isSourceFile, levenshteinDistance, loadConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles, similarityScore };
119
+ /**
120
+ * Common CLI configuration interface
121
+ */
122
+ interface CLIOptions {
123
+ rootDir: string;
124
+ include?: string[];
125
+ exclude?: string[];
126
+ [key: string]: any;
127
+ }
128
+ /**
129
+ * Load and merge configuration with CLI options
130
+ */
131
+ declare function loadMergedConfig<T extends Record<string, any>>(directory: string, defaults: T, cliOptions: Partial<T>): T & {
132
+ rootDir: string;
133
+ };
134
+ /**
135
+ * Handle JSON output for CLI commands
136
+ */
137
+ declare function handleJSONOutput(data: any, outputFile?: string, successMessage?: string): void;
138
+ /**
139
+ * Common error handler for CLI commands
140
+ */
141
+ declare function handleCLIError(error: unknown, commandName: string): never;
142
+ /**
143
+ * Calculate elapsed time and format for display
144
+ */
145
+ declare function getElapsedTime(startTime: number): string;
146
+
147
+ export { type AIReadyConfig, type ASTNode, type AnalysisResult, type CLIOptions, type Issue, type IssueType, type Location, type Metrics, type Report, type ScanOptions, estimateTokens, extractFunctions, extractImports, getElapsedTime, getFileExtension, handleCLIError, handleJSONOutput, isSourceFile, levenshteinDistance, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles, similarityScore };
package/dist/index.js CHANGED
@@ -23,10 +23,14 @@ __export(index_exports, {
23
23
  estimateTokens: () => estimateTokens,
24
24
  extractFunctions: () => extractFunctions,
25
25
  extractImports: () => extractImports,
26
+ getElapsedTime: () => getElapsedTime,
26
27
  getFileExtension: () => getFileExtension,
28
+ handleCLIError: () => handleCLIError,
29
+ handleJSONOutput: () => handleJSONOutput,
27
30
  isSourceFile: () => isSourceFile,
28
31
  levenshteinDistance: () => levenshteinDistance,
29
32
  loadConfig: () => loadConfig,
33
+ loadMergedConfig: () => loadMergedConfig,
30
34
  mergeConfigWithDefaults: () => mergeConfigWithDefaults,
31
35
  parseCode: () => parseCode,
32
36
  readFileContent: () => readFileContent,
@@ -201,15 +205,47 @@ function mergeConfigWithDefaults(userConfig, defaults) {
201
205
  }
202
206
  return result;
203
207
  }
208
+
209
+ // src/utils/cli-helpers.ts
210
+ var import_fs2 = require("fs");
211
+ function loadMergedConfig(directory, defaults, cliOptions) {
212
+ const config = loadConfig(directory);
213
+ const mergedConfig = mergeConfigWithDefaults(config, defaults);
214
+ const result = {
215
+ ...mergedConfig,
216
+ ...cliOptions,
217
+ rootDir: directory
218
+ };
219
+ return result;
220
+ }
221
+ function handleJSONOutput(data, outputFile, successMessage) {
222
+ if (outputFile) {
223
+ (0, import_fs2.writeFileSync)(outputFile, JSON.stringify(data, null, 2));
224
+ console.log(successMessage || `\u2705 Results saved to ${outputFile}`);
225
+ } else {
226
+ console.log(JSON.stringify(data, null, 2));
227
+ }
228
+ }
229
+ function handleCLIError(error, commandName) {
230
+ console.error(`\u274C ${commandName} failed:`, error);
231
+ process.exit(1);
232
+ }
233
+ function getElapsedTime(startTime) {
234
+ return ((Date.now() - startTime) / 1e3).toFixed(2);
235
+ }
204
236
  // Annotate the CommonJS export names for ESM import in node:
205
237
  0 && (module.exports = {
206
238
  estimateTokens,
207
239
  extractFunctions,
208
240
  extractImports,
241
+ getElapsedTime,
209
242
  getFileExtension,
243
+ handleCLIError,
244
+ handleJSONOutput,
210
245
  isSourceFile,
211
246
  levenshteinDistance,
212
247
  loadConfig,
248
+ loadMergedConfig,
213
249
  mergeConfigWithDefaults,
214
250
  parseCode,
215
251
  readFileContent,
package/dist/index.mjs CHANGED
@@ -171,14 +171,46 @@ function mergeConfigWithDefaults(userConfig, defaults) {
171
171
  }
172
172
  return result;
173
173
  }
174
+
175
+ // src/utils/cli-helpers.ts
176
+ import { writeFileSync } from "fs";
177
+ function loadMergedConfig(directory, defaults, cliOptions) {
178
+ const config = loadConfig(directory);
179
+ const mergedConfig = mergeConfigWithDefaults(config, defaults);
180
+ const result = {
181
+ ...mergedConfig,
182
+ ...cliOptions,
183
+ rootDir: directory
184
+ };
185
+ return result;
186
+ }
187
+ function handleJSONOutput(data, outputFile, successMessage) {
188
+ if (outputFile) {
189
+ writeFileSync(outputFile, JSON.stringify(data, null, 2));
190
+ console.log(successMessage || `\u2705 Results saved to ${outputFile}`);
191
+ } else {
192
+ console.log(JSON.stringify(data, null, 2));
193
+ }
194
+ }
195
+ function handleCLIError(error, commandName) {
196
+ console.error(`\u274C ${commandName} failed:`, error);
197
+ process.exit(1);
198
+ }
199
+ function getElapsedTime(startTime) {
200
+ return ((Date.now() - startTime) / 1e3).toFixed(2);
201
+ }
174
202
  export {
175
203
  estimateTokens,
176
204
  extractFunctions,
177
205
  extractImports,
206
+ getElapsedTime,
178
207
  getFileExtension,
208
+ handleCLIError,
209
+ handleJSONOutput,
179
210
  isSourceFile,
180
211
  levenshteinDistance,
181
212
  loadConfig,
213
+ loadMergedConfig,
182
214
  mergeConfigWithDefaults,
183
215
  parseCode,
184
216
  readFileContent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",