mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
feat: Add workflow dashboard template and utility functions
- Implemented a new HTML template for the workflow dashboard, featuring a responsive design with dark/light theme support, session statistics, and task management UI. - Created a browser launcher utility to open HTML files in the default browser across platforms. - Developed file utility functions for safe reading and writing of JSON and text files. - Added path resolver utilities to validate and resolve file paths, ensuring security against path traversal attacks. - Introduced UI utilities for displaying styled messages and banners in the console.
This commit is contained in:
49
ccw/src/utils/browser-launcher.js
Normal file
49
ccw/src/utils/browser-launcher.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import open from 'open';
|
||||
import { platform } from 'os';
|
||||
import { resolve } from 'path';
|
||||
|
||||
/**
|
||||
* Launch a file in the default browser
|
||||
* Cross-platform compatible (Windows/macOS/Linux)
|
||||
* @param {string} filePath - Path to HTML file
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function launchBrowser(filePath) {
|
||||
const absolutePath = resolve(filePath);
|
||||
|
||||
// Construct file:// URL based on platform
|
||||
let url;
|
||||
if (platform() === 'win32') {
|
||||
// Windows: file:///C:/path/to/file.html
|
||||
url = `file:///${absolutePath.replace(/\\/g, '/')}`;
|
||||
} else {
|
||||
// Unix: file:///path/to/file.html
|
||||
url = `file://${absolutePath}`;
|
||||
}
|
||||
|
||||
try {
|
||||
// Use the 'open' package which handles cross-platform browser launching
|
||||
await open(url);
|
||||
} catch (error) {
|
||||
// Fallback: try opening the file path directly
|
||||
try {
|
||||
await open(absolutePath);
|
||||
} catch (fallbackError) {
|
||||
throw new Error(`Failed to open browser: ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're running in a headless/CI environment
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isHeadlessEnvironment() {
|
||||
return !!(
|
||||
process.env.CI ||
|
||||
process.env.CONTINUOUS_INTEGRATION ||
|
||||
process.env.GITHUB_ACTIONS ||
|
||||
process.env.GITLAB_CI ||
|
||||
process.env.JENKINS_URL
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user