@azure-net/cli 2.3.62 → 4.0.0-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 (91) hide show
  1. package/.prettierrc +7 -0
  2. package/bin/azure-net.js +247 -157
  3. package/bin/azure-net.ts +253 -0
  4. package/eslint.config.js +19 -0
  5. package/package.json +12 -5
  6. package/src/commands/generate/generateCrudBase.js +95 -114
  7. package/src/commands/generate/generateCrudPresenter.js +135 -142
  8. package/src/commands/generate/generateModule.js +21 -21
  9. package/src/commands/generate/generateModuleBase.js +92 -114
  10. package/src/commands/generate/generateModulePresenter.js +73 -80
  11. package/src/commands/generate/generatePresenter.js +38 -44
  12. package/src/commands/generate/generateRepository.js +41 -47
  13. package/src/commands/generate/generateSchema.js +74 -70
  14. package/src/commands/generate/generateService.js +32 -37
  15. package/src/commands/generate/index.js +0 -5
  16. package/src/generate/layers/generateRepository.js +124 -0
  17. package/src/generate/layers/generateRepositoryMethod.js +102 -0
  18. package/src/generate/layers/generateUseCases.js +50 -0
  19. package/src/generate/layers/repositoryShared.js +569 -0
  20. package/src/generate/module/generateDomain.js +146 -0
  21. package/src/generate/module/generateDomain.ts +147 -0
  22. package/src/generate/module/generateModule.js +84 -0
  23. package/src/generate/module/generateModule.ts +84 -0
  24. package/src/generate/module/generatePresenter.js +419 -0
  25. package/src/generate/module/generatePresenter.ts +442 -0
  26. package/src/generate/module/generateRepository.js +144 -0
  27. package/src/generate/module/generateRepository.ts +158 -0
  28. package/src/generate/module/generateSchemaFromType.js +320 -0
  29. package/src/generate/module/generateSchemaFromType.ts +325 -0
  30. package/src/generate/module/generateTypesJson.js +252 -0
  31. package/src/generate/module/generateTypesJson.ts +259 -0
  32. package/src/generate/module/generateUseCases.js +67 -0
  33. package/src/generate/module/generateUseCases.ts +67 -0
  34. package/src/generate/module/repositoryModuleShared.js +598 -0
  35. package/src/generate/ui/generateComponent.js +98 -0
  36. package/src/generate/ui/generateComponent.ts +100 -0
  37. package/src/generate/ui/generateDesignComponent.js +71 -0
  38. package/src/generate/ui/generateDesignComponent.ts +71 -0
  39. package/src/generate/ui/generateWidget.js +71 -0
  40. package/src/generate/ui/generateWidget.ts +71 -0
  41. package/src/init/initAliases.js +159 -0
  42. package/src/init/initAliases.ts +167 -0
  43. package/src/init/initEdges.js +74 -0
  44. package/src/init/initEdges.ts +74 -0
  45. package/src/init/initStructure.js +122 -0
  46. package/src/init/initStructure.ts +124 -0
  47. package/src/install/installFresh.js +101 -0
  48. package/src/install/installFresh.ts +101 -0
  49. package/src/plugins/addLint.js +257 -0
  50. package/src/plugins/addLint.ts +274 -0
  51. package/src/plugins/index.js +1 -0
  52. package/src/plugins/index.ts +1 -0
  53. package/src/scaffolds/createCoreMiddleware.js +27 -0
  54. package/src/scaffolds/createCoreMiddleware.ts +27 -0
  55. package/src/scaffolds/createCoreSchema.js +141 -0
  56. package/src/scaffolds/createCoreSchema.ts +142 -0
  57. package/src/scaffolds/createDatasource.js +173 -0
  58. package/src/scaffolds/createDatasource.ts +175 -0
  59. package/src/scaffolds/createDatasourceProvider.js +164 -0
  60. package/src/scaffolds/createDatasourceProvider.ts +175 -0
  61. package/src/scaffolds/createMiddleware.js +105 -0
  62. package/src/scaffolds/createMiddleware.ts +105 -0
  63. package/src/scaffolds/createPresenterFactory.js +112 -0
  64. package/src/scaffolds/createPresenterFactory.ts +114 -0
  65. package/src/scaffolds/createResponse.js +64 -0
  66. package/src/scaffolds/createResponse.ts +64 -0
  67. package/src/scaffolds/createSchemaRule.js +40 -0
  68. package/src/scaffolds/createSchemaRule.ts +42 -0
  69. package/src/scaffolds/createTranslationManager.js +78 -0
  70. package/src/scaffolds/createTranslationManager.ts +78 -0
  71. package/src/scaffolds/index.js +9 -0
  72. package/src/scaffolds/index.ts +9 -0
  73. package/src/utils/contextUtils.js +56 -49
  74. package/src/utils/fileUtils.js +72 -84
  75. package/src/utils/loadConfig.js +57 -13
  76. package/tsconfig.json +19 -0
  77. package/src/commands/generate/generateComponent.js +0 -53
  78. package/src/commands/generate/generateDatasource.js +0 -84
  79. package/src/commands/generate/generateDesignComponent.js +0 -53
  80. package/src/commands/generate/generateResponse.js +0 -41
  81. package/src/commands/generate/generateWidget.js +0 -53
  82. package/src/commands/init/index.js +0 -9
  83. package/src/commands/init/initAliases.js +0 -52
  84. package/src/commands/init/initEdges.js +0 -42
  85. package/src/commands/init/initLint.js +0 -138
  86. package/src/commands/init/initMiddleware.js +0 -21
  87. package/src/commands/init/initPresenter.js +0 -25
  88. package/src/commands/init/initSchema.js +0 -22
  89. package/src/commands/init/initStructure.js +0 -140
  90. package/src/commands/init/initTranslations.js +0 -59
  91. package/src/commands/init/migrateStructure.js +0 -144
