@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.
- package/.prettierrc +7 -0
- package/bin/azure-net.js +247 -157
- package/bin/azure-net.ts +253 -0
- package/eslint.config.js +19 -0
- package/package.json +12 -5
- package/src/commands/generate/generateCrudBase.js +95 -114
- package/src/commands/generate/generateCrudPresenter.js +135 -142
- package/src/commands/generate/generateModule.js +21 -21
- package/src/commands/generate/generateModuleBase.js +92 -114
- package/src/commands/generate/generateModulePresenter.js +73 -80
- package/src/commands/generate/generatePresenter.js +38 -44
- package/src/commands/generate/generateRepository.js +41 -47
- package/src/commands/generate/generateSchema.js +74 -70
- package/src/commands/generate/generateService.js +32 -37
- package/src/commands/generate/index.js +0 -5
- package/src/generate/layers/generateRepository.js +124 -0
- package/src/generate/layers/generateRepositoryMethod.js +102 -0
- package/src/generate/layers/generateUseCases.js +50 -0
- package/src/generate/layers/repositoryShared.js +569 -0
- package/src/generate/module/generateDomain.js +146 -0
- package/src/generate/module/generateDomain.ts +147 -0
- package/src/generate/module/generateModule.js +84 -0
- package/src/generate/module/generateModule.ts +84 -0
- package/src/generate/module/generatePresenter.js +419 -0
- package/src/generate/module/generatePresenter.ts +442 -0
- package/src/generate/module/generateRepository.js +144 -0
- package/src/generate/module/generateRepository.ts +158 -0
- package/src/generate/module/generateSchemaFromType.js +320 -0
- package/src/generate/module/generateSchemaFromType.ts +325 -0
- package/src/generate/module/generateTypesJson.js +252 -0
- package/src/generate/module/generateTypesJson.ts +259 -0
- package/src/generate/module/generateUseCases.js +67 -0
- package/src/generate/module/generateUseCases.ts +67 -0
- package/src/generate/module/repositoryModuleShared.js +598 -0
- package/src/generate/ui/generateComponent.js +98 -0
- package/src/generate/ui/generateComponent.ts +100 -0
- package/src/generate/ui/generateDesignComponent.js +71 -0
- package/src/generate/ui/generateDesignComponent.ts +71 -0
- package/src/generate/ui/generateWidget.js +71 -0
- package/src/generate/ui/generateWidget.ts +71 -0
- package/src/init/initAliases.js +159 -0
- package/src/init/initAliases.ts +167 -0
- package/src/init/initEdges.js +74 -0
- package/src/init/initEdges.ts +74 -0
- package/src/init/initStructure.js +122 -0
- package/src/init/initStructure.ts +124 -0
- package/src/install/installFresh.js +101 -0
- package/src/install/installFresh.ts +101 -0
- package/src/plugins/addLint.js +257 -0
- package/src/plugins/addLint.ts +274 -0
- package/src/plugins/index.js +1 -0
- package/src/plugins/index.ts +1 -0
- package/src/scaffolds/createCoreMiddleware.js +27 -0
- package/src/scaffolds/createCoreMiddleware.ts +27 -0
- package/src/scaffolds/createCoreSchema.js +141 -0
- package/src/scaffolds/createCoreSchema.ts +142 -0
- package/src/scaffolds/createDatasource.js +173 -0
- package/src/scaffolds/createDatasource.ts +175 -0
- package/src/scaffolds/createDatasourceProvider.js +164 -0
- package/src/scaffolds/createDatasourceProvider.ts +175 -0
- package/src/scaffolds/createMiddleware.js +105 -0
- package/src/scaffolds/createMiddleware.ts +105 -0
- package/src/scaffolds/createPresenterFactory.js +112 -0
- package/src/scaffolds/createPresenterFactory.ts +114 -0
- package/src/scaffolds/createResponse.js +64 -0
- package/src/scaffolds/createResponse.ts +64 -0
- package/src/scaffolds/createSchemaRule.js +40 -0
- package/src/scaffolds/createSchemaRule.ts +42 -0
- package/src/scaffolds/createTranslationManager.js +78 -0
- package/src/scaffolds/createTranslationManager.ts +78 -0
- package/src/scaffolds/index.js +9 -0
- package/src/scaffolds/index.ts +9 -0
- package/src/utils/contextUtils.js +56 -49
- package/src/utils/fileUtils.js +72 -84
- package/src/utils/loadConfig.js +57 -13
- package/tsconfig.json +19 -0
- package/src/commands/generate/generateComponent.js +0 -53
- package/src/commands/generate/generateDatasource.js +0 -84
- package/src/commands/generate/generateDesignComponent.js +0 -53
- package/src/commands/generate/generateResponse.js +0 -41
- package/src/commands/generate/generateWidget.js +0 -53
- package/src/commands/init/index.js +0 -9
- package/src/commands/init/initAliases.js +0 -52
- package/src/commands/init/initEdges.js +0 -42
- package/src/commands/init/initLint.js +0 -138
- package/src/commands/init/initMiddleware.js +0 -21
- package/src/commands/init/initPresenter.js +0 -25
- package/src/commands/init/initSchema.js +0 -22
- package/src/commands/init/initStructure.js +0 -140
- package/src/commands/init/initTranslations.js +0 -59
- package/src/commands/init/migrateStructure.js +0 -144
package/eslint.config.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
|
|
4
|
+
export default tseslint.config(
|
|
5
|
+
{
|
|
6
|
+
ignores: ['dist/**', 'node_modules/**']
|
|
7
|
+
},
|
|
8
|
+
js.configs.recommended,
|
|
9
|
+
...tseslint.configs.recommended,
|
|
10
|
+
{
|
|
11
|
+
files: ['bin/**/*.ts', 'src/plugins/**/*.ts'],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
globals: {
|
|
14
|
+
console: 'readonly',
|
|
15
|
+
process: 'readonly'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
);
|
package/package.json
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-net/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"azure-net": "bin/azure-net.js"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@azure-net/kit": "^
|
|
9
|
+
"@azure-net/kit": "^4.0.0"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@azure-net/kit": "^1.3.7",
|
|
13
12
|
"commander": "^11",
|
|
14
13
|
"prompts": "^2"
|
|
15
14
|
},
|
|
16
15
|
"devDependencies": {
|
|
16
|
+
"@eslint/js": "^9.31.0",
|
|
17
17
|
"@types/node": "^24.0.3",
|
|
18
|
-
"
|
|
18
|
+
"@types/prompts": "^2.4.9",
|
|
19
|
+
"eslint": "^9.31.0",
|
|
20
|
+
"prettier": "^3.6.2",
|
|
21
|
+
"typescript": "^5",
|
|
22
|
+
"typescript-eslint": "^8.36.0"
|
|
19
23
|
},
|
|
20
24
|
"scripts": {
|
|
21
|
-
"build": "tsc"
|
|
25
|
+
"build": "tsc -p tsconfig.json",
|
|
26
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
27
|
+
"lint": "eslint \"bin/**/*.ts\" \"src/**/*.ts\"",
|
|
28
|
+
"format": "prettier --write ."
|
|
22
29
|
}
|
|
23
30
|
}
|
|
@@ -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
|
// Templates for CRUD base generation
|
|
@@ -99,109 +92,97 @@ export class {{name}}Service extends ClassMirror<{{name}}Repository> {
|
|
|
99
92
|
}`;
|
|
100
93
|
|
|
101
94
|
export default async function generateCrudBase() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
);
|
|
197
|
-
await updateIndexTs(servicePath);
|
|
198
|
-
|
|
199
|
-
// Update core index
|
|
200
|
-
await updateCoreIndex();
|
|
201
|
-
|
|
202
|
-
console.log(`✅ CRUD base for ${pascalName} created successfully!`);
|
|
203
|
-
console.log(`\n💡 Remember to:`);
|
|
204
|
-
console.log(` 1. Add ${pascalName}Repository to InfrastructureProvider`);
|
|
205
|
-
console.log(` 2. Add ${pascalName}Service to ApplicationProvider`);
|
|
206
|
-
console.log(` 3. Use 'make:crud-presenter' to create the CRUD presenter`);
|
|
207
|
-
}
|
|
95
|
+
const context = await selectContext('Select context for CRUD base:');
|
|
96
|
+
|
|
97
|
+
const { name } = await prompts({
|
|
98
|
+
type: 'text',
|
|
99
|
+
name: 'name',
|
|
100
|
+
message: 'Entity name (PascalCase):'
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const { endpoint } = await prompts({
|
|
104
|
+
type: 'text',
|
|
105
|
+
name: 'endpoint',
|
|
106
|
+
message: 'API endpoint (e.g. /api/users):'
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Get available datasources
|
|
110
|
+
const contextPath = getContextPath(context);
|
|
111
|
+
const coreDatasources = await getAvailableFiles(path.join(process.cwd(), 'src/core/datasources'));
|
|
112
|
+
const contextDatasources = await getAvailableFiles(path.join(contextPath, 'infrastructure/http/datasources'));
|
|
113
|
+
|
|
114
|
+
const allDatasources = [
|
|
115
|
+
...coreDatasources.map((d) => ({ title: `${d} (core)`, value: { name: d, from: 'core' } })),
|
|
116
|
+
...contextDatasources.map((d) => ({ title: `${d} (${context})`, value: { name: d, from: context } }))
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
const { datasource } = await prompts({
|
|
120
|
+
type: 'select',
|
|
121
|
+
name: 'datasource',
|
|
122
|
+
message: 'Select datasource:',
|
|
123
|
+
choices: allDatasources
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const pascalName = toPascalCase(name);
|
|
127
|
+
const camelName = toCamelCase(name);
|
|
128
|
+
const entityLower = toKebabCase(pascalName);
|
|
129
|
+
|
|
130
|
+
console.log('\n🚀 Generating CRUD base (repository & service)...\n');
|
|
131
|
+
|
|
132
|
+
// 1. Create Domain structure
|
|
133
|
+
const domainPath = path.join(contextPath, 'domain', entityLower);
|
|
134
|
+
const modelPath = path.join(domainPath, 'model');
|
|
135
|
+
const portsPath = path.join(domainPath, 'ports');
|
|
136
|
+
|
|
137
|
+
// Create Model
|
|
138
|
+
await writeIfNotExists(path.join(modelPath, 'index.ts'), entityTemplate.replace(/{{name}}/g, pascalName));
|
|
139
|
+
|
|
140
|
+
// Create Ports
|
|
141
|
+
await writeIfNotExists(
|
|
142
|
+
path.join(portsPath, 'index.ts'),
|
|
143
|
+
portsIndexTemplate
|
|
144
|
+
.replace(/{{name}}/g, pascalName)
|
|
145
|
+
.replace(/{{context}}/g, context)
|
|
146
|
+
.replace(/{{entityLower}}/g, entityLower)
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
// Create Domain module index
|
|
150
|
+
await writeIfNotExists(path.join(domainPath, 'index.ts'), `export * from './model';\nexport * from './ports';`);
|
|
151
|
+
|
|
152
|
+
// 2. Create Repository
|
|
153
|
+
const repoPath = path.join(contextPath, 'infrastructure/http/repositories');
|
|
154
|
+
const datasourceImport = datasource.from === 'core' ? '$core/datasources' : `\$${context}/infrastructure/http/datasources`;
|
|
155
|
+
|
|
156
|
+
await writeIfNotExists(
|
|
157
|
+
path.join(repoPath, `${pascalName}Repository.ts`),
|
|
158
|
+
repositoryTemplate
|
|
159
|
+
.replace(/{{name}}/g, pascalName)
|
|
160
|
+
.replace(/{{context}}/g, context)
|
|
161
|
+
.replace(/{{endpoint}}/g, endpoint)
|
|
162
|
+
.replace(/{{datasource}}/g, datasource.name)
|
|
163
|
+
.replace(/{{datasourceImport}}/g, datasourceImport)
|
|
164
|
+
.replace(/{{datasourceVar}}/g, toCamelCase(datasource.name))
|
|
165
|
+
.replace(/{{entityLower}}/g, entityLower)
|
|
166
|
+
);
|
|
167
|
+
await updateIndexTs(repoPath);
|
|
168
|
+
|
|
169
|
+
// 3. Create Service
|
|
170
|
+
const servicePath = path.join(contextPath, 'application/services');
|
|
171
|
+
await writeIfNotExists(
|
|
172
|
+
path.join(servicePath, `${pascalName}Service.ts`),
|
|
173
|
+
serviceTemplate
|
|
174
|
+
.replace(/{{name}}/g, pascalName)
|
|
175
|
+
.replace(/{{camelName}}/g, camelName)
|
|
176
|
+
.replace(/{{context}}/g, context)
|
|
177
|
+
);
|
|
178
|
+
await updateIndexTs(servicePath);
|
|
179
|
+
|
|
180
|
+
// Update core index
|
|
181
|
+
await updateCoreIndex();
|
|
182
|
+
|
|
183
|
+
console.log(`✅ CRUD base for ${pascalName} created successfully!`);
|
|
184
|
+
console.log(`\n💡 Remember to:`);
|
|
185
|
+
console.log(` 1. Add ${pascalName}Repository to InfrastructureProvider`);
|
|
186
|
+
console.log(` 2. Add ${pascalName}Service to ApplicationProvider`);
|
|
187
|
+
console.log(` 3. Use 'make:crud-presenter' to create the CRUD presenter`);
|
|
188
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import prompts from 'prompts';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
|
@@ -90,143 +90,136 @@ export const {{name}}Presenter = createPresenter('{{name}}Presenter', () => {
|
|
|
90
90
|
});`;
|
|
91
91
|
|
|
92
92
|
export default async function generateCrudPresenter() {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const schemaImport = schemaType === 'package'
|
|
154
|
-
? '@azure-net/kit'
|
|
155
|
-
: '$core/schemas';
|
|
156
|
-
|
|
157
|
-
if (schemaType === 'package') {
|
|
158
|
-
const schemaImportFull = `import { createSchemaFactory } from '@azure-net/kit';
|
|
93
|
+
const context = await selectContext('Select context for CRUD presenter:');
|
|
94
|
+
|
|
95
|
+
// Get available services from ApplicationProvider
|
|
96
|
+
const services = await getApplicationProviderServices(context);
|
|
97
|
+
|
|
98
|
+
if (services.length === 0) {
|
|
99
|
+
console.error('❌ No services found in ApplicationProvider. Add services manually first.');
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const { service } = await prompts({
|
|
104
|
+
type: 'select',
|
|
105
|
+
name: 'service',
|
|
106
|
+
message: 'Select service for CRUD:',
|
|
107
|
+
choices: services.map((s) => ({ title: s, value: s }))
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Extract entity name from service name
|
|
111
|
+
const entityName = service.replace('Service', '');
|
|
112
|
+
const pascalName = toPascalCase(entityName);
|
|
113
|
+
const entityLower = toKebabCase(pascalName);
|
|
114
|
+
|
|
115
|
+
// Get schema factory
|
|
116
|
+
const coreSchemas = await getAvailableFiles(path.join(process.cwd(), 'src/core/schemas'));
|
|
117
|
+
|
|
118
|
+
const { schemaType } = await prompts({
|
|
119
|
+
type: 'select',
|
|
120
|
+
name: 'schemaType',
|
|
121
|
+
message: 'Select schema factory:',
|
|
122
|
+
choices: [
|
|
123
|
+
{ title: 'Use createSchemaFactory from package', value: 'package' },
|
|
124
|
+
...coreSchemas.map((s) => ({ title: `Use ${s} from core`, value: s }))
|
|
125
|
+
]
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Get presenter factory
|
|
129
|
+
const corePresenters = await getAvailableFiles(path.join(process.cwd(), 'src/core/presenters'));
|
|
130
|
+
|
|
131
|
+
const { presenterType } = await prompts({
|
|
132
|
+
type: 'select',
|
|
133
|
+
name: 'presenterType',
|
|
134
|
+
message: 'Select presenter factory:',
|
|
135
|
+
choices: [
|
|
136
|
+
{ title: 'Use createPresenter from package', value: 'package' },
|
|
137
|
+
...corePresenters.map((p) => ({ title: `Use ${p} from core`, value: p }))
|
|
138
|
+
]
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const contextPath = getContextPath(context);
|
|
142
|
+
const deliveryModulePath = path.join(contextPath, 'delivery', entityLower);
|
|
143
|
+
const schemaPath = path.join(deliveryModulePath, 'schema');
|
|
144
|
+
|
|
145
|
+
console.log('\n🚀 Generating CRUD presenter...\n');
|
|
146
|
+
|
|
147
|
+
// Create schemas
|
|
148
|
+
const schemaFactory = schemaType === 'package' ? 'Schema' : schemaType;
|
|
149
|
+
const schemaImport = schemaType === 'package' ? '@azure-net/kit' : '$core/schemas';
|
|
150
|
+
|
|
151
|
+
if (schemaType === 'package') {
|
|
152
|
+
const schemaImportFull = `import { createSchemaFactory } from '@azure-net/kit';
|
|
159
153
|
import { createRules, validationMessagesI18n } from '@azure-net/kit/schema';
|
|
160
154
|
|
|
161
155
|
const Schema = createSchemaFactory(createRules(validationMessagesI18n));`;
|
|
162
156
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
157
|
+
await writeIfNotExists(
|
|
158
|
+
path.join(schemaPath, `Create${pascalName}Schema.ts`),
|
|
159
|
+
schemaImportFull +
|
|
160
|
+
'\n' +
|
|
161
|
+
createSchemaTemplate
|
|
162
|
+
.replace("import { {{schemaFactory}} } from '{{schemaImport}}';\n", '')
|
|
163
|
+
.replace(/{{name}}/g, pascalName)
|
|
164
|
+
.replace(/{{context}}/g, context)
|
|
165
|
+
.replace(/{{entityLower}}/g, entityLower)
|
|
166
|
+
.replace(/{{schemaFactory}}/g, 'Schema')
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
await writeIfNotExists(
|
|
170
|
+
path.join(schemaPath, `Update${pascalName}Schema.ts`),
|
|
171
|
+
schemaImportFull +
|
|
172
|
+
'\n' +
|
|
173
|
+
updateSchemaTemplate
|
|
174
|
+
.replace("import { {{schemaFactory}} } from '{{schemaImport}}';\n", '')
|
|
175
|
+
.replace(/{{name}}/g, pascalName)
|
|
176
|
+
.replace(/{{context}}/g, context)
|
|
177
|
+
.replace(/{{entityLower}}/g, entityLower)
|
|
178
|
+
.replace(/{{schemaFactory}}/g, 'Schema')
|
|
179
|
+
);
|
|
180
|
+
} else {
|
|
181
|
+
await writeIfNotExists(
|
|
182
|
+
path.join(schemaPath, `Create${pascalName}Schema.ts`),
|
|
183
|
+
createSchemaTemplate
|
|
184
|
+
.replace(/{{name}}/g, pascalName)
|
|
185
|
+
.replace(/{{context}}/g, context)
|
|
186
|
+
.replace(/{{entityLower}}/g, entityLower)
|
|
187
|
+
.replace(/{{schemaFactory}}/g, schemaFactory)
|
|
188
|
+
.replace(/{{schemaImport}}/g, schemaImport)
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
await writeIfNotExists(
|
|
192
|
+
path.join(schemaPath, `Update${pascalName}Schema.ts`),
|
|
193
|
+
updateSchemaTemplate
|
|
194
|
+
.replace(/{{name}}/g, pascalName)
|
|
195
|
+
.replace(/{{context}}/g, context)
|
|
196
|
+
.replace(/{{entityLower}}/g, entityLower)
|
|
197
|
+
.replace(/{{schemaFactory}}/g, schemaFactory)
|
|
198
|
+
.replace(/{{schemaImport}}/g, schemaImport)
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
await updateIndexTs(schemaPath);
|
|
202
|
+
|
|
203
|
+
// Create Presenter
|
|
204
|
+
const presenterTemplate = presenterType === 'package' ? presenterWithoutCoreTemplate : presenterWithCoreTemplate;
|
|
205
|
+
|
|
206
|
+
const presenterFactory = presenterType === 'package' ? 'createPresenter' : presenterType;
|
|
207
|
+
|
|
208
|
+
await writeIfNotExists(
|
|
209
|
+
path.join(deliveryModulePath, `${pascalName}Presenter.ts`),
|
|
210
|
+
presenterTemplate
|
|
211
|
+
.replace(/{{name}}/g, pascalName)
|
|
212
|
+
.replace(/{{context}}/g, context)
|
|
213
|
+
.replace(/{{serviceName}}/g, service)
|
|
214
|
+
.replace(/{{presenterFactory}}/g, presenterFactory)
|
|
215
|
+
.replace(/{{entityLower}}/g, entityLower)
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
// Create module index
|
|
219
|
+
await writeIfNotExists(path.join(deliveryModulePath, 'index.ts'), `export * from './${pascalName}Presenter';\nexport * from './schema';`);
|
|
220
|
+
|
|
221
|
+
// Update core index
|
|
222
|
+
await updateCoreIndex();
|
|
223
|
+
|
|
224
|
+
console.log(`✅ CRUD presenter for ${pascalName} created successfully!`);
|
|
225
|
+
}
|
|
@@ -5,27 +5,27 @@ import generatePresenter from './generatePresenter.js';
|
|
|
5
5
|
import generateSchema from './generateSchema.js';
|
|
6
6
|
|
|
7
7
|
export default async function generateModule() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
console.log('🚀 Generating complete module...\n');
|
|
9
|
+
console.log('⚠️ Note: This will create repository, service, presenter and schemas.');
|
|
10
|
+
console.log(' You will need to manually wire them in the providers.\n');
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const { confirm } = await prompts({
|
|
13
|
+
type: 'confirm',
|
|
14
|
+
name: 'confirm',
|
|
15
|
+
message: 'Continue?'
|
|
16
|
+
});
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
if (confirm) {
|
|
19
|
+
await generateRepository();
|
|
20
|
+
await generateService();
|
|
21
|
+
await generatePresenter();
|
|
22
|
+
await generateSchema(); // Create schema
|
|
23
|
+
await generateSchema(); // Update schema
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
25
|
+
console.log('\n✅ Module generation complete!');
|
|
26
|
+
console.log('\n💡 Remember to:');
|
|
27
|
+
console.log(' 1. Add repository to InfrastructureProvider');
|
|
28
|
+
console.log(' 2. Add service to ApplicationProvider');
|
|
29
|
+
console.log(' 3. Update presenter to use the service from ApplicationProvider');
|
|
30
|
+
}
|
|
31
|
+
}
|