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 | import { AllSelectorsProcessor, AllSelectorsProcessorResults } from '../processors/index.js';
import { SLDS_CSS_PATH, SLDS_PLUS_CSS_PATH, SLDS_CLASSES_FILENAME, SLDS_PLUS_CLASSES_FILENAME, SLDS_DEPRECATED_CLASSES_FILENAME } from '../constants.js';
import { CSSParser } from '../parsers/css-parser.js';
import { writeData } from '../services/file-service.js';
import { SupportedFileFormat } from '../types.js';
export async function parseForSelectors(cssFilePath: string): Promise<AllSelectorsProcessorResults> {
const processor = new AllSelectorsProcessor();
const cssParser = await CSSParser.parseCSSFile(cssFilePath);
return cssParser.processSelectors(processor);
}
/**
* This function parses SLDS.css and SLDSPlus.css files from aura/slds-scs repo
* to generate:
* - list of selectors in slds
* - list of selectors in slds plus / cosmos
* - list of selector which were only available in slds and deprecated in slds plus / cosmos
* @param outputDir - Custom output directory for generated files. Defaults to current working directory
*/
export async function generateSelectorsList(outputDir: string = process.cwd(), format: SupportedFileFormat = 'json') {
try {
// Process both files in parallel
const [sldsSelectors, sldsPlusSelectors] = await Promise.all([
parseForSelectors(SLDS_CSS_PATH),
parseForSelectors(SLDS_PLUS_CSS_PATH),
]);
// difference between sldsSelectors and sldsPlusSelectors
const deprecatedClasses = sldsSelectors.filter(selector => {
return !sldsPlusSelectors.includes(selector);
});
// Write all files in parallel
await Promise.all([
writeData(SLDS_CLASSES_FILENAME, sldsSelectors, outputDir, format),
writeData(SLDS_PLUS_CLASSES_FILENAME, sldsPlusSelectors, outputDir, format),
writeData(SLDS_DEPRECATED_CLASSES_FILENAME, deprecatedClasses, outputDir, format)
]);
} catch (error) {
console.error('Error processing CSS files:', error);
throw error;
}
} |