@azure-net/cli 2.3.3 → 2.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/bin/azure-net.js CHANGED
@@ -9,7 +9,8 @@ import {
9
9
  initTranslations,
10
10
  initSchema,
11
11
  initLint,
12
- initPresenter
12
+ initPresenter,
13
+ migrateStructure
13
14
  } from '../src/commands/init/index.js';
14
15
  import {
15
16
  generateDatasource,
@@ -71,6 +72,11 @@ program
71
72
  .description('Initialize presenter factory')
72
73
  .action(initPresenter);
73
74
 
75
+ program
76
+ .command('migrate:structure')
77
+ .description('Migrate existing contexts to new structure with layers and ui folders')
78
+ .action(migrateStructure);
79
+
74
80
  program
75
81
  .command('init')
76
82
  .description('Run all initialization steps')
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "2.3.3",
3
+ "version": "2.3.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
7
7
  },
8
8
  "peerDependencies": {
9
- "@azure-net/kit": "^1.3.3"
9
+ "@azure-net/kit": "^1.3.7"
10
10
  },
11
11
  "dependencies": {
12
- "@azure-net/kit": "^1.3.3",
12
+ "@azure-net/kit": "^1.3.7",
13
13
  "commander": "^11",
14
14
  "prompts": "^2"
15
15
  },
@@ -5,4 +5,5 @@ export { default as initEdges } from './initEdges.js';
5
5
  export { default as initTranslations } from './initTranslations.js';
6
6
  export { default as initSchema } from './initSchema.js';
7
7
  export { default as initLint } from './initLint.js';
