@xylex-group/athena 1.6.0 → 1.6.1

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/cli/index.js CHANGED
@@ -329,6 +329,13 @@ function normalizeOutputConfig(output) {
329
329
  }
330
330
  };
331
331
  }
332
+ function isAthenaGeneratorConfig(value) {
333
+ if (!value || typeof value !== "object") {
334
+ return false;
335
+ }
336
+ const record = value;
337
+ return Boolean(record.provider && typeof record.provider === "object") && Boolean(record.output && typeof record.output === "object");
338
+ }
332
339
  function normalizeGeneratorConfig(input) {
333
340
  return {
334
341
  provider: input.provider,
@@ -357,18 +364,41 @@ function findGeneratorConfigPath(cwd = process.cwd()) {
357
364
  return void 0;
358
365
  }
359
366
  function extractConfigExport(module) {
360
- if (module && typeof module === "object") {
361
- const record = module;
367
+ const visited = /* @__PURE__ */ new Set();
368
+ const queue = [module];
369
+ while (queue.length > 0) {
370
+ const current = queue.shift();
371
+ if (!current || typeof current !== "object" || visited.has(current)) {
372
+ continue;
373
+ }
374
+ visited.add(current);
375
+ const record = current;
376
+ if (isAthenaGeneratorConfig(record)) {
377
+ return record;
378
+ }
362
379
  const defaultExport = record.default;
363
380
  if (defaultExport && typeof defaultExport === "object") {
364
- return defaultExport;
381
+ queue.push(defaultExport);
365
382
  }
366
383
  const namedConfigExport = record.config;
367
384
  if (namedConfigExport && typeof namedConfigExport === "object") {
368
- return namedConfigExport;
385
+ queue.push(namedConfigExport);
386
+ }
387
+ const moduleExports = record["module.exports"];
388
+ if (moduleExports && typeof moduleExports === "object") {
389
+ queue.push(moduleExports);
369
390
  }
370
391
  }
371
- throw new Error("Generator config file must export a config object as default export or `config`.");
392
+ throw new Error(
393
+ "Generator config file must export a config object as default export or `config`."
394
+ );
395
+ }
396
+ function importConfigModule(moduleSpecifier) {
397
+ const runtimeImport = new Function(
398
+ "moduleSpecifier",
399
+ "return import(moduleSpecifier)"
400
+ );
401
+ return runtimeImport(moduleSpecifier);
372
402
  }
373
403
  async function loadGeneratorConfig(options = {}) {
374
404
  const cwd = options.cwd ?? process.cwd();
@@ -379,7 +409,7 @@ async function loadGeneratorConfig(options = {}) {
379
409
  );
380
410
  }
381
411
  const moduleUrl = pathToFileURL(resolvedPath);
382
- const module = await import(`${moduleUrl.href}?cacheBust=${Date.now()}`);
412
+ const module = await importConfigModule(`${moduleUrl.href}?cacheBust=${Date.now()}`);
383
413
  const rawConfig = extractConfigExport(module);
384
414
  return {
385
415
  configPath: resolvedPath,