@open-mercato/cli 0.10.1-develop.7753.1.61290f530d → 0.10.1-develop.7758.1.fb3a60392f
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 -0
- package/dist/lib/__integration__/TC-INT-007.spec.js.map +2 -2
- package/dist/lib/module-install.js +46 -8
- package/dist/lib/module-install.js.map +2 -2
- package/dist/lib/modules-config.js +100 -27
- package/dist/lib/modules-config.js.map +2 -2
- package/dist/lib/resolver.js +21 -1
- package/dist/lib/resolver.js.map +2 -2
- package/dist/mercato.js +19 -12
- package/dist/mercato.js.map +2 -2
- package/package.json +7 -7
- package/src/lib/__integration__/TC-INT-007.spec.ts +22 -0
- package/src/lib/__tests__/module-install.test.ts +220 -14
- package/src/lib/__tests__/modules-config.test.ts +273 -1
- package/src/lib/__tests__/resolver.enterprise.test.ts +60 -0
- package/src/lib/module-install.ts +54 -10
- package/src/lib/modules-config.ts +145 -36
- package/src/lib/resolver.ts +23 -1
- package/src/mercato.ts +19 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/cli",
|
|
3
|
-
"version": "0.10.1-develop.
|
|
3
|
+
"version": "0.10.1-develop.7758.1.fb3a60392f",
|
|
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.10.1-develop.
|
|
64
|
-
"@open-mercato/queue": "0.10.1-develop.
|
|
65
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
66
|
-
"@open-mercato/telemetry": "0.10.1-develop.
|
|
63
|
+
"@open-mercato/events": "0.10.1-develop.7758.1.fb3a60392f",
|
|
64
|
+
"@open-mercato/queue": "0.10.1-develop.7758.1.fb3a60392f",
|
|
65
|
+
"@open-mercato/shared": "0.10.1-develop.7758.1.fb3a60392f",
|
|
66
|
+
"@open-mercato/telemetry": "0.10.1-develop.7758.1.fb3a60392f",
|
|
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.10.1-develop.
|
|
77
|
+
"@open-mercato/shared": "0.10.1-develop.7758.1.fb3a60392f"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
80
|
+
"@open-mercato/shared": "0.10.1-develop.7758.1.fb3a60392f",
|
|
81
81
|
"@types/jest": "^30.0.0",
|
|
82
82
|
"jest": "^30.4.2",
|
|
83
83
|
"ts-jest": "^29.4.12"
|
|
@@ -241,4 +241,26 @@ test.describe('TC-INT-007: CLI official module install and eject flows', () => {
|
|
|
241
241
|
fs.rmSync(appDir, { recursive: true, force: true })
|
|
242
242
|
}
|
|
243
243
|
})
|
|
244
|
+
|
|
245
|
+
test('module add and module enable exit 0 without changes when the module is already enabled', () => {
|
|
246
|
+
const appDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-standalone-rerun-'))
|
|
247
|
+
|
|
248
|
+
try {
|
|
249
|
+
createStandaloneFixture(appDir)
|
|
250
|
+
runCommand(yarnBinary(), ['install'], appDir)
|
|
251
|
+
const packageSpec = `@open-mercato/test-package@file:${fixtureModulePackage}`
|
|
252
|
+
|
|
253
|
+
runMercato(['module', 'add', packageSpec], appDir)
|
|
254
|
+
const modulesSource = readFile(path.join(appDir, 'src', 'modules.ts'))
|
|
255
|
+
|
|
256
|
+
const addOutput = runMercato(['module', 'add', packageSpec], appDir)
|
|
257
|
+
const enableOutput = runMercato(['module', 'enable', '@open-mercato/test-package'], appDir)
|
|
258
|
+
|
|
259
|
+
expect(addOutput).toContain('is already enabled in modules.ts. Nothing to change.')
|
|
260
|
+
expect(enableOutput).toContain('is already enabled in modules.ts. Nothing to change.')
|
|
261
|
+
expect(readFile(path.join(appDir, 'src', 'modules.ts'))).toBe(modulesSource)
|
|
262
|
+
} finally {
|
|
263
|
+
fs.rmSync(appDir, { recursive: true, force: true })
|
|
264
|
+
}
|
|
265
|
+
})
|
|
244
266
|
})
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events'
|
|
1
2
|
import fs from 'node:fs'
|
|
2
3
|
import os from 'node:os'
|
|
3
4
|
import path from 'node:path'
|
|
4
5
|
import type { PackageResolver } from '../resolver'
|
|
5
6
|
import { addOfficialModule, enableOfficialModule } from '../module-install'
|
|
7
|
+
import * as modulesConfig from '../modules-config'
|
|
8
|
+
import spawn from 'cross-spawn'
|
|
9
|
+
|
|
10
|
+
jest.mock('cross-spawn', () => ({ __esModule: true, default: jest.fn() }))
|
|
11
|
+
|
|
12
|
+
const mockedSpawn = spawn as unknown as jest.Mock
|
|
6
13
|
|
|
7
14
|
function buildPackageFixture(
|
|
8
15
|
packageRoot: string,
|
|
@@ -70,7 +77,7 @@ describe('enableOfficialModule', () => {
|
|
|
70
77
|
fs.rmSync(tmpDir, { recursive: true, force: true })
|
|
71
78
|
})
|
|
72
79
|
|
|
73
|
-
it('
|
|
80
|
+
it('succeeds without changes when the module is already enabled with the same source', async () => {
|
|
74
81
|
const packageRoot = path.join(tmpDir, 'node_modules', '@open-mercato', 'test-package')
|
|
75
82
|
const appDir = path.join(tmpDir, 'app')
|
|
76
83
|
buildPackageFixture(packageRoot, 'test_package')
|
|
@@ -81,9 +88,17 @@ describe('enableOfficialModule', () => {
|
|
|
81
88
|
"export const enabledModules = [{ id: 'test_package', from: '@open-mercato/test-package' }]\n",
|
|
82
89
|
)
|
|
83
90
|
|
|
91
|
+
const modulesTsBefore = fs.readFileSync(resolver.getModulesConfigPath(), 'utf8')
|
|
92
|
+
|
|
84
93
|
await expect(
|
|
85
94
|
enableOfficialModule(resolver, '@open-mercato/test-package'),
|
|
86
|
-
).
|
|
95
|
+
).resolves.toEqual({
|
|
96
|
+
moduleId: 'test_package',
|
|
97
|
+
packageName: '@open-mercato/test-package',
|
|
98
|
+
from: '@open-mercato/test-package',
|
|
99
|
+
registrationChanged: false,
|
|
100
|
+
})
|
|
101
|
+
expect(fs.readFileSync(resolver.getModulesConfigPath(), 'utf8')).toBe(modulesTsBefore)
|
|
87
102
|
})
|
|
88
103
|
|
|
89
104
|
it('throws when module is already enabled with different casing in the source field', async () => {
|
|
@@ -104,7 +119,7 @@ describe('enableOfficialModule', () => {
|
|
|
104
119
|
).rejects.toThrow('already registered from')
|
|
105
120
|
})
|
|
106
121
|
|
|
107
|
-
it('
|
|
122
|
+
it('stays a no-op success when enable runs again for an enabled module', async () => {
|
|
108
123
|
const packageRoot = path.join(tmpDir, 'node_modules', '@open-mercato', 'test-package')
|
|
109
124
|
const appDir = path.join(tmpDir, 'app')
|
|
110
125
|
buildPackageFixture(packageRoot, 'test_package')
|
|
@@ -115,16 +130,14 @@ describe('enableOfficialModule', () => {
|
|
|
115
130
|
"export const enabledModules = [{ id: 'test_package', from: '@open-mercato/test-package' }]\n",
|
|
116
131
|
)
|
|
117
132
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
enableOfficialModule(resolver, '@open-mercato/test-package'),
|
|
124
|
-
).rejects.toThrow('"@open-mercato/test-package"')
|
|
133
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
134
|
+
await expect(
|
|
135
|
+
enableOfficialModule(resolver, '@open-mercato/test-package'),
|
|
136
|
+
).resolves.toMatchObject({ moduleId: 'test_package', registrationChanged: false })
|
|
137
|
+
}
|
|
125
138
|
})
|
|
126
139
|
|
|
127
|
-
it('
|
|
140
|
+
it('succeeds without changes when the specific module is already enabled in a multi-module package', async () => {
|
|
128
141
|
const packageRoot = path.join(tmpDir, 'node_modules', '@open-mercato', 'multi')
|
|
129
142
|
const appDir = path.join(tmpDir, 'app')
|
|
130
143
|
|
|
@@ -155,15 +168,15 @@ describe('enableOfficialModule', () => {
|
|
|
155
168
|
|
|
156
169
|
await expect(
|
|
157
170
|
enableOfficialModule(resolver, '@open-mercato/multi', 'alpha'),
|
|
158
|
-
).
|
|
171
|
+
).resolves.toMatchObject({ moduleId: 'alpha', registrationChanged: false })
|
|
159
172
|
|
|
160
|
-
// beta is not yet enabled — must not throw "already enabled", even if generators fail afterwards
|
|
161
173
|
try {
|
|
162
174
|
await enableOfficialModule(resolver, '@open-mercato/multi', 'beta')
|
|
163
175
|
} catch (error) {
|
|
164
176
|
const message = error instanceof Error ? error.message : String(error)
|
|
165
|
-
expect(message).
|
|
177
|
+
expect(message).toContain('Module "beta" is enabled')
|
|
166
178
|
}
|
|
179
|
+
expect(fs.readFileSync(resolver.getModulesConfigPath(), 'utf8')).toContain("id: 'beta'")
|
|
167
180
|
})
|
|
168
181
|
|
|
169
182
|
it('copies module source into the app when enabling with --eject', async () => {
|
|
@@ -206,6 +219,35 @@ describe('enableOfficialModule', () => {
|
|
|
206
219
|
)
|
|
207
220
|
})
|
|
208
221
|
|
|
222
|
+
it('rejects --eject for a module gated behind a disabled env flag before copying any source', async () => {
|
|
223
|
+
const originalFlag = process.env.OM_ENABLE_TEST_PACKAGE
|
|
224
|
+
delete process.env.OM_ENABLE_TEST_PACKAGE
|
|
225
|
+
const packageRoot = path.join(tmpDir, 'node_modules', '@open-mercato', 'test-package')
|
|
226
|
+
const appDir = path.join(tmpDir, 'app')
|
|
227
|
+
buildPackageFixture(packageRoot, 'test_package', { ejectable: true })
|
|
228
|
+
|
|
229
|
+
const resolver = buildResolver(
|
|
230
|
+
appDir,
|
|
231
|
+
packageRoot,
|
|
232
|
+
[
|
|
233
|
+
'export const enabledModules = []',
|
|
234
|
+
"if (process.env.OM_ENABLE_TEST_PACKAGE === 'true') {",
|
|
235
|
+
" enabledModules.push({ id: 'test_package', from: '@open-mercato/test-package' })",
|
|
236
|
+
'}',
|
|
237
|
+
].join('\n'),
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
await expect(
|
|
242
|
+
enableOfficialModule(resolver, '@open-mercato/test-package', undefined, true),
|
|
243
|
+
).rejects.toThrow('behind a condition that is currently off')
|
|
244
|
+
expect(fs.existsSync(path.join(appDir, 'src', 'modules', 'test_package'))).toBe(false)
|
|
245
|
+
} finally {
|
|
246
|
+
if (originalFlag === undefined) delete process.env.OM_ENABLE_TEST_PACKAGE
|
|
247
|
+
else process.env.OM_ENABLE_TEST_PACKAGE = originalFlag
|
|
248
|
+
}
|
|
249
|
+
})
|
|
250
|
+
|
|
209
251
|
it('rejects enabling with --eject when the package is not ejectable', async () => {
|
|
210
252
|
const packageRoot = path.join(tmpDir, 'node_modules', '@open-mercato', 'test-package')
|
|
211
253
|
const appDir = path.join(tmpDir, 'app')
|
|
@@ -301,3 +343,167 @@ describe('third-party module packages', () => {
|
|
|
301
343
|
)
|
|
302
344
|
})
|
|
303
345
|
})
|
|
346
|
+
|
|
347
|
+
describe('addOfficialModule', () => {
|
|
348
|
+
let tmpDir: string
|
|
349
|
+
|
|
350
|
+
beforeEach(() => {
|
|
351
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'module-install-add-test-'))
|
|
352
|
+
mockedSpawn.mockReset()
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
afterEach(() => {
|
|
356
|
+
fs.rmSync(tmpDir, { recursive: true, force: true })
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
function simulateYarnAdd(appDir: string, packageName: string): void {
|
|
360
|
+
mockedSpawn.mockImplementation(() => {
|
|
361
|
+
const child = new EventEmitter()
|
|
362
|
+
const packageJsonPath = path.join(appDir, 'package.json')
|
|
363
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) as {
|
|
364
|
+
dependencies?: Record<string, string>
|
|
365
|
+
}
|
|
366
|
+
packageJson.dependencies = { ...packageJson.dependencies, [packageName]: '0.1.0' }
|
|
367
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson))
|
|
368
|
+
setImmediate(() => child.emit('exit', 0))
|
|
369
|
+
return child
|
|
370
|
+
})
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function writeAppPackageJson(appDir: string, dependencies: Record<string, string> = {}): void {
|
|
374
|
+
fs.mkdirSync(appDir, { recursive: true })
|
|
375
|
+
fs.writeFileSync(path.join(appDir, 'package.json'), JSON.stringify({ name: 'test-app', dependencies }))
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
it('succeeds without changes when the module is already enabled', async () => {
|
|
379
|
+
const packageRoot = path.join(tmpDir, 'node_modules', '@open-mercato', 'test-package')
|
|
380
|
+
const appDir = path.join(tmpDir, 'app')
|
|
381
|
+
buildPackageFixture(packageRoot, 'test_package')
|
|
382
|
+
writeAppPackageJson(appDir, { '@open-mercato/test-package': '0.1.0' })
|
|
383
|
+
const resolver = buildResolver(
|
|
384
|
+
appDir,
|
|
385
|
+
packageRoot,
|
|
386
|
+
"export const enabledModules = [{ id: 'test_package', from: '@open-mercato/test-package' }]\n",
|
|
387
|
+
)
|
|
388
|
+
simulateYarnAdd(appDir, '@open-mercato/test-package')
|
|
389
|
+
const modulesTsBefore = fs.readFileSync(resolver.getModulesConfigPath(), 'utf8')
|
|
390
|
+
|
|
391
|
+
await expect(
|
|
392
|
+
addOfficialModule(resolver, '@open-mercato/test-package@0.1.0', false),
|
|
393
|
+
).resolves.toEqual({
|
|
394
|
+
moduleId: 'test_package',
|
|
395
|
+
packageName: '@open-mercato/test-package',
|
|
396
|
+
from: '@open-mercato/test-package',
|
|
397
|
+
registrationChanged: false,
|
|
398
|
+
})
|
|
399
|
+
expect(mockedSpawn).toHaveBeenCalledTimes(1)
|
|
400
|
+
expect(fs.readFileSync(resolver.getModulesConfigPath(), 'utf8')).toBe(modulesTsBefore)
|
|
401
|
+
})
|
|
402
|
+
|
|
403
|
+
it('tells the user how to remove a newly added package that has no modules', async () => {
|
|
404
|
+
const packageRoot = path.join(tmpDir, 'node_modules', '@open-mercato', 'no-modules')
|
|
405
|
+
const appDir = path.join(tmpDir, 'app')
|
|
406
|
+
fs.mkdirSync(packageRoot, { recursive: true })
|
|
407
|
+
fs.writeFileSync(
|
|
408
|
+
path.join(packageRoot, 'package.json'),
|
|
409
|
+
JSON.stringify({ name: '@open-mercato/no-modules', version: '0.1.0' }),
|
|
410
|
+
)
|
|
411
|
+
writeAppPackageJson(appDir)
|
|
412
|
+
const resolver = buildResolver(appDir, packageRoot, 'export const enabledModules = []\n')
|
|
413
|
+
simulateYarnAdd(appDir, '@open-mercato/no-modules')
|
|
414
|
+
|
|
415
|
+
const failure = addOfficialModule(resolver, '@open-mercato/no-modules', false)
|
|
416
|
+
await expect(failure).rejects.toThrow('has no modules in src/modules/ or dist/modules/.')
|
|
417
|
+
await expect(failure).rejects.toThrow(
|
|
418
|
+
'The package "@open-mercato/no-modules" stayed in package.json. To remove it, run: yarn remove @open-mercato/no-modules',
|
|
419
|
+
)
|
|
420
|
+
})
|
|
421
|
+
|
|
422
|
+
it('names the app workspace in the remove command inside a monorepo', async () => {
|
|
423
|
+
const packageRoot = path.join(tmpDir, 'node_modules', '@open-mercato', 'no-modules')
|
|
424
|
+
const appDir = path.join(tmpDir, 'apps', 'mercato')
|
|
425
|
+
fs.mkdirSync(packageRoot, { recursive: true })
|
|
426
|
+
fs.writeFileSync(
|
|
427
|
+
path.join(packageRoot, 'package.json'),
|
|
428
|
+
JSON.stringify({ name: '@open-mercato/no-modules', version: '0.1.0' }),
|
|
429
|
+
)
|
|
430
|
+
writeAppPackageJson(appDir)
|
|
431
|
+
const resolver = {
|
|
432
|
+
...buildResolver(appDir, packageRoot, 'export const enabledModules = []\n'),
|
|
433
|
+
isMonorepo: () => true,
|
|
434
|
+
getRootDir: () => tmpDir,
|
|
435
|
+
} as PackageResolver
|
|
436
|
+
simulateYarnAdd(appDir, '@open-mercato/no-modules')
|
|
437
|
+
|
|
438
|
+
await expect(addOfficialModule(resolver, '@open-mercato/no-modules', false)).rejects.toThrow(
|
|
439
|
+
'To remove it, run: yarn workspace test-app remove @open-mercato/no-modules',
|
|
440
|
+
)
|
|
441
|
+
})
|
|
442
|
+
|
|
443
|
+
it('does not suggest removing a package the app already depended on', async () => {
|
|
444
|
+
const packageRoot = path.join(tmpDir, 'node_modules', '@open-mercato', 'no-modules')
|
|
445
|
+
const appDir = path.join(tmpDir, 'app')
|
|
446
|
+
fs.mkdirSync(packageRoot, { recursive: true })
|
|
447
|
+
fs.writeFileSync(
|
|
448
|
+
path.join(packageRoot, 'package.json'),
|
|
449
|
+
JSON.stringify({ name: '@open-mercato/no-modules', version: '0.1.0' }),
|
|
450
|
+
)
|
|
451
|
+
writeAppPackageJson(appDir, { '@open-mercato/no-modules': '0.0.9' })
|
|
452
|
+
const resolver = buildResolver(appDir, packageRoot, 'export const enabledModules = []\n')
|
|
453
|
+
simulateYarnAdd(appDir, '@open-mercato/no-modules')
|
|
454
|
+
|
|
455
|
+
const failure = addOfficialModule(resolver, '@open-mercato/no-modules', false)
|
|
456
|
+
await expect(failure).rejects.toThrow('has no modules')
|
|
457
|
+
await expect(failure).rejects.not.toThrow('yarn remove')
|
|
458
|
+
})
|
|
459
|
+
|
|
460
|
+
it('rethrows a gated-off registration error without the leftover-package hint', async () => {
|
|
461
|
+
const packageRoot = path.join(tmpDir, 'node_modules', '@open-mercato', 'test-package')
|
|
462
|
+
const appDir = path.join(tmpDir, 'app')
|
|
463
|
+
buildPackageFixture(packageRoot, 'test_package')
|
|
464
|
+
writeAppPackageJson(appDir)
|
|
465
|
+
const resolver = buildResolver(appDir, packageRoot, 'export const enabledModules = []\n')
|
|
466
|
+
simulateYarnAdd(appDir, '@open-mercato/test-package')
|
|
467
|
+
const gatedOffError = Object.assign(
|
|
468
|
+
new Error('Module "test_package" is gated off. Enable it by setting OM_ENABLE_TEST_PACKAGE=true, then run `yarn generate`.'),
|
|
469
|
+
{ code: 'MODULE_GATED_OFF' },
|
|
470
|
+
)
|
|
471
|
+
const registrationSpy = jest
|
|
472
|
+
.spyOn(modulesConfig, 'ensureModuleRegistration')
|
|
473
|
+
.mockImplementation(() => {
|
|
474
|
+
throw gatedOffError
|
|
475
|
+
})
|
|
476
|
+
|
|
477
|
+
try {
|
|
478
|
+
const failure = addOfficialModule(resolver, '@open-mercato/test-package', false)
|
|
479
|
+
await expect(failure).rejects.toBe(gatedOffError)
|
|
480
|
+
await expect(failure).rejects.not.toThrow('stayed in package.json')
|
|
481
|
+
} finally {
|
|
482
|
+
registrationSpy.mockRestore()
|
|
483
|
+
}
|
|
484
|
+
})
|
|
485
|
+
|
|
486
|
+
it('keeps the leftover-package hint for a plain registration error on a newly added package', async () => {
|
|
487
|
+
const packageRoot = path.join(tmpDir, 'node_modules', '@open-mercato', 'test-package')
|
|
488
|
+
const appDir = path.join(tmpDir, 'app')
|
|
489
|
+
buildPackageFixture(packageRoot, 'test_package')
|
|
490
|
+
writeAppPackageJson(appDir)
|
|
491
|
+
const resolver = buildResolver(appDir, packageRoot, 'export const enabledModules = []\n')
|
|
492
|
+
simulateYarnAdd(appDir, '@open-mercato/test-package')
|
|
493
|
+
const registrationSpy = jest
|
|
494
|
+
.spyOn(modulesConfig, 'ensureModuleRegistration')
|
|
495
|
+
.mockImplementation(() => {
|
|
496
|
+
throw new Error('Could not update modules.ts.')
|
|
497
|
+
})
|
|
498
|
+
|
|
499
|
+
try {
|
|
500
|
+
const failure = addOfficialModule(resolver, '@open-mercato/test-package', false)
|
|
501
|
+
await expect(failure).rejects.toThrow('Could not update modules.ts.')
|
|
502
|
+
await expect(failure).rejects.toThrow(
|
|
503
|
+
'The package "@open-mercato/test-package" stayed in package.json. To remove it, run: yarn remove @open-mercato/test-package',
|
|
504
|
+
)
|
|
505
|
+
} finally {
|
|
506
|
+
registrationSpy.mockRestore()
|
|
507
|
+
}
|
|
508
|
+
})
|
|
509
|
+
})
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import os from 'node:os'
|
|
3
3
|
import path from 'node:path'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
assertModuleNotGatedOff,
|
|
6
|
+
ensureModuleRegistration,
|
|
7
|
+
ModuleGatedOffError,
|
|
8
|
+
setModuleRegistrationSource,
|
|
9
|
+
} from '../modules-config'
|
|
5
10
|
|
|
6
11
|
describe('modules-config', () => {
|
|
7
12
|
let tmpDir: string
|
|
@@ -133,6 +138,273 @@ describe('modules-config', () => {
|
|
|
133
138
|
expect(updated).toContain("enabledModules.push({ id: 'example_customers_sync', from: '@app' })")
|
|
134
139
|
})
|
|
135
140
|
|
|
141
|
+
describe('env-gated registrations', () => {
|
|
142
|
+
const flagNames = [
|
|
143
|
+
'OM_ENABLE_STORAGE_S3',
|
|
144
|
+
'OM_ENABLE_ENTERPRISE_MODULES',
|
|
145
|
+
'OM_ENABLE_ENTERPRISE_MODULES_SSO',
|
|
146
|
+
'OM_ENABLE_ENTERPRISE_MODULES_SECURITY',
|
|
147
|
+
'OM_ENABLE_ENTERPRISE_MODULES_AGENTS',
|
|
148
|
+
]
|
|
149
|
+
const originalEnv = Object.fromEntries(flagNames.map((name) => [name, process.env[name]]))
|
|
150
|
+
|
|
151
|
+
afterEach(() => {
|
|
152
|
+
for (const name of flagNames) {
|
|
153
|
+
if (originalEnv[name] === undefined) delete process.env[name]
|
|
154
|
+
else process.env[name] = originalEnv[name]
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
function writeGatedModulesFile(): string {
|
|
159
|
+
const filePath = path.join(tmpDir, 'modules.ts')
|
|
160
|
+
fs.writeFileSync(
|
|
161
|
+
filePath,
|
|
162
|
+
[
|
|
163
|
+
"import { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'",
|
|
164
|
+
'',
|
|
165
|
+
'export const enabledModules = [',
|
|
166
|
+
" { id: 'auth', from: '@open-mercato/core' },",
|
|
167
|
+
']',
|
|
168
|
+
'',
|
|
169
|
+
'if (parseBooleanWithDefault(process.env.OM_ENABLE_STORAGE_S3, false)) {',
|
|
170
|
+
" enabledModules.push({ id: 'storage_s3', from: '@open-mercato/storage-s3' })",
|
|
171
|
+
'}',
|
|
172
|
+
'',
|
|
173
|
+
'const enterpriseModulesEnabled = parseBooleanWithDefault(process.env.OM_ENABLE_ENTERPRISE_MODULES, false)',
|
|
174
|
+
'const enterpriseSsoEnabled = parseBooleanWithDefault(process.env.OM_ENABLE_ENTERPRISE_MODULES_SSO, false)',
|
|
175
|
+
'',
|
|
176
|
+
'if (enterpriseModulesEnabled && enterpriseSsoEnabled) {',
|
|
177
|
+
" enabledModules.push({ id: 'sso', from: '@open-mercato/enterprise' })",
|
|
178
|
+
'}',
|
|
179
|
+
].join('\n'),
|
|
180
|
+
)
|
|
181
|
+
return filePath
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
it('refuses to add a second entry for a module gated by a disabled env flag and names the flag', () => {
|
|
185
|
+
delete process.env.OM_ENABLE_STORAGE_S3
|
|
186
|
+
const filePath = writeGatedModulesFile()
|
|
187
|
+
const before = fs.readFileSync(filePath, 'utf8')
|
|
188
|
+
|
|
189
|
+
expect(() =>
|
|
190
|
+
ensureModuleRegistration(filePath, { id: 'storage_s3', from: '@open-mercato/storage-s3' }),
|
|
191
|
+
).toThrow(/storage_s3.*OM_ENABLE_STORAGE_S3=true/s)
|
|
192
|
+
expect(fs.readFileSync(filePath, 'utf8')).toBe(before)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
it('treats a gated module whose env flag is on as already registered', () => {
|
|
196
|
+
process.env.OM_ENABLE_STORAGE_S3 = 'true'
|
|
197
|
+
const filePath = writeGatedModulesFile()
|
|
198
|
+
const before = fs.readFileSync(filePath, 'utf8')
|
|
199
|
+
|
|
200
|
+
const result = ensureModuleRegistration(filePath, {
|
|
201
|
+
id: 'storage_s3',
|
|
202
|
+
from: '@open-mercato/storage-s3',
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
expect(result).toEqual({ changed: false, registeredAs: '@open-mercato/storage-s3' })
|
|
206
|
+
expect(fs.readFileSync(filePath, 'utf8')).toBe(before)
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
it('names only the env flags still off when a gate reads them through variables', () => {
|
|
210
|
+
process.env.OM_ENABLE_ENTERPRISE_MODULES = 'true'
|
|
211
|
+
delete process.env.OM_ENABLE_ENTERPRISE_MODULES_SSO
|
|
212
|
+
const filePath = writeGatedModulesFile()
|
|
213
|
+
|
|
214
|
+
let message = ''
|
|
215
|
+
try {
|
|
216
|
+
ensureModuleRegistration(filePath, { id: 'sso', from: '@open-mercato/enterprise' })
|
|
217
|
+
} catch (error) {
|
|
218
|
+
message = error instanceof Error ? error.message : String(error)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
expect(message).toContain('OM_ENABLE_ENTERPRISE_MODULES_SSO=true')
|
|
222
|
+
expect(message).not.toContain('OM_ENABLE_ENTERPRISE_MODULES=true')
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
it('covers every env-gated module of the create-app template', () => {
|
|
226
|
+
for (const name of flagNames) {
|
|
227
|
+
delete process.env[name]
|
|
228
|
+
}
|
|
229
|
+
const templatePath = path.resolve(__dirname, '../../../../create-app/template/src/modules.ts')
|
|
230
|
+
const filePath = path.join(tmpDir, 'modules.ts')
|
|
231
|
+
fs.copyFileSync(templatePath, filePath)
|
|
232
|
+
const before = fs.readFileSync(filePath, 'utf8')
|
|
233
|
+
|
|
234
|
+
const gatedModules: Array<{ id: string; from: string; flag: RegExp }> = [
|
|
235
|
+
{ id: 'storage_s3', from: '@open-mercato/storage-s3', flag: /OM_ENABLE_STORAGE_S3=true/ },
|
|
236
|
+
{ id: 'record_locks', from: '@open-mercato/enterprise', flag: /OM_ENABLE_ENTERPRISE_MODULES=true/ },
|
|
237
|
+
{ id: 'system_status_overlays', from: '@open-mercato/enterprise', flag: /OM_ENABLE_ENTERPRISE_MODULES=true/ },
|
|
238
|
+
{ id: 'sso', from: '@open-mercato/enterprise', flag: /OM_ENABLE_ENTERPRISE_MODULES_SSO=true/ },
|
|
239
|
+
{ id: 'security', from: '@open-mercato/enterprise', flag: /OM_ENABLE_ENTERPRISE_MODULES_SECURITY=true/ },
|
|
240
|
+
{ id: 'agent_orchestrator', from: '@open-mercato/enterprise', flag: /OM_ENABLE_ENTERPRISE_MODULES_AGENTS=true/ },
|
|
241
|
+
]
|
|
242
|
+
|
|
243
|
+
for (const gated of gatedModules) {
|
|
244
|
+
expect(() => ensureModuleRegistration(filePath, { id: gated.id, from: gated.from })).toThrow(gated.flag)
|
|
245
|
+
}
|
|
246
|
+
expect(fs.readFileSync(filePath, 'utf8')).toBe(before)
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
it('never suggests a flag value it cannot vouch for', () => {
|
|
250
|
+
process.env.OM_ENABLE_STORAGE_S3 = 'true'
|
|
251
|
+
const filePath = path.join(tmpDir, 'modules.ts')
|
|
252
|
+
fs.writeFileSync(
|
|
253
|
+
filePath,
|
|
254
|
+
[
|
|
255
|
+
"import { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'",
|
|
256
|
+
'',
|
|
257
|
+
'const enableS3 = parseBooleanWithDefault(process.env.OM_ENABLE_ENTERPRISE_MODULES, false)',
|
|
258
|
+
'const settings = { enableS3: false }',
|
|
259
|
+
'',
|
|
260
|
+
'export const enabledModules = []',
|
|
261
|
+
'',
|
|
262
|
+
'if (!parseBooleanWithDefault(process.env.OM_ENABLE_STORAGE_S3, false)) {',
|
|
263
|
+
" enabledModules.push({ id: 'negated', from: '@open-mercato/negated' })",
|
|
264
|
+
'}',
|
|
265
|
+
'',
|
|
266
|
+
'if (parseBooleanWithDefault(process.env.OM_ENABLE_STORAGE_S3, false)) {',
|
|
267
|
+
" enabledModules.push({ id: 'unrelated', from: '@open-mercato/unrelated' })",
|
|
268
|
+
'} else {',
|
|
269
|
+
" enabledModules.push({ id: 'fallback', from: '@open-mercato/fallback' })",
|
|
270
|
+
'}',
|
|
271
|
+
'',
|
|
272
|
+
'if (settings.enableS3) {',
|
|
273
|
+
" enabledModules.push({ id: 'property_gated', from: '@open-mercato/property-gated' })",
|
|
274
|
+
'}',
|
|
275
|
+
].join('\n'),
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
for (const id of ['negated', 'fallback', 'property_gated']) {
|
|
279
|
+
let message = ''
|
|
280
|
+
try {
|
|
281
|
+
ensureModuleRegistration(filePath, { id, from: `@open-mercato/${id.replace('_', '-')}` })
|
|
282
|
+
} catch (error) {
|
|
283
|
+
message = error instanceof Error ? error.message : String(error)
|
|
284
|
+
}
|
|
285
|
+
expect(message).toContain('Make that condition true to enable it.')
|
|
286
|
+
expect(message).not.toMatch(/=true/)
|
|
287
|
+
}
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
function readGatedOffError(filePath: string, id: string): ModuleGatedOffError {
|
|
291
|
+
try {
|
|
292
|
+
ensureModuleRegistration(filePath, { id, from: '@open-mercato/gated' })
|
|
293
|
+
} catch (error) {
|
|
294
|
+
if (error instanceof ModuleGatedOffError) return error
|
|
295
|
+
throw error
|
|
296
|
+
}
|
|
297
|
+
throw new Error(`[internal] expected module "${id}" to be gated off`)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function writeConditionFile(statements: string[]): string {
|
|
301
|
+
const filePath = path.join(tmpDir, 'modules.ts')
|
|
302
|
+
fs.writeFileSync(
|
|
303
|
+
filePath,
|
|
304
|
+
[
|
|
305
|
+
"import { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'",
|
|
306
|
+
'',
|
|
307
|
+
'const enterpriseEnabled = parseBooleanWithDefault(process.env.OM_ENABLE_ENTERPRISE_MODULES, false)',
|
|
308
|
+
'const s3Disabled = !parseBooleanWithDefault(process.env.OM_ENABLE_STORAGE_S3, false)',
|
|
309
|
+
'',
|
|
310
|
+
'export const enabledModules = []',
|
|
311
|
+
'',
|
|
312
|
+
...statements,
|
|
313
|
+
].join('\n'),
|
|
314
|
+
)
|
|
315
|
+
return filePath
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
it.each([
|
|
319
|
+
[
|
|
320
|
+
'a negated operand inside &&',
|
|
321
|
+
['if (enterpriseEnabled && !parseBooleanWithDefault(process.env.OM_ENABLE_STORAGE_S3, false)) {'],
|
|
322
|
+
],
|
|
323
|
+
['a comparison inside &&', ["if (enterpriseEnabled && process.env.OM_ENABLE_STORAGE_S3 !== 'true') {"]],
|
|
324
|
+
['a negated variable inside &&', ['if (enterpriseEnabled && s3Disabled) {']],
|
|
325
|
+
['a variable the parser does not know', ['if (enterpriseEnabled && unknownFlag) {']],
|
|
326
|
+
['an || condition', ['if (enterpriseEnabled || parseBooleanWithDefault(process.env.OM_ENABLE_ENTERPRISE_MODULES_SSO, false)) {']],
|
|
327
|
+
])('asks to make the condition true for %s', (_label, condition) => {
|
|
328
|
+
process.env.OM_ENABLE_STORAGE_S3 = 'true'
|
|
329
|
+
delete process.env.OM_ENABLE_ENTERPRISE_MODULES
|
|
330
|
+
delete process.env.OM_ENABLE_ENTERPRISE_MODULES_SSO
|
|
331
|
+
const filePath = writeConditionFile([
|
|
332
|
+
...condition,
|
|
333
|
+
" enabledModules.push({ id: 'gated', from: '@open-mercato/gated' })",
|
|
334
|
+
'}',
|
|
335
|
+
])
|
|
336
|
+
|
|
337
|
+
const error = readGatedOffError(filePath, 'gated')
|
|
338
|
+
expect(error.message).toContain('Make that condition true to enable it.')
|
|
339
|
+
expect(error.message).not.toMatch(/=true/)
|
|
340
|
+
expect(error.envFlags).toEqual([])
|
|
341
|
+
})
|
|
342
|
+
|
|
343
|
+
it('keeps an inner condition unvouched when the outer condition is not understood', () => {
|
|
344
|
+
process.env.OM_ENABLE_STORAGE_S3 = 'true'
|
|
345
|
+
delete process.env.OM_ENABLE_ENTERPRISE_MODULES
|
|
346
|
+
const filePath = writeConditionFile([
|
|
347
|
+
'if (s3Disabled) {',
|
|
348
|
+
' if (enterpriseEnabled) {',
|
|
349
|
+
" enabledModules.push({ id: 'gated', from: '@open-mercato/gated' })",
|
|
350
|
+
' }',
|
|
351
|
+
'}',
|
|
352
|
+
])
|
|
353
|
+
|
|
354
|
+
const error = readGatedOffError(filePath, 'gated')
|
|
355
|
+
expect(error.message).toContain('Make that condition true to enable it.')
|
|
356
|
+
expect(error.envFlags).toEqual([])
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
it('names the flags of nested positive conditions', () => {
|
|
360
|
+
delete process.env.OM_ENABLE_ENTERPRISE_MODULES
|
|
361
|
+
delete process.env.OM_ENABLE_ENTERPRISE_MODULES_SSO
|
|
362
|
+
const filePath = writeConditionFile([
|
|
363
|
+
'if (enterpriseEnabled) {',
|
|
364
|
+
' if (parseBooleanWithDefault(process.env.OM_ENABLE_ENTERPRISE_MODULES_SSO, false)) {',
|
|
365
|
+
" enabledModules.push({ id: 'gated', from: '@open-mercato/gated' })",
|
|
366
|
+
' }',
|
|
367
|
+
'}',
|
|
368
|
+
])
|
|
369
|
+
|
|
370
|
+
const error = readGatedOffError(filePath, 'gated')
|
|
371
|
+
expect(error.envFlags).toEqual(['OM_ENABLE_ENTERPRISE_MODULES', 'OM_ENABLE_ENTERPRISE_MODULES_SSO'])
|
|
372
|
+
expect(error.message).toContain('OM_ENABLE_ENTERPRISE_MODULES=true and OM_ENABLE_ENTERPRISE_MODULES_SSO=true')
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
it('throws a ModuleGatedOffError carrying the flags for a gated template module', () => {
|
|
376
|
+
delete process.env.OM_ENABLE_STORAGE_S3
|
|
377
|
+
const templatePath = path.resolve(__dirname, '../../../../create-app/template/src/modules.ts')
|
|
378
|
+
const filePath = path.join(tmpDir, 'modules.ts')
|
|
379
|
+
fs.copyFileSync(templatePath, filePath)
|
|
380
|
+
|
|
381
|
+
let thrown: unknown
|
|
382
|
+
try {
|
|
383
|
+
assertModuleNotGatedOff(filePath, 'storage_s3')
|
|
384
|
+
} catch (error) {
|
|
385
|
+
thrown = error
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
expect(thrown).toBeInstanceOf(ModuleGatedOffError)
|
|
389
|
+
const gatedOff = thrown as ModuleGatedOffError
|
|
390
|
+
expect(gatedOff.code).toBe('MODULE_GATED_OFF')
|
|
391
|
+
expect(gatedOff.moduleId).toBe('storage_s3')
|
|
392
|
+
expect(gatedOff.envFlags).toEqual(['OM_ENABLE_STORAGE_S3'])
|
|
393
|
+
expect(gatedOff.message).toContain('OM_ENABLE_STORAGE_S3=true')
|
|
394
|
+
expect(() => assertModuleNotGatedOff(filePath, 'auth')).not.toThrow()
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
it('ignores inactive gated entries when switching the source of an active registration', () => {
|
|
398
|
+
delete process.env.OM_ENABLE_STORAGE_S3
|
|
399
|
+
const filePath = writeGatedModulesFile()
|
|
400
|
+
|
|
401
|
+
expect(() => setModuleRegistrationSource(filePath, 'storage_s3', '@app')).toThrow(
|
|
402
|
+
/Could not find module entry for "storage_s3"/,
|
|
403
|
+
)
|
|
404
|
+
expect(setModuleRegistrationSource(filePath, 'auth', '@app')).toEqual({ changed: true })
|
|
405
|
+
})
|
|
406
|
+
})
|
|
407
|
+
|
|
136
408
|
describe('preserves the rest of the file when appending a module', () => {
|
|
137
409
|
const appendEntry = (source: string): string => {
|
|
138
410
|
const filePath = path.join(tmpDir, 'modules.ts')
|