fix: restore CLI validation and test baseline (#1857)
Fixed lazy CLI helper imports for tunnel flows Restored update command version detection Made web test and dead-code commands run reliably
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { beforeEach, describe, expect, it, mock } from 'bun:test';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
const gitLibraries = {
|
||||
stageFiles: mock(),
|
||||
unstageFiles: mock(),
|
||||
stageFiles: vi.fn(),
|
||||
unstageFiles: vi.fn(),
|
||||
};
|
||||
|
||||
mock.module('./index.js', () => ({
|
||||
vi.mock('./index.js', () => ({
|
||||
stageFiles: gitLibraries.stageFiles,
|
||||
unstageFiles: gitLibraries.unstageFiles,
|
||||
}));
|
||||
|
||||
@@ -982,6 +982,7 @@ export function registerGitHubRoutes(app) {
|
||||
if (upstream) {
|
||||
try {
|
||||
const { getRemotes } = await import('../git/index.js');
|
||||
const { resolveGitHubRepoFromDirectory } = await import('./index.js');
|
||||
const remotes = await getRemotes(directory);
|
||||
for (const r of remotes) {
|
||||
if (r?.name) {
|
||||
|
||||
@@ -621,7 +621,7 @@ export function getUpdateCommand(pm = detectPackageManager()) {
|
||||
/**
|
||||
* Get current installed version from package.json
|
||||
*/
|
||||
function getCurrentVersion() {
|
||||
export function getCurrentVersion() {
|
||||
try {
|
||||
const pkgPath = path.resolve(__dirname, '..', '..', 'package.json');
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
||||
|
||||
@@ -6,7 +6,7 @@ vi.mock('node:child_process', () => ({
|
||||
spawnSync: vi.fn(() => ({ status: 0, stdout: '/usr/local/bin', stderr: '' })),
|
||||
}));
|
||||
|
||||
const { checkForUpdates } = await import('./package-manager.js');
|
||||
const { checkForUpdates, getCurrentVersion } = await import('./package-manager.js');
|
||||
|
||||
/** Helper: create a fetch mock that routes by URL pattern */
|
||||
function createFetchMock() {
|
||||
@@ -244,3 +244,10 @@ describe('checkForUpdates', () => {
|
||||
expect(result.available).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getCurrentVersion', () => {
|
||||
it('is exported for the CLI update command', () => {
|
||||
expect(typeof getCurrentVersion).toBe('function');
|
||||
expect(getCurrentVersion()).toMatch(/^\d+\.\d+\.\d+|unknown$/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user