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.
Files changed (85) hide show
  1. package/README.md +159 -145
  2. package/dist/cli.js +208 -0
  3. package/dist/commands/action.js +118 -0
  4. package/dist/commands/component.js +18 -19
  5. package/dist/commands/container.js +10 -31
  6. package/dist/commands/controller.js +85 -0
  7. package/dist/commands/feature.js +59 -51
  8. package/dist/commands/hints.js +28 -0
  9. package/dist/commands/hook.js +10 -111
  10. package/dist/commands/repository.js +17 -115
  11. package/dist/commands/resolve.js +61 -0
  12. package/dist/commands/schema.js +22 -69
  13. package/dist/commands/service.js +15 -113
  14. package/dist/commands/sides.js +34 -0
  15. package/dist/commands/target.js +32 -0
  16. package/dist/commands/types.js +9 -17
  17. package/dist/commands/update.js +148 -0
  18. package/dist/commands/write.js +66 -0
  19. package/dist/index.js +8 -122
  20. package/dist/init/content.js +73 -0
  21. package/dist/init/init.js +66 -0
  22. package/dist/init/markers.js +21 -0
  23. package/dist/postinstall.js +80 -0
  24. package/dist/stack/detect.js +125 -0
  25. package/dist/stack/profiles/nest.js +18 -0
  26. package/dist/stack/profiles/next-frontend.js +28 -0
  27. package/dist/stack/profiles/next-fullstack.js +44 -0
  28. package/dist/stack/profiles/node.js +17 -0
  29. package/dist/stack/profiles/react.js +19 -0
  30. package/dist/stack/registry.js +63 -0
  31. package/dist/stack/types.js +24 -0
  32. package/dist/templates/actions.js +68 -0
  33. package/dist/templates/backend/server-repository.js +22 -0
  34. package/dist/templates/context.js +52 -0
  35. package/dist/templates/controllers/express.js +60 -0
  36. package/dist/templates/controllers/fastify.js +54 -0
  37. package/dist/templates/controllers/generic.js +30 -0
  38. package/dist/templates/controllers/hono.js +52 -0
  39. package/dist/templates/controllers/nest.js +63 -0
  40. package/dist/templates/controllers/next-action-route.js +40 -0
  41. package/dist/templates/controllers/next-route.js +62 -0
  42. package/dist/templates/controllers/node.js +46 -0
  43. package/dist/templates/controllers/shape.js +28 -0
  44. package/dist/templates/frontend/client-repository.js +38 -0
  45. package/dist/templates/frontend/component.js +18 -0
  46. package/dist/templates/frontend/container.js +28 -0
  47. package/{src/commands/hook.ts → dist/templates/frontend/hook.js} +28 -41
  48. package/dist/templates/frontend/page.js +26 -0
  49. package/dist/templates/nest/dto.js +12 -0
  50. package/dist/templates/nest/injectable.js +4 -0
  51. package/dist/templates/nest/module.js +41 -0
  52. package/dist/templates/service.js +40 -0
  53. package/dist/templates/shared/schema.js +13 -0
  54. package/dist/templates/shared/types.js +12 -0
  55. package/dist/templates/signatures.js +15 -0
  56. package/dist/update/cache.js +80 -0
  57. package/dist/update/check.js +47 -0
  58. package/dist/update/install-mode.js +96 -0
  59. package/dist/update/package-manager.js +99 -0
  60. package/dist/update/registry.js +77 -0
  61. package/dist/update/version.js +70 -0
  62. package/dist/utils/alias.js +80 -0
  63. package/dist/utils/fs.js +70 -0
  64. package/dist/utils/imports.js +61 -0
  65. package/dist/utils/naming.js +31 -0
  66. package/dist/utils/paths.js +44 -0
  67. package/package.json +27 -6
  68. package/scripts/postinstall.js +7 -0
  69. package/.github/workflows/publish.yml +0 -28
  70. package/dist/utils.js +0 -132
  71. package/src/__tests__/utils.test.ts +0 -128
  72. package/src/commands/__tests__/feature.test.ts +0 -85
  73. package/src/commands/__tests__/imports.test.ts +0 -115
  74. package/src/commands/__tests__/individual.test.ts +0 -137
  75. package/src/commands/component.ts +0 -33
  76. package/src/commands/container.ts +0 -42
  77. package/src/commands/feature.ts +0 -74
  78. package/src/commands/repository.ts +0 -95
  79. package/src/commands/schema.ts +0 -47
  80. package/src/commands/service.ts +0 -93
  81. package/src/commands/types.ts +0 -25
  82. package/src/index.ts +0 -126
  83. package/src/utils.ts +0 -115
  84. package/tsconfig.json +0 -13
  85. 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
- }
package/vitest.config.ts DELETED
@@ -1,7 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- include: ['src/**/__tests__/**/*.test.ts'],
6
- },
7
- });