@strapi/strapi 5.12.0 → 5.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +89 -45
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +90 -42
- package/dist/cli.mjs.map +1 -1
- package/dist/package.json.js +6 -0
- package/dist/package.json.js.map +1 -0
- package/dist/package.json.mjs +4 -0
- package/dist/package.json.mjs.map +1 -0
- package/dist/src/cli/commands/admin/create-user.js +124 -0
- package/dist/src/cli/commands/admin/create-user.js.map +1 -0
- package/dist/src/cli/commands/admin/create-user.mjs +121 -0
- package/dist/src/cli/commands/admin/create-user.mjs.map +1 -0
- package/dist/src/cli/commands/admin/reset-user-password.js +61 -0
- package/dist/src/cli/commands/admin/reset-user-password.js.map +1 -0
- package/dist/src/cli/commands/admin/reset-user-password.mjs +58 -0
- package/dist/src/cli/commands/admin/reset-user-password.mjs.map +1 -0
- package/dist/src/cli/commands/build.js +29 -0
- package/dist/src/cli/commands/build.js.map +1 -0
- package/dist/src/cli/commands/build.mjs +27 -0
- package/dist/src/cli/commands/build.mjs.map +1 -0
- package/dist/src/cli/commands/components/list.js +32 -0
- package/dist/src/cli/commands/components/list.js.map +1 -0
- package/dist/src/cli/commands/components/list.mjs +29 -0
- package/dist/src/cli/commands/components/list.mjs.map +1 -0
- package/dist/src/cli/commands/configuration/dump.js +53 -0
- package/dist/src/cli/commands/configuration/dump.js.map +1 -0
- package/dist/src/cli/commands/configuration/dump.mjs +50 -0
- package/dist/src/cli/commands/configuration/dump.mjs.map +1 -0
- package/dist/src/cli/commands/configuration/restore.js +173 -0
- package/dist/src/cli/commands/configuration/restore.js.map +1 -0
- package/dist/src/cli/commands/configuration/restore.mjs +170 -0
- package/dist/src/cli/commands/configuration/restore.mjs.map +1 -0
- package/dist/src/cli/commands/console.js +31 -0
- package/dist/src/cli/commands/console.js.map +1 -0
- package/dist/src/cli/commands/console.mjs +28 -0
- package/dist/src/cli/commands/console.mjs.map +1 -0
- package/dist/src/cli/commands/content-types/list.js +32 -0
- package/dist/src/cli/commands/content-types/list.js.map +1 -0
- package/dist/src/cli/commands/content-types/list.mjs +29 -0
- package/dist/src/cli/commands/content-types/list.mjs.map +1 -0
- package/dist/src/cli/commands/controllers/list.js +32 -0
- package/dist/src/cli/commands/controllers/list.js.map +1 -0
- package/dist/src/cli/commands/controllers/list.mjs +29 -0
- package/dist/src/cli/commands/controllers/list.mjs.map +1 -0
- package/dist/src/cli/commands/develop.js +32 -0
- package/dist/src/cli/commands/develop.js.map +1 -0
- package/dist/src/cli/commands/develop.mjs +30 -0
- package/dist/src/cli/commands/develop.mjs.map +1 -0
- package/dist/src/cli/commands/export/action.js +126 -0
- package/dist/src/cli/commands/export/action.js.map +1 -0
- package/dist/src/cli/commands/export/action.mjs +124 -0
- package/dist/src/cli/commands/export/action.mjs.map +1 -0
- package/dist/src/cli/commands/export/command.js +15 -0
- package/dist/src/cli/commands/export/command.js.map +1 -0
- package/dist/src/cli/commands/export/command.mjs +13 -0
- package/dist/src/cli/commands/export/command.mjs.map +1 -0
- package/dist/src/cli/commands/generate.js +18 -0
- package/dist/src/cli/commands/generate.js.map +1 -0
- package/dist/src/cli/commands/generate.mjs +16 -0
- package/dist/src/cli/commands/generate.mjs.map +1 -0
- package/dist/src/cli/commands/hooks/list.js +32 -0
- package/dist/src/cli/commands/hooks/list.js.map +1 -0
- package/dist/src/cli/commands/hooks/list.mjs +29 -0
- package/dist/src/cli/commands/hooks/list.mjs.map +1 -0
- package/dist/src/cli/commands/import/action.js +124 -0
- package/dist/src/cli/commands/import/action.js.map +1 -0
- package/dist/src/cli/commands/import/action.mjs +122 -0
- package/dist/src/cli/commands/import/action.mjs.map +1 -0
- package/dist/src/cli/commands/import/command.js +59 -0
- package/dist/src/cli/commands/import/command.js.map +1 -0
- package/dist/src/cli/commands/import/command.mjs +57 -0
- package/dist/src/cli/commands/import/command.mjs.map +1 -0
- package/dist/src/cli/commands/index.js +64 -0
- package/dist/src/cli/commands/index.js.map +1 -0
- package/dist/src/cli/commands/index.mjs +62 -0
- package/dist/src/cli/commands/index.mjs.map +1 -0
- package/dist/src/cli/commands/middlewares/list.js +32 -0
- package/dist/src/cli/commands/middlewares/list.js.map +1 -0
- package/dist/src/cli/commands/middlewares/list.mjs +29 -0
- package/dist/src/cli/commands/middlewares/list.mjs.map +1 -0
- package/dist/src/cli/commands/policies/list.js +32 -0
- package/dist/src/cli/commands/policies/list.js.map +1 -0
- package/dist/src/cli/commands/policies/list.mjs +29 -0
- package/dist/src/cli/commands/policies/list.mjs.map +1 -0
- package/dist/src/cli/commands/report.js +39 -0
- package/dist/src/cli/commands/report.js.map +1 -0
- package/dist/src/cli/commands/report.mjs +37 -0
- package/dist/src/cli/commands/report.mjs.map +1 -0
- package/dist/src/cli/commands/routes/list.js +40 -0
- package/dist/src/cli/commands/routes/list.js.map +1 -0
- package/dist/src/cli/commands/routes/list.mjs +37 -0
- package/dist/src/cli/commands/routes/list.mjs.map +1 -0
- package/dist/src/cli/commands/services/list.js +32 -0
- package/dist/src/cli/commands/services/list.js.map +1 -0
- package/dist/src/cli/commands/services/list.mjs +29 -0
- package/dist/src/cli/commands/services/list.mjs.map +1 -0
- package/dist/src/cli/commands/start.js +28 -0
- package/dist/src/cli/commands/start.js.map +1 -0
- package/dist/src/cli/commands/start.mjs +26 -0
- package/dist/src/cli/commands/start.mjs.map +1 -0
- package/dist/src/cli/commands/telemetry/disable.js +72 -0
- package/dist/src/cli/commands/telemetry/disable.js.map +1 -0
- package/dist/src/cli/commands/telemetry/disable.mjs +69 -0
- package/dist/src/cli/commands/telemetry/disable.mjs.map +1 -0
- package/dist/src/cli/commands/telemetry/enable.js +88 -0
- package/dist/src/cli/commands/telemetry/enable.js.map +1 -0
- package/dist/src/cli/commands/telemetry/enable.mjs +85 -0
- package/dist/src/cli/commands/telemetry/enable.mjs.map +1 -0
- package/dist/src/cli/commands/templates/generate.js +15 -0
- package/dist/src/cli/commands/templates/generate.js.map +1 -0
- package/dist/src/cli/commands/templates/generate.mjs +13 -0
- package/dist/src/cli/commands/templates/generate.mjs.map +1 -0
- package/dist/src/cli/commands/transfer/action.js +141 -0
- package/dist/src/cli/commands/transfer/action.js.map +1 -0
- package/dist/src/cli/commands/transfer/action.mjs +139 -0
- package/dist/src/cli/commands/transfer/action.mjs.map +1 -0
- package/dist/src/cli/commands/transfer/command.js +61 -0
- package/dist/src/cli/commands/transfer/command.js.map +1 -0
- package/dist/src/cli/commands/transfer/command.mjs +59 -0
- package/dist/src/cli/commands/transfer/command.mjs.map +1 -0
- package/dist/src/cli/commands/ts/generate-types.js +40 -0
- package/dist/src/cli/commands/ts/generate-types.js.map +1 -0
- package/dist/src/cli/commands/ts/generate-types.mjs +37 -0
- package/dist/src/cli/commands/ts/generate-types.mjs.map +1 -0
- package/dist/src/cli/commands/version.js +17 -0
- package/dist/src/cli/commands/version.js.map +1 -0
- package/dist/src/cli/commands/version.mjs +15 -0
- package/dist/src/cli/commands/version.mjs.map +1 -0
- package/dist/src/cli/utils/commander.js +125 -0
- package/dist/src/cli/utils/commander.js.map +1 -0
- package/dist/src/cli/utils/commander.mjs +116 -0
- package/dist/src/cli/utils/commander.mjs.map +1 -0
- package/dist/src/cli/utils/data-transfer.js +378 -0
- package/dist/src/cli/utils/data-transfer.js.map +1 -0
- package/dist/src/cli/utils/data-transfer.mjs +359 -0
- package/dist/src/cli/utils/data-transfer.mjs.map +1 -0
- package/dist/src/cli/utils/helpers.js +114 -0
- package/dist/src/cli/utils/helpers.js.map +1 -0
- package/dist/src/cli/utils/helpers.mjs +107 -0
- package/dist/src/cli/utils/helpers.mjs.map +1 -0
- package/dist/src/cli/utils/logger.js +125 -0
- package/dist/src/cli/utils/logger.js.map +1 -0
- package/dist/src/cli/utils/logger.mjs +104 -0
- package/dist/src/cli/utils/logger.mjs.map +1 -0
- package/dist/src/cli/utils/telemetry.js +27 -0
- package/dist/src/cli/utils/telemetry.js.map +1 -0
- package/dist/src/cli/utils/telemetry.mjs +25 -0
- package/dist/src/cli/utils/telemetry.mjs.map +1 -0
- package/dist/src/cli/utils/tsconfig.js +25 -0
- package/dist/src/cli/utils/tsconfig.js.map +1 -0
- package/dist/src/cli/utils/tsconfig.mjs +23 -0
- package/dist/src/cli/utils/tsconfig.mjs.map +1 -0
- package/dist/src/node/build.js +90 -0
- package/dist/src/node/build.js.map +1 -0
- package/dist/src/node/build.mjs +69 -0
- package/dist/src/node/build.mjs.map +1 -0
- package/dist/src/node/core/admin-customisations.js +27 -0
- package/dist/src/node/core/admin-customisations.js.map +1 -0
- package/dist/src/node/core/admin-customisations.mjs +25 -0
- package/dist/src/node/core/admin-customisations.mjs.map +1 -0
- package/dist/{chunks/aliases-B2TXon3T.js → src/node/core/aliases.js} +3 -42
- package/dist/src/node/core/aliases.js.map +1 -0
- package/dist/{chunks/aliases-BsT_zzr4.mjs → src/node/core/aliases.mjs} +4 -41
- package/dist/src/node/core/aliases.mjs.map +1 -0
- package/dist/src/node/core/config.js +18 -0
- package/dist/src/node/core/config.js.map +1 -0
- package/dist/src/node/core/config.mjs +16 -0
- package/dist/src/node/core/config.mjs.map +1 -0
- package/dist/src/node/core/dependencies.js +186 -0
- package/dist/src/node/core/dependencies.js.map +1 -0
- package/dist/src/node/core/dependencies.mjs +183 -0
- package/dist/src/node/core/dependencies.mjs.map +1 -0
- package/dist/src/node/core/env.js +32 -0
- package/dist/src/node/core/env.js.map +1 -0
- package/dist/src/node/core/env.mjs +29 -0
- package/dist/src/node/core/env.mjs.map +1 -0
- package/dist/src/node/core/errors.js +51 -0
- package/dist/src/node/core/errors.js.map +1 -0
- package/dist/src/node/core/errors.mjs +48 -0
- package/dist/src/node/core/errors.mjs.map +1 -0
- package/dist/src/node/core/files.js +68 -0
- package/dist/src/node/core/files.js.map +1 -0
- package/dist/src/node/core/files.mjs +63 -0
- package/dist/src/node/core/files.mjs.map +1 -0
- package/dist/src/node/core/managers.js +27 -0
- package/dist/src/node/core/managers.js.map +1 -0
- package/dist/src/node/core/managers.mjs +25 -0
- package/dist/src/node/core/managers.mjs.map +1 -0
- package/dist/src/node/core/monorepo.js +30 -0
- package/dist/src/node/core/monorepo.js.map +1 -0
- package/dist/src/node/core/monorepo.mjs +28 -0
- package/dist/src/node/core/monorepo.mjs.map +1 -0
- package/dist/src/node/core/plugins.js +140 -0
- package/dist/src/node/core/plugins.js.map +1 -0
- package/dist/src/node/core/plugins.mjs +137 -0
- package/dist/src/node/core/plugins.mjs.map +1 -0
- package/dist/src/node/core/timer.js +33 -0
- package/dist/src/node/core/timer.js.map +1 -0
- package/dist/src/node/core/timer.mjs +30 -0
- package/dist/src/node/core/timer.mjs.map +1 -0
- package/dist/src/node/create-build-context.js +111 -0
- package/dist/src/node/create-build-context.js.map +1 -0
- package/dist/src/node/create-build-context.mjs +109 -0
- package/dist/src/node/create-build-context.mjs.map +1 -0
- package/dist/src/node/develop.js +312 -0
- package/dist/src/node/develop.js.map +1 -0
- package/dist/src/node/develop.mjs +291 -0
- package/dist/src/node/develop.mjs.map +1 -0
- package/dist/src/node/staticFiles.js +81 -0
- package/dist/src/node/staticFiles.js.map +1 -0
- package/dist/src/node/staticFiles.mjs +78 -0
- package/dist/src/node/staticFiles.mjs.map +1 -0
- package/dist/src/node/vite/build.js +14 -0
- package/dist/src/node/vite/build.js.map +1 -0
- package/dist/src/node/vite/build.mjs +12 -0
- package/dist/src/node/vite/build.mjs.map +1 -0
- package/dist/{chunks/config-CsJ2EtSs.js → src/node/vite/config.js} +12 -50
- package/dist/src/node/vite/config.js.map +1 -0
- package/dist/{chunks/config-BqQdQJh_.mjs → src/node/vite/config.mjs} +6 -44
- package/dist/src/node/vite/config.mjs.map +1 -0
- package/dist/src/node/vite/plugins.js +46 -0
- package/dist/src/node/vite/plugins.js.map +1 -0
- package/dist/src/node/vite/plugins.mjs +44 -0
- package/dist/src/node/vite/plugins.mjs.map +1 -0
- package/dist/{chunks/watch-DzwyHBm4.js → src/node/vite/watch.js} +2 -45
- package/dist/src/node/vite/watch.js.map +1 -0
- package/dist/{chunks/watch-BDsNoG4h.mjs → src/node/vite/watch.mjs} +2 -45
- package/dist/src/node/vite/watch.mjs.map +1 -0
- package/dist/src/node/webpack/build.js +37 -0
- package/dist/src/node/webpack/build.js.map +1 -0
- package/dist/src/node/webpack/build.mjs +35 -0
- package/dist/src/node/webpack/build.mjs.map +1 -0
- package/dist/{chunks/config-B2BETQ-W.js → src/node/webpack/config.js} +10 -8
- package/dist/src/node/webpack/config.js.map +1 -0
- package/dist/{chunks/config-DHibCzCW.mjs → src/node/webpack/config.mjs} +5 -3
- package/dist/src/node/webpack/config.mjs.map +1 -0
- package/dist/{chunks/watch-BKW3b7Rj.js → src/node/webpack/watch.js} +2 -51
- package/dist/src/node/webpack/watch.js.map +1 -0
- package/dist/{chunks/watch-DQJ0HV0l.mjs → src/node/webpack/watch.mjs} +2 -51
- package/dist/src/node/webpack/watch.mjs.map +1 -0
- package/package.json +22 -22
- package/dist/chunks/aliases-B2TXon3T.js.map +0 -1
- package/dist/chunks/aliases-BsT_zzr4.mjs.map +0 -1
- package/dist/chunks/build-BQMdiYL1.mjs +0 -57
- package/dist/chunks/build-BQMdiYL1.mjs.map +0 -1
- package/dist/chunks/build-FJLfahVt.mjs +0 -85
- package/dist/chunks/build-FJLfahVt.mjs.map +0 -1
- package/dist/chunks/build-RZ8_oqFy.js +0 -59
- package/dist/chunks/build-RZ8_oqFy.js.map +0 -1
- package/dist/chunks/build-XY97xrwm.js +0 -87
- package/dist/chunks/build-XY97xrwm.js.map +0 -1
- package/dist/chunks/config-B2BETQ-W.js.map +0 -1
- package/dist/chunks/config-BqQdQJh_.mjs.map +0 -1
- package/dist/chunks/config-CsJ2EtSs.js.map +0 -1
- package/dist/chunks/config-DHibCzCW.mjs.map +0 -1
- package/dist/chunks/index-BJFfd72y.js +0 -3185
- package/dist/chunks/index-BJFfd72y.js.map +0 -1
- package/dist/chunks/index-DL_emYoN.mjs +0 -3160
- package/dist/chunks/index-DL_emYoN.mjs.map +0 -1
- package/dist/chunks/watch-BDsNoG4h.mjs.map +0 -1
- package/dist/chunks/watch-BKW3b7Rj.js.map +0 -1
- package/dist/chunks/watch-DQJ0HV0l.mjs.map +0 -1
- package/dist/chunks/watch-DzwyHBm4.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sources":["../../../../../src/cli/commands/export/action.ts"],"sourcesContent":["import { isObject, isString, isFinite, toNumber } from 'lodash/fp';\nimport fs from 'fs-extra';\nimport chalk from 'chalk';\nimport type { Core } from '@strapi/types';\n\nimport {\n engine as engineDataTransfer,\n strapi as strapiDataTransfer,\n file as fileDataTransfer,\n} from '@strapi/data-transfer';\n\nimport {\n getDefaultExportName,\n buildTransferTable,\n DEFAULT_IGNORED_CONTENT_TYPES,\n createStrapiInstance,\n formatDiagnostic,\n loadersFactory,\n exitMessageText,\n abortTransfer,\n getTransferTelemetryPayload,\n setSignalHandler,\n} from '../../utils/data-transfer';\nimport { exitWith } from '../../utils/helpers';\n\nconst {\n providers: { createLocalFileDestinationProvider },\n} = fileDataTransfer;\nconst {\n providers: { createLocalStrapiSourceProvider },\n} = strapiDataTransfer;\n\nconst BYTES_IN_MB = 1024 * 1024;\n\ninterface CmdOptions {\n file?: string;\n encrypt?: boolean;\n verbose?: boolean;\n key?: string;\n compress?: boolean;\n only?: (keyof engineDataTransfer.TransferGroupFilter)[];\n exclude?: (keyof engineDataTransfer.TransferGroupFilter)[];\n throttle?: number;\n maxSizeJsonl?: number;\n}\n\n/**\n * Export command.\n *\n * It transfers data from a local Strapi instance to a file\n *\n * @param {ExportCommandOptions} opts\n */\nexport default async (opts: CmdOptions) => {\n // Validate inputs from Commander\n if (!isObject(opts)) {\n exitWith(1, 'Could not parse command arguments');\n }\n\n const strapi = await createStrapiInstance();\n\n const source = createSourceProvider(strapi);\n const destination = createDestinationProvider(opts);\n\n const engine = engineDataTransfer.createTransferEngine(source, destination, {\n versionStrategy: 'ignore', // for an export to file, versionStrategy will always be skipped\n schemaStrategy: 'ignore', // for an export to file, schemaStrategy will always be skipped\n exclude: opts.exclude,\n only: opts.only,\n throttle: opts.throttle,\n transforms: {\n links: [\n {\n filter(link) {\n return (\n !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.left.type) &&\n !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.right.type)\n );\n },\n },\n ],\n entities: [\n {\n filter(entity) {\n return !DEFAULT_IGNORED_CONTENT_TYPES.includes(entity.type);\n },\n },\n ],\n },\n });\n\n engine.diagnostics.onDiagnostic(formatDiagnostic('export', opts.verbose));\n\n const progress = engine.progress.stream;\n\n const { updateLoader } = loadersFactory();\n\n progress.on(`stage::start`, ({ stage, data }) => {\n updateLoader(stage, data).start();\n });\n\n progress.on('stage::finish', ({ stage, data }) => {\n updateLoader(stage, data).succeed();\n });\n\n progress.on('stage::progress', ({ stage, data }) => {\n updateLoader(stage, data);\n });\n\n progress.on('transfer::start', async () => {\n console.log(`Starting export...`);\n\n await strapi.telemetry.send('didDEITSProcessStart', getTransferTelemetryPayload(engine));\n });\n\n let results: engineDataTransfer.ITransferResults<typeof source, typeof destination>;\n let outFile: string;\n try {\n // Abort transfer if user interrupts process\n setSignalHandler(() => abortTransfer({ engine, strapi }));\n\n results = await engine.transfer();\n outFile = results.destination?.file?.path ?? '';\n const outFileExists = await fs.pathExists(outFile);\n if (!outFileExists) {\n throw new engineDataTransfer.errors.TransferEngineTransferError(\n `Export file not created \"${outFile}\"`\n );\n }\n\n // Note: we need to await telemetry or else the process ends before it is sent\n await strapi.telemetry.send('didDEITSProcessFinish', getTransferTelemetryPayload(engine));\n\n try {\n const table = buildTransferTable(results.engine);\n console.log(table?.toString());\n } catch (e) {\n console.error('There was an error displaying the results of the transfer.');\n }\n\n console.log(`Export archive is in ${chalk.green(outFile)}`);\n exitWith(0, exitMessageText('export'));\n } catch {\n await strapi.telemetry.send('didDEITSProcessFail', getTransferTelemetryPayload(engine));\n exitWith(1, exitMessageText('export', true));\n }\n};\n\n/**\n * It creates a local strapi destination provider\n */\nconst createSourceProvider = (strapi: Core.Strapi) => {\n return createLocalStrapiSourceProvider({\n async getStrapi() {\n return strapi;\n },\n });\n};\n\n/**\n * It creates a local file destination provider based on the given options\n */\nconst createDestinationProvider = (opts: CmdOptions) => {\n const { file, compress, encrypt, key, maxSizeJsonl } = opts;\n\n const filepath = isString(file) && file.length > 0 ? file : getDefaultExportName();\n\n const maxSizeJsonlInMb = isFinite(toNumber(maxSizeJsonl))\n ? toNumber(maxSizeJsonl) * BYTES_IN_MB\n : undefined;\n\n return createLocalFileDestinationProvider({\n file: {\n path: filepath,\n maxSizeJsonl: maxSizeJsonlInMb,\n },\n encryption: {\n enabled: encrypt ?? false,\n key: encrypt ? key : undefined,\n },\n compression: {\n enabled: compress ?? false,\n },\n });\n};\n"],"names":["providers","createLocalFileDestinationProvider","fileDataTransfer","createLocalStrapiSourceProvider","strapiDataTransfer","BYTES_IN_MB","opts","isObject","exitWith","strapi","createStrapiInstance","source","createSourceProvider","destination","createDestinationProvider","engine","engineDataTransfer","createTransferEngine","versionStrategy","schemaStrategy","exclude","only","throttle","transforms","links","filter","link","DEFAULT_IGNORED_CONTENT_TYPES","includes","left","type","right","entities","entity","diagnostics","onDiagnostic","formatDiagnostic","verbose","progress","stream","updateLoader","loadersFactory","on","stage","data","start","succeed","console","log","telemetry","send","getTransferTelemetryPayload","results","outFile","setSignalHandler","abortTransfer","transfer","file","path","outFileExists","fs","pathExists","errors","TransferEngineTransferError","table","buildTransferTable","toString","e","error","chalk","green","exitMessageText","getStrapi","compress","encrypt","key","maxSizeJsonl","filepath","isString","length","getDefaultExportName","maxSizeJsonlInMb","isFinite","toNumber","undefined","encryption","enabled","compression"],"mappings":";;;;;;;;;AAyBA,MAAM,EACJA,SAAW,EAAA,EAAEC,kCAAkC,EAAE,EAClD,GAAGC,mBAAAA;AACJ,MAAM,EACJF,SAAW,EAAA,EAAEG,+BAA+B,EAAE,EAC/C,GAAGC,qBAAAA;A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EAAEC,GAAG,EAAEC,YAAY,EAAE,GAAGtE,IAAAA;AAEvD,IAAA,MAAMuE,WAAWC,WAASrB,CAAAA,IAAAA,CAAAA,IAASA,KAAKsB,MAAM,GAAG,IAAItB,IAAOuB,GAAAA,iCAAAA,EAAAA;AAE5D,IAAA,MAAMC,mBAAmBC,WAASC,CAAAA,WAAAA,CAASP,YACvCO,CAAAA,CAAAA,GAAAA,WAAAA,CAASP,gBAAgBvE,WACzB+E,GAAAA,SAAAA;AAEJ,IAAA,OAAOnF,kCAAmC,CAAA;QACxCwD,IAAM,EAAA;YACJC,IAAMmB,EAAAA,QAAAA;YACND,YAAcK,EAAAA;AAChB,SAAA;QACAI,UAAY,EAAA;AACVC,YAAAA,OAAAA,EAASZ,OAAW,IAAA,KAAA;AACpBC,YAAAA,GAAAA,EAAKD,UAAUC,GAAMS,GAAAA;AACvB,SAAA;QACAG,WAAa,EAAA;AACXD,YAAAA,OAAAA,EAASb,QAAY,IAAA;AACvB;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { isObject, isString, isFinite, toNumber } from 'lodash/fp';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { engine, file, strapi } from '@strapi/data-transfer';
|
|
5
|
+
import { createStrapiInstance, DEFAULT_IGNORED_CONTENT_TYPES, formatDiagnostic, getTransferTelemetryPayload, setSignalHandler, abortTransfer, buildTransferTable, exitMessageText, loadersFactory, getDefaultExportName } from '../../utils/data-transfer.mjs';
|
|
6
|
+
import { exitWith } from '../../utils/helpers.mjs';
|
|
7
|
+
|
|
8
|
+
const { providers: { createLocalFileDestinationProvider } } = file;
|
|
9
|
+
const { providers: { createLocalStrapiSourceProvider } } = strapi;
|
|
10
|
+
const BYTES_IN_MB = 1024 * 1024;
|
|
11
|
+
/**
|
|
12
|
+
* Export command.
|
|
13
|
+
*
|
|
14
|
+
* It transfers data from a local Strapi instance to a file
|
|
15
|
+
*
|
|
16
|
+
* @param {ExportCommandOptions} opts
|
|
17
|
+
*/ var action = (async (opts)=>{
|
|
18
|
+
// Validate inputs from Commander
|
|
19
|
+
if (!isObject(opts)) {
|
|
20
|
+
exitWith(1, 'Could not parse command arguments');
|
|
21
|
+
}
|
|
22
|
+
const strapi = await createStrapiInstance();
|
|
23
|
+
const source = createSourceProvider(strapi);
|
|
24
|
+
const destination = createDestinationProvider(opts);
|
|
25
|
+
const engine$1 = engine.createTransferEngine(source, destination, {
|
|
26
|
+
versionStrategy: 'ignore',
|
|
27
|
+
schemaStrategy: 'ignore',
|
|
28
|
+
exclude: opts.exclude,
|
|
29
|
+
only: opts.only,
|
|
30
|
+
throttle: opts.throttle,
|
|
31
|
+
transforms: {
|
|
32
|
+
links: [
|
|
33
|
+
{
|
|
34
|
+
filter (link) {
|
|
35
|
+
return !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.left.type) && !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.right.type);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
entities: [
|
|
40
|
+
{
|
|
41
|
+
filter (entity) {
|
|
42
|
+
return !DEFAULT_IGNORED_CONTENT_TYPES.includes(entity.type);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
engine$1.diagnostics.onDiagnostic(formatDiagnostic('export', opts.verbose));
|
|
49
|
+
const progress = engine$1.progress.stream;
|
|
50
|
+
const { updateLoader } = loadersFactory();
|
|
51
|
+
progress.on(`stage::start`, ({ stage, data })=>{
|
|
52
|
+
updateLoader(stage, data).start();
|
|
53
|
+
});
|
|
54
|
+
progress.on('stage::finish', ({ stage, data })=>{
|
|
55
|
+
updateLoader(stage, data).succeed();
|
|
56
|
+
});
|
|
57
|
+
progress.on('stage::progress', ({ stage, data })=>{
|
|
58
|
+
updateLoader(stage, data);
|
|
59
|
+
});
|
|
60
|
+
progress.on('transfer::start', async ()=>{
|
|
61
|
+
console.log(`Starting export...`);
|
|
62
|
+
await strapi.telemetry.send('didDEITSProcessStart', getTransferTelemetryPayload(engine$1));
|
|
63
|
+
});
|
|
64
|
+
let results;
|
|
65
|
+
let outFile;
|
|
66
|
+
try {
|
|
67
|
+
// Abort transfer if user interrupts process
|
|
68
|
+
setSignalHandler(()=>abortTransfer({
|
|
69
|
+
engine: engine$1,
|
|
70
|
+
strapi
|
|
71
|
+
}));
|
|
72
|
+
results = await engine$1.transfer();
|
|
73
|
+
outFile = results.destination?.file?.path ?? '';
|
|
74
|
+
const outFileExists = await fse.pathExists(outFile);
|
|
75
|
+
if (!outFileExists) {
|
|
76
|
+
throw new engine.errors.TransferEngineTransferError(`Export file not created "${outFile}"`);
|
|
77
|
+
}
|
|
78
|
+
// Note: we need to await telemetry or else the process ends before it is sent
|
|
79
|
+
await strapi.telemetry.send('didDEITSProcessFinish', getTransferTelemetryPayload(engine$1));
|
|
80
|
+
try {
|
|
81
|
+
const table = buildTransferTable(results.engine);
|
|
82
|
+
console.log(table?.toString());
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.error('There was an error displaying the results of the transfer.');
|
|
85
|
+
}
|
|
86
|
+
console.log(`Export archive is in ${chalk.green(outFile)}`);
|
|
87
|
+
exitWith(0, exitMessageText('export'));
|
|
88
|
+
} catch {
|
|
89
|
+
await strapi.telemetry.send('didDEITSProcessFail', getTransferTelemetryPayload(engine$1));
|
|
90
|
+
exitWith(1, exitMessageText('export', true));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* It creates a local strapi destination provider
|
|
95
|
+
*/ const createSourceProvider = (strapi)=>{
|
|
96
|
+
return createLocalStrapiSourceProvider({
|
|
97
|
+
async getStrapi () {
|
|
98
|
+
return strapi;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* It creates a local file destination provider based on the given options
|
|
104
|
+
*/ const createDestinationProvider = (opts)=>{
|
|
105
|
+
const { file, compress, encrypt, key, maxSizeJsonl } = opts;
|
|
106
|
+
const filepath = isString(file) && file.length > 0 ? file : getDefaultExportName();
|
|
107
|
+
const maxSizeJsonlInMb = isFinite(toNumber(maxSizeJsonl)) ? toNumber(maxSizeJsonl) * BYTES_IN_MB : undefined;
|
|
108
|
+
return createLocalFileDestinationProvider({
|
|
109
|
+
file: {
|
|
110
|
+
path: filepath,
|
|
111
|
+
maxSizeJsonl: maxSizeJsonlInMb
|
|
112
|
+
},
|
|
113
|
+
encryption: {
|
|
114
|
+
enabled: encrypt ?? false,
|
|
115
|
+
key: encrypt ? key : undefined
|
|
116
|
+
},
|
|
117
|
+
compression: {
|
|
118
|
+
enabled: compress ?? false
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export { action as default };
|
|
124
|
+
//# sourceMappingURL=action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.mjs","sources":["../../../../../src/cli/commands/export/action.ts"],"sourcesContent":["import { isObject, isString, isFinite, toNumber } from 'lodash/fp';\nimport fs from 'fs-extra';\nimport chalk from 'chalk';\nimport type { Core } from '@strapi/types';\n\nimport {\n engine as engineDataTransfer,\n strapi as strapiDataTransfer,\n file as fileDataTransfer,\n} from '@strapi/data-transfer';\n\nimport {\n getDefaultExportName,\n buildTransferTable,\n DEFAULT_IGNORED_CONTENT_TYPES,\n createStrapiInstance,\n formatDiagnostic,\n loadersFactory,\n exitMessageText,\n abortTransfer,\n getTransferTelemetryPayload,\n setSignalHandler,\n} from '../../utils/data-transfer';\nimport { exitWith } from '../../utils/helpers';\n\nconst {\n providers: { createLocalFileDestinationProvider },\n} = fileDataTransfer;\nconst {\n providers: { createLocalStrapiSourceProvider },\n} = strapiDataTransfer;\n\nconst BYTES_IN_MB = 1024 * 1024;\n\ninterface CmdOptions {\n file?: string;\n encrypt?: boolean;\n verbose?: boolean;\n key?: string;\n compress?: boolean;\n only?: (keyof engineDataTransfer.TransferGroupFilter)[];\n exclude?: (keyof engineDataTransfer.TransferGroupFilter)[];\n throttle?: number;\n maxSizeJsonl?: number;\n}\n\n/**\n * Export command.\n *\n * It transfers data from a local Strapi instance to a file\n *\n * @param {ExportCommandOptions} opts\n */\nexport default async (opts: CmdOptions) => {\n // Validate inputs from Commander\n if (!isObject(opts)) {\n exitWith(1, 'Could not parse command arguments');\n }\n\n const strapi = await createStrapiInstance();\n\n const source = createSourceProvider(strapi);\n const destination = createDestinationProvider(opts);\n\n const engine = engineDataTransfer.createTransferEngine(source, destination, {\n versionStrategy: 'ignore', // for an export to file, versionStrategy will always be skipped\n schemaStrategy: 'ignore', // for an export to file, schemaStrategy will always be skipped\n exclude: opts.exclude,\n only: opts.only,\n throttle: opts.throttle,\n transforms: {\n links: [\n {\n filter(link) {\n return (\n !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.left.type) &&\n !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.right.type)\n );\n },\n },\n ],\n entities: [\n {\n filter(entity) {\n return !DEFAULT_IGNORED_CONTENT_TYPES.includes(entity.type);\n },\n },\n ],\n },\n });\n\n engine.diagnostics.onDiagnostic(formatDiagnostic('export', opts.verbose));\n\n const progress = engine.progress.stream;\n\n const { updateLoader } = loadersFactory();\n\n progress.on(`stage::start`, ({ stage, data }) => {\n updateLoader(stage, data).start();\n });\n\n progress.on('stage::finish', ({ stage, data }) => {\n updateLoader(stage, data).succeed();\n });\n\n progress.on('stage::progress', ({ stage, data }) => {\n updateLoader(stage, data);\n });\n\n progress.on('transfer::start', async () => {\n console.log(`Starting export...`);\n\n await strapi.telemetry.send('didDEITSProcessStart', getTransferTelemetryPayload(engine));\n });\n\n let results: engineDataTransfer.ITransferResults<typeof source, typeof destination>;\n let outFile: string;\n try {\n // Abort transfer if user interrupts process\n setSignalHandler(() => abortTransfer({ engine, strapi }));\n\n results = await engine.transfer();\n outFile = results.destination?.file?.path ?? '';\n const outFileExists = await fs.pathExists(outFile);\n if (!outFileExists) {\n throw new engineDataTransfer.errors.TransferEngineTransferError(\n `Export file not created \"${outFile}\"`\n );\n }\n\n // Note: we need to await telemetry or else the process ends before it is sent\n await strapi.telemetry.send('didDEITSProcessFinish', getTransferTelemetryPayload(engine));\n\n try {\n const table = buildTransferTable(results.engine);\n console.log(table?.toString());\n } catch (e) {\n console.error('There was an error displaying the results of the transfer.');\n }\n\n console.log(`Export archive is in ${chalk.green(outFile)}`);\n exitWith(0, exitMessageText('export'));\n } catch {\n await strapi.telemetry.send('didDEITSProcessFail', getTransferTelemetryPayload(engine));\n exitWith(1, exitMessageText('export', true));\n }\n};\n\n/**\n * It creates a local strapi destination provider\n */\nconst createSourceProvider = (strapi: Core.Strapi) => {\n return createLocalStrapiSourceProvider({\n async getStrapi() {\n return strapi;\n },\n });\n};\n\n/**\n * It creates a local file destination provider based on the given options\n */\nconst createDestinationProvider = (opts: CmdOptions) => {\n const { file, compress, encrypt, key, maxSizeJsonl } = opts;\n\n const filepath = isString(file) && file.length > 0 ? file : getDefaultExportName();\n\n const maxSizeJsonlInMb = isFinite(toNumber(maxSizeJsonl))\n ? toNumber(maxSizeJsonl) * BYTES_IN_MB\n : undefined;\n\n return createLocalFileDestinationProvider({\n file: {\n path: filepath,\n maxSizeJsonl: maxSizeJsonlInMb,\n },\n encryption: {\n enabled: encrypt ?? false,\n key: encrypt ? key : undefined,\n },\n compression: {\n enabled: compress ?? false,\n },\n });\n};\n"],"names":["providers","createLocalFileDestinationProvider","fileDataTransfer","createLocalStrapiSourceProvider","strapiDataTransfer","BYTES_IN_MB","opts","isObject","exitWith","strapi","createStrapiInstance","source","createSourceProvider","destination","createDestinationProvider","engine","engineDataTransfer","createTransferEngine","versionStrategy","schemaStrategy","exclude","only","throttle","transforms","links","filter","link","DEFAULT_IGNORED_CONTENT_TYPES","includes","left","type","right","entities","entity","diagnostics","onDiagnostic","formatDiagnostic","verbose","progress","stream","updateLoader","loadersFactory","on","stage","data","start","succeed","console","log","telemetry","send","getTransferTelemetryPayload","results","outFile","setSignalHandler","abortTransfer","transfer","file","path","outFileExists","fs","pathExists","errors","TransferEngineTransferError","table","buildTransferTable","toString","e","error","chalk","green","exitMessageText","getStrapi","compress","encrypt","key","maxSizeJsonl","filepath","isString","length","getDefaultExportName","maxSizeJsonlInMb","isFinite","toNumber","undefined","encryption","enabled","compression"],"mappings":";;;;;;;AAyBA,MAAM,EACJA,SAAW,EAAA,EAAEC,kCAAkC,EAAE,EAClD,GAAGC,IAAAA;AACJ,MAAM,EACJF,SAAW,EAAA,EAAEG,+BAA+B,EAAE,EAC/C,GAAGC,MAAAA;AAEJ,MAAMC,cAAc,IAAO,GAAA,IAAA;AAc3B;;;;;;IAOA,aAAe,CAAA,OAAOC,IAAAA,GAAAA;;IAEpB,IAAI,CAACC,SAASD,IAAO,CAAA,EAAA;AACnBE,QAAAA,QAAAA,CAAS,CAAG,EAAA,mCAAA,CAAA;AACd;AAEA,IAAA,MAAMC,SAAS,MAAMC,oBAAAA,EAAAA;AAErB,IAAA,MAAMC,SAASC,oBAAqBH,CAAAA,MAAAA,CAAAA;AACpC,IAAA,MAAMI,cAAcC,yBAA0BR,CAAAA,IAAAA,CAAAA;AAE9C,IAAA,MAAMS,QAASC,GAAAA,MAAAA,CAAmBC,oBAAoB,CAACN,QAAQE,WAAa,EAAA;QAC1EK,eAAiB,EAAA,QAAA;QACjBC,cAAgB,EAAA,QAAA;AAChBC,QAAAA,OAAAA,EAASd,KAAKc,OAAO;AACrBC,QAAAA,IAAAA,EAAMf,KAAKe,IAAI;AACfC,QAAAA,QAAAA,EAAUhB,KAAKgB,QAAQ;QACvBC,UAAY,EAAA;YACVC,KAAO,EAAA;AACL,gBAAA;AACEC,oBAAAA,MAAAA,CAAAA,CAAOC,IAAI,EAAA;AACT,wBAAA,OACE,CAACC,6BAA8BC,CAAAA,QAAQ,CAACF,IAAAA,CAAKG,IAAI,CAACC,IAAI,CACtD,IAAA,CAACH,8B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,CAAAA,QAAAA,CAAAA,CAAAA;QAC/EP,QAAS,CAAA,CAAA,EAAG+D,gBAAgB,QAAU,EAAA,IAAA,CAAA,CAAA;AACxC;AACF,CAAA;AAEA;;IAGA,MAAM3D,uBAAuB,CAACH,MAAAA,GAAAA;AAC5B,IAAA,OAAON,+BAAgC,CAAA;QACrC,MAAMqE,SAAAA,CAAAA,GAAAA;YACJ,OAAO/D,MAAAA;AACT;AACF,KAAA,CAAA;AACF,CAAA;AAEA;;IAGA,MAAMK,4BAA4B,CAACR,IAAAA,GAAAA;IACjC,MAAM,EAAEmD,IAAI,EAAEgB,QAAQ,EAAEC,OAAO,EAAEC,GAAG,EAAEC,YAAY,EAAE,GAAGtE,IAAAA;AAEvD,IAAA,MAAMuE,WAAWC,QAASrB,CAAAA,IAAAA,CAAAA,IAASA,KAAKsB,MAAM,GAAG,IAAItB,IAAOuB,GAAAA,oBAAAA,EAAAA;AAE5D,IAAA,MAAMC,mBAAmBC,QAASC,CAAAA,QAAAA,CAASP,YACvCO,CAAAA,CAAAA,GAAAA,QAAAA,CAASP,gBAAgBvE,WACzB+E,GAAAA,SAAAA;AAEJ,IAAA,OAAOnF,kCAAmC,CAAA;QACxCwD,IAAM,EAAA;YACJC,IAAMmB,EAAAA,QAAAA;YACND,YAAcK,EAAAA;AAChB,SAAA;QACAI,UAAY,EAAA;AACVC,YAAAA,OAAAA,EAASZ,OAAW,IAAA,KAAA;AACpBC,YAAAA,GAAAA,EAAKD,UAAUC,GAAMS,GAAAA;AACvB,SAAA;QACAG,WAAa,EAAA;AACXD,YAAAA,OAAAA,EAASb,QAAY,IAAA;AACvB;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var commander = require('commander');
|
|
4
|
+
var dataTransfer = require('../../utils/data-transfer.js');
|
|
5
|
+
var commander$1 = require('../../utils/commander.js');
|
|
6
|
+
var action = require('./action.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `$ strapi export`
|
|
10
|
+
*/ const command = ()=>{
|
|
11
|
+
return commander.createCommand('export').description('Export data from Strapi to file').allowExcessArguments(false).addOption(new commander.Option('--no-encrypt', `Disables 'aes-128-ecb' encryption of the output file`).default(true)).addOption(new commander.Option('--no-compress', 'Disables gzip compression of output file').default(true)).addOption(new commander.Option('--verbose', 'Enable verbose logs')).addOption(new commander.Option('-k, --key <string>', 'Provide encryption key in command instead of using the prompt')).addOption(new commander.Option('-f, --file <file>', 'name to use for exported file (without extensions)')).addOption(dataTransfer.excludeOption).addOption(dataTransfer.onlyOption).addOption(dataTransfer.throttleOption).hook('preAction', dataTransfer.validateExcludeOnly).hook('preAction', commander$1.promptEncryptionKey).action(action);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports = command;
|
|
15
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sources":["../../../../../src/cli/commands/export/command.ts"],"sourcesContent":["import { createCommand, Option } from 'commander';\n\nimport {\n excludeOption,\n onlyOption,\n throttleOption,\n validateExcludeOnly,\n} from '../../utils/data-transfer';\nimport { promptEncryptionKey } from '../../utils/commander';\nimport action from './action';\n\n/**\n * `$ strapi export`\n */\nconst command = () => {\n return createCommand('export')\n .description('Export data from Strapi to file')\n .allowExcessArguments(false)\n .addOption(\n new Option('--no-encrypt', `Disables 'aes-128-ecb' encryption of the output file`).default(\n true\n )\n )\n .addOption(\n new Option('--no-compress', 'Disables gzip compression of output file').default(true)\n )\n .addOption(new Option('--verbose', 'Enable verbose logs'))\n .addOption(\n new Option(\n '-k, --key <string>',\n 'Provide encryption key in command instead of using the prompt'\n )\n )\n .addOption(\n new Option('-f, --file <file>', 'name to use for exported file (without extensions)')\n )\n .addOption(excludeOption)\n .addOption(onlyOption)\n .addOption(throttleOption)\n .hook('preAction', validateExcludeOnly)\n .hook('preAction', promptEncryptionKey)\n .action(action);\n};\n\nexport default command;\n"],"names":["command","createCommand","description","allowExcessArguments","addOption","Option","default","excludeOption","onlyOption","throttleOption","hook","validateExcludeOnly","promptEncryptionKey","action"],"mappings":";;;;;;;AAWA;;AAEC,UACKA,OAAU,GAAA,IAAA;AACd,IAAA,OAAOC,uBAAc,CAAA,QAAA,CAAA,CAClBC,WAAW,CAAC,iCACZC,CAAAA,CAAAA,oBAAoB,CAAC,KAAA,CAAA,CACrBC,SAAS,CACR,IAAIC,gBAAAA,CAAO,gBAAgB,CAAC,oDAAoD,CAAC,CAAA,CAAEC,OAAO,CACxF,IAGHF,CAAAA,CAAAA,CAAAA,SAAS,CACR,IAAIC,gBAAO,CAAA,eAAA,EAAiB,0CAA4CC,CAAAA,CAAAA,OAAO,CAAC,IAAA,CAAA,CAAA,CAEjFF,SAAS,CAAC,IAAIC,gBAAO,CAAA,WAAA,EAAa,qBAClCD,CAAAA,CAAAA,CAAAA,SAAS,CACR,IAAIC,gBACF,CAAA,oBAAA,EACA,+DAGHD,CAAAA,CAAAA,CAAAA,SAAS,CACR,IAAIC,gBAAO,CAAA,mBAAA,EAAqB,uDAEjCD,SAAS,CAACG,0BACVH,CAAAA,CAAAA,SAAS,CAACI,uBAAAA,CAAAA,CACVJ,SAAS,CAACK,6BACVC,IAAI,CAAC,WAAaC,EAAAA,gCAAAA,CAAAA,CAClBD,IAAI,CAAC,WAAaE,EAAAA,+BAAAA,CAAAA,CAClBC,MAAM,CAACA,MAAAA,CAAAA;AACZ;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createCommand, Option } from 'commander';
|
|
2
|
+
import { excludeOption, onlyOption, throttleOption, validateExcludeOnly } from '../../utils/data-transfer.mjs';
|
|
3
|
+
import { promptEncryptionKey } from '../../utils/commander.mjs';
|
|
4
|
+
import action from './action.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `$ strapi export`
|
|
8
|
+
*/ const command = ()=>{
|
|
9
|
+
return createCommand('export').description('Export data from Strapi to file').allowExcessArguments(false).addOption(new Option('--no-encrypt', `Disables 'aes-128-ecb' encryption of the output file`).default(true)).addOption(new Option('--no-compress', 'Disables gzip compression of output file').default(true)).addOption(new Option('--verbose', 'Enable verbose logs')).addOption(new Option('-k, --key <string>', 'Provide encryption key in command instead of using the prompt')).addOption(new Option('-f, --file <file>', 'name to use for exported file (without extensions)')).addOption(excludeOption).addOption(onlyOption).addOption(throttleOption).hook('preAction', validateExcludeOnly).hook('preAction', promptEncryptionKey).action(action);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { command as default };
|
|
13
|
+
//# sourceMappingURL=command.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.mjs","sources":["../../../../../src/cli/commands/export/command.ts"],"sourcesContent":["import { createCommand, Option } from 'commander';\n\nimport {\n excludeOption,\n onlyOption,\n throttleOption,\n validateExcludeOnly,\n} from '../../utils/data-transfer';\nimport { promptEncryptionKey } from '../../utils/commander';\nimport action from './action';\n\n/**\n * `$ strapi export`\n */\nconst command = () => {\n return createCommand('export')\n .description('Export data from Strapi to file')\n .allowExcessArguments(false)\n .addOption(\n new Option('--no-encrypt', `Disables 'aes-128-ecb' encryption of the output file`).default(\n true\n )\n )\n .addOption(\n new Option('--no-compress', 'Disables gzip compression of output file').default(true)\n )\n .addOption(new Option('--verbose', 'Enable verbose logs'))\n .addOption(\n new Option(\n '-k, --key <string>',\n 'Provide encryption key in command instead of using the prompt'\n )\n )\n .addOption(\n new Option('-f, --file <file>', 'name to use for exported file (without extensions)')\n )\n .addOption(excludeOption)\n .addOption(onlyOption)\n .addOption(throttleOption)\n .hook('preAction', validateExcludeOnly)\n .hook('preAction', promptEncryptionKey)\n .action(action);\n};\n\nexport default command;\n"],"names":["command","createCommand","description","allowExcessArguments","addOption","Option","default","excludeOption","onlyOption","throttleOption","hook","validateExcludeOnly","promptEncryptionKey","action"],"mappings":";;;;;AAWA;;AAEC,UACKA,OAAU,GAAA,IAAA;AACd,IAAA,OAAOC,aAAc,CAAA,QAAA,CAAA,CAClBC,WAAW,CAAC,iCACZC,CAAAA,CAAAA,oBAAoB,CAAC,KAAA,CAAA,CACrBC,SAAS,CACR,IAAIC,MAAAA,CAAO,gBAAgB,CAAC,oDAAoD,CAAC,CAAA,CAAEC,OAAO,CACxF,IAGHF,CAAAA,CAAAA,CAAAA,SAAS,CACR,IAAIC,MAAO,CAAA,eAAA,EAAiB,0CAA4CC,CAAAA,CAAAA,OAAO,CAAC,IAAA,CAAA,CAAA,CAEjFF,SAAS,CAAC,IAAIC,MAAO,CAAA,WAAA,EAAa,qBAClCD,CAAAA,CAAAA,CAAAA,SAAS,CACR,IAAIC,MACF,CAAA,oBAAA,EACA,+DAGHD,CAAAA,CAAAA,CAAAA,SAAS,CACR,IAAIC,MAAO,CAAA,mBAAA,EAAqB,uDAEjCD,SAAS,CAACG,aACVH,CAAAA,CAAAA,SAAS,CAACI,UAAAA,CAAAA,CACVJ,SAAS,CAACK,gBACVC,IAAI,CAAC,WAAaC,EAAAA,mBAAAA,CAAAA,CAClBD,IAAI,CAAC,WAAaE,EAAAA,mBAAAA,CAAAA,CAClBC,MAAM,CAACA,MAAAA,CAAAA;AACZ;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var commander = require('commander');
|
|
4
|
+
var helpers = require('../utils/helpers.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `$ strapi generate`
|
|
8
|
+
*/ const command = ({ argv })=>{
|
|
9
|
+
return commander.createCommand('generate').description('Launch the interactive API generator').action(()=>{
|
|
10
|
+
helpers.assertCwdContainsStrapiProject('generate');
|
|
11
|
+
argv.splice(2, 1);
|
|
12
|
+
// NOTE: this needs to be lazy loaded in order for plop to work correctly
|
|
13
|
+
import('@strapi/generators').then((gen)=>gen.runCLI());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.command = command;
|
|
18
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sources":["../../../../src/cli/commands/generate.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport { assertCwdContainsStrapiProject } from '../utils/helpers';\nimport type { StrapiCommand } from '../types';\n\n/**\n * `$ strapi generate`\n */\nconst command: StrapiCommand = ({ argv }) => {\n return createCommand('generate')\n .description('Launch the interactive API generator')\n .action(() => {\n assertCwdContainsStrapiProject('generate');\n argv.splice(2, 1);\n\n // NOTE: this needs to be lazy loaded in order for plop to work correctly\n import('@strapi/generators').then((gen) => gen.runCLI());\n });\n};\n\nexport { command };\n"],"names":["command","argv","createCommand","description","action","assertCwdContainsStrapiProject","splice","then","gen","runCLI"],"mappings":";;;;;AAIA;;AAEC,IACKA,MAAAA,OAAAA,GAAyB,CAAC,EAAEC,IAAI,EAAE,GAAA;AACtC,IAAA,OAAOC,wBAAc,UAClBC,CAAAA,CAAAA,WAAW,CAAC,sCAAA,CAAA,CACZC,MAAM,CAAC,IAAA;QACNC,sCAA+B,CAAA,UAAA,CAAA;QAC/BJ,IAAKK,CAAAA,MAAM,CAAC,CAAG,EAAA,CAAA,CAAA;;AAGf,QAAA,OAAO,oBAAsBC,CAAAA,CAAAA,IAAI,CAAC,CAACC,GAAAA,GAAQA,IAAIC,MAAM,EAAA,CAAA;AACvD,KAAA,CAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createCommand } from 'commander';
|
|
2
|
+
import { assertCwdContainsStrapiProject } from '../utils/helpers.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `$ strapi generate`
|
|
6
|
+
*/ const command = ({ argv })=>{
|
|
7
|
+
return createCommand('generate').description('Launch the interactive API generator').action(()=>{
|
|
8
|
+
assertCwdContainsStrapiProject('generate');
|
|
9
|
+
argv.splice(2, 1);
|
|
10
|
+
// NOTE: this needs to be lazy loaded in order for plop to work correctly
|
|
11
|
+
import('@strapi/generators').then((gen)=>gen.runCLI());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { command };
|
|
16
|
+
//# sourceMappingURL=generate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.mjs","sources":["../../../../src/cli/commands/generate.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport { assertCwdContainsStrapiProject } from '../utils/helpers';\nimport type { StrapiCommand } from '../types';\n\n/**\n * `$ strapi generate`\n */\nconst command: StrapiCommand = ({ argv }) => {\n return createCommand('generate')\n .description('Launch the interactive API generator')\n .action(() => {\n assertCwdContainsStrapiProject('generate');\n argv.splice(2, 1);\n\n // NOTE: this needs to be lazy loaded in order for plop to work correctly\n import('@strapi/generators').then((gen) => gen.runCLI());\n });\n};\n\nexport { command };\n"],"names":["command","argv","createCommand","description","action","assertCwdContainsStrapiProject","splice","then","gen","runCLI"],"mappings":";;;AAIA;;AAEC,IACKA,MAAAA,OAAAA,GAAyB,CAAC,EAAEC,IAAI,EAAE,GAAA;AACtC,IAAA,OAAOC,cAAc,UAClBC,CAAAA,CAAAA,WAAW,CAAC,sCAAA,CAAA,CACZC,MAAM,CAAC,IAAA;QACNC,8BAA+B,CAAA,UAAA,CAAA;QAC/BJ,IAAKK,CAAAA,MAAM,CAAC,CAAG,EAAA,CAAA,CAAA;;AAGf,QAAA,OAAO,oBAAsBC,CAAAA,CAAAA,IAAI,CAAC,CAACC,GAAAA,GAAQA,IAAIC,MAAM,EAAA,CAAA;AACvD,KAAA,CAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var commander = require('commander');
|
|
4
|
+
var CLITable = require('cli-table3');
|
|
5
|
+
var chalk = require('chalk');
|
|
6
|
+
var core = require('@strapi/core');
|
|
7
|
+
var helpers = require('../../utils/helpers.js');
|
|
8
|
+
|
|
9
|
+
const action = async ()=>{
|
|
10
|
+
const appContext = await core.compileStrapi();
|
|
11
|
+
const app = await core.createStrapi(appContext).register();
|
|
12
|
+
const list = app.get('hooks').keys();
|
|
13
|
+
const infoTable = new CLITable({
|
|
14
|
+
head: [
|
|
15
|
+
chalk.blue('Name')
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
list.forEach((name)=>infoTable.push([
|
|
19
|
+
name
|
|
20
|
+
]));
|
|
21
|
+
console.log(infoTable.toString());
|
|
22
|
+
await app.destroy();
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* `$ strapi hooks:list`
|
|
26
|
+
*/ const command = ()=>{
|
|
27
|
+
return commander.createCommand('hooks:list').description('List all the application hooks').action(helpers.runAction('hooks:list', action));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.action = action;
|
|
31
|
+
exports.command = command;
|
|
32
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sources":["../../../../../src/cli/commands/hooks/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).register();\n\n const list = app.get('hooks').keys();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Name')],\n });\n\n list.forEach((name: string) => infoTable.push([name]));\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi hooks:list`\n */\nconst command: StrapiCommand = () => {\n return createCommand('hooks:list')\n .description('List all the application hooks')\n .action(runAction('hooks:list', action));\n};\n\nexport { action, command };\n"],"names":["action","appContext","compileStrapi","app","createStrapi","register","list","get","keys","infoTable","CLITable","head","chalk","blue","forEach","name","push","console","log","toString","destroy","command","createCommand","description","runAction"],"mappings":";;;;;;;;AAQA,MAAMA,MAAS,GAAA,UAAA;AACb,IAAA,MAAMC,aAAa,MAAMC,kBAAAA,EAAAA;AACzB,IAAA,MAAMC,GAAM,GAAA,MAAMC,iBAAaH,CAAAA,UAAAA,CAAAA,CAAYI,QAAQ,EAAA;AAEnD,IAAA,MAAMC,IAAOH,GAAAA,GAAAA,CAAII,GAAG,CAAC,SAASC,IAAI,EAAA;IAElC,MAAMC,SAAAA,GAAY,IAAIC,QAAS,CAAA;QAC7BC,IAAM,EAAA;AAACC,YAAAA,KAAAA,CAAMC,IAAI,CAAC,MAAA;AAAQ;AAC5B,KAAA,CAAA;AAEAP,IAAAA,IAAAA,CAAKQ,OAAO,CAAC,CAACC,IAAiBN,GAAAA,SAAAA,CAAUO,IAAI,CAAC;AAACD,YAAAA;AAAK,SAAA,CAAA,CAAA;IAEpDE,OAAQC,CAAAA,GAAG,CAACT,SAAAA,CAAUU,QAAQ,EAAA,CAAA;AAE9B,IAAA,MAAMhB,IAAIiB,OAAO,EAAA;AACnB;AAEA;;AAEC,UACKC,OAAyB,GAAA,IAAA;IAC7B,OAAOC,uBAAAA,CAAc,cAClBC,WAAW,CAAC,kCACZvB,MAAM,CAACwB,kBAAU,YAAcxB,EAAAA,MAAAA,CAAAA,CAAAA;AACpC;;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createCommand } from 'commander';
|
|
2
|
+
import CLITable from 'cli-table3';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { compileStrapi, createStrapi } from '@strapi/core';
|
|
5
|
+
import { runAction } from '../../utils/helpers.mjs';
|
|
6
|
+
|
|
7
|
+
const action = async ()=>{
|
|
8
|
+
const appContext = await compileStrapi();
|
|
9
|
+
const app = await createStrapi(appContext).register();
|
|
10
|
+
const list = app.get('hooks').keys();
|
|
11
|
+
const infoTable = new CLITable({
|
|
12
|
+
head: [
|
|
13
|
+
chalk.blue('Name')
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
list.forEach((name)=>infoTable.push([
|
|
17
|
+
name
|
|
18
|
+
]));
|
|
19
|
+
console.log(infoTable.toString());
|
|
20
|
+
await app.destroy();
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* `$ strapi hooks:list`
|
|
24
|
+
*/ const command = ()=>{
|
|
25
|
+
return createCommand('hooks:list').description('List all the application hooks').action(runAction('hooks:list', action));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { action, command };
|
|
29
|
+
//# sourceMappingURL=list.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.mjs","sources":["../../../../../src/cli/commands/hooks/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).register();\n\n const list = app.get('hooks').keys();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Name')],\n });\n\n list.forEach((name: string) => infoTable.push([name]));\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi hooks:list`\n */\nconst command: StrapiCommand = () => {\n return createCommand('hooks:list')\n .description('List all the application hooks')\n .action(runAction('hooks:list', action));\n};\n\nexport { action, command };\n"],"names":["action","appContext","compileStrapi","app","createStrapi","register","list","get","keys","infoTable","CLITable","head","chalk","blue","forEach","name","push","console","log","toString","destroy","command","createCommand","description","runAction"],"mappings":";;;;;;AAQA,MAAMA,MAAS,GAAA,UAAA;AACb,IAAA,MAAMC,aAAa,MAAMC,aAAAA,EAAAA;AACzB,IAAA,MAAMC,GAAM,GAAA,MAAMC,YAAaH,CAAAA,UAAAA,CAAAA,CAAYI,QAAQ,EAAA;AAEnD,IAAA,MAAMC,IAAOH,GAAAA,GAAAA,CAAII,GAAG,CAAC,SAASC,IAAI,EAAA;IAElC,MAAMC,SAAAA,GAAY,IAAIC,QAAS,CAAA;QAC7BC,IAAM,EAAA;AAACC,YAAAA,KAAAA,CAAMC,IAAI,CAAC,MAAA;AAAQ;AAC5B,KAAA,CAAA;AAEAP,IAAAA,IAAAA,CAAKQ,OAAO,CAAC,CAACC,IAAiBN,GAAAA,SAAAA,CAAUO,IAAI,CAAC;AAACD,YAAAA;AAAK,SAAA,CAAA,CAAA;IAEpDE,OAAQC,CAAAA,GAAG,CAACT,SAAAA,CAAUU,QAAQ,EAAA,CAAA;AAE9B,IAAA,MAAMhB,IAAIiB,OAAO,EAAA;AACnB;AAEA;;AAEC,UACKC,OAAyB,GAAA,IAAA;IAC7B,OAAOC,aAAAA,CAAc,cAClBC,WAAW,CAAC,kCACZvB,MAAM,CAACwB,UAAU,YAAcxB,EAAAA,MAAAA,CAAAA,CAAAA;AACpC;;;;"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fp = require('lodash/fp');
|
|
4
|
+
var chalk = require('chalk');
|
|
5
|
+
var dataTransfer$1 = require('@strapi/data-transfer');
|
|
6
|
+
var dataTransfer = require('../../utils/data-transfer.js');
|
|
7
|
+
var helpers = require('../../utils/helpers.js');
|
|
8
|
+
|
|
9
|
+
const { providers: { createLocalFileSourceProvider } } = dataTransfer$1.file;
|
|
10
|
+
const { providers: { createLocalStrapiDestinationProvider, DEFAULT_CONFLICT_STRATEGY } } = dataTransfer$1.strapi;
|
|
11
|
+
const { createTransferEngine, DEFAULT_VERSION_STRATEGY, DEFAULT_SCHEMA_STRATEGY } = dataTransfer$1.engine;
|
|
12
|
+
/**
|
|
13
|
+
* Import command.
|
|
14
|
+
*
|
|
15
|
+
* It transfers data from a file to a local Strapi instance
|
|
16
|
+
*/ var action = (async (opts)=>{
|
|
17
|
+
// validate inputs from Commander
|
|
18
|
+
if (!fp.isObject(opts)) {
|
|
19
|
+
helpers.exitWith(1, 'Could not parse arguments');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* From strapi backup file
|
|
23
|
+
*/ const sourceOptions = getLocalFileSourceOptions(opts);
|
|
24
|
+
const source = createLocalFileSourceProvider(sourceOptions);
|
|
25
|
+
/**
|
|
26
|
+
* To local Strapi instance
|
|
27
|
+
*/ const strapiInstance = await dataTransfer.createStrapiInstance();
|
|
28
|
+
/**
|
|
29
|
+
* Configure and run the transfer engine
|
|
30
|
+
*/ const engineOptions = {
|
|
31
|
+
versionStrategy: DEFAULT_VERSION_STRATEGY,
|
|
32
|
+
schemaStrategy: DEFAULT_SCHEMA_STRATEGY,
|
|
33
|
+
exclude: opts.exclude,
|
|
34
|
+
only: opts.only,
|
|
35
|
+
throttle: opts.throttle,
|
|
36
|
+
transforms: {
|
|
37
|
+
links: [
|
|
38
|
+
{
|
|
39
|
+
filter (link) {
|
|
40
|
+
return !dataTransfer.DEFAULT_IGNORED_CONTENT_TYPES.includes(link.left.type) && !dataTransfer.DEFAULT_IGNORED_CONTENT_TYPES.includes(link.right.type);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
entities: [
|
|
45
|
+
{
|
|
46
|
+
filter: (entity)=>!dataTransfer.DEFAULT_IGNORED_CONTENT_TYPES.includes(entity.type)
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const destinationOptions = {
|
|
52
|
+
async getStrapi () {
|
|
53
|
+
return strapiInstance;
|
|
54
|
+
},
|
|
55
|
+
autoDestroy: false,
|
|
56
|
+
strategy: opts.conflictStrategy || DEFAULT_CONFLICT_STRATEGY,
|
|
57
|
+
restore: dataTransfer.parseRestoreFromOptions(engineOptions)
|
|
58
|
+
};
|
|
59
|
+
const destination = createLocalStrapiDestinationProvider(destinationOptions);
|
|
60
|
+
destination.onWarning = (message)=>console.warn(`\n${chalk.yellow('warn')}: ${message}`);
|
|
61
|
+
const engine = createTransferEngine(source, destination, engineOptions);
|
|
62
|
+
engine.diagnostics.onDiagnostic(dataTransfer.formatDiagnostic('import', opts.verbose));
|
|
63
|
+
const progress = engine.progress.stream;
|
|
64
|
+
const { updateLoader } = dataTransfer.loadersFactory();
|
|
65
|
+
engine.onSchemaDiff(dataTransfer.getDiffHandler(engine, {
|
|
66
|
+
force: opts.force,
|
|
67
|
+
action: 'import'
|
|
68
|
+
}));
|
|
69
|
+
progress.on(`stage::start`, ({ stage, data })=>{
|
|
70
|
+
updateLoader(stage, data).start();
|
|
71
|
+
});
|
|
72
|
+
progress.on('stage::finish', ({ stage, data })=>{
|
|
73
|
+
updateLoader(stage, data).succeed();
|
|
74
|
+
});
|
|
75
|
+
progress.on('stage::progress', ({ stage, data })=>{
|
|
76
|
+
updateLoader(stage, data);
|
|
77
|
+
});
|
|
78
|
+
progress.on('transfer::start', async ()=>{
|
|
79
|
+
console.log('Starting import...');
|
|
80
|
+
await strapiInstance.telemetry.send('didDEITSProcessStart', dataTransfer.getTransferTelemetryPayload(engine));
|
|
81
|
+
});
|
|
82
|
+
let results;
|
|
83
|
+
try {
|
|
84
|
+
// Abort transfer if user interrupts process
|
|
85
|
+
dataTransfer.setSignalHandler(()=>dataTransfer.abortTransfer({
|
|
86
|
+
engine,
|
|
87
|
+
strapi: strapi
|
|
88
|
+
}));
|
|
89
|
+
results = await engine.transfer();
|
|
90
|
+
try {
|
|
91
|
+
const table = dataTransfer.buildTransferTable(results.engine);
|
|
92
|
+
console.log(table?.toString());
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error('There was an error displaying the results of the transfer.');
|
|
95
|
+
}
|
|
96
|
+
// Note: we need to await telemetry or else the process ends before it is sent
|
|
97
|
+
await strapiInstance.telemetry.send('didDEITSProcessFinish', dataTransfer.getTransferTelemetryPayload(engine));
|
|
98
|
+
await strapiInstance.destroy();
|
|
99
|
+
helpers.exitWith(0, dataTransfer.exitMessageText('import'));
|
|
100
|
+
} catch (e) {
|
|
101
|
+
await strapiInstance.telemetry.send('didDEITSProcessFail', dataTransfer.getTransferTelemetryPayload(engine));
|
|
102
|
+
helpers.exitWith(1, dataTransfer.exitMessageText('import', true));
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* Infer local file source provider options based on a given filename
|
|
107
|
+
*/ const getLocalFileSourceOptions = (opts)=>{
|
|
108
|
+
const options = {
|
|
109
|
+
file: {
|
|
110
|
+
path: opts.file ?? ''
|
|
111
|
+
},
|
|
112
|
+
compression: {
|
|
113
|
+
enabled: !!opts.decompress
|
|
114
|
+
},
|
|
115
|
+
encryption: {
|
|
116
|
+
enabled: !!opts.decrypt,
|
|
117
|
+
key: opts.key
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return options;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
module.exports = action;
|
|
124
|
+
//# sourceMappingURL=action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sources":["../../../../../src/cli/commands/import/action.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport { isObject } from 'lodash/fp';\nimport chalk from 'chalk';\n\nimport {\n engine as engineDataTransfer,\n strapi as strapiDataTransfer,\n file as fileDataTransfer,\n} from '@strapi/data-transfer';\n\nimport {\n buildTransferTable,\n DEFAULT_IGNORED_CONTENT_TYPES,\n createStrapiInstance,\n formatDiagnostic,\n loadersFactory,\n exitMessageText,\n abortTransfer,\n getTransferTelemetryPayload,\n setSignalHandler,\n getDiffHandler,\n parseRestoreFromOptions,\n} from '../../utils/data-transfer';\nimport { exitWith } from '../../utils/helpers';\n\nconst {\n providers: { createLocalFileSourceProvider },\n} = fileDataTransfer;\n\nconst {\n providers: { createLocalStrapiDestinationProvider, DEFAULT_CONFLICT_STRATEGY },\n} = strapiDataTransfer;\n\nconst { createTransferEngine, DEFAULT_VERSION_STRATEGY, DEFAULT_SCHEMA_STRATEGY } =\n engineDataTransfer;\n\ninterface CmdOptions {\n file?: string;\n decompress?: boolean;\n decrypt?: boolean;\n verbose?: boolean;\n key?: string;\n conflictStrategy?: 'restore';\n force?: boolean;\n only?: (keyof engineDataTransfer.TransferGroupFilter)[];\n exclude?: (keyof engineDataTransfer.TransferGroupFilter)[];\n throttle?: number;\n}\n\ntype EngineOptions = Parameters<typeof createTransferEngine>[2];\n\n/**\n * Import command.\n *\n * It transfers data from a file to a local Strapi instance\n */\nexport default async (opts: CmdOptions) => {\n // validate inputs from Commander\n if (!isObject(opts)) {\n exitWith(1, 'Could not parse arguments');\n }\n\n /**\n * From strapi backup file\n */\n const sourceOptions = getLocalFileSourceOptions(opts);\n\n const source = createLocalFileSourceProvider(sourceOptions);\n\n /**\n * To local Strapi instance\n */\n const strapiInstance = await createStrapiInstance();\n\n /**\n * Configure and run the transfer engine\n */\n const engineOptions: EngineOptions = {\n versionStrategy: DEFAULT_VERSION_STRATEGY,\n schemaStrategy: DEFAULT_SCHEMA_STRATEGY,\n exclude: opts.exclude,\n only: opts.only,\n throttle: opts.throttle,\n transforms: {\n links: [\n {\n filter(link) {\n return (\n !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.left.type) &&\n !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.right.type)\n );\n },\n },\n ],\n entities: [\n {\n filter: (entity) => !DEFAULT_IGNORED_CONTENT_TYPES.includes(entity.type),\n },\n ],\n },\n };\n\n const destinationOptions = {\n async getStrapi() {\n return strapiInstance;\n },\n autoDestroy: false,\n strategy: opts.conflictStrategy || DEFAULT_CONFLICT_STRATEGY,\n restore: parseRestoreFromOptions(engineOptions),\n };\n\n const destination = createLocalStrapiDestinationProvider(destinationOptions);\n destination.onWarning = (message) => console.warn(`\\n${chalk.yellow('warn')}: ${message}`);\n\n const engine = createTransferEngine(source, destination, engineOptions);\n\n engine.diagnostics.onDiagnostic(formatDiagnostic('import', opts.verbose));\n\n const progress = engine.progress.stream;\n\n const { updateLoader } = loadersFactory();\n\n engine.onSchemaDiff(getDiffHandler(engine, { force: opts.force, action: 'import' }));\n\n progress.on(`stage::start`, ({ stage, data }) => {\n updateLoader(stage, data).start();\n });\n\n progress.on('stage::finish', ({ stage, data }) => {\n updateLoader(stage, data).succeed();\n });\n\n progress.on('stage::progress', ({ stage, data }) => {\n updateLoader(stage, data);\n });\n\n progress.on('transfer::start', async () => {\n console.log('Starting import...');\n await strapiInstance.telemetry.send(\n 'didDEITSProcessStart',\n getTransferTelemetryPayload(engine)\n );\n });\n\n let results: engineDataTransfer.ITransferResults<typeof source, typeof destination>;\n try {\n // Abort transfer if user interrupts process\n setSignalHandler(() => abortTransfer({ engine, strapi: strapi as Core.Strapi }));\n\n results = await engine.transfer();\n\n try {\n const table = buildTransferTable(results.engine);\n console.log(table?.toString());\n } catch (e) {\n console.error('There was an error displaying the results of the transfer.');\n }\n\n // Note: we need to await telemetry or else the process ends before it is sent\n await strapiInstance.telemetry.send(\n 'didDEITSProcessFinish',\n getTransferTelemetryPayload(engine)\n );\n await strapiInstance.destroy();\n\n exitWith(0, exitMessageText('import'));\n } catch (e) {\n await strapiInstance.telemetry.send('didDEITSProcessFail', getTransferTelemetryPayload(engine));\n exitWith(1, exitMessageText('import', true));\n }\n};\n\n/**\n * Infer local file source provider options based on a given filename\n */\nconst getLocalFileSourceOptions = (opts: {\n file?: string;\n decompress?: boolean;\n decrypt?: boolean;\n key?: string;\n}) => {\n const options: fileDataTransfer.providers.ILocalFileSourceProviderOptions = {\n file: { path: opts.file ?? '' },\n compression: { enabled: !!opts.decompress },\n encryption: { enabled: !!opts.decrypt, key: opts.key },\n };\n\n return options;\n};\n"],"names":["providers","createLocalFileSourceProvider","fileDataTransfer","createLocalStrapiDestinationProvider","DEFAULT_CONFLICT_STRATEGY","strapiDataTransfer","createTransferEngine","DEFAULT_VERSION_STRATEGY","DEFAULT_SCHEMA_STRATEGY","engineDataTransfer","opts","isObject","exitWith","sourceOptions","getLocalFileSourceOptions","source","strapiInstance","createStrapiInstance","engineOptions","versionStrategy","schemaStrategy","exclude","only","throttle","transforms","links","filter","link","DEFAULT_IGNORED_CONTENT_TYPES","includes","left","type","right","entities","entity","destinationOptions","getStrapi","autoDestroy","strategy","conflictStrategy","restore","parseRestoreFromOptions","destination","onWarning","message","console","warn","chalk","yellow","engine","diagnostics","onDiagnostic","formatDiagnostic","verbose","progress","stream","updateLoader","loadersFactory","onSchemaDiff","getDiffHandler","force","action","on","stage","data","start","succeed","log","telemetry","send","getTransferTelemetryPayload","results","setSignalHandler","abortTransfer","strapi","transfer","table","buildTransferTable","toString","e","error","destroy","exitMessageText","options","file","path","compression","enabled","decompress","encryption","decrypt","key"],"mappings":";;;;;;;;AAyBA,MAAM,EACJA,SAAW,EAAA,EAAEC,6BAA6B,EAAE,EAC7C,GAAGC,mBAAAA;AAEJ,MAAM,EACJF,WAAW,EAAEG,oCAAoC,EAAEC,yBAAyB,EAAE,EAC/E,GAAGC,qBAAAA;AAEJ,MAAM,EAAEC,oBAAoB,EAAEC,wBAAwB,EAAEC,uBAAuB,EAAE,GAC/EC,qBAAAA;AAiBF;;;;IAKA,aAAe,CAAA,OAAOC,IAAAA,GAAAA;;IAEpB,IAAI,CAACC,YAASD,IAAO,CAAA,EAAA;AACnBE,QAAAA,gBAAAA,CAAS,CAAG,EAAA,2BAAA,CAAA;AACd;AAEA;;MAGA,MAAMC,gBAAgBC,yBAA0BJ,CAAAA,IAAAA,CAAAA;AAEhD,IAAA,MAAMK,SAASd,6BAA8BY,CAAAA,aAAAA,CAAAA;AAE7C;;MAGA,MAAMG,iBAAiB,MAAMC,iCAAAA,EAAAA;AAE7B;;AAEC,MACD,MAAMC,aAA+B,GAAA;QACnCC,eAAiBZ,EAAAA,wBAAAA;QACjBa,cAAgBZ,EAAAA,uBAAAA;AAChBa,QAAAA,OAAAA,EAASX,KAAKW,OAAO;AACrBC,QAAAA,IAAAA,EAAMZ,KAAKY,IAAI;AACfC,QAAAA,QAAAA,EAAUb,KAAKa,QAAQ;QACvBC,UAAY,EAAA;YACVC,KAAO,EAAA;AACL,gBAAA;AACEC,oBAAAA,MAAAA,CAAAA,CAAOC,IAAI,EA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,OAAAA,CAAQmC,KAAK,CAAC,4DAAA,CAAA;AAChB;;AAGA,QAAA,MAAMhE,eAAeoD,SAAS,CAACC,IAAI,CACjC,yBACAC,wCAA4BrB,CAAAA,MAAAA,CAAAA,CAAAA;AAE9B,QAAA,MAAMjC,eAAeiE,OAAO,EAAA;AAE5BrE,QAAAA,gBAAAA,CAAS,GAAGsE,4BAAgB,CAAA,QAAA,CAAA,CAAA;AAC9B,KAAA,CAAE,OAAOH,CAAG,EAAA;AACV,QAAA,MAAM/D,eAAeoD,SAAS,CAACC,IAAI,CAAC,uBAAuBC,wCAA4BrB,CAAAA,MAAAA,CAAAA,CAAAA;QACvFrC,gBAAS,CAAA,CAAA,EAAGsE,6BAAgB,QAAU,EAAA,IAAA,CAAA,CAAA;AACxC;AACF,CAAA;AAEA;;IAGA,MAAMpE,4BAA4B,CAACJ,IAAAA,GAAAA;AAMjC,IAAA,MAAMyE,OAAsE,GAAA;QAC1EC,IAAM,EAAA;YAAEC,IAAM3E,EAAAA,IAAAA,CAAK0E,IAAI,IAAI;AAAG,SAAA;QAC9BE,WAAa,EAAA;YAAEC,OAAS,EAAA,CAAC,CAAC7E,IAAAA,CAAK8E;AAAW,SAAA;QAC1CC,UAAY,EAAA;YAAEF,OAAS,EAAA,CAAC,CAAC7E,IAAAA,CAAKgF,OAAO;AAAEC,YAAAA,GAAAA,EAAKjF,KAAKiF;AAAI;AACvD,KAAA;IAEA,OAAOR,OAAAA;AACT,CAAA;;;;"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { isObject } from 'lodash/fp';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { file, strapi as strapi$1, engine } from '@strapi/data-transfer';
|
|
4
|
+
import { createStrapiInstance, DEFAULT_IGNORED_CONTENT_TYPES, parseRestoreFromOptions, formatDiagnostic, getDiffHandler, getTransferTelemetryPayload, setSignalHandler, abortTransfer, buildTransferTable, exitMessageText, loadersFactory } from '../../utils/data-transfer.mjs';
|
|
5
|
+
import { exitWith } from '../../utils/helpers.mjs';
|
|
6
|
+
|
|
7
|
+
const { providers: { createLocalFileSourceProvider } } = file;
|
|
8
|
+
const { providers: { createLocalStrapiDestinationProvider, DEFAULT_CONFLICT_STRATEGY } } = strapi$1;
|
|
9
|
+
const { createTransferEngine, DEFAULT_VERSION_STRATEGY, DEFAULT_SCHEMA_STRATEGY } = engine;
|
|
10
|
+
/**
|
|
11
|
+
* Import command.
|
|
12
|
+
*
|
|
13
|
+
* It transfers data from a file to a local Strapi instance
|
|
14
|
+
*/ var action = (async (opts)=>{
|
|
15
|
+
// validate inputs from Commander
|
|
16
|
+
if (!isObject(opts)) {
|
|
17
|
+
exitWith(1, 'Could not parse arguments');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* From strapi backup file
|
|
21
|
+
*/ const sourceOptions = getLocalFileSourceOptions(opts);
|
|
22
|
+
const source = createLocalFileSourceProvider(sourceOptions);
|
|
23
|
+
/**
|
|
24
|
+
* To local Strapi instance
|
|
25
|
+
*/ const strapiInstance = await createStrapiInstance();
|
|
26
|
+
/**
|
|
27
|
+
* Configure and run the transfer engine
|
|
28
|
+
*/ const engineOptions = {
|
|
29
|
+
versionStrategy: DEFAULT_VERSION_STRATEGY,
|
|
30
|
+
schemaStrategy: DEFAULT_SCHEMA_STRATEGY,
|
|
31
|
+
exclude: opts.exclude,
|
|
32
|
+
only: opts.only,
|
|
33
|
+
throttle: opts.throttle,
|
|
34
|
+
transforms: {
|
|
35
|
+
links: [
|
|
36
|
+
{
|
|
37
|
+
filter (link) {
|
|
38
|
+
return !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.left.type) && !DEFAULT_IGNORED_CONTENT_TYPES.includes(link.right.type);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
entities: [
|
|
43
|
+
{
|
|
44
|
+
filter: (entity)=>!DEFAULT_IGNORED_CONTENT_TYPES.includes(entity.type)
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const destinationOptions = {
|
|
50
|
+
async getStrapi () {
|
|
51
|
+
return strapiInstance;
|
|
52
|
+
},
|
|
53
|
+
autoDestroy: false,
|
|
54
|
+
strategy: opts.conflictStrategy || DEFAULT_CONFLICT_STRATEGY,
|
|
55
|
+
restore: parseRestoreFromOptions(engineOptions)
|
|
56
|
+
};
|
|
57
|
+
const destination = createLocalStrapiDestinationProvider(destinationOptions);
|
|
58
|
+
destination.onWarning = (message)=>console.warn(`\n${chalk.yellow('warn')}: ${message}`);
|
|
59
|
+
const engine = createTransferEngine(source, destination, engineOptions);
|
|
60
|
+
engine.diagnostics.onDiagnostic(formatDiagnostic('import', opts.verbose));
|
|
61
|
+
const progress = engine.progress.stream;
|
|
62
|
+
const { updateLoader } = loadersFactory();
|
|
63
|
+
engine.onSchemaDiff(getDiffHandler(engine, {
|
|
64
|
+
force: opts.force,
|
|
65
|
+
action: 'import'
|
|
66
|
+
}));
|
|
67
|
+
progress.on(`stage::start`, ({ stage, data })=>{
|
|
68
|
+
updateLoader(stage, data).start();
|
|
69
|
+
});
|
|
70
|
+
progress.on('stage::finish', ({ stage, data })=>{
|
|
71
|
+
updateLoader(stage, data).succeed();
|
|
72
|
+
});
|
|
73
|
+
progress.on('stage::progress', ({ stage, data })=>{
|
|
74
|
+
updateLoader(stage, data);
|
|
75
|
+
});
|
|
76
|
+
progress.on('transfer::start', async ()=>{
|
|
77
|
+
console.log('Starting import...');
|
|
78
|
+
await strapiInstance.telemetry.send('didDEITSProcessStart', getTransferTelemetryPayload(engine));
|
|
79
|
+
});
|
|
80
|
+
let results;
|
|
81
|
+
try {
|
|
82
|
+
// Abort transfer if user interrupts process
|
|
83
|
+
setSignalHandler(()=>abortTransfer({
|
|
84
|
+
engine,
|
|
85
|
+
strapi: strapi
|
|
86
|
+
}));
|
|
87
|
+
results = await engine.transfer();
|
|
88
|
+
try {
|
|
89
|
+
const table = buildTransferTable(results.engine);
|
|
90
|
+
console.log(table?.toString());
|
|
91
|
+
} catch (e) {
|
|
92
|
+
console.error('There was an error displaying the results of the transfer.');
|
|
93
|
+
}
|
|
94
|
+
// Note: we need to await telemetry or else the process ends before it is sent
|
|
95
|
+
await strapiInstance.telemetry.send('didDEITSProcessFinish', getTransferTelemetryPayload(engine));
|
|
96
|
+
await strapiInstance.destroy();
|
|
97
|
+
exitWith(0, exitMessageText('import'));
|
|
98
|
+
} catch (e) {
|
|
99
|
+
await strapiInstance.telemetry.send('didDEITSProcessFail', getTransferTelemetryPayload(engine));
|
|
100
|
+
exitWith(1, exitMessageText('import', true));
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* Infer local file source provider options based on a given filename
|
|
105
|
+
*/ const getLocalFileSourceOptions = (opts)=>{
|
|
106
|
+
const options = {
|
|
107
|
+
file: {
|
|
108
|
+
path: opts.file ?? ''
|
|
109
|
+
},
|
|
110
|
+
compression: {
|
|
111
|
+
enabled: !!opts.decompress
|
|
112
|
+
},
|
|
113
|
+
encryption: {
|
|
114
|
+
enabled: !!opts.decrypt,
|
|
115
|
+
key: opts.key
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return options;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export { action as default };
|
|
122
|
+
//# sourceMappingURL=action.mjs.map
|