@@ -1,13 +1,6 @@
1
1
  import prompts from 'prompts';
2
2
  import path from 'path';
3
- import {
4
- selectContext,
5
- getContextPath,
6
- toPascalCase,
7
- toCamelCase,
8
- getAvailableFiles,
9
- toKebabCase
10
- } from '../../utils/contextUtils.js';
3
+ import { selectContext, getContextPath, toPascalCase, toCamelCase, getAvailableFiles, toKebabCase } from '../../utils/contextUtils.js';
11
4
  import { writeIfNotExists, updateIndexTs, updateCoreIndex } from '../../utils/fileUtils.js';
12
5
 
13
6
  const entityTemplate = `export interface I{{name}} {
@@ -43,110 +36,95 @@ export class {{name}}Service extends ClassMirror<{{name}}Repository> {
43
36
  }`;
44
37
 
45
38
  export default async function generateModuleBase() {
46
- const context = await selectContext('Select context for module base:');
47
-
48
- const { name } = await prompts({
49
- type: 'text',
50
- name: 'name',
51
- message: 'Module name (PascalCase):'
52
- });
53
-
54
- const { endpoint } = await prompts({
55
- type: 'text',
56
- name: 'endpoint',
57
- message: 'API endpoint (e.g. /api/users):'
58
- });
59
-
60
- const { needEntity } = await prompts({
61
- type: 'confirm',
62
- name: 'needEntity',
63
- message: 'Create domain entity?',
64
- initial: true
65
- });
66
-
67
- // Get available datasources
68
- const contextPath = getContextPath(context);
69
- const coreDatasources = await getAvailableFiles(
70
- path.join(process.cwd(), 'src/core/datasources')
71
- );
72
- const contextDatasources = await getAvailableFiles(
73
- path.join(contextPath, 'infrastructure/http/datasources')
74
- );
75
-
76
- const allDatasources = [
77
- ...coreDatasources.map(d => ({ title: `${d} (core)`, value: { name: d, from: 'core' } })),
78
- ...contextDatasources.map(d => ({ title: `${d} (${context})`, value: { name: d, from: context } }))
79
- ];
80
-
81
- const { datasource } = await prompts({
82
- type: 'select',
83
- name: 'datasource',
84
- message: 'Select datasource:',
85
- choices: allDatasources
86
- });
87
-
88
- const pascalName = toPascalCase(name);
89
- const camelName = toCamelCase(name);
90
- const entityLower = toKebabCase(pascalName);
91
-
92
- console.log('\nšŸš€ Generating module base (repository & service)...\n');
93
-
94
- // 1. Create Domain entity if needed
95
- if (needEntity) {
96
- const domainPath = path.join(contextPath, 'domain', entityLower);
97
- const modelPath = path.join(domainPath, 'model');
98
-
99
- await writeIfNotExists(
100
- path.join(modelPath, `I${pascalName}.ts`),
101
- entityTemplate.replace(/{{name}}/g, pascalName)
102
- );
103
-
104
- await writeIfNotExists(
105
- path.join(modelPath, 'index.ts'),
106
- `export * from './I${pascalName}';`
107
- );
108
-
109
- await writeIfNotExists(
110
- path.join(domainPath, 'index.ts'),
111
- `export * from './model';`
112
- );
113
-
114
- console.log(`āœ… Domain entity I${pascalName} created`);
115
- }
116
-
117
- // 2. Create Repository
118
- const repoPath = path.join(contextPath, 'infrastructure/http/repositories');
119
- const datasourceImport = datasource.from === 'core'
120
- ? '$core/datasources'
121
- : `\$${context}/infrastructure/http/datasources`;
122
-
123
- await writeIfNotExists(
124
- path.join(repoPath, `${pascalName}Repository.ts`),
125
- repositoryTemplate
126
- .replace(/{{name}}/g, pascalName)
127
- .replace(/{{endpoint}}/g, endpoint)
128
- .replace(/{{datasource}}/g, datasource.name)
129
- .replace(/{{datasourceImport}}/g, datasourceImport)
130
- .replace(/{{datasourceVar}}/g, toCamelCase(datasource.name))
131
- );
132
- await updateIndexTs(repoPath);
133
-
134
- // 3. Create Service
135
- const servicePath = path.join(contextPath, 'application/services');
136
- await writeIfNotExists(
137
- path.join(servicePath, `${pascalName}Service.ts`),
138
- serviceTemplate
139
- .replace(/{{name}}/g, pascalName)
140
- .replace(/{{camelName}}/g, camelName)
141
- .replace(/{{context}}/g, context)
142
- );
143
- await updateIndexTs(servicePath);
144
-
145
- // Update core index
146
- await updateCoreIndex();
147
-
148
- console.log(`\nāœ… Module base for ${pascalName} created successfully!`);
149
- console.log(`\nšŸ’” Remember to:`);
150
- console.log(` 1. Add ${pascalName}Repository to InfrastructureProvider`);
151
- console.log(` 2. Add ${pascalName}Service to ApplicationProvider`);
39
+ const context = await selectContext('Select context for module base:');
40
+
41
+ const { name } = await prompts({
42
+ type: 'text',
43
+ name: 'name',
44
+ message: 'Module name (PascalCase):'
45
+ });
46
+
47
+ const { endpoint } = await prompts({
48
+ type: 'text',
49
+ name: 'endpoint',
50
+ message: 'API endpoint (e.g. /api/users):'
51
+ });
52
+
53
+ const { needEntity } = await prompts({
54
+ type: 'confirm',
55
+ name: 'needEntity',
56
+ message: 'Create domain entity?',
57
+ initial: true
58
+ });
59
+
60
+ // Get available datasources
61
+ const contextPath = getContextPath(context);
62
+ const coreDatasources = await getAvailableFiles(path.join(process.cwd(), 'src/core/datasources'));
63
+ const contextDatasources = await getAvailableFiles(path.join(contextPath, 'infrastructure/http/datasources'));
64
+
65
+ const allDatasources = [
66
+ ...coreDatasources.map((d) => ({ title: `${d} (core)`, value: { name: d, from: 'core' } })),
67
+ ...contextDatasources.map((d) => ({ title: `${d} (${context})`, value: { name: d, from: context } }))
68
+ ];
69
+
70
+ const { datasource } = await prompts({
71
+ type: 'select',
72
+ name: 'datasource',
73
+ message: 'Select datasource:',
74
+ choices: allDatasources
75
+ });
76
+
77
+ const pascalName = toPascalCase(name);
78
+ const camelName = toCamelCase(name);
79
+ const entityLower = toKebabCase(pascalName);
80
+
81
+ console.log('\nšŸš€ Generating module base (repository & service)...\n');
82
+
83
+ // 1. Create Domain entity if needed
84
+ if (needEntity) {
85
+ const domainPath = path.join(contextPath, 'domain', entityLower);
86
+ const modelPath = path.join(domainPath, 'model');
87
+
88
+ await writeIfNotExists(path.join(modelPath, `I${pascalName}.ts`), entityTemplate.replace(/{{name}}/g, pascalName));
89
+
90
+ await writeIfNotExists(path.join(modelPath, 'index.ts'), `export * from './I${pascalName}';`);
91
+
92
+ await writeIfNotExists(path.join(domainPath, 'index.ts'), `export * from './model';`);
93
+
94
+ console.log(`āœ… Domain entity I${pascalName} created`);
95
+ }
96
+
97
+ // 2. Create Repository
98
+ const repoPath = path.join(contextPath, 'infrastructure/http/repositories');
99
+ const datasourceImport = datasource.from === 'core' ? '$core/datasources' : `\$${context}/infrastructure/http/datasources`;
100
+
101
+ await writeIfNotExists(
102
+ path.join(repoPath, `${pascalName}Repository.ts`),
103
+ repositoryTemplate
104
+ .replace(/{{name}}/g, pascalName)
105
+ .replace(/{{endpoint}}/g, endpoint)
106
+ .replace(/{{datasource}}/g, datasource.name)
107
+ .replace(/{{datasourceImport}}/g, datasourceImport)
108
+ .replace(/{{datasourceVar}}/g, toCamelCase(datasource.name))
109
+ );
110
+ await updateIndexTs(repoPath);
111
+
112
+ // 3. Create Service
113
+ const servicePath = path.join(contextPath, 'application/services');
114
+ await writeIfNotExists(
115
+ path.join(servicePath, `${pascalName}Service.ts`),
116
+ serviceTemplate
117
+ .replace(/{{name}}/g, pascalName)
118
+ .replace(/{{camelName}}/g, camelName)
119
+ .replace(/{{context}}/g, context)
120
+ );
121
+ await updateIndexTs(servicePath);
122
+
123
+ // Update core index
124
+ await updateCoreIndex();
125
+
126
+ console.log(`\nāœ… Module base for ${pascalName} created successfully!`);
127
+ console.log(`\nšŸ’” Remember to:`);
128
+ console.log(` 1. Add ${pascalName}Repository to InfrastructureProvider`);
129
+ console.log(` 2. Add ${pascalName}Service to ApplicationProvider`);
152
130
  }
