@azure-net/cli 2.0.6 → 2.0.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/bin/azure-net.js CHANGED
@@ -73,10 +73,10 @@ program
73
73
  .action(async () => {
74
74
  await initStructure();
75
75
  await initAliases();
76
- await initEdges();
77
- await initMiddleware();
78
- await initTranslations();
79
- await initSchema();
76
+ // await initEdges();
77
+ // await initMiddleware();
78
+ // await initTranslations();
79
+ // await initSchema();
80
80
  });
81
81
 
82
82
  // Generate commands
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
@@ -2,7 +2,7 @@ import prompts from 'prompts';
2
2
  import path from 'path';
3
3
  import fs from 'fs/promises';
4
4
  import { selectContext, getContextPath, toPascalCase, getAvailableFiles, getApplicationProviderServices } from '../../utils/contextUtils.js';
5
- import { writeIfNotExists } from '../../utils/fileUtils.js';
5
+ import {updateIndexTs, writeIfNotExists} from '../../utils/fileUtils.js';
6
6
 
7
7
  const createSchemaTemplate = `import { {{schemaFactory}} } from '{{schemaImport}}';
8
8
  import type { I{{name}}CreateRequest } from '\${{context}}/Domain/Ports/{{entity}}';
@@ -5,7 +5,6 @@ import { writeIfNotExists, updateIndexTs } from '../../utils/fileUtils.js';
5
5
 
6
6
  const datasourceWithResponseTemplate = `import { BaseHttpDatasource, type CreateRequestCallbackType } from '@azure-net/kit/infra';
7
7
  import { {{responseClass}}, type {{responseInterface}} } from '{{responseImport}}';
8
- import { HttpService } from '@azure-net/kit/infra';
9
8
 
