@pega/custom-dx-components
Version:
Utility for building custom UI components
40 lines (30 loc) • 1.27 kB
JavaScript
import fs from 'fs';
import path from 'path';
import chalk from 'chalk';
import { showVersion, updateUseWebPackPromotion, getLibraryBased, addDebugLog } from '../../util.js';
import { WEBPACK_CONFIG_JS_FILENAME } from '../../constants.js';
export const renamePromotedWebPack = async () => {
addDebugLog("renamePromotedWebPack","", "");
const promoteWebPackDir = path.resolve(WEBPACK_CONFIG_JS_FILENAME);
const renamedPromoteWebPackDir = path.resolve(`${WEBPACK_CONFIG_JS_FILENAME}.notused`);
try {
fs.renameSync(promoteWebPackDir, renamedPromoteWebPackDir);
} catch (ex) {
console.log(chalk.bold.red(`File ${promoteWebPackDir} not found.`));
process.exit();
}
console.log(chalk.bold.green('Bundler reverted to using internal webpack.config.js.'));
console.log(chalk.bold.green(`File ${promoteWebPackDir} marked as not used.`));
};
export default async () => {
const isLibraryBased = getLibraryBased();
if (isLibraryBased) {
console.log(`Command only supported for ${chalk.bold.green('non library mode')} components.`);
process.exit();
}
await showVersion();
addDebugLog("revertWebPack","", "+");
await renamePromotedWebPack();
await updateUseWebPackPromotion(false);
addDebugLog("revertWebPack","END", "-");
};