@azure-net/cli 2.3.63 → 4.0.0-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.
Files changed (117) hide show
  1. package/.prettierrc +7 -0
  2. package/bin/azure-net.js +278 -157
  3. package/bin/azure-net.ts +284 -0
  4. package/eslint.config.js +34 -0
  5. package/package.json +12 -5
  6. package/src/checks/checkDomain.js +201 -0
  7. package/src/checks/checkDomain.ts +213 -0
  8. package/src/checks/checkFoldersStructure.js +70 -0
  9. package/src/checks/checkFoldersStructure.ts +85 -0
  10. package/src/checks/checkInternal.js +35 -0
  11. package/src/checks/checkInternal.ts +40 -0
  12. package/src/checks/checkLayerBoundaries.js +178 -0
  13. package/src/checks/checkLayerBoundaries.ts +189 -0
  14. package/src/checks/checkPresenterNames.js +202 -0
  15. package/src/checks/checkPresenterNames.ts +208 -0
  16. package/src/checks/checkProject.js +42 -0
  17. package/src/checks/checkProject.ts +45 -0
  18. package/src/checks/checkProviderNames.js +158 -0
  19. package/src/checks/checkProviderNames.ts +165 -0
  20. package/src/checks/index.js +7 -0
  21. package/src/checks/index.ts +7 -0
  22. package/src/generate/layers/generateRepository.js +124 -0
  23. package/src/generate/layers/generateRepository.ts +123 -0
  24. package/src/generate/layers/generateRepositoryMethod.js +102 -0
  25. package/src/generate/layers/generateRepositoryMethod.ts +102 -0
  26. package/src/generate/layers/generateUseCases.js +50 -0
  27. package/src/generate/layers/generateUseCases.ts +50 -0
  28. package/src/generate/layers/repositoryShared.js +569 -0
  29. package/src/generate/layers/repositoryShared.ts +657 -0
  30. package/src/generate/module/generateDomain.js +146 -0
  31. package/src/generate/module/generateDomain.ts +147 -0
  32. package/src/generate/module/generateModule.js +84 -0
  33. package/src/generate/module/generateModule.ts +84 -0
  34. package/src/generate/module/generateModulePreset.js +307 -0
  35. package/src/generate/module/generateModulePreset.ts +337 -0
  36. package/src/generate/module/generatePresenter.js +419 -0
  37. package/src/generate/module/generatePresenter.ts +442 -0
  38. package/src/generate/module/generateRepository.js +144 -0
  39. package/src/generate/module/generateRepository.ts +158 -0
  40. package/src/generate/module/generateSchemaFromType.js +358 -0
  41. package/src/generate/module/generateSchemaFromType.ts +369 -0
  42. package/src/generate/module/generateTypesJson.js +252 -0
  43. package/src/generate/module/generateTypesJson.ts +259 -0
  44. package/src/generate/module/generateUseCases.js +67 -0
  45. package/src/generate/module/generateUseCases.ts +67 -0
  46. package/src/generate/module/repositoryModuleShared.js +598 -0
  47. package/src/generate/module/repositoryModuleShared.ts +661 -0
  48. package/src/generate/ui/generateComponent.js +98 -0
  49. package/src/generate/ui/generateComponent.ts +100 -0
  50. package/src/generate/ui/generateDesignComponent.js +71 -0
  51. package/src/generate/ui/generateDesignComponent.ts +71 -0
  52. package/src/generate/ui/generateWidget.js +71 -0
  53. package/src/generate/ui/generateWidget.ts +71 -0
  54. package/src/init/initAliases.js +159 -0
  55. package/src/init/initAliases.ts +167 -0
  56. package/src/init/initEdges.js +74 -0
  57. package/src/init/initEdges.ts +74 -0
  58. package/src/init/initStructure.js +122 -0
  59. package/src/init/initStructure.ts +124 -0
  60. package/src/install/installFresh.js +101 -0
  61. package/src/install/installFresh.ts +101 -0
  62. package/src/plugins/addLint.js +257 -0
  63. package/src/plugins/addLint.ts +274 -0
  64. package/src/plugins/index.js +1 -0
  65. package/src/plugins/index.ts +1 -0
  66. package/src/scaffolds/createCoreMiddleware.js +27 -0
  67. package/src/scaffolds/createCoreMiddleware.ts +27 -0
  68. package/src/scaffolds/createCoreSchema.js +141 -0
  69. package/src/scaffolds/createCoreSchema.ts +142 -0
  70. package/src/scaffolds/createDatasource.js +173 -0
  71. package/src/scaffolds/createDatasource.ts +175 -0
  72. package/src/scaffolds/createDatasourceProvider.js +164 -0
  73. package/src/scaffolds/createDatasourceProvider.ts +175 -0
  74. package/src/scaffolds/createMiddleware.js +105 -0
  75. package/src/scaffolds/createMiddleware.ts +105 -0
  76. package/src/scaffolds/createPresenterFactory.js +112 -0
  77. package/src/scaffolds/createPresenterFactory.ts +114 -0
  78. package/src/scaffolds/createResponse.js +64 -0
  79. package/src/scaffolds/createResponse.ts +64 -0
  80. package/src/scaffolds/createSchemaRule.js +40 -0
  81. package/src/scaffolds/createSchemaRule.ts +42 -0
  82. package/src/scaffolds/createTranslationManager.js +78 -0
  83. package/src/scaffolds/createTranslationManager.ts +78 -0
  84. package/src/scaffolds/index.js +9 -0
  85. package/src/scaffolds/index.ts +9 -0
  86. package/src/utils/contextUtils.js +56 -49
  87. package/src/utils/contextUtils.ts +89 -0
  88. package/src/utils/fileUtils.js +72 -84
  89. package/src/utils/fileUtils.ts +100 -0
  90. package/src/utils/loadConfig.js +57 -13
  91. package/src/utils/loadConfig.ts +69 -0
  92. package/tsconfig.json +19 -0
  93. package/src/commands/generate/generateComponent.js +0 -53
  94. package/src/commands/generate/generateCrudBase.js +0 -207
  95. package/src/commands/generate/generateCrudPresenter.js +0 -232
  96. package/src/commands/generate/generateDatasource.js +0 -84
  97. package/src/commands/generate/generateDesignComponent.js +0 -53
  98. package/src/commands/generate/generateModule.js +0 -31
  99. package/src/commands/generate/generateModuleBase.js +0 -152
  100. package/src/commands/generate/generateModulePresenter.js +0 -110
  101. package/src/commands/generate/generatePresenter.js +0 -86
  102. package/src/commands/generate/generateRepository.js +0 -76
  103. package/src/commands/generate/generateResponse.js +0 -41
  104. package/src/commands/generate/generateSchema.js +0 -96
  105. package/src/commands/generate/generateService.js +0 -71
  106. package/src/commands/generate/generateWidget.js +0 -53
  107. package/src/commands/generate/index.js +0 -14
  108. package/src/commands/init/index.js +0 -9
  109. package/src/commands/init/initAliases.js +0 -52
  110. package/src/commands/init/initEdges.js +0 -42
  111. package/src/commands/init/initLint.js +0 -138
  112. package/src/commands/init/initMiddleware.js +0 -21
  113. package/src/commands/init/initPresenter.js +0 -25
  114. package/src/commands/init/initSchema.js +0 -22
  115. package/src/commands/init/initStructure.js +0 -140
  116. package/src/commands/init/initTranslations.js +0 -59
  117. package/src/commands/init/migrateStructure.js +0 -144
