@azure-net/cli 2.1.4 → 2.1.6

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/bin/azure-net.js CHANGED
@@ -20,9 +20,7 @@ import {
20
20
  generatePresenter,
21
21
  generateModule,
22
22
  generateCrudBase,
23
- generateCrudPresenter,
24
- generatePresenterByService,
25
- generateServiceByRepo
23
+ generateCrudPresenter
26
24
  } from '../src/commands/generate/index.js';
27
25
 
28
26
  const program = new Command();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
@@ -11,7 +11,7 @@ const entityTemplate = `export interface I{{name}} {
11
11
  \tupdated_at: string;
12
12
  }`;
13
13
 
14
- const portsIndexTemplate = `import type { I{{name}} } from '\${{context}}/Domain/{{name}}/Model';
14
+ const portsIndexTemplate = `import type { I{{name}} } from '\${{context}}/domain/{{name}}/model';
15
15
 
16
16
  export interface I{{name}}Collection {
17
17
  \tdata: I{{name}}[];
@@ -41,7 +41,7 @@ import type {
41
41
  \tI{{name}}CollectionQuery,
42
42
  \tI{{name}}CreateRequest,
43
43
  \tI{{name}}UpdateRequest
44
- } from '\${{context}}/Domain/{{name}}';
44
+ } from '\${{context}}/domain/{{name}}';
45
45
 
