@azure-net/cli 2.1.8 → 2.2.1

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.8",
3
+ "version": "2.2.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
@@ -1,6 +1,13 @@
1
1
  import prompts from 'prompts';
2
2
  import path from 'path';
3
- import { selectContext, getContextPath, toPascalCase, toCamelCase, getAvailableFiles } from '../../utils/contextUtils.js';
3
+ import {
4
+ selectContext,
5
+ getContextPath,
6
+ toPascalCase,
7
+ toCamelCase,
8
+ getAvailableFiles,
9
+ toKebabCase
10
+ } from '../../utils/contextUtils.js';
4
11
  import { writeIfNotExists, updateIndexTs, updateCoreIndex } from '../../utils/fileUtils.js';
5
12
 
6
13
  // Templates for CRUD base generation
@@ -132,7 +139,7 @@ export default async function generateCrudBase() {
132
139
 
133
140
  const pascalName = toPascalCase(name);
134
141
  const camelName = toCamelCase(name);
135
- const entityLower = pascalName.toLowerCase();
142
+ const entityLower = toKebabCase(pascalName);
136
143
 
137
144
  console.log('\nšŸš€ Generating CRUD base (repository & service)...\n');
138
145
 
@@ -166,7 +173,7 @@ export default async function generateCrudBase() {
166
173
  const repoPath = path.join(contextPath, 'infrastructure/http/repositories');
167
174
  const datasourceImport = datasource.from === 'core'
168
175
  ? '$core/datasources'
169
- : `\${context}/infrastructure/http/datasources`;
176
+ : `\$${context}/infrastructure/http/datasources`;
170
177
 
171
178
  await writeIfNotExists(
172
179
  path.join(repoPath, `${pascalName}Repository.ts`),
@@ -1,6 +1,13 @@
1
1
  import prompts from 'prompts';
2
2
  import path from 'path';
3
- import { selectContext, getContextPath, toPascalCase, getAvailableFiles, getApplicationProviderServices } from '../../utils/contextUtils.js';
3
+ import {
4
+ selectContext,
5
+ getContextPath,
6
+ toPascalCase,
7
+ getAvailableFiles,
8
+ getApplicationProviderServices,
9
+ toKebabCase
10
+ } from '../../utils/contextUtils.js';
4
11
  import { updateIndexTs, writeIfNotExists, updateCoreIndex } from '../../utils/fileUtils.js';
5
12
 
6
13
  const createSchemaTemplate = `import { {{schemaFactory}} } from '{{schemaImport}}';
@@ -102,7 +109,7 @@ export default async function generateCrudPresenter() {
102
109
  // Extract entity name from service name
103
110
  const entityName = service.replace('Service', '');
104
111
  const pascalName = toPascalCase(entityName);
105
- const entityLower = pascalName.toLowerCase();
112
+ const entityLower = toKebabCase(pascalName);
106
113
 
107
114
  // Get schema factory
108
115
  const coreSchemas = await getAvailableFiles(
@@ -72,3 +72,10 @@ export function toCamelCase(str) {
72
72
  const pascal = toPascalCase(str);
73
73
  return pascal.charAt(0).toLowerCase() + pascal.slice(1);
74
74
  }
75
+
76
+ export function toKebabCase(str) {
77
+ return str
78
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
79
+ .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
80
+ .toLowerCase();
81
+ }