@azure-net/cli 1.4.2 → 2.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 (32) hide show
  1. package/bin/azure-net.js +82 -37
  2. package/package.json +1 -1
  3. package/src/commands/generate/generateCrud.js +323 -0
  4. package/src/commands/generate/generateDatasource.js +36 -0
  5. package/src/commands/generate/generateModule.js +23 -0
  6. package/src/commands/generate/generatePresenter.js +113 -0
  7. package/src/commands/generate/generateRepository.js +97 -0
  8. package/src/commands/generate/generateResponse.js +42 -0
  9. package/src/commands/generate/generateSchema.js +70 -0
  10. package/src/commands/generate/generateService.js +93 -0
  11. package/src/commands/generate/index.js +8 -0
  12. package/src/commands/init/index.js +6 -0
  13. package/src/commands/init/initAliases.js +50 -0
  14. package/src/commands/init/initEdges.js +42 -0
  15. package/src/commands/init/initMiddleware.js +58 -0
  16. package/src/commands/init/initSchema.js +19 -0
  17. package/src/commands/init/initStructure.js +68 -0
  18. package/src/commands/init/initTranslations.js +97 -0
  19. package/src/utils/contextUtils.js +53 -0
  20. package/src/utils/fileUtils.js +60 -0
  21. package/src/utils/loadConfig.js +2 -2
  22. package/src/utils/providerUtils.js +78 -0
  23. package/.idea/azure-net-ecosystem-cli.iml +0 -9
  24. package/.idea/modules.xml +0 -8
  25. package/src/commands/generateCrud.js +0 -135
  26. package/src/commands/generateDatasource.js +0 -44
  27. package/src/commands/generateRepo.js +0 -69
  28. package/src/commands/generateRequest.js +0 -95
  29. package/src/commands/generateService.js +0 -77
  30. package/src/commands/generateStructure.js +0 -65
  31. package/src/commands/initAliases.js +0 -101
  32. package/src/commands/initLint.js +0 -138
