@azure-net/cli 2.0.7 → 2.0.9

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
@@ -110,11 +110,6 @@ program
110
110
  .description('Generate presenter')
111
111
  .action(generatePresenter);
112
112
 
113
- program
114
- .command('make:module')
115
- .description('Generate complete module')
116
- .action(generateModule);
117
-
118
113
  program
119
114
  .command('make:crud-base')
120
115
  .description('Generate CRUD repository and service')
@@ -125,11 +120,6 @@ program
125
120
  .description('Generate CRUD presenter for existing service')
126
121
  .action(generateCrudPresenter);
127
122
 
128
- program
129
- .command('make:presenter-by-service')
130
- .description('Generate presenter from existing service')
131
- .action(generatePresenterByService);
132
-
133
123
  program
134
124
  .command('make:service-by-repo')
135
125
  .description('Generate service from existing repository')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
@@ -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
- 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}
8
+ export class {{name}}Response<TData = unknown, TMeta = unknown> extends ResponseBuilder<TData, TMeta, TData> {
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
  }
@@ -5,6 +5,7 @@ import { loadUserConfig } from '../../utils/loadConfig.js';
5
5
  const APP_ROOT = path.join(process.cwd(), 'src', 'app');
6
6
  const CONTEXTS_PATH = path.join(APP_ROOT, 'contexts');
7
7
  const SHARED_PATH = path.join(APP_ROOT, 'shared');
8
+ const CORE_PATH = path.join(APP_ROOT, 'shared', 'core');
8
9
 