@@ -0,0 +1,284 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import { addLint } from '../src/plugins/index.js';
5
+
6
+ const program = new Command();
7
+
8
+ program.name('azure-net').description('Azure-Net CLI generator').version('4.0.0');
9
+
10
+ const addCommand = program.command('add').description('Add project integrations and plugins');
11
+ const createCommand = program.command('create').description('Create project boilerplate artifacts');
12
+ const initCommand = program.command('init').description('Initialize project scaffolding');
13
+ const installCommand = program.command('install').description('Install project presets and flows');
14
+ const generateCommand = program.command('generate').description('Generate UI artifacts');
15
+ const checkCommand = program.command('check').description('Run project checks');
16
+
17
+ addCommand
18
+ .command('commit-tools')
19
+ .description('Setup linting and commit tools')
20
+ .option('-m, --manager <manager>', 'Package manager: bun | pnpm | npm | yarn')
21
+ .action(addLint);
22
+
23
+ createCommand
24
+ .command('schema-factory')
25
+ .description('Create base schema in src/core/schema')
26
+ .action(async () => {
27
+ const handler = (await import('../src/scaffolds/createCoreSchema.js')).default;
28
+ await handler();
29
+ });
30
+
31
+ createCommand
32
+ .command('middleware-manager')
33
+ .description('Create middleware manager in src/core/middleware-manager')
34
+ .action(async () => {
35
+ const handler = (await import('../src/scaffolds/createCoreMiddleware.js')).default;
36
+ await handler();
37
+ });
38
+
39
+ createCommand
40
+ .command('translation-manager')
41
+ .description('Create translation manager in src/core/translation')
42
+ .action(async () => {
43
+ const handler = (await import('../src/scaffolds/createTranslationManager.js')).default;
44
+ await handler();
45
+ });
46
+
47
+ createCommand
48
+ .command('presenter-factory')
49
+ .description('Create presenter factory in src/core/presenter')
50
+ .action(async () => {
51
+ const handler = (await import('../src/scaffolds/createPresenterFactory.js')).default;
52
+ await handler();
53
+ });
54
+
55
+ createCommand
56
+ .command('schema-rule')
57
+ .description('Create schema rule in src/core/schema/custom-rules')
58
+ .action(async () => {
59
+ const handler = (await import('../src/scaffolds/createSchemaRule.js')).default;
60
+ await handler();
61
+ });
62
+
63
+ createCommand
64
+ .command('middleware')
65
+ .description('Create middleware in src/core/middleware-manager/middlewares')
66
+ .action(async () => {
67
+ const handler = (await import('../src/scaffolds/createMiddleware.js')).default;
68
+ await handler();
69
+ });
70
+
71
+ createCommand
72
+ .command('response')
73
+ .description('Create response in src/core/response')
74
+ .action(async () => {
75
+ const handler = (await import('../src/scaffolds/createResponse.js')).default;
76
+ await handler();
77
+ });
78
+
79
+ createCommand
80
+ .command('datasource')
81
+ .description('Create datasource in core or context infrastructure')
82
+ .action(async () => {
83
+ const handler = (await import('../src/scaffolds/createDatasource.js')).default;
84
+ await handler();
85
+ });
86
+
87
+ createCommand
88
+ .command('datasource-provider')
89
+ .description('Create datasource provider in core or context infrastructure')
90
+ .action(async () => {
91
+ const handler = (await import('../src/scaffolds/createDatasourceProvider.js')).default;
92
+ await handler();
93
+ });
94
+
95
+ initCommand
96
+ .command('edges')
97
+ .description('Initialize edges plugin in vite config')
98
+ .action(async () => {
99
+ const handler = (await import('../src/init/initEdges.js')).default;
100
+ await handler();
101
+ });
102
+
103
+ initCommand
104
+ .command('folders-structure')
105
+ .description('Generate base folders structure')
106
+ .action(async () => {
107
+ const handler = (await import('../src/init/initStructure.js')).default;
108
+ await handler();
109
+ });
110
+
111
+ initCommand.action(async () => {
112
+ const initStructure = (await import('../src/init/initStructure.js')).default;
113
+ await initStructure();
114
+ });
115
+
116
+ installCommand
117
+ .command('fresh')
118
+ .description('Run full fresh install flow (structure + optional generators)')
119
+ .action(async () => {
120
+ const handler = (await import('../src/install/installFresh.js')).default;
121
+ await handler();
122
+ });
123
+
124
+ generateCommand
125
+ .command('component')
126
+ .description('Generate UI component')
127
+ .action(async () => {
128
+ const handler = (await import('../src/generate/ui/generateComponent.js')).default;
129
+ await handler();
130
+ });
131
+
132
+ generateCommand
133
+ .command('widget')
134
+ .description('Generate UI widget')
135
+ .action(async () => {
136
+ const handler = (await import('../src/generate/ui/generateWidget.js')).default;
137
+ await handler();
138
+ });
139
+
140
+ generateCommand
141
+ .command('design-component')
142
+ .description('Generate UI design component')
143
+ .action(async () => {
144
+ const handler = (await import('../src/generate/ui/generateDesignComponent.js')).default;
145
+ await handler();
146
+ });
147
+
148
+ generateCommand
149
+ .command('repository')
150
+ .description('Generate infrastructure repository')
151
+ .action(async () => {
152
+ const handler = (await import('../src/generate/layers/generateRepository.js')).default;
153
+ await handler();
154
+ });
155
+
156
+ generateCommand
157
+ .command('repo')
158
+ .description('Generate infrastructure repository (module flow)')
159
+ .action(async () => {
160
+ const handler = (await import('../src/generate/module/generateRepository.js')).default;
161
+ await handler();
162
+ });
163
+
164
+ generateCommand
165
+ .command('repository-method')
166
+ .description('Generate method for an existing repository')
167
+ .action(async () => {
168
+ const handler = (await import('../src/generate/layers/generateRepositoryMethod.js')).default;
169
+ await handler();
170
+ });
171
+
172
+ generateCommand
173
+ .command('use-cases')
174
+ .description('Generate use-cases for an existing repository')
175
+ .action(async () => {
176
+ const handler = (await import('../src/generate/module/generateUseCases.js')).default;
177
+ await handler();
178
+ });
179
+
180
+ generateCommand
181
+ .command('domain')
182
+ .description('Generate domain module (model/ports)')
183
+ .action(async () => {
184
+ const handler = (await import('../src/generate/module/generateDomain.js')).default;
185
+ await handler();
186
+ });
187
+
188
+ generateCommand
189
+ .command('presenter')
190
+ .description('Generate presentation layer presenter from UseCases')
191
+ .action(async () => {
192
+ const handler = (await import('../src/generate/module/generatePresenter.js')).default;
193
+ await handler();
194
+ });
195
+
196
+ generateCommand
197
+ .command('types-json')
198
+ .description('Fill model interface keys from JSON')
199
+ .action(async () => {
200
+ const handler = (await import('../src/generate/module/generateTypesJson.js')).default;
201
+ await handler();
202
+ });
203
+
204
+ generateCommand
205
+ .command('schema-from-type')
206
+ .description('Fill schema rules keys from schema generic type')
207
+ .action(async () => {
208
+ const handler = (await import('../src/generate/module/generateSchemaFromType.js')).default;
209
+ await handler();
210
+ });
211
+
212
+ generateCommand
213
+ .command('module')
214
+ .description('Generate domain + repository + presenter flow')
215
+ .action(async () => {
216
+ const handler = (await import('../src/generate/module/generateModule.js')).default;
217
+ await handler();
218
+ });
219
+
220
+ generateCommand
221
+ .command('module-preset')
222
+ .description('Generate preset CRUD-like module flow')
223
+ .action(async () => {
224
+ const handler = (await import('../src/generate/module/generateModulePreset.js')).default;
225
+ await handler();
226
+ });
227
+
228
+ checkCommand
229
+ .command('presenter-names')
230
+ .description('Check duplicate presenter names in src')
231
+ .action(async () => {
232
+ const handler = (await import('../src/checks/checkPresenterNames.js')).default;
233
+ await handler();
234
+ });
235
+
236
+ checkCommand
237
+ .command('provider-names')
238
+ .description('Check duplicate provider names in src')
239
+ .action(async () => {
240
+ const handler = (await import('../src/checks/checkProviderNames.js')).default;
241
+ await handler();
242
+ });
243
+
244
+ checkCommand
245
+ .command('domain')
246
+ .description('Check domain naming and structure rules in all contexts')
247
+ .action(async () => {
248
+ const handler = (await import('../src/checks/checkDomain.js')).default;
249
+ await handler();
250
+ });
251
+
252
+ checkCommand
253
+ .command('layer-boundaries')
254
+ .description('Check layer boundaries between contexts by aliases')
255
+ .action(async () => {
256
+ const handler = (await import('../src/checks/checkLayerBoundaries.js')).default;
257
+ await handler();
258
+ });
259
+
260
+ checkCommand
261
+ .command('folders-structure')
262
+ .description('Check allowed folders structure in context layers/ui/components')
263
+ .action(async () => {
264
+ const handler = (await import('../src/checks/checkFoldersStructure.js')).default;
265
+ await handler();
266
+ });
267
+
268
+ checkCommand
269
+ .command('internal')
270
+ .description('Run all internal azure-net checks')
271
+ .action(async () => {
272
+ const handler = (await import('../src/checks/checkInternal.js')).default;
273
+ await handler();
274
+ });
275
+
276
+ checkCommand
277
+ .command('project')
278
+ .description('Run full project checks: format, internal, lint, typecheck')
279
+ .action(async () => {
280
+ const handler = (await import('../src/checks/checkProject.js')).default;
281
+ await handler();
282
+ });
283
+
284
+ program.parse();
@@ -0,0 +1,34 @@
1
+ import js from '@eslint/js';
2
+ import tseslint from 'typescript-eslint';
3
+
4
+ export default tseslint.config(
5
+ {
6
+ ignores: ['dist/**', 'node_modules/**']
7
+ },
8
+ js.configs.recommended,
9
+ ...tseslint.configs.recommended,
10
+ {
11
+ files: ['bin/**/*.ts', 'src/plugins/**/*.ts'],
12
+ languageOptions: {
13
+ globals: {
14
+ console: 'readonly',
15
+ process: 'readonly'
16
+ }
17
+ }
18
+ },
19
+ {
20
+ files: [
21
+ 'src/generate/module/repositoryModuleShared.ts',
22
+ 'src/generate/layers/repositoryShared.ts',
23
+ 'src/generate/layers/generateUseCases.ts',
24
+ 'src/generate/layers/generateRepositoryMethod.ts',
25
+ 'src/generate/layers/generateRepository.ts',
26
+ 'src/utils/contextUtils.ts',
27
+ 'src/utils/loadConfig.ts',
28
+ 'src/utils/fileUtils.ts'
29
+ ],
30
+ rules: {
31
+ '@typescript-eslint/ban-ts-comment': 'off'
32
+ }
33
+ }
34
+ );
package/package.json CHANGED
@@ -1,23 +1,30 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "2.3.63",
3
+ "version": "4.0.0-1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
7
7
  },
