@open-mercato/cli 0.9.1-develop.7553.1.8dbab05b5a → 0.9.1-develop.7566.1.b9de0a5eb7
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 +160 -154
- package/dist/agentic/guides/module-facts.v2.json +160 -154
- 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/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/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/customers/owned-contract-module-metadata.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_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/portal/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/modules/progress/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/modules/workflows/owned-contract-module-metadata.md +1 -1
- package/dist/agentic/guides/reference-module-facts.json +1 -1
- package/dist/agentic/guides/upstream/manifest.json +1 -1
- package/dist/mercato.js +13 -11
- package/dist/mercato.js.map +2 -2
- package/package.json +7 -7
- package/src/__tests__/mercato.test.ts +116 -0
- package/src/mercato.ts +14 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/cli",
|
|
3
|
-
"version": "0.9.1-develop.
|
|
3
|
+
"version": "0.9.1-develop.7566.1.b9de0a5eb7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"@mikro-orm/decorators": "^7.1.14",
|
|
61
61
|
"@mikro-orm/migrations": "^7.1.14",
|
|
62
62
|
"@mikro-orm/postgresql": "^7.1.14",
|
|
63
|
-
"@open-mercato/events": "0.9.1-develop.
|
|
64
|
-
"@open-mercato/queue": "0.9.1-develop.
|
|
65
|
-
"@open-mercato/shared": "0.9.1-develop.
|
|
66
|
-
"@open-mercato/telemetry": "0.9.1-develop.
|
|
63
|
+
"@open-mercato/events": "0.9.1-develop.7566.1.b9de0a5eb7",
|
|
64
|
+
"@open-mercato/queue": "0.9.1-develop.7566.1.b9de0a5eb7",
|
|
65
|
+
"@open-mercato/shared": "0.9.1-develop.7566.1.b9de0a5eb7",
|
|
66
|
+
"@open-mercato/telemetry": "0.9.1-develop.7566.1.b9de0a5eb7",
|
|
67
67
|
"cross-spawn": "^7.0.6",
|
|
68
68
|
"pg": "8.23.0",
|
|
69
69
|
"semver": "^7.8.5",
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
"typescript-js": "npm:typescript@6.0.3"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@open-mercato/shared": "0.9.1-develop.
|
|
77
|
+
"@open-mercato/shared": "0.9.1-develop.7566.1.b9de0a5eb7"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@open-mercato/shared": "0.9.1-develop.
|
|
80
|
+
"@open-mercato/shared": "0.9.1-develop.7566.1.b9de0a5eb7",
|
|
81
81
|
"@types/jest": "^30.0.0",
|
|
82
82
|
"jest": "^30.4.2",
|
|
83
83
|
"ts-jest": "^29.4.12"
|
|
@@ -789,6 +789,122 @@ describe('init command failure output', () => {
|
|
|
789
789
|
consoleErrorSpy.mockRestore()
|
|
790
790
|
consoleLogSpy.mockRestore()
|
|
791
791
|
})
|
|
792
|
+
|
|
793
|
+
function mockInitDependencies({
|
|
794
|
+
authSetup,
|
|
795
|
+
}: {
|
|
796
|
+
authSetup: jest.Mock
|
|
797
|
+
}) {
|
|
798
|
+
jest.doMock('child_process', () => ({
|
|
799
|
+
execSync: jest.fn(),
|
|
800
|
+
}))
|
|
801
|
+
jest.doMock('pg', () => ({
|
|
802
|
+
Client: jest.fn().mockImplementation(() => ({
|
|
803
|
+
connect: jest.fn().mockResolvedValue(undefined),
|
|
804
|
+
query: jest.fn().mockResolvedValue({
|
|
805
|
+
rows: [{ org_id: 'org-1', tenant_id: 'tenant-1' }],
|
|
806
|
+
}),
|
|
807
|
+
end: jest.fn().mockResolvedValue(undefined),
|
|
808
|
+
})),
|
|
809
|
+
}))
|
|
810
|
+
jest.doMock('../lib/generators', () => ({
|
|
811
|
+
generateEntityIds: jest.fn().mockResolvedValue(undefined),
|
|
812
|
+
generateModuleRegistries: jest.fn().mockResolvedValue(undefined),
|
|
813
|
+
generateModuleEntities: jest.fn().mockResolvedValue(undefined),
|
|
814
|
+
generateModuleDi: jest.fn().mockResolvedValue(undefined),
|
|
815
|
+
generateModulePackageSources: jest.fn().mockResolvedValue(undefined),
|
|
816
|
+
generateWebResearchAdapters: jest.fn().mockResolvedValue(undefined),
|
|
817
|
+
generateOpenApi: jest.fn().mockResolvedValue(undefined),
|
|
818
|
+
}))
|
|
819
|
+
jest.doMock('../lib/db', () => ({
|
|
820
|
+
dbMigrate: jest.fn().mockResolvedValue(undefined),
|
|
821
|
+
}))
|
|
822
|
+
jest.doMock('../lib/resolver', () => ({
|
|
823
|
+
createResolver: () => ({
|
|
824
|
+
getAppDir: () => '/tmp/test-app',
|
|
825
|
+
}),
|
|
826
|
+
}))
|
|
827
|
+
jest.doMock('@open-mercato/shared/lib/bootstrap/dynamicLoader', () => ({
|
|
828
|
+
bootstrapFromAppRoot: jest.fn().mockResolvedValue({
|
|
829
|
+
modules: [
|
|
830
|
+
{
|
|
831
|
+
id: 'configs',
|
|
832
|
+
cli: [{ command: 'restore-defaults', run: jest.fn().mockResolvedValue(undefined) }],
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
id: 'auth',
|
|
836
|
+
cli: [
|
|
837
|
+
{ command: 'setup', run: authSetup },
|
|
838
|
+
{ command: 'seed-roles', run: jest.fn().mockResolvedValue(undefined) },
|
|
839
|
+
],
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
id: 'entities',
|
|
843
|
+
cli: [{ command: 'seed-encryption', run: jest.fn().mockResolvedValue(undefined) }],
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
id: 'query_index',
|
|
847
|
+
cli: [{ command: 'reindex', run: jest.fn().mockResolvedValue(undefined) }],
|
|
848
|
+
},
|
|
849
|
+
],
|
|
850
|
+
}),
|
|
851
|
+
}))
|
|
852
|
+
jest.doMock('@open-mercato/shared/lib/di/container', () => ({
|
|
853
|
+
createRequestContainer: jest.fn().mockResolvedValue({
|
|
854
|
+
resolve: jest.fn().mockReturnValue({}),
|
|
855
|
+
}),
|
|
856
|
+
}))
|
|
857
|
+
jest.doMock(
|
|
858
|
+
'@open-mercato/core/modules/auth/lib/setup-app',
|
|
859
|
+
() => ({
|
|
860
|
+
ensureCustomRoleAcls: jest.fn().mockResolvedValue(undefined),
|
|
861
|
+
}),
|
|
862
|
+
{ virtual: true },
|
|
863
|
+
)
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
it('passes --include-demo-users to auth setup by default', async () => {
|
|
867
|
+
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
868
|
+
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
869
|
+
const authSetup = jest.fn().mockResolvedValue(undefined)
|
|
870
|
+
mockInitDependencies({ authSetup })
|
|
871
|
+
|
|
872
|
+
const mercato = await import('../mercato')
|
|
873
|
+
const exitCode = await mercato.run(['node', 'mercato', 'init'])
|
|
874
|
+
|
|
875
|
+
expect(exitCode).toBe(0)
|
|
876
|
+
expect(authSetup).toHaveBeenCalledWith(expect.arrayContaining(['--include-demo-users']))
|
|
877
|
+
expect(consoleLogSpy).toHaveBeenCalledWith('👤 Demo accounts (admin@/employee@): enabled')
|
|
878
|
+
const loggedLines = consoleLogSpy.mock.calls.map((args) => args.join(' '))
|
|
879
|
+
expect(loggedLines.some((line) => line.includes('🧰 Admin:'))).toBe(true)
|
|
880
|
+
expect(loggedLines.some((line) => line.includes('👷 Employee:'))).toBe(true)
|
|
881
|
+
|
|
882
|
+
consoleErrorSpy.mockRestore()
|
|
883
|
+
consoleLogSpy.mockRestore()
|
|
884
|
+
})
|
|
885
|
+
|
|
886
|
+
it('skips --include-demo-users when --no-demo-users is passed', async () => {
|
|
887
|
+
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation()
|
|
888
|
+
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation()
|
|
889
|
+
const authSetup = jest.fn().mockResolvedValue(undefined)
|
|
890
|
+
mockInitDependencies({ authSetup })
|
|
891
|
+
|
|
892
|
+
const mercato = await import('../mercato')
|
|
893
|
+
const exitCode = await mercato.run(['node', 'mercato', 'init', '--no-demo-users'])
|
|
894
|
+
|
|
895
|
+
expect(exitCode).toBe(0)
|
|
896
|
+
expect(authSetup).toHaveBeenCalled()
|
|
897
|
+
expect(authSetup.mock.calls[0][0]).not.toContain('--include-demo-users')
|
|
898
|
+
expect(consoleLogSpy).toHaveBeenCalledWith(
|
|
899
|
+
'👤 Demo accounts (admin@/employee@): skipped (--no-demo-users)',
|
|
900
|
+
)
|
|
901
|
+
const loggedLines = consoleLogSpy.mock.calls.map((args) => args.join(' '))
|
|
902
|
+
expect(loggedLines.some((line) => line.includes('🧰 Admin:'))).toBe(false)
|
|
903
|
+
expect(loggedLines.some((line) => line.includes('👷 Employee:'))).toBe(false)
|
|
904
|
+
|
|
905
|
+
consoleErrorSpy.mockRestore()
|
|
906
|
+
consoleLogSpy.mockRestore()
|
|
907
|
+
})
|
|
792
908
|
})
|
|
793
909
|
|
|
794
910
|
describe('seed:defaults command', () => {
|
package/src/mercato.ts
CHANGED
|
@@ -906,7 +906,7 @@ export function isHelpRequest(args: string[]): boolean {
|
|
|
906
906
|
// generic help branch. Without an entry here, `mercato init --help` runs a full install.
|
|
907
907
|
const TOP_LEVEL_COMMAND_HELP: Record<string, string[]> = {
|
|
908
908
|
init: [
|
|
909
|
-
'Usage: mercato init [--reinstall|-r] [--no-examples] [--stresstest [--lite] [--count=<n>]]',
|
|
909
|
+
'Usage: mercato init [--reinstall|-r] [--no-examples] [--no-demo-users] [--stresstest [--lite] [--count=<n>]]',
|
|
910
910
|
'Initializes this app: installs dependencies, runs generators, applies migrations and seeds data.',
|
|
911
911
|
],
|
|
912
912
|
'agentic:init': [
|
|
@@ -975,6 +975,7 @@ export async function run(argv = process.argv) {
|
|
|
975
975
|
delete process.env.OM_INIT_REINSTALL
|
|
976
976
|
}
|
|
977
977
|
const skipExamples = initArgs.includes('--no-examples')
|
|
978
|
+
const skipDemoUsers = initArgs.includes('--no-demo-users')
|
|
978
979
|
const stressTestEnabled =
|
|
979
980
|
initArgs.includes('--stresstest') || initArgs.includes('--stress-test')
|
|
980
981
|
const stressTestLite =
|
|
@@ -1015,6 +1016,7 @@ export async function run(argv = process.argv) {
|
|
|
1015
1016
|
}
|
|
1016
1017
|
console.log(`🔄 Reinstall mode: ${reinstall ? 'enabled' : 'disabled'}`)
|
|
1017
1018
|
console.log(`🎨 Example content: ${skipExamples ? 'skipped (--no-examples)' : 'enabled'}`)
|
|
1019
|
+
console.log(`👤 Demo accounts (admin@/employee@): ${skipDemoUsers ? 'skipped (--no-demo-users)' : 'enabled'}`)
|
|
1018
1020
|
console.log(
|
|
1019
1021
|
`🏋️ Stress test dataset: ${
|
|
1020
1022
|
stressTestEnabled
|
|
@@ -1205,10 +1207,10 @@ export async function run(argv = process.argv) {
|
|
|
1205
1207
|
const derivedSecrets = resolveInitDerivedSecrets({ email, env: process.env })
|
|
1206
1208
|
const adminEmailDerived = derivedSecrets.adminEmail
|
|
1207
1209
|
const employeeEmailDerived = derivedSecrets.employeeEmail
|
|
1208
|
-
if (adminEmailDerived && derivedSecrets.adminPassword) {
|
|
1210
|
+
if (!skipDemoUsers && adminEmailDerived && derivedSecrets.adminPassword) {
|
|
1209
1211
|
process.env.OM_INIT_ADMIN_PASSWORD = derivedSecrets.adminPassword
|
|
1210
1212
|
}
|
|
1211
|
-
if (employeeEmailDerived && derivedSecrets.employeePassword) {
|
|
1213
|
+
if (!skipDemoUsers && employeeEmailDerived && derivedSecrets.employeePassword) {
|
|
1212
1214
|
process.env.OM_INIT_EMPLOYEE_PASSWORD = derivedSecrets.employeePassword
|
|
1213
1215
|
}
|
|
1214
1216
|
const roles = findArgValue(['--roles='], 'superadmin,admin,employee')
|
|
@@ -1229,12 +1231,15 @@ export async function run(argv = process.argv) {
|
|
|
1229
1231
|
'--email', email,
|
|
1230
1232
|
'--password', password,
|
|
1231
1233
|
'--roles', roles,
|
|
1234
|
+
]
|
|
1235
|
+
if (!skipDemoUsers) {
|
|
1232
1236
|
// `mercato init` is the dev/demo bootstrap flow — it explicitly wants
|
|
1233
1237
|
// the derived admin@/employee@ demo accounts. Standalone callers of
|
|
1234
1238
|
// `mercato auth setup` must opt in themselves; without this flag the
|
|
1235
1239
|
// setup command no longer seeds those accounts by default.
|
|
1236
|
-
|
|
1237
|
-
|
|
1240
|
+
// `--no-demo-users` opts a caller (e.g. a production `init`) out of them.
|
|
1241
|
+
setupArgs.push('--include-demo-users')
|
|
1242
|
+
}
|
|
1238
1243
|
if (skipPasswordPolicy) {
|
|
1239
1244
|
setupArgs.push('--skip-password-policy')
|
|
1240
1245
|
}
|
|
@@ -1388,8 +1393,10 @@ export async function run(argv = process.argv) {
|
|
|
1388
1393
|
createdPasswords.set(value.toLowerCase(), passwordValue)
|
|
1389
1394
|
}
|
|
1390
1395
|
pushUser('Superadmin', '👑', email, password)
|
|
1391
|
-
|
|
1392
|
-
|
|
1396
|
+
if (!skipDemoUsers) {
|
|
1397
|
+
pushUser('Admin', '🧰', adminEmailDerived, adminPasswordOverride ?? password)
|
|
1398
|
+
pushUser('Employee', '👷', employeeEmailDerived, employeePasswordOverride ?? password)
|
|
1399
|
+
}
|
|
1393
1400
|
// Simplified success message: we know which users were created
|
|
1394
1401
|
console.log('🎉 App initialization complete!\n')
|
|
1395
1402
|
console.log('╔══════════════════════════════════════════════════════════════╗')
|