react-native-live-widgets 1.2.1 → 1.2.2
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/CHANGELOG.md +27 -0
- package/README.md +89 -49
- package/android/src/main/AndroidManifest.xml +12 -0
- package/android/src/main/assets/fonts/MaterialIcons-Regular.ttf +0 -0
- package/android/src/main/java/com/reactnativeliveactivity/bridge/LiveActivityModule.kt +61 -1
- package/android/src/main/java/com/reactnativeliveactivity/liveactivity/LiveActivityNotifier.kt +153 -17
- package/android/src/main/java/com/reactnativeliveactivity/liveactivity/LiveActivityReceiver.kt +1 -1
- package/android/src/main/java/com/reactnativeliveactivity/renderer/DynamicWidgetCanvasRenderer.kt +86 -13
- package/android/src/main/java/com/reactnativeliveactivity/storage/DynamicWidgetImageCache.kt +53 -0
- package/android/src/main/java/com/reactnativeliveactivity/storage/DynamicWidgetStateStore.kt +647 -104
- package/android/src/main/java/com/reactnativeliveactivity/widgets/DynamicHomeScreenWidgetProvider.kt +3 -1
- package/android/src/main/java/com/reactnativeliveactivity/widgets/DynamicQuickSettingsTileService.kt +120 -0
- package/app.plugin.js +36 -0
- package/assets/MaterialIcons.json +2236 -0
- package/cli/codegen.js +789 -0
- package/cli/setup.js +323 -63
- package/docs/EXPO-GUIDE-EN.md +21 -3
- package/docs/EXPO-GUIDE-VI.md +21 -3
- package/docs/GUIDE-EN.md +203 -21
- package/docs/GUIDE-VI.md +207 -22
- package/docs/index.html +1328 -211
- package/docs/llms-full.txt +15 -0
- package/docs/llms.txt +16 -7
- package/ios/Bridge/LiveActivityModule.swift +333 -44
- package/ios/Intents/DynamicWidgetActionIntent.swift +57 -2
- package/ios/Models/DynamicLayoutModels.swift +114 -4
- package/ios/Renderer/DynamicNodeView.swift +15 -6
- package/ios/Storage/DynamicWidgetStateStore.swift +649 -38
- package/ios/Widgets/DynamicControlWidget.swift +63 -0
- package/ios/Widgets/DynamicHomeScreenWidget.swift +99 -26
- package/ios/Widgets/DynamicLiveActivityWidget.swift +25 -4
- package/lib/builder.d.ts +50 -7
- package/lib/builder.d.ts.map +1 -1
- package/lib/builder.js +326 -18
- package/lib/builder.js.map +1 -1
- package/lib/hooks.d.ts +13 -9
- package/lib/hooks.d.ts.map +1 -1
- package/lib/hooks.js +70 -12
- package/lib/hooks.js.map +1 -1
- package/lib/index.d.ts +80 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +303 -59
- package/lib/index.js.map +1 -1
- package/lib/ir.d.ts.map +1 -1
- package/lib/ir.js +9 -2
- package/lib/ir.js.map +1 -1
- package/lib/jsx.d.ts +11 -7
- package/lib/jsx.d.ts.map +1 -1
- package/lib/jsx.js +50 -13
- package/lib/jsx.js.map +1 -1
- package/lib/material-icons.generated.d.ts +8 -0
- package/lib/material-icons.generated.d.ts.map +1 -0
- package/lib/material-icons.generated.js +9 -0
- package/lib/material-icons.generated.js.map +1 -0
- package/lib/preview.d.ts +11 -4
- package/lib/preview.d.ts.map +1 -1
- package/lib/preview.js +150 -82
- package/lib/preview.js.map +1 -1
- package/lib/sf-symbols.generated.d.ts +8 -0
- package/lib/sf-symbols.generated.d.ts.map +1 -0
- package/lib/sf-symbols.generated.js +9 -0
- package/lib/sf-symbols.generated.js.map +1 -0
- package/lib/types.d.ts +302 -18
- package/lib/types.d.ts.map +1 -1
- package/package.json +6 -2
- package/scripts/build.js +98 -0
- package/scripts/generate-material-icons.js +93 -0
- package/scripts/generate-sf-symbols.js +95 -0
- package/scripts/release.js +115 -0
- package/scripts/test-ir-semantic.js +314 -0
- package/src/builder.ts +382 -24
- package/src/hooks.ts +88 -12
- package/src/index.ts +319 -56
- package/src/ir.ts +8 -2
- package/src/jsx.tsx +69 -21
- package/src/material-icons.generated.ts +3844 -0
- package/src/preview.tsx +235 -81
- package/src/sf-symbols.generated.ts +9533 -0
- package/src/types.ts +348 -18
package/scripts/build.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build & Package script for react-native-live-widgets
|
|
5
|
+
* Compiles TypeScript (src/*.ts) -> JavaScript (lib/*.js) + Type Definitions (lib/*.d.ts)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { execFileSync } = require('child_process');
|
|
11
|
+
|
|
12
|
+
const rootDir = path.resolve(__dirname, '..');
|
|
13
|
+
const libDir = path.join(rootDir, 'lib');
|
|
14
|
+
const tsconfigPath = path.join(rootDir, 'tsconfig.json');
|
|
15
|
+
|
|
16
|
+
function findTscBinary() {
|
|
17
|
+
const candidates = [
|
|
18
|
+
path.join(rootDir, 'node_modules', '.bin', 'tsc'),
|
|
19
|
+
path.join(rootDir, '..', 'LiveWidgetsExample', 'node_modules', '.bin', 'tsc'),
|
|
20
|
+
path.join(rootDir, '..', 'node_modules', '.bin', 'tsc'),
|
|
21
|
+
];
|
|
22
|
+
for (const candidate of candidates) {
|
|
23
|
+
if (fs.existsSync(candidate)) {
|
|
24
|
+
return candidate;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return 'tsc';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function cleanLib() {
|
|
31
|
+
if (fs.existsSync(libDir)) {
|
|
32
|
+
fs.rmSync(libDir, { recursive: true, force: true });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function build() {
|
|
37
|
+
console.log('📦 [react-native-live-widgets] Cleaning lib/ directory...');
|
|
38
|
+
cleanLib();
|
|
39
|
+
|
|
40
|
+
// Đảm bảo file sf-symbols.generated.ts và material-icons.generated.ts đã được sinh sẵn
|
|
41
|
+
try {
|
|
42
|
+
const { generateSFSymbolsFile } = require('./generate-sf-symbols');
|
|
43
|
+
const symbolsOutput = path.join(rootDir, 'src', 'sf-symbols.generated.ts');
|
|
44
|
+
if (!fs.existsSync(symbolsOutput)) {
|
|
45
|
+
generateSFSymbolsFile(symbolsOutput);
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.warn('ℹ️ [build] Không thể trích xuất SF Symbols tự động:', err.message);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const { generateMaterialIconsFile } = require('./generate-material-icons');
|
|
53
|
+
const materialOutput = path.join(rootDir, 'src', 'material-icons.generated.ts');
|
|
54
|
+
if (!fs.existsSync(materialOutput)) {
|
|
55
|
+
generateMaterialIconsFile(materialOutput);
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.warn('ℹ️ [build] Không thể trích xuất Material Icons tự động:', err.message);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const tscBin = findTscBinary();
|
|
62
|
+
console.log(`🔨 [react-native-live-widgets] Compiling TypeScript -> JavaScript + Type Definitions (.d.ts)...`);
|
|
63
|
+
execFileSync(tscBin, ['-p', tsconfigPath], {
|
|
64
|
+
cwd: rootDir,
|
|
65
|
+
stdio: 'inherit',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const expectedFiles = [
|
|
69
|
+
'index.js',
|
|
70
|
+
'index.d.ts',
|
|
71
|
+
'builder.js',
|
|
72
|
+
'builder.d.ts',
|
|
73
|
+
'types.js',
|
|
74
|
+
'types.d.ts',
|
|
75
|
+
'ir.js',
|
|
76
|
+
'ir.d.ts',
|
|
77
|
+
];
|
|
78
|
+
for (const file of expectedFiles) {
|
|
79
|
+
const filePath = path.join(libDir, file);
|
|
80
|
+
if (!fs.existsSync(filePath)) {
|
|
81
|
+
throw new Error(`Missing expected build output: lib/${file}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.log('✅ [react-native-live-widgets] Build succeeded! Output generated in ./lib:');
|
|
86
|
+
for (const file of fs.readdirSync(libDir)) {
|
|
87
|
+
const stat = fs.statSync(path.join(libDir, file));
|
|
88
|
+
console.log(` - lib/${file} (${stat.size} bytes)`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
build();
|
|
94
|
+
} catch (err) {
|
|
95
|
+
console.error('❌ [react-native-live-widgets] Build failed:', err.message);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Script tự động trích xuất toàn bộ Google Material Icons
|
|
5
|
+
* và sinh ra file type definitions `src/material-icons.generated.ts`
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
function findGlyphMapPath() {
|
|
12
|
+
const possiblePaths = [
|
|
13
|
+
path.join(__dirname, '..', 'assets', 'MaterialIcons.json'),
|
|
14
|
+
path.join(__dirname, '..', 'android', 'src', 'main', 'assets', 'MaterialIcons.json'),
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
for (const p of possiblePaths) {
|
|
18
|
+
if (fs.existsSync(p)) {
|
|
19
|
+
return p;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function generateMaterialIconsFile(outputPath) {
|
|
26
|
+
const glyphPath = findGlyphMapPath();
|
|
27
|
+
let iconNames = [];
|
|
28
|
+
|
|
29
|
+
if (glyphPath && fs.existsSync(glyphPath)) {
|
|
30
|
+
try {
|
|
31
|
+
const data = JSON.parse(fs.readFileSync(glyphPath, 'utf8'));
|
|
32
|
+
const set = new Set();
|
|
33
|
+
for (const name of Object.keys(data)) {
|
|
34
|
+
if (!name) continue;
|
|
35
|
+
set.add(name);
|
|
36
|
+
// Hỗ trợ cả snake_case và kebab-case
|
|
37
|
+
if (name.includes('-')) {
|
|
38
|
+
set.add(name.replace(/-/g, '_'));
|
|
39
|
+
}
|
|
40
|
+
if (name.includes('_')) {
|
|
41
|
+
set.add(name.replace(/_/g, '-'));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
iconNames = Array.from(set).sort();
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.warn('[Material Icons] Error reading glyphmap:', err.message);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (iconNames.length === 0) {
|
|
51
|
+
console.warn('[Material Icons] Glyphmap list not found, skipping file generation.');
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const lines = [
|
|
56
|
+
'/**',
|
|
57
|
+
' * AUTO-GENERATED BY react-native-live-widgets.',
|
|
58
|
+
' * Source: Google Material Icons GlyphMap',
|
|
59
|
+
` * Total icons: ${iconNames.length}`,
|
|
60
|
+
' * DO NOT EDIT MANUALLY.',
|
|
61
|
+
' */',
|
|
62
|
+
'',
|
|
63
|
+
'export type KnownMaterialIcon =',
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
for (const name of iconNames) {
|
|
67
|
+
lines.push(` | '${name}'`);
|
|
68
|
+
}
|
|
69
|
+
lines.push(';');
|
|
70
|
+
lines.push('');
|
|
71
|
+
|
|
72
|
+
fs.writeFileSync(outputPath, lines.join('\n'), 'utf8');
|
|
73
|
+
console.log(`🤖 Auto-generated Material Icons (${iconNames.length} icons) at: ${path.basename(outputPath)}`);
|
|
74
|
+
|
|
75
|
+
// Also update lib/ if it exists so types are available immediately
|
|
76
|
+
try {
|
|
77
|
+
const libTarget = outputPath.replace(/[\\/]src[\\/]/, '/lib/').replace(/\.ts$/, '.d.ts');
|
|
78
|
+
if (fs.existsSync(path.dirname(libTarget))) {
|
|
79
|
+
fs.writeFileSync(libTarget, lines.join('\n'), 'utf8');
|
|
80
|
+
}
|
|
81
|
+
} catch (_) {}
|
|
82
|
+
|
|
83
|
+
return iconNames.length;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (require.main === module) {
|
|
87
|
+
const target = path.join(__dirname, '..', 'src', 'material-icons.generated.ts');
|
|
88
|
+
generateMaterialIconsFile(target);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
module.exports = {
|
|
92
|
+
generateMaterialIconsFile,
|
|
93
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Script tự động trích xuất toàn bộ SF Symbols từ hệ thống Apple
|
|
5
|
+
* và sinh ra file type definitions `src/sf-symbols.generated.ts`
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { execSync } = require('child_process');
|
|
11
|
+
|
|
12
|
+
function extractSFSymbolsFromSystem() {
|
|
13
|
+
const possiblePaths = [
|
|
14
|
+
'/Applications/SF Symbols.app/Contents/Resources/Metadata/name_availability.plist',
|
|
15
|
+
'/Applications/Xcode.app/Contents/SharedFrameworks/DVTUserInterfaceKit.framework/Resources/SFSymbols/name_availability.plist',
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
for (const plistPath of possiblePaths) {
|
|
19
|
+
if (fs.existsSync(plistPath)) {
|
|
20
|
+
try {
|
|
21
|
+
const jsonStr = execSync(`plutil -convert json -o - "${plistPath}"`, {
|
|
22
|
+
encoding: 'utf8',
|
|
23
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
24
|
+
});
|
|
25
|
+
const data = JSON.parse(jsonStr);
|
|
26
|
+
const symbolsMap = data.symbols || data;
|
|
27
|
+
const names = Object.keys(symbolsMap).filter((name) => Boolean(name) && !name.startsWith('.'));
|
|
28
|
+
if (names.length > 0) {
|
|
29
|
+
names.sort();
|
|
30
|
+
return { symbols: names, source: plistPath };
|
|
31
|
+
}
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.warn(`[SF Symbols Extract] Error reading ${plistPath}:`, err.message);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function generateSFSymbolsFile(outputPath, fallbackList = []) {
|
|
42
|
+
let symbols = fallbackList;
|
|
43
|
+
let sourceLabel = 'Fallback Curated List';
|
|
44
|
+
|
|
45
|
+
const extracted = extractSFSymbolsFromSystem();
|
|
46
|
+
if (extracted && extracted.symbols.length > 0) {
|
|
47
|
+
symbols = extracted.symbols;
|
|
48
|
+
sourceLabel = extracted.source;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (symbols.length === 0) {
|
|
52
|
+
console.warn('[SF Symbols] No symbols found to generate.');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const lines = [
|
|
57
|
+
'/**',
|
|
58
|
+
' * AUTO-GENERATED BY react-native-live-widgets.',
|
|
59
|
+
` * Source: ${sourceLabel}`,
|
|
60
|
+
` * Total symbols: ${symbols.length}`,
|
|
61
|
+
' * DO NOT EDIT MANUALLY.',
|
|
62
|
+
' */',
|
|
63
|
+
'',
|
|
64
|
+
'export type KnownSFSymbol =',
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
for (const name of symbols) {
|
|
68
|
+
lines.push(` | '${name}'`);
|
|
69
|
+
}
|
|
70
|
+
lines.push(';');
|
|
71
|
+
lines.push('');
|
|
72
|
+
|
|
73
|
+
fs.writeFileSync(outputPath, lines.join('\n'), 'utf8');
|
|
74
|
+
console.log(`✨ Auto-generated SF Symbols (${symbols.length} icons) at: ${path.basename(outputPath)}`);
|
|
75
|
+
|
|
76
|
+
// Also update lib/ if it exists so types are available immediately
|
|
77
|
+
try {
|
|
78
|
+
const libTarget = outputPath.replace(/[\\/]src[\\/]/, '/lib/').replace(/\.ts$/, '.d.ts');
|
|
79
|
+
if (fs.existsSync(path.dirname(libTarget))) {
|
|
80
|
+
fs.writeFileSync(libTarget, lines.join('\n'), 'utf8');
|
|
81
|
+
}
|
|
82
|
+
} catch (_) {}
|
|
83
|
+
|
|
84
|
+
return symbols.length;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (require.main === module) {
|
|
88
|
+
const target = path.join(__dirname, '..', 'src', 'sf-symbols.generated.ts');
|
|
89
|
+
generateSFSymbolsFile(target);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
extractSFSymbolsFromSystem,
|
|
94
|
+
generateSFSymbolsFile,
|
|
95
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Release & Versioning script for react-native-live-widgets
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* node scripts/release.js patch # 1.0.0 -> 1.0.1
|
|
8
|
+
* node scripts/release.js minor # 1.0.0 -> 1.1.0
|
|
9
|
+
* node scripts/release.js major # 1.0.0 -> 2.0.0
|
|
10
|
+
* node scripts/release.js 1.2.0 # Set explicit version 1.2.0
|
|
11
|
+
* node scripts/release.js patch --tag # Also create git commit & tag vX.Y.Z locally
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const { execFileSync } = require('child_process');
|
|
17
|
+
|
|
18
|
+
const rootDir = path.resolve(__dirname, '..');
|
|
19
|
+
const pkgPath = path.join(rootDir, 'package.json');
|
|
20
|
+
const changelogPath = path.join(rootDir, 'CHANGELOG.md');
|
|
21
|
+
|
|
22
|
+
function bumpSemver(current, releaseType) {
|
|
23
|
+
if (/^\d+\.\d+\.\d+(-[\w.]+)?$/.test(releaseType)) {
|
|
24
|
+
return releaseType;
|
|
25
|
+
}
|
|
26
|
+
const parts = current.split('-')[0].split('.').map(Number);
|
|
27
|
+
if (parts.length !== 3 || parts.some(isNaN)) {
|
|
28
|
+
throw new Error(`Invalid current version in package.json: ${current}`);
|
|
29
|
+
}
|
|
30
|
+
let [major, minor, patch] = parts;
|
|
31
|
+
switch (releaseType) {
|
|
32
|
+
case 'major':
|
|
33
|
+
major += 1;
|
|
34
|
+
minor = 0;
|
|
35
|
+
patch = 0;
|
|
36
|
+
break;
|
|
37
|
+
case 'minor':
|
|
38
|
+
minor += 1;
|
|
39
|
+
patch = 0;
|
|
40
|
+
break;
|
|
41
|
+
case 'patch':
|
|
42
|
+
patch += 1;
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
throw new Error(`Unknown release type "${releaseType}". Use patch | minor | major | <X.Y.Z>`);
|
|
46
|
+
}
|
|
47
|
+
return `${major}.${minor}.${patch}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function updateChangelog(newVersion) {
|
|
51
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
52
|
+
const header = `## [${newVersion}] - ${today}\n`;
|
|
53
|
+
let existing = '';
|
|
54
|
+
if (fs.existsSync(changelogPath)) {
|
|
55
|
+
existing = fs.readFileSync(changelogPath, 'utf8');
|
|
56
|
+
} else {
|
|
57
|
+
existing = `# Changelog\n\nAll notable changes to \`react-native-live-widgets\` will be documented in this file.\n\n`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (existing.includes(`## [${newVersion}]`)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const marker = 'All notable changes to `react-native-live-widgets` will be documented in this file.\n\n';
|
|
65
|
+
if (existing.includes(marker)) {
|
|
66
|
+
existing = existing.replace(
|
|
67
|
+
marker,
|
|
68
|
+
`${marker}${header}- Release version ${newVersion}\n\n`
|
|
69
|
+
);
|
|
70
|
+
} else {
|
|
71
|
+
existing = `${existing}\n${header}- Release version ${newVersion}\n`;
|
|
72
|
+
}
|
|
73
|
+
fs.writeFileSync(changelogPath, existing, 'utf8');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function run() {
|
|
77
|
+
const args = process.argv.slice(2);
|
|
78
|
+
const releaseType = args.find((a) => !a.startsWith('--')) || 'patch';
|
|
79
|
+
const shouldTag = args.includes('--tag');
|
|
80
|
+
|
|
81
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
82
|
+
const oldVersion = pkg.version;
|
|
83
|
+
const newVersion = bumpSemver(oldVersion, releaseType);
|
|
84
|
+
|
|
85
|
+
console.log(`🚀 Bumping version: ${oldVersion} -> ${newVersion}`);
|
|
86
|
+
|
|
87
|
+
// 1. Update package.json
|
|
88
|
+
pkg.version = newVersion;
|
|
89
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
|
90
|
+
|
|
91
|
+
// 2. Update CHANGELOG.md
|
|
92
|
+
updateChangelog(newVersion);
|
|
93
|
+
|
|
94
|
+
// 3. Build TypeScript -> lib/
|
|
95
|
+
execFileSync(process.execPath, [path.join(__dirname, 'build.js')], {
|
|
96
|
+
cwd: rootDir,
|
|
97
|
+
stdio: 'inherit',
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// 4. Optional local git commit & tag (never pushes to remote automatically)
|
|
101
|
+
if (shouldTag) {
|
|
102
|
+
execFileSync('git', ['add', 'package.json', 'CHANGELOG.md', 'lib'], { cwd: rootDir, stdio: 'inherit' });
|
|
103
|
+
execFileSync('git', ['commit', '-m', `chore(release): v${newVersion}`], { cwd: rootDir, stdio: 'inherit' });
|
|
104
|
+
execFileSync('git', ['tag', '-a', `v${newVersion}`, '-m', `Release v${newVersion}`], {
|
|
105
|
+
cwd: rootDir,
|
|
106
|
+
stdio: 'inherit',
|
|
107
|
+
});
|
|
108
|
+
console.log(`🏷️ Created local commit and git tag v${newVersion} (not pushed).`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
console.log(`✅ Version ${newVersion} is ready!`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
run();
|
|
115
|
+
|