Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const start = async (...args: string[]) => {
logger.debug('Running dev-server');
// Finds the first available free port where two consecutive ports are free
const port = await findPorts();
process.env.PORT = port.toString();
// This script runs after React Script is finished running
process.env.BROWSER = join(__dirname, 'start', 'browser.js');
const exitCode = await craco('start', ...args);
exit(exitCode, args);
};
const build = async (...args: string[]) => {
logger.debug('Building Flex plugin bundle');
// This prints a hosting instruction specific to react applications
// We should replace it with instruction about Twilio Assets
// hijack('react-dev-utils/printHostingInstructions', () => {
// // to be filled
// });
const exitCode = await craco('build', ...args);
exit(exitCode, args);
};
const start = () => {
logger.debug('Running dev-server');
// This will overwrite React App from opening the browser and allows us to control the flow
process.env.BROWSER = join(__dirname, 'sub', 'browser.js');
require(resolve(cracoScriptPath));
};
const remove = async () => {
logger.debug('Removing Flex plugin');
const pluginName = logger.colors.blue(paths.packageName);
const question = `Are you sure you want to permanently remove plugin ${pluginName}?`;
const answer = await confirm(question, 'N');
if (!answer) {
return process.exit(0);
}
await _doRemove();
};
public upload = (url: string, formData: FormData): Promise => {
logger.debug('Uploading formData to %s', url);
logger.trace(formData);
return axios
.post(url, formData, {
headers: formData.getHeaders(),
auth: {
username: this.config.auth.accountSid,
password: this.config.auth.authToken,
},
})
.then((resp) => resp.data)
.catch(this.onError);
}
public get(uri: string): Promise {
logger.debug('Making GET request to %s/%s', this.config.baseURL, uri);
return this.client
.get(uri)
.then((resp) => resp.data || {});
}
const deploy = async (...argv: string[]) => {
logger.debug('Deploying Flex plugin');
const disallowVersioning = argv.includes('--disallow-versioning');
let nextVersion = argv[1] as string;
const bump = argv[0];
const opts = {
isPublic: argv.includes('--public'),
overwrite: argv.includes('--overwrite') || disallowVersioning,
disallowVersioning,
};
if (!disallowVersioning) {
if (!allowedBumps.includes(bump)) {
throw new FlexPluginError(`Version bump can only be one of ${allowedBumps.join(', ')}`);
}
if (bump === 'custom' && !argv[1]) {
const checkStart = async () => {
logger.debug('Checking Flex plugin project directory');
const allowSkip = process.env.SKIP_PREFLIGHT_CHECK === 'true';
_checkAppConfig();
_checkCracoConfig();
_checkPublicDirSync(allowSkip);
_checkExternalDepsVersions(allowSkip);
};
public post(uri: string, data: any): Promise {
logger.debug('Making POST request to %s/%s with data %s', this.config.baseURL, uri, JSON.stringify(data));
if (!this.jsonPOST) {
data = stringify(data);
}
return this.client
.post(uri, data)
.then((resp) => resp.data);
}
public delete(uri: string): Promise {
logger.debug('Making DELETE request to %s/%s', this.config.baseURL, uri);
return this.client
.delete(uri);
}