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

1 lines 3.4 kB
{"version":3,"file":"validate-dir-format.mjs","sources":["../../../../../src/cli/commands/export/validate-dir-format.ts"],"sourcesContent":["import type { Command } from 'commander';\n\nimport { exitWith } from '../../utils/helpers';\n\nexport const EXPORT_DIR_REQUIRES_NO_ENCRYPT =\n 'Unpacked directory exports (--format dir) require --no-encrypt.';\n\nexport const EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED =\n 'Unpacked directory exports (--format dir) do not support encryption. Use --format tar, or omit --encrypt.';\n\n/**\n * Directory exports require an explicit `--no-encrypt` (security). Compression is tar-only and is\n * turned off automatically for `--format dir` (no `--no-compress` needed). Runs before\n * `promptEncryptionKey` so missing `--no-encrypt` fails with a clear message instead of a key prompt.\n */\nexport function prepareExportDirFormatCli(command: Command) {\n const opts = command.opts();\n const format = opts.format ?? 'tar';\n if (format !== 'dir') {\n return;\n }\n\n const encrypt = command.getOptionValue('encrypt');\n const encryptSource = command.getOptionValueSource('encrypt');\n\n if (encrypt === true && encryptSource === 'cli') {\n exitWith(1, EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED);\n }\n\n const explicitNoEncrypt =\n encrypt === false && (encryptSource === 'cli' || encryptSource === 'env');\n\n if (!explicitNoEncrypt) {\n exitWith(1, EXPORT_DIR_REQUIRES_NO_ENCRYPT);\n }\n\n command.setOptionValue('compress', false);\n}\n\n/**\n * Same rules for programmatic `exportAction(opts)` (no Commander hooks).\n */\nexport function normalizeExportDirFormatOpts(opts: {\n format?: 'tar' | 'dir';\n encrypt?: boolean;\n compress?: boolean;\n}) {\n const format = opts.format ?? 'tar';\n if (format !== 'dir') {\n return;\n }\n\n if (opts.encrypt === true) {\n exitWith(1, EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED);\n }\n\n if (opts.encrypt !== false) {\n exitWith(1, EXPORT_DIR_REQUIRES_NO_ENCRYPT);\n }\n\n opts.compress = false;\n}\n"],"names":["EXPORT_DIR_REQUIRES_NO_ENCRYPT","EXPORT_DIR_ENCRYPTION_NOT_SUPPORTED","prepareExportDirFormatCli","command","opts","format","encrypt","getOptionValue","encryptSource","getOptionValueSource","exitWith","explicitNoEncrypt","setOptionValue","normalizeExportDirFormatOpts","compress"],"mappings":";;AAIO,MAAMA,iCACX;AAEK,MAAMC,sCACX;AAEF;;;;IAKO,SAASC,yBAAAA,CAA0BC,OAAgB,EAAA;IACxD,MAAMC,IAAAA,GAAOD,QAAQC,IAAI,EAAA;IACzB,MAAMC,MAAAA,GAASD,IAAAA,CAAKC,MAAM,IAAI,KAAA;AAC9B,IAAA,IAAIA,WAAW,KAAA,EAAO;AACpB,QAAA;AACF,IAAA;IAEA,MAAMC,OAAAA,GAAUH,OAAAA,CAAQI,cAAc,CAAC,SAAA,CAAA;IACvC,MAAMC,aAAAA,GAAgBL,OAAAA,CAAQM,oBAAoB,CAAC,SAAA,CAAA;IAEnD,IAAIH,OAAAA,KAAY,IAAA,IAAQE,aAAAA,KAAkB,KAAA,EAAO;AAC/CE,QAAAA,QAAAA,CAAS,CAAA,EAAGT,mCAAAA,CAAAA;AACd,IAAA;AAEA,IAAA,MAAMU,oBACJL,OAAAA,KAAY,KAAA,KAAUE,aAAAA,KAAkB,KAAA,IAASA,kBAAkB,KAAI,CAAA;AAEzE,IAAA,IAAI,CAACG,iBAAAA,EAAmB;AACtBD,QAAAA,QAAAA,CAAS,CAAA,EAAGV,8BAAAA,CAAAA;AACd,IAAA;IAEAG,OAAAA,CAAQS,cAAc,CAAC,UAAA,EAAY,KAAA,CAAA;AACrC;AAEA;;IAGO,SAASC,4BAAAA,CAA6BT,IAI5C,EAAA;IACC,MAAMC,MAAAA,GAASD,IAAAA,CAAKC,MAAM,IAAI,KAAA;AAC9B,IAAA,IAAIA,WAAW,KAAA,EAAO;AACpB,QAAA;AACF,IAAA;IAEA,IAAID,IAAAA,CAAKE,OAAO,KAAK,IAAA,EAAM;AACzBI,QAAAA,QAAAA,CAAS,CAAA,EAAGT,mCAAAA,CAAAA;AACd,IAAA;IAEA,IAAIG,IAAAA,CAAKE,OAAO,KAAK,KAAA,EAAO;AAC1BI,QAAAA,QAAAA,CAAS,CAAA,EAAGV,8BAAAA,CAAAA;AACd,IAAA;AAEAI,IAAAA,IAAAA,CAAKU,QAAQ,GAAG,KAAA;AAClB;;;;"}