@aiready/core 0.5.2 → 0.5.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,6 +116,14 @@ interface CLIOptions {
116
116
  exclude?: string[];
117
117
  [key: string]: any;
118
118
  }
119
+ /**
120
+ * Resolve output file path, defaulting to .aiready directory
121
+ * @param userPath - User-provided output path (optional)
122
+ * @param defaultFilename - Default filename to use
123
+ * @param workingDir - Working directory (default: process.cwd())
124
+ * @returns Resolved absolute path
125
+ */
126
+ declare function resolveOutputPath(userPath: string | undefined, defaultFilename: string, workingDir?: string): string;
119
127
  /**
120
128
  * Load and merge configuration with CLI options
121
129
  */
@@ -135,4 +143,4 @@ declare function handleCLIError(error: unknown, commandName: string): never;
135
143
  */
136
144
  declare function getElapsedTime(startTime: number): string;
137
145
 
138
- 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, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles };
146
+ 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, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, readFileContent, resolveOutputPath, scanFiles };
package/dist/index.d.ts CHANGED
@@ -116,6 +116,14 @@ interface CLIOptions {
116
116
  exclude?: string[];
117
117
  [key: string]: any;
118
118
  }
119
+ /**
120
+ * Resolve output file path, defaulting to .aiready directory
121
+ * @param userPath - User-provided output path (optional)
122
+ * @param defaultFilename - Default filename to use
123
+ * @param workingDir - Working directory (default: process.cwd())
124
+ * @returns Resolved absolute path
125
+ */
126
+ declare function resolveOutputPath(userPath: string | undefined, defaultFilename: string, workingDir?: string): string;
119
127
  /**
120
128
  * Load and merge configuration with CLI options
121
129
  */
@@ -135,4 +143,4 @@ declare function handleCLIError(error: unknown, commandName: string): never;
135
143
  */
136
144
  declare function getElapsedTime(startTime: number): string;
137
145
 
138
- 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, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, readFileContent, scanFiles };
146
+ 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, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, readFileContent, resolveOutputPath, scanFiles };
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  mergeConfigWithDefaults: () => mergeConfigWithDefaults,
34
34
  parseCode: () => parseCode,
35
35
  readFileContent: () => readFileContent,
36
+ resolveOutputPath: () => resolveOutputPath,
36
37
  scanFiles: () => scanFiles
37
38
  });
38
39
  module.exports = __toCommonJS(index_exports);
@@ -188,6 +189,17 @@ function mergeConfigWithDefaults(userConfig, defaults) {
188
189
 
189
190
  // src/utils/cli-helpers.ts
190
191
  var import_fs2 = require("fs");
192
+ var import_path2 = require("path");
193
+ function resolveOutputPath(userPath, defaultFilename, workingDir = process.cwd()) {
194
+ if (userPath) {
195
+ return userPath;
196
+ }
197
+ const aireadyDir = (0, import_path2.join)(workingDir, ".aiready");
198
+ if (!(0, import_fs2.existsSync)(aireadyDir)) {
199
+ (0, import_fs2.mkdirSync)(aireadyDir, { recursive: true });
200
+ }
201
+ return (0, import_path2.join)(aireadyDir, defaultFilename);
202
+ }
191
203
  function loadMergedConfig(directory, defaults, cliOptions) {
192
204
  const config = loadConfig(directory);
193
205
  const mergedConfig = mergeConfigWithDefaults(config, defaults);
@@ -200,6 +212,10 @@ function loadMergedConfig(directory, defaults, cliOptions) {
200
212
  }
201
213
  function handleJSONOutput(data, outputFile, successMessage) {
202
214
  if (outputFile) {
215
+ const dir = (0, import_path2.dirname)(outputFile);
216
+ if (!(0, import_fs2.existsSync)(dir)) {
217
+ (0, import_fs2.mkdirSync)(dir, { recursive: true });
218
+ }
203
219
  (0, import_fs2.writeFileSync)(outputFile, JSON.stringify(data, null, 2));
204
220
  console.log(successMessage || `\u2705 Results saved to ${outputFile}`);
205
221
  } else {
@@ -228,5 +244,6 @@ function getElapsedTime(startTime) {
228
244
  mergeConfigWithDefaults,
229
245
  parseCode,
230
246
  readFileContent,
247
+ resolveOutputPath,
231
248
  scanFiles
232
249
  });
package/dist/index.mjs CHANGED
@@ -155,7 +155,18 @@ function mergeConfigWithDefaults(userConfig, defaults) {
155
155
  }
156
156
 
157
157
  // src/utils/cli-helpers.ts
158
- import { writeFileSync } from "fs";
158
+ import { writeFileSync, mkdirSync, existsSync as existsSync2 } from "fs";
159
+ import { join as join2, dirname as dirname2 } from "path";
160
+ function resolveOutputPath(userPath, defaultFilename, workingDir = process.cwd()) {
161
+ if (userPath) {
162
+ return userPath;
163
+ }
164
+ const aireadyDir = join2(workingDir, ".aiready");
165
+ if (!existsSync2(aireadyDir)) {
166
+ mkdirSync(aireadyDir, { recursive: true });
167
+ }
168
+ return join2(aireadyDir, defaultFilename);
169
+ }
159
170
  function loadMergedConfig(directory, defaults, cliOptions) {
160
171
  const config = loadConfig(directory);
161
172
  const mergedConfig = mergeConfigWithDefaults(config, defaults);
@@ -168,6 +179,10 @@ function loadMergedConfig(directory, defaults, cliOptions) {
168
179
  }
169
180
  function handleJSONOutput(data, outputFile, successMessage) {
170
181
  if (outputFile) {
182
+ const dir = dirname2(outputFile);
183
+ if (!existsSync2(dir)) {
184
+ mkdirSync(dir, { recursive: true });
185
+ }
171
186
  writeFileSync(outputFile, JSON.stringify(data, null, 2));
172
187
  console.log(successMessage || `\u2705 Results saved to ${outputFile}`);
173
188
  } else {
@@ -195,5 +210,6 @@ export {
195
210
  mergeConfigWithDefaults,
196
211
  parseCode,
197
212
  readFileContent,
213
+ resolveOutputPath,
198
214
  scanFiles
199
215
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",