@open-mercato/cli 0.10.1-develop.7983.1.fd91207efe → 0.10.1-develop.7994.1.c9f31972aa
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/.turbo/turbo-build.log +1 -1
- package/dist/agentic/guides/module-facts.json +162 -162
- package/dist/agentic/guides/module-facts.v2.json +162 -162
- package/dist/agentic/guides/module-tool.md +21 -0
- package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
- package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
- package/dist/agentic/guides/modules/api_docs/index.md +1 -1
- package/dist/agentic/guides/modules/api_keys/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/index.md +1 -1
- package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
- package/dist/agentic/guides/modules/auth/index.md +1 -1
- package/dist/agentic/guides/modules/availability/index.md +1 -1
- package/dist/agentic/guides/modules/business_rules/index.md +1 -1
- package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
- package/dist/agentic/guides/modules/cart/index.md +1 -1
- package/dist/agentic/guides/modules/catalog/index.md +1 -1
- package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
- package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
- package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
- package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
- package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
- package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
- package/dist/agentic/guides/modules/configs/index.md +1 -1
- package/dist/agentic/guides/modules/content/index.md +1 -1
- package/dist/agentic/guides/modules/currencies/index.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
- package/dist/agentic/guides/modules/customers/index.md +1 -1
- package/dist/agentic/guides/modules/dashboards/index.md +1 -1
- package/dist/agentic/guides/modules/data_sync/index.md +1 -1
- package/dist/agentic/guides/modules/design_system/index.md +1 -1
- package/dist/agentic/guides/modules/devices/index.md +1 -1
- package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
- package/dist/agentic/guides/modules/directory/index.md +1 -1
- package/dist/agentic/guides/modules/documents/index.md +1 -1
- package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
- package/dist/agentic/guides/modules/entities/index.md +1 -1
- package/dist/agentic/guides/modules/eudr/index.md +1 -1
- package/dist/agentic/guides/modules/events/index.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
- package/dist/agentic/guides/modules/forms/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
- package/dist/agentic/guides/modules/generators/index.md +1 -1
- package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
- package/dist/agentic/guides/modules/integrations/index.md +1 -1
- package/dist/agentic/guides/modules/messages/index.md +1 -1
- package/dist/agentic/guides/modules/notifications/index.md +1 -1
- package/dist/agentic/guides/modules/onboarding/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
- package/dist/agentic/guides/modules/perspectives/index.md +1 -1
- package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
- package/dist/agentic/guides/modules/planner/index.md +1 -1
- package/dist/agentic/guides/modules/portal/index.md +1 -1
- package/dist/agentic/guides/modules/progress/index.md +1 -1
- package/dist/agentic/guides/modules/promotions/index.md +1 -1
- package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
- package/dist/agentic/guides/modules/query_index/index.md +1 -1
- package/dist/agentic/guides/modules/record_locks/index.md +1 -1
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/sales/index.md +1 -1
- package/dist/agentic/guides/modules/scheduler/index.md +1 -1
- package/dist/agentic/guides/modules/search/index.md +1 -1
- package/dist/agentic/guides/modules/security/index.md +1 -1
- package/dist/agentic/guides/modules/seeds/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/index.md +1 -1
- package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
- package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
- package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
- package/dist/agentic/guides/modules/telemetry/index.md +1 -1
- package/dist/agentic/guides/modules/tillio/index.md +1 -1
- package/dist/agentic/guides/modules/translations/index.md +1 -1
- package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
- package/dist/agentic/guides/modules/webhooks/index.md +1 -1
- package/dist/agentic/guides/modules/wms/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/reference-module-facts.json +1 -1
- package/dist/agentic/guides/upstream/manifest.json +1 -1
- package/dist/agentic/shared/ai/harness/cases.json +23 -9
- package/dist/agentic/shared/ai/harness/source-link-inventory.json +90 -4
- package/dist/lib/__integration__/TC-INT-007.spec.js +207 -19
- package/dist/lib/__integration__/TC-INT-007.spec.js.map +2 -2
- package/dist/lib/__integration__/TC-INT-009.spec.js +267 -0
- package/dist/lib/__integration__/TC-INT-009.spec.js.map +7 -0
- package/dist/lib/eject.js +25 -9
- package/dist/lib/eject.js.map +2 -2
- package/dist/lib/generators/entity-ids.js +2 -0
- package/dist/lib/generators/entity-ids.js.map +2 -2
- package/dist/lib/generators/module-di.js +2 -0
- package/dist/lib/generators/module-di.js.map +2 -2
- package/dist/lib/generators/module-entities.js +2 -0
- package/dist/lib/generators/module-entities.js.map +2 -2
- package/dist/lib/generators/module-package-sources.js +6 -4
- package/dist/lib/generators/module-package-sources.js.map +2 -2
- package/dist/lib/generators/module-registry.js +32 -86
- package/dist/lib/generators/module-registry.js.map +2 -2
- package/dist/lib/generators/openapi.js +2 -0
- package/dist/lib/generators/openapi.js.map +2 -2
- package/dist/lib/generators/source-exports.js +73 -0
- package/dist/lib/generators/source-exports.js.map +7 -0
- package/dist/lib/init-summary.js +44 -0
- package/dist/lib/init-summary.js.map +7 -0
- package/dist/lib/module-github.js +98 -0
- package/dist/lib/module-github.js.map +7 -0
- package/dist/lib/module-identity.js +131 -0
- package/dist/lib/module-identity.js.map +7 -0
- package/dist/lib/module-inspection.js +124 -0
- package/dist/lib/module-inspection.js.map +7 -0
- package/dist/lib/module-install.js +150 -21
- package/dist/lib/module-install.js.map +3 -3
- package/dist/lib/module-package.js +205 -15
- package/dist/lib/module-package.js.map +2 -2
- package/dist/lib/modules-config.js +69 -30
- package/dist/lib/modules-config.js.map +2 -2
- package/dist/lib/resolver.js +33 -34
- package/dist/lib/resolver.js.map +2 -2
- package/dist/mercato.js +14 -23
- package/dist/mercato.js.map +2 -2
- package/package.json +7 -7
- package/src/__tests__/mercato.test.ts +14 -4
- package/src/lib/__fixtures__/official-module-package/dist/modules/test_package/widgets/injection/test/widget.js +1 -0
- package/src/lib/__integration__/TC-INT-007.spec.ts +219 -19
- package/src/lib/__integration__/TC-INT-009.spec.ts +279 -0
- package/src/lib/__tests__/eject.test.ts +98 -4
- package/src/lib/__tests__/init-summary.test.ts +50 -0
- package/src/lib/__tests__/module-github.test.ts +108 -0
- package/src/lib/__tests__/module-identity.test.ts +144 -0
- package/src/lib/__tests__/module-inspection.test.ts +195 -0
- package/src/lib/__tests__/module-install.test.ts +399 -10
- package/src/lib/__tests__/module-package.test.ts +154 -0
- package/src/lib/__tests__/modules-config.test.ts +55 -0
- package/src/lib/__tests__/resolver.packages.test.ts +29 -0
- package/src/lib/eject.ts +28 -10
- package/src/lib/generators/__tests__/module-id-collisions.test.ts +146 -0
- package/src/lib/generators/__tests__/module-package-sources.test.ts +19 -2
- package/src/lib/generators/__tests__/module-requirements.test.ts +56 -0
- package/src/lib/generators/entity-ids.ts +2 -0
- package/src/lib/generators/module-di.ts +2 -0
- package/src/lib/generators/module-entities.ts +2 -0
- package/src/lib/generators/module-package-sources.ts +7 -5
- package/src/lib/generators/module-registry.ts +33 -115
- package/src/lib/generators/openapi.ts +3 -0
- package/src/lib/generators/source-exports.ts +93 -0
- package/src/lib/init-summary.ts +54 -0
- package/src/lib/module-github.ts +109 -0
- package/src/lib/module-identity.ts +145 -0
- package/src/lib/module-inspection.ts +133 -0
- package/src/lib/module-install.ts +170 -22
- package/src/lib/module-package.ts +243 -16
- package/src/lib/modules-config.ts +80 -32
- package/src/lib/resolver.ts +35 -39
- package/src/mercato.ts +14 -24
- package/src/types/cross-spawn.d.ts +2 -2
|
@@ -4,11 +4,19 @@ import { parseBooleanWithDefault } from "@open-mercato/shared/lib/boolean";
|
|
|
4
4
|
function parseModuleEntryFromObjectLiteral(node) {
|
|
5
5
|
let id = null;
|
|
6
6
|
let from = null;
|
|
7
|
+
let locator;
|
|
8
|
+
let packageName;
|
|
7
9
|
for (const property of node.properties) {
|
|
8
|
-
if (!ts.isPropertyAssignment(property) || !ts.isIdentifier(property.name)) continue;
|
|
10
|
+
if (!ts.isPropertyAssignment(property) || !ts.isIdentifier(property.name) && !ts.isStringLiteralLike(property.name)) continue;
|
|
9
11
|
if (property.name.text === "id" && ts.isStringLiteralLike(property.initializer)) {
|
|
10
12
|
id = property.initializer.text;
|
|
11
13
|
}
|
|
14
|
+
if (property.name.text === "packageName" && ts.isStringLiteralLike(property.initializer)) {
|
|
15
|
+
packageName = property.initializer.text;
|
|
16
|
+
}
|
|
17
|
+
if (property.name.text === "locator" && ts.isStringLiteralLike(property.initializer)) {
|
|
18
|
+
locator = property.initializer.text;
|
|
19
|
+
}
|
|
12
20
|
if (property.name.text === "from" && ts.isStringLiteralLike(property.initializer)) {
|
|
13
21
|
from = property.initializer.text;
|
|
14
22
|
}
|
|
@@ -16,7 +24,9 @@ function parseModuleEntryFromObjectLiteral(node) {
|
|
|
16
24
|
if (!id) return null;
|
|
17
25
|
return {
|
|
18
26
|
id,
|
|
19
|
-
from: from ?? "@open-mercato/core"
|
|
27
|
+
from: from ?? "@open-mercato/core",
|
|
28
|
+
...locator ? { locator } : {},
|
|
29
|
+
...packageName ? { packageName } : {}
|
|
20
30
|
};
|
|
21
31
|
}
|
|
22
32
|
function readProcessEnvName(node) {
|
|
@@ -233,7 +243,9 @@ function parseModuleConfigShape(source, env = process.env) {
|
|
|
233
243
|
function normalizeModuleEntry(entry) {
|
|
234
244
|
return {
|
|
235
245
|
id: entry.id,
|
|
236
|
-
from: entry.from ?? "@open-mercato/core"
|
|
246
|
+
from: entry.from ?? "@open-mercato/core",
|
|
247
|
+
...entry.locator ? { locator: entry.locator } : {},
|
|
248
|
+
...entry.packageName ? { packageName: entry.packageName } : {}
|
|
237
249
|
};
|
|
238
250
|
}
|
|
239
251
|
function escapeSingleQuotedString(value) {
|
|
@@ -241,7 +253,7 @@ function escapeSingleQuotedString(value) {
|
|
|
241
253
|
}
|
|
242
254
|
function buildModuleEntryLiteral(entry) {
|
|
243
255
|
const normalized = normalizeModuleEntry(entry);
|
|
244
|
-
return `{ id: '${escapeSingleQuotedString(normalized.id)}', from: '${escapeSingleQuotedString(normalized.from ?? "@open-mercato/core")}' }`;
|
|
256
|
+
return `{ id: '${escapeSingleQuotedString(normalized.id)}', from: '${escapeSingleQuotedString(normalized.from ?? "@open-mercato/core")}'${normalized.locator ? `, locator: '${escapeSingleQuotedString(normalized.locator)}'` : ""}${normalized.packageName ? `, packageName: '${escapeSingleQuotedString(normalized.packageName)}'` : ""} }`;
|
|
245
257
|
}
|
|
246
258
|
function lineIndentAt(source, position) {
|
|
247
259
|
const lineStart = source.lastIndexOf("\n", Math.max(0, position - 1)) + 1;
|
|
@@ -289,14 +301,29 @@ function insertArrayElement(source, arrayNode, entry, sourceFile) {
|
|
|
289
301
|
const tail = closesOnSameLine ? source.slice(closingBracket) : source.slice(insertAt);
|
|
290
302
|
return head + insertion + closingLine + tail;
|
|
291
303
|
}
|
|
292
|
-
function
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
304
|
+
function upsertModuleProperty(objectLiteral, propertyName, value) {
|
|
305
|
+
const prefix = "const entry = ";
|
|
306
|
+
const sourceFile = ts.createSourceFile("entry.ts", prefix + objectLiteral, ts.ScriptTarget.Latest, true);
|
|
307
|
+
const statement = sourceFile.statements[0];
|
|
308
|
+
const initializer = ts.isVariableStatement(statement) ? statement.declarationList.declarations[0]?.initializer : void 0;
|
|
309
|
+
if (!initializer || !ts.isObjectLiteralExpression(initializer)) {
|
|
310
|
+
throw new Error("Cannot update module registration: expected an object literal.");
|
|
311
|
+
}
|
|
312
|
+
const property = initializer.properties.find(
|
|
313
|
+
(candidate) => "name" in candidate && candidate.name && (ts.isIdentifier(candidate.name) || ts.isStringLiteralLike(candidate.name)) && candidate.name.text === propertyName
|
|
314
|
+
);
|
|
315
|
+
const quotedValue = `'${escapeSingleQuotedString(value)}'`;
|
|
316
|
+
if (property) {
|
|
317
|
+
const target = ts.isPropertyAssignment(property) ? property.initializer : property;
|
|
318
|
+
const existingQuote = ts.isPropertyAssignment(property) ? property.initializer.getText(sourceFile)[0] : void 0;
|
|
319
|
+
const replacementValue = existingQuote === '"' ? JSON.stringify(value) : quotedValue;
|
|
320
|
+
const replacement = ts.isPropertyAssignment(property) ? replacementValue : `${propertyName}: ${replacementValue}`;
|
|
321
|
+
return objectLiteral.slice(0, target.getStart(sourceFile) - prefix.length) + replacement + objectLiteral.slice(target.end - prefix.length);
|
|
322
|
+
}
|
|
323
|
+
const lastProperty = initializer.properties[initializer.properties.length - 1];
|
|
324
|
+
const insertPosition = lastProperty ? lastProperty.end - prefix.length : initializer.end - prefix.length - 1;
|
|
325
|
+
const separator = lastProperty ? ", " : " ";
|
|
326
|
+
return objectLiteral.slice(0, insertPosition) + `${separator}${propertyName}: ${quotedValue}` + objectLiteral.slice(insertPosition);
|
|
300
327
|
}
|
|
301
328
|
function readEnabledModules(modulesPath, env = process.env) {
|
|
302
329
|
const source = fs.readFileSync(modulesPath, "utf8");
|
|
@@ -335,6 +362,11 @@ function ensureModuleRegistration(modulesPath, entry) {
|
|
|
335
362
|
throw new Error(`modules.ts not found at ${modulesPath}`);
|
|
336
363
|
}
|
|
337
364
|
const source = fs.readFileSync(modulesPath, "utf8");
|
|
365
|
+
const result = prepareModuleRegistration(source, entry, modulesPath);
|
|
366
|
+
if (result.changed) fs.writeFileSync(modulesPath, result.source);
|
|
367
|
+
return { changed: result.changed, registeredAs: result.registeredAs };
|
|
368
|
+
}
|
|
369
|
+
function prepareModuleRegistration(source, entry, modulesPath = "src/modules.ts") {
|
|
338
370
|
const sourceFile = ts.createSourceFile("modules.ts", source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
339
371
|
const config = parseModuleConfigShape(source);
|
|
340
372
|
const normalized = normalizeModuleEntry(entry);
|
|
@@ -344,55 +376,62 @@ function ensureModuleRegistration(modulesPath, entry) {
|
|
|
344
376
|
throw buildModuleGatedOffError(normalized.id, modulesPath, allMatches);
|
|
345
377
|
}
|
|
346
378
|
if (matches.length > 1) {
|
|
347
|
-
throw new Error(
|
|
348
|
-
`Module "${normalized.id}" is registered multiple times in ${modulesPath}. Resolve duplicates manually before running this command.`
|
|
349
|
-
);
|
|
379
|
+
throw new Error(`Module "${normalized.id}" is registered multiple times in src/modules.ts. Resolve duplicates manually before running this command.`);
|
|
350
380
|
}
|
|
351
381
|
if (matches.length === 1) {
|
|
352
382
|
const existing = normalizeModuleEntry(matches[0].entry);
|
|
353
383
|
if (existing.from === normalized.from) {
|
|
354
|
-
return { changed: false, registeredAs: normalized.from ?? "@open-mercato/core" };
|
|
384
|
+
return { source, changed: false, registeredAs: normalized.from ?? "@open-mercato/core" };
|
|
355
385
|
}
|
|
356
|
-
throw new Error(
|
|
357
|
-
`Module "${normalized.id}" is already registered from "${existing.from}". Remove or eject the existing registration first.`
|
|
358
|
-
);
|
|
386
|
+
throw new Error(`Module "${normalized.id}" is already registered from "${existing.from}". Remove or eject the existing registration first.`);
|
|
359
387
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
388
|
+
return {
|
|
389
|
+
source: insertArrayElement(source, config.arrayNode, normalized, sourceFile),
|
|
390
|
+
changed: true,
|
|
391
|
+
registeredAs: normalized.from ?? "@open-mercato/core"
|
|
392
|
+
};
|
|
363
393
|
}
|
|
364
|
-
function setModuleRegistrationSource(modulesPath, moduleId, from) {
|
|
394
|
+
function setModuleRegistrationSource(modulesPath, moduleId, from, provenance) {
|
|
365
395
|
if (!fs.existsSync(modulesPath)) {
|
|
366
396
|
throw new Error(`modules.ts not found at ${modulesPath}`);
|
|
367
397
|
}
|
|
368
398
|
const source = fs.readFileSync(modulesPath, "utf8");
|
|
399
|
+
const updated = prepareModuleRegistrationSource(source, moduleId, from, provenance);
|
|
400
|
+
if (updated === source) return { changed: false };
|
|
401
|
+
fs.writeFileSync(modulesPath, updated);
|
|
402
|
+
return { changed: true };
|
|
403
|
+
}
|
|
404
|
+
function prepareModuleRegistrationSource(source, moduleId, from, provenance) {
|
|
369
405
|
const config = parseModuleConfigShape(source);
|
|
370
406
|
const matches = config.occurrences.filter((occurrence) => occurrence.active && occurrence.entry.id === moduleId);
|
|
371
407
|
if (matches.length === 0) {
|
|
372
408
|
throw new Error(
|
|
373
|
-
`Could not find module entry for "${moduleId}" in
|
|
409
|
+
`Could not find module entry for "${moduleId}" in src/modules.ts. Expected a pattern like: { id: '${moduleId}', from: '...' } or { id: '${moduleId}' }`
|
|
374
410
|
);
|
|
375
411
|
}
|
|
376
412
|
if (matches.length > 1) {
|
|
377
413
|
throw new Error(
|
|
378
|
-
`Module "${moduleId}" is registered multiple times in
|
|
414
|
+
`Module "${moduleId}" is registered multiple times in src/modules.ts. Resolve duplicates manually before running this command.`
|
|
379
415
|
);
|
|
380
416
|
}
|
|
381
417
|
const match = matches[0];
|
|
382
418
|
const current = normalizeModuleEntry(match.entry);
|
|
383
|
-
if (current.from === from) {
|
|
384
|
-
return
|
|
419
|
+
if (current.from === from && (!provenance?.locator || current.locator === provenance.locator) && (!provenance?.packageName || current.packageName === provenance.packageName)) {
|
|
420
|
+
return source;
|
|
385
421
|
}
|
|
386
422
|
const objectLiteral = source.slice(match.node.getStart(), match.node.end);
|
|
387
|
-
|
|
423
|
+
let updatedObjectLiteral = upsertModuleProperty(objectLiteral, "from", from);
|
|
424
|
+
if (provenance?.locator) updatedObjectLiteral = upsertModuleProperty(updatedObjectLiteral, "locator", provenance.locator);
|
|
425
|
+
if (provenance?.packageName) updatedObjectLiteral = upsertModuleProperty(updatedObjectLiteral, "packageName", provenance.packageName);
|
|
388
426
|
const updated = source.slice(0, match.node.getStart()) + updatedObjectLiteral + source.slice(match.node.end);
|
|
389
|
-
|
|
390
|
-
return { changed: true };
|
|
427
|
+
return updated;
|
|
391
428
|
}
|
|
392
429
|
export {
|
|
393
430
|
ModuleGatedOffError,
|
|
394
431
|
assertModuleNotGatedOff,
|
|
395
432
|
ensureModuleRegistration,
|
|
433
|
+
prepareModuleRegistration,
|
|
434
|
+
prepareModuleRegistrationSource,
|
|
396
435
|
readEnabledModules,
|
|
397
436
|
setModuleRegistrationSource
|
|
398
437
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/modules-config.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'node:fs'\nimport ts from 'typescript-js'\nimport { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'\n\nexport type ModuleEntry = {\n id: string\n from?: '@open-mercato/core' | '@app' | string\n}\n\ntype ModuleOccurrence = {\n entry: ModuleEntry\n node: ts.ObjectLiteralExpression\n active: boolean\n envFlags: string[] | null\n}\n\ntype EnvFlagScope = Map<string, string[] | null>\n\ntype ModuleConfigShape = {\n arrayNode: ts.ArrayLiteralExpression\n occurrences: ModuleOccurrence[]\n}\n\nfunction parseModuleEntryFromObjectLiteral(node: ts.ObjectLiteralExpression): ModuleEntry | null {\n let id: string | null = null\n let from: string | null = null\n\n for (const property of node.properties) {\n if (!ts.isPropertyAssignment(property) || !ts.isIdentifier(property.name)) continue\n\n if (property.name.text === 'id' && ts.isStringLiteralLike(property.initializer)) {\n id = property.initializer.text\n }\n\n if (property.name.text === 'from' && ts.isStringLiteralLike(property.initializer)) {\n from = property.initializer.text\n }\n }\n\n if (!id) return null\n\n return {\n id,\n from: from ?? '@open-mercato/core',\n }\n}\n\nfunction readProcessEnvName(node: ts.Expression): string | null {\n if (\n ts.isPropertyAccessExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && ts.isIdentifier(node.expression.expression)\n && node.expression.expression.text === 'process'\n && node.expression.name.text === 'env'\n ) {\n return node.name.text\n }\n\n if (\n ts.isElementAccessExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && ts.isIdentifier(node.expression.expression)\n && node.expression.expression.text === 'process'\n && node.expression.name.text === 'env'\n && ts.isStringLiteralLike(node.argumentExpression)\n ) {\n return node.argumentExpression.text\n }\n\n return null\n}\n\nfunction evaluateStaticExpressionWithScope(\n node: ts.Expression,\n env: NodeJS.ProcessEnv,\n scope: Map<string, unknown>,\n): unknown {\n if (ts.isParenthesizedExpression(node)) {\n return evaluateStaticExpressionWithScope(node.expression, env, scope)\n }\n\n if (ts.isIdentifier(node)) {\n return scope.get(node.text)\n }\n\n if (ts.isStringLiteralLike(node) || ts.isNoSubstitutionTemplateLiteral(node)) {\n return node.text\n }\n\n if (ts.isNumericLiteral(node)) {\n return Number(node.text)\n }\n\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false\n if (node.kind === ts.SyntaxKind.NullKeyword) return null\n\n const envName = readProcessEnvName(node)\n if (envName) {\n return env[envName]\n }\n\n if (ts.isPropertyAccessExpression(node)) {\n const target = evaluateStaticExpressionWithScope(node.expression, env, scope)\n if (target && typeof target === 'object' && node.name.text in target) {\n return (target as Record<string, unknown>)[node.name.text]\n }\n return undefined\n }\n\n if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.ExclamationToken) {\n return !Boolean(evaluateStaticExpressionWithScope(node.operand, env, scope))\n }\n\n if (ts.isBinaryExpression(node)) {\n if (node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {\n return Boolean(evaluateStaticExpressionWithScope(node.left, env, scope))\n && Boolean(evaluateStaticExpressionWithScope(node.right, env, scope))\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.BarBarToken) {\n return Boolean(evaluateStaticExpressionWithScope(node.left, env, scope))\n || Boolean(evaluateStaticExpressionWithScope(node.right, env, scope))\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken) {\n return evaluateStaticExpressionWithScope(node.left, env, scope)\n === evaluateStaticExpressionWithScope(node.right, env, scope)\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.ExclamationEqualsEqualsToken) {\n return evaluateStaticExpressionWithScope(node.left, env, scope)\n !== evaluateStaticExpressionWithScope(node.right, env, scope)\n }\n }\n\n if (\n ts.isCallExpression(node)\n && ts.isIdentifier(node.expression)\n && node.expression.text === 'parseBooleanWithDefault'\n ) {\n const rawValueNode = node.arguments[0]\n const fallbackNode = node.arguments[1]\n const rawValue = rawValueNode\n ? evaluateStaticExpressionWithScope(rawValueNode, env, scope)\n : undefined\n const fallbackValue = fallbackNode\n ? evaluateStaticExpressionWithScope(fallbackNode, env, scope)\n : false\n\n return parseBooleanWithDefault(\n typeof rawValue === 'string' ? rawValue : undefined,\n Boolean(fallbackValue),\n )\n }\n\n if (\n ts.isCallExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && node.expression.name.text === 'some'\n ) {\n const target = evaluateStaticExpressionWithScope(node.expression.expression, env, scope)\n const predicate = node.arguments[0]\n if (!Array.isArray(target) || !predicate) {\n return undefined\n }\n\n return target.some((entry) => {\n if (!ts.isArrowFunction(predicate) && !ts.isFunctionExpression(predicate)) {\n return false\n }\n\n const localScope = new Map(scope)\n const parameter = predicate.parameters[0]\n if (parameter && ts.isIdentifier(parameter.name)) {\n localScope.set(parameter.name.text, entry)\n }\n\n if (ts.isBlock(predicate.body)) {\n const returnStatement = predicate.body.statements.find((statement): statement is ts.ReturnStatement =>\n ts.isReturnStatement(statement),\n )\n if (!returnStatement?.expression) {\n return false\n }\n return Boolean(evaluateStaticExpressionWithScope(returnStatement.expression, env, localScope))\n }\n\n return Boolean(evaluateStaticExpressionWithScope(predicate.body, env, localScope))\n })\n }\n\n return undefined\n}\n\nfunction evaluateStaticCondition(\n node: ts.Expression,\n env: NodeJS.ProcessEnv,\n scope: Map<string, unknown>,\n): boolean {\n return Boolean(evaluateStaticExpressionWithScope(node, env, scope))\n}\n\nfunction mergeEnvFlags(left: string[] | null, right: string[] | null): string[] | null {\n if (left === null || right === null) return null\n return Array.from(new Set([...left, ...right]))\n}\n\nfunction collectEnablingEnvFlags(node: ts.Expression, envFlagScope: EnvFlagScope): string[] | null {\n if (ts.isParenthesizedExpression(node)) {\n return collectEnablingEnvFlags(node.expression, envFlagScope)\n }\n\n const envName = readProcessEnvName(node)\n if (envName) return [envName]\n\n if (ts.isIdentifier(node)) {\n return envFlagScope.get(node.text) ?? null\n }\n\n if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {\n return mergeEnvFlags(\n collectEnablingEnvFlags(node.left, envFlagScope),\n collectEnablingEnvFlags(node.right, envFlagScope),\n )\n }\n\n if (\n ts.isCallExpression(node)\n && ts.isIdentifier(node.expression)\n && node.expression.text === 'parseBooleanWithDefault'\n && node.arguments[0]\n ) {\n const envArgument = readProcessEnvName(node.arguments[0])\n return envArgument ? [envArgument] : null\n }\n\n return null\n}\n\ntype BranchContext = {\n active: boolean\n envFlags: string[] | null\n}\n\nfunction collectPushEntriesFromStatement(\n statement: ts.Statement,\n env: NodeJS.ProcessEnv,\n targetVariableName: string,\n scope: Map<string, unknown>,\n envFlagScope: EnvFlagScope,\n branch: BranchContext = { active: true, envFlags: [] },\n): ModuleOccurrence[] {\n if (ts.isBlock(statement)) {\n return statement.statements.flatMap((child) =>\n collectPushEntriesFromStatement(child, env, targetVariableName, scope, envFlagScope, branch),\n )\n }\n\n if (ts.isIfStatement(statement)) {\n const conditionMet = evaluateStaticCondition(statement.expression, env, scope)\n const envFlags = mergeEnvFlags(branch.envFlags, collectEnablingEnvFlags(statement.expression, envFlagScope))\n const thenEntries = collectPushEntriesFromStatement(\n statement.thenStatement,\n env,\n targetVariableName,\n scope,\n envFlagScope,\n { active: branch.active && conditionMet, envFlags },\n )\n const elseEntries = statement.elseStatement\n ? collectPushEntriesFromStatement(\n statement.elseStatement,\n env,\n targetVariableName,\n scope,\n envFlagScope,\n { active: branch.active && !conditionMet, envFlags: null },\n )\n : []\n return [...thenEntries, ...elseEntries]\n }\n\n if (!ts.isExpressionStatement(statement)) return []\n\n const expression = statement.expression\n if (!ts.isCallExpression(expression) || !ts.isPropertyAccessExpression(expression.expression)) {\n return []\n }\n\n const pushTarget = expression.expression.expression\n const pushMethod = expression.expression.name\n\n if (!ts.isIdentifier(pushTarget) || pushTarget.text !== targetVariableName || pushMethod.text !== 'push') {\n return []\n }\n\n return expression.arguments.flatMap((argument) => {\n if (!ts.isObjectLiteralExpression(argument)) return []\n const entry = parseModuleEntryFromObjectLiteral(argument)\n return entry ? [{ entry, node: argument, active: branch.active, envFlags: branch.envFlags }] : []\n })\n}\n\nfunction activeEntries(occurrences: ModuleOccurrence[]): ModuleEntry[] {\n return occurrences.filter((occurrence) => occurrence.active).map((occurrence) => occurrence.entry)\n}\n\nfunction parseModuleConfigShape(\n source: string,\n env: NodeJS.ProcessEnv = process.env,\n): ModuleConfigShape {\n const sourceFile = ts.createSourceFile('modules.ts', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)\n const variableName = 'enabledModules'\n const occurrences: ModuleOccurrence[] = []\n const scope = new Map<string, unknown>()\n const envFlagScope: EnvFlagScope = new Map()\n let arrayNode: ts.ArrayLiteralExpression | null = null\n let foundDeclaration = false\n\n for (const statement of sourceFile.statements) {\n if (ts.isVariableStatement(statement)) {\n for (const declaration of statement.declarationList.declarations) {\n if (!ts.isIdentifier(declaration.name)) continue\n\n if (declaration.name.text === variableName) {\n if (!declaration.initializer || !ts.isArrayLiteralExpression(declaration.initializer)) continue\n\n arrayNode = declaration.initializer\n occurrences.push(...declaration.initializer.elements.flatMap((element) => {\n if (!ts.isObjectLiteralExpression(element)) return []\n const entry = parseModuleEntryFromObjectLiteral(element)\n return entry ? [{ entry, node: element, active: true, envFlags: [] }] : []\n }))\n scope.set(variableName, activeEntries(occurrences))\n foundDeclaration = true\n continue\n }\n\n if (!declaration.initializer) continue\n\n scope.set(\n declaration.name.text,\n evaluateStaticExpressionWithScope(declaration.initializer, env, scope),\n )\n envFlagScope.set(declaration.name.text, collectEnablingEnvFlags(declaration.initializer, envFlagScope))\n }\n continue\n }\n\n if (!foundDeclaration) continue\n\n const pushedOccurrences = collectPushEntriesFromStatement(statement, env, variableName, scope, envFlagScope)\n if (pushedOccurrences.length > 0) {\n occurrences.push(...pushedOccurrences)\n scope.set(variableName, activeEntries(occurrences))\n }\n }\n\n if (!arrayNode) {\n throw new Error('Could not find enabledModules array declaration in src/modules.ts')\n }\n\n return { arrayNode, occurrences }\n}\n\nfunction normalizeModuleEntry(entry: ModuleEntry): ModuleEntry {\n return {\n id: entry.id,\n from: entry.from ?? '@open-mercato/core',\n }\n}\n\nfunction escapeSingleQuotedString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")\n}\n\nfunction buildModuleEntryLiteral(entry: ModuleEntry): string {\n const normalized = normalizeModuleEntry(entry)\n return `{ id: '${escapeSingleQuotedString(normalized.id)}', from: '${escapeSingleQuotedString(normalized.from ?? '@open-mercato/core')}' }`\n}\n\nfunction lineIndentAt(source: string, position: number): string {\n const lineStart = source.lastIndexOf('\\n', Math.max(0, position - 1)) + 1\n const lineToPosition = source.slice(lineStart, position)\n const match = lineToPosition.match(/^\\s*/)\n return match?.[0] ?? ''\n}\n\nfunction nextTokenEnd(source: string, position: number): number {\n const scanner = ts.createScanner(ts.ScriptTarget.Latest, true, ts.LanguageVariant.Standard, source)\n scanner.resetTokenState(position)\n scanner.scan()\n return scanner.getTokenEnd()\n}\n\nfunction trailingCommentsEnd(source: string, position: number): number {\n const ranges = ts.getTrailingCommentRanges(source, position) ?? []\n return ranges.length > 0 ? ranges[ranges.length - 1].end : position\n}\n\nfunction insertArrayElement(\n source: string,\n arrayNode: ts.ArrayLiteralExpression,\n entry: ModuleEntry,\n sourceFile: ts.SourceFile,\n): string {\n const newline = source.includes('\\r\\n') ? '\\r\\n' : '\\n'\n const entryLiteral = buildModuleEntryLiteral(entry)\n const openingBracket = arrayNode.getStart(sourceFile)\n const closingBracket = arrayNode.end - 1\n const openingIndent = lineIndentAt(source, openingBracket)\n const lastElement = arrayNode.elements[arrayNode.elements.length - 1]\n\n let head: string\n let insertAt: number\n let insertion: string\n\n if (!lastElement) {\n const innerContent = source.slice(openingBracket + 1, closingBracket).trimEnd()\n insertAt = openingBracket + 1 + innerContent.length\n head = source.slice(0, insertAt)\n insertion = `${newline}${openingIndent} ${entryLiteral},`\n } else {\n const hasTrailingComma = arrayNode.elements.hasTrailingComma\n const anchor = hasTrailingComma ? nextTokenEnd(source, lastElement.end) : lastElement.end\n insertAt = trailingCommentsEnd(source, anchor)\n head = hasTrailingComma\n ? source.slice(0, insertAt)\n : `${source.slice(0, anchor)},${source.slice(anchor, insertAt)}`\n const lastElementStart = lastElement.getStart(sourceFile)\n const startsOnOpeningLine = !source.slice(openingBracket, lastElementStart).includes('\\n')\n const elementIndent = startsOnOpeningLine\n ? `${openingIndent} `\n : lineIndentAt(source, lastElementStart)\n insertion = `${newline}${elementIndent}${entryLiteral}${hasTrailingComma ? ',' : ''}`\n }\n\n const closesOnSameLine = !source.slice(insertAt, closingBracket).includes('\\n')\n const closingLine = closesOnSameLine ? `${newline}${openingIndent}` : ''\n const tail = closesOnSameLine ? source.slice(closingBracket) : source.slice(insertAt)\n\n return head + insertion + closingLine + tail\n}\n\nfunction upsertModuleSource(objectLiteral: string, from: string): string {\n if (/from\\s*:\\s*'[^']*'/.test(objectLiteral)) {\n return objectLiteral.replace(/from\\s*:\\s*'[^']*'/, `from: '${escapeSingleQuotedString(from)}'`)\n }\n\n if (/from\\s*:\\s*\"[^\"]*\"/.test(objectLiteral)) {\n return objectLiteral.replace(/from\\s*:\\s*\"[^\"]*\"/, `from: \"${from.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`)\n }\n\n return objectLiteral.replace(/\\}\\s*$/, `, from: '${escapeSingleQuotedString(from)}' }`)\n}\n\nexport function readEnabledModules(modulesPath: string, env: NodeJS.ProcessEnv = process.env): ModuleEntry[] {\n const source = fs.readFileSync(modulesPath, 'utf8')\n // keeps only registrations whose condition holds; #8116 tags the others `active: false` instead of skipping them\n return parseModuleConfigShape(source, env)\n .occurrences.filter((occurrence) => !('active' in occurrence) || occurrence.active !== false)\n .map((occurrence) => normalizeModuleEntry(occurrence.entry))\n}\n\nexport class ModuleGatedOffError extends Error {\n readonly code = 'MODULE_GATED_OFF'\n\n constructor(\n message: string,\n readonly moduleId: string,\n readonly envFlags: string[],\n ) {\n super(message)\n this.name = 'ModuleGatedOffError'\n }\n}\n\nfunction resolveFlagsToSet(occurrences: ModuleOccurrence[], env: NodeJS.ProcessEnv): string[] {\n if (occurrences.some((occurrence) => occurrence.envFlags === null)) return []\n const envFlags = Array.from(new Set(occurrences.flatMap((occurrence) => occurrence.envFlags ?? [])))\n return envFlags.filter((flag) => !parseBooleanWithDefault(env[flag], false))\n}\n\nfunction buildModuleGatedOffError(\n moduleId: string,\n modulesPath: string,\n occurrences: ModuleOccurrence[],\n env: NodeJS.ProcessEnv = process.env,\n): ModuleGatedOffError {\n const flagsToSet = resolveFlagsToSet(occurrences, env)\n const prefix = `Module \"${moduleId}\" is already registered in ${modulesPath} behind a condition that is currently off, so no second entry was added.`\n const message = flagsToSet.length === 0\n ? `${prefix} Make that condition true to enable it.`\n : `${prefix} Enable it by setting ${flagsToSet.map((flag) => `${flag}=true`).join(' and ')} in your environment (.env), then run \\`yarn generate\\`.`\n return new ModuleGatedOffError(message, moduleId, flagsToSet)\n}\n\nexport function assertModuleNotGatedOff(modulesPath: string, moduleId: string): void {\n if (!fs.existsSync(modulesPath)) return\n\n const config = parseModuleConfigShape(fs.readFileSync(modulesPath, 'utf8'))\n const matches = config.occurrences.filter((occurrence) => occurrence.entry.id === moduleId)\n if (matches.length > 0 && matches.every((occurrence) => !occurrence.active)) {\n throw buildModuleGatedOffError(moduleId, modulesPath, matches)\n }\n}\n\nexport function ensureModuleRegistration(\n modulesPath: string,\n entry: ModuleEntry,\n): { changed: boolean; registeredAs: string } {\n if (!fs.existsSync(modulesPath)) {\n throw new Error(`modules.ts not found at ${modulesPath}`)\n }\n\n const source = fs.readFileSync(modulesPath, 'utf8')\n const sourceFile = ts.createSourceFile('modules.ts', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)\n const config = parseModuleConfigShape(source)\n const normalized = normalizeModuleEntry(entry)\n const allMatches = config.occurrences.filter((occurrence) => occurrence.entry.id === normalized.id)\n const matches = allMatches.filter((occurrence) => occurrence.active)\n\n if (matches.length === 0 && allMatches.length > 0) {\n throw buildModuleGatedOffError(normalized.id, modulesPath, allMatches)\n }\n\n if (matches.length > 1) {\n throw new Error(\n `Module \"${normalized.id}\" is registered multiple times in ${modulesPath}. Resolve duplicates manually before running this command.`,\n )\n }\n\n if (matches.length === 1) {\n const existing = normalizeModuleEntry(matches[0].entry)\n if (existing.from === normalized.from) {\n return { changed: false, registeredAs: normalized.from ?? '@open-mercato/core' }\n }\n\n throw new Error(\n `Module \"${normalized.id}\" is already registered from \"${existing.from}\". Remove or eject the existing registration first.`,\n )\n }\n\n const updated = insertArrayElement(source, config.arrayNode, normalized, sourceFile)\n fs.writeFileSync(modulesPath, updated)\n\n return { changed: true, registeredAs: normalized.from ?? '@open-mercato/core' }\n}\n\nexport function setModuleRegistrationSource(\n modulesPath: string,\n moduleId: string,\n from: string,\n): { changed: boolean } {\n if (!fs.existsSync(modulesPath)) {\n throw new Error(`modules.ts not found at ${modulesPath}`)\n }\n\n const source = fs.readFileSync(modulesPath, 'utf8')\n const config = parseModuleConfigShape(source)\n const matches = config.occurrences.filter((occurrence) => occurrence.active && occurrence.entry.id === moduleId)\n\n if (matches.length === 0) {\n throw new Error(\n `Could not find module entry for \"${moduleId}\" in ${modulesPath}. Expected a pattern like: { id: '${moduleId}', from: '...' } or { id: '${moduleId}' }`,\n )\n }\n\n if (matches.length > 1) {\n throw new Error(\n `Module \"${moduleId}\" is registered multiple times in ${modulesPath}. Resolve duplicates manually before running this command.`,\n )\n }\n\n const match = matches[0]\n const current = normalizeModuleEntry(match.entry)\n if (current.from === from) {\n return { changed: false }\n }\n\n const objectLiteral = source.slice(match.node.getStart(), match.node.end)\n const updatedObjectLiteral = upsertModuleSource(objectLiteral, from)\n const updated =\n source.slice(0, match.node.getStart()) +\n updatedObjectLiteral +\n source.slice(match.node.end)\n\n fs.writeFileSync(modulesPath, updated)\n\n return { changed: true }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,SAAS,+BAA+B;AAqBxC,SAAS,kCAAkC,MAAsD;AAC/F,MAAI,KAAoB;AACxB,MAAI,OAAsB;AAE1B,aAAW,YAAY,KAAK,YAAY;AACtC,QAAI,CAAC,GAAG,qBAAqB,QAAQ,KAAK,CAAC,GAAG,aAAa,SAAS,IAAI,EAAG;AAE3E,QAAI,SAAS,KAAK,SAAS,QAAQ,GAAG,oBAA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B;AAEA,QAAM,gBAAgB,OAAO,MAAM,MAAM,KAAK,SAAS,GAAG,MAAM,KAAK,GAAG;AACxE,QAAM,uBAAuB,mBAAmB,eAAe,IAAI;AACnE,QAAM,UACJ,OAAO,MAAM,GAAG,MAAM,KAAK,SAAS,CAAC,IACrC,uBACA,OAAO,MAAM,MAAM,KAAK,GAAG;AAE7B,KAAG,cAAc,aAAa,OAAO;AAErC,SAAO,EAAE,SAAS,KAAK;AACzB;",
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs'\nimport ts from 'typescript-js'\nimport { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'\n\nexport type ModuleEntry = {\n id: string\n from?: '@open-mercato/core' | '@app' | string\n locator?: string\n packageName?: string\n}\n\ntype ModuleOccurrence = {\n entry: ModuleEntry\n node: ts.ObjectLiteralExpression\n active: boolean\n envFlags: string[] | null\n}\n\ntype EnvFlagScope = Map<string, string[] | null>\n\ntype ModuleConfigShape = {\n arrayNode: ts.ArrayLiteralExpression\n occurrences: ModuleOccurrence[]\n}\n\nfunction parseModuleEntryFromObjectLiteral(node: ts.ObjectLiteralExpression): ModuleEntry | null {\n let id: string | null = null\n let from: string | null = null\n let locator: string | undefined\n let packageName: string | undefined\n\n for (const property of node.properties) {\n if (!ts.isPropertyAssignment(property) || (!ts.isIdentifier(property.name) && !ts.isStringLiteralLike(property.name))) continue\n\n if (property.name.text === 'id' && ts.isStringLiteralLike(property.initializer)) {\n id = property.initializer.text\n }\n\n if (property.name.text === 'packageName' && ts.isStringLiteralLike(property.initializer)) {\n packageName = property.initializer.text\n }\n\n if (property.name.text === 'locator' && ts.isStringLiteralLike(property.initializer)) {\n locator = property.initializer.text\n }\n\n if (property.name.text === 'from' && ts.isStringLiteralLike(property.initializer)) {\n from = property.initializer.text\n }\n }\n\n if (!id) return null\n\n return {\n id,\n from: from ?? '@open-mercato/core',\n ...(locator ? { locator } : {}),\n ...(packageName ? { packageName } : {}),\n }\n}\n\nfunction readProcessEnvName(node: ts.Expression): string | null {\n if (\n ts.isPropertyAccessExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && ts.isIdentifier(node.expression.expression)\n && node.expression.expression.text === 'process'\n && node.expression.name.text === 'env'\n ) {\n return node.name.text\n }\n\n if (\n ts.isElementAccessExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && ts.isIdentifier(node.expression.expression)\n && node.expression.expression.text === 'process'\n && node.expression.name.text === 'env'\n && ts.isStringLiteralLike(node.argumentExpression)\n ) {\n return node.argumentExpression.text\n }\n\n return null\n}\n\nfunction evaluateStaticExpressionWithScope(\n node: ts.Expression,\n env: NodeJS.ProcessEnv,\n scope: Map<string, unknown>,\n): unknown {\n if (ts.isParenthesizedExpression(node)) {\n return evaluateStaticExpressionWithScope(node.expression, env, scope)\n }\n\n if (ts.isIdentifier(node)) {\n return scope.get(node.text)\n }\n\n if (ts.isStringLiteralLike(node) || ts.isNoSubstitutionTemplateLiteral(node)) {\n return node.text\n }\n\n if (ts.isNumericLiteral(node)) {\n return Number(node.text)\n }\n\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false\n if (node.kind === ts.SyntaxKind.NullKeyword) return null\n\n const envName = readProcessEnvName(node)\n if (envName) {\n return env[envName]\n }\n\n if (ts.isPropertyAccessExpression(node)) {\n const target = evaluateStaticExpressionWithScope(node.expression, env, scope)\n if (target && typeof target === 'object' && node.name.text in target) {\n return (target as Record<string, unknown>)[node.name.text]\n }\n return undefined\n }\n\n if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.ExclamationToken) {\n return !Boolean(evaluateStaticExpressionWithScope(node.operand, env, scope))\n }\n\n if (ts.isBinaryExpression(node)) {\n if (node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {\n return Boolean(evaluateStaticExpressionWithScope(node.left, env, scope))\n && Boolean(evaluateStaticExpressionWithScope(node.right, env, scope))\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.BarBarToken) {\n return Boolean(evaluateStaticExpressionWithScope(node.left, env, scope))\n || Boolean(evaluateStaticExpressionWithScope(node.right, env, scope))\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken) {\n return evaluateStaticExpressionWithScope(node.left, env, scope)\n === evaluateStaticExpressionWithScope(node.right, env, scope)\n }\n\n if (node.operatorToken.kind === ts.SyntaxKind.ExclamationEqualsEqualsToken) {\n return evaluateStaticExpressionWithScope(node.left, env, scope)\n !== evaluateStaticExpressionWithScope(node.right, env, scope)\n }\n }\n\n if (\n ts.isCallExpression(node)\n && ts.isIdentifier(node.expression)\n && node.expression.text === 'parseBooleanWithDefault'\n ) {\n const rawValueNode = node.arguments[0]\n const fallbackNode = node.arguments[1]\n const rawValue = rawValueNode\n ? evaluateStaticExpressionWithScope(rawValueNode, env, scope)\n : undefined\n const fallbackValue = fallbackNode\n ? evaluateStaticExpressionWithScope(fallbackNode, env, scope)\n : false\n\n return parseBooleanWithDefault(\n typeof rawValue === 'string' ? rawValue : undefined,\n Boolean(fallbackValue),\n )\n }\n\n if (\n ts.isCallExpression(node)\n && ts.isPropertyAccessExpression(node.expression)\n && node.expression.name.text === 'some'\n ) {\n const target = evaluateStaticExpressionWithScope(node.expression.expression, env, scope)\n const predicate = node.arguments[0]\n if (!Array.isArray(target) || !predicate) {\n return undefined\n }\n\n return target.some((entry) => {\n if (!ts.isArrowFunction(predicate) && !ts.isFunctionExpression(predicate)) {\n return false\n }\n\n const localScope = new Map(scope)\n const parameter = predicate.parameters[0]\n if (parameter && ts.isIdentifier(parameter.name)) {\n localScope.set(parameter.name.text, entry)\n }\n\n if (ts.isBlock(predicate.body)) {\n const returnStatement = predicate.body.statements.find((statement): statement is ts.ReturnStatement =>\n ts.isReturnStatement(statement),\n )\n if (!returnStatement?.expression) {\n return false\n }\n return Boolean(evaluateStaticExpressionWithScope(returnStatement.expression, env, localScope))\n }\n\n return Boolean(evaluateStaticExpressionWithScope(predicate.body, env, localScope))\n })\n }\n\n return undefined\n}\n\nfunction evaluateStaticCondition(\n node: ts.Expression,\n env: NodeJS.ProcessEnv,\n scope: Map<string, unknown>,\n): boolean {\n return Boolean(evaluateStaticExpressionWithScope(node, env, scope))\n}\n\nfunction mergeEnvFlags(left: string[] | null, right: string[] | null): string[] | null {\n if (left === null || right === null) return null\n return Array.from(new Set([...left, ...right]))\n}\n\nfunction collectEnablingEnvFlags(node: ts.Expression, envFlagScope: EnvFlagScope): string[] | null {\n if (ts.isParenthesizedExpression(node)) {\n return collectEnablingEnvFlags(node.expression, envFlagScope)\n }\n\n const envName = readProcessEnvName(node)\n if (envName) return [envName]\n\n if (ts.isIdentifier(node)) {\n return envFlagScope.get(node.text) ?? null\n }\n\n if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {\n return mergeEnvFlags(\n collectEnablingEnvFlags(node.left, envFlagScope),\n collectEnablingEnvFlags(node.right, envFlagScope),\n )\n }\n\n if (\n ts.isCallExpression(node)\n && ts.isIdentifier(node.expression)\n && node.expression.text === 'parseBooleanWithDefault'\n && node.arguments[0]\n ) {\n const envArgument = readProcessEnvName(node.arguments[0])\n return envArgument ? [envArgument] : null\n }\n\n return null\n}\n\ntype BranchContext = {\n active: boolean\n envFlags: string[] | null\n}\n\nfunction collectPushEntriesFromStatement(\n statement: ts.Statement,\n env: NodeJS.ProcessEnv,\n targetVariableName: string,\n scope: Map<string, unknown>,\n envFlagScope: EnvFlagScope,\n branch: BranchContext = { active: true, envFlags: [] },\n): ModuleOccurrence[] {\n if (ts.isBlock(statement)) {\n return statement.statements.flatMap((child) =>\n collectPushEntriesFromStatement(child, env, targetVariableName, scope, envFlagScope, branch),\n )\n }\n\n if (ts.isIfStatement(statement)) {\n const conditionMet = evaluateStaticCondition(statement.expression, env, scope)\n const envFlags = mergeEnvFlags(branch.envFlags, collectEnablingEnvFlags(statement.expression, envFlagScope))\n const thenEntries = collectPushEntriesFromStatement(\n statement.thenStatement,\n env,\n targetVariableName,\n scope,\n envFlagScope,\n { active: branch.active && conditionMet, envFlags },\n )\n const elseEntries = statement.elseStatement\n ? collectPushEntriesFromStatement(\n statement.elseStatement,\n env,\n targetVariableName,\n scope,\n envFlagScope,\n { active: branch.active && !conditionMet, envFlags: null },\n )\n : []\n return [...thenEntries, ...elseEntries]\n }\n\n if (!ts.isExpressionStatement(statement)) return []\n\n const expression = statement.expression\n if (!ts.isCallExpression(expression) || !ts.isPropertyAccessExpression(expression.expression)) {\n return []\n }\n\n const pushTarget = expression.expression.expression\n const pushMethod = expression.expression.name\n\n if (!ts.isIdentifier(pushTarget) || pushTarget.text !== targetVariableName || pushMethod.text !== 'push') {\n return []\n }\n\n return expression.arguments.flatMap((argument) => {\n if (!ts.isObjectLiteralExpression(argument)) return []\n const entry = parseModuleEntryFromObjectLiteral(argument)\n return entry ? [{ entry, node: argument, active: branch.active, envFlags: branch.envFlags }] : []\n })\n}\n\nfunction activeEntries(occurrences: ModuleOccurrence[]): ModuleEntry[] {\n return occurrences.filter((occurrence) => occurrence.active).map((occurrence) => occurrence.entry)\n}\n\nfunction parseModuleConfigShape(\n source: string,\n env: NodeJS.ProcessEnv = process.env,\n): ModuleConfigShape {\n const sourceFile = ts.createSourceFile('modules.ts', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)\n const variableName = 'enabledModules'\n const occurrences: ModuleOccurrence[] = []\n const scope = new Map<string, unknown>()\n const envFlagScope: EnvFlagScope = new Map()\n let arrayNode: ts.ArrayLiteralExpression | null = null\n let foundDeclaration = false\n\n for (const statement of sourceFile.statements) {\n if (ts.isVariableStatement(statement)) {\n for (const declaration of statement.declarationList.declarations) {\n if (!ts.isIdentifier(declaration.name)) continue\n\n if (declaration.name.text === variableName) {\n if (!declaration.initializer || !ts.isArrayLiteralExpression(declaration.initializer)) continue\n\n arrayNode = declaration.initializer\n occurrences.push(...declaration.initializer.elements.flatMap((element) => {\n if (!ts.isObjectLiteralExpression(element)) return []\n const entry = parseModuleEntryFromObjectLiteral(element)\n return entry ? [{ entry, node: element, active: true, envFlags: [] }] : []\n }))\n scope.set(variableName, activeEntries(occurrences))\n foundDeclaration = true\n continue\n }\n\n if (!declaration.initializer) continue\n\n scope.set(\n declaration.name.text,\n evaluateStaticExpressionWithScope(declaration.initializer, env, scope),\n )\n envFlagScope.set(declaration.name.text, collectEnablingEnvFlags(declaration.initializer, envFlagScope))\n }\n continue\n }\n\n if (!foundDeclaration) continue\n\n const pushedOccurrences = collectPushEntriesFromStatement(statement, env, variableName, scope, envFlagScope)\n if (pushedOccurrences.length > 0) {\n occurrences.push(...pushedOccurrences)\n scope.set(variableName, activeEntries(occurrences))\n }\n }\n\n if (!arrayNode) {\n throw new Error('Could not find enabledModules array declaration in src/modules.ts')\n }\n\n return { arrayNode, occurrences }\n}\n\nfunction normalizeModuleEntry(entry: ModuleEntry): ModuleEntry {\n return {\n id: entry.id,\n from: entry.from ?? '@open-mercato/core',\n ...(entry.locator ? { locator: entry.locator } : {}),\n ...(entry.packageName ? { packageName: entry.packageName } : {}),\n }\n}\n\nfunction escapeSingleQuotedString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")\n}\n\nfunction buildModuleEntryLiteral(entry: ModuleEntry): string {\n const normalized = normalizeModuleEntry(entry)\n return `{ id: '${escapeSingleQuotedString(normalized.id)}', from: '${escapeSingleQuotedString(normalized.from ?? '@open-mercato/core')}'${normalized.locator ? `, locator: '${escapeSingleQuotedString(normalized.locator)}'` : ''}${normalized.packageName ? `, packageName: '${escapeSingleQuotedString(normalized.packageName)}'` : ''} }`\n}\n\nfunction lineIndentAt(source: string, position: number): string {\n const lineStart = source.lastIndexOf('\\n', Math.max(0, position - 1)) + 1\n const lineToPosition = source.slice(lineStart, position)\n const match = lineToPosition.match(/^\\s*/)\n return match?.[0] ?? ''\n}\n\nfunction nextTokenEnd(source: string, position: number): number {\n const scanner = ts.createScanner(ts.ScriptTarget.Latest, true, ts.LanguageVariant.Standard, source)\n scanner.resetTokenState(position)\n scanner.scan()\n return scanner.getTokenEnd()\n}\n\nfunction trailingCommentsEnd(source: string, position: number): number {\n const ranges = ts.getTrailingCommentRanges(source, position) ?? []\n return ranges.length > 0 ? ranges[ranges.length - 1].end : position\n}\n\nfunction insertArrayElement(\n source: string,\n arrayNode: ts.ArrayLiteralExpression,\n entry: ModuleEntry,\n sourceFile: ts.SourceFile,\n): string {\n const newline = source.includes('\\r\\n') ? '\\r\\n' : '\\n'\n const entryLiteral = buildModuleEntryLiteral(entry)\n const openingBracket = arrayNode.getStart(sourceFile)\n const closingBracket = arrayNode.end - 1\n const openingIndent = lineIndentAt(source, openingBracket)\n const lastElement = arrayNode.elements[arrayNode.elements.length - 1]\n\n let head: string\n let insertAt: number\n let insertion: string\n\n if (!lastElement) {\n const innerContent = source.slice(openingBracket + 1, closingBracket).trimEnd()\n insertAt = openingBracket + 1 + innerContent.length\n head = source.slice(0, insertAt)\n insertion = `${newline}${openingIndent} ${entryLiteral},`\n } else {\n const hasTrailingComma = arrayNode.elements.hasTrailingComma\n const anchor = hasTrailingComma ? nextTokenEnd(source, lastElement.end) : lastElement.end\n insertAt = trailingCommentsEnd(source, anchor)\n head = hasTrailingComma\n ? source.slice(0, insertAt)\n : `${source.slice(0, anchor)},${source.slice(anchor, insertAt)}`\n const lastElementStart = lastElement.getStart(sourceFile)\n const startsOnOpeningLine = !source.slice(openingBracket, lastElementStart).includes('\\n')\n const elementIndent = startsOnOpeningLine\n ? `${openingIndent} `\n : lineIndentAt(source, lastElementStart)\n insertion = `${newline}${elementIndent}${entryLiteral}${hasTrailingComma ? ',' : ''}`\n }\n\n const closesOnSameLine = !source.slice(insertAt, closingBracket).includes('\\n')\n const closingLine = closesOnSameLine ? `${newline}${openingIndent}` : ''\n const tail = closesOnSameLine ? source.slice(closingBracket) : source.slice(insertAt)\n\n return head + insertion + closingLine + tail\n}\n\nfunction upsertModuleProperty(objectLiteral: string, propertyName: 'from' | 'locator' | 'packageName', value: string): string {\n const prefix = 'const entry = '\n const sourceFile = ts.createSourceFile('entry.ts', prefix + objectLiteral, ts.ScriptTarget.Latest, true)\n const statement = sourceFile.statements[0]\n const initializer = ts.isVariableStatement(statement) ? statement.declarationList.declarations[0]?.initializer : undefined\n if (!initializer || !ts.isObjectLiteralExpression(initializer)) {\n throw new Error('Cannot update module registration: expected an object literal.')\n }\n const property = initializer.properties.find((candidate) =>\n 'name' in candidate && candidate.name && (ts.isIdentifier(candidate.name) || ts.isStringLiteralLike(candidate.name)) && candidate.name.text === propertyName,\n )\n const quotedValue = `'${escapeSingleQuotedString(value)}'`\n if (property) {\n const target = ts.isPropertyAssignment(property) ? property.initializer : property\n const existingQuote = ts.isPropertyAssignment(property) ? property.initializer.getText(sourceFile)[0] : undefined\n const replacementValue = existingQuote === '\"' ? JSON.stringify(value) : quotedValue\n const replacement = ts.isPropertyAssignment(property) ? replacementValue : `${propertyName}: ${replacementValue}`\n return objectLiteral.slice(0, target.getStart(sourceFile) - prefix.length) + replacement + objectLiteral.slice(target.end - prefix.length)\n }\n const lastProperty = initializer.properties[initializer.properties.length - 1]\n const insertPosition = lastProperty ? lastProperty.end - prefix.length : initializer.end - prefix.length - 1\n const separator = lastProperty ? ', ' : ' '\n return objectLiteral.slice(0, insertPosition) + `${separator}${propertyName}: ${quotedValue}` + objectLiteral.slice(insertPosition)\n}\n\nexport function readEnabledModules(modulesPath: string, env: NodeJS.ProcessEnv = process.env): ModuleEntry[] {\n const source = fs.readFileSync(modulesPath, 'utf8')\n // keeps only registrations whose condition holds; #8116 tags the others `active: false` instead of skipping them\n return parseModuleConfigShape(source, env)\n .occurrences.filter((occurrence) => !('active' in occurrence) || occurrence.active !== false)\n .map((occurrence) => normalizeModuleEntry(occurrence.entry))\n}\n\nexport class ModuleGatedOffError extends Error {\n readonly code = 'MODULE_GATED_OFF'\n\n constructor(\n message: string,\n readonly moduleId: string,\n readonly envFlags: string[],\n ) {\n super(message)\n this.name = 'ModuleGatedOffError'\n }\n}\n\nfunction resolveFlagsToSet(occurrences: ModuleOccurrence[], env: NodeJS.ProcessEnv): string[] {\n if (occurrences.some((occurrence) => occurrence.envFlags === null)) return []\n const envFlags = Array.from(new Set(occurrences.flatMap((occurrence) => occurrence.envFlags ?? [])))\n return envFlags.filter((flag) => !parseBooleanWithDefault(env[flag], false))\n}\n\nfunction buildModuleGatedOffError(\n moduleId: string,\n modulesPath: string,\n occurrences: ModuleOccurrence[],\n env: NodeJS.ProcessEnv = process.env,\n): ModuleGatedOffError {\n const flagsToSet = resolveFlagsToSet(occurrences, env)\n const prefix = `Module \"${moduleId}\" is already registered in ${modulesPath} behind a condition that is currently off, so no second entry was added.`\n const message = flagsToSet.length === 0\n ? `${prefix} Make that condition true to enable it.`\n : `${prefix} Enable it by setting ${flagsToSet.map((flag) => `${flag}=true`).join(' and ')} in your environment (.env), then run \\`yarn generate\\`.`\n return new ModuleGatedOffError(message, moduleId, flagsToSet)\n}\n\nexport function assertModuleNotGatedOff(modulesPath: string, moduleId: string): void {\n if (!fs.existsSync(modulesPath)) return\n\n const config = parseModuleConfigShape(fs.readFileSync(modulesPath, 'utf8'))\n const matches = config.occurrences.filter((occurrence) => occurrence.entry.id === moduleId)\n if (matches.length > 0 && matches.every((occurrence) => !occurrence.active)) {\n throw buildModuleGatedOffError(moduleId, modulesPath, matches)\n }\n}\n\nexport function ensureModuleRegistration(\n modulesPath: string,\n entry: ModuleEntry,\n): { changed: boolean; registeredAs: string } {\n if (!fs.existsSync(modulesPath)) {\n throw new Error(`modules.ts not found at ${modulesPath}`)\n }\n\n const source = fs.readFileSync(modulesPath, 'utf8')\n const result = prepareModuleRegistration(source, entry, modulesPath)\n if (result.changed) fs.writeFileSync(modulesPath, result.source)\n return { changed: result.changed, registeredAs: result.registeredAs }\n}\n\nexport function prepareModuleRegistration(\n source: string,\n entry: ModuleEntry,\n modulesPath = 'src/modules.ts',\n): { source: string; changed: boolean; registeredAs: string } {\n const sourceFile = ts.createSourceFile('modules.ts', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)\n const config = parseModuleConfigShape(source)\n const normalized = normalizeModuleEntry(entry)\n const allMatches = config.occurrences.filter((occurrence) => occurrence.entry.id === normalized.id)\n const matches = allMatches.filter((occurrence) => occurrence.active)\n\n if (matches.length === 0 && allMatches.length > 0) {\n throw buildModuleGatedOffError(normalized.id, modulesPath, allMatches)\n }\n\n if (matches.length > 1) {\n throw new Error(`Module \"${normalized.id}\" is registered multiple times in src/modules.ts. Resolve duplicates manually before running this command.`)\n }\n\n if (matches.length === 1) {\n const existing = normalizeModuleEntry(matches[0].entry)\n if (existing.from === normalized.from) {\n return { source, changed: false, registeredAs: normalized.from ?? '@open-mercato/core' }\n }\n throw new Error(`Module \"${normalized.id}\" is already registered from \"${existing.from}\". Remove or eject the existing registration first.`)\n }\n\n return {\n source: insertArrayElement(source, config.arrayNode, normalized, sourceFile),\n changed: true,\n registeredAs: normalized.from ?? '@open-mercato/core',\n }\n}\n\nexport function setModuleRegistrationSource(\n modulesPath: string,\n moduleId: string,\n from: string,\n provenance?: Pick<ModuleEntry, 'locator' | 'packageName'>,\n): { changed: boolean } {\n if (!fs.existsSync(modulesPath)) {\n throw new Error(`modules.ts not found at ${modulesPath}`)\n }\n\n const source = fs.readFileSync(modulesPath, 'utf8')\n const updated = prepareModuleRegistrationSource(source, moduleId, from, provenance)\n if (updated === source) return { changed: false }\n fs.writeFileSync(modulesPath, updated)\n return { changed: true }\n}\n\nexport function prepareModuleRegistrationSource(\n source: string,\n moduleId: string,\n from: string,\n provenance?: Pick<ModuleEntry, 'locator' | 'packageName'>,\n): string {\n const config = parseModuleConfigShape(source)\n const matches = config.occurrences.filter((occurrence) => occurrence.active && occurrence.entry.id === moduleId)\n\n if (matches.length === 0) {\n throw new Error(\n `Could not find module entry for \"${moduleId}\" in src/modules.ts. Expected a pattern like: { id: '${moduleId}', from: '...' } or { id: '${moduleId}' }`,\n )\n }\n\n if (matches.length > 1) {\n throw new Error(\n `Module \"${moduleId}\" is registered multiple times in src/modules.ts. Resolve duplicates manually before running this command.`,\n )\n }\n\n const match = matches[0]\n const current = normalizeModuleEntry(match.entry)\n if (current.from === from && (!provenance?.locator || current.locator === provenance.locator) && (!provenance?.packageName || current.packageName === provenance.packageName)) {\n return source\n }\n\n const objectLiteral = source.slice(match.node.getStart(), match.node.end)\n let updatedObjectLiteral = upsertModuleProperty(objectLiteral, 'from', from)\n if (provenance?.locator) updatedObjectLiteral = upsertModuleProperty(updatedObjectLiteral, 'locator', provenance.locator)\n if (provenance?.packageName) updatedObjectLiteral = upsertModuleProperty(updatedObjectLiteral, 'packageName', provenance.packageName)\n const updated =\n source.slice(0, match.node.getStart()) +\n updatedObjectLiteral +\n source.slice(match.node.end)\n\n return updated\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,SAAS,+BAA+B;AAuBxC,SAAS,kCAAkC,MAAsD;AAC/F,MAAI,KAAoB;AACxB,MAAI,OAAsB;AAC1B,MAAI;AACJ,MAAI;AAEJ,aAAW,YAAY,KAAK,YAAY;AACtC,QAAI,CAAC,GAAG,qBAAqB,QAAQ,KAAM,CAAC,GAAG,aAAa,SAAS,IAAI,KAAK,CAAC,GAAG,oBAAoB,SAAS,IAAI,EAAI;AAEvH,QAAI,SAAS,KAAK,SAAS,QAAQ,GAAG,oBAAoB,SAAS,WAAW,GAAG;AAC/E,WAAK,SAAS,YAAY;AAAA,IAC5B;AAEA,QAAI,SAAS,KAAK,SAAS,iBAAiB,GAAG,oBAAoB,SAAS,WAAW,GAAG;AACxF,oBAAc,SAAS,YAAY;AAAA,IACrC;AAEA,QAAI,SAAS,KAAK,SAAS,aAAa,GAAG,oBAAoB,SAAS,WAAW,GAAG;AACpF,gBAAU,SAAS,YAAY;AAAA,IACjC;AAEA,QAAI,SAAS,KAAK,SAAS,UAAU,GAAG,oBAAoB,SAAS,WAAW,GAAG;AACjF,aAAO,SAAS,YAAY;AAAA,IAC9B;AAAA,E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B,UAAM,IAAI;AAAA,MACR,WAAW,QAAQ;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,QAAQ,QAAQ,CAAC;AACvB,QAAM,UAAU,qBAAqB,MAAM,KAAK;AAChD,MAAI,QAAQ,SAAS,SAAS,CAAC,YAAY,WAAW,QAAQ,YAAY,WAAW,aAAa,CAAC,YAAY,eAAe,QAAQ,gBAAgB,WAAW,cAAc;AAC7K,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB,OAAO,MAAM,MAAM,KAAK,SAAS,GAAG,MAAM,KAAK,GAAG;AACxE,MAAI,uBAAuB,qBAAqB,eAAe,QAAQ,IAAI;AAC3E,MAAI,YAAY,QAAS,wBAAuB,qBAAqB,sBAAsB,WAAW,WAAW,OAAO;AACxH,MAAI,YAAY,YAAa,wBAAuB,qBAAqB,sBAAsB,eAAe,WAAW,WAAW;AACpI,QAAM,UACJ,OAAO,MAAM,GAAG,MAAM,KAAK,SAAS,CAAC,IACrC,uBACA,OAAO,MAAM,MAAM,KAAK,GAAG;AAE7B,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/resolver.js
CHANGED
|
@@ -2,40 +2,32 @@ import path from "node:path";
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import ts from "typescript-js";
|
|
4
4
|
import { parseBooleanWithDefault } from "@open-mercato/shared/lib/boolean";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return path.resolve(rootDir, "packages/core/src/modules");
|
|
15
|
-
}
|
|
16
|
-
const m = from.match(/^@open-mercato\/(.+)$/);
|
|
17
|
-
if (m) {
|
|
18
|
-
return path.resolve(rootDir, `packages/${m[1]}/src/modules`);
|
|
19
|
-
}
|
|
20
|
-
return path.resolve(rootDir, "packages/core/src/modules");
|
|
5
|
+
import { resolveInstalledPackageRootWithRequire } from "./module-package.js";
|
|
6
|
+
function pkgDirFor(rootDir, from, isMonorepo = true, appDir = rootDir) {
|
|
7
|
+
const packageRoot = pkgRootFor(rootDir, from, isMonorepo, appDir);
|
|
8
|
+
const sourceModules = path.join(packageRoot, "src", "modules");
|
|
9
|
+
const distModules = path.join(packageRoot, "dist", "modules");
|
|
10
|
+
const workspacePackage = isMonorepo && packageRoot.startsWith(path.join(rootDir, "packages") + path.sep);
|
|
11
|
+
if (workspacePackage && fs.existsSync(sourceModules)) return sourceModules;
|
|
12
|
+
if (fs.existsSync(distModules)) return distModules;
|
|
13
|
+
return sourceModules;
|
|
21
14
|
}
|
|
22
|
-
function pkgRootFor(rootDir, from, isMonorepo = true) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const m = from.match(/^@open-mercato\/(.+)$/);
|
|
31
|
-
if (m) {
|
|
32
|
-
return path.resolve(rootDir, `packages/${m[1]}`);
|
|
15
|
+
function pkgRootFor(rootDir, from, isMonorepo = true, appDir = rootDir) {
|
|
16
|
+
const packageName = from || "@open-mercato/core";
|
|
17
|
+
if (isMonorepo) {
|
|
18
|
+
const workspaceMatch = packageName.match(/^@open-mercato\/(.+)$/);
|
|
19
|
+
if (workspaceMatch) {
|
|
20
|
+
const workspaceRoot = path.join(rootDir, "packages", workspaceMatch[1]);
|
|
21
|
+
if (fs.existsSync(workspaceRoot)) return workspaceRoot;
|
|
22
|
+
}
|
|
33
23
|
}
|
|
34
|
-
return path.
|
|
24
|
+
return resolveInstalledPackageRootWithRequire(packageName, appDir) ?? path.join(rootDir, "node_modules", packageName);
|
|
35
25
|
}
|
|
36
26
|
function parseModuleEntryFromObjectLiteral(node) {
|
|
37
27
|
let id = null;
|
|
38
28
|
let from = null;
|
|
29
|
+
let locator;
|
|
30
|
+
let packageName;
|
|
39
31
|
let devSupervisorRequiresFullBootstrap = false;
|
|
40
32
|
for (const property of node.properties) {
|
|
41
33
|
if (!ts.isPropertyAssignment(property)) continue;
|
|
@@ -46,6 +38,12 @@ function parseModuleEntryFromObjectLiteral(node) {
|
|
|
46
38
|
if (key === "from" && ts.isStringLiteralLike(property.initializer)) {
|
|
47
39
|
from = property.initializer.text;
|
|
48
40
|
}
|
|
41
|
+
if (key === "packageName" && ts.isStringLiteralLike(property.initializer)) {
|
|
42
|
+
packageName = property.initializer.text;
|
|
43
|
+
}
|
|
44
|
+
if (key === "locator" && ts.isStringLiteralLike(property.initializer)) {
|
|
45
|
+
locator = property.initializer.text;
|
|
46
|
+
}
|
|
49
47
|
if (key === "overrides") {
|
|
50
48
|
if (!ts.isObjectLiteralExpression(property.initializer)) {
|
|
51
49
|
devSupervisorRequiresFullBootstrap = true;
|
|
@@ -69,6 +67,8 @@ function parseModuleEntryFromObjectLiteral(node) {
|
|
|
69
67
|
return {
|
|
70
68
|
id,
|
|
71
69
|
from: from ?? "@open-mercato/core",
|
|
70
|
+
...locator ? { locator } : {},
|
|
71
|
+
...packageName ? { packageName } : {},
|
|
72
72
|
...devSupervisorRequiresFullBootstrap ? { devSupervisorRequiresFullBootstrap: true } : {}
|
|
73
73
|
};
|
|
74
74
|
}
|
|
@@ -251,8 +251,7 @@ function loadEnabledModulesFromConfig(appDir) {
|
|
|
251
251
|
const cfgPath = path.resolve(appDir, "src/modules.ts");
|
|
252
252
|
if (fs.existsSync(cfgPath)) {
|
|
253
253
|
try {
|
|
254
|
-
|
|
255
|
-
if (loadedModules.length > 0) return loadedModules;
|
|
254
|
+
return readEnabledModulesFromConfig(cfgPath);
|
|
256
255
|
} catch (error) {
|
|
257
256
|
console.warn(
|
|
258
257
|
"[resolver] Failed to read enabled modules from src/modules.ts, falling back to src/modules scan:",
|
|
@@ -396,7 +395,7 @@ function createResolver(cwd = process.cwd()) {
|
|
|
396
395
|
loadEnabledModules: () => loadEnabledModulesFromConfig(appDir),
|
|
397
396
|
getModulePaths: (entry) => {
|
|
398
397
|
const appBase = path.resolve(appDir, "src/modules", entry.id);
|
|
399
|
-
const pkgModulesRoot = pkgDirFor(rootDir, entry.from, _isMonorepo);
|
|
398
|
+
const pkgModulesRoot = pkgDirFor(rootDir, entry.from, _isMonorepo, appDir);
|
|
400
399
|
const pkgBase = path.join(pkgModulesRoot, entry.id);
|
|
401
400
|
return { appBase, pkgBase };
|
|
402
401
|
},
|
|
@@ -411,11 +410,11 @@ function createResolver(cwd = process.cwd()) {
|
|
|
411
410
|
if (packageName === "@app") {
|
|
412
411
|
return path.join(appDir, ".mercato", "generated");
|
|
413
412
|
}
|
|
414
|
-
const pkgRoot = pkgRootFor(rootDir, packageName, _isMonorepo);
|
|
413
|
+
const pkgRoot = pkgRootFor(rootDir, packageName, _isMonorepo, appDir);
|
|
415
414
|
return path.join(pkgRoot, "generated");
|
|
416
415
|
},
|
|
417
416
|
getPackageRoot: (from) => {
|
|
418
|
-
return pkgRootFor(rootDir, from, _isMonorepo);
|
|
417
|
+
return pkgRootFor(rootDir, from, _isMonorepo, appDir);
|
|
419
418
|
}
|
|
420
419
|
};
|
|
421
420
|
}
|
|
@@ -428,7 +427,7 @@ function resolveEnvironment(cwd = process.cwd()) {
|
|
|
428
427
|
mode: _isMonorepo ? "monorepo" : "standalone",
|
|
429
428
|
rootDir,
|
|
430
429
|
appDir,
|
|
431
|
-
packageRoot: (packageName) => pkgRootFor(rootDir, packageName, _isMonorepo)
|
|
430
|
+
packageRoot: (packageName) => pkgRootFor(rootDir, packageName, _isMonorepo, appDir)
|
|
432
431
|
};
|
|
433
432
|
}
|
|
434
433
|
export {
|