@@ -1,12 +1,12 @@
1
1
  import prompts from 'prompts';
2
2
  import path from 'path';
3
3
  import {
4
- selectContext,
5
- getContextPath,
6
- toPascalCase,
7
- getAvailableFiles,
8
- getApplicationProviderServices,
9
- toKebabCase
4
+ selectContext,
5
+ getContextPath,
6
+ toPascalCase,
7
+ getAvailableFiles,
8
+ getApplicationProviderServices,
9
+ toKebabCase
10
10
  } from '../../utils/contextUtils.js';
11
11
  import { updateIndexTs, writeIfNotExists, updateCoreIndex } from '../../utils/fileUtils.js';
12
12
 
@@ -33,78 +33,71 @@ export const {{name}}Presenter = createPresenter('{{name}}Presenter', () => {
33
33
  });`;
34
34
 
35
35
  export default async function generateModulePresenter() {
36
- const context = await selectContext('Select context for module presenter:');
37
-
38
- // Get available services from ApplicationProvider
39
- const services = await getApplicationProviderServices(context);
40
-
41
- if (services.length === 0) {
42
- console.error('āŒ No services found in ApplicationProvider. Add services manually first.');
43
- return;
44
- }
45
-
46
- const { service } = await prompts({
47
- type: 'select',
48
- name: 'service',
49
- message: 'Select service for presenter:',
50
- choices: services.map(s => ({ title: s, value: s }))
51
- });
52
-
53
- const { moduleName } = await prompts({
54
- type: 'text',
55
- name: 'moduleName',
56
- message: 'Module name for presenter (will create folder in delivery):'
57
- });
58
-
59
- // Extract entity name from service name
60
- const pascalName = toPascalCase(moduleName);
61
- const entityLower = toKebabCase(pascalName);
62
-
63
- // Get presenter factory
64
- const corePresenters = await getAvailableFiles(
65
- path.join(process.cwd(), 'src/core/presenters')
66
- );
67
-
68
- const { presenterType } = await prompts({
69
- type: 'select',
70
- name: 'presenterType',
71
- message: 'Select presenter factory:',
72
- choices: [
73
- { title: 'Use createPresenter from package', value: 'package' },
74
- ...corePresenters.map(p => ({ title: `Use ${p} from core`, value: p }))
75
- ]
76
- });
77
-
78
- const contextPath = getContextPath(context);
79
- const deliveryModulePath = path.join(contextPath, 'delivery', entityLower);
80
-
81
- console.log('\nšŸš€ Generating module presenter...\n');
82
-
83
- // Create Presenter
84
- const presenterTemplate = presenterType === 'package'
85
- ? presenterWithoutCoreTemplate
86
- : presenterWithCoreTemplate;
87
-
88
- const presenterFactory = presenterType === 'package' ? 'createPresenter' : presenterType;
89
-
90
- await writeIfNotExists(
91
- path.join(deliveryModulePath, `${pascalName}Presenter.ts`),
92
- presenterTemplate
93
- .replace(/{{name}}/g, pascalName)
94
- .replace(/{{context}}/g, context)
95
- .replace(/{{serviceName}}/g, service)
96
- .replace(/{{presenterFactory}}/g, presenterFactory)
97
- );
98
-
99
- // Create module index
100
- await writeIfNotExists(
101
- path.join(deliveryModulePath, 'index.ts'),
102
- `export * from './${pascalName}Presenter';`
103
- );
104
-
105
- // Update core index
106
- await updateCoreIndex();
107
-
108
- console.log(`āœ… Module presenter for ${pascalName} created successfully!`);
109
- console.log(`\nšŸ’” Remember to add presenter methods using the ${service}.`);
36
+ const context = await selectContext('Select context for module presenter:');
37
+
38
+ // Get available services from ApplicationProvider
39
+ const services = await getApplicationProviderServices(context);
40
+
41
+ if (services.length === 0) {
42
+ console.error('āŒ No services found in ApplicationProvider. Add services manually first.');
43
+ return;
44
+ }
45
+
46
+ const { service } = await prompts({
47
+ type: 'select',
48
+ name: 'service',
49
+ message: 'Select service for presenter:',
50
+ choices: services.map((s) => ({ title: s, value: s }))
51
+ });
52
+
53
+ const { moduleName } = await prompts({
54
+ type: 'text',
55
+ name: 'moduleName',
56
+ message: 'Module name for presenter (will create folder in delivery):'
57
+ });
58
+
59
+ // Extract entity name from service name
60
+ const pascalName = toPascalCase(moduleName);
61
+ const entityLower = toKebabCase(pascalName);
62
+
63
+ // Get presenter factory
64
+ const corePresenters = await getAvailableFiles(path.join(process.cwd(), 'src/core/presenters'));
65
+
66
+ const { presenterType } = await prompts({
67
+ type: 'select',
68
+ name: 'presenterType',
69
+ message: 'Select presenter factory:',
70
+ choices: [
71
+ { title: 'Use createPresenter from package', value: 'package' },
72
+ ...corePresenters.map((p) => ({ title: `Use ${p} from core`, value: p }))
73
+ ]
74
+ });
75
+
76
+ const contextPath = getContextPath(context);
77
+ const deliveryModulePath = path.join(contextPath, 'delivery', entityLower);
78
+
79
+ console.log('\nšŸš€ Generating module presenter...\n');
80
+
81
+ // Create Presenter
82
+ const presenterTemplate = presenterType === 'package' ? presenterWithoutCoreTemplate : presenterWithCoreTemplate;
83
+
84
+ const presenterFactory = presenterType === 'package' ? 'createPresenter' : presenterType;
85
+
86
+ await writeIfNotExists(
87
+ path.join(deliveryModulePath, `${pascalName}Presenter.ts`),
88
+ presenterTemplate
89
+ .replace(/{{name}}/g, pascalName)
90
+ .replace(/{{context}}/g, context)
91
+ .replace(/{{serviceName}}/g, service)
92
+ .replace(/{{presenterFactory}}/g, presenterFactory)
93
+ );
94
+
95
+ // Create module index
96
+ await writeIfNotExists(path.join(deliveryModulePath, 'index.ts'), `export * from './${pascalName}Presenter';`);
97
+
98
+ // Update core index
99
+ await updateCoreIndex();
100
+
101
+ console.log(`āœ… Module presenter for ${pascalName} created successfully!`);
102
+ console.log(`\nšŸ’” Remember to add presenter methods using the ${service}.`);
110
103
  }
@@ -1,6 +1,6 @@
1
1
  import prompts from 'prompts';
2
2
  import path from 'path';
3
- import {selectContext, getContextPath, toPascalCase, getAvailableFiles, toKebabCase} from '../../utils/contextUtils.js';
3
+ import { selectContext, getContextPath, toPascalCase, getAvailableFiles, toKebabCase } from '../../utils/contextUtils.js';
4
4
  import { writeIfNotExists, updateCoreIndex } from '../../utils/fileUtils.js';
5
5
 
6
6
  const presenterWithCoreTemplate = `import { {{corePresenter}} } from '$core/presenters';
