@azure-net/cli 2.1.7 → 2.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
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/{{entityLower}}/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/{{entityLower}}';
45
45
 
46
46
  export class {{name}}Repository {
47
47
  \tprivate endpoint = '{{endpoint}}';
@@ -132,11 +132,12 @@ export default async function generateCrudBase() {
132
132
 
133
133
  const pascalName = toPascalCase(name);
134
134
  const camelName = toCamelCase(name);
135
+ const entityLower = pascalName.toLowerCase();
135
136
 
136
137
  console.log('\nšŸš€ Generating CRUD base (repository & service)...\n');
137
138
 
138
139
  // 1. Create Domain structure
139
- const domainPath = path.join(contextPath, 'domain', pascalName);
140
+ const domainPath = path.join(contextPath, 'domain', entityLower);
140
141
  const modelPath = path.join(domainPath, 'model');
141
142
  const portsPath = path.join(domainPath, 'ports');
142
143
 
@@ -152,6 +153,7 @@ export default async function generateCrudBase() {
152
153
  portsIndexTemplate
153
154
  .replace(/{{name}}/g, pascalName)
154
155
  .replace(/{{context}}/g, context)
156
+ .replace(/{{entityLower}}/g, entityLower)
155
157
  );
156
158
 
157
159
  // Create Domain module index
@@ -164,7 +166,7 @@ export default async function generateCrudBase() {
164
166
  const repoPath = path.join(contextPath, 'infrastructure/http/repositories');
165
167
  const datasourceImport = datasource.from === 'core'
166
168
  ? '$core/datasources'
167
- : `\$${context}/infrastructure/http/datasources`;
169
+ : `\${context}/infrastructure/http/datasources`;
168
170
 
169
171
  await writeIfNotExists(
170
172
  path.join(repoPath, `${pascalName}Repository.ts`),
@@ -175,6 +177,7 @@ export default async function generateCrudBase() {
175
177
  .replace(/{{datasource}}/g, datasource.name)
176
178
  .replace(/{{datasourceImport}}/g, datasourceImport)
177
179
  .replace(/{{datasourceVar}}/g, toCamelCase(datasource.name))
180
+ .replace(/{{entityLower}}/g, entityLower)
178
181
  );
179
182
  await updateIndexTs(repoPath);
180
183
 
@@ -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/{{entityLower}}';
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/{{entityLower}}';
17
17
 
18
18
  export const Update{{name}}Schema = {{schemaFactory}}<I{{name}}UpdateRequest>()
19
19
  \t.rules((rules) => ({
@@ -28,7 +28,7 @@ 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/{{entityLower}}';
32
32
 
33
33
  export const {{name}}Presenter = {{presenterFactory}}('{{name}}Presenter', ({ createAsyncResource, createAsyncAction }) => {
34
34
  \tconst { {{serviceName}} } = ApplicationProvider();
@@ -58,7 +58,7 @@ 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/{{entityLower}}';
62
62
 
63
63
  export const {{name}}Presenter = createPresenter('{{name}}Presenter', () => {
64
64
  \tconst { {{serviceName}} } = ApplicationProvider();
@@ -102,6 +102,7 @@ export default async function generateCrudPresenter() {
102
102
  // Extract entity name from service name
103
103
  const entityName = service.replace('Service', '');
104
104
  const pascalName = toPascalCase(entityName);
105
+ const entityLower = pascalName.toLowerCase();
105
106
 
106
107
  // Get schema factory
107
108
  const coreSchemas = await getAvailableFiles(
@@ -134,7 +135,7 @@ export default async function generateCrudPresenter() {
134
135
  });
135
136
 
136
137
  const contextPath = getContextPath(context);
137
- const deliveryModulePath = path.join(contextPath, 'delivery', pascalName);
138
+ const deliveryModulePath = path.join(contextPath, 'delivery', entityLower);
138
139
  const schemaPath = path.join(deliveryModulePath, 'schema');
139
140
 
140
141
  console.log('\nšŸš€ Generating CRUD presenter...\n');
@@ -157,7 +158,7 @@ const Schema = createSchemaFactory(createRules(validationMessagesI18n));`;
157
158
  .replace('import { {{schemaFactory}} } from \'{{schemaImport}}\';\n', '')
158
159
  .replace(/{{name}}/g, pascalName)
159
160
  .replace(/{{context}}/g, context)
160
- .replace(/{{entity}}/g, pascalName)
161
+ .replace(/{{entityLower}}/g, entityLower)
161
162
  .replace(/{{schemaFactory}}/g, 'Schema')
162
163
  );
163
164
 
@@ -167,7 +168,7 @@ const Schema = createSchemaFactory(createRules(validationMessagesI18n));`;
167
168
  .replace('import { {{schemaFactory}} } from \'{{schemaImport}}\';\n', '')
168
169
  .replace(/{{name}}/g, pascalName)
169
170
  .replace(/{{context}}/g, context)
170
- .replace(/{{entity}}/g, pascalName)
171
+ .replace(/{{entityLower}}/g, entityLower)
171
172
  .replace(/{{schemaFactory}}/g, 'Schema')
172
173
  );
173
174
  } else {
@@ -176,7 +177,7 @@ const Schema = createSchemaFactory(createRules(validationMessagesI18n));`;
176
177
  createSchemaTemplate
177
178
  .replace(/{{name}}/g, pascalName)
178
179
  .replace(/{{context}}/g, context)
179
- .replace(/{{entity}}/g, pascalName)
180
+ .replace(/{{entityLower}}/g, entityLower)
180
181
  .replace(/{{schemaFactory}}/g, schemaFactory)
181
182
  .replace(/{{schemaImport}}/g, schemaImport)
182
183
  );
@@ -186,7 +187,7 @@ const Schema = createSchemaFactory(createRules(validationMessagesI18n));`;
186
187
  updateSchemaTemplate
187
188
  .replace(/{{name}}/g, pascalName)
188
189
  .replace(/{{context}}/g, context)
189
- .replace(/{{entity}}/g, pascalName)
190
+ .replace(/{{entityLower}}/g, entityLower)
190
191
  .replace(/{{schemaFactory}}/g, schemaFactory)
191
192
  .replace(/{{schemaImport}}/g, schemaImport)
192
193
  );
@@ -207,6 +208,7 @@ const Schema = createSchemaFactory(createRules(validationMessagesI18n));`;
207
208
  .replace(/{{context}}/g, context)
208
209
  .replace(/{{serviceName}}/g, service)
209
210
  .replace(/{{presenterFactory}}/g, presenterFactory)
211
+ .replace(/{{entityLower}}/g, entityLower)
210
212
  );
211
213
 
212
214
  // Create module index
@@ -58,8 +58,9 @@ export default async function generatePresenter() {
58
58
  });
59
59
 
60
60
  const pascalName = toPascalCase(name);
61
+ const moduleLower = pascalName.toLowerCase();
61
62
  const contextPath = getContextPath(context);
62
- const modulePath = path.join(contextPath, 'delivery', pascalName);
63
+ const modulePath = path.join(contextPath, 'delivery', moduleLower);
63
64
  const filePath = path.join(modulePath, `${pascalName}Presenter.ts`);
64
65
 
65
66
  const content = presenterType === 'package'
@@ -5,7 +5,7 @@ import { selectContext, getContextPath, toPascalCase, getAvailableFiles } from '
5
5
  import { writeIfNotExists, updateIndexTs } from '../../utils/fileUtils.js';
6
6
 
7
7
  const schemaWithCoreTemplate = `import { {{coreSchema}} } from '\$core/schemas';
8
- import type { I{{name}}Request } from '\${{context}}/domain/{{entity}}';
8
+ import type { I{{name}}Request } from '\${{context}}/domain/{{entityLower}}';
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/{{entityLower}}';
19
19
 
20
20
  const Schema = createSchemaFactory(createRules(validationMessagesI18n));
21
21
 
@@ -64,26 +64,28 @@ export default async function generateSchema() {
64
64
 
65
65
  const pascalName = toPascalCase(name);
66
66
  const moduleName = toPascalCase(module);
67
+ const moduleLower = moduleName.toLowerCase();
68
+ const entityLower = moduleName.toLowerCase();
67
69
  const contextPath = getContextPath(context);
68
- const schemaPath = path.join(contextPath, 'delivery', moduleName, 'schema');
70
+ const schemaPath = path.join(contextPath, 'delivery', moduleLower, 'schema');
69
71
  const filePath = path.join(schemaPath, `${pascalName}Schema.ts`);
70
72
 
71
73
  const content = schemaType === 'package'
72
74
  ? schemaWithPackageTemplate
73
75
  .replace(/{{name}}/g, pascalName)
74
76
  .replace(/{{context}}/g, context)
75
- .replace(/{{entity}}/g, moduleName)
77
+ .replace(/{{entityLower}}/g, entityLower)
76
78
  : schemaWithCoreTemplate
77
79
  .replace(/{{name}}/g, pascalName)
78
80
  .replace(/{{context}}/g, context)
79
- .replace(/{{entity}}/g, moduleName)
81
+ .replace(/{{entityLower}}/g, entityLower)
80
82
  .replace(/{{coreSchema}}/g, schemaType);
81
83
 
82
84
  await writeIfNotExists(filePath, content);
83
85
  await updateIndexTs(schemaPath);
84
86
 
85
87
  // Update module index
86
- const moduleIndexPath = path.join(contextPath, 'delivery', moduleName, 'index.ts');
88
+ const moduleIndexPath = path.join(contextPath, 'delivery', moduleLower, 'index.ts');
87
89
  if (await fs.access(moduleIndexPath).then(() => true).catch(() => false)) {
88
90
  let indexContent = await fs.readFile(moduleIndexPath, 'utf-8');
89
91
  if (!indexContent.includes(`export * from './schema'`)) {