-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c39880
commit 1f27c2d
Showing
12 changed files
with
628 additions
and
43 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Command } from 'commander'; | ||
import { CopyField } from 'migratortron'; | ||
import { cliCommand } from '~/services/ContensisCliService'; | ||
import { | ||
commit, | ||
concurrency, | ||
ignoreErrors, | ||
mapContensisOpts, | ||
outputEntries, | ||
} from './globalOptions'; | ||
|
||
export const makeCopyCommand = () => { | ||
const copy = new Command() | ||
.command('copy') | ||
.description('copy command') | ||
.addHelpText('after', `\n`) | ||
.showHelpAfterError(true) | ||
.exitOverride(); | ||
|
||
copy | ||
.command('field') | ||
.description('copy the contents of one content type field to another') | ||
.argument( | ||
'<contentTypeId>', | ||
'the api id of the content type containing the fields to copy' | ||
) | ||
.argument('<fieldId>', 'the id of the field to copy from') | ||
.argument('<destinationId>', 'the id of the field to copy to') | ||
.option( | ||
'-t --template <template>', | ||
'apply a liquidjs template to modify the copied field content' | ||
) | ||
.addOption(commit) | ||
.addOption(concurrency) | ||
.addOption(ignoreErrors) | ||
.addOption(outputEntries) | ||
.usage('<contentTypeId> <fieldId> <destinationId> (all arguments required)') | ||
.addHelpText( | ||
'after', | ||
` | ||
Example call: | ||
> copy field blog authorName contributors\n` | ||
) | ||
.action( | ||
async ( | ||
contentTypeId: string, | ||
fieldId: string, | ||
destinationId: string, | ||
opts: any | ||
) => { | ||
const copyField: CopyField = { | ||
contentTypeId, | ||
fieldId, | ||
destinationId, | ||
template: opts.template, | ||
}; | ||
|
||
return await cliCommand( | ||
['copy', 'project', contentTypeId, fieldId, destinationId], | ||
opts, | ||
mapContensisOpts({ copyField }) | ||
).CopyEntryField({ | ||
commit: opts.commit, | ||
fromFile: opts.fromFile, | ||
logOutput: opts.outputEntries, | ||
}); | ||
} | ||
); | ||
|
||
return copy; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.