@azure-net/cli 2.3.62 → 4.0.0-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.
Files changed (91) hide show
  1. package/.prettierrc +7 -0
  2. package/bin/azure-net.js +247 -157
  3. package/bin/azure-net.ts +253 -0
  4. package/eslint.config.js +19 -0
  5. package/package.json +12 -5
  6. package/src/commands/generate/generateCrudBase.js +95 -114
  7. package/src/commands/generate/generateCrudPresenter.js +135 -142
  8. package/src/commands/generate/generateModule.js +21 -21
  9. package/src/commands/generate/generateModuleBase.js +92 -114
  10. package/src/commands/generate/generateModulePresenter.js +73 -80
  11. package/src/commands/generate/generatePresenter.js +38 -44
  12. package/src/commands/generate/generateRepository.js +41 -47
  13. package/src/commands/generate/generateSchema.js +74 -70
  14. package/src/commands/generate/generateService.js +32 -37
  15. package/src/commands/generate/index.js +0 -5
  16. package/src/generate/layers/generateRepository.js +124 -0
  17. package/src/generate/layers/generateRepositoryMethod.js +102 -0
  18. package/src/generate/layers/generateUseCases.js +50 -0
  19. package/src/generate/layers/repositoryShared.js +569 -0
  20. package/src/generate/module/generateDomain.js +146 -0
  21. package/src/generate/module/generateDomain.ts +147 -0
  22. package/src/generate/module/generateModule.js +84 -0
  23. package/src/generate/module/generateModule.ts +84 -0
  24. package/src/generate/module/generatePresenter.js +419 -0
  25. package/src/generate/module/generatePresenter.ts +442 -0
  26. package/src/generate/module/generateRepository.js +144 -0
  27. package/src/generate/module/generateRepository.ts +158 -0
  28. package/src/generate/module/generateSchemaFromType.js +320 -0
  29. package/src/generate/module/generateSchemaFromType.ts +325 -0
  30. package/src/generate/module/generateTypesJson.js +252 -0
  31. package/src/generate/module/generateTypesJson.ts +259 -0
  32. package/src/generate/module/generateUseCases.js +67 -0
  33. package/src/generate/module/generateUseCases.ts +67 -0
  34. package/src/generate/module/repositoryModuleShared.js +598 -0
  35. package/src/generate/ui/generateComponent.js +98 -0
  36. package/src/generate/ui/generateComponent.ts +100 -0
  37. package/src/generate/ui/generateDesignComponent.js +71 -0
  38. package/src/generate/ui/generateDesignComponent.ts +71 -0
  39. package/src/generate/ui/generateWidget.js +71 -0
  40. package/src/generate/ui/generateWidget.ts +71 -0
  41. package/src/init/initAliases.js +159 -0
  42. package/src/init/initAliases.ts +167 -0
  43. package/src/init/initEdges.js +74 -0
  44. package/src/init/initEdges.ts +74 -0
  45. package/src/init/initStructure.js +122 -0
  46. package/src/init/initStructure.ts +124 -0
  47. package/src/install/installFresh.js +101 -0
  48. package/src/install/installFresh.ts +101 -0
  49. package/src/plugins/addLint.js +257 -0
  50. package/src/plugins/addLint.ts +274 -0
  51. package/src/plugins/index.js +1 -0
  52. package/src/plugins/index.ts +1 -0
  53. package/src/scaffolds/createCoreMiddleware.js +27 -0
  54. package/src/scaffolds/createCoreMiddleware.ts +27 -0
  55. package/src/scaffolds/createCoreSchema.js +141 -0
  56. package/src/scaffolds/createCoreSchema.ts +142 -0
  57. package/src/scaffolds/createDatasource.js +173 -0
  58. package/src/scaffolds/createDatasource.ts +175 -0
  59. package/src/scaffolds/createDatasourceProvider.js +164 -0
  60. package/src/scaffolds/createDatasourceProvider.ts +175 -0
  61. package/src/scaffolds/createMiddleware.js +105 -0
  62. package/src/scaffolds/createMiddleware.ts +105 -0
  63. package/src/scaffolds/createPresenterFactory.js +112 -0
  64. package/src/scaffolds/createPresenterFactory.ts +114 -0
  65. package/src/scaffolds/createResponse.js +64 -0
  66. package/src/scaffolds/createResponse.ts +64 -0
  67. package/src/scaffolds/createSchemaRule.js +40 -0
  68. package/src/scaffolds/createSchemaRule.ts +42 -0
  69. package/src/scaffolds/createTranslationManager.js +78 -0
  70. package/src/scaffolds/createTranslationManager.ts +78 -0
  71. package/src/scaffolds/index.js +9 -0
  72. package/src/scaffolds/index.ts +9 -0
  73. package/src/utils/contextUtils.js +56 -49
  74. package/src/utils/fileUtils.js +72 -84
  75. package/src/utils/loadConfig.js +57 -13
  76. package/tsconfig.json +19 -0
  77. package/src/commands/generate/generateComponent.js +0 -53
  78. package/src/commands/generate/generateDatasource.js +0 -84
  79. package/src/commands/generate/generateDesignComponent.js +0 -53
  80. package/src/commands/generate/generateResponse.js +0 -41
  81. package/src/commands/generate/generateWidget.js +0 -53
  82. package/src/commands/init/index.js +0 -9
  83. package/src/commands/init/initAliases.js +0 -52
  84. package/src/commands/init/initEdges.js +0 -42
  85. package/src/commands/init/initLint.js +0 -138
  86. package/src/commands/init/initMiddleware.js +0 -21
  87. package/src/commands/init/initPresenter.js +0 -25
  88. package/src/commands/init/initSchema.js +0 -22
  89. package/src/commands/init/initStructure.js +0 -140
  90. package/src/commands/init/initTranslations.js +0 -59
  91. package/src/commands/init/migrateStructure.js +0 -144
