adpa-enterprise-framework-automation
Version:
Modular, standards-compliant Node.js/TypeScript automation framework for enterprise requirements, project, and data management. Provides CLI and API for BABOK v3, PMBOK 7th Edition, and DMBOK 2.0 (in progress). Production-ready Express.js API with TypeSpe
234 lines • 8.85 kB
JavaScript
/**
* Brand Guidelines System
*
* Provides centralized access to brand guidelines for consistent
* styling across all Adobe Creative Suite generated documents.
*/
import { promises as fs } from 'fs';
import path from 'path';
export class BrandGuidelinesManager {
guidelines = null;
guidelinesPath;
constructor(guidelinesPath) {
this.guidelinesPath = guidelinesPath || path.join(process.cwd(), 'assets', 'branding', 'brand-guidelines.json');
}
/**
* Load brand guidelines from JSON file
*/
async loadGuidelines() {
if (this.guidelines) {
return this.guidelines;
}
try {
const guidelinesContent = await fs.readFile(this.guidelinesPath, 'utf-8');
this.guidelines = JSON.parse(guidelinesContent);
return this.guidelines;
}
catch (error) {
console.error('Failed to load brand guidelines:', error);
throw new Error(`Failed to load brand guidelines from ${this.guidelinesPath}`);
}
}
/**
* Get complete brand guidelines
*/
async getGuidelines() {
return this.loadGuidelines();
}
/**
* Get color system
*/
async getColors() {
const guidelines = await this.loadGuidelines();
return guidelines.colors;
}
/**
* Get typography system
*/
async getTypography() {
const guidelines = await this.loadGuidelines();
return guidelines.typography;
}
/**
* Get document styles for specific template type
*/
async getTemplateStyles(templateType) {
const guidelines = await this.loadGuidelines();
return guidelines.templates[templateType];
}
/**
* Get visualization color palette
*/
async getVisualizationColors() {
const guidelines = await this.loadGuidelines();
return guidelines.visualizations.charts.colorPalette;
}
/**
* Get brand assets paths
*/
async getAssets() {
const guidelines = await this.loadGuidelines();
return guidelines.assets;
}
/**
* Generate CSS variables from brand guidelines
*/
async generateCSSVariables() {
const guidelines = await this.loadGuidelines();
const cssVariables = [];
// Add colors
cssVariables.push('/* Brand Colors */');
cssVariables.push(`--color-primary: ${guidelines.colors.primary};`);
cssVariables.push(`--color-primary-light: ${guidelines.colors.primaryLight};`);
cssVariables.push(`--color-primary-dark: ${guidelines.colors.primaryDark};`);
cssVariables.push(`--color-secondary: ${guidelines.colors.secondary};`);
cssVariables.push(`--color-accent: ${guidelines.colors.accent};`);
// Add neutral colors
cssVariables.push('/* Neutral Colors */');
Object.entries(guidelines.colors.neutral).forEach(([key, value]) => {
cssVariables.push(`--color-neutral-${key}: ${value};`);
});
// Add typography
cssVariables.push('/* Typography */');
cssVariables.push(`--font-heading: ${guidelines.typography.headings.fontFamily};`);
cssVariables.push(`--font-body: ${guidelines.typography.body.fontFamily};`);
cssVariables.push(`--font-mono: ${guidelines.typography.monospace.fontFamily};`);
// Add spacing
cssVariables.push('/* Spacing */');
Object.entries(guidelines.spacing).forEach(([key, value]) => {
cssVariables.push(`--spacing-${key}: ${value};`);
});
return `:root {\n ${cssVariables.join('\n ')}\n}`;
}
/**
* Generate Adobe Illustrator color swatches
*/
async generateIllustratorSwatches() {
const guidelines = await this.loadGuidelines();
return {
name: guidelines.brandName,
swatches: [
{ name: 'Primary', color: guidelines.colors.primary, type: 'CMYK' },
{ name: 'Secondary', color: guidelines.colors.secondary, type: 'CMYK' },
{ name: 'Accent', color: guidelines.colors.accent, type: 'CMYK' },
{ name: 'Success', color: guidelines.colors.semantic.success, type: 'CMYK' },
{ name: 'Warning', color: guidelines.colors.semantic.warning, type: 'CMYK' },
{ name: 'Error', color: guidelines.colors.semantic.error, type: 'CMYK' }
]
};
}
/**
* Generate InDesign paragraph styles
*/
async generateInDesignStyles() {
const guidelines = await this.loadGuidelines();
const styles = [];
// Header styles
Object.entries(guidelines.documentStyles.headers).forEach(([key, style]) => {
styles.push({
name: key.toUpperCase(),
fontFamily: guidelines.typography.headings.fontFamily,
fontSize: style.fontSize,
fontWeight: style.fontWeight,
color: style.color,
marginTop: style.marginTop,
marginBottom: style.marginBottom
});
});
// Body styles
styles.push({
name: 'Body Text',
fontFamily: guidelines.typography.body.fontFamily,
fontSize: guidelines.documentStyles.body.paragraph.fontSize,
lineHeight: guidelines.documentStyles.body.paragraph.lineHeight,
color: guidelines.documentStyles.body.paragraph.color
});
return { styles };
}
/**
* Validate brand compliance of colors
*/
async validateColorCompliance(colors) {
const guidelines = await this.loadGuidelines();
const approvedColors = [
guidelines.colors.primary,
guidelines.colors.primaryLight,
guidelines.colors.primaryDark,
guidelines.colors.secondary,
guidelines.colors.secondaryLight,
guidelines.colors.secondaryDark,
guidelines.colors.accent,
...Object.values(guidelines.colors.neutral),
...Object.values(guidelines.colors.semantic)
];
const issues = [];
const suggestions = [];
colors.forEach(color => {
if (!approvedColors.includes(color.toUpperCase())) {
issues.push(`Color ${color} is not in the approved brand palette`);
// Find closest approved color (simplified)
const closest = this.findClosestColor(color, approvedColors);
suggestions.push(`Consider using ${closest} instead of ${color}`);
}
});
return {
compliant: issues.length === 0,
issues,
suggestions
};
}
/**
* Get style properties for specific element type
*/
async getElementStyle(elementType, variant) {
const guidelines = await this.loadGuidelines();
const stylePath = variant ? `${elementType}.${variant}` : elementType;
const pathParts = stylePath.split('.');
let style = guidelines.documentStyles;
for (const part of pathParts) {
style = style[part];
if (!style) {
throw new Error(`Style not found: ${stylePath}`);
}
}
return style;
}
// Private helper methods
findClosestColor(targetColor, approvedColors) {
// Simplified color distance calculation
// In a real implementation, this would use proper color space calculations
return approvedColors[0]; // Return first approved color as fallback
}
/**
* Save updated guidelines back to file
*/
async saveGuidelines(guidelines) {
try {
const guidelinesJSON = JSON.stringify(guidelines, null, 2);
await fs.writeFile(this.guidelinesPath, guidelinesJSON, 'utf-8');
this.guidelines = guidelines; // Update cached copy
}
catch (error) {
console.error('Failed to save brand guidelines:', error);
throw new Error('Failed to save brand guidelines');
}
}
/**
* Create a custom brand variation
*/
async createBrandVariation(name, colorOverrides, typographyOverrides) {
const baseGuidelines = await this.loadGuidelines();
const variation = {
...baseGuidelines,
brandName: `${baseGuidelines.brandName} - ${name}`,
colors: { ...baseGuidelines.colors, ...colorOverrides },
typography: typographyOverrides
? { ...baseGuidelines.typography, ...typographyOverrides }
: baseGuidelines.typography
};
return variation;
}
}
// Export singleton instance
export const brandGuidelines = new BrandGuidelinesManager();
//# sourceMappingURL=brand-guidelines.js.map