diff --git a/.eslintrc.back.typescript.js b/.eslintrc.back.typescript.js index 0c6543c94e..a47ced9405 100644 --- a/.eslintrc.back.typescript.js +++ b/.eslintrc.back.typescript.js @@ -10,8 +10,8 @@ module.exports = { globals: { strapi: false, }, - // Instead of extending (which includes values that interfere with this configuration), only take the rules field rules: { + // Instead of extending (which includes values that interfere with this configuration), only take the rules field ...require('./.eslintrc.back.js').rules, 'import/no-extraneous-dependencies': ['error', { devDependencies: ['**/*.test.ts'] }], // TODO: The following rules from @strapi/eslint-config/typescript are disabled because they're causing problems we need to solve or fix diff --git a/.eslintrc.js b/.eslintrc.js index e2371ccd58..fb1f2fe344 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,8 +12,8 @@ module.exports = { ecmaVersion: 2020, }, overrides: [ + // Backend javascript { - // Backend javascript files: ['packages/**/*.js', 'test/**/*.js', 'scripts/**/*.js', 'jest.*.js'], excludedFiles: frontPaths, ...require('./.eslintrc.back.js'), diff --git a/packages/core/admin/server/register.js b/packages/core/admin/server/register.js index c5ec1046b6..ab84ebec02 100644 --- a/packages/core/admin/server/register.js +++ b/packages/core/admin/server/register.js @@ -1,6 +1,6 @@ 'use strict'; -const { register: registerDataTransferRoute } = require('@strapi/data-transfer/lib/strapi'); +// const { register: registerDataTransferRoute } = require('@strapi/data-transfer/lib/strapi'); const registerAdminPanelRoute = require('./routes/serve-admin-panel'); const adminAuthStrategy = require('./strategies/admin'); @@ -17,10 +17,10 @@ module.exports = ({ strapi }) => { registerAdminPanelRoute({ strapi }); } - if ( - process.env.STRAPI_EXPERIMENTAL === 'true' && - process.env.STRAPI_DISABLE_REMOTE_DATA_TRANSFER !== 'true' - ) { - registerDataTransferRoute(strapi); - } + // if ( + // process.env.STRAPI_EXPERIMENTAL === 'true' && + // process.env.STRAPI_DISABLE_REMOTE_DATA_TRANSFER !== 'true' + // ) { + // registerDataTransferRoute(strapi); + // } }; diff --git a/packages/core/data-transfer/src/__tests__/test-utils.ts b/packages/core/data-transfer/src/__tests__/test-utils.ts index 8a86e4b3e7..72ba3ee6c8 100644 --- a/packages/core/data-transfer/src/__tests__/test-utils.ts +++ b/packages/core/data-transfer/src/__tests__/test-utils.ts @@ -175,6 +175,7 @@ export const extendExpectForDataTransferTests = () => { const missing = destinationStages.filter((stage) => { if (provider[stage]) { try { + // TODO: why is mock.calls an empty array? maybe an async function call that doesn't resolve? // expect(provider[stage]).toHaveBeenCalledOnce(); expect(provider[stage].mock.results.length).toEqual(times); return false; diff --git a/packages/core/data-transfer/src/engine/__tests__/engine.test.ts b/packages/core/data-transfer/src/engine/__tests__/engine.test.ts index e54b9182ab..18bd83bfe9 100644 --- a/packages/core/data-transfer/src/engine/__tests__/engine.test.ts +++ b/packages/core/data-transfer/src/engine/__tests__/engine.test.ts @@ -99,16 +99,6 @@ const metadata = { createdAt: '2022-11-23T09:26:43.463Z', strapi: { version: '1.2.3', - plugins: [ - { - name: 'content-manager', - version: '1.2.3', - }, - { - name: 'content-type-builder', - version: '1.2.3', - }, - ], }, }; diff --git a/packages/core/data-transfer/src/engine/index.ts b/packages/core/data-transfer/src/engine/index.ts index 5d04e6f932..2787953bc7 100644 --- a/packages/core/data-transfer/src/engine/index.ts +++ b/packages/core/data-transfer/src/engine/index.ts @@ -476,9 +476,8 @@ class TransferEngine< stream .pipe(destination) .on('error', (e) => { - // TODO ? - // this.#reportError(e, 'error'); - // destination.destroy(e); + this.#reportError(e, 'error'); + destination.destroy(e); reject(e); }) .on('close', resolve); diff --git a/packages/core/data-transfer/src/strapi/providers/local-destination/index.ts b/packages/core/data-transfer/src/strapi/providers/local-destination/index.ts index 421c7659ba..a543c1bdf2 100644 --- a/packages/core/data-transfer/src/strapi/providers/local-destination/index.ts +++ b/packages/core/data-transfer/src/strapi/providers/local-destination/index.ts @@ -77,8 +77,8 @@ class LocalStrapiDestinationProvider implements IDestinationProvider { return restore.deleteRecords(this.strapi, this.options.restore); } - async rollback(e: Error): Promise { - await this.transaction?.rollback(); + rollback(): void { + this.transaction?.rollback(); } async beforeTransfer() { @@ -101,17 +101,10 @@ class LocalStrapiDestinationProvider implements IDestinationProvider { const strapiVersion = strapi.config.get('info.strapi'); const createdAt = new Date().toISOString(); - const plugins = Object.keys(strapi.plugins); - return { createdAt, strapi: { version: strapiVersion, - plugins: plugins.map((name) => ({ - name, - // TODO: Get the plugin actual version when it'll be available - version: strapiVersion, - })), }, }; } diff --git a/packages/core/data-transfer/src/strapi/providers/local-source/index.ts b/packages/core/data-transfer/src/strapi/providers/local-source/index.ts index b1401c967f..d7f66a0bf5 100644 --- a/packages/core/data-transfer/src/strapi/providers/local-source/index.ts +++ b/packages/core/data-transfer/src/strapi/providers/local-source/index.ts @@ -49,17 +49,10 @@ class LocalStrapiSourceProvider implements ISourceProvider { const strapiVersion = strapi.config.get('info.strapi'); const createdAt = new Date().toISOString(); - const plugins = Object.keys(strapi.plugins); - return { createdAt, strapi: { version: strapiVersion, - plugins: plugins.map((name) => ({ - name, - // TODO: Get the plugin actual version when it'll be available - version: strapiVersion, - })), }, }; } diff --git a/packages/core/data-transfer/src/strapi/remote/handlers.ts b/packages/core/data-transfer/src/strapi/remote/handlers.ts index f0d91dc144..f04c2e4fff 100644 --- a/packages/core/data-transfer/src/strapi/remote/handlers.ts +++ b/packages/core/data-transfer/src/strapi/remote/handlers.ts @@ -149,7 +149,7 @@ export const createTransferHandler = const { controller } = state; // TODO: (re)move this check - // It shouldn't be possible to strart a pull transfer for now, so reaching + // It shouldn't be possible to start a pull transfer for now, so reaching // this code should be impossible too, but this has been added by security if (state.transfer?.kind === 'pull') { return callback(new ProviderTransferError('Pull transfer not implemented')); diff --git a/packages/core/data-transfer/types/common-entities.d.ts b/packages/core/data-transfer/types/common-entities.d.ts index f473d97cab..4c682b49e2 100644 --- a/packages/core/data-transfer/types/common-entities.d.ts +++ b/packages/core/data-transfer/types/common-entities.d.ts @@ -5,11 +5,6 @@ import type { Readable } from 'stream'; export interface IMetadata { strapi?: { version?: string; - - plugins?: { - name: string; - version: string; - }[]; }; createdAt?: string; diff --git a/packages/core/strapi/bin/strapi.js b/packages/core/strapi/bin/strapi.js index 7550d02c0d..c6ee724c25 100755 --- a/packages/core/strapi/bin/strapi.js +++ b/packages/core/strapi/bin/strapi.js @@ -17,10 +17,9 @@ const packageJSON = require('../package.json'); const { promptEncryptionKey, confirmMessage, - parseURL, forceOption, } = require('../lib/commands/utils/commander'); -const { ifOptions, assertUrlHasProtocol, exitWith } = require('../lib/commands/utils/helpers'); +const { exitWith } = require('../lib/commands/utils/helpers'); const { excludeOption, onlyOption, @@ -269,59 +268,59 @@ program .option('-s, --silent', `Run the generation silently, without any output`, false) .action(getLocalScript('ts/generate-types')); -if (process.env.STRAPI_EXPERIMENTAL === 'true') { - // `$ strapi transfer` - program - .command('transfer') - .description('Transfer data from one source to another') - .allowExcessArguments(false) - .addOption( - new Option( - '--from ', - `URL of the remote Strapi instance to get data from` - ).argParser(parseURL) - ) - .addOption( - new Option( - '--to ', - `URL of the remote Strapi instance to send data to` - ).argParser(parseURL) - ) - .addOption(forceOption) - // Validate URLs - .hook( - 'preAction', - ifOptions( - (opts) => opts.from, - (thisCommand) => assertUrlHasProtocol(thisCommand.opts().from, ['https:', 'http:']) - ) - ) - .hook( - 'preAction', - ifOptions( - (opts) => opts.to, - (thisCommand) => assertUrlHasProtocol(thisCommand.opts().to, ['https:', 'http:']) - ) - ) - .hook( - 'preAction', - ifOptions( - (opts) => !opts.from && !opts.to, - () => exitWith(1, 'At least one source (from) or destination (to) option must be provided') - ) - ) - .addOption(forceOption) - .addOption(excludeOption) - .addOption(onlyOption) - .hook('preAction', validateExcludeOnly) - .hook( - 'preAction', - confirmMessage( - 'The import will delete all data in the remote database. Are you sure you want to proceed?' - ) - ) - .action(getLocalScript('transfer/transfer')); -} +// if (process.env.STRAPI_EXPERIMENTAL === 'true') { +// // `$ strapi transfer` +// program +// .command('transfer') +// .description('Transfer data from one source to another') +// .allowExcessArguments(false) +// .addOption( +// new Option( +// '--from ', +// `URL of the remote Strapi instance to get data from` +// ).argParser(parseURL) +// ) +// .addOption( +// new Option( +// '--to ', +// `URL of the remote Strapi instance to send data to` +// ).argParser(parseURL) +// ) +// .addOption(forceOption) +// // Validate URLs +// .hook( +// 'preAction', +// ifOptions( +// (opts) => opts.from, +// (thisCommand) => assertUrlHasProtocol(thisCommand.opts().from, ['https:', 'http:']) +// ) +// ) +// .hook( +// 'preAction', +// ifOptions( +// (opts) => opts.to, +// (thisCommand) => assertUrlHasProtocol(thisCommand.opts().to, ['https:', 'http:']) +// ) +// ) +// .hook( +// 'preAction', +// ifOptions( +// (opts) => !opts.from && !opts.to, +// () => exitWith(1, 'At least one source (from) or destination (to) option must be provided') +// ) +// ) +// .addOption(forceOption) +// .addOption(excludeOption) +// .addOption(onlyOption) +// .hook('preAction', validateExcludeOnly) +// .hook( +// 'preAction', +// confirmMessage( +// 'The import will delete all data in the remote database. Are you sure you want to proceed?' +// ) +// ) +// .action(getLocalScript('transfer/transfer')); +// } // `$ strapi export` program diff --git a/packages/core/strapi/lib/commands/transfer/export.js b/packages/core/strapi/lib/commands/transfer/export.js index 841c9dceaa..b64d99174e 100644 --- a/packages/core/strapi/lib/commands/transfer/export.js +++ b/packages/core/strapi/lib/commands/transfer/export.js @@ -21,7 +21,7 @@ const { } = require('./utils'); /** - * @typedef ImportCommandOptions Options given to the CLI import command + * @typedef ExportCommandOptions Options given to the CLI import command * * @property {string} [file] The file path to import * @property {boolean} [encrypt] Used to encrypt the final archive @@ -34,11 +34,11 @@ const logger = console; const BYTES_IN_MB = 1024 * 1024; /** - * Import command. + * Export command. * - * It transfers data from a local file to a local strapi instance + * It transfers data from a local Strapi instance to a file * - * @param {ImportCommandOptions} opts + * @param {ExportCommandOptions} opts */ module.exports = async (opts) => { // Validate inputs from Commander @@ -135,7 +135,7 @@ const createSourceProvider = (strapi) => { /** * It creates a local file destination provider based on the given options * - * @param {ImportCommandOptions} opts + * @param {ExportCommandOptions} opts */ const createDestinationProvider = (opts) => { const { file, compress, encrypt, key, maxSizeJsonl } = opts;