@azure-net/cli 1.3.1 → 1.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
@@ -4,7 +4,7 @@ import { loadUserConfig } from '../utils/loadConfig.js';
4
4
 
5
5
  const BASE_STRUCTURE = ['domain', 'infra', 'application', 'presentation'];
6
6
  const APP_ROOT = path.join(process.cwd(), 'src', 'app');
7
- const ARCHITECTURE_PATH = path.join(APP_ROOT, 'architecture');
7
+ const ARCHITECTURE_PATH = path.join(APP_ROOT, 'context');
8
8
 
9
9
  async function createDirIfNotExists(dirPath) {
10
10
  try {
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs/promises';
2
2
  import path from 'path';
3
3
  import { loadUserConfig } from '../utils/loadConfig.js';
4
+ import { execSync } from 'child_process';
4
5
 
5
6
  /** Файл конфигурации */
6
7
  const svelteConfigPath = path.resolve('svelte.config.js');
@@ -41,32 +42,57 @@ function serializeObjectLiteral(obj) {
41
42
  .join(',\n');
42
43
  }
43
44
 
45
+ function insertAliasBlock(content, aliasBlock) {
46
+ const kitRegex = /kit:\s*{([\s\S]*?)}/m;
47
+ const match = content.match(kitRegex);
48
+
49
+ if (!match) {
50
+ throw new Error('❌ Cannot find `kit: {}` block in svelte.config.js');
51
+ }
52
+
53
+ const existingKit = match[0];
54
+ const newKit = existingKit.includes('alias:')
55
+ ? existingKit.replace(/alias:\s*{([\s\S]*?)}/m, aliasBlock)
56
+ : existingKit.replace(/{/, `{\n\t\t${aliasBlock},`);
57
+
58
+ return content.replace(kitRegex, newKit);
59
+ }
60
+
44
61
  async function updateAliases() {
45
62
  const config = await loadUserConfig();
46
63
  const newAliases = generateAliases(config);
47
64
 
48
65
  let content = await fs.readFile(svelteConfigPath, 'utf-8');
49
66
 
67
+ // если alias уже есть
50
68
  const aliasRegex = /alias:\s*{([\s\S]*?)}/m;
51
- const match = content.match(aliasRegex);
69
+ const aliasMatch = content.match(aliasRegex);
52
70
 
53
- if (!match) {
54
- console.error('❌ No `alias` field found in svelte.config.js');
55
- process.exit(1);
56
- }
71
+ let updatedAliases = {};
57
72
 
58
- // существующие алиасы
59
- const existingAliases = parseObjectLiteral(match[1]);
60
-
61
- // объединение
62
- const updatedAliases = { ...existingAliases, ...newAliases };
73
+ if (aliasMatch) {
74
+ const existingAliases = parseObjectLiteral(aliasMatch[1]);
75
+ updatedAliases = { ...existingAliases, ...newAliases };
76
+ } else {
77
+ updatedAliases = { ...newAliases };
78
+ }
63
79
 
64
- // замена в контенте
65
80
  const newAliasBlock = `alias: {\n${serializeObjectLiteral(updatedAliases)}\n\t\t}`;
66
- content = content.replace(aliasRegex, newAliasBlock);
81
+
82
+ content = aliasMatch
83
+ ? content.replace(aliasRegex, newAliasBlock)
84
+ : insertAliasBlock(content, newAliasBlock);
67
85
 
68
86
  await fs.writeFile(svelteConfigPath, content, 'utf-8');
69
87
  console.log('✅ Aliases updated in svelte.config.js');
88
+
89
+ // Run formatter
90
+ try {
91
+ execSync('npm run format', { stdio: 'inherit' });
92
+ console.log('✅ Ran npm run format');
93
+ } catch {
94
+ console.warn('⚠️ Failed to run format. Make sure you have a format script in package.json');
95
+ }
70
96
  }
71
97
 
72
98
  export default updateAliases;