@@ -32,55 +32,49 @@ export const {{name}}Presenter = createPresenter('{{name}}Presenter', () => {
32
32
  });`;
33
33
 
34
34
  export default async function generatePresenter() {
35
- const context = await selectContext('Select context for presenter:');
35
+ const context = await selectContext('Select context for presenter:');
36
36
 
37
- const { name } = await prompts({
38
- type: 'text',
39
- name: 'name',
40
- message: 'Module name (will create folder in delivery):'
41
- });
37
+ const { name } = await prompts({
38
+ type: 'text',
39
+ name: 'name',
40
+ message: 'Module name (will create folder in delivery):'
41
+ });
42
42
 
43
- // Check for core presenters
44
- const corePresenters = await getAvailableFiles(
45
- path.join(process.cwd(), 'src/core/presenters')
46
- );
43
+ // Check for core presenters
44
+ const corePresenters = await getAvailableFiles(path.join(process.cwd(), 'src/core/presenters'));
47
45
 
48
- const presenterChoices = [
49
- { title: 'Use createPresenter from package', value: 'package' },
50
- ...corePresenters.map(p => ({ title: `Use ${p} from core`, value: p }))
51
- ];
46
+ const presenterChoices = [
47
+ { title: 'Use createPresenter from package', value: 'package' },
48
+ ...corePresenters.map((p) => ({ title: `Use ${p} from core`, value: p }))
49
+ ];
52
50
 
53
- const { presenterType } = await prompts({
54
- type: 'select',
55
- name: 'presenterType',
56
- message: 'Select presenter factory:',
57
- choices: presenterChoices
58
- });
51
+ const { presenterType } = await prompts({
52
+ type: 'select',
53
+ name: 'presenterType',
54
+ message: 'Select presenter factory:',
55
+ choices: presenterChoices
56
+ });
59
57
 
60
- const pascalName = toPascalCase(name);
61
- const moduleLower = toKebabCase(pascalName);
62
- const contextPath = getContextPath(context);
63
- const modulePath = path.join(contextPath, 'delivery', moduleLower);
64
- const filePath = path.join(modulePath, `${pascalName}Presenter.ts`);
58
+ const pascalName = toPascalCase(name);
59
+ const moduleLower = toKebabCase(pascalName);
60
+ const contextPath = getContextPath(context);
61
+ const modulePath = path.join(contextPath, 'delivery', moduleLower);
62
+ const filePath = path.join(modulePath, `${pascalName}Presenter.ts`);
65
63
 
66
- const content = presenterType === 'package'
67
- ? presenterWithPackageTemplate
68
- .replace(/{{name}}/g, pascalName)
69
- .replace(/{{context}}/g, context)
70
- : presenterWithCoreTemplate
71
- .replace(/{{name}}/g, pascalName)
72
- .replace(/{{corePresenter}}/g, presenterType)
73
- .replace(/{{context}}/g, context);
64
+ const content =
65
+ presenterType === 'package'
66
+ ? presenterWithPackageTemplate.replace(/{{name}}/g, pascalName).replace(/{{context}}/g, context)
67
+ : presenterWithCoreTemplate
68
+ .replace(/{{name}}/g, pascalName)
69
+ .replace(/{{corePresenter}}/g, presenterType)
70
+ .replace(/{{context}}/g, context);
74
71
 
75
- await writeIfNotExists(filePath, content);
76
- await writeIfNotExists(
77
- path.join(modulePath, 'index.ts'),
78
- `export * from './${pascalName}Presenter';`
79
- );
72
+ await writeIfNotExists(filePath, content);
73
+ await writeIfNotExists(path.join(modulePath, 'index.ts'), `export * from './${pascalName}Presenter';`);
80
74
 
81
- // Update core index
82
- await updateCoreIndex();
75
+ // Update core index
76
+ await updateCoreIndex();
83
77
 
84
- console.log(`āœ… Presenter created at ${filePath}`);
85
- console.log(`\nšŸ’” Remember to extract needed services from ApplicationProvider in the presenter.`);
86
- }
78
+ console.log(`āœ… Presenter created at ${filePath}`);
79
+ console.log(`\nšŸ’” Remember to extract needed services from ApplicationProvider in the presenter.`);
80
+ }
@@ -16,61 +16,55 @@ export class {{name}}Repository {
16
16
  }`;
