generateSiteStoriesListings = (config) => {
	let additions = '';

	if (
		config.component &&
		config['site-stories'] &&
		config['site-stories'].length > 0
	) {
		additions = `\t${
			config.component.search(/-/g) >= 0
				? `'${config.component}'`
				: config.component
		}: [\n`;

		config['site-stories'].forEach((storyPath) => {
			additions += `\t\t{\n`;
			additions += `\t\t\theading: '${storyPath.heading}',\n`;
			additions += `\t\t\tpath: require('raw-loader!@salesforce/design-system-react/components/${config.component}${storyPath.path}'),\n`;
			additions += `\t\t},\n`;
		});

		additions += `\t],\n`;
	}

	siteStoriesFile += additions;
}
/component.json`
);
configFiles.forEach((filePath, index) => {
	const data = fs.readFileSync(filePath, 'utf8');
	if (data) {
		try {
			configFiles[index] = JSON.parse(data.toString());
		} catch (err) {
			throw new Error(err.message);
		}
	} else {
		throw new Error(
			`The configuration file at ${filePath} is missing or was not loaded correctly.`
		);
	}
});

// Read index file
let indexFile = fs.readFileSync(path.join(__dirname, '../components/index.js'));
if (indexFile) {
	try {
		indexFile = babel.parse(indexFile.toString(), babelOpts);
	} catch (err) {
		throw new Error(err.message);
	}

	// Removing leading comments as they will be added in final output
	if (
		indexFile &&
		indexFile.program &&
		indexFile.program.body[0] &&
		indexFile.program.body[0].leadingComments
	) {
		delete indexFile.program.body[0].leadingComments;
	}
} else {
	throw new Error(
		'The "../components/index.js" file is missing or was not loaded correctly'
	);
}
// A list of required index file entries. This will be filled up from config files and compared against what's already in the index file later.
const indexFileRequirements = {};

// Create initial site-stories string
let siteStoriesFile = `/* eslint-disable max-lines