domain-driver 0.0.5 → 0.2.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 (70) hide show
  1. package/README.md +138 -146
  2. package/dist/commands/action.js +118 -0
  3. package/dist/commands/component.js +18 -20
  4. package/dist/commands/container.js +12 -26
  5. package/dist/commands/controller.js +85 -0
  6. package/dist/commands/feature.js +59 -48
  7. package/dist/commands/hints.js +28 -0
  8. package/dist/commands/hook.js +12 -22
  9. package/dist/commands/repository.js +17 -101
  10. package/dist/commands/resolve.js +61 -0
  11. package/dist/commands/schema.js +22 -73
  12. package/dist/commands/service.js +15 -88
  13. package/dist/commands/sides.js +34 -0
  14. package/dist/commands/target.js +32 -0
  15. package/dist/commands/types.js +49 -0
  16. package/dist/commands/write.js +66 -0
  17. package/dist/index.js +132 -59
  18. package/dist/init/content.js +73 -0
  19. package/dist/init/init.js +60 -0
  20. package/dist/init/markers.js +21 -0
  21. package/dist/postinstall.js +80 -0
  22. package/dist/stack/detect.js +125 -0
  23. package/dist/stack/profiles/nest.js +18 -0
  24. package/dist/stack/profiles/next-frontend.js +28 -0
  25. package/dist/stack/profiles/next-fullstack.js +44 -0
  26. package/dist/stack/profiles/node.js +17 -0
  27. package/dist/stack/profiles/react.js +19 -0
  28. package/dist/stack/registry.js +63 -0
  29. package/dist/stack/types.js +24 -0
  30. package/dist/templates/actions.js +68 -0
  31. package/dist/templates/backend/server-repository.js +22 -0
  32. package/dist/templates/context.js +52 -0
  33. package/dist/templates/controllers/express.js +60 -0
  34. package/dist/templates/controllers/fastify.js +54 -0
  35. package/dist/templates/controllers/generic.js +30 -0
  36. package/dist/templates/controllers/hono.js +52 -0
  37. package/dist/templates/controllers/nest.js +63 -0
  38. package/dist/templates/controllers/next-action-route.js +40 -0
  39. package/dist/templates/controllers/next-route.js +62 -0
  40. package/dist/templates/controllers/node.js +46 -0
  41. package/dist/templates/controllers/shape.js +28 -0
  42. package/dist/templates/frontend/client-repository.js +38 -0
  43. package/dist/templates/frontend/component.js +18 -0
  44. package/dist/templates/frontend/container.js +28 -0
  45. package/dist/templates/frontend/hook.js +109 -0
  46. package/dist/templates/frontend/page.js +26 -0
  47. package/dist/templates/nest/dto.js +12 -0
  48. package/dist/templates/nest/injectable.js +4 -0
  49. package/dist/templates/nest/module.js +41 -0
  50. package/dist/templates/service.js +40 -0
  51. package/dist/templates/shared/schema.js +13 -0
  52. package/dist/templates/shared/types.js +12 -0
  53. package/dist/templates/signatures.js +15 -0
  54. package/dist/utils/alias.js +80 -0
  55. package/dist/utils/fs.js +70 -0
  56. package/dist/utils/imports.js +61 -0
  57. package/dist/utils/naming.js +31 -0
  58. package/dist/utils/paths.js +44 -0
  59. package/package.json +33 -11
  60. package/scripts/postinstall.js +7 -0
  61. package/.github/workflows/publish.yml +0 -28
  62. package/src/commands/component.ts +0 -36
  63. package/src/commands/container.ts +0 -36
  64. package/src/commands/feature.ts +0 -68
  65. package/src/commands/hook.ts +0 -32
  66. package/src/commands/repository.ts +0 -81
  67. package/src/commands/schema.ts +0 -52
  68. package/src/commands/service.ts +0 -68
  69. package/src/index.ts +0 -75
  70. package/tsconfig.json +0 -13
