Alexander b4d33beada
fix CLI asset sync (#355)
* fix CLI asset sync

* fix(cli): normalize line endings in asset sync/check

check:assets hashed raw bytes, so identical CSV/JSON/py content with
CRLF vs LF (git autocrlf on checkout) was reported as stale drift,
blocking the release guard on Windows/mixed checkouts.

- fileHash now normalizes CRLF->LF before hashing, so check:assets
  compares content, not line endings.
- sync:assets writes LF-normalized copies instead of a raw byte copy,
  so re-syncing is deterministic across platforms.

All synced assets are text (csv/json/md/py); no binaries affected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* ci: enforce CLI asset sync on PRs

Adds a Check asset sync workflow that runs `npm run check:assets` on any
PR touching src/ui-ux-pro-max/** or cli/assets/**, so the bundled CLI
assets can't silently drift from the source of truth.

The check uses only node builtins (no install step) and normalizes
line endings before hashing, so it hard-fails on real content drift
without the CRLF/LF soft-fail hack other approaches needed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 12:54:58 +07:00

47 lines
1.3 KiB
TypeScript

import chalk from 'chalk';
import ora from 'ora';
import { fetchReleases } from '../utils/github.js';
import { logger } from '../utils/logger.js';
interface VersionsOptions {
token?: string;
}
export async function versionsCommand(options: VersionsOptions = {}): Promise<void> {
const spinner = ora('Fetching available versions...').start();
try {
const releases = await fetchReleases(options.token);
if (releases.length === 0) {
spinner.warn('No releases found');
return;
}
spinner.succeed(`Found ${releases.length} version(s)\n`);
console.log(chalk.bold('Available versions:\n'));
releases.forEach((release, index) => {
const isLatest = index === 0;
const tag = release.tag_name;
const date = new Date(release.published_at).toLocaleDateString();
if (isLatest) {
console.log(` ${chalk.green('*')} ${chalk.bold(tag)} ${chalk.dim(`(${date})`)} ${chalk.green('[latest]')}`);
} else {
console.log(` ${tag} ${chalk.dim(`(${date})`)}`);
}
});
console.log();
logger.dim('Update the CLI package first, then run: uipro init --ai <platform>');
} catch (error) {
spinner.fail('Failed to fetch versions');
if (error instanceof Error) {
logger.error(error.message);
}
process.exit(1);
}
}