46
46
  export class {{name}}Repository {
47
47
  \tprivate endpoint = '{{endpoint}}';
@@ -80,7 +80,7 @@ export class {{name}}Repository {
80
80
  }`;
81
81
 
82
82
  const serviceTemplate = `import { ClassMirror } from '@azure-net/kit';
83
- import { {{name}}Repository } from '\${{context}}/Infrastructure/Http/Repositories';
83
+ import { {{name}}Repository } from '\${{context}}/infrastructure/http/repositories';
84
84
 
85
85
  export class {{name}}Service extends ClassMirror<{{name}}Repository> {
86
86
  \tconstructor(private {{camelName}}Repository: {{name}}Repository) {
@@ -112,10 +112,10 @@ export default async function generateCrudBase() {
112
112
  // Get available datasources
113
113
  const contextPath = getContextPath(context);
114
114
  const coreDatasources = await getAvailableFiles(
115
- path.join(process.cwd(), 'src/app/core/Datasource')
115
+ path.join(process.cwd(), 'src/app/core/datasources')
116
116
  );
117
117
  const contextDatasources = await getAvailableFiles(
118
- path.join(contextPath, 'Infrastructure/Http/Datasource')
118
+ path.join(contextPath, 'infrastructure/http/datasources')
119
119
  );
120
120
 
121
121
  const allDatasources = [
@@ -136,9 +136,9 @@ export default async function generateCrudBase() {
136
136
  console.log('\nšŸš€ Generating CRUD base (repository & service)...\n');
137
137
 
138
138
  // 1. Create Domain structure
139
- const domainPath = path.join(contextPath, 'Domain', pascalName);
140
- const modelPath = path.join(domainPath, 'Model');
141
- const portsPath = path.join(domainPath, 'Ports');
139
+ const domainPath = path.join(contextPath, 'domain', pascalName);
140
+ const modelPath = path.join(domainPath, 'model');
141
+ const portsPath = path.join(domainPath, 'ports');
142
142
 
143
143
  // Create Model
144
144
  await writeIfNotExists(
@@ -157,14 +157,14 @@ export default async function generateCrudBase() {
157
157
  // Create Domain module index
158
158
  await writeIfNotExists(
159
159
  path.join(domainPath, 'index.ts'),
160
- `export * from './Model';\nexport * from './Ports';`
160
+ `export * from './model';\nexport * from './ports';`
161
161
  );
162
162
 
163
163
  // 2. Create Repository
164
- const repoPath = path.join(contextPath, 'Infrastructure/Http/Repositories');
164
+ const repoPath = path.join(contextPath, 'infrastructure/http/repositories');
165
165
  const datasourceImport = datasource.from === 'core'
166
- ? '$core/Datasource'
167
- : `\$${context}/Infrastructure/Http/Datasource`;
166
+ ? '$core/datasources'
167
+ : `\$${context}/infrastructure/http/datasources`;
168
168
 
169
169
  await writeIfNotExists(
170
170
  path.join(repoPath, `${pascalName}Repository.ts`),
@@ -179,7 +179,7 @@ export default async function generateCrudBase() {
179
179
  await updateIndexTs(repoPath);
180
180
 
181
181
  // 3. Create Service
182
- const servicePath = path.join(contextPath, 'Application/Services');
182
+ const servicePath = path.join(contextPath, 'application/services');
183
183
  await writeIfNotExists(
184
184
  path.join(servicePath, `${pascalName}Service.ts`),
185
185
  serviceTemplate
@@ -4,7 +4,7 @@ import { selectContext, getContextPath, toPascalCase, getAvailableFiles, getAppl
4
4
  import { updateIndexTs, writeIfNotExists, updateCoreIndex } from '../../utils/fileUtils.js';
5
5
 
6
6
  const createSchemaTemplate = `import { {{schemaFactory}} } from '{{schemaImport}}';
7
- import type { I{{name}}CreateRequest } from '\${{context}}/Domain/{{entity}}';
7
+ import type { I{{name}}CreateRequest } from '\${{context}}/domain/{{entity}}';
8
8
 
9
9
  export const Create{{name}}Schema = {{schemaFactory}}<I{{name}}CreateRequest>()
10
10
  \t.rules((rules) => ({
@@ -13,7 +13,7 @@ export const Create{{name}}Schema = {{schemaFactory}}<I{{name}}CreateRequest>()
13
13
  \t.create();`;
14
14
 
15
15
  const updateSchemaTemplate = `import { {{schemaFactory}} } from '{{schemaImport}}';
16
- import type { I{{name}}UpdateRequest } from '\${{context}}/Domain/{{entity}}';
16
+ import type { I{{name}}UpdateRequest } from '\${{context}}/domain/{{entity}}';
17
17
 
18
18
  export const Update{{name}}Schema = {{schemaFactory}}<I{{name}}UpdateRequest>()
19
19
  \t.rules((rules) => ({
@@ -21,14 +21,14 @@ export const Update{{name}}Schema = {{schemaFactory}}<I{{name}}UpdateRequest>()
21
21
  \t}))
22
22
  \t.create();`;
23
23
 
24
- const presenterWithCoreTemplate = `import { {{presenterFactory}} } from '$core/Presenter';
25
- import { ApplicationProvider } from '\${{context}}/Application';
26
- import { Create{{name}}Schema, Update{{name}}Schema } from './Schema';
24
+ const presenterWithCoreTemplate = `import { {{presenterFactory}} } from '$core/presenters';
25
+ import { ApplicationProvider } from '\${{context}}/application';
26
+ import { Create{{name}}Schema, Update{{name}}Schema } from './schema';
27
27
  import type {
28
28
  \tI{{name}}CollectionQuery,
29
29
  \tI{{name}}CreateRequest,
30
30
  \tI{{name}}UpdateRequest
31
- } from '\${{context}}/Domain/{{name}}';
31
+ } from '\${{context}}/domain/{{name}}';
32
32
 
33
33
  export const {{name}}Presenter = {{presenterFactory}}('{{name}}Presenter', ({ createAsyncResource, createAsyncAction }) => {
34
34
  \tconst { {{serviceName}} } = ApplicationProvider();
@@ -52,13 +52,13 @@ export const {{name}}Presenter = {{presenterFactory}}('{{name}}Presenter', ({ cr
52
52
  });`;
53
53
 
54
54
  const presenterWithoutCoreTemplate = `import { createPresenter } from '@azure-net/kit';
55
- import { ApplicationProvider } from '\${{context}}/Application';
56
- import { Create{{name}}Schema, Update{{name}}Schema } from './Schema';
55
+ import { ApplicationProvider } from '\${{context}}/application';
56
+ import { Create{{name}}Schema, Update{{name}}Schema } from './schema';
57
57
  import type {
58
58
  \tI{{name}}CollectionQuery,
59
59
  \tI{{name}}CreateRequest,
60
60
  \tI{{name}}UpdateRequest
61
- } from '\${{context}}/Domain/{{name}}';
61
+ } from '\${{context}}/domain/{{name}}';
62
62
 
63
63
  export const {{name}}Presenter = createPresenter('{{name}}Presenter', () => {
64
64
  \tconst { {{serviceName}} } = ApplicationProvider();
@@ -105,7 +105,7 @@ export default async function generateCrudPresenter() {
105
105
 
106
106
  // Get schema factory
107
107
  const coreSchemas = await getAvailableFiles(
108
- path.join(process.cwd(), 'src/app/core/Schema')
108
+ path.join(process.cwd(), 'src/app/core/schemas')
109
109
  );
110
110
 
111
111
  const { schemaType } = await prompts({
@@ -120,7 +120,7 @@ export default async function generateCrudPresenter() {
120
120
 
121
121
  // Get presenter factory
122
122
  const corePresenters = await getAvailableFiles(
123
- path.join(process.cwd(), 'src/app/core/Presenter')
123
+ path.join(process.cwd(), 'src/app/core/presenters')
124
124
  );
125
125
 
126
126
  const { presenterType } = await prompts({
@@ -134,8 +134,8 @@ export default async function generateCrudPresenter() {
134
134
  });
135
135
 
136
136
  const contextPath = getContextPath(context);
137
- const deliveryModulePath = path.join(contextPath, 'Delivery', pascalName);
138
- const schemaPath = path.join(deliveryModulePath, 'Schema');
137
+ const deliveryModulePath = path.join(contextPath, 'delivery', pascalName);
138
+ const schemaPath = path.join(deliveryModulePath, 'schema');
139
139
 
140
140
  console.log('\nšŸš€ Generating CRUD presenter...\n');
141
141
 
@@ -143,7 +143,7 @@ export default async function generateCrudPresenter() {
143
143
  const schemaFactory = schemaType === 'package' ? 'Schema' : schemaType;
144
144
  const schemaImport = schemaType === 'package'
145
145
  ? '@azure-net/kit'
146
- : '$core/Schema';
146
+ : '$core/schemas';
147
147
 
148
148
  if (schemaType === 'package') {
149
149
  const schemaImportFull = `import { createSchemaFactory } from '@azure-net/kit';
@@ -212,7 +212,7 @@ const Schema = createSchemaFactory(createRules(validationMessagesI18n));`;
212
212
  // Create module index
213
213
  await writeIfNotExists(
214
214
  path.join(deliveryModulePath, 'index.ts'),
215
- `export * from './${pascalName}Presenter';\nexport * from './Schema';`
215
+ `export * from './${pascalName}Presenter';\nexport * from './schema';`
216
216
  );
217
217
 
218
218
  // Update core index
@@ -28,11 +28,11 @@ export default async function generateDatasource() {
28
28
 
29
29
  // Get available responses
30
30
  const coreResponses = await getAvailableFiles(
31
- path.join(process.cwd(), 'src/app/core/Response')
31
+ path.join(process.cwd(), 'src/app/core/responses')
32
32
  );
33
33
 
34
34
  const contextResponses = context !== 'core'
35
- ? await getAvailableFiles(path.join(contextPath, 'Infrastructure/Response'))
35
+ ? await getAvailableFiles(path.join(contextPath, 'infrastructure/responses'))
36
36
  : [];
37
37
 
38
38
  const allResponses = [
@@ -59,12 +59,12 @@ export default async function generateDatasource() {
59
59
  });
60
60
 
61
61
  const datasourcePath = context === 'core'
62
- ? path.join(contextPath, 'Datasource')
63
- : path.join(contextPath, 'Infrastructure/Http/Datasource');
62
+ ? path.join(contextPath, 'datasources')
63
+ : path.join(contextPath, 'infrastructure/http/datasources');
64
64
 
65
65
  const responseImport = response.from === 'core'
66
- ? context === 'core' ? '../Response' : '$core/Response'
67
- : `\$${context}/Infrastructure/Response`;
66
+ ? context === 'core' ? '../responses' : '$core/responses'
67
+ : `\$${context}/infrastructure/responses`;
68
68
 
69
69
  const content = datasourceWithResponseTemplate
70
70
  .replace(/{{name}}/g, pascalName)
@@ -3,8 +3,8 @@ import path from 'path';
3
3
  import { selectContext, getContextPath, toPascalCase, getAvailableFiles } from '../../utils/contextUtils.js';
4
4
  import { writeIfNotExists, updateCoreIndex } from '../../utils/fileUtils.js';
5
5
 
6
- const presenterWithCoreTemplate = `import { {{corePresenter}} } from '$core/Presenter';
7
- import { ApplicationProvider } from '\${{context}}/Application';
6
+ const presenterWithCoreTemplate = `import { {{corePresenter}} } from '$core/presenters';
7
+ import { ApplicationProvider } from '\${{context}}/application';
8
8
 
9
9
  export const {{name}}Presenter = {{corePresenter}}('{{name}}Presenter', ({ createAsyncResource, createAsyncAction }) => {
10
10
  \tconst { /* extract services from ApplicationProvider */ } = ApplicationProvider();
@@ -18,7 +18,7 @@ export const {{name}}Presenter = {{corePresenter}}('{{name}}Presenter', ({ creat
18
18
  });`;
19
19
 
20
20
  const presenterWithPackageTemplate = `import { createPresenter } from '@azure-net/kit';
21
- import { ApplicationProvider } from '\${{context}}/Application';
21
+ import { ApplicationProvider } from '\${{context}}/application';
22
22
 
23
23
  export const {{name}}Presenter = createPresenter('{{name}}Presenter', () => {
24
24
  \tconst { /* extract services from ApplicationProvider */ } = ApplicationProvider();
@@ -37,12 +37,12 @@ export default async function generatePresenter() {
37
37
  const { name } = await prompts({
38
38
  type: 'text',
39
39
  name: 'name',
40
- message: 'Module name (will create folder in Delivery):'
40
+ message: 'Module name (will create folder in delivery):'
41
41
  });
42
42
 
43
43
  // Check for core presenters
44
44
  const corePresenters = await getAvailableFiles(
45
- path.join(process.cwd(), 'src/app/core/Presenter')
45
+ path.join(process.cwd(), 'src/app/core/presenters')
46
46
  );
47
47
 
48
48
  const presenterChoices = [
@@ -59,7 +59,7 @@ export default async function generatePresenter() {
59
59
 
60
60
  const pascalName = toPascalCase(name);
61
61
  const contextPath = getContextPath(context);
62
- const modulePath = path.join(contextPath, 'Delivery', pascalName);
62
+ const modulePath = path.join(contextPath, 'delivery', pascalName);
63
63
  const filePath = path.join(modulePath, `${pascalName}Presenter.ts`);
64
64
 
65
65
  const content = presenterType === 'package'
@@ -27,10 +27,10 @@ export default async function generateRepository() {
27
27
  // Get available datasources
28
28
  const contextPath = getContextPath(context);
29
29
  const coreDatasources = await getAvailableFiles(
30
- path.join(process.cwd(), 'src/app/core/Datasource')
30
+ path.join(process.cwd(), 'src/app/core/datasources')
31
31
  );
32
32
  const contextDatasources = await getAvailableFiles(
33
- path.join(contextPath, 'Infrastructure/Http/Datasource')
33
+ path.join(contextPath, 'infrastructure/http/datasources')
34
34
  );
35
35
 
36
36
  const allDatasources = [
@@ -51,13 +51,13 @@ export default async function generateRepository() {
51
51
  });
52
52
 
53
53
  const pascalName = toPascalCase(name);
54
- const repoPath = path.join(contextPath, 'Infrastructure/Http/Repositories');
54
+ const repoPath = path.join(contextPath, 'infrastructure/http/repositories');
55
55
  const filePath = path.join(repoPath, `${pascalName}Repository.ts`);
56
56
 
57
57
  // Generate repository
58
58
  const datasourceImport = datasource.from === 'core'
59
- ? '$core/Datasource'
60
- : `\$${context}/Infrastructure/Http/Datasource`;
59
+ ? '$core/datasources'
60
+ : `\${context}/infrastructure/http/datasources`;
61
61
 
62
62
  const content = repositoryTemplate
63
63
  .replace(/{{name}}/g, pascalName)
@@ -23,8 +23,8 @@ export default async function generateResponse() {
23
23
  : getContextPath(context);
24
24
 
25
25
  const responsePath = context === 'core'
26
- ? path.join(contextPath, 'Response')
27
- : path.join(contextPath, 'Infrastructure/Response');
26
+ ? path.join(contextPath, 'responses')
27
+ : path.join(contextPath, 'infrastructure/responses');
28
28
 
29
29
  const content = responseTemplate.replace(/{{name}}/g, pascalName);
30
30
  const filePath = path.join(responsePath, `${pascalName}Response.ts`);
@@ -4,8 +4,8 @@ import fs from 'fs/promises';
4
4
  import { selectContext, getContextPath, toPascalCase, getAvailableFiles } from '../../utils/contextUtils.js';
5
5
  import { writeIfNotExists, updateIndexTs } from '../../utils/fileUtils.js';
6
6
 
7
- const schemaWithCoreTemplate = `import { {{coreSchema}} } from '\$core/Schema';
8
- import type { I{{name}}Request } from '\${{context}}/Domain/{{entity}}';
7
+ const schemaWithCoreTemplate = `import { {{coreSchema}} } from '\$core/schemas';
8
+ import type { I{{name}}Request } from '\${{context}}/domain/{{entity}}';
9
9
 
10
10
  export const {{name}}Schema = {{coreSchema}}<I{{name}}Request>()
11
11
  \t.rules((rules) => ({
@@ -15,7 +15,7 @@ export const {{name}}Schema = {{coreSchema}}<I{{name}}Request>()
15
15
 
16
16
  const schemaWithPackageTemplate = `import { createSchemaFactory } from '@azure-net/kit';
17
17
  import { createRules, validationMessagesI18n } from '@azure-net/kit/schema';
18
- import type { I{{name}}Request } from '\${{context}}/Domain/{{entity}}';
18
+ import type { I{{name}}Request } from '\${{context}}/domain/{{entity}}';
19
19
 
20
20
  const Schema = createSchemaFactory(createRules(validationMessagesI18n));
21
21
 
@@ -36,7 +36,7 @@ export default async function generateSchema() {
36
36
  const { module } = await prompts({
37
37
  type: 'text',
38
38
  name: 'module',
39
- message: 'Module name (folder in Delivery):'
39
+ message: 'Module name (folder in delivery):'
40
40
  });
41
41
 
42
42
  const { name } = await prompts({
@@ -47,7 +47,7 @@ export default async function generateSchema() {
47
47
 
48
48
  // Check for core schemas
49
49
  const coreSchemas = await getAvailableFiles(
50
- path.join(process.cwd(), 'src/app/core/Schema')
50
+ path.join(process.cwd(), 'src/app/core/schemas')
51
51
  );
52
52
 
53
53
  const choices = [
@@ -65,7 +65,7 @@ export default async function generateSchema() {
65
65
  const pascalName = toPascalCase(name);
66
66
  const moduleName = toPascalCase(module);
67
67
  const contextPath = getContextPath(context);
68
- const schemaPath = path.join(contextPath, 'Delivery', moduleName, 'Schema');
68
+ const schemaPath = path.join(contextPath, 'delivery', moduleName, 'schema');
69
69
  const filePath = path.join(schemaPath, `${pascalName}Schema.ts`);
70
70
 
71
71
  const content = schemaType === 'package'
@@ -83,11 +83,11 @@ export default async function generateSchema() {
83
83
  await updateIndexTs(schemaPath);
84
84
 
85
85
  // Update module index
86
- const moduleIndexPath = path.join(contextPath, 'Delivery', moduleName, 'index.ts');
86
+ const moduleIndexPath = path.join(contextPath, 'delivery', moduleName, 'index.ts');
87
87
  if (await fs.access(moduleIndexPath).then(() => true).catch(() => false)) {
88
88
  let indexContent = await fs.readFile(moduleIndexPath, 'utf-8');
89
- if (!indexContent.includes(`export * from './Schema'`)) {
90
- indexContent += `\nexport * from './Schema';`;
89
+ if (!indexContent.includes(`export * from './schema'`)) {
90
+ indexContent += `\nexport * from './schema';`;
91
91
  await fs.writeFile(moduleIndexPath, indexContent, 'utf-8');
92
92
  }
93
93
  }
@@ -4,7 +4,7 @@ import { selectContext, getContextPath, toPascalCase, getAvailableFiles } from '
4
4
  import { writeIfNotExists, updateIndexTs } from '../../utils/fileUtils.js';
5
5
 
6
6
  const serviceTemplate = `import { ClassMirror } from '@azure-net/kit';
7
- import { {{repository}} } from '\${{context}}/Infrastructure/Http/Repositories';
7
+ import { {{repository}} } from '\${{context}}/infrastructure/http/repositories';
8
8
 
9
9
  export class {{name}}Service extends ClassMirror<{{repository}}> {
10
10
  \tconstructor(private {{repositoryVar}}: {{repository}}) {
@@ -35,7 +35,7 @@ export default async function generateService() {
35
35
  // Get available repositories
36
36
  const contextPath = getContextPath(context);
37
37
  const repositories = await getAvailableFiles(
38
- path.join(contextPath, 'Infrastructure', 'Http', 'Repositories')
38
+ path.join(contextPath, 'infrastructure', 'http', 'repositories')
39
39
  );
40
40
 
41
41
  const choices = [
@@ -51,7 +51,7 @@ export default async function generateService() {
51
51
  });
52
52
 
53
53
  const pascalName = toPascalCase(name);
54
- const servicePath = path.join(contextPath, 'Application', 'Services');
54
+ const servicePath = path.join(contextPath, 'application', 'services');
55
55
  const filePath = path.join(servicePath, `${pascalName}Service.ts`);
56
56
 
57
57
  // Generate service
@@ -6,6 +6,4 @@ export { default as generateSchema } from './generateSchema.js';
6
6
  export { default as generatePresenter } from './generatePresenter.js';
7
7
  export { default as generateModule } from './generateModule.js';
8
8
  export { default as generateCrudBase } from './generateCrudBase.js';
9
- export { default as generateCrudPresenter } from './generateCrudPresenter.js';
10
- export { default as generatePresenterByService } from './generatePresenterByService.js';
11
- export { default as generateServiceByRepo } from './generateServiceByRepo.js';
9
+ export { default as generateCrudPresenter } from './generateCrudPresenter.js';
@@ -1,7 +1,7 @@
1
1
  import { writeIfNotExists, updateCoreIndex } from '../../utils/fileUtils.js';
2
2
  import path from 'path';
3
3
 
4
- const middlewarePath = path.join(process.cwd(), 'src/app/core/Middleware/MiddlewareManager.ts');
4
+ const middlewarePath = path.join(process.cwd(), 'src/app/core/middleware/MiddlewareManager.ts');
5
5
 
6
6
  const middlewareTemplate = `import { createMiddlewareManager } from '@azure-net/kit';
7
7
 
@@ -10,7 +10,7 @@ export const { clientMiddleware, serverMiddleware } = createMiddlewareManager([]
10
10
  export default async function initMiddleware() {
11
11
  await writeIfNotExists(middlewarePath, middlewareTemplate);
12
12
  await writeIfNotExists(
13
- path.join(process.cwd(), 'src/app/core/Middleware/index.ts'),
13
+ path.join(process.cwd(), 'src/app/core/middleware/index.ts'),
14
14
  `export * from './MiddlewareManager';`
15
15
  );
16
16
 
@@ -1,7 +1,7 @@
1
1
  import {updateCoreIndex, writeIfNotExists} from '../../utils/fileUtils.js';
2
2
  import path from 'path';
3
3
 
4
- const presenterPath = path.join(process.cwd(), 'src/app/core/Presenter/AppPresenter.ts');
4
+ const presenterPath = path.join(process.cwd(), 'src/app/core/presenters/AppPresenter.ts');
5
5
 
6
6
  const presenterTemplate = `import { createPresenterFactory } from '@azure-net/kit/edges';
7
7
  import { createAsyncHelpers, createErrorParser } from '@azure-net/kit';
@@ -14,7 +14,7 @@ export const AppPresenter = createPresenterFactory({ ...AsyncHelpers, handleErro
14
14
  export default async function initPresenter() {
15
15
  await writeIfNotExists(presenterPath, presenterTemplate);
16
16
  await writeIfNotExists(
17
- path.join(process.cwd(), 'src/app/core/Presenter/index.ts'),
17
+ path.join(process.cwd(), 'src/app/core/presenters/index.ts'),
18
18
  `export * from './AppPresenter';`
19
19
  );
20
20
 
@@ -1,7 +1,7 @@
1
1
  import { writeIfNotExists, updateCoreIndex } from '../../utils/fileUtils.js';
2
2
  import path from 'path';
3
3
 
4
- const schemaPath = path.join(process.cwd(), 'src/app/core/Schema/Schema.ts');
4
+ const schemaPath = path.join(process.cwd(), 'src/app/core/schemas/Schema.ts');
5
5
 
6
6
  const schemaTemplate = `import { createSchemaFactory } from '@azure-net/kit';
7
7
  import { createRules, validationMessagesI18n } from '@azure-net/kit/schema';
@@ -11,7 +11,7 @@ export const Schema = createSchemaFactory(createRules(validationMessagesI18n));`
11
11
  export default async function initSchema() {
12
12
  await writeIfNotExists(schemaPath, schemaTemplate);
13
13
  await writeIfNotExists(
14
- path.join(process.cwd(), 'src/app/core/Schema/index.ts'),
14
+ path.join(process.cwd(), 'src/app/core/schemas/index.ts'),
15
15
  `export * from './Schema';`
16
16
  );
17
17
 
@@ -27,14 +27,14 @@ async function createIndexFile(dirPath, exportPatterns = []) {
27
27
 
28
28
  async function createBaseStructure(root, contextName, contextAlias) {
29
29
  // Domain - Š½Š¾Š²Š°Ń ŃŃ‚Ń€ŃƒŠŗŃ‚ŃƒŃ€Š°
30
- const domainPath = path.join(root, 'Domain');
30
+ const domainPath = path.join(root, 'domain');
31
31
  await createDirIfNotExists(domainPath);
32
32
 
33
33
  // Infrastructure
34
- const infraPath = path.join(root, 'Infrastructure');
35
- await createDirIfNotExists(path.join(infraPath, 'Http', 'Repositories'));
36
- await createDirIfNotExists(path.join(infraPath, 'Http', 'Datasource'));
37
- await createDirIfNotExists(path.join(infraPath, 'Providers'));
34
+ const infraPath = path.join(root, 'infrastructure');
35
+ await createDirIfNotExists(path.join(infraPath, 'http', 'repositories'));
36
+ await createDirIfNotExists(path.join(infraPath, 'http', 'datasources'));
37
+ await createDirIfNotExists(path.join(infraPath, 'providers'));
38
38
 
39
39
  // Create empty InfrastructureProvider
40
40
  const infraProviderContent = `import { createBoundaryProvider } from '@azure-net/kit';
@@ -47,13 +47,13 @@ export const InfrastructureProvider = createBoundaryProvider(
47
47
  );`;
48
48
 
49
49
  await fs.writeFile(
50
- path.join(infraPath, 'Providers', 'InfrastructureProvider.ts'),
50
+ path.join(infraPath, 'providers', 'InfrastructureProvider.ts'),
51
51
  infraProviderContent,
52
52
  'utf-8'
53
53
  );
54
54
 
55
55
  await fs.writeFile(
56
- path.join(infraPath, 'Providers', 'index.ts'),
56
+ path.join(infraPath, 'providers', 'index.ts'),
57
57
  `export * from './InfrastructureProvider';`,
58
58
  'utf-8'
59
59
  );
@@ -61,18 +61,18 @@ export const InfrastructureProvider = createBoundaryProvider(
61
61
  // Create Infrastructure index
62
62
  await fs.writeFile(
63
63
  path.join(infraPath, 'index.ts'),
64
- `export * from './Providers';`,
64
+ `export * from './providers';`,
65
65
  'utf-8'
66
66
  );
67
67
 
68
68
  // Application
69
- const appPath = path.join(root, 'Application');
70
- await createDirIfNotExists(path.join(appPath, 'Services'));
71
- await createDirIfNotExists(path.join(appPath, 'Providers'));
69
+ const appPath = path.join(root, 'application');
70
+ await createDirIfNotExists(path.join(appPath, 'services'));
71
+ await createDirIfNotExists(path.join(appPath, 'providers'));
72
72
 
73
73
  // Create empty ApplicationProvider with correct import
74
74
  const appProviderContent = `import { createBoundaryProvider } from '@azure-net/kit';
75
- import { InfrastructureProvider } from '\$${contextAlias}/Infrastructure';
75
+ import { InfrastructureProvider } from '\${contextAlias}/infrastructure';
76
76
 
77
77
  export const ApplicationProvider = createBoundaryProvider(
78
78
  \t'${contextName}ApplicationProvider',
@@ -83,13 +83,13 @@ export const ApplicationProvider = createBoundaryProvider(
83
83
  );`;
84
84
 
85
85
  await fs.writeFile(
86
- path.join(appPath, 'Providers', 'ApplicationProvider.ts'),
86
+ path.join(appPath, 'providers', 'ApplicationProvider.ts'),
87
87
  appProviderContent,
88
88
  'utf-8'
89
89
  );
90
90
 
91
91
  await fs.writeFile(
92
- path.join(appPath, 'Providers', 'index.ts'),
92
+ path.join(appPath, 'providers', 'index.ts'),
93
93
  `export * from './ApplicationProvider';`,
94
94
  'utf-8'
95
95
  );
@@ -97,12 +97,12 @@ export const ApplicationProvider = createBoundaryProvider(
97
97
  // Create Application index
98
98
  await fs.writeFile(
99
99
  path.join(appPath, 'index.ts'),
100
- `export * from './Providers';`,
100
+ `export * from './providers';`,
101
101
  'utf-8'
102
102
  );
103
103
 
104
104
  // Delivery - organized by modules
105
- const deliveryPath = path.join(root, 'Delivery');
105
+ const deliveryPath = path.join(root, 'delivery');
106
106
  await createDirIfNotExists(deliveryPath);
107
107
  }
108
108
 
@@ -124,12 +124,12 @@ export default async function initStructure() {
124
124
 
125
125
  // Create core structure with all functionality
126
126
  await createDirIfNotExists(CORE_PATH);
127
- await createDirIfNotExists(path.join(CORE_PATH, 'Datasource'));
128
- await createDirIfNotExists(path.join(CORE_PATH, 'Response'));
129
- await createDirIfNotExists(path.join(CORE_PATH, 'Schema'));
130
- await createDirIfNotExists(path.join(CORE_PATH, 'Middleware'));
131
- await createDirIfNotExists(path.join(CORE_PATH, 'Presenter'));
132
- await createDirIfNotExists(path.join(CORE_PATH, 'Translation'));
127
+ await createDirIfNotExists(path.join(CORE_PATH, 'datasources'));
128
+ await createDirIfNotExists(path.join(CORE_PATH, 'responses'));
129
+ await createDirIfNotExists(path.join(CORE_PATH, 'schemas'));
130
+ await createDirIfNotExists(path.join(CORE_PATH, 'middleware'));
131
+ await createDirIfNotExists(path.join(CORE_PATH, 'presenters'));
132
+ await createDirIfNotExists(path.join(CORE_PATH, 'translations'));
133
133
 
134
134
  // Update core index
135
135
  await updateCoreIndex();
@@ -1,9 +1,9 @@
1
1
  import { writeIfNotExists, updateCoreIndex } from '../../utils/fileUtils.js';
2
2
  import path from 'path';
3
3
 
4
- const translationsPath = path.join(process.cwd(), 'src/app/core/Translation');
4
+ const translationsPath = path.join(process.cwd(), 'src/app/core/translations');
5
5
 
6
- const translationProviderTemplate = `import { messages } from './Locales';
6
+ const translationProviderTemplate = `import { messages } from './locales';
7
7
  import { createTranslations } from '@azure-net/kit/i18n';
8
8
 
9
9
  export const Translation = createTranslations({
@@ -38,17 +38,17 @@ export default async function initTranslations() {
38
38
  );
39
39
 
40
40
  await writeIfNotExists(
41
- path.join(translationsPath, 'Locales', 'en.ts'),
41
+ path.join(translationsPath, 'locales', 'en.ts'),
42
42
  enLocaleTemplate
43
43
  );
44
44
 
45
45
  await writeIfNotExists(
46
- path.join(translationsPath, 'Locales', 'ru.ts'),
46
+ path.join(translationsPath, 'locales', 'ru.ts'),
47
47
  ruLocaleTemplate
48
48
  );
49
49
 
50
50
  await writeIfNotExists(
51
- path.join(translationsPath, 'Locales', 'index.ts'),
51
+ path.join(translationsPath, 'locales', 'index.ts'),
52
52
  localesIndexTemplate
53
53
  );
54
54
 
@@ -42,7 +42,7 @@ export async function getAvailableFiles(dir, pattern = '.ts') {
42
42
 
43
43
  export async function getApplicationProviderServices(context) {
44
44
  const contextPath = getContextPath(context);
45
- const providerPath = path.join(contextPath, 'Application/Providers/ApplicationProvider.ts');
45
+ const providerPath = path.join(contextPath, 'application/providers/ApplicationProvider.ts');
46
46
 
47
47
  try {
48
48
  const content = await fs.readFile(providerPath, 'utf-8');
@@ -71,4 +71,4 @@ export function toPascalCase(str) {
71
71
  export function toCamelCase(str) {
72
72
  const pascal = toPascalCase(str);
73
73
  return pascal.charAt(0).toLowerCase() + pascal.slice(1);
74
- }
74
+ }
@@ -1,102 +0,0 @@
1
- import prompts from 'prompts';
2
- import path from 'path';
3
- import { selectContext, getContextPath, toPascalCase, getApplicationProviderServices, getAvailableFiles } from '../../utils/contextUtils.js';
4
- import { writeIfNotExists } from '../../utils/fileUtils.js';
5
-
6
- const presenterWithSharedTemplate = `import { {{presenterFactory}} } from '$shared/Presenter';
7
- import { ApplicationProvider } from '\${{context}}/Application';
8
-
9
- export const {{name}}Presenter = {{presenterFactory}}('{{name}}Presenter', ({ createAsyncResource, createAsyncAction }) => {
10
- \tconst { {{serviceName}} } = ApplicationProvider();
11
- \t
12
- {{methods}}
13
- \t
14
- \treturn { {{exports}} };
15
- });`;
16
-
17
- const presenterWithPackageTemplate = `import { createPresenter } from '@azure-net/kit';
18
- import { ApplicationProvider } from '\${{context}}/Application';
19
-
20
- export const {{name}}Presenter = createPresenter('{{name}}Presenter', () => {
21
- \tconst { {{serviceName}} } = ApplicationProvider();
22
- \t
23
- {{methods}}
24
- \t
25
- \treturn { {{exports}} };
26
- });`;
27
-
28
- export default async function generatePresenterByService() {
29
- const context = await selectContext('Select context:');
30
-
31
- // Get available services from ApplicationProvider
32
- const services = await getApplicationProviderServices(context);
33
-
34
- if (services.length === 0) {
35
- console.error('āŒ No services found in ApplicationProvider. Add services manually first.');
36
- return;
37
- }
38
-
39
- const { service } = await prompts({
40
- type: 'select',
41
- name: 'service',
42
- message: 'Select service to create presenter from:',
43
- choices: services.map(s => ({ title: s, value: s }))
44
- });
45
-
46
- // Get presenter factory
47
- const sharedPresenters = await getAvailableFiles(
48
- path.join(process.cwd(), 'src/app/shared/Presenter')
49
- );
50
-
51
- const { presenterType } = await prompts({
52
- type: 'select',
53
- name: 'presenterType',
54
- message: 'Select presenter factory:',
55
- choices: [
56
- { title: 'Use createPresenter from package', value: 'package' },
57
- ...sharedPresenters.map(p => ({ title: `Use ${p} from shared`, value: p }))
58
- ]
59
- });
60
-
61
- const entityName = service.replace('Service', '');
62
- const pascalName = toPascalCase(entityName);
63
- const contextPath = getContextPath(context);
64
- const deliveryModulePath = path.join(contextPath, 'Delivery', pascalName);
65
-
66
- // Generate method declarations based on common service patterns
67
- const commonMethods = ['collection', 'resource', 'create', 'update', 'remove'];
68
-
69
- const methods = presenterType === 'package'
70
- ? commonMethods.map(m => `\tconst ${m} = async (...args: Parameters<typeof ${service}['${m}']>) =>
71
- \t\tawait ${service}.${m}(...args);`).join('\n\n')
72
- : commonMethods.map(m => `\tconst ${m} = async (...args: Parameters<typeof ${service}['${m}']>) =>
73
- \t\tawait createAsyncResource(${service}.${m}(...args));`).join('\n\n');
74
-
75
- const exports = commonMethods.join(', ');
76
-
77
- const template = presenterType === 'package'
78
- ? presenterWithPackageTemplate
79
- : presenterWithSharedTemplate;
80
-
81
- const presenterFactory = presenterType === 'package' ? 'createPresenter' : presenterType;
82
-
83
- await writeIfNotExists(
84
- path.join(deliveryModulePath, `${pascalName}Presenter.ts`),
85
- template
86
- .replace(/{{name}}/g, pascalName)
87
- .replace(/{{context}}/g, context)
88
- .replace(/{{serviceName}}/g, service)
89
- .replace(/{{presenterFactory}}/g, presenterFactory)
90
- .replace(/{{methods}}/g, methods)
91
- .replace(/{{exports}}/g, exports)
92
- );
93
-
94
- // Create module index
95
- await writeIfNotExists(
96
- path.join(deliveryModulePath, 'index.ts'),
97
- `export * from './${pascalName}Presenter';`
98
- );
99
-
100
- console.log(`āœ… Presenter for ${service} created successfully!`);
101
- console.log(`\nšŸ’” Note: Methods are based on common patterns. Adjust them to match your actual service methods.`);
102
- }
@@ -1,86 +0,0 @@
1
- import prompts from 'prompts';
2
- import path from 'path';
3
- import fs from 'fs/promises';
4
- import { selectContext, getContextPath, toPascalCase, getAvailableFiles } from '../../utils/contextUtils.js';
5
- import { writeIfNotExists, updateIndexTs } from '../../utils/fileUtils.js';
6
-
7
- const serviceTemplate = `import { ClassMirror } from '@azure-net/kit';
8
- import { {{repository}} } from '\${{context}}/Infrastructure/Http/Repositories';
9
-
10
- export class {{name}}Service extends ClassMirror<{{repository}}> {
11
- \tconstructor(private {{repositoryVar}}: {{repository}}) {
12
- \t\tsuper({{repositoryVar}});
13
- \t}
14
- \t
15
- {{methodDeclarations}}
16
- }`;
17
-
18
- export default async function generateServiceByRepo() {
19
- const context = await selectContext('Select context:');
20
-
21
- const contextPath = getContextPath(context);
22
- const repositories = await getAvailableFiles(
23
- path.join(contextPath, 'Infrastructure/Http/Repositories')
24
- );
25
-
26
- if (repositories.length === 0) {
27
- console.error('āŒ No repositories available. Create a repository first.');
28
- return;
29
- }
30
-
31
- const { repository } = await prompts({
32
- type: 'select',
33
- name: 'repository',
34
- message: 'Select repository to create service from:',
35
- choices: repositories.map(r => ({ title: r, value: r }))
36
- });
37
-
38
- const serviceName = repository.replace('Repository', 'Service');
39
- const servicePath = path.join(contextPath, 'Application/Services');
40
- const filePath = path.join(servicePath, `${serviceName}.ts`);
41
-
42
- // Try to get repository file to extract methods
43
- const repoFilePath = path.join(contextPath, 'Infrastructure/Http/Repositories', `${repository}.ts`);
44
- let methodDeclarations = '';
45
-
46
- try {
47
- const repoContent = await fs.readFile(repoFilePath, 'utf-8');
48
- // Extract public methods from repository
49
- const methodRegex = /public async (\w+)\([^)]*\)(?:\s*:\s*[^{]+)?/g;
50
- const methods = [];
51
- let match;
52
-
53
- while ((match = methodRegex.exec(repoContent)) !== null) {
54
- methods.push(match[1]);
55
- }
56
-
57
- if (methods.length > 0) {
58
- methodDeclarations = methods
59
- .map(m => `\tdeclare ${m}: ${repository}['${m}'];`)
60
- .join('\n');
61
- } else {
62
- // Fallback to common CRUD methods
63
- methodDeclarations = [
64
- 'collection', 'resource', 'create', 'update', 'remove'
65
- ].map(m => `\tdeclare ${m}: ${repository}['${m}'];`).join('\n');
66
- }
67
- } catch (error) {
68
- // Fallback if can't read repository file
69
- methodDeclarations = [
70
- 'collection', 'resource', 'create', 'update', 'remove'
71
- ].map(m => `\tdeclare ${m}: ${repository}['${m}'];`).join('\n');
72
- }
73
-
74
- const content = serviceTemplate
75
- .replace(/{{name}}/g, serviceName.replace('Service', ''))
76
- .replace(/{{repository}}/g, repository)
77
- .replace(/{{repositoryVar}}/g, repository.charAt(0).toLowerCase() + repository.slice(1))
78
- .replace(/{{context}}/g, context)
79
- .replace(/{{methodDeclarations}}/g, methodDeclarations);
80
-
81
- await writeIfNotExists(filePath, content);
82
- await updateIndexTs(servicePath);
83
-
84
- console.log(`āœ… Service created at ${filePath}`);
85
- console.log(`\nšŸ’” Remember to manually add this service to ApplicationProvider when needed.`);
86
- }