@@ -1,65 +0,0 @@
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 CONTEXTS_PATH = path.join(APP_ROOT, 'contexts');
8
- const CORE_PATH = path.join(APP_ROOT, 'core');
9
-
10
- async function createDirIfNotExists(dirPath) {
11
- try {
12
- await fs.mkdir(dirPath, { recursive: true });
13
- console.log(`📁 Created: ${dirPath}`);
14
- } catch (e) {
15
- console.error(`❌ Failed to create ${dirPath}:`, e.message);
16
- }
17
- }
18
-
19
- async function createBaseStructure(root) {
20
- for (const section of BASE_STRUCTURE) {
21
- const sectionPath = path.join(root, section);
22
- await createDirIfNotExists(sectionPath);
23
-
24
- if (section === 'Infra') {
25
- await createDirIfNotExists(path.join(sectionPath, 'Repo'));
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
- const hasModules = Array.isArray(modules) && modules.length > 0;
38
-
39
- console.log('📦 Generating architecture in: /contexts');
40
-
41
- // всегда shared-context
42
- const sharedKernelPath = path.join(CONTEXTS_PATH, 'shared-context');
43
- await createBaseStructure(sharedKernelPath);
44
-
45
- if (hasModules) {
46
- // по модулям
47
- console.log('🔧 Creating module contexts...');
48
- for (const mod of modules) {
49
- const modPath = path.join(CONTEXTS_PATH, mod);
50
- await createBaseStructure(modPath);
51
- }
52
- } else {
53
- // fallback-контекст
54
- console.log('🧱 No modules found — using default "app-context"...');
55
- const fallbackPath = path.join(CONTEXTS_PATH, 'app-context');
56
- await createBaseStructure(fallbackPath);
57
- }
58
-
59
- // Доп. слои вне contexts
60
- await createDirIfNotExists(CORE_PATH);
61
- await createDirIfNotExists(path.join(CORE_PATH, 'datasources'));
62
- await createDirIfNotExists(path.join(APP_ROOT, 'ui'));
63
-
64
- console.log('✅ Structure initialization complete!');
65
- }
@@ -1,101 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import { loadUserConfig } from '../utils/loadConfig.js';
4
- import { execSync } from 'child_process';
5
-
6
- /** Файл конфигурации */
7
- const svelteConfigPath = path.resolve('svelte.config.js');
8
-
9
- function generateAliases(config) {
10
- const hasModules = Array.isArray(config.modules) && config.modules.length > 0;
11
-
12
- if (hasModules) {
13
- config.modules.push('shared-context');
14
- return Object.fromEntries(
15
- [
16
- ...config.modules.map(m => [`$${m}`, `./src/app/contexts/${m}`]),
17
- ['$core', './src/app/core'],
18
- ['$ui', './src/app/ui']
19
- ]
20
- );
21
- }
22
-
23
- return {
24
- '$app-context': './src/app/contexts/app-context',
25
- '$shared-context': './src/app/contexts/shared-context',
26
- '$core': './src/app/core',
27
- '$ui': './src/app/ui'
28
- };
29
- }
30
-
31
- function parseObjectLiteral(text) {
32
- const obj = {};
33
- const entries = text.split(/,(?![^{]*})/).filter(Boolean);
34
- for (const entry of entries) {
35
- const [key, value] = entry.split(':').map(s => s.trim());
36
- if (key && value) {
37
- obj[key.replace(/^['"]|['"]$/g, '')] = value.replace(/^['"]|['"]$/g, '');
38
- }
39
- }
40
- return obj;
41
- }
42
-
43
- function serializeObjectLiteral(obj) {
44
- return Object.entries(obj)
45
- .map(([key, value]) => `\t\t\t'${key}': '${value}'`)
46
- .join(',\n');
47
- }
48
-
49
- function insertAliasBlock(content, aliasBlock) {
50
- const kitRegex = /kit:\s*{([\s\S]*?)}/m;
51
- const match = content.match(kitRegex);
52
-
53
- if (!match) {
54
- throw new Error('❌ Cannot find `kit: {}` block in svelte.config.js');
55
- }
56
-
57
- const existingKit = match[0];
58
- const newKit = existingKit.includes('alias:')
59
- ? existingKit.replace(/alias:\s*{([\s\S]*?)}/m, aliasBlock)
60
- : existingKit.replace(/{/, `{\n\t\t${aliasBlock},`);
61
-
62
- return content.replace(kitRegex, newKit);
63
- }
64
-
65
- async function updateAliases() {
66
- const config = await loadUserConfig();
67
- const newAliases = generateAliases(config);
68
-
69
- let content = await fs.readFile(svelteConfigPath, 'utf-8');
70
-
71
- // если alias уже есть
72
- const aliasRegex = /alias:\s*{([\s\S]*?)}/m;
73
- const aliasMatch = content.match(aliasRegex);
74
-
75
- let updatedAliases = {};
76
-
77
- if (aliasMatch) {
78
- const existingAliases = parseObjectLiteral(aliasMatch[1]);
79
- updatedAliases = { ...existingAliases, ...newAliases };
80
- } else {
81
- updatedAliases = { ...newAliases };
82
- }
83
-
84
- const newAliasBlock = `alias: {\n${serializeObjectLiteral(updatedAliases)}\n\t\t}`;
85
-
86
- content = aliasMatch
87
- ? content.replace(aliasRegex, newAliasBlock)
88
- : insertAliasBlock(content, newAliasBlock);
89
-
90
- await fs.writeFile(svelteConfigPath, content, 'utf-8');
91
- console.log('✅ Aliases updated in svelte.config.js');
92
-
93
- // Run formatter
94
- try {
95
- execSync('npm run format', { stdio: 'inherit' });
96
- } catch {
97
- console.warn('⚠️ Failed to run format. Make sure you have a format script in package.json');
98
- }
99
- }
100
-
101
- export default updateAliases;
@@ -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
- }