core-maugli 1.2.5 → 1.2.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "core-maugli",
3
3
  "description": "Astro & Tailwind CSS blog theme for Maugli.",
4
4
  "type": "module",
5
- "version": "1.2.5",
5
+ "version": "1.2.6",
6
6
  "license": "GPL-3.0-or-later OR Commercial",
7
7
  "repository": {
8
8
  "type": "git",
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'fs/promises';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ async function testVersionUpdate() {
11
+ console.log('🧪 Testing version update function...');
12
+
13
+ try {
14
+ // Получаем версию из package.json
15
+ const packageJsonPath = path.join(__dirname, '../package.json');
16
+ const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
17
+ const packageData = JSON.parse(packageJsonContent);
18
+ const newVersion = packageData.version;
19
+
20
+ // Путь к конфигу
21
+ const configPath = path.join(__dirname, '../src/config/maugli.config.ts');
22
+
23
+ // Читаем конфиг
24
+ const configContent = await fs.readFile(configPath, 'utf-8');
25
+
26
+ // Ищем строку с MAUGLI_CONFIG_VERSION
27
+ const versionRegex = /export const MAUGLI_CONFIG_VERSION = ['"`]([^'"`]+)['"`];/;
28
+ const match = configContent.match(versionRegex);
29
+
30
+ if (match) {
31
+ const currentVersion = match[1];
32
+ console.log(`📦 Current config version: ${currentVersion}`);
33
+ console.log(`📦 Package version: ${newVersion}`);
34
+
35
+ if (currentVersion !== newVersion) {
36
+ const updatedContent = configContent.replace(
37
+ versionRegex,
38
+ `export const MAUGLI_CONFIG_VERSION = '${newVersion}';`
39
+ );
40
+
41
+ await fs.writeFile(configPath, updatedContent, 'utf-8');
42
+ console.log(`✅ Updated config version: ${currentVersion} → ${newVersion}`);
43
+ } else {
44
+ console.log(`✅ Config version already up to date: ${newVersion}`);
45
+ }
46
+ } else {
47
+ console.log('❌ Config version line not found');
48
+ }
49
+ } catch (error) {
50
+ console.error('❌ Test failed:', error.message);
51
+ }
52
+ }
53
+
54
+ testVersionUpdate();
@@ -28,6 +28,9 @@ const FORCE_UPDATE_PATHS = [
28
28
  'src/scripts',
29
29
  'src/icons',
30
30
  'src/i18n',
31
+ 'scripts', // Скрипты в корне проекта (включая generate-previews.js)
32
+ 'typograf-batch.js', // Отдельный файл
33
+ 'resize-all.cjs', // Отдельный файл для ресайза
31
34
  'public/flags',
32
35
  'public/img/default'
33
36
  // Исключили src/styles - может содержать пользовательские стили
@@ -41,9 +44,82 @@ const PRESERVE_PATHS = [
41
44
  'package.json',
42
45
  'astro.config.mjs',
43
46
  'tailwind.config.js',
44
- 'tsconfig.json'
47
+ 'tsconfig.json',
48
+ 'scripts/custom-*' // Пользовательские скрипты с префиксом custom-
45
49
  ];
46
50
 
51
+ async function updateConfigVersion() {
52
+ try {
53
+ // Получаем версию из package.json пакета
54
+ const packageJsonPath = path.join(packageRoot, 'package.json');
55
+ const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
56
+ const packageData = JSON.parse(packageJsonContent);
57
+ const newVersion = packageData.version;
58
+
59
+ // Путь к package.json пользователя
60
+ const userPackageJsonPath = path.join(userRoot, 'package.json');
61
+
62
+ try {
63
+ // Читаем package.json пользователя
64
+ const userPackageContent = await fs.readFile(userPackageJsonPath, 'utf-8');
65
+ const userPackageData = JSON.parse(userPackageContent);
66
+
67
+ let updated = false;
68
+
69
+ // Обновляем версию зависимости
70
+ if (userPackageData.dependencies && userPackageData.dependencies['core-maugli']) {
71
+ const currentVersion = userPackageData.dependencies['core-maugli'];
72
+ if (currentVersion !== `^${newVersion}`) {
73
+ userPackageData.dependencies['core-maugli'] = `^${newVersion}`;
74
+ updated = true;
75
+ }
76
+ }
77
+
78
+ if (userPackageData.devDependencies && userPackageData.devDependencies['core-maugli']) {
79
+ const currentVersion = userPackageData.devDependencies['core-maugli'];
80
+ if (currentVersion !== `^${newVersion}`) {
81
+ userPackageData.devDependencies['core-maugli'] = `^${newVersion}`;
82
+ updated = true;
83
+ }
84
+ }
85
+
86
+ // Обновляем build скрипт для включения генерации превью
87
+ if (userPackageData.scripts) {
88
+ const expectedBuildScript = "node typograf-batch.js && node scripts/generate-previews.js && node scripts/verify-assets.js && astro build";
89
+ const currentBuildScript = userPackageData.scripts.build;
90
+
91
+ // Проверяем, содержит ли build скрипт генерацию превью
92
+ if (currentBuildScript && !currentBuildScript.includes('generate-previews.js')) {
93
+ // Добавляем генерацию превью в build процесс
94
+ if (currentBuildScript.includes('astro build')) {
95
+ userPackageData.scripts.build = currentBuildScript.replace(
96
+ 'astro build',
97
+ 'node scripts/generate-previews.js && astro build'
98
+ );
99
+ updated = true;
100
+ console.log('📦 Added generate-previews.js to build script');
101
+ }
102
+ }
103
+ }
104
+
105
+ if (updated) {
106
+ await fs.writeFile(userPackageJsonPath, JSON.stringify(userPackageData, null, 2) + '\n', 'utf-8');
107
+ console.log(`📦 Updated package.json with version ^${newVersion}`);
108
+ } else {
109
+ console.log(`📦 Package.json already up to date`);
110
+ }
111
+ } catch (error) {
112
+ if (error.code === 'ENOENT') {
113
+ console.log('📦 User package.json not found, skipping version update');
114
+ } else {
115
+ console.warn('Warning: Could not update package.json version:', error.message);
116
+ }
117
+ }
118
+ } catch (error) {
119
+ console.warn('Warning: Could not read package version:', error.message);
120
+ }
121
+ }
122
+
47
123
  async function copyDirectory(src, dest) {
48
124
  try {
49
125
  await fs.mkdir(dest, { recursive: true });
@@ -154,6 +230,9 @@ async function updateComponents() {
154
230
  // Обрабатываем стили отдельно
155
231
  await updateStyles();
156
232
 
233
+ // Обновляем версию в конфиге
234
+ await updateConfigVersion();
235
+
157
236
  console.log(`✅ Updated ${updatedCount} component directories/files`);
158
237
  }
159
238
 
@@ -93,7 +93,7 @@ async function main() {
93
93
  const defText = await fs.readFile(defaultConfigPath, 'utf8');
94
94
  const headerEnd = defText.indexOf('export const maugliConfig');
95
95
  let header = defText.slice(0, headerEnd);
96
- header = header.replace(/MAUGLI_CONFIG_VERSION\s*=\s*['\"][^'\"]*['\"]/, `MAUGLI_CONFIG_VERSION = '${newVersion}'`);
96
+ // Не обновляем MAUGLI_CONFIG_VERSION автоматически - только вручную при добавлении новых полей
97
97
  let bracePos = defText.indexOf('{', headerEnd);
98
98
  let count = 0,
99
99
  i = bracePos;