@open-mercato/cli 0.10.1-develop.7752.1.fd7c06569b → 0.10.1-develop.7756.1.8f5dec1b96
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/agentic/guides/module-facts.json +162 -162
- package/dist/agentic/guides/module-facts.v2.json +162 -162
- 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/lib/__integration__/TC-INT-007.spec.js +17 -2
- package/dist/lib/__integration__/TC-INT-007.spec.js.map +2 -2
- package/dist/lib/modules-config.js +40 -13
- package/dist/lib/modules-config.js.map +2 -2
- package/package.json +7 -7
- package/src/lib/__integration__/TC-INT-007.spec.ts +18 -2
- package/src/lib/__tests__/modules-config.test.ts +125 -0
- package/src/lib/modules-config.ts +50 -17
|
@@ -132,4 +132,129 @@ describe('modules-config', () => {
|
|
|
132
132
|
expect(updated).toContain("{ id: 'test_package', from: '@open-mercato/test-package' }")
|
|
133
133
|
expect(updated).toContain("enabledModules.push({ id: 'example_customers_sync', from: '@app' })")
|
|
134
134
|
})
|
|
135
|
+
|
|
136
|
+
describe('preserves the rest of the file when appending a module', () => {
|
|
137
|
+
const appendEntry = (source: string): string => {
|
|
138
|
+
const filePath = path.join(tmpDir, 'modules.ts')
|
|
139
|
+
fs.writeFileSync(filePath, source)
|
|
140
|
+
const result = ensureModuleRegistration(filePath, {
|
|
141
|
+
id: 'storage_s3',
|
|
142
|
+
from: '@open-mercato/storage-s3',
|
|
143
|
+
})
|
|
144
|
+
expect(result.changed).toBe(true)
|
|
145
|
+
return fs.readFileSync(filePath, 'utf8')
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
it('keeps line comments, block comments, blank lines and commented-out entries', () => {
|
|
149
|
+
const source = [
|
|
150
|
+
'// Central place to enable modules.',
|
|
151
|
+
'export const enabledModules: ModuleEntry[] = [',
|
|
152
|
+
" { id: 'auth', from: '@open-mercato/core' },",
|
|
153
|
+
' // customer_groups stays disabled by default:',
|
|
154
|
+
' // enabling it needs extra harness coverage.',
|
|
155
|
+
" // { id: 'customer_groups', from: '@open-mercato/core' },",
|
|
156
|
+
'',
|
|
157
|
+
' /* Communication channels hub.',
|
|
158
|
+
' * Provider packages register adapters here. */',
|
|
159
|
+
" { id: 'communication_channels', from: '@open-mercato/core' }, // trailing note",
|
|
160
|
+
" // { id: 'cart', from: '@open-mercato/core' },",
|
|
161
|
+
']',
|
|
162
|
+
'',
|
|
163
|
+
"if (process.env.OM_ENABLE_ENTERPRISE_MODULES === 'true') {",
|
|
164
|
+
" // enterprise modules",
|
|
165
|
+
" enabledModules.push({ id: 'record_locks', from: '@open-mercato/enterprise' })",
|
|
166
|
+
'}',
|
|
167
|
+
'',
|
|
168
|
+
].join('\n')
|
|
169
|
+
|
|
170
|
+
const updated = appendEntry(source)
|
|
171
|
+
|
|
172
|
+
expect(updated).toBe(
|
|
173
|
+
source.replace(
|
|
174
|
+
" { id: 'communication_channels', from: '@open-mercato/core' }, // trailing note\n",
|
|
175
|
+
" { id: 'communication_channels', from: '@open-mercato/core' }, // trailing note\n" +
|
|
176
|
+
" { id: 'storage_s3', from: '@open-mercato/storage-s3' },\n",
|
|
177
|
+
),
|
|
178
|
+
)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('adds a separating comma when the last element has none', () => {
|
|
182
|
+
const source = [
|
|
183
|
+
'export const enabledModules = [',
|
|
184
|
+
" { id: 'auth', from: '@open-mercato/core' } // no trailing comma",
|
|
185
|
+
' // closing comment',
|
|
186
|
+
']',
|
|
187
|
+
'',
|
|
188
|
+
].join('\n')
|
|
189
|
+
|
|
190
|
+
expect(appendEntry(source)).toBe(
|
|
191
|
+
[
|
|
192
|
+
'export const enabledModules = [',
|
|
193
|
+
" { id: 'auth', from: '@open-mercato/core' }, // no trailing comma",
|
|
194
|
+
" { id: 'storage_s3', from: '@open-mercato/storage-s3' }",
|
|
195
|
+
' // closing comment',
|
|
196
|
+
']',
|
|
197
|
+
'',
|
|
198
|
+
].join('\n'),
|
|
199
|
+
)
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
it('fills an empty array and keeps its comments', () => {
|
|
203
|
+
expect(appendEntry('export const enabledModules = []\n')).toBe(
|
|
204
|
+
"export const enabledModules = [\n { id: 'storage_s3', from: '@open-mercato/storage-s3' },\n]\n",
|
|
205
|
+
)
|
|
206
|
+
expect(
|
|
207
|
+
appendEntry('export const enabledModules = [\n // nothing yet\n]\n'),
|
|
208
|
+
).toBe(
|
|
209
|
+
"export const enabledModules = [\n // nothing yet\n { id: 'storage_s3', from: '@open-mercato/storage-s3' },\n]\n",
|
|
210
|
+
)
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
it('keeps CRLF line endings', () => {
|
|
214
|
+
const source = "export const enabledModules = [\r\n // core\r\n { id: 'auth', from: '@open-mercato/core' },\r\n]\r\n"
|
|
215
|
+
expect(appendEntry(source)).toBe(
|
|
216
|
+
"export const enabledModules = [\r\n // core\r\n { id: 'auth', from: '@open-mercato/core' },\r\n { id: 'storage_s3', from: '@open-mercato/storage-s3' },\r\n]\r\n",
|
|
217
|
+
)
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
it('handles a spread or a comma-less last element', () => {
|
|
221
|
+
expect(
|
|
222
|
+
appendEntry("export const enabledModules = [\n { id: 'auth' },\n ...officialModuleEntries,\n]\n"),
|
|
223
|
+
).toBe(
|
|
224
|
+
"export const enabledModules = [\n { id: 'auth' },\n ...officialModuleEntries,\n { id: 'storage_s3', from: '@open-mercato/storage-s3' },\n]\n",
|
|
225
|
+
)
|
|
226
|
+
expect(appendEntry("export const enabledModules = [\n { id: 'auth' }\n]\n")).toBe(
|
|
227
|
+
"export const enabledModules = [\n { id: 'auth' },\n { id: 'storage_s3', from: '@open-mercato/storage-s3' }\n]\n",
|
|
228
|
+
)
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
it('indents from the opening line when brackets share a line with elements', () => {
|
|
232
|
+
expect(appendEntry("export const enabledModules = [{ id: 'auth' }]\n")).toBe(
|
|
233
|
+
"export const enabledModules = [{ id: 'auth' },\n { id: 'storage_s3', from: '@open-mercato/storage-s3' }\n]\n",
|
|
234
|
+
)
|
|
235
|
+
expect(appendEntry("export const enabledModules = [\n { id: 'auth' },\n { id: 'directory' }]\n")).toBe(
|
|
236
|
+
"export const enabledModules = [\n { id: 'auth' },\n { id: 'directory' },\n { id: 'storage_s3', from: '@open-mercato/storage-s3' }\n]\n",
|
|
237
|
+
)
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
it('leaves the create-app template untouched apart from the new entry', () => {
|
|
241
|
+
const templatePath = path.resolve(__dirname, '../../../../create-app/template/src/modules.ts')
|
|
242
|
+
const source = fs.readFileSync(templatePath, 'utf8')
|
|
243
|
+
const filePath = path.join(tmpDir, 'modules.ts')
|
|
244
|
+
fs.writeFileSync(filePath, source)
|
|
245
|
+
const added = " { id: 'template_probe', from: '@open-mercato/template-probe' },\n"
|
|
246
|
+
|
|
247
|
+
expect(source).not.toContain('template_probe')
|
|
248
|
+
expect(
|
|
249
|
+
ensureModuleRegistration(filePath, { id: 'template_probe', from: '@open-mercato/template-probe' }).changed,
|
|
250
|
+
).toBe(true)
|
|
251
|
+
|
|
252
|
+
const updated = fs.readFileSync(filePath, 'utf8')
|
|
253
|
+
expect(updated.length).toBe(source.length + added.length)
|
|
254
|
+
expect(updated.replace(added, '')).toBe(source)
|
|
255
|
+
expect(updated.split('\n').filter((line) => line.trim().startsWith('//'))).toEqual(
|
|
256
|
+
source.split('\n').filter((line) => line.trim().startsWith('//')),
|
|
257
|
+
)
|
|
258
|
+
})
|
|
259
|
+
})
|
|
135
260
|
})
|
|
@@ -326,27 +326,60 @@ function lineIndentAt(source: string, position: number): string {
|
|
|
326
326
|
return match?.[0] ?? ''
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
function
|
|
329
|
+
function nextTokenEnd(source: string, position: number): number {
|
|
330
|
+
const scanner = ts.createScanner(ts.ScriptTarget.Latest, true, ts.LanguageVariant.Standard, source)
|
|
331
|
+
scanner.resetTokenState(position)
|
|
332
|
+
scanner.scan()
|
|
333
|
+
return scanner.getTokenEnd()
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function trailingCommentsEnd(source: string, position: number): number {
|
|
337
|
+
const ranges = ts.getTrailingCommentRanges(source, position) ?? []
|
|
338
|
+
return ranges.length > 0 ? ranges[ranges.length - 1].end : position
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function insertArrayElement(
|
|
330
342
|
source: string,
|
|
331
343
|
arrayNode: ts.ArrayLiteralExpression,
|
|
332
344
|
entry: ModuleEntry,
|
|
333
345
|
sourceFile: ts.SourceFile,
|
|
334
346
|
): string {
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
)
|
|
338
|
-
const
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
347
|
+
const newline = source.includes('\r\n') ? '\r\n' : '\n'
|
|
348
|
+
const entryLiteral = buildModuleEntryLiteral(entry)
|
|
349
|
+
const openingBracket = arrayNode.getStart(sourceFile)
|
|
350
|
+
const closingBracket = arrayNode.end - 1
|
|
351
|
+
const openingIndent = lineIndentAt(source, openingBracket)
|
|
352
|
+
const lastElement = arrayNode.elements[arrayNode.elements.length - 1]
|
|
353
|
+
|
|
354
|
+
let head: string
|
|
355
|
+
let insertAt: number
|
|
356
|
+
let insertion: string
|
|
357
|
+
|
|
358
|
+
if (!lastElement) {
|
|
359
|
+
const innerContent = source.slice(openingBracket + 1, closingBracket).trimEnd()
|
|
360
|
+
insertAt = openingBracket + 1 + innerContent.length
|
|
361
|
+
head = source.slice(0, insertAt)
|
|
362
|
+
insertion = `${newline}${openingIndent} ${entryLiteral},`
|
|
363
|
+
} else {
|
|
364
|
+
const hasTrailingComma = arrayNode.elements.hasTrailingComma
|
|
365
|
+
const anchor = hasTrailingComma ? nextTokenEnd(source, lastElement.end) : lastElement.end
|
|
366
|
+
insertAt = trailingCommentsEnd(source, anchor)
|
|
367
|
+
head = hasTrailingComma
|
|
368
|
+
? source.slice(0, insertAt)
|
|
369
|
+
: `${source.slice(0, anchor)},${source.slice(anchor, insertAt)}`
|
|
370
|
+
const lastElementStart = lastElement.getStart(sourceFile)
|
|
371
|
+
const startsOnOpeningLine = !source.slice(openingBracket, lastElementStart).includes('\n')
|
|
372
|
+
const elementIndent = startsOnOpeningLine
|
|
373
|
+
? `${openingIndent} `
|
|
374
|
+
: lineIndentAt(source, lastElementStart)
|
|
375
|
+
insertion = `${newline}${elementIndent}${entryLiteral}${hasTrailingComma ? ',' : ''}`
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const closesOnSameLine = !source.slice(insertAt, closingBracket).includes('\n')
|
|
379
|
+
const closingLine = closesOnSameLine ? `${newline}${openingIndent}` : ''
|
|
380
|
+
const tail = closesOnSameLine ? source.slice(closingBracket) : source.slice(insertAt)
|
|
381
|
+
|
|
382
|
+
return head + insertion + closingLine + tail
|
|
350
383
|
}
|
|
351
384
|
|
|
352
385
|
function upsertModuleSource(objectLiteral: string, from: string): string {
|
|
@@ -392,7 +425,7 @@ export function ensureModuleRegistration(
|
|
|
392
425
|
)
|
|
393
426
|
}
|
|
394
427
|
|
|
395
|
-
const updated =
|
|
428
|
+
const updated = insertArrayElement(source, config.arrayNode, normalized, sourceFile)
|
|
396
429
|
fs.writeFileSync(modulesPath, updated)
|
|
397
430
|
|
|
398
431
|
return { changed: true, registeredAs: normalized.from ?? '@open-mercato/core' }
|