9
10
  async function createDirIfNotExists(dirPath) {
10
11
  try {
@@ -23,7 +24,7 @@ async function createIndexFile(dirPath, exportPatterns = []) {
23
24
  }
24
25
  }
25
26
 
26
- async function createBaseStructure(root, contextName) {
27
+ async function createBaseStructure(root, contextName, contextAlias) {
27
28
  // Domain
28
29
  const domainPath = path.join(root, 'Domain');
29
30
  await createDirIfNotExists(path.join(domainPath, 'Entities'));
@@ -69,9 +70,9 @@ export const InfrastructureProvider = createBoundaryProvider(
69
70
  await createDirIfNotExists(path.join(appPath, 'Services'));
70
71
  await createDirIfNotExists(path.join(appPath, 'Providers'));
71
72
 
72
- // Create empty ApplicationProvider
73
+ // Create empty ApplicationProvider with correct import
73
74
  const appProviderContent = `import { createBoundaryProvider } from '@azure-net/kit';
74
- import { InfrastructureProvider } from '../Infrastructure';
75
+ import { InfrastructureProvider } from '\$${contextAlias}/Infrastructure';
75
76
 
76
77
  export const ApplicationProvider = createBoundaryProvider(
77
78
  \t'${contextName}ApplicationProvider',
@@ -115,7 +116,7 @@ export default async function initStructure() {
115
116
  for (const context of contexts) {
116
117
  const contextPath = path.join(CONTEXTS_PATH, context);
117
118
  const contextName = context.charAt(0).toUpperCase() + context.slice(1);
118
- await createBaseStructure(contextPath, contextName);
119
+ await createBaseStructure(contextPath, contextName, context);
119
120
  }
120
121
 
121
122
  // 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
  }
@@ -8,8 +8,8 @@ export async function loadUserConfig() {
8
8
  return userConfig.default || {};
9
9
  } catch {
10
10
  return {
11
- contexts: ['app'],
12
- defaultContext: 'app'
11
+ contexts: ['public'],
12
+ defaultContext: 'public'
13
13
  };
14
14
  }
15
15
  }
@@ -1,7 +0,0 @@
1
- import { BaseHttpDatasource, HttpService } from '@azure-net/kit';
2
-
3
- export class <%= name %>Datasource extends BaseHttpDatasource {
4
- constructor() {
5
- super({ http: new HttpService({ baseUrl: '' }) });
6
- }
7
- }
@@ -1,33 +0,0 @@
1
- import { <%= datasource %> } from '$core/datasources';
2
- import type {
3
- I<%= pascalCaseName %>Collection,
4
- I<%= pascalCaseName %>Resource,
5
- I<%= pascalCaseName %>CreateRequest,
6
- I<%= pascalCaseName %>UpdateRequest,
7
- I<%= pascalCaseName %>CollectionQuery,
8
- } from '<%= aliasDomain %>/<%= pascalCaseName %>';
9
-
10
- export class <%= pascalCaseName %>Repo {
11
- private endpoint = '<%= endpoint %>';
12
- constructor(private source = new <%= datasource %>()) {}
13
-
14
- public async collection(queryParams?: I<%= pascalCaseName %>CollectionQuery) {
15
- return await this.source.createRequest<I<%= pascalCaseName %>Collection>(({ http, query }) => http.get(`${this.endpoint}${query.build(queryParams)}`));
16
- }
17
-
18
- public async resource(id: number) {
19
- return await this.source.createRequest<I<%= pascalCaseName %>Resource>(({ http }) => http.get(`${this.endpoint}/${id}`));
20
- }
21
-
22
- public async create(data: I<%= pascalCaseName %>CreateRequest) {
23
- return await this.source.createRequest<I<%= pascalCaseName %>Resource>(({ http }) => http.post(this.endpoint, { json: data }));
24
- }
25
-
26
- public async update(id: number, data: I<%= pascalCaseName %>UpdateRequest) {
27
- return await this.source.createRequest<I<%= pascalCaseName %>Resource>(({ http }) => http.put(`${this.endpoint}/${id}`, { json: data }));
28
- }
29
-
30
- public async remove(id: number) {
31
- return await this.source.createRequest<never>(({ http }) => http.delete(`${this.endpoint}/${id}`));
32
- }
33
- }
@@ -1,6 +0,0 @@
1
- export interface I<%= pascalCaseName %>Resource {
2
- // TODO: define fields
3
- [key: string]: unknown;
4
- }
5
-
6
- export type I<%= pascalCaseName %>Collection = I<%= pascalCaseName %>Resource[];
@@ -1,3 +0,0 @@
1
- export interface I<%= pascalCaseName %>CollectionQuery {
2
- [key: string]: unknown;
3
- }
@@ -1,4 +0,0 @@
1
- export interface I<%= pascalCaseName %>CreateRequest {
2
- // TODO: define fields
3
- [key: string]: unknown;
4
- }
@@ -1,4 +0,0 @@
1
- export interface I<%= pascalCaseName %>UpdateRequest {
2
- // TODO: define fields
3
- [key: string]: unknown;
4
- }
@@ -1,8 +0,0 @@
1
- import { BaseRequest } from '@azure-net/kit';
2
- import type { I<%= pascalCaseName %>CreateRequest } from '../Abstracts';
3
-
4
- export class <%= pascalCaseName %>CreateRequest extends BaseRequest<I<%= pascalCaseName %>CreateRequest> {
5
- override rules() {
6
- return {};
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- import { BaseRequest } from '@azure-net/kit';
2
- import type { I<%= pascalCaseName %>Request } from '../Abstracts';
3
-
4
- export class <%= pascalCaseName %>Request extends BaseRequest<I<%= pascalCaseName %>Request> {
5
- override rules() {
6
- return {};
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- import { BaseRequest } from '@azure-net/kit';
2
- import type { I<%= pascalCaseName %>UpdateRequest } from '../Abstracts';
3
-
4
- export class <%= pascalCaseName %>UpdateRequest extends BaseRequest<I<%= pascalCaseName %>UpdateRequest> {
5
- override rules() {
6
- return {};
7
- }
8
- }
@@ -1,29 +0,0 @@
1
- import { BaseService } from '@azure-net/kit';
2
- import { <%= pascalCaseName %>Repo } from '<%= aliasRepo %>';
3
- import type { <%= pascalCaseName %>CreateRequest, <%= pascalCaseName %>UpdateRequest, I<%= pascalCaseName %>CollectionQuery } from '<%= aliasDomain %>/<%= pascalCaseName %>';
4
-
5
- export class <%= pascalCaseName %>Service extends BaseService {
6
- constructor(private <%= camelCaseName %>Repo = new <%= pascalCaseName %>Repo()) {
7
- super();
8
- }
9
-
10
- async collection(queryParams?: I<%= pascalCaseName %>CollectionQuery) {
11
- return await this.transformResponse(this.<%= camelCaseName %>Repo.collection(queryParams));
12
- }
13
-
14
- async resource(id: number) {
15
- return await this.transformResponse(this.<%= camelCaseName %>Repo.resource(id));
16
- }
17
-
18
- async create(request: <%= pascalCaseName %>CreateRequest) {
19
- return await this.transformResponse(this.<%= camelCaseName %>Repo.create(request.json()));
20
- }
21
-
22
- async update(id: number, request: <%= pascalCaseName %>UpdateRequest) {
23
- return await this.transformResponse(this.<%= camelCaseName %>Repo.update(id, request.json()));
24
- }
25
-
26
- async remove(id: number) {
27
- return await this.transformResponse(this.<%= camelCaseName %>Repo.remove(id));
28
- }
29
- }