@@ -1,81 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
-
4
- type RepositoryAction = 'List' | 'Create' | 'Update' | 'Delete' | 'Show';
5
-
6
- const REPOSITORY_ACTIONS: RepositoryAction[] = ['List', 'Create', 'Update', 'Delete', 'Show'];
7
-
8
- function renderRepository(action: RepositoryAction, name: string, feature: string): string {
9
- switch (action) {
10
- case 'List':
11
- return `export class List${name}Repository {
12
- async handle() {
13
- const response = await fetch('/api/${feature}');
14
- return response.json();
15
- }
16
- }
17
- `;
18
- case 'Show':
19
- return `export class Show${name}Repository {
20
- async handle(id: string) {
21
- const response = await fetch(\`/api/${feature}/\${id}\`);
22
- return response.json();
23
- }
24
- }
25
- `;
26
- case 'Create':
27
- return `export class Create${name}Repository {
28
- async handle(data: unknown) {
29
- const response = await fetch('/api/${feature}', {
30
- method: 'POST',
31
- body: JSON.stringify(data),
32
- });
33
- return response.json();
34
- }
35
- }
36
- `;
37
- case 'Update':
38
- return `export class Update${name}Repository {
39
- async handle(id: string, data: unknown) {
40
- const response = await fetch(\`/api/${feature}/\${id}\`, {
41
- method: 'PUT',
42
- body: JSON.stringify(data),
43
- });
44
- return response.json();
45
- }
46
- }
47
- `;
48
- case 'Delete':
49
- return `export class Delete${name}Repository {
50
- async handle(id: string) {
51
- const response = await fetch(\`/api/${feature}/\${id}\`, {
52
- method: 'DELETE',
53
- });
54
- return response.json();
55
- }
56
- }
57
- `;
58
- }
59
- }
60
-
61
- export function makeRepository(feature: string, name: string) {
62
- const base = path.join(process.cwd(), 'app', feature, 'repositories');
63
-
64
- if (!fs.existsSync(base)) {
65
- console.error(`❌ Feature "${feature}" does not exist. Run make:feature ${feature} first.`);
66
- process.exit(1);
67
- }
68
-
69
- for (const action of REPOSITORY_ACTIONS) {
70
- const filePath = path.join(base, `${action}${name}.repository.ts`);
71
-
72
- if (fs.existsSync(filePath)) {
73
- console.warn(`⚠️ Skipping "${action}${name}.repository.ts" — already exists`);
74
- continue;
75
- }
76
-
77
- fs.writeFileSync(filePath, renderRepository(action, name, feature));
78
- }
79
-
80
- console.log(`✅ Repositories for "${name}" created at ${base}`);
81
- }
@@ -1,52 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
-
4
- type SchemaAction = 'Create' | 'Update';
5
-
6
- const SCHEMA_ACTIONS: SchemaAction[] = ['Create', 'Update'];
7
-
8
- function renderSchema(action: SchemaAction, name: string): string {
9
- switch (action) {
10
- case 'Create':
11
- return `import { z } from 'zod';
12
-
13
- export const Create${name}Schema = z.object({
14
- // add create fields here
15
- });
16
-
17
- export type Create${name} = z.infer<typeof Create${name}Schema>;
18
- `;
19
- case 'Update':
20
- return `import { z } from 'zod';
21
-
22
- export const Update${name}Schema = z.object({
23
- id: z.string(),
24
- // add update fields here
25
- });
26
-
27
- export type Update${name} = z.infer<typeof Update${name}Schema>;
28
- `;
29
- }
30
- }
31
-
32
- export function makeSchema(feature: string, name: string) {
33
- const base = path.join(process.cwd(), 'app', feature, 'schemas');
34
-
35
- if (!fs.existsSync(base)) {
36
- console.error(`❌ Feature "${feature}" does not exist. Run make:feature ${feature} first.`);
37
- process.exit(1);
38
- }
39
-
40
- for (const action of SCHEMA_ACTIONS) {
41
- const filePath = path.join(base, `${action}${name}.schema.ts`);
42
-
43
- if (fs.existsSync(filePath)) {
44
- console.warn(`⚠️ Skipping "${action}${name}.schema.ts" — already exists`);
45
- continue;
46
- }
47
-
48
- fs.writeFileSync(filePath, renderSchema(action, name));
49
- }
50
-
51
- console.log(`✅ Schemas for "${name}" created at ${base}`);
52
- }
@@ -1,68 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
-
4
- type ServiceAction = 'List' | 'Create' | 'Update' | 'Delete' | 'Show';
5
-
6
- const SERVICE_ACTIONS: ServiceAction[] = ['List', 'Create', 'Update', 'Delete', 'Show'];
7
-
8
- function renderService(action: ServiceAction, name: string): string {
9
- switch (action) {
10
- case 'List':
11
- return `export class List${name}Service {
12
- async handle() {
13
- // fetch all ${name}
14
- }
15
- }
16
- `;
17
- case 'Show':
18
- return `export class Show${name}Service {
19
- async handle(id: string) {
20
- // fetch single ${name}
21
- }
22
- }
23
- `;
24
- case 'Create':
25
- return `export class Create${name}Service {
26
- async handle(data: unknown) {
27
- // create ${name}
28
- }
29
- }
30
- `;
31
- case 'Update':
32
- return `export class Update${name}Service {
33
- async handle(id: string, data: unknown) {
34
- // update ${name}
35
- }
36
- }
37
- `;
38
- case 'Delete':
39
- return `export class Delete${name}Service {
40
- async handle(id: string) {
41
- // delete ${name}
42
- }
43
- }
44
- `;
45
- }
46
- }
47
-
48
- export function makeService(feature: string, name: string) {
49
- const base = path.join(process.cwd(), 'app', feature, 'services');
50
-
51
- if (!fs.existsSync(base)) {
52
- console.error(`❌ Feature "${feature}" does not exist. Run make:feature ${feature} first.`);
53
- process.exit(1);
54
- }
55
-
56
- for (const action of SERVICE_ACTIONS) {
57
- const filePath = path.join(base, `${action}${name}.service.ts`);
58
-
59
- if (fs.existsSync(filePath)) {
60
- console.warn(`⚠️ Skipping "${action}${name}.service.ts" — already exists`);
61
- continue;
62
- }
63
-
64
- fs.writeFileSync(filePath, renderService(action, name));
65
- }
66
-
67
- console.log(`✅ Services for "${name}" created at ${base}`);
68
- }
package/src/index.ts DELETED
@@ -1,75 +0,0 @@
1
- #!/usr/bin/env node
2
- import { makeFeature } from './commands/feature';
3
- import { makeComponent } from './commands/component';
4
- import { makeHook } from './commands/hook';
5
- import { makeService } from './commands/service';
6
- import { makeSchema } from './commands/schema';
7
- import { makeRepository } from './commands/repository';
8
- import { makeContainer } from './commands/container';
9
-
10
- const [,, command, feature, name] = process.argv;
11
-
12
- if (!command || !feature) {
13
- console.error('Usage: domain-driver <command> [options]');
14
- process.exit(1);
15
- }
16
-
17
- switch (command) {
18
- case 'make:feature':
19
- const all = process.argv.includes('-a') || process.argv.includes('-A');
20
- makeFeature(feature, all).then(() => {});
21
- break;
22
-
23
- case 'make:component':
24
- if (!name) {
25
- console.error('Usage: domain-driver make:component <feature> <name> [client|server]');
26
- process.exit(1);
27
- }
28
- const type = (process.argv[5] as 'client' | 'server') || 'client';
29
- makeComponent(feature, name, type);
30
- break;
31
-
32
- case 'make:hook':
33
- if (!name) {
34
- console.error('Usage: domain-driver make:hook <feature> <name>');
35
- process.exit(1);
36
- }
37
- makeHook(feature, name);
38
- break;
39
-
40
- case 'make:service':
41
- if (!name) {
42
- console.error('Usage: domain-driver make:service <feature> <name>');
43
- process.exit(1);
44
- }
45
- makeService(feature, name);
46
- break;
47
-
48
- case 'make:schema':
49
- if (!name) {
50
- console.error('Usage: domain-driver make:schema <feature> <name>');
51
- process.exit(1);
52
- }
53
- makeSchema(feature, name);
54
- break;
55
-
56
- case 'make:repository':
57
- if (!name) {
58
- console.error('Usage: domain-driver make:repository <feature> <name>');
59
- process.exit(1);
60
- }
61
- makeRepository(feature, name);
62
- break;
63
-
64
- case 'make:container':
65
- if (!name) {
66
- console.error('Usage: domain-driver make:container <feature> <name>');
67
- process.exit(1);
68
- }
69
- makeContainer(feature, name);
70
- break;
71
-
72
- default:
73
- console.error(`Unknown command: ${command}`);
74
- process.exit(1);
75
- }
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"]
13
- }