domain-driver 0.1.0 → 0.3.0
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 +159 -145
- package/dist/cli.js +208 -0
- package/dist/commands/action.js +118 -0
- package/dist/commands/component.js +18 -19
- package/dist/commands/container.js +10 -31
- package/dist/commands/controller.js +85 -0
- package/dist/commands/feature.js +59 -51
- package/dist/commands/hints.js +28 -0
- package/dist/commands/hook.js +10 -111
- package/dist/commands/repository.js +17 -115
- package/dist/commands/resolve.js +61 -0
- package/dist/commands/schema.js +22 -69
- package/dist/commands/service.js +15 -113
- package/dist/commands/sides.js +34 -0
- package/dist/commands/target.js +32 -0
- package/dist/commands/types.js +9 -17
- package/dist/commands/update.js +148 -0
- package/dist/commands/write.js +66 -0
- package/dist/index.js +8 -122
- package/dist/init/content.js +73 -0
- package/dist/init/init.js +66 -0
- package/dist/init/markers.js +21 -0
- package/dist/postinstall.js +80 -0
- package/dist/stack/detect.js +125 -0
- package/dist/stack/profiles/nest.js +18 -0
- package/dist/stack/profiles/next-frontend.js +28 -0
- package/dist/stack/profiles/next-fullstack.js +44 -0
- package/dist/stack/profiles/node.js +17 -0
- package/dist/stack/profiles/react.js +19 -0
- package/dist/stack/registry.js +63 -0
- package/dist/stack/types.js +24 -0
- package/dist/templates/actions.js +68 -0
- package/dist/templates/backend/server-repository.js +22 -0
- package/dist/templates/context.js +52 -0
- package/dist/templates/controllers/express.js +60 -0
- package/dist/templates/controllers/fastify.js +54 -0
- package/dist/templates/controllers/generic.js +30 -0
- package/dist/templates/controllers/hono.js +52 -0
- package/dist/templates/controllers/nest.js +63 -0
- package/dist/templates/controllers/next-action-route.js +40 -0
- package/dist/templates/controllers/next-route.js +62 -0
- package/dist/templates/controllers/node.js +46 -0
- package/dist/templates/controllers/shape.js +28 -0
- package/dist/templates/frontend/client-repository.js +38 -0
- package/dist/templates/frontend/component.js +18 -0
- package/dist/templates/frontend/container.js +28 -0
- package/{src/commands/hook.ts → dist/templates/frontend/hook.js} +28 -41
- package/dist/templates/frontend/page.js +26 -0
- package/dist/templates/nest/dto.js +12 -0
- package/dist/templates/nest/injectable.js +4 -0
- package/dist/templates/nest/module.js +41 -0
- package/dist/templates/service.js +40 -0
- package/dist/templates/shared/schema.js +13 -0
- package/dist/templates/shared/types.js +12 -0
- package/dist/templates/signatures.js +15 -0
- package/dist/update/cache.js +80 -0
- package/dist/update/check.js +47 -0
- package/dist/update/install-mode.js +96 -0
- package/dist/update/package-manager.js +99 -0
- package/dist/update/registry.js +77 -0
- package/dist/update/version.js +70 -0
- package/dist/utils/alias.js +80 -0
- package/dist/utils/fs.js +70 -0
- package/dist/utils/imports.js +61 -0
- package/dist/utils/naming.js +31 -0
- package/dist/utils/paths.js +44 -0
- package/package.json +27 -6
- package/scripts/postinstall.js +7 -0
- package/.github/workflows/publish.yml +0 -28
- package/dist/utils.js +0 -132
- package/src/__tests__/utils.test.ts +0 -128
- package/src/commands/__tests__/feature.test.ts +0 -85
- package/src/commands/__tests__/imports.test.ts +0 -115
- package/src/commands/__tests__/individual.test.ts +0 -137
- package/src/commands/component.ts +0 -33
- package/src/commands/container.ts +0 -42
- package/src/commands/feature.ts +0 -74
- package/src/commands/repository.ts +0 -95
- package/src/commands/schema.ts +0 -47
- package/src/commands/service.ts +0 -93
- package/src/commands/types.ts +0 -25
- package/src/index.ts +0 -126
- package/src/utils.ts +0 -115
- package/tsconfig.json +0 -13
- package/vitest.config.ts +0 -7
package/src/utils.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
|
|
4
|
-
export function toPascalCase(name: string): string {
|
|
5
|
-
return name
|
|
6
|
-
.split('-')
|
|
7
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
8
|
-
.join('');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function featureBasePath(feature: string): string {
|
|
12
|
-
return path.join(process.cwd(), 'app', feature);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function ensureFeatureExists(feature: string, subdir: string): string {
|
|
16
|
-
const base = path.join(featureBasePath(feature), subdir);
|
|
17
|
-
|
|
18
|
-
if (!fs.existsSync(base)) {
|
|
19
|
-
throw new Error(
|
|
20
|
-
`Feature "${feature}" does not exist. Run: domain-driver make:feature ${feature}`
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return base;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function writeFileSafe(filePath: string, content: string): void {
|
|
28
|
-
try {
|
|
29
|
-
fs.writeFileSync(filePath, content);
|
|
30
|
-
} catch (error: unknown) {
|
|
31
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
32
|
-
throw new Error(`Failed to write ${filePath}: ${message}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function mkdirSafe(dirPath: string): void {
|
|
37
|
-
try {
|
|
38
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
39
|
-
} catch (error: unknown) {
|
|
40
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
41
|
-
throw new Error(`Failed to create directory ${dirPath}: ${message}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function fileExists(filePath: string): boolean {
|
|
46
|
-
return fs.existsSync(filePath);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface AliasConfig {
|
|
50
|
-
alias: string | null;
|
|
51
|
-
appDir: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
let cachedAlias: AliasConfig | undefined;
|
|
55
|
-
|
|
56
|
-
export function detectAlias(): AliasConfig {
|
|
57
|
-
if (cachedAlias) return cachedAlias;
|
|
58
|
-
|
|
59
|
-
const tsconfigPath = path.join(process.cwd(), 'tsconfig.json');
|
|
60
|
-
|
|
61
|
-
if (!fs.existsSync(tsconfigPath)) {
|
|
62
|
-
cachedAlias = { alias: null, appDir: 'app' };
|
|
63
|
-
return cachedAlias;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
const raw = fs.readFileSync(tsconfigPath, 'utf-8');
|
|
68
|
-
const stripped = raw.replace(/\/\/.*$/gm, '').replace(/\/\*[\s\S]*?\*\//g, '');
|
|
69
|
-
const tsconfig = JSON.parse(stripped);
|
|
70
|
-
const paths = tsconfig?.compilerOptions?.paths;
|
|
71
|
-
|
|
72
|
-
if (paths) {
|
|
73
|
-
for (const [key, values] of Object.entries(paths)) {
|
|
74
|
-
const targets = values as string[];
|
|
75
|
-
const hasAppMapping = targets.some(
|
|
76
|
-
(v) => v === './app/*' || v === 'app/*' || v === './src/app/*' || v === 'src/app/*'
|
|
77
|
-
);
|
|
78
|
-
if (hasAppMapping && key.endsWith('/*')) {
|
|
79
|
-
const prefix = key.slice(0, -1);
|
|
80
|
-
const appDir = targets[0].replace('/*', '').replace('./', '');
|
|
81
|
-
cachedAlias = { alias: prefix, appDir };
|
|
82
|
-
return cachedAlias;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const hasSrcMapping = targets.some(
|
|
86
|
-
(v) => v === './src/*' || v === 'src/*' || v === './*'
|
|
87
|
-
);
|
|
88
|
-
if (hasSrcMapping && key.endsWith('/*')) {
|
|
89
|
-
const prefix = key.slice(0, -1);
|
|
90
|
-
cachedAlias = { alias: prefix, appDir: 'app' };
|
|
91
|
-
return cachedAlias;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
} catch {
|
|
96
|
-
// tsconfig parse failed, fall back to relative imports
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
cachedAlias = { alias: null, appDir: 'app' };
|
|
100
|
-
return cachedAlias;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function resetAliasCache(): void {
|
|
104
|
-
cachedAlias = undefined;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function resolveImport(fromFeature: string, relativePath: string, fromRoot: boolean = false): string {
|
|
108
|
-
const { alias } = detectAlias();
|
|
109
|
-
|
|
110
|
-
if (alias) {
|
|
111
|
-
return `${alias}app/${fromFeature}/${relativePath}`;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return fromRoot ? `./${relativePath}` : `../${relativePath}`;
|
|
115
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"outDir": "./dist",
|
|
6
|
-
"rootDir": "./src",
|
|
7
|
-
"strict": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"types": ["node"]
|
|
10
|
-
},
|
|
11
|
-
"include": ["src/**/*"],
|
|
12
|
-
"exclude": ["node_modules", "dist", "src/**/__tests__/**"]
|
|
13
|
-
}
|