17
17
 
18
18
  export default async function generateRepository() {
19
- const context = await selectContext('Select context for repository:');
19
+ const context = await selectContext('Select context for repository:');
20
20
 
21
- const { name } = await prompts({
22
- type: 'text',
23
- name: 'name',
24
- message: 'Repository name (without "Repository" suffix):'
25
- });
21
+ const { name } = await prompts({
22
+ type: 'text',
23
+ name: 'name',
24
+ message: 'Repository name (without "Repository" suffix):'
25
+ });
26
26
 
27
- // Get available datasources
28
- const contextPath = getContextPath(context);
29
- const coreDatasources = await getAvailableFiles(
30
- path.join(process.cwd(), 'src/core/datasources')
31
- );
32
- const contextDatasources = await getAvailableFiles(
33
- path.join(contextPath, 'infrastructure/http/datasources')
34
- );
27
+ // Get available datasources
28
+ const contextPath = getContextPath(context);
29
+ const coreDatasources = await getAvailableFiles(path.join(process.cwd(), 'src/core/datasources'));
30
+ const contextDatasources = await getAvailableFiles(path.join(contextPath, 'infrastructure/http/datasources'));
35
31
 
36
- const allDatasources = [
37
- ...coreDatasources.map(d => ({ title: `${d} (core)`, value: { name: d, from: 'core' } })),
38
- ...contextDatasources.map(d => ({ title: `${d} (${context})`, value: { name: d, from: context } }))
39
- ];
32
+ const allDatasources = [
33
+ ...coreDatasources.map((d) => ({ title: `${d} (core)`, value: { name: d, from: 'core' } })),
34
+ ...contextDatasources.map((d) => ({ title: `${d} (${context})`, value: { name: d, from: context } }))
35
+ ];
40
36
 
41
- if (allDatasources.length === 0) {
42
- console.error('āŒ No datasources available. Create a datasource first.');
43
- return;
44
- }
37
+ if (allDatasources.length === 0) {
38
+ console.error('āŒ No datasources available. Create a datasource first.');
39
+ return;
40
+ }
45
41
 
46
- const { datasource } = await prompts({
47
- type: 'select',
48
- name: 'datasource',
49
- message: 'Select datasource:',
50
- choices: allDatasources
51
- });
42
+ const { datasource } = await prompts({
43
+ type: 'select',
44
+ name: 'datasource',
45
+ message: 'Select datasource:',
46
+ choices: allDatasources
47
+ });
52
48
 
53
- const pascalName = toPascalCase(name);
54
- const repoPath = path.join(contextPath, 'infrastructure/http/repositories');
55
- const filePath = path.join(repoPath, `${pascalName}Repository.ts`);
49
+ const pascalName = toPascalCase(name);
50
+ const repoPath = path.join(contextPath, 'infrastructure/http/repositories');
51
+ const filePath = path.join(repoPath, `${pascalName}Repository.ts`);
56
52
 
57
- // Generate repository
58
- const datasourceImport = datasource.from === 'core'
59
- ? '$core/datasources'
60
- : `\${context}/infrastructure/http/datasources`;
53
+ // Generate repository
54
+ const datasourceImport = datasource.from === 'core' ? '$core/datasources' : `\${context}/infrastructure/http/datasources`;
61
55
 
62
- const content = repositoryTemplate
63
- .replace(/{{name}}/g, pascalName)
64
- .replace(/{{datasource}}/g, datasource.name)
65
- .replace(/{{datasourceImport}}/g, datasourceImport)
66
- .replace(/{{datasourceVar}}/g, toCamelCase(datasource.name));
56
+ const content = repositoryTemplate
57
+ .replace(/{{name}}/g, pascalName)
58
+ .replace(/{{datasource}}/g, datasource.name)
59
+ .replace(/{{datasourceImport}}/g, datasourceImport)
60
+ .replace(/{{datasourceVar}}/g, toCamelCase(datasource.name));
67
61
 
68
- await writeIfNotExists(filePath, content);
69
- await updateIndexTs(repoPath);
62
+ await writeIfNotExists(filePath, content);
63
+ await updateIndexTs(repoPath);
70
64
 
71
- // Update core index
72
- await updateCoreIndex();
65
+ // Update core index
66
+ await updateCoreIndex();
73
67
 
74
- console.log(`āœ… Repository created at ${filePath}`);
75
- console.log(`\nšŸ’” Remember to manually add this repository to InfrastructureProvider when needed.`);
76
- }
68
+ console.log(`āœ… Repository created at ${filePath}`);
69
+ console.log(`\nšŸ’” Remember to manually add this repository to InfrastructureProvider when needed.`);
70
+ }