@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
|
@@ -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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
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
|
-
|
|
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
|
|
|
@@ -33,78 +33,71 @@ export const {{name}}Presenter = createPresenter('{{name}}Presenter', () => {
|
|
|
33
33
|
});`;
|
|
34
34
|
|
|
35
35
|
export default async function generateModulePresenter() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
35
|
+
const context = await selectContext('Select context for presenter:');
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
const { presenterType } = await prompts({
|
|
52
|
+
type: 'select',
|
|
53
|
+
name: 'presenterType',
|
|
54
|
+
message: 'Select presenter factory:',
|
|
55
|
+
choices: presenterChoices
|
|
56
|
+
});
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
76
|
-
|
|
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
|
-
|
|
82
|
-
|
|
75
|
+
// Update core index
|
|
76
|
+
await updateCoreIndex();
|
|
83
77
|
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
19
|
+
const context = await selectContext('Select context for repository:');
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const { name } = await prompts({
|
|
22
|
+
type: 'text',
|
|
23
|
+
name: 'name',
|
|
24
|
+
message: 'Repository name (without "Repository" suffix):'
|
|
25
|
+
});
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
if (allDatasources.length === 0) {
|
|
38
|
+
console.error('ā No datasources available. Create a datasource first.');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
const { datasource } = await prompts({
|
|
43
|
+
type: 'select',
|
|
44
|
+
name: 'datasource',
|
|
45
|
+
message: 'Select datasource:',
|
|
46
|
+
choices: allDatasources
|
|
47
|
+
});
|
|
52
48
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
69
|
-
|
|
62
|
+
await writeIfNotExists(filePath, content);
|
|
63
|
+
await updateIndexTs(repoPath);
|
|
70
64
|
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
// Update core index
|
|
66
|
+
await updateCoreIndex();
|
|
73
67
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
68
|
+
console.log(`ā
Repository created at ${filePath}`);
|
|
69
|
+
console.log(`\nš” Remember to manually add this repository to InfrastructureProvider when needed.`);
|
|
70
|
+
}
|