@aiready/core 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/dist/index.d.mts CHANGED
@@ -146,7 +146,7 @@ declare function extractImports(ast: ASTNode): string[];
146
146
  */
147
147
  declare function estimateTokens(text: string): number;
148
148
 
149
- declare function loadConfig(rootDir: string): AIReadyConfig | null;
149
+ declare function loadConfig(rootDir: string): Promise<AIReadyConfig | null>;
150
150
  declare function mergeConfigWithDefaults(userConfig: AIReadyConfig | null, defaults: any): any;
151
151
 
152
152
  /**
@@ -170,9 +170,9 @@ declare function resolveOutputPath(userPath: string | undefined, defaultFilename
170
170
  /**
171
171
  * Load and merge configuration with CLI options
172
172
  */
173
- declare function loadMergedConfig<T extends Record<string, any>>(directory: string, defaults: T, cliOptions: Partial<T>): T & {
173
+ declare function loadMergedConfig<T extends Record<string, any>>(directory: string, defaults: T, cliOptions: Partial<T>): Promise<T & {
174
174
  rootDir: string;
175
- };
175
+ }>;
176
176
  /**
177
177
  * Handle JSON output for CLI commands
178
178
  */
package/dist/index.d.ts CHANGED
@@ -146,7 +146,7 @@ declare function extractImports(ast: ASTNode): string[];
146
146
  */
147
147
  declare function estimateTokens(text: string): number;
148
148
 
149
- declare function loadConfig(rootDir: string): AIReadyConfig | null;
149
+ declare function loadConfig(rootDir: string): Promise<AIReadyConfig | null>;
150
150
  declare function mergeConfigWithDefaults(userConfig: AIReadyConfig | null, defaults: any): any;
151
151
 
152
152
  /**
@@ -170,9 +170,9 @@ declare function resolveOutputPath(userPath: string | undefined, defaultFilename
170
170
  /**
171
171
  * Load and merge configuration with CLI options
172
172
  */
173
- declare function loadMergedConfig<T extends Record<string, any>>(directory: string, defaults: T, cliOptions: Partial<T>): T & {
173
+ declare function loadMergedConfig<T extends Record<string, any>>(directory: string, defaults: T, cliOptions: Partial<T>): Promise<T & {
174
174
  rootDir: string;
175
- };
175
+ }>;
176
176
  /**
177
177
  * Handle JSON output for CLI commands
178
178
  */
package/dist/index.js CHANGED
@@ -291,6 +291,7 @@ function estimateTokens(text) {
291
291
  // src/utils/config.ts
292
292
  var import_fs = require("fs");
293
293
  var import_path = require("path");
294
+ var import_url = require("url");
294
295
  var CONFIG_FILES = [
295
296
  "aiready.json",
296
297
  "aiready.config.json",
@@ -299,7 +300,7 @@ var CONFIG_FILES = [
299
300
  "aiready.config.js",
300
301
  ".aireadyrc.js"
301
302
  ];
302
- function loadConfig(rootDir) {
303
+ async function loadConfig(rootDir) {
303
304
  let currentDir = (0, import_path.resolve)(rootDir);
304
305
  while (true) {
305
306
  for (const configFile of CONFIG_FILES) {
@@ -308,8 +309,9 @@ function loadConfig(rootDir) {
308
309
  try {
309
310
  let config;
310
311
  if (configFile.endsWith(".js")) {
311
- delete require.cache[require.resolve(configPath)];
312
- config = require(configPath);
312
+ const fileUrl = (0, import_url.pathToFileURL)(configPath).href;
313
+ const module2 = await import(`${fileUrl}?t=${Date.now()}`);
314
+ config = module2.default || module2;
313
315
  } else {
314
316
  const content = (0, import_fs.readFileSync)(configPath, "utf-8");
315
317
  config = JSON.parse(content);
@@ -319,7 +321,8 @@ function loadConfig(rootDir) {
319
321
  }
320
322
  return config;
321
323
  } catch (error) {
322
- throw new Error(`Failed to load config from ${configPath}: ${error}`);
324
+ const errorMessage = error instanceof Error ? error.message : String(error);
325
+ throw new Error(`Failed to load config from ${configPath}: ${errorMessage}`);
323
326
  }
324
327
  }
325
328
  }
@@ -371,8 +374,8 @@ function resolveOutputPath(userPath, defaultFilename, workingDir = process.cwd()
371
374
  }
372
375
  return outputPath;
373
376
  }
374
- function loadMergedConfig(directory, defaults, cliOptions) {
375
- const config = loadConfig(directory);
377
+ async function loadMergedConfig(directory, defaults, cliOptions) {
378
+ const config = await loadConfig(directory);
376
379
  const mergedConfig = mergeConfigWithDefaults(config, defaults);
377
380
  const result = {
378
381
  ...mergedConfig,
package/dist/index.mjs CHANGED
@@ -1,10 +1,3 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // src/utils/file-scanner.ts
9
2
  import { glob } from "glob";
10
3
  import { readFile } from "fs/promises";
@@ -255,6 +248,7 @@ function estimateTokens(text) {
255
248
  // src/utils/config.ts
256
249
  import { readFileSync, existsSync } from "fs";
257
250
  import { join, resolve, dirname } from "path";
251
+ import { pathToFileURL } from "url";
258
252
  var CONFIG_FILES = [
259
253
  "aiready.json",
260
254
  "aiready.config.json",
@@ -263,7 +257,7 @@ var CONFIG_FILES = [
263
257
  "aiready.config.js",
264
258
  ".aireadyrc.js"
265
259
  ];
266
- function loadConfig(rootDir) {
260
+ async function loadConfig(rootDir) {
267
261
  let currentDir = resolve(rootDir);
268
262
  while (true) {
269
263
  for (const configFile of CONFIG_FILES) {
@@ -272,8 +266,9 @@ function loadConfig(rootDir) {
272
266
  try {
273
267
  let config;
274
268
  if (configFile.endsWith(".js")) {
275
- delete __require.cache[__require.resolve(configPath)];
276
- config = __require(configPath);
269
+ const fileUrl = pathToFileURL(configPath).href;
270
+ const module = await import(`${fileUrl}?t=${Date.now()}`);
271
+ config = module.default || module;
277
272
  } else {
278
273
  const content = readFileSync(configPath, "utf-8");
279
274
  config = JSON.parse(content);
@@ -283,7 +278,8 @@ function loadConfig(rootDir) {
283
278
  }
284
279
  return config;
285
280
  } catch (error) {
286
- throw new Error(`Failed to load config from ${configPath}: ${error}`);
281
+ const errorMessage = error instanceof Error ? error.message : String(error);
282
+ throw new Error(`Failed to load config from ${configPath}: ${errorMessage}`);
287
283
  }
288
284
  }
289
285
  }
@@ -335,8 +331,8 @@ function resolveOutputPath(userPath, defaultFilename, workingDir = process.cwd()
335
331
  }
336
332
  return outputPath;
337
333
  }
338
- function loadMergedConfig(directory, defaults, cliOptions) {
339
- const config = loadConfig(directory);
334
+ async function loadMergedConfig(directory, defaults, cliOptions) {
335
+ const config = await loadConfig(directory);
340
336
  const mergedConfig = mergeConfigWithDefaults(config, defaults);
341
337
  const result = {
342
338
  ...mergedConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/core",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Shared utilities for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",