@azure-net/cli 1.3.5 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
@@ -48,52 +48,62 @@ export default async function generateCrud() {
48
48
  const selectedModule = answers.module;
49
49
 
50
50
  const baseArch = path.join(process.cwd(), 'src/app/contexts');
51
- const basePath = selectedModule ? path.join(baseArch, selectedModule) : baseArch;
51
+ const basePath = selectedModule ? path.join(baseArch, selectedModule) : path.join(baseArch, 'app-context');
52
52
 
53
- const domainPath = path.join(basePath, 'domain', lower);
54
- const serviceDir = path.join(basePath, 'application', 'services');
55
- const repoPath = path.join(basePath, 'infra', 'repo');
53
+ const domainPath = path.join(basePath, 'Domain', lower);
54
+ const serviceDir = path.join(basePath, 'Application', 'Services');
55
+ const repoPath = path.join(basePath, 'Infra', 'Repo');
56
+
57
+ const aliasCurrent = selectedModule ? `$${selectedModule}` : '$app-context';
58
+ const aliasShared = '$shared-context';
59
+
60
+ const templateData = {
61
+ className: capital,
62
+ domainName: lower,
63
+ endpoint,
64
+ datasource,
65
+ aliasDomain: `${aliasCurrent}/Domain`,
66
+ aliasShared: aliasShared,
67
+ aliasApplication: `${aliasCurrent}/Application`,
68
+ aliasInfra: `${aliasCurrent}/Infra`
69
+ };
56
70
 
57
71
  // === 1) Abstracts
58
- const abstractsDir = path.join(domainPath, 'abstracts');
72
+ const abstractsDir = path.join(domainPath, 'Abstracts');
59
73
  for (const file of ['Class', 'ClassCreateRequest', 'ClassUpdateRequest']) {
60
74
  const tpl = await fs.readFile(path.join(__dirname, `../templates/domain/abstracts/${file}.ejs`), 'utf-8');
61
- const result = ejs.render(tpl, { className: capital });
75
+ const result = ejs.render(tpl, templateData);
62
76
  await writeIfNotExists(path.join(abstractsDir, `${capital}${file.replace('Class', '')}.ts`), result);
63
77
  }
64
78
  await updateIndexTs(abstractsDir);
65
79
 
66
80
  // === 2) Request
67
- const requestDir = path.join(domainPath, 'request');
81
+ const requestDir = path.join(domainPath, 'Request');
68
82
  for (const file of ['ClassCreateRequest', 'ClassUpdateRequest']) {
69
83
  const tpl = await fs.readFile(path.join(__dirname, `../templates/domain/request/${file}.ejs`), 'utf-8');
70
- const result = ejs.render(tpl, { className: capital });
84
+ const result = ejs.render(tpl, templateData);
71
85
  await writeIfNotExists(path.join(requestDir, `${capital}${file.replace('Class', '')}.ts`), result);
72
86
  }
73
87
  await updateIndexTs(requestDir);
74
88
 
75
89
  // === 3) Services
76
90
  const serviceTpl = await fs.readFile(path.join(__dirname, '../templates/domain/services/ClassService.ejs'), 'utf-8');
77
- const serviceResult = ejs.render(serviceTpl, { className: capital, domainName: lower });
91
+ const serviceResult = ejs.render(serviceTpl, templateData);
78
92
  await writeIfNotExists(path.join(serviceDir, `${capital}Service.ts`), serviceResult);
79
93
  await updateIndexTs(serviceDir);
80
94
 
81
95
  // === 4) Domain Index
82
96
  await writeIfNotExists(
83
97
  path.join(domainPath, 'index.ts'),
84
- [`export * from './abstracts';`, `export * from './request';`].join('\n') + '\n'
98
+ [`export * from './Abstracts';`, `export * from './Request';`].join('\n') + '\n'
85
99
  );
100
+ await updateIndexTs(domainPath);
86
101
 
87
102
  // === 5) Repo
88
103
  const repoTpl = await fs.readFile(path.join(__dirname, '../templates/data/repo/ClassRepo.ejs'), 'utf-8');
89
- const repoResult = ejs.render(repoTpl, {
90
- className: capital,
91
- endpoint,
92
- domainName: lower,
93
- datasource
94
- });
104
+ const repoResult = ejs.render(repoTpl, templateData);
95
105
  await writeIfNotExists(path.join(repoPath, `${capital}Repo.ts`), repoResult);
96
106
  await updateIndexTs(repoPath);
97
107
 
98
- console.log(`✅ CRUD for ${capital} generated in ${selectedModule || 'monolith'} structure`);
99
- }
108
+ console.log(`✅ CRUD for ${capital} generated in ${selectedModule || 'app-context'} structure`);
109
+ }
@@ -2,9 +2,9 @@ import fs from 'fs/promises';
2
2
  import path from 'path';
3
3
  import { loadUserConfig } from '../utils/loadConfig.js';
4
4
 
5
- const BASE_STRUCTURE = ['domain', 'infra', 'application', 'presentation'];
5
+ const BASE_STRUCTURE = ['Domain', 'Infra', 'Application', 'Presentation'];
6
6
  const APP_ROOT = path.join(process.cwd(), 'src', 'app');
7
- const ARCHITECTURE_PATH = path.join(APP_ROOT, 'contexts');
7
+ const CONTEXTS_PATH = path.join(APP_ROOT, 'contexts');
8
8
 
