@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/README.md +1 -1
- package/dist/cli/index.cjs +36 -6
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +36 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/{errors-DQerAaXC.d.cts → errors-C4GJaFI_.d.cts} +1 -1
- package/dist/{errors-DQerAaXC.d.ts → errors-C4GJaFI_.d.ts} +1 -1
- package/dist/index.cjs +36 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +36 -6
- package/dist/index.js.map +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/package.json +2 -1
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
|
-
|
|
361
|
-
|
|
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
|
-
|
|
381
|
+
queue.push(defaultExport);
|
|
365
382
|
}
|
|
366
383
|
const namedConfigExport = record.config;
|
|
367
384
|
if (namedConfigExport && typeof namedConfigExport === "object") {
|
|
368
|
-
|
|
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(
|
|
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
|
|
412
|
+
const module = await importConfigModule(`${moduleUrl.href}?cacheBust=${Date.now()}`);
|
|
383
413
|
const rawConfig = extractConfigExport(module);
|
|
384
414
|
return {
|
|
385
415
|
configPath: resolvedPath,
|