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 _rebasePlugins = (remotePlugins: Plugin[]) => {
const pkg = readPackageJson();
return _getLocalPlugins()
.map((plugin) => {
// Local main (plugin) we are running
if (plugin.name === pkg.name) {
return plugin;
}
// Plugin is disabled - do not load it
if (!plugin.enabled) {
return null;
}
// Load remote plugin from Flex
if (plugin.remote === true) {
return remotePlugins.find((p) => p.name === plugin.name);
import { logger } from 'flex-dev-utils';
import { FlexPluginError } from 'flex-dev-utils/dist/errors';
import { join } from 'path';
import { readPackageJson } from 'flex-dev-utils/dist/fs';
const packageJson = readPackageJson();
const packageName = packageJson.name;
const buildDir = join(process.cwd(), 'build');
const assetBaseUrl = `/plugins/${packageName}/%PLUGIN_VERSION%`;
if (packageName.substr(0, 6) !== 'plugin') {
throw new FlexPluginError(`Package name "${packageName}" does not start with "plugin"`);
}
export default {
buildDir,
packageName,
version: packageJson.version,
localBundlePath: `${join(buildDir, packageName)}.js`,
localSourceMapPath: `${join(buildDir, packageName)}.js.map`,
appConfig: join(process.cwd(), 'public', 'appConfig.js'),
assetBaseUrlTemplate: assetBaseUrl,
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]) {
throw new FlexPluginError('Custom version bump requires the version value.');
}
if (bump === 'overwrite') {
opts.overwrite = true;
nextVersion = readPackageJson().version;
} else if (bump !== 'custom') {
nextVersion = semver.inc(paths.version, bump as ReleaseType) as any;
}
} else {
nextVersion = '0.0.0';
}
await _doDeploy(nextVersion, opts);
};