@strapi/strapi
Version:
An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite
44 lines (41 loc) • 1.89 kB
JavaScript
import { exitWith } from '../../utils/helpers.mjs';
const EXPORT_DIR_REQUIRES_NO_ENCRYPT = 'Unpacked directory exports (--format dir) require --no-encrypt.';
const EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED = 'Unpacked directory exports (--format dir) do not support encryption. Use --format tar, or omit --encrypt.';
/**
* Directory exports require an explicit `--no-encrypt` (security). Compression is tar-only and is
* turned off automatically for `--format dir` (no `--no-compress` needed). Runs before
* `promptEncryptionKey` so missing `--no-encrypt` fails with a clear message instead of a key prompt.
*/ function prepareExportDirFormatCli(command) {
const opts = command.opts();
const format = opts.format ?? 'tar';
if (format !== 'dir') {
return;
}
const encrypt = command.getOptionValue('encrypt');
const encryptSource = command.getOptionValueSource('encrypt');
if (encrypt === true && encryptSource === 'cli') {
exitWith(1, EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED);
}
const explicitNoEncrypt = encrypt === false && (encryptSource === 'cli' || encryptSource === 'env');
if (!explicitNoEncrypt) {
exitWith(1, EXPORT_DIR_REQUIRES_NO_ENCRYPT);
}
command.setOptionValue('compress', false);
}
/**
* Same rules for programmatic `exportAction(opts)` (no Commander hooks).
*/ function normalizeExportDirFormatOpts(opts) {
const format = opts.format ?? 'tar';
if (format !== 'dir') {
return;
}
if (opts.encrypt === true) {
exitWith(1, EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED);
}
if (opts.encrypt !== false) {
exitWith(1, EXPORT_DIR_REQUIRES_NO_ENCRYPT);
}
opts.compress = false;
}
export { EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED, EXPORT_DIR_REQUIRES_NO_ENCRYPT, normalizeExportDirFormatOpts, prepareExportDirFormatCli };
//# sourceMappingURL=validate-dir-format.mjs.map