@@ -1,138 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { execSync } from 'child_process';
4
- import prompts from 'prompts';
5
-
6
- const dependencies = [
7
- '@commitlint/cli',
8
- 'semantic-release',
9
- '@semantic-release/git',
10
- 'git-cz',
11
- 'husky',
12
- 'commitizen',
13
- 'env-cmd'
14
- ];
15
-
16
- const scriptsToAdd = {
17
- precommit: 'pnpm lint && pnpm check',
18
- 'semantic-release': 'env-cmd semantic-release',
19
- commit: 'pnpm format && git add . && git-cz && git push',
20
- release: 'pnpm commit && pnpm semantic-release'
21
- };
22
-
23
- const commitlintConfig = `export default {
24
- rules: {
25
- 'body-leading-blank': [2, 'always'],
26
- 'footer-leading-blank': [2, 'always'],
27
- 'header-max-length': [2, 'always', 72],
28
- 'subject-empty': [2, 'never'],
29
- 'subject-full-stop': [2, 'never', '.'],
30
- 'type-case': [2, 'always', 'lower-case'],
31
- 'type-empty': [2, 'never'],
32
- 'type-enum': [2, 'always', ['feat', 'fix', 'refactor', 'perf', 'chore', 'docs', 'style', 'test', 'ci']]
33
- }
34
- };
35
- `;
36
-
37
- const releaseConfig = `export default {
38
- branches: ['main', 'dev'],
39
- dryRun: false,
40
- ci: false,
41
- plugins: [
42
- [
43
- '@semantic-release/commit-analyzer',
44
- {
45
- releaseRules: [
46
- { type: 'release', release: 'major' },
47
- { type: 'feature', release: 'minor' },
48
- { type: 'perf', release: false },
49
- { type: 'refactor', release: false },
50
- { type: 'fix', release: 'patch' },
51
- { type: 'chore', release: false },
52
- { type: 'ci', release: false },
53
- { type: 'docs', scope: 'README', release: false },
54
- { type: 'test', release: false },
55
- { type: 'style', release: false }
56
- ]
57
- }
58
- ],
59
- '@semantic-release/release-notes-generator'
60
- ]
61
- };
62
- `;
63
-
64
- const prettierConfig = `{
65
- "useTabs": true,
66
- "singleQuote": true,
67
- "trailingComma": "none",
68
- "tabWidth": 2,
69
- "semi": true,
70
- "printWidth": 150,
71
- "plugins": ["prettier-plugin-svelte"],
72
- "overrides": [
73
- {
74
- "files": "*.svelte",
75
- "options": {
76
- "parser": "svelte"
77
- }
78
- }
79
- ]
80
- }
81
- `;
82
-
83
- export default async function initLint() {
84
- const cwd = process.cwd();
85
- const pkgPath = path.join(cwd, 'package.json');
86
-
87
- if (!fs.existsSync(pkgPath)) {
88
- console.error('❌ package.json not found in this directory');
89
- process.exit(1);
90
- }
91
-
92
- const { manager } = await prompts({
93
- type: 'select',
94
- name: 'manager',
95
- message: 'Choose your package manager:',
96
- choices: [
97
- { title: 'pnpm', value: 'pnpm' },
98
- { title: 'npm', value: 'npm' },
99
- { title: 'yarn', value: 'yarn' }
100
- ],
101
- initial: 0
102
- });
103
-
104
- const installCommand =
105
- manager === 'pnpm'
106
- ? `pnpm add -D ${dependencies.join(' ')}`
107
- : manager === 'npm'
108
- ? `npm install -D ${dependencies.join(' ')}`
109
- : `yarn add -D ${dependencies.join(' ')}`;
110
-
111
- console.log(`📦 Installing packages with ${manager}...`);
112
- execSync(installCommand, { stdio: 'inherit' });
113
-
114
- console.log('📁 Updating package.json...');
115
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
116
-
117
- pkg.scripts = {
118
- ...pkg.scripts,
119
- ...scriptsToAdd
120
- };
121
-
122
- pkg.config = pkg.config || {};
123
- pkg.config.commitizen = {
124
- path: 'git-cz'
125
- };
126
-
127
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 4));
128
-
129
- // Write config files
130
- fs.writeFileSync(path.join(cwd, 'commitlint.config.ts'), commitlintConfig);
131
- fs.writeFileSync(path.join(cwd, 'release.config.ts'), releaseConfig);
132
- fs.writeFileSync(path.join(cwd, '.prettierrc'), prettierConfig);
133
-
134
- console.log('🔧 Initializing Husky...');
135
- execSync(`${manager === 'npm' ? 'npx' : manager} husky`, { stdio: 'inherit' });
136
- execSync('npm run format', { stdio: 'inherit' });
137
- console.log('✅ Linting and release setup completed! Change your prepare script in package.json: node -e \"if (process.env.NODE_ENV !== \'production\'){process.exit(1)} \" || (husky && svelte-kit sync)');
138
- }
@@ -1,21 +0,0 @@
1
- import { writeIfNotExists, updateCoreIndex } from '../../utils/fileUtils.js';
2
- import path from 'path';
3
-
4
- const middlewarePath = path.join(process.cwd(), 'src/core/middleware/MiddlewareManager.ts');
5
-
6
- const middlewareTemplate = `import { createMiddlewareManager } from '@azure-net/kit';
7
-
8
- export const { clientMiddleware, serverMiddleware } = createMiddlewareManager([]);`;
9
-
10
- export default async function initMiddleware() {
11
- await writeIfNotExists(middlewarePath, middlewareTemplate);
12
- await writeIfNotExists(
13
- path.join(process.cwd(), 'src/core/middleware/index.ts'),
14
- `export * from './MiddlewareManager';`
15
- );
16
-
17
- // Update core index
18
- await updateCoreIndex();
19
-
20
- console.log('✅ Middleware initialized');
21
- }
@@ -1,25 +0,0 @@
1
- import {updateCoreIndex, writeIfNotExists} from '../../utils/fileUtils.js';
2
- import path from 'path';
3
-
4
- const presenterPath = path.join(process.cwd(), 'src/core/presenters/AppPresenter.ts');
5
-
6
- const presenterTemplate = `import { createPresenterFactory } from '@azure-net/kit/edges';
7
- import { createAsyncHelpers, createErrorParser } from '@azure-net/kit';
8
-
9
- const ErrorHandler = createErrorParser();
10
- const AsyncHelpers = createAsyncHelpers({ parseError: ErrorHandler });
11
-
12
- export const AppPresenter = createPresenterFactory({ ...AsyncHelpers, handleError: ErrorHandler });`;
13
-
14
- export default async function initPresenter() {
15
- await writeIfNotExists(presenterPath, presenterTemplate);
16
- await writeIfNotExists(
17
- path.join(process.cwd(), 'src/core/presenters/index.ts'),
18
- `export * from './AppPresenter';`
19
- );
20
-
21
- // Update core index
22
- await updateCoreIndex();
23
-
24
- console.log('✅ Presenter factory initialized');
25
- }
@@ -1,22 +0,0 @@
1
- import { writeIfNotExists, updateCoreIndex } from '../../utils/fileUtils.js';
2
- import path from 'path';
3
-
4
- const schemaPath = path.join(process.cwd(), 'src/core/schemas/Schema.ts');
5
-
6
- const schemaTemplate = `import { createSchemaFactory } from '@azure-net/kit';
7
- import { createRules, validationMessagesI18n } from '@azure-net/kit/schema';
8
-
9
- export const Schema = createSchemaFactory(createRules(validationMessagesI18n));`;
10
-
11
- export default async function initSchema() {
12
- await writeIfNotExists(schemaPath, schemaTemplate);
13
- await writeIfNotExists(
14
- path.join(process.cwd(), 'src/core/schemas/index.ts'),
15
- `export * from './Schema';`
16
- );
17
-
18
- // Update core index
19
- await updateCoreIndex();
20
-
21
- console.log('✅ Schema factory initialized');
22
- }
@@ -1,140 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import { loadUserConfig } from '../../utils/loadConfig.js';
4
- import { updateCoreIndex } from '../../utils/fileUtils.js';
5
-
6
- const APP_PATH = path.join(process.cwd(), 'src', 'app');
7
- const CORE_PATH = path.join(process.cwd(), 'src', 'core');
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 createIndexFile(dirPath, exportPatterns = []) {
19
- const indexPath = path.join(dirPath, 'index.ts');
20
- if (exportPatterns.length > 0) {
21
- const content = exportPatterns.map(pattern => `export * from '${pattern}';`).join('\n') + '\n';
22
- await fs.writeFile(indexPath, content, 'utf-8');
23
- }
24
- }
25
-
26
- async function createBaseStructure(root, contextName, contextAlias) {
27
- // Create layers and ui folders
28
- const layersPath = path.join(root, 'layers');
29
- const uiPath = path.join(root, 'ui');
30
-
31
- await createDirIfNotExists(layersPath);
32
- await createDirIfNotExists(uiPath);
33
-
34
- // Domain - новая структура
35
- const domainPath = path.join(layersPath, 'domain');
36
- await createDirIfNotExists(domainPath);
37
-
38
- // Infrastructure
39
- const infraPath = path.join(layersPath, 'infrastructure');
40
- await createDirIfNotExists(path.join(infraPath, 'http', 'repositories'));
41
- await createDirIfNotExists(path.join(infraPath, 'http', 'datasources'));
42
- await createDirIfNotExists(path.join(infraPath, 'providers'));
43
-
44
- // Create empty InfrastructureProvider
45
- const infraProviderContent = `import { createBoundaryProvider } from '@azure-net/kit';
46
-
47
- export const InfrastructureProvider = createBoundaryProvider(
48
- \t'${contextName}InfrastructureProvider', {register: () => ({})}
49
- );`;
50
-
51
- await fs.writeFile(
52
- path.join(infraPath, 'providers', 'InfrastructureProvider.ts'),
53
- infraProviderContent,
54
- 'utf-8'
55
- );
56
-
57
- await fs.writeFile(
58
- path.join(infraPath, 'providers', 'index.ts'),
59
- `export * from './InfrastructureProvider';`,
60
- 'utf-8'
61
- );
62
-
63
- // Create Infrastructure index
64
- await fs.writeFile(
65
- path.join(infraPath, 'index.ts'),
66
- `export * from './providers';`,
67
- 'utf-8'
68
- );
69
-
70
- // Application
71
- const appPath = path.join(layersPath, 'application');
72
- await createDirIfNotExists(path.join(appPath, 'services'));
73
- await createDirIfNotExists(path.join(appPath, 'providers'));
74
-
75
- // Create empty ApplicationProvider with correct import
76
- const appProviderContent = `import { createBoundaryProvider } from '@azure-net/kit';
77
- import { InfrastructureProvider } from '\$${contextAlias}/infrastructure';
78
-
79
- export const ApplicationProvider = createBoundaryProvider(
80
- \t'${contextName}ApplicationProvider',
81
- \t{
82
- \t\tdependsOn: { InfrastructureProvider },
83
- \t\tregister: () => ({
84
- \t\t// Application services will be added here manually
85
- \t\t}),
86
- \t}
87
- );`;
88
-
89
- await fs.writeFile(
90
- path.join(appPath, 'providers', 'ApplicationProvider.ts'),
91
- appProviderContent,
92
- 'utf-8'
93
- );
94
-
95
- await fs.writeFile(
96
- path.join(appPath, 'providers', 'index.ts'),
97
- `export * from './ApplicationProvider';`,
98
- 'utf-8'
99
- );
100
-
101
- // Create Application index
102
- await fs.writeFile(
103
- path.join(appPath, 'index.ts'),
104
- `export * from './providers';`,
105
- 'utf-8'
106
- );
107
-
108
- // Delivery - organized by modules
109
- const deliveryPath = path.join(layersPath, 'delivery');
110
- await createDirIfNotExists(deliveryPath);
111
- }
112
-
113
- export default async function initStructure() {
114
- const config = await loadUserConfig();
115
- const contexts = config.contexts || ['app'];
116
-
117
- console.log('📦 Generating architecture...');
118
-
119
- // Create contexts directly in src/app
120
- for (const context of contexts) {
121
- const contextPath = path.join(APP_PATH, context);
122
- const contextName = context.charAt(0).toUpperCase() + context.slice(1);
123
- await createBaseStructure(contextPath, contextName, context);
124
- }
125
-
126
- // Create core structure with all functionality (in src/core, not src/app/core)
127
- await createDirIfNotExists(CORE_PATH);
128
- await createDirIfNotExists(path.join(CORE_PATH, 'datasources'));
129
- await createDirIfNotExists(path.join(CORE_PATH, 'responses'));
130
- await createDirIfNotExists(path.join(CORE_PATH, 'schemas'));
131
- await createDirIfNotExists(path.join(CORE_PATH, 'middleware'));
132
- await createDirIfNotExists(path.join(CORE_PATH, 'presenters'));
133
- await createDirIfNotExists(path.join(CORE_PATH, 'translations'));
134
- await createDirIfNotExists(path.join(CORE_PATH, 'providers'));
135
-
136
- // Update core index
137
- await updateCoreIndex();
138
-
139
- console.log('✅ Structure initialization complete!');
140
- }
@@ -1,59 +0,0 @@
1
- import { writeIfNotExists, updateCoreIndex } from '../../utils/fileUtils.js';
2
- import path from 'path';
3
-
4
- const translationsPath = path.join(process.cwd(), 'src/core/translations');
5
-
6
- const translationProviderTemplate = `import { messages } from './locales';
7
- import { createTranslations } from '@azure-net/kit/i18n';
8
-
9
- export const Translation = createTranslations({
10
- \tmessages,
11
- \tinitLang: 'en',
12
- \tinitLangFromAcceptLanguage: true,
13
- \tcookieName: 'lang'
14
- });`;
15
-
16
- const enLocaleTemplate = `export default {
17
- \tapp: {
18
- \t\ttitle: 'Application'
19
- \t}
20
- };`;
21
-
22
- const ruLocaleTemplate = `export default {
23
- \tapp: {
24
- \t\ttitle: 'Приложение'
25
- \t}
26
- };`;
27
-
28
- const localesIndexTemplate = `export const messages = {
29
- \ten: () => import('./en').then((res) => res.default),
30
- \tru: () => import('./ru').then((res) => res.default)
31
- };`;
32
-
33
- export default async function initTranslations() {
34
- // Create translation files
35
- await writeIfNotExists(
36
- path.join(translationsPath, 'index.ts'),
37
- translationProviderTemplate
38
- );
39
-
40
- await writeIfNotExists(
41
- path.join(translationsPath, 'locales', 'en.ts'),
42
- enLocaleTemplate
43
- );
44
-
45
- await writeIfNotExists(
46
- path.join(translationsPath, 'locales', 'ru.ts'),
47
- ruLocaleTemplate
48
- );
49
-
50
- await writeIfNotExists(
51
- path.join(translationsPath, 'locales', 'index.ts'),
52
- localesIndexTemplate
53
- );
54
-
55
- // Update core index
56
- await updateCoreIndex();
57
-
58
- console.log('✅ Translations initialized');
59
- }
@@ -1,144 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import { loadUserConfig } from '../../utils/loadConfig.js';
4
-
5
- const APP_PATH = path.join(process.cwd(), 'src/app');
6
- const OLD_CONTEXTS_PATH = path.join(APP_PATH, 'contexts');
7
- const OLD_CORE_PATH = path.join(APP_PATH, 'core');
8
- const NEW_CORE_PATH = path.join(process.cwd(), 'src/core');
9
-
10
- async function directoryExists(dirPath) {
11
- try {
12
- const stat = await fs.stat(dirPath);
13
- return stat.isDirectory();
14
- } catch {
15
- return false;
16
- }
17
- }
18
-
19
- async function moveDirectory(source, destination) {
20
- try {
21
- // Check if source exists
22
- if (!(await directoryExists(source))) {
23
- return false;
24
- }
25
-
26
- // Create destination parent directory if needed
27
- await fs.mkdir(path.dirname(destination), { recursive: true });
28
-
29
- // Move the directory
30
- await fs.rename(source, destination);
31
- console.log(`✅ Moved: ${source} -> ${destination}`);
32
- return true;
33
- } catch (error) {
34
- console.error(`❌ Failed to move ${source}:`, error.message);
35
- return false;
36
- }
37
- }
38
-
39
- async function removeEmptyDir(dirPath) {
40
- try {
41
- await fs.rmdir(dirPath);
42
- console.log(`🗑️ Removed empty directory: ${dirPath}`);
43
- } catch {
44
- // Directory not empty or doesn't exist
45
- }
46
- }
47
-
48
- export default async function migrateStructure() {
49
- const config = await loadUserConfig();
50
- const contexts = config.contexts || ['app'];
51
-
52
- console.log('🔄 Starting structure migration...\n');
53
- console.log('This will reorganize existing structure to the new format:\n');
54
- console.log(' - src/app/contexts/{context} -> src/app/{context}');
55
- console.log(' - src/app/core -> src/core');
56
- console.log(' - Ensure layers and ui folders exist\n');
57
-
58
- // Step 1: Migrate core from src/app/core to src/core
59
- if (await directoryExists(OLD_CORE_PATH)) {
60
- console.log('📦 Migrating core...');
61
-
62
- // Check if new core already exists
63
- if (await directoryExists(NEW_CORE_PATH)) {
64
- console.log('⚠️ Core already exists at src/core, skipping core migration...');
65
- } else {
66
- await moveDirectory(OLD_CORE_PATH, NEW_CORE_PATH);
67
- }
68
- }
69
-
70
- // Step 2: Migrate contexts
71
- for (const context of contexts) {
72
- console.log(`\n📁 Migrating context: ${context}`);
73
-
74
- const oldContextPath = path.join(OLD_CONTEXTS_PATH, context);
75
- const newContextPath = path.join(APP_PATH, context);
76
-
77
- // Check if context exists in old location (src/app/contexts/{context})
78
- if (await directoryExists(oldContextPath)) {
79
- // Check if new location already exists
80
- if (await directoryExists(newContextPath)) {
81
- console.log(`⚠️ Context '${context}' already exists at src/app/${context}, skipping...`);
82
- continue;
83
- }
84
-
85
- // Move from contexts/{context} to app/{context}
86
- await moveDirectory(oldContextPath, newContextPath);
87
- }
88
-
89
- // Now ensure the context has layers and ui structure
90
- const contextPath = newContextPath;
91
-
92
- if (!(await directoryExists(contextPath))) {
93
- console.log(`⚠️ Context '${context}' does not exist, skipping...`);
94
- continue;
95
- }
96
-
97
- const layersPath = path.join(contextPath, 'layers');
98
- const uiPath = path.join(contextPath, 'ui');
99
-
100
- // Check if already has layers structure
101
- if (await directoryExists(layersPath)) {
102
- console.log(`✓ Context '${context}' already has layers structure`);
103
-
104
- // Just ensure ui folder exists
105
- if (!(await directoryExists(uiPath))) {
106
- await fs.mkdir(uiPath, { recursive: true });
107
- console.log(`✅ Created: ${uiPath}`);
108
- }
109
-
110
- continue;
111
- }
112
-
113
- // Need to create layers structure
114
- console.log(`📦 Creating layers structure for '${context}'...`);
115
-
116
- await fs.mkdir(layersPath, { recursive: true });
117
- await fs.mkdir(uiPath, { recursive: true });
118
- console.log(`✅ Created: ${layersPath}`);
119
- console.log(`✅ Created: ${uiPath}`);
120
-
121
- // Move existing layer folders to layers directory
122
- const layerFolders = ['domain', 'infrastructure', 'application', 'delivery'];
123
-
124
- for (const layer of layerFolders) {
125
- const sourcePath = path.join(contextPath, layer);
126
- const destPath = path.join(layersPath, layer);
127
-
128
- await moveDirectory(sourcePath, destPath);
129
- }
130
-
131
- console.log(`✅ Context '${context}' migration completed!`);
132
- }
133
-
134
- // Step 3: Clean up old contexts folder if empty
135
- if (await directoryExists(OLD_CONTEXTS_PATH)) {
136
- await removeEmptyDir(OLD_CONTEXTS_PATH);
137
- }
138
-
139
- console.log('\n✅ Structure migration complete!');
140
- console.log('\n💡 Next steps:');
141
- console.log(' 1. Run "azure-net init:aliases" to update path aliases');
142
- console.log(' 2. Verify all imports are working correctly');
143
- console.log(' 3. Update any hardcoded paths in your code');
144
- }