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 _doDeploy = async (nextVersion: string, options: Options) => {
if (!checkFilesExist(paths.localBundlePath)) {
throw new FlexPluginError('Could not find build file. Did you run `npm run build` first?');
}
logger.info('Uploading your Flex plugin to Twilio Assets\n');
const pluginBaseUrl = paths.assetBaseUrlTemplate.replace('%PLUGIN_VERSION%', nextVersion);
const bundleUri = `${pluginBaseUrl}/bundle.js`;
const sourceMapUri = `${pluginBaseUrl}/bundle.js.map`;
const credentials = await getCredential();
const runtime = await getRuntime(credentials);
const pluginUrl = `https://${runtime.environment.domain_name}${bundleUri}`;
const configurationClient = new ConfigurationClient(credentials);
const buildClient = new BuildClient(credentials, runtime.service.sid);
const assetClient = new AssetClient(credentials, runtime.service.sid);
const deploymentClient = new DeploymentClient(credentials, runtime.service.sid, runtime.environment.sid);
// Check duplicate routes
export const _doList = async (visibilities: Visibility[], order: Order = 'asc') => {
logger.info('Fetching all available versions of plugin %s', paths.packageName);
const credentials = await getCredential();
const runtime = await getRuntime(credentials);
const regex = new RegExp(PLUGIN_REGEX_STR.replace('%PLUGIN_NAME%', paths.packageName));
const assets = runtime.build && runtime.build.asset_versions || [];
const versions = assets
.filter((a) => regex.test(a.path))
.filter((a) => visibilities.includes(a.visibility));
if (versions.length === 0) {
logger.newline();
logger.info('No versions of plugin %s have been deployed', paths.packageName);
logger.newline();
return process.exit(0);
export const _doList = async (visibilities: Visibility[], order: Order = 'asc') => {
logger.info('Fetching all available versions of plugin %s', paths.packageName);
const credentials = await getCredential();
const runtime = await getRuntime(credentials);
const regex = new RegExp(PLUGIN_REGEX_STR.replace('%PLUGIN_NAME%', paths.packageName));
const assets = runtime.build && runtime.build.asset_versions || [];
const versions = assets
.filter((a) => regex.test(a.path))
.filter((a) => visibilities.includes(a.visibility));
if (versions.length === 0) {
logger.newline();
logger.info('No versions of plugin %s have been deployed', paths.packageName);
logger.newline();
return process.exit(0);
}
pluginVersions(runtime.environment.domain_name, versions, order);
};
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(
`Remove ${nameColor(packageName)} from your ${nameColor('package.json')} file`,
);
preFlightByPass(skip);
logger.newline();
};
const clear = async () => {
logger.info('Clearing caches and stored credentials');
await progress('Removing stored credentials', async () => await clearCredentials());
logger.newline();
logger.info('✨ Successfully cleared all caches and stored credentials');
logger.newline();
};
export default (packageName: string) => {
const nameColor = logger.coloredStrings.name;
const flexUIName = nameColor('@twilio/flex-ui');
logger.newline();
logger.error('An expected package was not found.');
logger.newline();
logger.info(`Expected package ${nameColor(packageName)} was not found in ${flexUIName}.`);
logger.newline();
instructionToReinstall();
};
export default (...extras: string[]) => {
const nameColor = logger.coloredStrings.name;
const headline = logger.coloredStrings.headline;
logger.info(`Please follow these steps to possibly ${headline('fix')} this issue:`);
const lines = [
`Delete your ${nameColor('node_modules')} directory`,
`Delete ${nameColor('package-lock.json')} and/or ${nameColor('yarn.lock')}`,
...extras,
`Run ${nameColor('npm install')} or ${nameColor('yarn install')} again`,
];
printList(...lines);
};
const clear = async () => {
logger.info('Clearing caches and stored credentials');
await progress('Removing stored credentials', async () => await clearCredentials());
logger.newline();
logger.info('✨ Successfully cleared all caches and stored credentials');
logger.newline();
};
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(
`Remove ${nameColor(packageName)} from your ${nameColor('package.json')} file`,
);
preFlightByPass(skip);
logger.newline();
};
.forEach((detail) => {
logger.info(`\t ${headline(`"${detail.name}": "${detail.package.version}"`)}`);
});