10
9
  export class {{name}}Datasource extends BaseHttpDatasource {
11
10
  \tasync createRequest<T>(callback: CreateRequestCallbackType<{{responseInterface}}<T>>) {
@@ -5,16 +5,7 @@ import { writeIfNotExists, updateIndexTs } from '../../utils/fileUtils.js';
5
5
 
6
6
  const responseTemplate = `import { ResponseBuilder } from '@azure-net/kit/infra';
7
7
 
8
- export interface I{{name}}Response<T = unknown> {
9
- \tdata: T;
10
- \tsuccess: boolean;
11
- \tmessage: string;
12
- }
13
-
14
8
  export class {{name}}Response<TData = unknown, TMeta = unknown> extends ResponseBuilder<TData, TMeta, I{{name}}Response<TData>> {
15
- \toverride unwrapData(data: I{{name}}Response<TData>): TData {
16
- \t\treturn data.data;
17
- \t}
18
9
  }`;
19
10
 
20
11
  export default async function generateResponse() {
@@ -2,8 +2,6 @@ import { writeIfNotExists, injectIntoFile } from '../../utils/fileUtils.js';
2
2
  import path from 'path';
3
3
 
4
4
  const middlewarePath = path.join(process.cwd(), 'src/app/shared/Middleware/MiddlewareManager.ts');
5
- const hooksServerPath = path.join(process.cwd(), 'src/hooks.server.ts');
6
- const layoutPath = path.join(process.cwd(), 'src/routes/+layout.svelte');
7
5
 
8
6
  const middlewareTemplate = `import { createMiddlewareManager } from '@azure-net/kit';
9
7
 
@@ -16,28 +14,5 @@ export default async function initMiddleware() {
16
14
  `export * from './MiddlewareManager';`
17
15
  );
18
16
 
19
- // Add to hooks.server.ts
20
- await injectIntoFile(
21
- hooksServerPath,
22
- 'import',
23
- `import { serverMiddleware } from '$shared';`,
24
- 'before'
25
- );
26
-
27
- await injectIntoFile(
28
- hooksServerPath,
29
- 'async ({ edgesEvent, serialize }) => {',
30
- '\t\t\tawait serverMiddleware();',
31
- 'after'
32
- );
33
-
34
- // Add to +layout.svelte
35
- await injectIntoFile(
36
- layoutPath,
37
- '<script',
38
- `\timport { clientMiddleware } from '$shared';\n\tclientMiddleware();`,
39
- 'after'
40
- );
41
-
42
17
  console.log('✅ Middleware initialized');
43
18
  }
@@ -23,7 +23,7 @@ async function createIndexFile(dirPath, exportPatterns = []) {
23
23
  }
24
24
  }
25
25
 
26
- async function createBaseStructure(root, contextName) {
26
+ async function createBaseStructure(root, contextName, contextAlias) {
27
27
  // Domain
28
28
  const domainPath = path.join(root, 'Domain');
29
29
  await createDirIfNotExists(path.join(domainPath, 'Entities'));
@@ -69,9 +69,9 @@ export const InfrastructureProvider = createBoundaryProvider(
69
69
  await createDirIfNotExists(path.join(appPath, 'Services'));
70
70
  await createDirIfNotExists(path.join(appPath, 'Providers'));
71
71
 
72
- // Create empty ApplicationProvider
72
+ // Create empty ApplicationProvider with correct import
73
73
  const appProviderContent = `import { createBoundaryProvider } from '@azure-net/kit';
74
- import { InfrastructureProvider } from '../Infrastructure';
74
+ import { InfrastructureProvider } from '\$${contextAlias}/Infrastructure';
75
75
 
76
76
  export const ApplicationProvider = createBoundaryProvider(
77
77
  \t'${contextName}ApplicationProvider',
@@ -115,7 +115,7 @@ export default async function initStructure() {
115
115
  for (const context of contexts) {
116
116
  const contextPath = path.join(CONTEXTS_PATH, context);
117
117
  const contextName = context.charAt(0).toUpperCase() + context.slice(1);
118
- await createBaseStructure(contextPath, contextName);
118
+ await createBaseStructure(contextPath, contextName, context);
119
119
  }
120
120
 
121
121
  // Create shared structure (former core)
@@ -1,9 +1,7 @@
1
- import { writeIfNotExists, injectIntoFile } from '../../utils/fileUtils.js';
1
+ import { writeIfNotExists } from '../../utils/fileUtils.js';
2
2
  import path from 'path';
3
3
 
4
4
  const translationsPath = path.join(process.cwd(), 'src/app/shared/Translation');
5
- const layoutServerPath = path.join(process.cwd(), 'src/routes/+layout.server.ts');
6
- const layoutTsPath = path.join(process.cwd(), 'src/routes/+layout.ts');
7
5
 
8
6
  const translationProviderTemplate = `import { messages } from './Locales';
9
7
  import { createTranslations } from '@azure-net/kit/i18n';
@@ -54,49 +52,5 @@ export default async function initTranslations() {
54
52
  localesIndexTemplate
55
53
  );
56
54
 
57
- // Add to hooks.server.ts
58
- await injectIntoFile(
59
- path.join(process.cwd(), 'src/hooks.server.ts'),
60
- 'import',
61
- `import { Translation } from '$shared';`,
62
- 'before'
63
- );
64
-
65
- await injectIntoFile(
66
- path.join(process.cwd(), 'src/hooks.server.ts'),
67
- 'await serverMiddleware();',
68
- `\t\t\tconst { preloadTranslation, applyHtmlLocaleAttr } = Translation();\n\t\t\tawait preloadTranslation(edgesEvent);`,
69
- 'after'
70
- );
71
-
72
- await injectIntoFile(
73
- path.join(process.cwd(), 'src/hooks.server.ts'),
74
- 'transformPageChunk: ({ html })',
75
- ' => {\n\t\t\t\tconst serialized = serialize(html);\n\t\t\t\treturn applyHtmlLocaleAttr(serialized);\n\t\t\t}',
76
- 'after'
77
- );
78
-
79
- // Add to layout files
80
- await injectIntoFile(
81
- layoutServerPath,
82
- 'export const load',
83
- `\treturn { lang: locals.lang };`,
84
- 'after'
85
- );
86
-
87
- await injectIntoFile(
88
- layoutTsPath,
89
- 'import',
90
- `import { Translation } from '$shared';\nimport { browser } from '$app/environment';`,
91
- 'before'
92
- );
93
-
94
- await injectIntoFile(
95
- layoutTsPath,
96
- 'export const load',
97
- `\tconst { syncTranslation } = Translation();\n\tif (browser) {\n\t\tawait syncTranslation({ lang: data.lang }, false);\n\t}`,
98
- 'after'
99
- );
100
-
101
55
  console.log('✅ Translations initialized');
102
56
  }