mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 19:04:38 +00:00
Review fixes
This commit is contained in:
parent
3346f92fd0
commit
c631b7f77c
@ -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
|
||||
|
||||
@ -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'),
|
||||
|
||||
@ -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);
|
||||
// }
|
||||
};
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -77,8 +77,8 @@ class LocalStrapiDestinationProvider implements IDestinationProvider {
|
||||
return restore.deleteRecords(this.strapi, this.options.restore);
|
||||
}
|
||||
|
||||
async rollback(e: Error): Promise<void> {
|
||||
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,
|
||||
})),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -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,
|
||||
})),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -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'));
|
||||
|
||||
@ -5,11 +5,6 @@ import type { Readable } from 'stream';
|
||||
export interface IMetadata {
|
||||
strapi?: {
|
||||
version?: string;
|
||||
|
||||
plugins?: {
|
||||
name: string;
|
||||
version: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
createdAt?: string;
|
||||
|
||||
@ -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 <sourceURL>',
|
||||
`URL of the remote Strapi instance to get data from`
|
||||
).argParser(parseURL)
|
||||
)
|
||||
.addOption(
|
||||
new Option(
|
||||
'--to <destinationURL>',
|
||||
`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 <sourceURL>',
|
||||
// `URL of the remote Strapi instance to get data from`
|
||||
// ).argParser(parseURL)
|
||||
// )
|
||||
// .addOption(
|
||||
// new Option(
|
||||
// '--to <destinationURL>',
|
||||
// `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
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user