8
- export { default as initPresenter } from './initPresenter.js';
8
+ export { default as initPresenter } from './initPresenter.js';
9
+ export { default as migrateStructure } from './migrateStructure.js';
@@ -9,7 +9,10 @@ function generateAliases(config) {
9
9
  const contexts = config.contexts || ['app'];
10
10
 
11
11
  return Object.fromEntries([
12
- ...contexts.map(c => [`$${c}`, `./src/app/contexts/${c}`]),
12
+ ...contexts.flatMap(c => [
13
+ [`$${c}`, `./src/app/contexts/${c}/layers`],
14
+ [`$${c}/ui`, `./src/app/contexts/${c}/ui`]
15
+ ]),
13
16
  ['$shared', './src/app/shared'],
14
17
  ['$core', './src/app/core']
15
18
  ]);
@@ -26,12 +26,19 @@ async function createIndexFile(dirPath, exportPatterns = []) {
26
26
  }
27
27
 
28
28
  async function createBaseStructure(root, contextName, contextAlias) {
29
+ // Create layers and ui folders
30
+ const layersPath = path.join(root, 'layers');
31
+ const uiPath = path.join(root, 'ui');
32
+
33
+ await createDirIfNotExists(layersPath);
34
+ await createDirIfNotExists(uiPath);
35
+
29
36
  // Domain - новая структура
30
- const domainPath = path.join(root, 'domain');
37
+ const domainPath = path.join(layersPath, 'domain');
31
38
  await createDirIfNotExists(domainPath);
32
39
 
33
40
  // Infrastructure
34
- const infraPath = path.join(root, 'infrastructure');
41
+ const infraPath = path.join(layersPath, 'infrastructure');
35
42
  await createDirIfNotExists(path.join(infraPath, 'http', 'repositories'));
36
43
  await createDirIfNotExists(path.join(infraPath, 'http', 'datasources'));
37
44
  await createDirIfNotExists(path.join(infraPath, 'providers'));
@@ -63,7 +70,7 @@ export const InfrastructureProvider = createBoundaryProvider(
63
70
  );
64
71
 
65
72
  // Application
66
- const appPath = path.join(root, 'application');
73
+ const appPath = path.join(layersPath, 'application');
67
74
  await createDirIfNotExists(path.join(appPath, 'services'));
68
75
  await createDirIfNotExists(path.join(appPath, 'providers'));
69
76
 
@@ -101,7 +108,7 @@ export const ApplicationProvider = createBoundaryProvider(
101
108
  );
102
109
 
103
110
  // Delivery - organized by modules
104
- const deliveryPath = path.join(root, 'delivery');
111
+ const deliveryPath = path.join(layersPath, 'delivery');
105
112
  await createDirIfNotExists(deliveryPath);
106
113
  }
107
114
 
@@ -0,0 +1,84 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { loadUserConfig } from '../../utils/loadConfig.js';
4
+
5
+ const CONTEXTS_PATH = path.join(process.cwd(), 'src/app/contexts');
6
+
7
+ async function directoryExists(dirPath) {
8
+ try {
9
+ const stat = await fs.stat(dirPath);
10
+ return stat.isDirectory();
11
+ } catch {
12
+ return false;
13
+ }
14
+ }
15
+
16
+ async function moveDirectory(source, destination) {
17
+ try {
18
+ // Check if source exists
19
+ if (!(await directoryExists(source))) {
20
+ return false;
21
+ }
22
+
23
+ // Create destination parent directory if needed
24
+ await fs.mkdir(path.dirname(destination), { recursive: true });
25
+
26
+ // Move the directory
27
+ await fs.rename(source, destination);
28
+ console.log(`✅ Moved: ${source} -> ${destination}`);
29
+ return true;
30
+ } catch (error) {
31
+ console.error(`❌ Failed to move ${source}:`, error.message);
32
+ return false;
33
+ }
34
+ }
35
+
36
+ export default async function migrateStructure() {
37
+ const config = await loadUserConfig();
38
+ const contexts = config.contexts || ['app'];
39
+
40
+ console.log('🔄 Starting structure migration...\n');
41
+ console.log('This will reorganize existing contexts to use layers and ui folders.\n');
42
+
43
+ for (const context of contexts) {
44
+ const contextPath = path.join(CONTEXTS_PATH, context);
45
+
46
+ // Check if context exists
47
+ if (!(await directoryExists(contextPath))) {
48
+ console.log(`⚠️ Context '${context}' does not exist, skipping...`);
49
+ continue;
50
+ }
51
+
52
+ console.log(`\n📁 Migrating context: ${context}`);
53
+
54
+ // Check if already migrated (has layers folder)
55
+ const layersPath = path.join(contextPath, 'layers');
56
+ if (await directoryExists(layersPath)) {
57
+ console.log(`⚠️ Context '${context}' already migrated, skipping...`);
58
+ continue;
59
+ }
60
+
61
+ // Create layers and ui folders
62
+ await fs.mkdir(layersPath, { recursive: true });
63
+ await fs.mkdir(path.join(contextPath, 'ui'), { recursive: true });
64
+ console.log(`✅ Created: ${layersPath}`);
65
+ console.log(`✅ Created: ${path.join(contextPath, 'ui')}`);
66
+
67
+ // Move existing layer folders to layers directory
68
+ const layerFolders = ['domain', 'infrastructure', 'application', 'delivery'];
69
+
70
+ for (const layer of layerFolders) {
71
+ const sourcePath = path.join(contextPath, layer);
72
+ const destPath = path.join(layersPath, layer);
73
+
74
+ await moveDirectory(sourcePath, destPath);
75
+ }
76
+
77
+ console.log(`✅ Context '${context}' migration completed!`);
78
+ }
79
+
80
+ console.log('\n✅ Structure migration complete!');
81
+ console.log('\n💡 Next steps:');
82
+ console.log(' 1. Run "azure-net init:aliases" to update path aliases');
83
+ console.log(' 2. Verify all imports are working correctly');
84
+ }
@@ -26,7 +26,7 @@ export async function selectContext(message = 'Select context:') {
26
26
  export function getContextPath(context) {
27
27
  return context === 'core'
28
28
  ? CORE_PATH
29
- : path.join(CONTEXTS_PATH, context);
29
+ : path.join(CONTEXTS_PATH, context, 'layers');
30
30
  }
31
31
 
32
32
  export async function getAvailableFiles(dir, pattern = '.ts') {