@domain-first/project-structure 8.8.0 → 8.9.1
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/README.md +3 -3
- package/dist/{526.js → 115.js} +210 -2
- package/dist/{947.js → 201.js} +483 -2
- package/dist/287.js +243 -298
- package/dist/38.js +1 -2
- package/dist/561.js +2 -3
- package/dist/agent-cli.d.ts +2 -1
- package/dist/agent-requests.d.ts +2 -0
- package/dist/graph.cjs +4 -0
- package/dist/graph.js +1 -2
- package/dist/in-memory-db.d.ts +9 -0
- package/dist/index.cjs +407 -258
- package/dist/index.js +1 -1
- package/dist/init.cjs +47 -45
- package/dist/init.js +1 -1
- package/dist/integration.cjs +408 -259
- package/dist/integration.js +1 -1
- package/dist/integrations/drizzle.d.ts +8 -0
- package/dist/integrations/drizzle.spec.d.ts +1 -0
- package/dist/integrations/index.d.ts +1 -0
- package/dist/integrations/testcontainers.d.ts +1 -1
- package/dist/lint.cjs +4 -0
- package/dist/lint.js +1 -1
- package/dist/react.cjs +407 -258
- package/dist/react.js +1 -1
- package/dist/upgrade-in-memory-db.d.ts +7 -0
- package/dist/upgrade-in-memory-db.spec.d.ts +1 -0
- package/dist/upgrade.cjs +93 -27
- package/dist/upgrade.js +25 -3
- package/dist/use-cases/add-integration.d.ts +3 -3
- package/package.json +1 -1
- package/skills/df-ps-project-scripts/SKILL.md +22 -5
- package/skills/df-ps-scaffold/references/agent-operations.md +2 -1
- package/skills/df-ps-scaffold/references/generators.md +1 -1
- package/dist/780.js +0 -481
package/dist/react.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
3
|
import { select as prompts_select } from "@inquirer/prompts";
|
|
4
4
|
import { runCLI } from "./561.js";
|
|
5
|
-
import { outdatedConfigMessage, ProjectRoot, ConfigFile, Folder } from "./
|
|
5
|
+
import { outdatedConfigMessage, ProjectRoot, ConfigFile, Folder } from "./201.js";
|
|
6
6
|
import { scaffoldReactWidget, moveReactModuleUseCase, deleteReactModuleUseCase, scaffoldReactPage, scaffoldReactUIKitComponent, scaffoldReactSharedHook, savePendingChanges } from "./287.js";
|
|
7
7
|
runCLI('df-react', async ()=>{
|
|
8
8
|
const help = `Usage: df-react
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UpgradeStep } from './upgrade-steps';
|
|
2
|
+
/**
|
|
3
|
+
* Fixes `withId` of the generated in-memory DB: items saved as an
|
|
4
|
+
* `[id, item]` tuple have no `id` of their own and were never found.
|
|
5
|
+
* Only the untouched generated lookup is replaced.
|
|
6
|
+
*/
|
|
7
|
+
export declare const inMemoryDbWithIdStep: UpgradeStep;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/upgrade.cjs
CHANGED
|
@@ -172,7 +172,7 @@ class FileSystemItem {
|
|
|
172
172
|
return external_node_fs_default().existsSync(this.path);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
class
|
|
175
|
+
class file_system_File extends FileSystemItem {
|
|
176
176
|
get exists() {
|
|
177
177
|
return pendingFiles.has(this.path) || pendingMoves.has(this.path) || external_node_fs_default().existsSync(this.path) && !pendingDeletions.has(this.path);
|
|
178
178
|
}
|
|
@@ -237,7 +237,7 @@ const implementationOptionsSchema = external_zod_default().object({
|
|
|
237
237
|
])),
|
|
238
238
|
integrationTests: external_zod_default().array(implementationLabelSchema).optional()
|
|
239
239
|
}).strict();
|
|
240
|
-
class
|
|
240
|
+
class project_root_ProjectRoot {
|
|
241
241
|
path;
|
|
242
242
|
constructor(){
|
|
243
243
|
let dir = process.cwd();
|
|
@@ -319,7 +319,7 @@ class ConfigOutdatedError extends Error {
|
|
|
319
319
|
class config_file_ConfigFile {
|
|
320
320
|
data;
|
|
321
321
|
constructor(){
|
|
322
|
-
const raw = JSON.parse(new
|
|
322
|
+
const raw = JSON.parse(new file_system_File(config_file_ConfigFile.path).data);
|
|
323
323
|
if (isOutdatedConfig(raw)) throw new ConfigOutdatedError();
|
|
324
324
|
this.data = configSchema.parse(raw);
|
|
325
325
|
}
|
|
@@ -332,15 +332,15 @@ class config_file_ConfigFile {
|
|
|
332
332
|
return backend;
|
|
333
333
|
}
|
|
334
334
|
static get path() {
|
|
335
|
-
return external_node_path_default().resolve(new
|
|
335
|
+
return external_node_path_default().resolve(new project_root_ProjectRoot().path, configFileName);
|
|
336
336
|
}
|
|
337
337
|
static get exists() {
|
|
338
|
-
return new
|
|
338
|
+
return new file_system_File(config_file_ConfigFile.path).exists;
|
|
339
339
|
}
|
|
340
340
|
static get outdated() {
|
|
341
341
|
if (!config_file_ConfigFile.exists) return false;
|
|
342
342
|
try {
|
|
343
|
-
return isOutdatedConfig(JSON.parse(new
|
|
343
|
+
return isOutdatedConfig(JSON.parse(new file_system_File(config_file_ConfigFile.path).data));
|
|
344
344
|
} catch {
|
|
345
345
|
return false;
|
|
346
346
|
}
|
|
@@ -355,11 +355,11 @@ class config_file_ConfigFile {
|
|
|
355
355
|
}));
|
|
356
356
|
};
|
|
357
357
|
static stage(config) {
|
|
358
|
-
new
|
|
358
|
+
new file_system_File(config_file_ConfigFile.path).update(`${JSON.stringify(config, null, 4)}\n`);
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
const hasDependency = (name)=>{
|
|
362
|
-
const manifestFile = new
|
|
362
|
+
const manifestFile = new file_system_File(external_node_path_default().join(new project_root_ProjectRoot().path, 'package.json'));
|
|
363
363
|
if (!manifestFile.exists) return false;
|
|
364
364
|
const manifest = JSON.parse(manifestFile.data);
|
|
365
365
|
return [
|
|
@@ -368,6 +368,71 @@ const hasDependency = (name)=>{
|
|
|
368
368
|
manifest.optionalDependencies
|
|
369
369
|
].some((dependencies)=>dependencies && Object.hasOwn(dependencies, name));
|
|
370
370
|
};
|
|
371
|
+
new Map([
|
|
372
|
+
[
|
|
373
|
+
'prisma',
|
|
374
|
+
'prisma-infrastructure-service'
|
|
375
|
+
],
|
|
376
|
+
[
|
|
377
|
+
'drizzle',
|
|
378
|
+
'drizzle-infrastructure-service'
|
|
379
|
+
],
|
|
380
|
+
[
|
|
381
|
+
'in-memory',
|
|
382
|
+
'in-memory-db-infrastructure-service'
|
|
383
|
+
]
|
|
384
|
+
]);
|
|
385
|
+
const legacyWithIdLookup = ` withId: (id: TId): T | null =>
|
|
386
|
+
items().find(
|
|
387
|
+
(x: T) => hasId(x) && idsAreEqual(x.id as TId, id)
|
|
388
|
+
) ?? null,
|
|
389
|
+
`;
|
|
390
|
+
const legacyHasId = `const hasId = (x: unknown): x is { id: unknown } =>
|
|
391
|
+
typeof x === 'object' && x !== null && 'id' in x;
|
|
392
|
+
|
|
393
|
+
`;
|
|
394
|
+
const withIdLookup = ` withId: (id: TId): T | null =>
|
|
395
|
+
globalThis.___SHARED_IN_MEMORY_DB___![key].find((entry) =>
|
|
396
|
+
idsAreEqual(entry.id as TId, id)
|
|
397
|
+
)?.item ?? null,
|
|
398
|
+
`;
|
|
399
|
+
const uncountableEndings = [
|
|
400
|
+
'data',
|
|
401
|
+
'info',
|
|
402
|
+
'usage',
|
|
403
|
+
'feedback',
|
|
404
|
+
'media',
|
|
405
|
+
'ware',
|
|
406
|
+
'equipment',
|
|
407
|
+
'information',
|
|
408
|
+
'knowledge',
|
|
409
|
+
'traffic',
|
|
410
|
+
'telemetry',
|
|
411
|
+
'analytics',
|
|
412
|
+
'series'
|
|
413
|
+
];
|
|
414
|
+
new RegExp(`(${uncountableEndings.join('|')})$`, 'i');
|
|
415
|
+
const upgrade_in_memory_db_serviceFile = ({ config })=>{
|
|
416
|
+
const project = config.project;
|
|
417
|
+
const rootFolder = 'object' == typeof project && null !== project ? project.rootFolder : void 0;
|
|
418
|
+
if ('string' != typeof rootFolder) return;
|
|
419
|
+
const file = new file_system_File(external_node_path_default().join(new project_root_ProjectRoot().path, rootFolder, 'shared-kernel/infrastructure/services/in-memory-db-infrastructure-service.ts'));
|
|
420
|
+
return file.exists ? file : void 0;
|
|
421
|
+
};
|
|
422
|
+
const inMemoryDbWithIdStep = {
|
|
423
|
+
id: 'in-memory-db-with-id',
|
|
424
|
+
kind: 'optional',
|
|
425
|
+
title: 'Let withId of the in-memory DB find items saved as [id, item]',
|
|
426
|
+
detect: (context)=>upgrade_in_memory_db_serviceFile(context)?.data.includes(legacyWithIdLookup) ?? false,
|
|
427
|
+
plan: (context)=>[
|
|
428
|
+
`${external_node_path_default().relative(new project_root_ProjectRoot().path, upgrade_in_memory_db_serviceFile(context).path).split(external_node_path_default().sep).join('/')}: withId looks up the id saved with the item`
|
|
429
|
+
],
|
|
430
|
+
apply: (context)=>{
|
|
431
|
+
const file = upgrade_in_memory_db_serviceFile(context);
|
|
432
|
+
const fixed = file.data.replace(legacyWithIdLookup, withIdLookup);
|
|
433
|
+
file.update(/\bhasId\b/.test(fixed.replace(legacyHasId, '')) ? fixed : fixed.replace(legacyHasId, ''));
|
|
434
|
+
}
|
|
435
|
+
};
|
|
371
436
|
const openapiExtractorPath = "scripts/extract-open-api-data-from-endpoint.ts";
|
|
372
437
|
const rootFolderSegments = (rootFolder, indent = 20)=>rootFolder.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment && '.' !== segment).map((segment)=>`'${segment}',\n${' '.repeat(indent)}`).join('');
|
|
373
438
|
const legacyEndpointFileLookup = (rootFolder)=>` // The controller, if any, is the first folder of the path:
|
|
@@ -426,13 +491,13 @@ const ignoredFolders = new Set([
|
|
|
426
491
|
'storybook-static'
|
|
427
492
|
]);
|
|
428
493
|
const codeExtension = /\.(?:tsx?|mts|cts|jsx?|mjs|cjs|mdx)$/;
|
|
429
|
-
const
|
|
494
|
+
const module_move_walk = (folder)=>{
|
|
430
495
|
if (!external_node_fs_default().existsSync(folder)) return [];
|
|
431
496
|
return external_node_fs_default().readdirSync(folder, {
|
|
432
497
|
withFileTypes: true
|
|
433
498
|
}).flatMap((entry)=>{
|
|
434
499
|
const entryPath = external_node_path_default().join(folder, entry.name);
|
|
435
|
-
if (entry.isDirectory()) return ignoredFolders.has(entry.name) ? [] :
|
|
500
|
+
if (entry.isDirectory()) return ignoredFolders.has(entry.name) ? [] : module_move_walk(entryPath);
|
|
436
501
|
return entry.isFile() ? [
|
|
437
502
|
entryPath
|
|
438
503
|
] : [];
|
|
@@ -483,7 +548,7 @@ const projectImports = (projectRoot)=>{
|
|
|
483
548
|
const relative = toPosix(external_node_path_default().relative(external_node_path_default().dirname(fromFile), toPath));
|
|
484
549
|
return relative.startsWith('.') ? relative : `./${relative}`;
|
|
485
550
|
};
|
|
486
|
-
const codeFiles = new Map(
|
|
551
|
+
const codeFiles = new Map(module_move_walk(projectRoot).filter((file)=>codeExtension.test(file)).map((file)=>[
|
|
487
552
|
file,
|
|
488
553
|
external_node_fs_default().readFileSync(file, 'utf8')
|
|
489
554
|
]));
|
|
@@ -535,16 +600,16 @@ const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyF
|
|
|
535
600
|
moved: moves.has(oldFile)
|
|
536
601
|
});
|
|
537
602
|
};
|
|
538
|
-
for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new
|
|
603
|
+
for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new file_system_File(file).moveTo(newFile, stopFor(file));
|
|
539
604
|
const updated = [];
|
|
540
605
|
for (const [file, content] of codeFiles){
|
|
541
606
|
const newFile = moves.get(file);
|
|
542
607
|
const next = rewrite(content, file, newFile ?? file);
|
|
543
608
|
if (newFile && newFile !== file) {
|
|
544
|
-
new
|
|
545
|
-
new
|
|
609
|
+
new file_system_File(newFile).data = next;
|
|
610
|
+
new file_system_File(file).delete(stopFor(file));
|
|
546
611
|
} else if (next !== content) {
|
|
547
|
-
new
|
|
612
|
+
new file_system_File(file).update(next);
|
|
548
613
|
if (!newFile) updated.push(file);
|
|
549
614
|
}
|
|
550
615
|
}
|
|
@@ -588,13 +653,13 @@ const rootFolderOf = ({ config })=>{
|
|
|
588
653
|
const contextFolders = (context)=>{
|
|
589
654
|
const rootFolder = rootFolderOf(context);
|
|
590
655
|
if (!rootFolder) return [];
|
|
591
|
-
const contexts = external_node_path_default().join(new
|
|
656
|
+
const contexts = external_node_path_default().join(new project_root_ProjectRoot().path, rootFolder, 'bounded-contexts');
|
|
592
657
|
return external_node_fs_default().existsSync(contexts) ? external_node_fs_default().readdirSync(contexts, {
|
|
593
658
|
withFileTypes: true
|
|
594
659
|
}).filter((entry)=>entry.isDirectory()).map((entry)=>external_node_path_default().join(contexts, entry.name)) : [];
|
|
595
660
|
};
|
|
596
661
|
const legacyContexts = (context)=>contextFolders(context).filter(hasLegacyRootEndpoints);
|
|
597
|
-
const upgrade_rest_root_relative = (file)=>toPosix(external_node_path_default().relative(new
|
|
662
|
+
const upgrade_rest_root_relative = (file)=>toPosix(external_node_path_default().relative(new project_root_ProjectRoot().path, file));
|
|
598
663
|
const intoRoot = (folder, file)=>external_node_path_default().join(folder, "(root)", external_node_path_default().relative(folder, file));
|
|
599
664
|
const rootMoves = (contextFolder)=>{
|
|
600
665
|
const { presentation, wiring } = restFolders(contextFolder);
|
|
@@ -603,7 +668,7 @@ const rootMoves = (contextFolder)=>{
|
|
|
603
668
|
files: [
|
|
604
669
|
...[
|
|
605
670
|
...endpointFiles,
|
|
606
|
-
...parameterFolders.flatMap(
|
|
671
|
+
...parameterFolders.flatMap(module_move_walk)
|
|
607
672
|
].map((file)=>[
|
|
608
673
|
file,
|
|
609
674
|
intoRoot(presentation, file)
|
|
@@ -649,14 +714,14 @@ const restRootControllerStep = {
|
|
|
649
714
|
...files.map(([from, to])=>`${upgrade_rest_root_relative(from)} → ${upgrade_rest_root_relative(to)}`),
|
|
650
715
|
...wired ? [
|
|
651
716
|
`${upgrade_rest_root_relative(external_node_path_default().join(wiring, 'index.ts'))}: the context-root lines → one line for ./(root)`,
|
|
652
|
-
`${upgrade_rest_root_relative(external_node_path_default().join(new
|
|
717
|
+
`${upgrade_rest_root_relative(external_node_path_default().join(new project_root_ProjectRoot().path, rootFolderOf(context), 'presentation', 'rest', 'wires.ts'))}: the ${name} context-root lines → one line for (root), added if missing`
|
|
653
718
|
] : [],
|
|
654
719
|
'Imports of the moved files are rewritten'
|
|
655
720
|
];
|
|
656
721
|
}),
|
|
657
722
|
apply: (context)=>{
|
|
658
723
|
const contexts = legacyContexts(context);
|
|
659
|
-
const projectRoot = new
|
|
724
|
+
const projectRoot = new project_root_ProjectRoot().path;
|
|
660
725
|
const moves = new Map();
|
|
661
726
|
const folders = [];
|
|
662
727
|
for (const contextFolder of contexts){
|
|
@@ -686,15 +751,15 @@ const restRootControllerStep = {
|
|
|
686
751
|
},
|
|
687
752
|
rename: (content)=>content
|
|
688
753
|
});
|
|
689
|
-
const sharedWires = new
|
|
754
|
+
const sharedWires = new file_system_File(external_node_path_default().join(projectRoot, rootFolderOf(context), 'presentation', 'rest', 'wires.ts'));
|
|
690
755
|
for (const contextFolder of contexts){
|
|
691
756
|
const name = external_node_path_default().basename(contextFolder);
|
|
692
757
|
const { wiring } = restFolders(contextFolder);
|
|
693
758
|
const movedWires = legacyRootEndpoints(contextFolder).wireFiles;
|
|
694
759
|
if (!movedWires.length) continue;
|
|
695
|
-
const listed = regroupExports(new
|
|
760
|
+
const listed = regroupExports(new file_system_File(external_node_path_default().join(wiring, 'index.ts')), (specifier)=>specifier.startsWith("./(root)/"), "./(root)").map((line)=>line.replace("./(root)/", './'));
|
|
696
761
|
const unlisted = movedWires.map((file)=>`./${external_node_path_default().basename(file, '.ts')}`).filter((specifier)=>!listed.some((line)=>exportedSpecifier(line) === specifier)).map((specifier)=>`export * from '${specifier}'`);
|
|
697
|
-
new
|
|
762
|
+
new file_system_File(external_node_path_default().join(wiring, "(root)", 'index.ts')).data = [
|
|
698
763
|
...listed,
|
|
699
764
|
...unlisted
|
|
700
765
|
].join('\n');
|
|
@@ -703,7 +768,7 @@ const restRootControllerStep = {
|
|
|
703
768
|
}
|
|
704
769
|
}
|
|
705
770
|
};
|
|
706
|
-
const extractorFile = ()=>new
|
|
771
|
+
const extractorFile = ()=>new file_system_File(external_node_path_default().join(new project_root_ProjectRoot().path, openapiExtractorPath));
|
|
707
772
|
const openapiExtractorRootStep = {
|
|
708
773
|
id: 'openapi-extractor-root',
|
|
709
774
|
kind: 'optional',
|
|
@@ -856,7 +921,8 @@ const upgradeSteps = [
|
|
|
856
921
|
persistenceStep,
|
|
857
922
|
restRootControllerStep,
|
|
858
923
|
openapiExtractorRootStep,
|
|
859
|
-
openapiExtractorManualStep
|
|
924
|
+
openapiExtractorManualStep,
|
|
925
|
+
inMemoryDbWithIdStep
|
|
860
926
|
];
|
|
861
927
|
const skillsNote = 'Update the agent skills to this version: npx df-skills';
|
|
862
928
|
const planUpgrade = async (config, acceptOptional = ()=>true, steps = upgradeSteps)=>{
|
|
@@ -923,7 +989,7 @@ const printStep = ({ step, changes })=>{
|
|
|
923
989
|
for (const change of changes)console.log(` ${change}`);
|
|
924
990
|
};
|
|
925
991
|
const run = async ()=>{
|
|
926
|
-
const root = new
|
|
992
|
+
const root = new project_root_ProjectRoot().path;
|
|
927
993
|
const configPath = external_node_path_default().join(root, configFileName);
|
|
928
994
|
if (!config_file_ConfigFile.exists) {
|
|
929
995
|
console.log(`No ${configFileName} found: run df-init to initialize the project.`);
|
|
@@ -931,7 +997,7 @@ const run = async ()=>{
|
|
|
931
997
|
}
|
|
932
998
|
let raw;
|
|
933
999
|
try {
|
|
934
|
-
raw = JSON.parse(new
|
|
1000
|
+
raw = JSON.parse(new file_system_File(configPath).data);
|
|
935
1001
|
} catch {
|
|
936
1002
|
console.log(`${configFileName} is not valid JSON: fix it first.`);
|
|
937
1003
|
process.exit(1);
|
package/dist/upgrade.js
CHANGED
|
@@ -4,8 +4,29 @@ import { parseArgs } from "node:util";
|
|
|
4
4
|
import { confirm as prompts_confirm } from "@inquirer/prompts";
|
|
5
5
|
import zod from "zod";
|
|
6
6
|
import node_fs from "node:fs";
|
|
7
|
-
import { implementationLabelSchema, domainFirstPackages as config_file_domainFirstPackages, discardPendingChanges, configSchema, rulesSchema, ConfigFile, isOutdatedConfig, writePendingChanges, File, configFileName, ProjectRoot } from "./
|
|
8
|
-
import { restFolders, openapiExtractorPath, legacyEndpointFileLookup, walk, hasLegacyRootEndpoints, endpointFileLookup, hasDependency, stageModuleMove, legacyRootEndpoints, toPosix, codeExtension } from "./
|
|
7
|
+
import { implementationLabelSchema, domainFirstPackages as config_file_domainFirstPackages, discardPendingChanges, configSchema, rulesSchema, ConfigFile, isOutdatedConfig, writePendingChanges, File, configFileName, ProjectRoot } from "./201.js";
|
|
8
|
+
import { restFolders, withIdLookup, openapiExtractorPath, legacyEndpointFileLookup, walk, legacyHasId, legacyWithIdLookup, hasLegacyRootEndpoints, endpointFileLookup, hasDependency, stageModuleMove, legacyRootEndpoints, toPosix, codeExtension } from "./115.js";
|
|
9
|
+
const serviceFile = ({ config })=>{
|
|
10
|
+
const project = config.project;
|
|
11
|
+
const rootFolder = 'object' == typeof project && null !== project ? project.rootFolder : void 0;
|
|
12
|
+
if ('string' != typeof rootFolder) return;
|
|
13
|
+
const file = new File(node_path.join(new ProjectRoot().path, rootFolder, 'shared-kernel/infrastructure/services/in-memory-db-infrastructure-service.ts'));
|
|
14
|
+
return file.exists ? file : void 0;
|
|
15
|
+
};
|
|
16
|
+
const inMemoryDbWithIdStep = {
|
|
17
|
+
id: 'in-memory-db-with-id',
|
|
18
|
+
kind: 'optional',
|
|
19
|
+
title: 'Let withId of the in-memory DB find items saved as [id, item]',
|
|
20
|
+
detect: (context)=>serviceFile(context)?.data.includes(legacyWithIdLookup) ?? false,
|
|
21
|
+
plan: (context)=>[
|
|
22
|
+
`${node_path.relative(new ProjectRoot().path, serviceFile(context).path).split(node_path.sep).join('/')}: withId looks up the id saved with the item`
|
|
23
|
+
],
|
|
24
|
+
apply: (context)=>{
|
|
25
|
+
const file = serviceFile(context);
|
|
26
|
+
const fixed = file.data.replace(legacyWithIdLookup, withIdLookup);
|
|
27
|
+
file.update(/\bhasId\b/.test(fixed.replace(legacyHasId, '')) ? fixed : fixed.replace(legacyHasId, ''));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
9
30
|
const rootFolderOf = ({ config })=>{
|
|
10
31
|
const project = config.project;
|
|
11
32
|
const rootFolder = 'object' == typeof project && null !== project ? project.rootFolder : void 0;
|
|
@@ -282,7 +303,8 @@ const upgradeSteps = [
|
|
|
282
303
|
persistenceStep,
|
|
283
304
|
restRootControllerStep,
|
|
284
305
|
openapiExtractorRootStep,
|
|
285
|
-
openapiExtractorManualStep
|
|
306
|
+
openapiExtractorManualStep,
|
|
307
|
+
inMemoryDbWithIdStep
|
|
286
308
|
];
|
|
287
309
|
const skillsNote = 'Update the agent skills to this version: npx df-skills';
|
|
288
310
|
const planUpgrade = async (config, acceptOptional = ()=>true, steps = upgradeSteps)=>{
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Integrations are shown by group, but selected ones run in this order, each one seeing the changes of
|
|
3
3
|
* the previous ones: Storybook configures `frontend.react` for the Swagger UI page
|
|
4
|
-
* of OpenAPI, integration tests read the Prisma
|
|
4
|
+
* of OpenAPI, integration tests read the Prisma and Drizzle configs and the Vitest
|
|
5
5
|
* config, Orval reads the OpenAPI document path.
|
|
6
6
|
*/
|
|
7
|
-
export declare const integrationIds: readonly ["storybook", "rest-endpoint-generator", "in-memory-db", "prisma", "vitest", "playwright", "testcontainers", "openapi", "orval"];
|
|
7
|
+
export declare const integrationIds: readonly ["storybook", "rest-endpoint-generator", "in-memory-db", "prisma", "drizzle", "vitest", "playwright", "testcontainers", "openapi", "orval"];
|
|
8
8
|
export declare const addIntegration: ({ save }?: {
|
|
9
9
|
save?: boolean;
|
|
10
10
|
}) => Promise<string[]>;
|
|
11
11
|
export declare const integrationDescriptions: () => {
|
|
12
|
-
id: "prisma" | "openapi" | "orval" | "rest-endpoint-generator" | "storybook" | "vitest" | "testcontainers" | "in-memory-db" | "playwright";
|
|
12
|
+
id: "prisma" | "drizzle" | "openapi" | "orval" | "rest-endpoint-generator" | "storybook" | "vitest" | "testcontainers" | "in-memory-db" | "playwright";
|
|
13
13
|
name: string;
|
|
14
14
|
group: "backend" | "frontend";
|
|
15
15
|
available: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: df-ps-project-scripts
|
|
3
|
-
description: Rules for running this project's own scripts (package.json) and handling the files they produce — Prisma contract (`contract.prisma`, `prisma:emit`), database migrations (`prisma:migration:plan`, `prisma:migration:apply`), and other codegen. Use when a change needs new or changed database data (models, fields), when planning or creating a migration, when regenerating contract types, or when the user asks to run any project script that writes files.
|
|
3
|
+
description: Rules for running this project's own scripts (package.json) and handling the files they produce — Prisma contract (`contract.prisma`, `prisma:emit`), Drizzle schema (`schema.ts`), database migrations (`prisma:migration:plan`, `prisma:migration:apply`, `drizzle:generate`, `drizzle:migrate`), and other codegen. Use when a change needs new or changed database data (models, fields), when planning or creating a migration, when regenerating contract types, or when the user asks to run any project script that writes files.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Project scripts
|
|
@@ -9,9 +9,9 @@ The project's scripts live in `package.json`. Run them through `npm run <script>
|
|
|
9
9
|
|
|
10
10
|
## Rules
|
|
11
11
|
|
|
12
|
-
1. **No approval needed.** Files written by the project's own scripts (`prisma:emit`, `prisma:migration:plan`, …) aren't "new files" under `df-ps-scaffold` rule 1: run these scripts yourself when the work needs them. Still list them under "Tool runs" in a work plan so the user sees them coming, and report every run.
|
|
13
|
-
2. **The database is changed only by a human.** Never run `prisma:migration:apply` or anything else that touches the database (`prisma db
|
|
14
|
-
3. **Script output is never edited.** Generated migrations, `contract.json`, `contract.d.ts`, and any other output are used as-is: no edits, no deletions, no hand-written copies. Output is wrong → change the source (`contract.prisma`) and run the script again; if that can't fix it (a wrong migration already exists), stop and tell the user.
|
|
12
|
+
1. **No approval needed.** Files written by the project's own scripts (`prisma:emit`, `prisma:migration:plan`, `drizzle:generate`, …) aren't "new files" under `df-ps-scaffold` rule 1: run these scripts yourself when the work needs them. Still list them under "Tool runs" in a work plan so the user sees them coming, and report every run.
|
|
13
|
+
2. **The database is changed only by a human.** Never run `prisma:migration:apply`, `drizzle:migrate` or anything else that touches the database (`prisma db …`, `drizzle-kit push`). When a migration is ready, give the user the command (`! npm run prisma:migration:apply`, `! npm run drizzle:migrate`) and wait.
|
|
14
|
+
3. **Script output is never edited.** Generated migrations, `contract.json`, `contract.d.ts`, and any other output are used as-is: no edits, no deletions, no hand-written copies. Output is wrong → change the source (`contract.prisma`, `schema.ts`) and run the script again; if that can't fix it (a wrong migration already exists), stop and tell the user.
|
|
15
15
|
|
|
16
16
|
## Prisma
|
|
17
17
|
|
|
@@ -27,7 +27,7 @@ Config: `shared-kernel/infrastructure/prisma/prisma.config.ts`. Source: `shared-
|
|
|
27
27
|
|
|
28
28
|
Only when domain and application logic are implemented, and implementing an infrastructure module (repository, command/query) needs data the database doesn't have yet. Not earlier "just in case", and never as the first step of a feature: the domain decides what's stored, not the schema.
|
|
29
29
|
|
|
30
|
-
Order: domain → application → `contract.prisma` + migration → user applies it → infrastructure → endpoints → other codegen → React.
|
|
30
|
+
Order: domain → application → `contract.prisma` / `schema.ts` + migration → user applies it → infrastructure → endpoints → other codegen → React.
|
|
31
31
|
|
|
32
32
|
### Making a migration
|
|
33
33
|
|
|
@@ -38,3 +38,20 @@ Order: domain → application → `contract.prisma` + migration → user applies
|
|
|
38
38
|
5. Check the output: the planned files only, nothing else changed. Report each migration and ask the user to apply them before implementing the infrastructure that depends on them.
|
|
39
39
|
|
|
40
40
|
Types only (no storage change, e.g. after pulling someone's contract change): `npm run prisma:emit`.
|
|
41
|
+
|
|
42
|
+
## Drizzle
|
|
43
|
+
|
|
44
|
+
Config: `shared-kernel/infrastructure/drizzle/drizzle.config.ts`. Source: `shared-kernel/infrastructure/drizzle/schema.ts` (edit by hand, tables with `drizzle-orm/pg-core`). Output: `migrations/` next to it (SQL files and `meta/`, from `drizzle:generate`). The database is created in `shared-kernel/infrastructure/services/drizzle-infrastructure-service.ts`; implementations import tables from `schema.ts`.
|
|
45
|
+
|
|
46
|
+
| Script | Does | Who runs it |
|
|
47
|
+
| ------------------ | ------------------------------------------------------------ | ----------------- |
|
|
48
|
+
| `drizzle:generate` | Writes a SQL migration from the change in `schema.ts`. Offline. | You |
|
|
49
|
+
| `drizzle:migrate` | Applies migrations to the database. | **The user only** |
|
|
50
|
+
|
|
51
|
+
When to migrate: as for Prisma above.
|
|
52
|
+
|
|
53
|
+
1. Edit `schema.ts` for **one** logical change.
|
|
54
|
+
2. Generate it with a name by meaning: `npm run drizzle:generate -- --name add-user`.
|
|
55
|
+
3. Several changes → repeat 1–2 once per change.
|
|
56
|
+
4. When `drizzle:generate` asks whether a column or table is created or renamed, it waits for an answer you can't give: stop it, and ask the user to run `! npm run drizzle:generate -- --name <name>` and answer it.
|
|
57
|
+
5. Check the output: the new SQL file and `meta/` only. Report each migration and ask the user to apply them before implementing the infrastructure that depends on them.
|
|
@@ -139,9 +139,10 @@ Use `operation: "add"` and a nonempty `integrations` array. Select only IDs mark
|
|
|
139
139
|
| `rest-endpoint-generator` | Backend must have `@domain-first/handlers-rest`. `nextAdapter` applies only when `frontend.react.framework` is `next`; omitted means no Next adapter in JSON mode. Existing support files are preserved with a manual connection note as needed. |
|
|
140
140
|
| `in-memory-db` | Backend required. Enables the DB flag and restores missing support files while keeping edited files. No extra fields. |
|
|
141
141
|
| `prisma` | Backend required. `withService` defaults to true; false skips the infrastructure service and its wire. Registers `prisma` implementation choices. Existing incompatible Prisma setups are rejected rather than upgraded. |
|
|
142
|
+
| `drizzle` | Backend required. `withService` defaults to true; false skips the infrastructure service and its wire. Registers `drizzle` implementation choices. A `drizzle.config.*` in the project root is rejected as an existing setup. |
|
|
142
143
|
| `vitest` | Backend required. `replaceTestingLibrary` is required if a different testing library is configured; true changes it to Vitest, false skips this setup. |
|
|
143
144
|
| `playwright` | No extra integration-specific fields. Adds its config, example and scripts. |
|
|
144
|
-
| `testcontainers` | Backend required. With wire: optional `integrationTestTypes`, the saved primary types whose implementations get integration specs (omitted: the configured list stays); missing specs of existing primary implementations are added. Reads staged Prisma/Vitest setup when selected together. Database scripts are generated, not executed. |
|
|
145
|
+
| `testcontainers` | Backend required. With wire: optional `integrationTestTypes`, the saved primary types whose implementations get integration specs (omitted: the configured list stays); missing specs of existing primary implementations are added. Reads staged Prisma/Drizzle/Vitest setup when selected together. Database scripts are generated, not executed. |
|
|
145
146
|
| `openapi` | Backend with `handlers-rest`. `routePrefix` defaults to `/api`; `openapiPath` is computed from the project unless supplied. `withExtractor` defaults to true. `swaggerPage` applies only with React configured and defaults to true there; otherwise omit it. |
|
|
146
147
|
| `orval` | Requires configured `handlers-rest`. `openapiPath` is read from the staged/existing OpenAPI generator when omitted. With React configured, `targets` can be a nonempty list of `hooks`/`client` and defaults to `hooks`. Without React, omit `targets`: the typed client is generated automatically. |
|
|
147
148
|
|
|
@@ -35,7 +35,7 @@ Each chosen module goes into the wire (`wireClass(X, [wireUserRepository])`) and
|
|
|
35
35
|
|
|
36
36
|
An env-branched wire (repository, command/query, port) wires each implementation in isolation: it asks `Dependencies for <Implementation>:` once per implementation, in the order of the wire (main, then test). Each list leaves out only what that implementation already has, and a list with nothing to choose is skipped.
|
|
37
37
|
|
|
38
|
-
It may start with a `Suggested` group, which holds only the system service of the implementation: `prisma-infrastructure-service` for `prisma`, `in-memory-db-infrastructure-service` for `in-memory`. It is listed there only and is **checked**: omitting the implementation's group in JSON keeps it, `[]` selects none. Any other service is an ordinary unchecked item in `Infrastructure services`, whatever its name, so select it explicitly.
|
|
38
|
+
It may start with a `Suggested` group, which holds only the system service of the implementation: `prisma-infrastructure-service` for `prisma`, `drizzle-infrastructure-service` for `drizzle`, `in-memory-db-infrastructure-service` for `in-memory`. It is listed there only and is **checked**: omitting the implementation's group in JSON keeps it, `[]` selects none. Any other service is an ordinary unchecked item in `Infrastructure services`, whatever its name, so select it explicitly.
|
|
39
39
|
|
|
40
40
|
## Remembered and system implementation types
|
|
41
41
|
|