UNPKG

@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

49 lines (45 loc) 2.08 kB
'use strict'; var helpers = require('../../utils/helpers.js'); 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') { helpers.exitWith(1, EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED); } const explicitNoEncrypt = encrypt === false && (encryptSource === 'cli' || encryptSource === 'env'); if (!explicitNoEncrypt) { helpers.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) { helpers.exitWith(1, EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED); } if (opts.encrypt !== false) { helpers.exitWith(1, EXPORT_DIR_REQUIRES_NO_ENCRYPT); } opts.compress = false; } exports.EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED = EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED; exports.EXPORT_DIR_REQUIRES_NO_ENCRYPT = EXPORT_DIR_REQUIRES_NO_ENCRYPT; exports.normalizeExportDirFormatOpts = normalizeExportDirFormatOpts; exports.prepareExportDirFormatCli = prepareExportDirFormatCli; //# sourceMappingURL=validate-dir-format.js.map