Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
],
"scripts": {
"start": "bun run src/ccstatusline.ts",
"build": "rm -rf dist/* ; bun build src/ccstatusline.ts --target=node --outfile=dist/ccstatusline.js --target-version=14",
"build": "rm -rf dist/* ; bun build src/ccstatusline.ts --target=node --splitting --format=esm --outdir=dist --target-version=14",
"postbuild": "bun run scripts/replace-version.ts",
"example": "cat scripts/payload.example.json | bun start",
"video:studio": "remotion studio remotion/index.ts",
Expand Down
30 changes: 21 additions & 9 deletions scripts/replace-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {
readFileSync,
readdirSync,
writeFileSync
} from 'fs';
import { join } from 'path';
Expand All @@ -15,14 +16,25 @@ interface PackageJson {
const packageJson = JSON.parse(readFileSync('package.json', 'utf-8')) as PackageJson;
const version = packageJson.version;

// Read the bundled file
const bundledFilePath = join('dist', 'ccstatusline.js');
let bundledContent = readFileSync(bundledFilePath, 'utf-8');

// Replace the placeholder with the actual version
bundledContent = bundledContent.replace(/__PACKAGE_VERSION__/g, version);
// The build emits the entry plus code-split chunks, and the placeholder can
// land in any of them, so patch every emitted script rather than just the entry.
let patched = 0;
for (const file of readdirSync('dist')) {
if (!file.endsWith('.js')) {
continue;
}
const path = join('dist', file);
const content = readFileSync(path, 'utf-8');
if (!content.includes('__PACKAGE_VERSION__')) {
continue;
}
writeFileSync(path, content.replace(/__PACKAGE_VERSION__/g, version));
patched++;
}

// Write back the modified content
writeFileSync(bundledFilePath, bundledContent);
if (patched === 0) {
console.error('✗ No __PACKAGE_VERSION__ placeholder found in dist/');
process.exit(1);
}

console.log(`✓ Replaced version placeholder with ${version}`);
console.log(`✓ Replaced version placeholder with ${version} in ${patched} file(s)`);
6 changes: 5 additions & 1 deletion src/ccstatusline.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import chalk from 'chalk';

import { runTUI } from './tui';
import type { SkillsMetrics } from './types';
import type { RenderContext } from './types/RenderContext';
import type { StatusJSON } from './types/StatusJSON';
Expand Down Expand Up @@ -353,6 +352,11 @@ async function main() {
const { updatemessage, ...newSettings } = settings;
await saveSettings(newSettings);
}
// Imported lazily: the TUI pulls in ink/React/yoga-layout, which the
// status line render path never touches. Claude Code re-runs this
// binary every couple of seconds, so keeping that graph off the
// render path is worth the dynamic import here.
const { runTUI } = await import('./tui');
runTUI();
}
}
Expand Down