mirror of
https://github.com/jlengrand/Maestro.git
synced 2026-03-10 08:31:19 +00:00
refactor: Cross-platform build scripts and session format cleanup
- Add scripts/set-version.mjs for cross-platform VITE_APP_VERSION setting
(replaces bash-specific env var syntax that failed on Windows)
- Extract magic numbers into CLAUDE_SESSION_PARSE_LIMITS and CLAUDE_PRICING
constants for better maintainability
- Remove legacy session format migration code - sessions now require aiTabs
- Fix session ID regex patterns to properly parse -ai-{tabId} format
- Remove deprecated aiLogs fallbacks - logs are exclusively in aiTabs now
Claude ID: bfd92ffb-a375-47be-94c5-fe4186325092
Maestro ID: b9bc0d08-5be2-4fdf-93cd-5618a8d53b35
This commit is contained in:
56
scripts/set-version.mjs
Normal file
56
scripts/set-version.mjs
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Cross-platform script to set VITE_APP_VERSION environment variable
|
||||
* with the local git hash. Works on Windows, macOS, and Linux.
|
||||
*
|
||||
* Usage: node scripts/set-version.mjs <command> [args...]
|
||||
* Example: node scripts/set-version.mjs npm run build
|
||||
*/
|
||||
|
||||
import { execFileSync, spawn } from 'child_process';
|
||||
import process from 'process';
|
||||
|
||||
function getGitHash() {
|
||||
try {
|
||||
const hash = execFileSync('git', ['rev-parse', '--short=8', 'HEAD'], {
|
||||
encoding: 'utf8',
|
||||
stdio: ['pipe', 'pipe', 'pipe']
|
||||
}).trim();
|
||||
return hash;
|
||||
} catch {
|
||||
return 'unknown';
|
||||
}
|
||||
}
|
||||
|
||||
const gitHash = getGitHash();
|
||||
const version = `LOCAL ${gitHash}`;
|
||||
|
||||
// Set environment variable
|
||||
process.env.VITE_APP_VERSION = version;
|
||||
|
||||
// Get the command and args to run
|
||||
const [,, ...args] = process.argv;
|
||||
|
||||
if (args.length === 0) {
|
||||
console.log(`VITE_APP_VERSION=${version}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Run the command with the environment variable set
|
||||
const command = args[0];
|
||||
const commandArgs = args.slice(1);
|
||||
|
||||
const child = spawn(command, commandArgs, {
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
env: { ...process.env, VITE_APP_VERSION: version }
|
||||
});
|
||||
|
||||
child.on('close', (code) => {
|
||||
process.exit(code ?? 0);
|
||||
});
|
||||
|
||||
child.on('error', (err) => {
|
||||
console.error(`Failed to run command: ${err.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user