8
8
  "peerDependencies": {
9
- "@azure-net/kit": "^2.1.5"
9
+ "@azure-net/kit": "^4.0.0"
10
10
  },
11
11
  "dependencies": {
12
- "@azure-net/kit": "^2.1.5",
13
12
  "commander": "^11",
14
13
  "prompts": "^2"
15
14
  },
16
15
  "devDependencies": {
16
+ "@eslint/js": "^9.31.0",
17
17
  "@types/node": "^24.0.3",
18
- "typescript": "^5"
18
+ "@types/prompts": "^2.4.9",
19
+ "eslint": "^9.31.0",
20
+ "prettier": "^3.6.2",
21
+ "typescript": "^5",
22
+ "typescript-eslint": "^8.36.0"
19
23
  },
20
24
  "scripts": {
21
- "build": "tsc"
25
+ "build": "tsc -p tsconfig.json",
26
+ "typecheck": "tsc --noEmit -p tsconfig.json",
27
+ "lint": "eslint \"bin/**/*.ts\" \"src/**/*.ts\"",
28
+ "format": "prettier --write ."
22
29
  }
23
30
  }
@@ -0,0 +1,201 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { loadUserConfig } from '../utils/loadConfig.js';
4
+ import { normalizeContexts } from '../init/initAliases.js';
5
+
6
+ const DOMAIN_FILE_EXTENSIONS = new Set(['.ts']);
7
+ const IGNORED_DIRS = new Set(['node_modules', 'dist', '.svelte-kit', '.git']);
8
+
9
+ const INTERFACE_DECLARATION_PATTERN = /(?:^|\n)\s*(?:export\s+)?interface\s+([A-Za-z_$][A-Za-z0-9_$]*)\b/g;
10
+ const TYPE_DECLARATION_PATTERN = /(?:^|\n)\s*(?:export\s+)?type\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=/g;
11
+
12
+ const EXPORT_STAR_PATTERN = /export\s+\*\s+from\s*['"][^'"]+['"]\s*;?/g;
13
+ const EXPORT_FROM_PATTERN = /export\s+(?:type\s+)?\{[\s\S]*?\}\s+from\s*['"][^'"]+['"]\s*;?/g;
14
+ const EXPORT_LOCAL_PATTERN = /export\s+(?:type\s+)?\{[\s\S]*?\}\s*;?/g;
15
+
16
+ const toPosixPath = (value) => value.split(path.sep).join('/');
17
+
18
+ const stripComments = (content) => content.replace(/\/\*[\s\S]*?\*\//g, '').replace(/(^|[^\\])\/\/.*$/gm, '$1');
19
+
20
+ const stripExportStatements = (content) =>
21
+ content.replace(EXPORT_STAR_PATTERN, '').replace(EXPORT_FROM_PATTERN, '').replace(EXPORT_LOCAL_PATTERN, '');
22
+
23
+ const findLineByIndex = (content, index) => {
24
+ let line = 1;
25
+ for (let i = 0; i < index; i += 1) {
26
+ if (content[i] === '\n') line += 1;
27
+ }
28
+ return line;
29
+ };
30
+
31
+ const getRelativeFilePath = (filePath) => toPosixPath(path.relative(process.cwd(), filePath));
32
+
33
+ const isEnumsPath = (filePath) => {
34
+ const normalized = toPosixPath(filePath);
35
+ return normalized.includes('/enums/');
36
+ };
37
+
38
+ const isIndexFile = (filePath) => path.basename(filePath) === 'index.ts';
39
+
40
+ const isExportOnlyIndex = (content) => {
41
+ const withoutComments = stripComments(content);
42
+ const withoutExports = stripExportStatements(withoutComments);
43
+ return withoutExports.trim().length === 0;
44
+ };
45
+
46
+ const validateName = (declaration) => {
47
+ if (declaration.kind === 'interface') {
48
+ return /^I[A-Z]/.test(declaration.name) ? null : `Interface "${declaration.name}" must start with "I" and have uppercase second letter`;
49
+ }
50
+
51
+ return /^[IT][A-Z]/.test(declaration.name)
52
+ ? null
53
+ : `Type "${declaration.name}" must start with "I" or "T" and have uppercase second letter`;
54
+ };
55
+
56
+ const extractDeclarations = (content) => {
57
+ const cleaned = stripComments(content);
58
+ const declarations = [];
59
+
60
+ const interfaceRegex = new RegExp(INTERFACE_DECLARATION_PATTERN.source, 'g');
61
+ let interfaceMatch;
62
+ while ((interfaceMatch = interfaceRegex.exec(cleaned)) !== null) {
63
+ const name = interfaceMatch[1];
64
+ if (!name) continue;
65
+ declarations.push({
66
+ kind: 'interface',
67
+ name,
68
+ line: findLineByIndex(cleaned, interfaceMatch.index)
69
+ });
70
+ }
71
+
72
+ const typeRegex = new RegExp(TYPE_DECLARATION_PATTERN.source, 'g');
73
+ let typeMatch;
74
+ while ((typeMatch = typeRegex.exec(cleaned)) !== null) {
75
+ const name = typeMatch[1];
76
+ if (!name) continue;
77
+ declarations.push({
78
+ kind: 'type',
79
+ name,
80
+ line: findLineByIndex(cleaned, typeMatch.index)
81
+ });
82
+ }
83
+
84
+ return declarations.sort((a, b) => a.line - b.line);
85
+ };
86
+
87
+ const listDomainFiles = async (domainRoot) => {
88
+ const files = [];
89
+ const stack = [domainRoot];
90
+
91
+ while (stack.length) {
92
+ const current = stack.pop();
93
+ if (!current) continue;
94
+
95
+ let entries = [];
96
+ try {
97
+ entries = await fs.readdir(current, { withFileTypes: true });
98
+ } catch {
99
+ continue;
100
+ }
101
+
102
+ for (const entry of entries) {
103
+ if (entry.isDirectory()) {
104
+ if (!IGNORED_DIRS.has(entry.name)) {
105
+ stack.push(path.join(current, entry.name));
106
+ }
107
+ continue;
108
+ }
109
+
110
+ if (!entry.isFile()) continue;
111
+ const filePath = path.join(current, entry.name);
112
+ if (!DOMAIN_FILE_EXTENSIONS.has(path.extname(filePath))) continue;
113
+ files.push(filePath);
114
+ }
115
+ }
116
+
117
+ return files;
118
+ };
119
+
120
+ const collectIssuesForFile = (filePath, content) => {
121
+ const issues = [];
122
+
123
+ if (isIndexFile(filePath) && !isExportOnlyIndex(content)) {
124
+ issues.push({
125
+ file: filePath,
126
+ line: 1,
127
+ message: 'index.ts must contain only exports. Move declarations to separate files'
128
+ });
129
+ }
130
+
131
+ if (isEnumsPath(filePath)) {
132
+ return issues;
133
+ }
134
+
135
+ const declarations = extractDeclarations(content);
136
+ if (declarations.length > 5) {
137
+ issues.push({
138
+ file: filePath,
139
+ line: declarations[5]?.line ?? 1,
140
+ message: `Too many declarations in one file (${declarations.length}). Maximum is 5`
141
+ });
142
+ }
143
+
144
+ for (const declaration of declarations) {
145
+ const validationError = validateName(declaration);
146
+ if (!validationError) continue;
147
+ issues.push({
148
+ file: filePath,
149
+ line: declaration.line,
150
+ message: validationError
151
+ });
152
+ }
153
+
154
+ return issues;
155
+ };
156
+
157
+ export default async function checkDomain() {
158
+ const config = await loadUserConfig();
159
+ const contexts = normalizeContexts(config.contexts);
160
+
161
+ if (!contexts.length) {
162
+ console.error('❌ No contexts found in azure-net.config.ts/js. Fill `contexts` first.');
163
+ process.exitCode = 1;
164
+ return;
165
+ }
166
+
167
+ const issues = [];
168
+
169
+ for (const context of contexts) {
170
+ const domainRoot = path.join(process.cwd(), 'src', 'app', context.name, 'layers', 'domain');
171
+
172
+ try {
173
+ await fs.access(domainRoot);
174
+ } catch {
175
+ issues.push({
176
+ file: domainRoot,
177
+ line: 1,
178
+ message: `Domain folder not found for context "${context.name}"`
179
+ });
180
+ continue;
181
+ }
182
+
183
+ const files = await listDomainFiles(domainRoot);
184
+ for (const filePath of files) {
185
+ const content = await fs.readFile(filePath, 'utf-8');
186
+ issues.push(...collectIssuesForFile(filePath, content));
187
+ }
188
+ }
189
+
190
+ if (!issues.length) {
191
+ console.log('✅ Domain check passed: naming, per-file limits and index exports are valid.');
192
+ return;
193
+ }
194
+
195
+ console.error('❌ Domain check failed:');
196
+ for (const issue of issues) {
197
+ console.error(`• ${getRelativeFilePath(issue.file)}:${issue.line} — ${issue.message}`);
198
+ }
199
+
200
+ process.exitCode = 1;
201
+ }