mirror of
https://github.com/ivuorinen/everforest-resources.git
synced 2026-01-26 03:04:02 +00:00
feat: initial scaffold and generator
- Complete project structure with directories for all target platforms - Template system for CLI tools with color placeholder replacement - Working generator that processes templates for 6 theme variants - GitHub workflows for build, snapshots, commitlint, and cli-verify - Installer and verifier scripts for CLI tool deployment - Comprehensive documentation and specifications - Biome 2.x linting and formatting setup - Husky git hooks for pre-commit validation
This commit is contained in:
186
scripts/generate-themes.mjs
Normal file
186
scripts/generate-themes.mjs
Normal file
@@ -0,0 +1,186 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Everforest Resources Theme Generator
|
||||
*
|
||||
* Generates all theme files from canonical palette definitions.
|
||||
* Uses template system with color placeholders for CLI tools.
|
||||
*
|
||||
* Architecture:
|
||||
* - Loads palettes from palettes/everforest.(json|yaml)
|
||||
* - Processes template.txt files with color placeholders
|
||||
* - Generates all 6 variants (dark/light × hard/medium/soft)
|
||||
* - Outputs to appropriate directories
|
||||
*/
|
||||
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const rootDir = path.resolve(__dirname, '..');
|
||||
|
||||
/**
|
||||
* Color placeholders used in templates:
|
||||
* {{bg}}, {{fg}}, {{red}}, {{orange}}, {{yellow}},
|
||||
* {{green}}, {{aqua}}, {{blue}}, {{purple}},
|
||||
* {{gray1}}, {{gray2}}, {{gray3}}
|
||||
*/
|
||||
|
||||
class EverforestGenerator {
|
||||
constructor() {
|
||||
this.palette = null;
|
||||
}
|
||||
|
||||
async loadPalette() {
|
||||
try {
|
||||
const paletteJson = await fs.readFile(
|
||||
path.join(rootDir, 'palettes/everforest.json'),
|
||||
'utf-8'
|
||||
);
|
||||
this.palette = JSON.parse(paletteJson);
|
||||
console.log('✅ Loaded palette from everforest.json');
|
||||
} catch (error) {
|
||||
console.error('❌ Failed to load palette:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
async processTemplate(templatePath, variant, contrast) {
|
||||
try {
|
||||
const template = await fs.readFile(templatePath, 'utf-8');
|
||||
const colors = this.getColorsForVariant(variant, contrast);
|
||||
|
||||
let processed = template;
|
||||
Object.entries(colors).forEach(([key, value]) => {
|
||||
const placeholder = new RegExp(`{{${key}}}`, 'g');
|
||||
processed = processed.replace(placeholder, value);
|
||||
});
|
||||
|
||||
return processed;
|
||||
} catch (error) {
|
||||
console.error(`❌ Failed to process template ${templatePath}:`, error.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
getColorsForVariant(variant, contrast) {
|
||||
const variantColors = this.palette.variants[variant][contrast];
|
||||
const accentColors = this.palette.accents;
|
||||
const grayColors = this.palette.grays[variant];
|
||||
|
||||
return {
|
||||
bg: variantColors.bg,
|
||||
bg1: variantColors.bg1,
|
||||
bg2: variantColors.bg2,
|
||||
fg: variantColors.fg,
|
||||
red: accentColors.red,
|
||||
orange: accentColors.orange,
|
||||
yellow: accentColors.yellow,
|
||||
green: accentColors.green,
|
||||
aqua: accentColors.aqua,
|
||||
blue: accentColors.blue,
|
||||
purple: accentColors.purple,
|
||||
gray1: grayColors.gray1,
|
||||
gray2: grayColors.gray2,
|
||||
gray3: grayColors.gray3,
|
||||
};
|
||||
}
|
||||
|
||||
async generateAll() {
|
||||
console.log('🎨 Starting Everforest theme generation...');
|
||||
|
||||
if (!this.palette) {
|
||||
await this.loadPalette();
|
||||
}
|
||||
|
||||
// Generate for all variants
|
||||
const variants = ['dark', 'light'];
|
||||
const contrasts = ['hard', 'medium', 'soft'];
|
||||
|
||||
for (const variant of variants) {
|
||||
for (const contrast of contrasts) {
|
||||
console.log(`📝 Generating ${variant}-${contrast} variant...`);
|
||||
await this.generateVariant(variant, contrast);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('✨ Theme generation complete!');
|
||||
}
|
||||
|
||||
async generateVariant(variant, contrast) {
|
||||
console.log(` - Processing ${variant}-${contrast} templates...`);
|
||||
|
||||
// Process CLI tool templates
|
||||
await this.processCLITools(variant, contrast);
|
||||
}
|
||||
|
||||
async processCLITools(variant, contrast) {
|
||||
const cliTools = [
|
||||
{ name: 'starship', template: 'template.txt', output: 'starship.toml' },
|
||||
{ name: 'fzf', template: 'template.txt', output: 'everforest.sh' },
|
||||
{ name: 'delta', template: 'template.txt', output: 'gitconfig.delta' },
|
||||
{ name: 'tmux', template: 'template.txt', output: 'everforest.tmux.conf' },
|
||||
{ name: 'ls_colors', template: 'template.txt', output: 'everforest.sh' },
|
||||
];
|
||||
|
||||
for (const tool of cliTools) {
|
||||
await this.processToolTemplate(tool, variant, contrast);
|
||||
}
|
||||
|
||||
// Process fish with multiple templates and outputs
|
||||
await this.processFishTemplates(variant, contrast);
|
||||
}
|
||||
|
||||
async processToolTemplate(tool, variant, contrast) {
|
||||
const templatePath = path.join(rootDir, 'cli', tool.name, tool.template);
|
||||
const outputPath = path.join(rootDir, 'cli', tool.name, tool.output);
|
||||
|
||||
try {
|
||||
if (await this.fileExists(templatePath)) {
|
||||
const processed = await this.processTemplate(templatePath, variant, contrast);
|
||||
if (processed) {
|
||||
await fs.writeFile(outputPath, processed);
|
||||
console.log(` ✅ Generated ${tool.name}/${tool.output}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(` ❌ Failed to process ${tool.name}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async processFishTemplates(variant, contrast) {
|
||||
const fishPath = path.join(rootDir, 'cli', 'fish');
|
||||
const colorsTemplate = path.join(fishPath, 'colors-template.txt');
|
||||
const outputFile = `everforest-${variant}-${contrast}.fish`;
|
||||
const outputPath = path.join(fishPath, outputFile);
|
||||
|
||||
try {
|
||||
if (await this.fileExists(colorsTemplate)) {
|
||||
const processed = await this.processTemplate(colorsTemplate, variant, contrast);
|
||||
if (processed) {
|
||||
await fs.writeFile(outputPath, processed);
|
||||
console.log(` ✅ Generated fish/${outputFile}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(` ❌ Failed to process fish colors: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async fileExists(filePath) {
|
||||
try {
|
||||
await fs.access(filePath);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Main execution
|
||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
const generator = new EverforestGenerator();
|
||||
await generator.generateAll();
|
||||
}
|
||||
119
scripts/validate.mjs
Normal file
119
scripts/validate.mjs
Normal file
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Everforest Resources Validation Script
|
||||
*
|
||||
* Validates that all generated files are consistent and follow the spec.
|
||||
* Ensures no raw hex values in CLI configs (ANSI only).
|
||||
* Validates that all required variants are present.
|
||||
*/
|
||||
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const rootDir = path.resolve(__dirname, '..');
|
||||
|
||||
class EverforestValidator {
|
||||
constructor() {
|
||||
this.errors = [];
|
||||
this.warnings = [];
|
||||
}
|
||||
|
||||
async validate() {
|
||||
console.log('🔍 Starting Everforest validation...');
|
||||
|
||||
await this.validatePalette();
|
||||
await this.validateFileStructure();
|
||||
await this.validateNoRawHex();
|
||||
await this.validateVariants();
|
||||
|
||||
this.reportResults();
|
||||
}
|
||||
|
||||
async validatePalette() {
|
||||
try {
|
||||
const paletteData = await fs.readFile(
|
||||
path.join(rootDir, 'palettes/everforest.json'),
|
||||
'utf-8'
|
||||
);
|
||||
const palette = JSON.parse(paletteData);
|
||||
|
||||
// Validate structure
|
||||
if (!palette.variants || !palette.accents || !palette.grays) {
|
||||
this.errors.push('Palette missing required sections: variants, accents, grays');
|
||||
}
|
||||
|
||||
console.log('✅ Palette structure valid');
|
||||
} catch (error) {
|
||||
this.errors.push(`Palette validation failed: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async validateFileStructure() {
|
||||
// Validate that required directories exist
|
||||
const requiredDirs = [
|
||||
'palettes',
|
||||
'scripts',
|
||||
'terminals',
|
||||
'cli',
|
||||
'editors',
|
||||
'web',
|
||||
'docs',
|
||||
'verify',
|
||||
];
|
||||
|
||||
for (const dir of requiredDirs) {
|
||||
try {
|
||||
await fs.access(path.join(rootDir, dir));
|
||||
console.log(`✅ Directory ${dir} exists`);
|
||||
} catch (_error) {
|
||||
this.warnings.push(`Directory ${dir} missing - will be created during generation`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async validateNoRawHex() {
|
||||
// This will be implemented to scan CLI configs for raw hex values
|
||||
console.log('🔍 Checking for raw hex values in CLI configs...');
|
||||
// Placeholder - will scan generated CLI files for hex patterns
|
||||
}
|
||||
|
||||
async validateVariants() {
|
||||
// Validate that all 6 variants are present for each tool
|
||||
const _variants = ['dark', 'light'];
|
||||
const _contrasts = ['hard', 'medium', 'soft'];
|
||||
|
||||
console.log('🔍 Validating theme variants...');
|
||||
// Placeholder - will check that all variants exist
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
console.log('\n📊 Validation Results:');
|
||||
|
||||
if (this.errors.length > 0) {
|
||||
console.log('\n❌ Errors:');
|
||||
this.errors.forEach(error => console.log(` - ${error}`));
|
||||
}
|
||||
|
||||
if (this.warnings.length > 0) {
|
||||
console.log('\n⚠️ Warnings:');
|
||||
this.warnings.forEach(warning => console.log(` - ${warning}`));
|
||||
}
|
||||
|
||||
if (this.errors.length === 0) {
|
||||
console.log('\n✅ Validation passed!');
|
||||
} else {
|
||||
console.log('\n❌ Validation failed!');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Main execution
|
||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
const validator = new EverforestValidator();
|
||||
await validator.validate();
|
||||
}
|
||||
Reference in New Issue
Block a user