@azure-net/cli 1.2.10 → 1.3.0

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
@@ -4,6 +4,7 @@ import { Command } from 'commander';
4
4
  import generateRepository from '../src/commands/generateCrudRepo.js';
5
5
  import generateCrud from '../src/commands/generateCrud.js';
6
6
  import initLint from '../src/commands/initLint.js';
7
+ import initStructure from '../src/commands/generateStructure.js';
7
8
 
8
9
  const program = new Command();
9
10
 
@@ -26,4 +27,9 @@ program
26
27
  .description('Setup linting and commit tools')
27
28
  .action(initLint)
28
29
 
30
+ program
31
+ .command('init:structure')
32
+ .description('Generate base folder structure based on config')
33
+ .action(initStructure);
34
+
29
35
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "1.2.10",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
@@ -0,0 +1,56 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { loadUserConfig } from '../utils/loadConfig.js';
4
+
5
+ const BASE_STRUCTURE = ['domain', 'infra', 'application', 'presentation'];
6
+ const APP_ROOT = path.join(process.cwd(), 'src', 'app');
7
+ const ARCHITECTURE_PATH = path.join(APP_ROOT, 'architecture');
8
+
9
+ async function createDirIfNotExists(dirPath) {
10
+ try {
11
+ await fs.mkdir(dirPath, { recursive: true });
12
+ console.log(`📁 Created: ${dirPath}`);
13
+ } catch (e) {
14
+ console.error(`❌ Failed to create ${dirPath}:`, e.message);
15
+ }
16
+ }
17
+
18
+ async function createBaseStructure(root) {
19
+ for (const section of BASE_STRUCTURE) {
20
+ const sectionPath = path.join(root, section);
21
+ await createDirIfNotExists(sectionPath);
22
+
23
+ if (section === 'infra') {
24
+ await createDirIfNotExists(path.join(sectionPath, 'repo'));
25
+ }
26
+
27
+ if (section === 'application') {
28
+ await createDirIfNotExists(path.join(sectionPath, 'services'));
29
+ await createDirIfNotExists(path.join(sectionPath, 'orchestrators'));
30
+ }
31
+ }
32
+ }
33
+
34
+ export default async function initStructure() {
35
+ const config = await loadUserConfig();
36
+ const modules = config.modules;
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...');
45
+ for (const mod of modules) {
46
+ const modRoot = path.join(ARCHITECTURE_PATH, mod);
47
+ await createBaseStructure(modRoot);
48
+ }
49
+ }
50
+
51
+ // shared и ui вне modules
52
+ await createDirIfNotExists(path.join(APP_ROOT, 'shared'));
53
+ await createDirIfNotExists(path.join(APP_ROOT, 'ui'));
54
+
55
+ console.log('✅ Structure initialization complete!');
56
+ }
@@ -9,9 +9,10 @@ export async function loadUserConfig() {
9
9
  } catch {
10
10
  return {
11
11
  output: {
12
- domain: 'src/app/layers/domain',
13
- repo: 'src/app/layers/data/repo'
14
- }
12
+ domain: 'src/app/architecture/domain',
13
+ repo: 'src/app/architecture/infra/repo'
14
+ },
15
+ modules: ['admin', 'auth']
15
16
  };
16
17
  }
17
18
  }