mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-17 10:03:08 +00:00
Merge remote-tracking branch 'origin/v0.15.0rc' into feature/bug-startup-warning-ignores-claude-oauth-credenti-fuzx
This commit is contained in:
100
libs/platform/tests/rc-file-manager.test.ts
Normal file
100
libs/platform/tests/rc-file-manager.test.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import { needsRegeneration, writeRcFiles } from '../src/rc-file-manager';
|
||||
import { terminalThemeColors } from '../src/terminal-theme-colors';
|
||||
import type { TerminalConfig } from '../src/rc-generator';
|
||||
import type { ThemeMode } from '@automaker/types';
|
||||
|
||||
describe('rc-file-manager.ts', () => {
|
||||
let tempDir: string;
|
||||
let projectPath: string;
|
||||
|
||||
const TEMP_DIR_PREFIX = 'platform-rc-files-test-';
|
||||
const PROJECT_DIR_NAME = 'test-project';
|
||||
const THEME_DARK = 'dark' as ThemeMode;
|
||||
const THEME_LIGHT = 'light' as ThemeMode;
|
||||
const PROMPT_FORMAT_STANDARD: TerminalConfig['promptFormat'] = 'standard';
|
||||
const PROMPT_FORMAT_MINIMAL: TerminalConfig['promptFormat'] = 'minimal';
|
||||
const EMPTY_ALIASES = '';
|
||||
const PATH_STYLE_FULL: TerminalConfig['pathStyle'] = 'full';
|
||||
const PATH_DEPTH_DEFAULT = 0;
|
||||
|
||||
const baseConfig: TerminalConfig = {
|
||||
enabled: true,
|
||||
customPrompt: true,
|
||||
promptFormat: PROMPT_FORMAT_STANDARD,
|
||||
showGitBranch: true,
|
||||
showGitStatus: true,
|
||||
showUserHost: true,
|
||||
showPath: true,
|
||||
pathStyle: PATH_STYLE_FULL,
|
||||
pathDepth: PATH_DEPTH_DEFAULT,
|
||||
showTime: false,
|
||||
showExitStatus: false,
|
||||
customAliases: EMPTY_ALIASES,
|
||||
customEnvVars: {},
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), TEMP_DIR_PREFIX));
|
||||
projectPath = path.join(tempDir, PROJECT_DIR_NAME);
|
||||
await fs.mkdir(projectPath, { recursive: true });
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
try {
|
||||
await fs.rm(tempDir, { recursive: true, force: true });
|
||||
} catch {
|
||||
// Ignore cleanup errors
|
||||
}
|
||||
});
|
||||
|
||||
it('should not regenerate when signature matches', async () => {
|
||||
await writeRcFiles(
|
||||
projectPath,
|
||||
THEME_DARK,
|
||||
baseConfig,
|
||||
terminalThemeColors[THEME_DARK],
|
||||
terminalThemeColors
|
||||
);
|
||||
|
||||
const needsRegen = await needsRegeneration(projectPath, THEME_DARK, baseConfig);
|
||||
|
||||
expect(needsRegen).toBe(false);
|
||||
});
|
||||
|
||||
it('should regenerate when config changes', async () => {
|
||||
await writeRcFiles(
|
||||
projectPath,
|
||||
THEME_DARK,
|
||||
baseConfig,
|
||||
terminalThemeColors[THEME_DARK],
|
||||
terminalThemeColors
|
||||
);
|
||||
|
||||
const updatedConfig: TerminalConfig = {
|
||||
...baseConfig,
|
||||
promptFormat: PROMPT_FORMAT_MINIMAL,
|
||||
};
|
||||
|
||||
const needsRegen = await needsRegeneration(projectPath, THEME_DARK, updatedConfig);
|
||||
|
||||
expect(needsRegen).toBe(true);
|
||||
});
|
||||
|
||||
it('should regenerate when theme changes', async () => {
|
||||
await writeRcFiles(
|
||||
projectPath,
|
||||
THEME_DARK,
|
||||
baseConfig,
|
||||
terminalThemeColors[THEME_DARK],
|
||||
terminalThemeColors
|
||||
);
|
||||
|
||||
const needsRegen = await needsRegeneration(projectPath, THEME_LIGHT, baseConfig);
|
||||
|
||||
expect(needsRegen).toBe(true);
|
||||
});
|
||||
});
|
||||
55
libs/platform/tests/rc-generator.test.ts
Normal file
55
libs/platform/tests/rc-generator.test.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { generateCommonFunctions, generateThemeColors } from '../src/rc-generator';
|
||||
import { terminalThemeColors } from '../src/terminal-theme-colors';
|
||||
import type { TerminalConfig } from '../src/rc-generator';
|
||||
import type { ThemeMode } from '@automaker/types';
|
||||
|
||||
describe('rc-generator.ts', () => {
|
||||
const THEME_DARK = 'dark' as ThemeMode;
|
||||
const PROMPT_FORMAT_STANDARD: TerminalConfig['promptFormat'] = 'standard';
|
||||
const EMPTY_ALIASES = '';
|
||||
const EMPTY_ENV_VARS = {};
|
||||
const PATH_STYLE_FULL: TerminalConfig['pathStyle'] = 'full';
|
||||
const PATH_DEPTH_DEFAULT = 0;
|
||||
const EXPECTED_BANNER_FUNCTION = 'automaker_show_banner_once';
|
||||
const RAW_COLOR_PREFIX = 'export COLOR_USER_RAW=';
|
||||
const RAW_COLOR_ESCAPE_START = '\\\\[';
|
||||
const RAW_COLOR_ESCAPE_END = '\\\\]';
|
||||
const STARTUP_PRIMARY_COLOR = '38;5;51m';
|
||||
const STARTUP_SECONDARY_COLOR = '38;5;39m';
|
||||
const STARTUP_ACCENT_COLOR = '38;5;33m';
|
||||
|
||||
const baseConfig: TerminalConfig = {
|
||||
enabled: true,
|
||||
customPrompt: true,
|
||||
promptFormat: PROMPT_FORMAT_STANDARD,
|
||||
showGitBranch: true,
|
||||
showGitStatus: true,
|
||||
showUserHost: true,
|
||||
showPath: true,
|
||||
pathStyle: PATH_STYLE_FULL,
|
||||
pathDepth: PATH_DEPTH_DEFAULT,
|
||||
showTime: false,
|
||||
showExitStatus: false,
|
||||
customAliases: EMPTY_ALIASES,
|
||||
customEnvVars: EMPTY_ENV_VARS,
|
||||
};
|
||||
|
||||
it('includes banner functions in common shell script', () => {
|
||||
const output = generateCommonFunctions(baseConfig);
|
||||
|
||||
expect(output).toContain(EXPECTED_BANNER_FUNCTION);
|
||||
expect(output).toContain(STARTUP_PRIMARY_COLOR);
|
||||
expect(output).toContain(STARTUP_SECONDARY_COLOR);
|
||||
expect(output).toContain(STARTUP_ACCENT_COLOR);
|
||||
});
|
||||
|
||||
it('exports raw banner colors without prompt escape wrappers', () => {
|
||||
const output = generateThemeColors(terminalThemeColors[THEME_DARK]);
|
||||
const rawLine = output.split('\n').find((line) => line.startsWith(RAW_COLOR_PREFIX));
|
||||
|
||||
expect(rawLine).toBeDefined();
|
||||
expect(rawLine).not.toContain(RAW_COLOR_ESCAPE_START);
|
||||
expect(rawLine).not.toContain(RAW_COLOR_ESCAPE_END);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user