mirror of
https://github.com/strapi/strapi.git
synced 2025-11-08 14:19:40 +00:00
fix option validation and order
This commit is contained in:
parent
e404bc6015
commit
ac4e688995
@ -296,6 +296,14 @@ program
|
|||||||
.addOption(excludeOption)
|
.addOption(excludeOption)
|
||||||
.addOption(onlyOption)
|
.addOption(onlyOption)
|
||||||
.hook('preAction', validateExcludeOnly)
|
.hook('preAction', validateExcludeOnly)
|
||||||
|
.hook(
|
||||||
|
'preAction',
|
||||||
|
ifOptions(
|
||||||
|
(opts) => !(opts.from || opts.to) || (opts.from && opts.to),
|
||||||
|
() =>
|
||||||
|
exitWith(1, 'Exactly one remote source (from) or destination (to) option must be provided')
|
||||||
|
)
|
||||||
|
)
|
||||||
// If --from is used, validate the URL and token
|
// If --from is used, validate the URL and token
|
||||||
.hook(
|
.hook(
|
||||||
'preAction',
|
'preAction',
|
||||||
@ -346,21 +354,6 @@ program
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.hook(
|
|
||||||
'preAction',
|
|
||||||
ifOptions(
|
|
||||||
(opts) => !opts.from && !opts.to,
|
|
||||||
() =>
|
|
||||||
exitWith(1, 'At least one remote source (from) or destination (to) option must be provided')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.hook(
|
|
||||||
'preAction',
|
|
||||||
ifOptions(
|
|
||||||
(opts) => opts.from && opts.to,
|
|
||||||
() => exitWith(1, 'Only one source (from) or destination (to) option may be provided')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.action(getLocalScript('transfer/transfer'));
|
.action(getLocalScript('transfer/transfer'));
|
||||||
|
|
||||||
// `$ strapi export`
|
// `$ strapi export`
|
||||||
|
|||||||
@ -35,6 +35,9 @@ describe('Transfer', () => {
|
|||||||
strapi: {
|
strapi: {
|
||||||
providers: {
|
providers: {
|
||||||
createLocalStrapiSourceProvider: jest.fn().mockReturnValue({ name: 'testLocalSource' }),
|
createLocalStrapiSourceProvider: jest.fn().mockReturnValue({ name: 'testLocalSource' }),
|
||||||
|
createLocalStrapiDestinationProvider: jest
|
||||||
|
.fn()
|
||||||
|
.mockReturnValue({ name: 'testLocalDestination' }),
|
||||||
createRemoteStrapiDestinationProvider: jest
|
createRemoteStrapiDestinationProvider: jest
|
||||||
.fn()
|
.fn()
|
||||||
.mockReturnValue({ name: 'testRemoteDest' }),
|
.mockReturnValue({ name: 'testRemoteDest' }),
|
||||||
|
|||||||
@ -44,8 +44,13 @@ module.exports = async (opts) => {
|
|||||||
exitWith(1, 'Could not parse command arguments');
|
exitWith(1, 'Could not parse command arguments');
|
||||||
}
|
}
|
||||||
|
|
||||||
const strapi = await createStrapiInstance();
|
if (!(opts.from || opts.to) || (opts.from && opts.to)) {
|
||||||
|
console.log('from', opts.from);
|
||||||
|
console.log('to', opts.to);
|
||||||
|
exitWith(1, 'Exactly one source (from) or destination (to) option must be provided');
|
||||||
|
}
|
||||||
|
|
||||||
|
const strapi = await createStrapiInstance();
|
||||||
let source;
|
let source;
|
||||||
let destination;
|
let destination;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user