@strapi/strapi 5.31.2 → 5.31.3
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/commands/transfer/command.d.ts.map +1 -1
- package/dist/package.json.js +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/cli/commands/transfer/command.js +7 -6
- package/dist/src/cli/commands/transfer/command.js.map +1 -1
- package/dist/src/cli/commands/transfer/command.mjs +7 -6
- package/dist/src/cli/commands/transfer/command.mjs.map +1 -1
- package/package.json +22 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/transfer/command.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,QAAA,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/transfer/command.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,QAAA,MAAM,OAAO,mCAwOZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/package.json.js
CHANGED
package/dist/package.json.mjs
CHANGED
|
@@ -10,7 +10,8 @@ var action = require('./action.js');
|
|
|
10
10
|
/**
|
|
11
11
|
* `$ strapi transfer`
|
|
12
12
|
*/ const command = ()=>{
|
|
13
|
-
return commander.createCommand('transfer').description('Transfer data from one source to another').allowExcessArguments(false).addOption(new commander.Option('--from <sourceURL>', `URL of the remote Strapi instance to get data from`).argParser(commander$1.parseURL)).addOption(new commander.Option('--from-token <token>', `Transfer token for the remote Strapi source`)).addOption(new commander.Option('--to <destinationURL>', `URL of the remote Strapi instance to send data to`).argParser(commander$1.parseURL)).addOption(new commander.Option('--to-token <token>', `Transfer token for the remote Strapi destination`)).addOption(new commander.Option('--verbose', 'Enable verbose logs')).addOption(commander$1.forceOption).addOption(dataTransfer.excludeOption).addOption(dataTransfer.onlyOption).addOption(dataTransfer.throttleOption).hook('preAction', dataTransfer.validateExcludeOnly).hook('preAction', helpers.ifOptions((opts)=>opts.from && opts.to || opts.from && opts.toToken || opts.to && opts.fromToken, async ()=>helpers.exitWith(1, 'Only one remote source (from) or destination (to) option may be provided'))).hook('preAction',
|
|
13
|
+
return commander.createCommand('transfer').description('Transfer data from one source to another').allowExcessArguments(false).addOption(new commander.Option('--from <sourceURL>', `URL of the remote Strapi instance to get data from`).argParser(commander$1.parseURL)).addOption(new commander.Option('--from-token <token>', `Transfer token for the remote Strapi source`)).addOption(new commander.Option('--to <destinationURL>', `URL of the remote Strapi instance to send data to`).argParser(commander$1.parseURL)).addOption(new commander.Option('--to-token <token>', `Transfer token for the remote Strapi destination`)).addOption(new commander.Option('--verbose', 'Enable verbose logs')).addOption(commander$1.forceOption).addOption(dataTransfer.excludeOption).addOption(dataTransfer.onlyOption).addOption(dataTransfer.throttleOption).hook('preAction', dataTransfer.validateExcludeOnly).hook('preAction', helpers.ifOptions(async (opts)=>opts.from && opts.to || opts.from && opts.toToken || opts.to && opts.fromToken, async ()=>helpers.exitWith(1, 'Only one remote source (from) or destination (to) option may be provided'))).hook('preAction', helpers.ifOptions(// Only run interactive prompts if neither --from nor --to is provided
|
|
14
|
+
async (opts)=>!opts.from && !opts.to, async (thisCommand)=>{
|
|
14
15
|
const opts = thisCommand.opts();
|
|
15
16
|
const hasEnvUrl = process.env.STRAPI_TRANSFER_URL;
|
|
16
17
|
const hasEnvToken = process.env.STRAPI_TRANSFER_TOKEN;
|
|
@@ -39,10 +40,10 @@ var action = require('./action.js');
|
|
|
39
40
|
}
|
|
40
41
|
logEnvironmentVariables();
|
|
41
42
|
if (opts.from) {
|
|
42
|
-
return
|
|
43
|
+
return 'from';
|
|
43
44
|
}
|
|
44
45
|
if (opts.to) {
|
|
45
|
-
return
|
|
46
|
+
return 'to';
|
|
46
47
|
}
|
|
47
48
|
const { dir } = await inquirer.prompt([
|
|
48
49
|
{
|
|
@@ -120,8 +121,8 @@ var action = require('./action.js');
|
|
|
120
121
|
const direction = await determineDirection();
|
|
121
122
|
opts[direction] = await determineUrl(direction);
|
|
122
123
|
opts[`${direction}Token`] = await determineToken(direction);
|
|
123
|
-
})// If --from is used, validate the URL and token
|
|
124
|
-
.hook('preAction', helpers.ifOptions((opts)=>opts.from, async (thisCommand)=>{
|
|
124
|
+
}))// If --from is used, validate the URL and token
|
|
125
|
+
.hook('preAction', helpers.ifOptions(async (opts)=>opts.from, async (thisCommand)=>{
|
|
125
126
|
helpers.assertUrlHasProtocol(thisCommand.opts().from, [
|
|
126
127
|
'https:',
|
|
127
128
|
'http:'
|
|
@@ -143,7 +144,7 @@ var action = require('./action.js');
|
|
|
143
144
|
failMessage: 'Transfer process aborted'
|
|
144
145
|
})(thisCommand);
|
|
145
146
|
}))// If --to is used, validate the URL, token, and confirm restore
|
|
146
|
-
.hook('preAction', helpers.ifOptions((opts)=>opts.to, async (thisCommand)=>{
|
|
147
|
+
.hook('preAction', helpers.ifOptions(async (opts)=>opts.to, async (thisCommand)=>{
|
|
147
148
|
helpers.assertUrlHasProtocol(thisCommand.opts().to, [
|
|
148
149
|
'https:',
|
|
149
150
|
'http:'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sources":["../../../../../src/cli/commands/transfer/command.ts"],"sourcesContent":["import inquirer from 'inquirer';\nimport { createCommand, Option } from 'commander';\nimport { getCommanderConfirmMessage, forceOption, parseURL } from '../../utils/commander';\nimport { exitWith, assertUrlHasProtocol, ifOptions } from '../../utils/helpers';\nimport {\n excludeOption,\n onlyOption,\n throttleOption,\n validateExcludeOnly,\n} from '../../utils/data-transfer';\n\nimport action from './action';\n\n/**\n * `$ strapi transfer`\n */\nconst command = () => {\n return (\n createCommand('transfer')\n .description('Transfer data from one source to another')\n .allowExcessArguments(false)\n .addOption(\n new Option(\n '--from <sourceURL>',\n `URL of the remote Strapi instance to get data from`\n ).argParser(parseURL)\n )\n .addOption(new Option('--from-token <token>', `Transfer token for the remote Strapi source`))\n .addOption(\n new Option(\n '--to <destinationURL>',\n `URL of the remote Strapi instance to send data to`\n ).argParser(parseURL)\n )\n\n .addOption(\n new Option('--to-token <token>', `Transfer token for the remote Strapi destination`)\n )\n .addOption(new Option('--verbose', 'Enable verbose logs'))\n .addOption(forceOption)\n .addOption(excludeOption)\n .addOption(onlyOption)\n .addOption(throttleOption)\n .hook('preAction', validateExcludeOnly)\n .hook(\n 'preAction',\n ifOptions(\n (opts) =>\n (opts.from && opts.to) || (opts.from && opts.toToken) || (opts.to && opts.fromToken),\n async () =>\n exitWith(1, 'Only one remote source (from) or destination (to) option may be provided')\n )\n )\n .hook('preAction', async (thisCommand) => {\n const opts = thisCommand.opts();\n const hasEnvUrl = process.env.STRAPI_TRANSFER_URL;\n const hasEnvToken = process.env.STRAPI_TRANSFER_TOKEN;\n\n const logDocumentation = () => {\n console.info(\n 'ℹ️ Data transfer documentation: https://docs.strapi.io/dev-docs/data-management/transfer'\n );\n };\n\n const logEnvironmentVariables = () => {\n if (!hasEnvUrl && !hasEnvToken) {\n console.info('ℹ️ No transfer configuration found in environment variables');\n console.info(\n ' → Add STRAPI_TRANSFER_URL and STRAPI_TRANSFER_TOKEN environment variables to make the transfer process faster for future runs'\n );\n return;\n }\n\n console.info('ℹ️ Found transfer configuration in your environment:');\n\n if (hasEnvUrl) {\n console.info(\n ` → Environment STRAPI_TRANSFER_URL (${hasEnvUrl}) will be used as the transfer URL`\n );\n }\n\n if (hasEnvToken) {\n console.info(\n ' → Environment STRAPI_TRANSFER_TOKEN value will be used as the transfer token'\n );\n }\n\n console.info(); // Empty line for better readability\n };\n\n const determineDirection = async () => {\n // If user has not provided a direction from CLI, log the documentation\n if (!opts.from && !opts.to) {\n logDocumentation();\n }\n\n logEnvironmentVariables();\n\n if (opts.from) {\n return opts.from;\n }\n if (opts.to) {\n return opts.to;\n }\n\n const { dir } = await inquirer.prompt([\n {\n type: 'list',\n name: 'dir',\n message: 'Choose transfer direction:',\n choices: [\n { name: 'Pull data from remote Strapi to local', value: 'from' },\n { name: 'Push local data to remote Strapi', value: 'to' },\n ],\n },\n ]);\n\n return dir;\n };\n\n const determineUrl = async (direction: 'from' | 'to') => {\n if (opts[direction]) {\n return new URL(opts[direction]);\n }\n\n if (process.env.STRAPI_TRANSFER_URL) {\n return new URL(process.env.STRAPI_TRANSFER_URL);\n }\n\n const answer = await inquirer.prompt([\n {\n type: 'input',\n name: 'remoteUrl',\n message: `Enter the URL of the remote Strapi instance to ${direction === 'from' ? 'get data from' : 'send data to'}:`,\n default: process.env.STRAPI_TRANSFER_URL,\n validate(input: string) {\n try {\n const url = new URL(input);\n if (!['http:', 'https:'].includes(url.protocol)) {\n return 'URL must use http: or https: protocol';\n }\n return true;\n } catch (error) {\n return 'Please enter a valid URL (e.g., http://localhost:1337/admin or https://example.com/admin)';\n }\n },\n },\n ]);\n\n return new URL(answer.remoteUrl);\n };\n\n const determineToken = async (direction: 'from' | 'to') => {\n if (opts[`${direction}Token`]) {\n return opts[`${direction}Token`];\n }\n\n if (process.env.STRAPI_TRANSFER_TOKEN) {\n return process.env.STRAPI_TRANSFER_TOKEN;\n }\n\n const answer = await inquirer.prompt([\n {\n type: 'password',\n name: 'token',\n message: `Enter the transfer token for the remote Strapi ${direction === 'from' ? 'source' : 'destination'}:`,\n default: process.env.STRAPI_TRANSFER_TOKEN,\n validate(input: string) {\n if (!input?.length) {\n return 'Transfer token is required';\n }\n return true;\n },\n },\n ]);\n\n return answer.token;\n };\n\n const direction = await determineDirection();\n opts[direction] = await determineUrl(direction);\n opts[`${direction}Token`] = await determineToken(direction);\n })\n // If --from is used, validate the URL and token\n .hook(\n 'preAction',\n ifOptions(\n (opts) => opts.from,\n async (thisCommand) => {\n assertUrlHasProtocol(thisCommand.opts().from, ['https:', 'http:']);\n if (!thisCommand.opts().fromToken) {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n message: 'Please enter your transfer token for the remote Strapi source',\n name: 'fromToken',\n },\n ]);\n if (!answers.fromToken?.length) {\n exitWith(1, 'No token provided for remote source, aborting transfer.');\n }\n thisCommand.opts().fromToken = answers.fromToken;\n }\n\n await getCommanderConfirmMessage(\n 'The transfer will delete all the local Strapi assets and its database. Are you sure you want to proceed?',\n { failMessage: 'Transfer process aborted' }\n )(thisCommand);\n }\n )\n )\n // If --to is used, validate the URL, token, and confirm restore\n .hook(\n 'preAction',\n ifOptions(\n (opts) => opts.to,\n async (thisCommand) => {\n assertUrlHasProtocol(thisCommand.opts().to, ['https:', 'http:']);\n if (!thisCommand.opts().toToken) {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n message: 'Please enter your transfer token for the remote Strapi destination',\n name: 'toToken',\n },\n ]);\n if (!answers.toToken?.length) {\n exitWith(1, 'No token provided for remote destination, aborting transfer.');\n }\n thisCommand.opts().toToken = answers.toToken;\n }\n\n await getCommanderConfirmMessage(\n 'The transfer will delete existing data from the remote Strapi! Are you sure you want to proceed?',\n { failMessage: 'Transfer process aborted' }\n )(thisCommand);\n }\n )\n )\n .action(action)\n );\n};\n\nexport default command;\n"],"names":["command","createCommand","description","allowExcessArguments","addOption","Option","argParser","parseURL","forceOption","excludeOption","onlyOption","throttleOption","hook","validateExcludeOnly","ifOptions","opts","from","to","toToken","fromToken","exitWith","thisCommand","hasEnvUrl","process","env","STRAPI_TRANSFER_URL","hasEnvToken","STRAPI_TRANSFER_TOKEN","logDocumentation","console","info","logEnvironmentVariables","determineDirection","dir","inquirer","prompt","type","name","message","choices","value","determineUrl","direction","URL","answer","default","validate","input","url","includes","protocol","error","remoteUrl","determineToken","length","token","assertUrlHasProtocol","answers","getCommanderConfirmMessage","failMessage","action"],"mappings":";;;;;;;;;AAaA;;AAEC,UACKA,OAAU,GAAA,IAAA;IACd,OACEC,uBAAAA,CAAc,YACXC,WAAW,CAAC,4CACZC,oBAAoB,CAAC,KACrBC,CAAAA,CAAAA,SAAS,CACR,IAAIC,iBACF,oBACA,EAAA,CAAC,kDAAkD,CAAC,CACpDC,CAAAA,SAAS,CAACC,oBAEbH,CAAAA,CAAAA,CAAAA,SAAS,CAAC,I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["../../../../../src/cli/commands/transfer/command.ts"],"sourcesContent":["import inquirer from 'inquirer';\nimport { createCommand, Option } from 'commander';\nimport { getCommanderConfirmMessage, forceOption, parseURL } from '../../utils/commander';\nimport { exitWith, assertUrlHasProtocol, ifOptions } from '../../utils/helpers';\nimport {\n excludeOption,\n onlyOption,\n throttleOption,\n validateExcludeOnly,\n} from '../../utils/data-transfer';\n\nimport action from './action';\n\n/**\n * `$ strapi transfer`\n */\nconst command = () => {\n return (\n createCommand('transfer')\n .description('Transfer data from one source to another')\n .allowExcessArguments(false)\n .addOption(\n new Option(\n '--from <sourceURL>',\n `URL of the remote Strapi instance to get data from`\n ).argParser(parseURL)\n )\n .addOption(new Option('--from-token <token>', `Transfer token for the remote Strapi source`))\n .addOption(\n new Option(\n '--to <destinationURL>',\n `URL of the remote Strapi instance to send data to`\n ).argParser(parseURL)\n )\n\n .addOption(\n new Option('--to-token <token>', `Transfer token for the remote Strapi destination`)\n )\n .addOption(new Option('--verbose', 'Enable verbose logs'))\n .addOption(forceOption)\n .addOption(excludeOption)\n .addOption(onlyOption)\n .addOption(throttleOption)\n .hook('preAction', validateExcludeOnly)\n .hook(\n 'preAction',\n ifOptions(\n async (opts) =>\n (opts.from && opts.to) || (opts.from && opts.toToken) || (opts.to && opts.fromToken),\n async () =>\n exitWith(1, 'Only one remote source (from) or destination (to) option may be provided')\n )\n )\n .hook(\n 'preAction',\n ifOptions(\n // Only run interactive prompts if neither --from nor --to is provided\n async (opts) => !opts.from && !opts.to,\n async (thisCommand) => {\n const opts = thisCommand.opts();\n const hasEnvUrl = process.env.STRAPI_TRANSFER_URL;\n const hasEnvToken = process.env.STRAPI_TRANSFER_TOKEN;\n\n const logDocumentation = () => {\n console.info(\n 'ℹ️ Data transfer documentation: https://docs.strapi.io/dev-docs/data-management/transfer'\n );\n };\n\n const logEnvironmentVariables = () => {\n if (!hasEnvUrl && !hasEnvToken) {\n console.info('ℹ️ No transfer configuration found in environment variables');\n console.info(\n ' → Add STRAPI_TRANSFER_URL and STRAPI_TRANSFER_TOKEN environment variables to make the transfer process faster for future runs'\n );\n return;\n }\n\n console.info('ℹ️ Found transfer configuration in your environment:');\n\n if (hasEnvUrl) {\n console.info(\n ` → Environment STRAPI_TRANSFER_URL (${hasEnvUrl}) will be used as the transfer URL`\n );\n }\n\n if (hasEnvToken) {\n console.info(\n ' → Environment STRAPI_TRANSFER_TOKEN value will be used as the transfer token'\n );\n }\n\n console.info(); // Empty line for better readability\n };\n\n const determineDirection = async () => {\n // If user has not provided a direction from CLI, log the documentation\n if (!opts.from && !opts.to) {\n logDocumentation();\n }\n\n logEnvironmentVariables();\n\n if (opts.from) {\n return 'from';\n }\n if (opts.to) {\n return 'to';\n }\n\n const { dir } = await inquirer.prompt([\n {\n type: 'list',\n name: 'dir',\n message: 'Choose transfer direction:',\n choices: [\n { name: 'Pull data from remote Strapi to local', value: 'from' },\n { name: 'Push local data to remote Strapi', value: 'to' },\n ],\n },\n ]);\n\n return dir;\n };\n\n const determineUrl = async (direction: 'from' | 'to') => {\n if (opts[direction]) {\n return new URL(opts[direction]);\n }\n\n if (process.env.STRAPI_TRANSFER_URL) {\n return new URL(process.env.STRAPI_TRANSFER_URL);\n }\n\n const answer = await inquirer.prompt([\n {\n type: 'input',\n name: 'remoteUrl',\n message: `Enter the URL of the remote Strapi instance to ${direction === 'from' ? 'get data from' : 'send data to'}:`,\n default: process.env.STRAPI_TRANSFER_URL,\n validate(input: string) {\n try {\n const url = new URL(input);\n if (!['http:', 'https:'].includes(url.protocol)) {\n return 'URL must use http: or https: protocol';\n }\n return true;\n } catch (error) {\n return 'Please enter a valid URL (e.g., http://localhost:1337/admin or https://example.com/admin)';\n }\n },\n },\n ]);\n\n return new URL(answer.remoteUrl);\n };\n\n const determineToken = async (direction: 'from' | 'to') => {\n if (opts[`${direction}Token`]) {\n return opts[`${direction}Token`];\n }\n\n if (process.env.STRAPI_TRANSFER_TOKEN) {\n return process.env.STRAPI_TRANSFER_TOKEN;\n }\n\n const answer = await inquirer.prompt([\n {\n type: 'password',\n name: 'token',\n message: `Enter the transfer token for the remote Strapi ${direction === 'from' ? 'source' : 'destination'}:`,\n default: process.env.STRAPI_TRANSFER_TOKEN,\n validate(input: string) {\n if (!input?.length) {\n return 'Transfer token is required';\n }\n return true;\n },\n },\n ]);\n\n return answer.token;\n };\n\n const direction = await determineDirection();\n opts[direction] = await determineUrl(direction);\n opts[`${direction}Token`] = await determineToken(direction);\n }\n )\n )\n // If --from is used, validate the URL and token\n .hook(\n 'preAction',\n ifOptions(\n async (opts) => opts.from,\n async (thisCommand) => {\n assertUrlHasProtocol(thisCommand.opts().from, ['https:', 'http:']);\n if (!thisCommand.opts().fromToken) {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n message: 'Please enter your transfer token for the remote Strapi source',\n name: 'fromToken',\n },\n ]);\n if (!answers.fromToken?.length) {\n exitWith(1, 'No token provided for remote source, aborting transfer.');\n }\n thisCommand.opts().fromToken = answers.fromToken;\n }\n\n await getCommanderConfirmMessage(\n 'The transfer will delete all the local Strapi assets and its database. Are you sure you want to proceed?',\n { failMessage: 'Transfer process aborted' }\n )(thisCommand);\n }\n )\n )\n // If --to is used, validate the URL, token, and confirm restore\n .hook(\n 'preAction',\n ifOptions(\n async (opts) => opts.to,\n async (thisCommand) => {\n assertUrlHasProtocol(thisCommand.opts().to, ['https:', 'http:']);\n if (!thisCommand.opts().toToken) {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n message: 'Please enter your transfer token for the remote Strapi destination',\n name: 'toToken',\n },\n ]);\n if (!answers.toToken?.length) {\n exitWith(1, 'No token provided for remote destination, aborting transfer.');\n }\n thisCommand.opts().toToken = answers.toToken;\n }\n\n await getCommanderConfirmMessage(\n 'The transfer will delete existing data from the remote Strapi! Are you sure you want to proceed?',\n { failMessage: 'Transfer process aborted' }\n )(thisCommand);\n }\n )\n )\n .action(action)\n );\n};\n\nexport default command;\n"],"names":["command","createCommand","description","allowExcessArguments","addOption","Option","argParser","parseURL","forceOption","excludeOption","onlyOption","throttleOption","hook","validateExcludeOnly","ifOptions","opts","from","to","toToken","fromToken","exitWith","thisCommand","hasEnvUrl","process","env","STRAPI_TRANSFER_URL","hasEnvToken","STRAPI_TRANSFER_TOKEN","logDocumentation","console","info","logEnvironmentVariables","determineDirection","dir","inquirer","prompt","type","name","message","choices","value","determineUrl","direction","URL","answer","default","validate","input","url","includes","protocol","error","remoteUrl","determineToken","length","token","assertUrlHasProtocol","answers","getCommanderConfirmMessage","failMessage","action"],"mappings":";;;;;;;;;AAaA;;AAEC,UACKA,OAAU,GAAA,IAAA;IACd,OACEC,uBAAAA,CAAc,YACXC,WAAW,CAAC,4CACZC,oBAAoB,CAAC,KACrBC,CAAAA,CAAAA,SAAS,CACR,IAAIC,iBACF,oBACA,EAAA,CAAC,kDAAkD,CAAC,CACpDC,CAAAA,SAAS,CAACC,oBAEbH,CAAAA,CAAAA,CAAAA,SAAS,CAAC,IAAIC,gBAAO,CAAA,sBAAA,EAAwB,CAAC,2CAA2C,CAAC,GAC1FD,SAAS,CACR,IAAIC,gBACF,CAAA,uBAAA,EACA,CAAC,iDAAiD,CAAC,CAAA,CACnDC,SAAS,CAACC,oBAAAA,CAAAA,CAAAA,CAGbH,SAAS,CACR,IAAIC,gBAAAA,CAAO,sBAAsB,CAAC,gDAAgD,CAAC,CAAA,CAAA,CAEpFD,SAAS,CAAC,IAAIC,gBAAO,CAAA,WAAA,EAAa,wBAClCD,SAAS,CAACI,yBACVJ,SAAS,CAACK,0BACVL,CAAAA,CAAAA,SAAS,CAACM,uBAAAA,CAAAA,CACVN,SAAS,CAACO,2BAAAA,CAAAA,CACVC,IAAI,CAAC,WAAaC,EAAAA,gCAAAA,CAAAA,CAClBD,IAAI,CACH,WAAA,EACAE,iBACE,CAAA,OAAOC,IACL,GAACA,KAAKC,IAAI,IAAID,IAAKE,CAAAA,EAAE,IAAMF,IAAAA,CAAKC,IAAI,IAAID,IAAAA,CAAKG,OAAO,IAAMH,IAAKE,CAAAA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QAAA,IAAI,CAACI,WAAAA,CAAYN,IAAI,EAAA,CAAGG,OAAO,EAAE;AAC/B,YAAA,MAAMuC,OAAU,GAAA,MAAMvB,QAASC,CAAAA,MAAM,CAAC;AACpC,gBAAA;oBACEC,IAAM,EAAA,UAAA;oBACNE,OAAS,EAAA,oEAAA;oBACTD,IAAM,EAAA;AACR;AACD,aAAA,CAAA;AACD,YAAA,IAAI,CAACoB,OAAAA,CAAQvC,OAAO,EAAEoC,MAAQ,EAAA;AAC5BlC,gBAAAA,gBAAAA,CAAS,CAAG,EAAA,8DAAA,CAAA;AACd;AACAC,YAAAA,WAAAA,CAAYN,IAAI,EAAA,CAAGG,OAAO,GAAGuC,QAAQvC,OAAO;AAC9C;AAEA,QAAA,MAAMwC,uCACJ,kGACA,EAAA;YAAEC,WAAa,EAAA;SACftC,CAAAA,CAAAA,WAAAA,CAAAA;AACJ,KAAA,CAAA,CAAA,CAGHuC,MAAM,CAACA,MAAAA,CAAAA;AAEd;;;;"}
|
|
@@ -8,7 +8,8 @@ import action from './action.mjs';
|
|
|
8
8
|
/**
|
|
9
9
|
* `$ strapi transfer`
|
|
10
10
|
*/ const command = ()=>{
|
|
11
|
-
return createCommand('transfer').description('Transfer data from one source to another').allowExcessArguments(false).addOption(new Option('--from <sourceURL>', `URL of the remote Strapi instance to get data from`).argParser(parseURL)).addOption(new Option('--from-token <token>', `Transfer token for the remote Strapi source`)).addOption(new Option('--to <destinationURL>', `URL of the remote Strapi instance to send data to`).argParser(parseURL)).addOption(new Option('--to-token <token>', `Transfer token for the remote Strapi destination`)).addOption(new Option('--verbose', 'Enable verbose logs')).addOption(forceOption).addOption(excludeOption).addOption(onlyOption).addOption(throttleOption).hook('preAction', validateExcludeOnly).hook('preAction', ifOptions((opts)=>opts.from && opts.to || opts.from && opts.toToken || opts.to && opts.fromToken, async ()=>exitWith(1, 'Only one remote source (from) or destination (to) option may be provided'))).hook('preAction',
|
|
11
|
+
return createCommand('transfer').description('Transfer data from one source to another').allowExcessArguments(false).addOption(new Option('--from <sourceURL>', `URL of the remote Strapi instance to get data from`).argParser(parseURL)).addOption(new Option('--from-token <token>', `Transfer token for the remote Strapi source`)).addOption(new Option('--to <destinationURL>', `URL of the remote Strapi instance to send data to`).argParser(parseURL)).addOption(new Option('--to-token <token>', `Transfer token for the remote Strapi destination`)).addOption(new Option('--verbose', 'Enable verbose logs')).addOption(forceOption).addOption(excludeOption).addOption(onlyOption).addOption(throttleOption).hook('preAction', validateExcludeOnly).hook('preAction', ifOptions(async (opts)=>opts.from && opts.to || opts.from && opts.toToken || opts.to && opts.fromToken, async ()=>exitWith(1, 'Only one remote source (from) or destination (to) option may be provided'))).hook('preAction', ifOptions(// Only run interactive prompts if neither --from nor --to is provided
|
|
12
|
+
async (opts)=>!opts.from && !opts.to, async (thisCommand)=>{
|
|
12
13
|
const opts = thisCommand.opts();
|
|
13
14
|
const hasEnvUrl = process.env.STRAPI_TRANSFER_URL;
|
|
14
15
|
const hasEnvToken = process.env.STRAPI_TRANSFER_TOKEN;
|
|
@@ -37,10 +38,10 @@ import action from './action.mjs';
|
|
|
37
38
|
}
|
|
38
39
|
logEnvironmentVariables();
|
|
39
40
|
if (opts.from) {
|
|
40
|
-
return
|
|
41
|
+
return 'from';
|
|
41
42
|
}
|
|
42
43
|
if (opts.to) {
|
|
43
|
-
return
|
|
44
|
+
return 'to';
|
|
44
45
|
}
|
|
45
46
|
const { dir } = await inquirer.prompt([
|
|
46
47
|
{
|
|
@@ -118,8 +119,8 @@ import action from './action.mjs';
|
|
|
118
119
|
const direction = await determineDirection();
|
|
119
120
|
opts[direction] = await determineUrl(direction);
|
|
120
121
|
opts[`${direction}Token`] = await determineToken(direction);
|
|
121
|
-
})// If --from is used, validate the URL and token
|
|
122
|
-
.hook('preAction', ifOptions((opts)=>opts.from, async (thisCommand)=>{
|
|
122
|
+
}))// If --from is used, validate the URL and token
|
|
123
|
+
.hook('preAction', ifOptions(async (opts)=>opts.from, async (thisCommand)=>{
|
|
123
124
|
assertUrlHasProtocol(thisCommand.opts().from, [
|
|
124
125
|
'https:',
|
|
125
126
|
'http:'
|
|
@@ -141,7 +142,7 @@ import action from './action.mjs';
|
|
|
141
142
|
failMessage: 'Transfer process aborted'
|
|
142
143
|
})(thisCommand);
|
|
143
144
|
}))// If --to is used, validate the URL, token, and confirm restore
|
|
144
|
-
.hook('preAction', ifOptions((opts)=>opts.to, async (thisCommand)=>{
|
|
145
|
+
.hook('preAction', ifOptions(async (opts)=>opts.to, async (thisCommand)=>{
|
|
145
146
|
assertUrlHasProtocol(thisCommand.opts().to, [
|
|
146
147
|
'https:',
|
|
147
148
|
'http:'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.mjs","sources":["../../../../../src/cli/commands/transfer/command.ts"],"sourcesContent":["import inquirer from 'inquirer';\nimport { createCommand, Option } from 'commander';\nimport { getCommanderConfirmMessage, forceOption, parseURL } from '../../utils/commander';\nimport { exitWith, assertUrlHasProtocol, ifOptions } from '../../utils/helpers';\nimport {\n excludeOption,\n onlyOption,\n throttleOption,\n validateExcludeOnly,\n} from '../../utils/data-transfer';\n\nimport action from './action';\n\n/**\n * `$ strapi transfer`\n */\nconst command = () => {\n return (\n createCommand('transfer')\n .description('Transfer data from one source to another')\n .allowExcessArguments(false)\n .addOption(\n new Option(\n '--from <sourceURL>',\n `URL of the remote Strapi instance to get data from`\n ).argParser(parseURL)\n )\n .addOption(new Option('--from-token <token>', `Transfer token for the remote Strapi source`))\n .addOption(\n new Option(\n '--to <destinationURL>',\n `URL of the remote Strapi instance to send data to`\n ).argParser(parseURL)\n )\n\n .addOption(\n new Option('--to-token <token>', `Transfer token for the remote Strapi destination`)\n )\n .addOption(new Option('--verbose', 'Enable verbose logs'))\n .addOption(forceOption)\n .addOption(excludeOption)\n .addOption(onlyOption)\n .addOption(throttleOption)\n .hook('preAction', validateExcludeOnly)\n .hook(\n 'preAction',\n ifOptions(\n (opts) =>\n (opts.from && opts.to) || (opts.from && opts.toToken) || (opts.to && opts.fromToken),\n async () =>\n exitWith(1, 'Only one remote source (from) or destination (to) option may be provided')\n )\n )\n .hook('preAction', async (thisCommand) => {\n const opts = thisCommand.opts();\n const hasEnvUrl = process.env.STRAPI_TRANSFER_URL;\n const hasEnvToken = process.env.STRAPI_TRANSFER_TOKEN;\n\n const logDocumentation = () => {\n console.info(\n 'ℹ️ Data transfer documentation: https://docs.strapi.io/dev-docs/data-management/transfer'\n );\n };\n\n const logEnvironmentVariables = () => {\n if (!hasEnvUrl && !hasEnvToken) {\n console.info('ℹ️ No transfer configuration found in environment variables');\n console.info(\n ' → Add STRAPI_TRANSFER_URL and STRAPI_TRANSFER_TOKEN environment variables to make the transfer process faster for future runs'\n );\n return;\n }\n\n console.info('ℹ️ Found transfer configuration in your environment:');\n\n if (hasEnvUrl) {\n console.info(\n ` → Environment STRAPI_TRANSFER_URL (${hasEnvUrl}) will be used as the transfer URL`\n );\n }\n\n if (hasEnvToken) {\n console.info(\n ' → Environment STRAPI_TRANSFER_TOKEN value will be used as the transfer token'\n );\n }\n\n console.info(); // Empty line for better readability\n };\n\n const determineDirection = async () => {\n // If user has not provided a direction from CLI, log the documentation\n if (!opts.from && !opts.to) {\n logDocumentation();\n }\n\n logEnvironmentVariables();\n\n if (opts.from) {\n return opts.from;\n }\n if (opts.to) {\n return opts.to;\n }\n\n const { dir } = await inquirer.prompt([\n {\n type: 'list',\n name: 'dir',\n message: 'Choose transfer direction:',\n choices: [\n { name: 'Pull data from remote Strapi to local', value: 'from' },\n { name: 'Push local data to remote Strapi', value: 'to' },\n ],\n },\n ]);\n\n return dir;\n };\n\n const determineUrl = async (direction: 'from' | 'to') => {\n if (opts[direction]) {\n return new URL(opts[direction]);\n }\n\n if (process.env.STRAPI_TRANSFER_URL) {\n return new URL(process.env.STRAPI_TRANSFER_URL);\n }\n\n const answer = await inquirer.prompt([\n {\n type: 'input',\n name: 'remoteUrl',\n message: `Enter the URL of the remote Strapi instance to ${direction === 'from' ? 'get data from' : 'send data to'}:`,\n default: process.env.STRAPI_TRANSFER_URL,\n validate(input: string) {\n try {\n const url = new URL(input);\n if (!['http:', 'https:'].includes(url.protocol)) {\n return 'URL must use http: or https: protocol';\n }\n return true;\n } catch (error) {\n return 'Please enter a valid URL (e.g., http://localhost:1337/admin or https://example.com/admin)';\n }\n },\n },\n ]);\n\n return new URL(answer.remoteUrl);\n };\n\n const determineToken = async (direction: 'from' | 'to') => {\n if (opts[`${direction}Token`]) {\n return opts[`${direction}Token`];\n }\n\n if (process.env.STRAPI_TRANSFER_TOKEN) {\n return process.env.STRAPI_TRANSFER_TOKEN;\n }\n\n const answer = await inquirer.prompt([\n {\n type: 'password',\n name: 'token',\n message: `Enter the transfer token for the remote Strapi ${direction === 'from' ? 'source' : 'destination'}:`,\n default: process.env.STRAPI_TRANSFER_TOKEN,\n validate(input: string) {\n if (!input?.length) {\n return 'Transfer token is required';\n }\n return true;\n },\n },\n ]);\n\n return answer.token;\n };\n\n const direction = await determineDirection();\n opts[direction] = await determineUrl(direction);\n opts[`${direction}Token`] = await determineToken(direction);\n })\n // If --from is used, validate the URL and token\n .hook(\n 'preAction',\n ifOptions(\n (opts) => opts.from,\n async (thisCommand) => {\n assertUrlHasProtocol(thisCommand.opts().from, ['https:', 'http:']);\n if (!thisCommand.opts().fromToken) {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n message: 'Please enter your transfer token for the remote Strapi source',\n name: 'fromToken',\n },\n ]);\n if (!answers.fromToken?.length) {\n exitWith(1, 'No token provided for remote source, aborting transfer.');\n }\n thisCommand.opts().fromToken = answers.fromToken;\n }\n\n await getCommanderConfirmMessage(\n 'The transfer will delete all the local Strapi assets and its database. Are you sure you want to proceed?',\n { failMessage: 'Transfer process aborted' }\n )(thisCommand);\n }\n )\n )\n // If --to is used, validate the URL, token, and confirm restore\n .hook(\n 'preAction',\n ifOptions(\n (opts) => opts.to,\n async (thisCommand) => {\n assertUrlHasProtocol(thisCommand.opts().to, ['https:', 'http:']);\n if (!thisCommand.opts().toToken) {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n message: 'Please enter your transfer token for the remote Strapi destination',\n name: 'toToken',\n },\n ]);\n if (!answers.toToken?.length) {\n exitWith(1, 'No token provided for remote destination, aborting transfer.');\n }\n thisCommand.opts().toToken = answers.toToken;\n }\n\n await getCommanderConfirmMessage(\n 'The transfer will delete existing data from the remote Strapi! Are you sure you want to proceed?',\n { failMessage: 'Transfer process aborted' }\n )(thisCommand);\n }\n )\n )\n .action(action)\n );\n};\n\nexport default command;\n"],"names":["command","createCommand","description","allowExcessArguments","addOption","Option","argParser","parseURL","forceOption","excludeOption","onlyOption","throttleOption","hook","validateExcludeOnly","ifOptions","opts","from","to","toToken","fromToken","exitWith","thisCommand","hasEnvUrl","process","env","STRAPI_TRANSFER_URL","hasEnvToken","STRAPI_TRANSFER_TOKEN","logDocumentation","console","info","logEnvironmentVariables","determineDirection","dir","inquirer","prompt","type","name","message","choices","value","determineUrl","direction","URL","answer","default","validate","input","url","includes","protocol","error","remoteUrl","determineToken","length","token","assertUrlHasProtocol","answers","getCommanderConfirmMessage","failMessage","action"],"mappings":";;;;;;;AAaA;;AAEC,UACKA,OAAU,GAAA,IAAA;IACd,OACEC,aAAAA,CAAc,YACXC,WAAW,CAAC,4CACZC,oBAAoB,CAAC,KACrBC,CAAAA,CAAAA,SAAS,CACR,IAAIC,OACF,oBACA,EAAA,CAAC,kDAAkD,CAAC,CACpDC,CAAAA,SAAS,CAACC,QAEbH,CAAAA,CAAAA,CAAAA,SAAS,CAAC,IAAIC,MAAO,CAAA,sBAAA,EAAwB,CAAC,2CAA2C,CAAC,GAC1FD,SAAS,CACR,IAAIC,MACF,CAAA,uBAAA,EACA,CAAC,iDAAiD,CAAC,CAAA,CACnDC,SAAS,CAACC,QAAAA,CAAAA,CAAAA,CAGbH,SAAS,CACR,IAAIC,MAAAA,CAAO,sBAAsB,CAAC,gDAAgD,CAAC,CAAA,CAAA,CAEpFD,SAAS,CAAC,IAAIC,MAAO,CA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AAA,CAAAA,WAAAA,CAAAA;AACJ,KAAA,CAAA,CAGJ;KACCT,IAAI,CACH,aACAE,SACE,CAAA,CAACC,OAASA,IAAKE,CAAAA,EAAE,EACjB,OAAOI,WAAAA,GAAAA;AACLmC,QAAAA,oBAAAA,CAAqBnC,WAAYN,CAAAA,IAAI,EAAGE,CAAAA,EAAE,EAAE;AAAC,YAAA,QAAA;AAAU,YAAA;AAAQ,SAAA,CAAA;AAC/D,QAAA,IAAI,CAACI,WAAAA,CAAYN,IAAI,EAAA,CAAGG,OAAO,EAAE;AAC/B,YAAA,MAAMuC,OAAU,GAAA,MAAMvB,QAASC,CAAAA,MAAM,CAAC;AACpC,gBAAA;oBACEC,IAAM,EAAA,UAAA;oBACNE,OAAS,EAAA,oEAAA;oBACTD,IAAM,EAAA;AACR;AACD,aAAA,CAAA;AACD,YAAA,IAAI,CAACoB,OAAAA,CAAQvC,OAAO,EAAEoC,MAAQ,EAAA;AAC5BlC,gBAAAA,QAAAA,CAAS,CAAG,EAAA,8DAAA,CAAA;AACd;AACAC,YAAAA,WAAAA,CAAYN,IAAI,EAAA,CAAGG,OAAO,GAAGuC,QAAQvC,OAAO;AAC9C;AAEA,QAAA,MAAMwC,2BACJ,kGACA,EAAA;YAAEC,WAAa,EAAA;SACftC,CAAAA,CAAAA,WAAAA,CAAAA;AACJ,KAAA,CAAA,CAAA,CAGHuC,MAAM,CAACA,MAAAA,CAAAA;AAEd;;;;"}
|
|
1
|
+
{"version":3,"file":"command.mjs","sources":["../../../../../src/cli/commands/transfer/command.ts"],"sourcesContent":["import inquirer from 'inquirer';\nimport { createCommand, Option } from 'commander';\nimport { getCommanderConfirmMessage, forceOption, parseURL } from '../../utils/commander';\nimport { exitWith, assertUrlHasProtocol, ifOptions } from '../../utils/helpers';\nimport {\n excludeOption,\n onlyOption,\n throttleOption,\n validateExcludeOnly,\n} from '../../utils/data-transfer';\n\nimport action from './action';\n\n/**\n * `$ strapi transfer`\n */\nconst command = () => {\n return (\n createCommand('transfer')\n .description('Transfer data from one source to another')\n .allowExcessArguments(false)\n .addOption(\n new Option(\n '--from <sourceURL>',\n `URL of the remote Strapi instance to get data from`\n ).argParser(parseURL)\n )\n .addOption(new Option('--from-token <token>', `Transfer token for the remote Strapi source`))\n .addOption(\n new Option(\n '--to <destinationURL>',\n `URL of the remote Strapi instance to send data to`\n ).argParser(parseURL)\n )\n\n .addOption(\n new Option('--to-token <token>', `Transfer token for the remote Strapi destination`)\n )\n .addOption(new Option('--verbose', 'Enable verbose logs'))\n .addOption(forceOption)\n .addOption(excludeOption)\n .addOption(onlyOption)\n .addOption(throttleOption)\n .hook('preAction', validateExcludeOnly)\n .hook(\n 'preAction',\n ifOptions(\n async (opts) =>\n (opts.from && opts.to) || (opts.from && opts.toToken) || (opts.to && opts.fromToken),\n async () =>\n exitWith(1, 'Only one remote source (from) or destination (to) option may be provided')\n )\n )\n .hook(\n 'preAction',\n ifOptions(\n // Only run interactive prompts if neither --from nor --to is provided\n async (opts) => !opts.from && !opts.to,\n async (thisCommand) => {\n const opts = thisCommand.opts();\n const hasEnvUrl = process.env.STRAPI_TRANSFER_URL;\n const hasEnvToken = process.env.STRAPI_TRANSFER_TOKEN;\n\n const logDocumentation = () => {\n console.info(\n 'ℹ️ Data transfer documentation: https://docs.strapi.io/dev-docs/data-management/transfer'\n );\n };\n\n const logEnvironmentVariables = () => {\n if (!hasEnvUrl && !hasEnvToken) {\n console.info('ℹ️ No transfer configuration found in environment variables');\n console.info(\n ' → Add STRAPI_TRANSFER_URL and STRAPI_TRANSFER_TOKEN environment variables to make the transfer process faster for future runs'\n );\n return;\n }\n\n console.info('ℹ️ Found transfer configuration in your environment:');\n\n if (hasEnvUrl) {\n console.info(\n ` → Environment STRAPI_TRANSFER_URL (${hasEnvUrl}) will be used as the transfer URL`\n );\n }\n\n if (hasEnvToken) {\n console.info(\n ' → Environment STRAPI_TRANSFER_TOKEN value will be used as the transfer token'\n );\n }\n\n console.info(); // Empty line for better readability\n };\n\n const determineDirection = async () => {\n // If user has not provided a direction from CLI, log the documentation\n if (!opts.from && !opts.to) {\n logDocumentation();\n }\n\n logEnvironmentVariables();\n\n if (opts.from) {\n return 'from';\n }\n if (opts.to) {\n return 'to';\n }\n\n const { dir } = await inquirer.prompt([\n {\n type: 'list',\n name: 'dir',\n message: 'Choose transfer direction:',\n choices: [\n { name: 'Pull data from remote Strapi to local', value: 'from' },\n { name: 'Push local data to remote Strapi', value: 'to' },\n ],\n },\n ]);\n\n return dir;\n };\n\n const determineUrl = async (direction: 'from' | 'to') => {\n if (opts[direction]) {\n return new URL(opts[direction]);\n }\n\n if (process.env.STRAPI_TRANSFER_URL) {\n return new URL(process.env.STRAPI_TRANSFER_URL);\n }\n\n const answer = await inquirer.prompt([\n {\n type: 'input',\n name: 'remoteUrl',\n message: `Enter the URL of the remote Strapi instance to ${direction === 'from' ? 'get data from' : 'send data to'}:`,\n default: process.env.STRAPI_TRANSFER_URL,\n validate(input: string) {\n try {\n const url = new URL(input);\n if (!['http:', 'https:'].includes(url.protocol)) {\n return 'URL must use http: or https: protocol';\n }\n return true;\n } catch (error) {\n return 'Please enter a valid URL (e.g., http://localhost:1337/admin or https://example.com/admin)';\n }\n },\n },\n ]);\n\n return new URL(answer.remoteUrl);\n };\n\n const determineToken = async (direction: 'from' | 'to') => {\n if (opts[`${direction}Token`]) {\n return opts[`${direction}Token`];\n }\n\n if (process.env.STRAPI_TRANSFER_TOKEN) {\n return process.env.STRAPI_TRANSFER_TOKEN;\n }\n\n const answer = await inquirer.prompt([\n {\n type: 'password',\n name: 'token',\n message: `Enter the transfer token for the remote Strapi ${direction === 'from' ? 'source' : 'destination'}:`,\n default: process.env.STRAPI_TRANSFER_TOKEN,\n validate(input: string) {\n if (!input?.length) {\n return 'Transfer token is required';\n }\n return true;\n },\n },\n ]);\n\n return answer.token;\n };\n\n const direction = await determineDirection();\n opts[direction] = await determineUrl(direction);\n opts[`${direction}Token`] = await determineToken(direction);\n }\n )\n )\n // If --from is used, validate the URL and token\n .hook(\n 'preAction',\n ifOptions(\n async (opts) => opts.from,\n async (thisCommand) => {\n assertUrlHasProtocol(thisCommand.opts().from, ['https:', 'http:']);\n if (!thisCommand.opts().fromToken) {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n message: 'Please enter your transfer token for the remote Strapi source',\n name: 'fromToken',\n },\n ]);\n if (!answers.fromToken?.length) {\n exitWith(1, 'No token provided for remote source, aborting transfer.');\n }\n thisCommand.opts().fromToken = answers.fromToken;\n }\n\n await getCommanderConfirmMessage(\n 'The transfer will delete all the local Strapi assets and its database. Are you sure you want to proceed?',\n { failMessage: 'Transfer process aborted' }\n )(thisCommand);\n }\n )\n )\n // If --to is used, validate the URL, token, and confirm restore\n .hook(\n 'preAction',\n ifOptions(\n async (opts) => opts.to,\n async (thisCommand) => {\n assertUrlHasProtocol(thisCommand.opts().to, ['https:', 'http:']);\n if (!thisCommand.opts().toToken) {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n message: 'Please enter your transfer token for the remote Strapi destination',\n name: 'toToken',\n },\n ]);\n if (!answers.toToken?.length) {\n exitWith(1, 'No token provided for remote destination, aborting transfer.');\n }\n thisCommand.opts().toToken = answers.toToken;\n }\n\n await getCommanderConfirmMessage(\n 'The transfer will delete existing data from the remote Strapi! Are you sure you want to proceed?',\n { failMessage: 'Transfer process aborted' }\n )(thisCommand);\n }\n )\n )\n .action(action)\n );\n};\n\nexport default command;\n"],"names":["command","createCommand","description","allowExcessArguments","addOption","Option","argParser","parseURL","forceOption","excludeOption","onlyOption","throttleOption","hook","validateExcludeOnly","ifOptions","opts","from","to","toToken","fromToken","exitWith","thisCommand","hasEnvUrl","process","env","STRAPI_TRANSFER_URL","hasEnvToken","STRAPI_TRANSFER_TOKEN","logDocumentation","console","info","logEnvironmentVariables","determineDirection","dir","inquirer","prompt","type","name","message","choices","value","determineUrl","direction","URL","answer","default","validate","input","url","includes","protocol","error","remoteUrl","determineToken","length","token","assertUrlHasProtocol","answers","getCommanderConfirmMessage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AAA,CAAS,CAAG,EAAA,8DAAA,CAAA;AACd;AACAC,YAAAA,WAAAA,CAAYN,IAAI,EAAA,CAAGG,OAAO,GAAGuC,QAAQvC,OAAO;AAC9C;AAEA,QAAA,MAAMwC,2BACJ,kGACA,EAAA;YAAEC,WAAa,EAAA;SACftC,CAAAA,CAAAA,WAAAA,CAAAA;AACJ,KAAA,CAAA,CAAA,CAGHuC,MAAM,CAACA,MAAAA,CAAAA;AAEd;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "5.31.
|
|
3
|
+
"version": "5.31.3",
|
|
4
4
|
"description": "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",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -110,25 +110,25 @@
|
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
|
|
113
|
-
"@strapi/admin": "5.31.
|
|
114
|
-
"@strapi/cloud-cli": "5.31.
|
|
115
|
-
"@strapi/content-manager": "5.31.
|
|
116
|
-
"@strapi/content-releases": "5.31.
|
|
117
|
-
"@strapi/content-type-builder": "5.31.
|
|
118
|
-
"@strapi/core": "5.31.
|
|
119
|
-
"@strapi/data-transfer": "5.31.
|
|
120
|
-
"@strapi/database": "5.31.
|
|
121
|
-
"@strapi/email": "5.31.
|
|
122
|
-
"@strapi/generators": "5.31.
|
|
123
|
-
"@strapi/i18n": "5.31.
|
|
124
|
-
"@strapi/logger": "5.31.
|
|
125
|
-
"@strapi/openapi": "5.31.
|
|
126
|
-
"@strapi/permissions": "5.31.
|
|
127
|
-
"@strapi/review-workflows": "5.31.
|
|
128
|
-
"@strapi/types": "5.31.
|
|
129
|
-
"@strapi/typescript-utils": "5.31.
|
|
130
|
-
"@strapi/upload": "5.31.
|
|
131
|
-
"@strapi/utils": "5.31.
|
|
113
|
+
"@strapi/admin": "5.31.3",
|
|
114
|
+
"@strapi/cloud-cli": "5.31.3",
|
|
115
|
+
"@strapi/content-manager": "5.31.3",
|
|
116
|
+
"@strapi/content-releases": "5.31.3",
|
|
117
|
+
"@strapi/content-type-builder": "5.31.3",
|
|
118
|
+
"@strapi/core": "5.31.3",
|
|
119
|
+
"@strapi/data-transfer": "5.31.3",
|
|
120
|
+
"@strapi/database": "5.31.3",
|
|
121
|
+
"@strapi/email": "5.31.3",
|
|
122
|
+
"@strapi/generators": "5.31.3",
|
|
123
|
+
"@strapi/i18n": "5.31.3",
|
|
124
|
+
"@strapi/logger": "5.31.3",
|
|
125
|
+
"@strapi/openapi": "5.31.3",
|
|
126
|
+
"@strapi/permissions": "5.31.3",
|
|
127
|
+
"@strapi/review-workflows": "5.31.3",
|
|
128
|
+
"@strapi/types": "5.31.3",
|
|
129
|
+
"@strapi/typescript-utils": "5.31.3",
|
|
130
|
+
"@strapi/upload": "5.31.3",
|
|
131
|
+
"@strapi/utils": "5.31.3",
|
|
132
132
|
"@types/nodemon": "1.19.6",
|
|
133
133
|
"@vitejs/plugin-react-swc": "3.6.0",
|
|
134
134
|
"boxen": "5.1.2",
|
|
@@ -182,11 +182,11 @@
|
|
|
182
182
|
"@types/node": "24.10.0",
|
|
183
183
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
184
184
|
"@types/webpack-hot-middleware": "2.25.9",
|
|
185
|
-
"eslint-config-custom": "5.31.
|
|
185
|
+
"eslint-config-custom": "5.31.3",
|
|
186
186
|
"jest": "29.6.0",
|
|
187
187
|
"react": "18.3.1",
|
|
188
188
|
"react-dom": "18.3.1",
|
|
189
|
-
"tsconfig": "5.31.
|
|
189
|
+
"tsconfig": "5.31.3"
|
|
190
190
|
},
|
|
191
191
|
"peerDependencies": {
|
|
192
192
|
"react": "^17.0.0 || ^18.0.0",
|