Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const createFlexPlugin = async (config: FlexPluginArguments) => {
config = await validate(config);
config = setupConfiguration(config);
// Check folder does not exist
if (fs.existsSync(config.targetDirectory)) {
throw new FlexPluginError(singleLineString(
`Path ${logger.coloredStrings.link(config.targetDirectory)} already exists;`,
'please remove it and try again.',
));
}
// Setup the directories
if (!await _scaffold(config)) {
throw new FlexPluginError('Failed to scaffold project');
}
// Install NPM dependencies
if (config.install) {
if (!await _install(config)) {
logger.error('Failed to install dependencies. Please run `npm install` manually.');
config.install = false;
}
export default (packageName: string, installedVersion: string, requiredVersion: string, skip: boolean) => {
const nameColor = logger.coloredStrings.name;
const headline = logger.coloredStrings.headline;
const red = logger.colors.red;
const flexUIName = nameColor('@twilio/flex-ui');
const scriptName = nameColor('flex-plugin-scripts');
logger.newline();
logger.error(singleLineString(
'There might be a problem with your project dependency tree.',
));
logger.newline();
logger.info(`The ${flexUIName} requires the following package:`);
logger.newline();
logger.info(`\t ${headline(`"${packageName}": "${requiredVersion}"`)}`);
logger.newline();
const versionPrint = red(installedVersion);
logger.info(`However, a different version of this package was detected: ${versionPrint}.`);
logger.info(`Do not try to install this manually; ${scriptName} manages that for you.`);
logger.info('Managing this package yourself is known to cause issues in production environments.');
logger.newline();
instructionToReinstall(
export default (url: string, isPublic: boolean, account: Account) => {
const availability = isPublic ? 'publicly' : 'privately';
const nameLogger = logger.coloredStrings.name;
logger.newline();
logger.success(singleLineString(
'🚀 Your plugin has been successfully deployed to your Flex project',
`${nameLogger(account.friendly_name)} (${nameLogger(account.sid)}).`,
`It is hosted (${availability}) as a Twilio Asset on ${logger.coloredStrings.link(url)}.`,
));
logger.newline();
};