Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | /**
* Manifest generation and management
*
* RFC Terminology:
* foundation - Base component definitions (copied as-is)
* system - Design system layer (extends from foundation, resolved/merged)
*/
import fs from 'fs-extra';
/**
* Generate manifest of all successfully processed UIFs
* @param {Array} foundationResults - Results from foundation layer processing
* @param {Array} sldsResults - Results from SLDS system layer processing
* @param {string} manifestPath - Path to write manifest file
* @returns {object} Generated manifest object
*/
export function generateManifest(foundationResults, sldsResults, manifestPath) {
const now = new Date().toISOString();
const manifest = {
uifManifest: '1.0.0',
generatedAt: now,
system: 'slds2',
foundations: {},
systems: {},
};
// Add foundations
foundationResults
.filter((result) => result.success)
.forEach((result) => {
manifest.foundations[result.componentName] = {
source: result.inputPath,
output: result.outputPath,
};
});
// Add SLDS system layer UIFs
sldsResults
.filter((result) => result.success)
.forEach((result) => {
manifest.systems[result.componentName] = {
source: result.inputPath,
output: result.outputPath,
resolvedAt: now,
};
});
const parentDir = manifestPath.split('/').slice(0, -1).join('/');
fs.ensureDirSync(parentDir);
fs.writeJsonSync(manifestPath, manifest, { spaces: 2 });
return manifest;
}
/**
* Update manifest for a single component (incremental update for watch mode)
* @param {object} result - Build result from buildSingleUif
* @param {string} manifestPath - Path to manifest file
* @param {object} log - Logger instance
*/
Iexport function updateManifestForComponent(result, manifestPath, log) {
if (!result.success) return;
// Read existing manifest or create new one
let manifest;
if (fs.existsSync(manifestPath)) {
manifest = fs.readJsonSync(manifestPath);
} else {
manifest = {
uifManifest: '1.0.0',
generatedAt: new Date().toISOString(),
system: 'slds2',
foundations: {},
systems: {},
};
}
const now = new Date().toISOString();
// Update the specific component entry
if (result.type === 'foundation') {
manifest.foundations[result.componentName] = {
source: result.inputPath,
output: result.outputPath,
};
} else if (result.type === 'system') {
manifest.systems[result.componentName] = {
source: result.inputPath,
output: result.outputPath,
resolvedAt: now,
};
}
// Update manifest timestamp
manifest.generatedAt = now;
fs.writeJsonSync(manifestPath, manifest, { spaces: 2 });
log.detail(`Updated manifest for ${result.componentName}`);
}
/**
* Remove component from manifest (for watch mode file deletion)
* @param {string} componentName - Name of component to remove
* @param {string} manifestPath - Path to manifest file
* @param {object} log - Logger instance
*/
export function removeFromManifest(componentName, manifestPath, log) {
if (!fs.existsSync(manifestPath)) return;
const manifest = fs.readJsonSync(manifestPath);
delete manifest.foundations[componentName];
delete manifest.systems[componentName];
manifest.generatedAt = new Date().toISOString();
fs.writeJsonSync(manifestPath, manifest, { spaces: 2 });
log.success(`Removed ${componentName} from manifest`);
}
|