@beignet/cli 0.0.37 → 0.0.39
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/CHANGELOG.md +26 -0
- package/README.md +138 -101
- package/dist/choices.d.ts +17 -21
- package/dist/choices.d.ts.map +1 -1
- package/dist/choices.js +21 -67
- package/dist/choices.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/create-prompts.d.ts +5 -6
- package/dist/create-prompts.d.ts.map +1 -1
- package/dist/create-prompts.js +15 -15
- package/dist/create-prompts.js.map +1 -1
- package/dist/create.d.ts +11 -2
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +38 -28
- package/dist/create.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +149 -47
- package/dist/index.js.map +1 -1
- package/dist/inspect.js +69 -16
- package/dist/inspect.js.map +1 -1
- package/dist/lib.d.ts +1 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/lint.d.ts.map +1 -1
- package/dist/lint.js +27 -6
- package/dist/lint.js.map +1 -1
- package/dist/make/inbox.js +10 -10
- package/dist/make/inbox.js.map +1 -1
- package/dist/make/payments.d.ts +2 -1
- package/dist/make/payments.d.ts.map +1 -1
- package/dist/make/payments.js +18 -14
- package/dist/make/payments.js.map +1 -1
- package/dist/make/shared.d.ts +11 -4
- package/dist/make/shared.d.ts.map +1 -1
- package/dist/make/shared.js +56 -45
- package/dist/make/shared.js.map +1 -1
- package/dist/make/tenancy.js +8 -8
- package/dist/make/tenancy.js.map +1 -1
- package/dist/make.d.ts +3 -2
- package/dist/make.d.ts.map +1 -1
- package/dist/make.js +481 -200
- package/dist/make.js.map +1 -1
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +15 -11
- package/dist/mcp.js.map +1 -1
- package/dist/operational-error-reporting.d.ts +15 -0
- package/dist/operational-error-reporting.d.ts.map +1 -0
- package/dist/operational-error-reporting.js +42 -0
- package/dist/operational-error-reporting.js.map +1 -0
- package/dist/outbox.d.ts.map +1 -1
- package/dist/outbox.js +73 -0
- package/dist/outbox.js.map +1 -1
- package/dist/provider-add.d.ts +21 -3
- package/dist/provider-add.d.ts.map +1 -1
- package/dist/provider-add.js +117 -81
- package/dist/provider-add.js.map +1 -1
- package/dist/provider-audit.js +3 -3
- package/dist/provider-audit.js.map +1 -1
- package/dist/schedule.d.ts.map +1 -1
- package/dist/schedule.js +28 -1
- package/dist/schedule.js.map +1 -1
- package/dist/task.d.ts.map +1 -1
- package/dist/task.js +38 -5
- package/dist/task.js.map +1 -1
- package/dist/templates/base.d.ts +1 -1
- package/dist/templates/base.d.ts.map +1 -1
- package/dist/templates/base.js +15 -15
- package/dist/templates/base.js.map +1 -1
- package/dist/templates/index.d.ts +2 -2
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +7 -7
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/server.d.ts +1 -1
- package/dist/templates/server.d.ts.map +1 -1
- package/dist/templates/server.js +22 -18
- package/dist/templates/server.js.map +1 -1
- package/dist/templates/shared.d.ts +4 -4
- package/dist/templates/shared.d.ts.map +1 -1
- package/dist/templates/shared.js +6 -6
- package/dist/templates/shared.js.map +1 -1
- package/dist/templates/testing.js +1 -1
- package/dist/templates/todos.js +6 -6
- package/package.json +4 -4
- package/skills/app-structure/SKILL.md +13 -8
- package/src/choices.ts +38 -88
- package/src/config.ts +2 -2
- package/src/create-prompts.ts +20 -21
- package/src/create.ts +54 -36
- package/src/index.ts +193 -65
- package/src/inspect.ts +116 -18
- package/src/lib.ts +1 -1
- package/src/lint.ts +35 -4
- package/src/make/inbox.ts +10 -10
- package/src/make/payments.ts +26 -18
- package/src/make/shared.ts +72 -50
- package/src/make/tenancy.ts +8 -8
- package/src/make.ts +607 -191
- package/src/mcp.ts +20 -13
- package/src/operational-error-reporting.ts +60 -0
- package/src/outbox.ts +77 -0
- package/src/provider-add.ts +179 -95
- package/src/provider-audit.ts +3 -3
- package/src/schedule.ts +32 -1
- package/src/task.ts +42 -5
- package/src/templates/base.ts +16 -16
- package/src/templates/index.ts +8 -8
- package/src/templates/server.ts +22 -18
- package/src/templates/shared.ts +10 -10
- package/src/templates/testing.ts +1 -1
- package/src/templates/todos.ts +6 -6
- package/src/test-helpers/generated-app.ts +1 -0
package/src/make/shared.ts
CHANGED
|
@@ -45,8 +45,8 @@ export type ResourceNames = {
|
|
|
45
45
|
export type ResourceGenerationMode = "feature" | "resource";
|
|
46
46
|
|
|
47
47
|
export type ResourceGenerationOptions = {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
authorization: boolean;
|
|
49
|
+
tenantScoped: boolean;
|
|
50
50
|
events: boolean;
|
|
51
51
|
softDelete: boolean;
|
|
52
52
|
};
|
|
@@ -220,6 +220,13 @@ export type UploadNames = FeatureArtifactNames & {
|
|
|
220
220
|
uploadExportName: string;
|
|
221
221
|
metadataSchemaName: string;
|
|
222
222
|
metadataTypeName: string;
|
|
223
|
+
fileConstraintsExportName: string;
|
|
224
|
+
manifestExportName: string;
|
|
225
|
+
manifestFileName: string;
|
|
226
|
+
reactUploadsExportName: string;
|
|
227
|
+
clientFileName: string;
|
|
228
|
+
componentExportName: string;
|
|
229
|
+
componentFileName: string;
|
|
223
230
|
};
|
|
224
231
|
|
|
225
232
|
export type FeatureUiNames = ResourceNames & {
|
|
@@ -273,7 +280,7 @@ export type FileChangeSet = {
|
|
|
273
280
|
* A provider-backed app port a generator depends on.
|
|
274
281
|
*
|
|
275
282
|
* Generated code that publishes events or sends notifications needs the
|
|
276
|
-
* matching port in `AppPorts`, the key deferred in `infra/
|
|
283
|
+
* matching port in `AppPorts`, the key deferred in `infra/port-wiring.ts`, and a
|
|
277
284
|
* dev-default provider registered in `server/providers.ts`. Wiring is
|
|
278
285
|
* generation-time by design: the starter stays lean and each generator wires
|
|
279
286
|
* its own dependencies.
|
|
@@ -434,8 +441,13 @@ export function wireListenersProviderSource(
|
|
|
434
441
|
}
|
|
435
442
|
|
|
436
443
|
if (!new RegExp(`\\bconst\\s+${providerName}\\b`).test(next)) {
|
|
444
|
+
next = addNamedImport(
|
|
445
|
+
next,
|
|
446
|
+
"tryReportException",
|
|
447
|
+
"@beignet/core/error-reporting",
|
|
448
|
+
);
|
|
437
449
|
const providerDefinition = `const ${providerName} = createProvider<
|
|
438
|
-
\tPick<AppPorts, "eventBus" | "logger">,
|
|
450
|
+
\tPick<AppPorts, "errorReporter" | "eventBus" | "logger">,
|
|
439
451
|
\tAppContext,
|
|
440
452
|
\tAppServiceContextInput
|
|
441
453
|
>()({
|
|
@@ -451,6 +463,20 @@ export function wireListenersProviderSource(
|
|
|
451
463
|
\t\t\t\t\terror,
|
|
452
464
|
\t\t\t\t\tlistenerName: listener.name,
|
|
453
465
|
\t\t\t\t});
|
|
466
|
+
\t\t\t\tvoid tryReportException({
|
|
467
|
+
\t\t\t\t\treporter: ports.errorReporter,
|
|
468
|
+
\t\t\t\t\terror,
|
|
469
|
+
\t\t\t\t\treportOptions: {
|
|
470
|
+
\t\t\t\t\t\tlevel: "error",
|
|
471
|
+
\t\t\t\t\t\tmechanism: "beignet.listener",
|
|
472
|
+
\t\t\t\t\t\thandled: false,
|
|
473
|
+
\t\t\t\t\t\ttags: {
|
|
474
|
+
\t\t\t\t\t\t\t"beignet.kind": "listener",
|
|
475
|
+
\t\t\t\t\t\t\t"beignet.listener": listener.name,
|
|
476
|
+
\t\t\t\t\t\t},
|
|
477
|
+
\t\t\t\t\t\tcontexts: { listener: { name: listener.name } },
|
|
478
|
+
\t\t\t\t\t},
|
|
479
|
+
\t\t\t\t});
|
|
454
480
|
\t\t\t},
|
|
455
481
|
\t\t});
|
|
456
482
|
|
|
@@ -483,7 +509,7 @@ export function wireListenersProviderSource(
|
|
|
483
509
|
*
|
|
484
510
|
* Each wiring is independent and skipped silently when its port key already
|
|
485
511
|
* appears in the ports file, so apps that wired their own adapter (or scaffolds
|
|
486
|
-
* whose
|
|
512
|
+
* whose providers already contribute the port) are left untouched. All
|
|
487
513
|
* anchors are computed before any file is written; an anchor miss aborts with a
|
|
488
514
|
* copy-pasteable manual instruction so the generator never leaves partial
|
|
489
515
|
* wiring behind. Callers validate anchors with `dryRun: true` before writing
|
|
@@ -496,7 +522,7 @@ export async function wirePortProviders(
|
|
|
496
522
|
options: { dryRun: boolean },
|
|
497
523
|
): Promise<{ updatedFiles: string[] }> {
|
|
498
524
|
const portsFile = config.paths.ports;
|
|
499
|
-
const infrastructureFile = config.paths.
|
|
525
|
+
const infrastructureFile = config.paths.portWiring;
|
|
500
526
|
const providersFile = providersFilePath(config);
|
|
501
527
|
const manualFor = (wiring: PortProviderWiring) =>
|
|
502
528
|
`Wire the ${wiring.portKey} port manually: add ${wiring.portKey}: ${wiring.portType}; to AppPorts in ${portsFile}, defer "${wiring.portKey}" in ${infrastructureFile}, and register ${wiring.providerFactory}() from ${wiring.providerModule} in ${providersFile}.`;
|
|
@@ -510,7 +536,7 @@ export async function wirePortProviders(
|
|
|
510
536
|
}
|
|
511
537
|
|
|
512
538
|
// A port key that already appears in the ports file means the app wired its
|
|
513
|
-
// own adapter or
|
|
539
|
+
// own adapter or a provider already contributes the port.
|
|
514
540
|
const active = wirings.filter(
|
|
515
541
|
(wiring) => !new RegExp(`\\b${wiring.portKey}\\b`).test(portsOriginal),
|
|
516
542
|
);
|
|
@@ -536,7 +562,7 @@ export async function wirePortProviders(
|
|
|
536
562
|
);
|
|
537
563
|
if (infrastructureOriginal === undefined) {
|
|
538
564
|
throw new Error(
|
|
539
|
-
`Could not find the generated
|
|
565
|
+
`Could not find the generated port wiring file ${infrastructureFile}. ${manualFor(active[0])}`,
|
|
540
566
|
);
|
|
541
567
|
}
|
|
542
568
|
|
|
@@ -548,7 +574,7 @@ export async function wirePortProviders(
|
|
|
548
574
|
!new RegExp(`["']${wiring.portKey}["']`).test(infrastructureNext)
|
|
549
575
|
) {
|
|
550
576
|
throw new Error(
|
|
551
|
-
`Could not find the deferred port list in ${infrastructureFile}. ${manualFor(wiring)} Or restore the generated
|
|
577
|
+
`Could not find the deferred port list in ${infrastructureFile}. ${manualFor(wiring)} Or restore the generated port wiring file before running beignet ${wiring.command}.`,
|
|
552
578
|
);
|
|
553
579
|
}
|
|
554
580
|
infrastructureNext = appended;
|
|
@@ -651,7 +677,7 @@ export async function assertStandardApp(
|
|
|
651
677
|
): Promise<void> {
|
|
652
678
|
const requiredFiles = [
|
|
653
679
|
config.paths.appContext,
|
|
654
|
-
config.paths.
|
|
680
|
+
config.paths.portWiring,
|
|
655
681
|
config.paths.ports,
|
|
656
682
|
config.paths.server,
|
|
657
683
|
config.paths.useCaseBuilder,
|
|
@@ -688,7 +714,7 @@ export async function assertTestApp(
|
|
|
688
714
|
): Promise<void> {
|
|
689
715
|
const requiredFiles = [
|
|
690
716
|
config.paths.appContext,
|
|
691
|
-
config.paths.
|
|
717
|
+
config.paths.portWiring,
|
|
692
718
|
useCaseFilePath(names, config),
|
|
693
719
|
];
|
|
694
720
|
|
|
@@ -707,7 +733,7 @@ export async function assertPortApp(
|
|
|
707
733
|
targetDir: string,
|
|
708
734
|
config: ResolvedBeignetConfig,
|
|
709
735
|
): Promise<void> {
|
|
710
|
-
const requiredFiles = [config.paths.ports, config.paths.
|
|
736
|
+
const requiredFiles = [config.paths.ports, config.paths.portWiring];
|
|
711
737
|
|
|
712
738
|
for (const file of requiredFiles) {
|
|
713
739
|
try {
|
|
@@ -725,10 +751,7 @@ export async function assertAdapterApp(
|
|
|
725
751
|
names: PortNames,
|
|
726
752
|
config: ResolvedBeignetConfig,
|
|
727
753
|
): Promise<void> {
|
|
728
|
-
const requiredFiles = [
|
|
729
|
-
config.paths.infrastructurePorts,
|
|
730
|
-
portFilePath(names, config),
|
|
731
|
-
];
|
|
754
|
+
const requiredFiles = [config.paths.portWiring, portFilePath(names, config)];
|
|
732
755
|
|
|
733
756
|
for (const file of requiredFiles) {
|
|
734
757
|
try {
|
|
@@ -740,16 +763,16 @@ export async function assertAdapterApp(
|
|
|
740
763
|
}
|
|
741
764
|
}
|
|
742
765
|
|
|
743
|
-
const
|
|
744
|
-
path.join(targetDir, config.paths.
|
|
766
|
+
const portWiring = await readFile(
|
|
767
|
+
path.join(targetDir, config.paths.portWiring),
|
|
745
768
|
"utf8",
|
|
746
769
|
);
|
|
747
770
|
if (
|
|
748
|
-
!
|
|
749
|
-
!
|
|
771
|
+
!portWiring.includes(portStubEntry(names)) &&
|
|
772
|
+
!portWiring.includes(adapterEntry(names))
|
|
750
773
|
) {
|
|
751
774
|
throw new Error(
|
|
752
|
-
`Could not find the generated ${names.interfaceName} infrastructure stub in ${config.paths.
|
|
775
|
+
`Could not find the generated ${names.interfaceName} infrastructure stub in ${config.paths.portWiring}. Wire ${names.adapterFactoryName}() manually or restore the generated stub before running make adapter.`,
|
|
753
776
|
);
|
|
754
777
|
}
|
|
755
778
|
}
|
|
@@ -822,7 +845,7 @@ export async function assertServerRuntimeApp(
|
|
|
822
845
|
const requiredFiles = [
|
|
823
846
|
config.paths.appContext,
|
|
824
847
|
config.paths.server,
|
|
825
|
-
config.paths.
|
|
848
|
+
config.paths.portWiring,
|
|
826
849
|
];
|
|
827
850
|
|
|
828
851
|
for (const file of requiredFiles) {
|
|
@@ -1163,7 +1186,7 @@ export async function updatePortsIndex(
|
|
|
1163
1186
|
next = insertAfterImports(next, importLine);
|
|
1164
1187
|
}
|
|
1165
1188
|
|
|
1166
|
-
if (options.generationOptions?.
|
|
1189
|
+
if (options.generationOptions?.authorization) {
|
|
1167
1190
|
const policyPath = path.join(
|
|
1168
1191
|
config.paths.features,
|
|
1169
1192
|
names.pluralKebab,
|
|
@@ -1254,11 +1277,11 @@ export async function updateInfrastructurePortStub(
|
|
|
1254
1277
|
config: ResolvedBeignetConfig,
|
|
1255
1278
|
options: { dryRun: boolean },
|
|
1256
1279
|
): Promise<boolean> {
|
|
1257
|
-
const filePath = path.join(targetDir, config.paths.
|
|
1280
|
+
const filePath = path.join(targetDir, config.paths.portWiring);
|
|
1258
1281
|
const original = await readFile(filePath, "utf8");
|
|
1259
1282
|
let next = original;
|
|
1260
1283
|
const portPath = portFilePath(names, config);
|
|
1261
|
-
const importLine = `import type { ${names.interfaceName} } from "${relativeModule(config.paths.
|
|
1284
|
+
const importLine = `import type { ${names.interfaceName} } from "${relativeModule(config.paths.portWiring, portPath)}";`;
|
|
1262
1285
|
|
|
1263
1286
|
if (!next.includes(importLine)) {
|
|
1264
1287
|
next = insertAfterImports(next, importLine);
|
|
@@ -1273,7 +1296,7 @@ export async function updateInfrastructurePortStub(
|
|
|
1273
1296
|
next = insertDefinePortsProperty(
|
|
1274
1297
|
next,
|
|
1275
1298
|
entry.trim(),
|
|
1276
|
-
`Could not find definePorts({ in ${config.paths.
|
|
1299
|
+
`Could not find definePorts({ in ${config.paths.portWiring}. Add the ${names.interfaceName} stub manually, or restore the generated port wiring file before running make port.`,
|
|
1277
1300
|
);
|
|
1278
1301
|
}
|
|
1279
1302
|
|
|
@@ -1288,18 +1311,18 @@ export async function updateInfrastructureAdapterWiring(
|
|
|
1288
1311
|
config: ResolvedBeignetConfig,
|
|
1289
1312
|
options: { dryRun: boolean },
|
|
1290
1313
|
): Promise<boolean> {
|
|
1291
|
-
const filePath = path.join(targetDir, config.paths.
|
|
1314
|
+
const filePath = path.join(targetDir, config.paths.portWiring);
|
|
1292
1315
|
const original = await readFile(filePath, "utf8");
|
|
1293
1316
|
let next = original;
|
|
1294
1317
|
const adapterPath = adapterFilePath(names, config);
|
|
1295
|
-
const adapterImportLine = `import { ${names.adapterFactoryName} } from "${relativeModule(config.paths.
|
|
1318
|
+
const adapterImportLine = `import { ${names.adapterFactoryName} } from "${relativeModule(config.paths.portWiring, adapterPath)}";`;
|
|
1296
1319
|
|
|
1297
1320
|
if (!next.includes(adapterImportLine)) {
|
|
1298
1321
|
next = insertAfterImports(next, adapterImportLine);
|
|
1299
1322
|
}
|
|
1300
1323
|
|
|
1301
1324
|
const portPath = portFilePath(names, config);
|
|
1302
|
-
const portImportLine = `import type { ${names.interfaceName} } from "${relativeModule(config.paths.
|
|
1325
|
+
const portImportLine = `import type { ${names.interfaceName} } from "${relativeModule(config.paths.portWiring, portPath)}";`;
|
|
1303
1326
|
if (next.includes(portImportLine)) {
|
|
1304
1327
|
next = next.replace(`${portImportLine}\n`, "");
|
|
1305
1328
|
}
|
|
@@ -1310,7 +1333,7 @@ export async function updateInfrastructureAdapterWiring(
|
|
|
1310
1333
|
next = next.replace(stub, adapter);
|
|
1311
1334
|
} else if (!next.includes(adapter)) {
|
|
1312
1335
|
throw new Error(
|
|
1313
|
-
`Could not find the generated ${names.interfaceName} infrastructure stub in ${config.paths.
|
|
1336
|
+
`Could not find the generated ${names.interfaceName} infrastructure stub in ${config.paths.portWiring}. Wire ${names.adapterFactoryName}() manually or restore the generated stub before running make adapter.`,
|
|
1314
1337
|
);
|
|
1315
1338
|
}
|
|
1316
1339
|
|
|
@@ -1325,15 +1348,15 @@ export async function updateInfrastructurePorts(
|
|
|
1325
1348
|
config: ResolvedBeignetConfig,
|
|
1326
1349
|
options: { dryRun: boolean },
|
|
1327
1350
|
): Promise<boolean> {
|
|
1328
|
-
const filePath = path.join(targetDir, config.paths.
|
|
1351
|
+
const filePath = path.join(targetDir, config.paths.portWiring);
|
|
1329
1352
|
const original = await readFile(filePath, "utf8");
|
|
1330
1353
|
let next = original;
|
|
1331
1354
|
const repositoryPath = path.join(
|
|
1332
|
-
path.dirname(config.paths.
|
|
1355
|
+
path.dirname(config.paths.portWiring),
|
|
1333
1356
|
names.pluralKebab,
|
|
1334
1357
|
`in-memory-${names.singularKebab}-repository.ts`,
|
|
1335
1358
|
);
|
|
1336
|
-
const importLine = `import { createInMemory${names.singularPascal}Repository } from "${relativeModule(config.paths.
|
|
1359
|
+
const importLine = `import { createInMemory${names.singularPascal}Repository } from "${relativeModule(config.paths.portWiring, repositoryPath)}";`;
|
|
1337
1360
|
|
|
1338
1361
|
if (!next.includes(importLine)) {
|
|
1339
1362
|
next = insertAfterImports(next, importLine);
|
|
@@ -1343,9 +1366,9 @@ export async function updateInfrastructurePorts(
|
|
|
1343
1366
|
if (!next.includes(repositoryConst)) {
|
|
1344
1367
|
next = replaceRequired(
|
|
1345
1368
|
next,
|
|
1346
|
-
/(\nexport const
|
|
1369
|
+
/(\nexport const initialPorts = definePorts(?:<[^>]+>)?\((?:\)\()?\{)/,
|
|
1347
1370
|
`\n${repositoryConst}\n$1`,
|
|
1348
|
-
`Could not find definePorts({ in ${config.paths.
|
|
1371
|
+
`Could not find definePorts({ in ${config.paths.portWiring}. Add ${repositoryConst} manually, or restore the generated port wiring file before running make resource.`,
|
|
1349
1372
|
);
|
|
1350
1373
|
}
|
|
1351
1374
|
|
|
@@ -1358,7 +1381,7 @@ export async function updateInfrastructurePorts(
|
|
|
1358
1381
|
next = insertDefinePortsProperty(
|
|
1359
1382
|
next,
|
|
1360
1383
|
entry.trim(),
|
|
1361
|
-
`Could not find definePorts({ in ${config.paths.
|
|
1384
|
+
`Could not find definePorts({ in ${config.paths.portWiring}. Add ${entry.trim()} to initialPorts manually, or restore the generated port wiring file before running make resource.`,
|
|
1362
1385
|
);
|
|
1363
1386
|
}
|
|
1364
1387
|
|
|
@@ -1371,7 +1394,7 @@ export async function updateInfrastructurePorts(
|
|
|
1371
1394
|
next = insertNoopUnitOfWorkProperty(
|
|
1372
1395
|
next,
|
|
1373
1396
|
transactionEntry.trim(),
|
|
1374
|
-
`Could not find the generated Unit of Work port list in ${config.paths.
|
|
1397
|
+
`Could not find the generated Unit of Work port list in ${config.paths.portWiring}. Add ${transactionEntry.trim()} manually, or restore the generated port wiring file before running make resource.`,
|
|
1375
1398
|
);
|
|
1376
1399
|
}
|
|
1377
1400
|
|
|
@@ -1386,7 +1409,7 @@ export async function updateInfrastructureGatePolicies(
|
|
|
1386
1409
|
config: ResolvedBeignetConfig,
|
|
1387
1410
|
options: { dryRun: boolean },
|
|
1388
1411
|
): Promise<boolean> {
|
|
1389
|
-
const filePath = path.join(targetDir, config.paths.
|
|
1412
|
+
const filePath = path.join(targetDir, config.paths.portWiring);
|
|
1390
1413
|
const original = await readFile(filePath, "utf8");
|
|
1391
1414
|
let next = original;
|
|
1392
1415
|
const policyPath = path.join(
|
|
@@ -1394,7 +1417,7 @@ export async function updateInfrastructureGatePolicies(
|
|
|
1394
1417
|
names.pluralKebab,
|
|
1395
1418
|
"policy.ts",
|
|
1396
1419
|
);
|
|
1397
|
-
const importLine = `import { ${names.singularCamel}Policy } from "${relativeModule(config.paths.
|
|
1420
|
+
const importLine = `import { ${names.singularCamel}Policy } from "${relativeModule(config.paths.portWiring, policyPath)}";`;
|
|
1398
1421
|
|
|
1399
1422
|
if (!next.includes(importLine)) {
|
|
1400
1423
|
next = insertAfterImports(next, importLine);
|
|
@@ -1403,7 +1426,7 @@ export async function updateInfrastructureGatePolicies(
|
|
|
1403
1426
|
next = appendCreateGatePolicy(
|
|
1404
1427
|
next,
|
|
1405
1428
|
`${names.singularCamel}Policy`,
|
|
1406
|
-
`Could not find createGate({ policies: [...] }) in ${config.paths.
|
|
1429
|
+
`Could not find createGate({ policies: [...] }) in ${config.paths.portWiring}. Add ${names.singularCamel}Policy to the gate policies manually, or restore the generated port wiring file before running make resource --auth.`,
|
|
1407
1430
|
);
|
|
1408
1431
|
|
|
1409
1432
|
if (next === original) return false;
|
|
@@ -1713,7 +1736,7 @@ export async function updateInfrastructureDeferredPorts(
|
|
|
1713
1736
|
config: ResolvedBeignetConfig,
|
|
1714
1737
|
options: { dryRun: boolean },
|
|
1715
1738
|
): Promise<boolean> {
|
|
1716
|
-
const filePath = path.join(targetDir, config.paths.
|
|
1739
|
+
const filePath = path.join(targetDir, config.paths.portWiring);
|
|
1717
1740
|
const original = await readFile(filePath, "utf8");
|
|
1718
1741
|
// Drizzle resources are provided by the app database provider at startup,
|
|
1719
1742
|
// so deferred-form ports files defer the new repository key. Identity-form
|
|
@@ -1745,11 +1768,11 @@ export async function updateServerTransactionPorts(
|
|
|
1745
1768
|
|
|
1746
1769
|
if (!/\bappPorts\b/.test(next)) {
|
|
1747
1770
|
throw new Error(
|
|
1748
|
-
`Could not find
|
|
1771
|
+
`Could not find initialPorts in ${config.paths.server}. Add ${names.pluralCamel}: initialPorts.${names.pluralCamel} to createTransactionPorts manually, or restore the generated server file before running make resource.`,
|
|
1749
1772
|
);
|
|
1750
1773
|
}
|
|
1751
1774
|
|
|
1752
|
-
const entry = `\t\t\t\t\t\t${names.pluralCamel}:
|
|
1775
|
+
const entry = `\t\t\t\t\t\t${names.pluralCamel}: initialPorts.${names.pluralCamel},`;
|
|
1753
1776
|
next = insertDrizzleTransactionPortsProperty(
|
|
1754
1777
|
next,
|
|
1755
1778
|
entry.trim(),
|
|
@@ -2895,13 +2918,12 @@ export function artifactNameParts(
|
|
|
2895
2918
|
): [string, string] {
|
|
2896
2919
|
const parts = input
|
|
2897
2920
|
.trim()
|
|
2898
|
-
.split("
|
|
2899
|
-
.map((part) => part.trim())
|
|
2900
|
-
.filter(Boolean);
|
|
2921
|
+
.split(".")
|
|
2922
|
+
.map((part) => part.trim());
|
|
2901
2923
|
|
|
2902
|
-
if (parts.length !== 2) {
|
|
2924
|
+
if (parts.length !== 2 || parts.some((part) => part.length === 0)) {
|
|
2903
2925
|
throw new Error(
|
|
2904
|
-
`${label} name must use feature
|
|
2926
|
+
`${label} name must use feature.name format, for example posts.published.`,
|
|
2905
2927
|
);
|
|
2906
2928
|
}
|
|
2907
2929
|
|
|
@@ -3048,14 +3070,14 @@ export function adapterFilePath(
|
|
|
3048
3070
|
config: ResolvedBeignetConfig,
|
|
3049
3071
|
): string {
|
|
3050
3072
|
return path.join(
|
|
3051
|
-
path.dirname(config.paths.
|
|
3073
|
+
path.dirname(config.paths.portWiring),
|
|
3052
3074
|
names.kebab,
|
|
3053
3075
|
`${names.kebab}-adapter.ts`,
|
|
3054
3076
|
);
|
|
3055
3077
|
}
|
|
3056
3078
|
|
|
3057
3079
|
export function infrastructureDir(config: ResolvedBeignetConfig): string {
|
|
3058
|
-
return path.dirname(config.paths.
|
|
3080
|
+
return path.dirname(config.paths.portWiring);
|
|
3059
3081
|
}
|
|
3060
3082
|
|
|
3061
3083
|
export function drizzleSchemaIndexPath(config: ResolvedBeignetConfig): string {
|
package/src/make/tenancy.ts
CHANGED
|
@@ -330,7 +330,7 @@ export async function updateTenancyWiring(
|
|
|
330
330
|
if (
|
|
331
331
|
await updateWorkspaceInfrastructurePorts(targetDir, config, editOptions)
|
|
332
332
|
) {
|
|
333
|
-
updated.add(config.paths.
|
|
333
|
+
updated.add(config.paths.portWiring);
|
|
334
334
|
}
|
|
335
335
|
if (
|
|
336
336
|
await updateDrizzleSchemaIndexExports(
|
|
@@ -524,7 +524,7 @@ export async function updateWorkspaceInfrastructurePorts(
|
|
|
524
524
|
config: ResolvedBeignetConfig,
|
|
525
525
|
options: { dryRun: boolean },
|
|
526
526
|
): Promise<boolean> {
|
|
527
|
-
const filePath = path.join(targetDir, config.paths.
|
|
527
|
+
const filePath = path.join(targetDir, config.paths.portWiring);
|
|
528
528
|
const original = await readFile(filePath, "utf8");
|
|
529
529
|
let next = original;
|
|
530
530
|
|
|
@@ -532,21 +532,21 @@ export async function updateWorkspaceInfrastructurePorts(
|
|
|
532
532
|
const appended = appendDeferredPortKey(next, portKey);
|
|
533
533
|
if (appended === next && !new RegExp(`["']${portKey}["']`).test(next)) {
|
|
534
534
|
throw new Error(
|
|
535
|
-
`Could not find the deferred port list in ${config.paths.
|
|
535
|
+
`Could not find the deferred port list in ${config.paths.portWiring}. Add "${portKey}" manually, or restore the generated port wiring file before running make tenancy.`,
|
|
536
536
|
);
|
|
537
537
|
}
|
|
538
538
|
next = appended;
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
const policyModule = relativeModule(
|
|
542
|
-
config.paths.
|
|
542
|
+
config.paths.portWiring,
|
|
543
543
|
path.join(config.paths.features, "workspaces/policy.ts"),
|
|
544
544
|
);
|
|
545
545
|
next = addNamedImport(next, "workspacePolicy", policyModule);
|
|
546
546
|
next = appendCreateGatePolicy(
|
|
547
547
|
next,
|
|
548
548
|
"workspacePolicy",
|
|
549
|
-
`Could not find createGate({ policies: [...] }) in ${config.paths.
|
|
549
|
+
`Could not find createGate({ policies: [...] }) in ${config.paths.portWiring}. Add workspacePolicy to the gate policies manually, or restore the generated port wiring file before running make tenancy.`,
|
|
550
550
|
);
|
|
551
551
|
|
|
552
552
|
if (next === original) return false;
|
|
@@ -2274,7 +2274,7 @@ import type {
|
|
|
2274
2274
|
\tWorkspaceMemberWithUser,
|
|
2275
2275
|
\tWorkspaceRepository,
|
|
2276
2276
|
} from "@/features/workspaces/ports";
|
|
2277
|
-
import {
|
|
2277
|
+
import { initialPorts } from "@/infra/port-wiring";
|
|
2278
2278
|
import type { AppTransactionPorts } from "@/ports";
|
|
2279
2279
|
|
|
2280
2280
|
export type MemoryWorkspacePorts = {
|
|
@@ -2468,9 +2468,9 @@ export type WorkspaceTestFixture = TestPortsFixture<
|
|
|
2468
2468
|
export function createWorkspaceFixture(): WorkspaceTestFixture {
|
|
2469
2469
|
\tconst repositories = createMemoryWorkspacePorts();
|
|
2470
2470
|
\tconst fixture = createTestPorts<AppContext["ports"], AppTransactionPorts>({
|
|
2471
|
-
\t\tbase:
|
|
2471
|
+
\t\tbase: initialPorts,
|
|
2472
2472
|
\t\toverrides: {
|
|
2473
|
-
\t\t\tgate:
|
|
2473
|
+
\t\t\tgate: initialPorts.gate,
|
|
2474
2474
|
\t\t\t...repositories,
|
|
2475
2475
|
\t\t},
|
|
2476
2476
|
\t});
|