9
9
  async function createDirIfNotExists(dirPath) {
10
10
  try {
@@ -21,12 +21,11 @@ async function createBaseStructure(root) {
21
21
  await createDirIfNotExists(sectionPath);
22
22
 
23
23
  if (section === 'infra') {
24
- await createDirIfNotExists(path.join(sectionPath, 'repo'));
24
+ await createDirIfNotExists(path.join(sectionPath, 'Repo'));
25
25
  }
26
-
27
26
  if (section === 'application') {
28
- await createDirIfNotExists(path.join(sectionPath, 'services'));
29
- await createDirIfNotExists(path.join(sectionPath, 'orchestrators'));
27
+ await createDirIfNotExists(path.join(sectionPath, 'Services'));
28
+ await createDirIfNotExists(path.join(sectionPath, 'Orchestrators'));
30
29
  }
31
30
  }
32
31
  }
@@ -34,21 +33,29 @@ async function createBaseStructure(root) {
34
33
  export default async function initStructure() {
35
34
  const config = await loadUserConfig();
36
35
  const modules = config.modules;
36
+ const hasModules = Array.isArray(modules) && modules.length > 0;
37
37
 
38
- if (!modules || modules.length === 0) {
39
- // Без модулей
40
- console.log('📦 Generating monolithic architecture...');
41
- await createBaseStructure(ARCHITECTURE_PATH);
42
- } else {
43
- // С модулями
44
- console.log('📦 Generating modular architecture...');
38
+ console.log('📦 Generating architecture in: /contexts');
39
+
40
+ // всегда shared-kernel
41
+ const sharedKernelPath = path.join(CONTEXTS_PATH, 'shared-context');
42
+ await createBaseStructure(sharedKernelPath);
43
+
44
+ if (hasModules) {
45
+ // по модулям
46
+ console.log('🔧 Creating module contexts...');
45
47
  for (const mod of modules) {
46
- const modRoot = path.join(ARCHITECTURE_PATH, mod);
47
- await createBaseStructure(modRoot);
48
+ const modPath = path.join(CONTEXTS_PATH, mod);
49
+ await createBaseStructure(modPath);
48
50
  }
51
+ } else {
52
+ // fallback-контекст
53
+ console.log('🧱 No modules found — using default "app" context...');
54
+ const corePath = path.join(CONTEXTS_PATH, 'app-context');
55
+ await createBaseStructure(corePath);
49
56
  }
50
57
 
51
- // shared и ui вне modules
58
+ // доп. папки вне contexts
52
59
  await createDirIfNotExists(path.join(APP_ROOT, 'shared'));
53
60
  await createDirIfNotExists(path.join(APP_ROOT, 'ui'));
54
61
 
@@ -10,17 +10,15 @@ function generateAliases(config) {
10
10
  const hasModules = Array.isArray(config.modules) && config.modules.length > 0;
11
11
 
12
12
  if (hasModules) {
13
+ config.modules.push('shared-context');
13
14
  return Object.fromEntries(
14
15
  config.modules.map(m => [`$${m}`, `./src/app/contexts/${m}`])
15
16
  );
16
17
  }
17
18
 
18
19
  return {
19
- '$domain': './src/app/contexts/domain',
20
- '$infra': './src/app/contexts/infra',
21
- '$application': './src/app/contexts/application',
22
- '$presentation': './src/app/contexts/presentation',
23
- '$services': './src/app/contexts/application/services'
20
+ '$app-context': './src/app/contexts/app-context',
21
+ '$shared-context': './src/app/contexts/shared-context'
24
22
  };
25
23
  }
26
24
 
@@ -1,10 +1,10 @@
1
- import { <%= datasource %> } from '$data/datasources';
1
+ import { <%= datasource %> } from '<%= aliasShared %>/datasources';
2
2
  import type {
3
3
  I<%= className %>Collection,
4
4
  I<%= className %>Resource,
5
5
  I<%= className %>CreateRequest,
6
6
  I<%= className %>UpdateRequest
7
- } from '$domain/<%= domainName %>';
7
+ } from '<%= aliasDomain %>/<%= domainName %>';
8
8
 
9
9
  export class <%= className %>Repo {
10
10
  private endpoint = '<%= endpoint %>';
@@ -29,4 +29,4 @@ export class <%= className %>Repo {
29
29
  public async remove(id: number) {
30
30
  return await this.source.createRequest<never>(({ http }) => http.delete(`${this.endpoint}/${id}`));
31
31
  }
32
- }
32
+ }
@@ -1,6 +1,6 @@
1
1
  import { BaseService } from '@azure-net/kit';
2
- import { <%= className %>Repo } from '$data/repo';
3
- import type { <%= className %>CreateRequest, <%= className %>UpdateRequest } from '$domain/<%= domainName %>';
2
+ import { <%= className %>Repo } from '<%= aliasRepo %>';
3
+ import type { <%= className %>CreateRequest, <%= className %>UpdateRequest } from '<%= aliasDomain %>/<%= domainName %>';
4
4
 
5
5
  export class <%= className %>Service extends BaseService {
6
6
  constructor(private <%= domainName %>Repo = new <%= className %>Repo()) {
@@ -26,4 +26,4 @@ export class <%= className %>Service extends BaseService {
26
26
  async remove(id: number) {
27
27
  return await this.transformResponse(this.<%= domainName %>Repo.remove(id));
28
28
  }
29
- }
29
+ }