Initial commit: Clean DSS implementation
Migrated from design-system-swarm with fresh git history.
Old project history preserved in /home/overbits/apps/design-system-swarm
Core components:
- MCP Server (Python FastAPI with mcp 1.23.1)
- Claude Plugin (agents, commands, skills, strategies, hooks, core)
- DSS Backend (dss-mvp1 - token translation, Figma sync)
- Admin UI (Node.js/React)
- Server (Node.js/Express)
- Storybook integration (dss-mvp1/.storybook)
Self-contained configuration:
- All paths relative or use DSS_BASE_PATH=/home/overbits/dss
- PYTHONPATH configured for dss-mvp1 and dss-claude-plugin
- .env file with all configuration
- Claude plugin uses ${CLAUDE_PLUGIN_ROOT} for portability
Migration completed: $(date)
🤖 Clean migration with full functionality preserved
This commit is contained in:
95
cli/src/lib/config.ts
Normal file
95
cli/src/lib/config.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* DSS Configuration Manager
|
||||
*
|
||||
* Manages local and project configuration.
|
||||
*/
|
||||
|
||||
import Conf from 'conf';
|
||||
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
// Global user config (stored in home directory)
|
||||
const globalConfig = new Conf({
|
||||
projectName: 'dss',
|
||||
schema: {
|
||||
figmaToken: { type: 'string' },
|
||||
defaultPort: { type: 'number', default: 3456 },
|
||||
defaultFormat: { type: 'string', default: 'css' },
|
||||
},
|
||||
});
|
||||
|
||||
// Project-level config file
|
||||
const PROJECT_CONFIG_FILE = '.dss/config.json';
|
||||
|
||||
export interface DSSConfig {
|
||||
figmaFileKey?: string;
|
||||
figmaToken?: string;
|
||||
port?: number;
|
||||
outputDir?: string;
|
||||
tokenFormat?: 'css' | 'scss' | 'json' | 'ts';
|
||||
componentFramework?: 'react' | 'vue' | 'svelte' | 'webcomponent';
|
||||
}
|
||||
|
||||
export function getProjectRoot(): string {
|
||||
return process.cwd();
|
||||
}
|
||||
|
||||
export function getProjectConfigPath(): string {
|
||||
return join(getProjectRoot(), PROJECT_CONFIG_FILE);
|
||||
}
|
||||
|
||||
export function hasProjectConfig(): boolean {
|
||||
return existsSync(getProjectConfigPath());
|
||||
}
|
||||
|
||||
export function loadProjectConfig(): DSSConfig {
|
||||
const configPath = getProjectConfigPath();
|
||||
if (!existsSync(configPath)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
try {
|
||||
const content = readFileSync(configPath, 'utf-8');
|
||||
return JSON.parse(content);
|
||||
} catch (error) {
|
||||
console.warn('Failed to parse project config:', error);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export function saveProjectConfig(config: DSSConfig): void {
|
||||
const configPath = getProjectConfigPath();
|
||||
const dir = join(getProjectRoot(), '.dss');
|
||||
|
||||
// Ensure .dss directory exists
|
||||
if (!existsSync(dir)) {
|
||||
const { mkdirSync } = require('fs');
|
||||
mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
|
||||
writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||
}
|
||||
|
||||
export function getConfig(): DSSConfig {
|
||||
const project = loadProjectConfig();
|
||||
return {
|
||||
figmaToken: project.figmaToken || globalConfig.get('figmaToken') as string | undefined,
|
||||
figmaFileKey: project.figmaFileKey,
|
||||
port: project.port || globalConfig.get('defaultPort') as number,
|
||||
outputDir: project.outputDir || '.dss/output',
|
||||
tokenFormat: project.tokenFormat || (globalConfig.get('defaultFormat') as DSSConfig['tokenFormat']),
|
||||
componentFramework: project.componentFramework || 'react',
|
||||
};
|
||||
}
|
||||
|
||||
export function setGlobalConfig(key: string, value: string | number): void {
|
||||
globalConfig.set(key, value);
|
||||
}
|
||||
|
||||
export function getGlobalConfig(key: string): unknown {
|
||||
return globalConfig.get(key);
|
||||
}
|
||||
|
||||
export function listGlobalConfig(): Record<string, unknown> {
|
||||
return globalConfig.store;
|
||||
}
|
||||
Reference in New Issue
Block a user