Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/cli/FrodoCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,12 @@ function decorateDescriptionWithStability(
*/
function cloneOption(option: Option): Option {
const cloned = Object.assign(new Option(option.flags, option.description), {
defaultValue: option.defaultValue,
defaultValueDescription: option.defaultValueDescription,
presetArg: option.presetArg,
envVar: option.envVar,
parseArg: option.parseArg,
hidden: option.hidden,
mandatory: option.mandatory,
...option,
// @ts-expect-error: CommanderJS Typings needs an update for node_modules to recognize conflictsWith
conflictsWith: option.conflictsWith
? [...option.conflictsWith]
: option.conflictsWith,
argChoices: option.argChoices ? [...option.argChoices] : option.argChoices,
helpGroupHeading: option.helpGroupHeading,
});

setStabilityMetadata(cloned, getStabilityMetadata(option));
Expand Down
4 changes: 2 additions & 2 deletions src/cli/config/config-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default function setup() {
includeReadOnly: options.readOnly,
onlyRealm: options.realmOnly,
onlyGlobal: options.globalOnly,
onlyCustom: options.onlyCustom
onlyCustom: options.onlyCustom,
}
);
if (!outcome) process.exitCode = 1;
Expand Down Expand Up @@ -209,7 +209,7 @@ export default function setup() {
includeReadOnly: options.readOnly,
onlyRealm: options.realmOnly,
onlyGlobal: options.globalOnly,
onlyCustom: options.onlyCustom
onlyCustom: options.onlyCustom,
}
);
if (!outcome) process.exitCode = 1;
Expand Down
6 changes: 3 additions & 3 deletions src/cli/config/config-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default function setup() {
includeDefault: options.default,
includeActiveValues: options.includeActiveValues,
source: options.source,
onlyCustom: options.onlyCustom
onlyCustom: options.onlyCustom,
});
if (!outcome) process.exitCode = 1;
}
Expand All @@ -159,7 +159,7 @@ export default function setup() {
includeDefault: options.default,
includeActiveValues: options.includeActiveValues,
source: options.source,
onlyCustom: options.onlyCustom
onlyCustom: options.onlyCustom,
});
if (!outcome) process.exitCode = 1;
}
Expand All @@ -177,7 +177,7 @@ export default function setup() {
includeDefault: options.default,
includeActiveValues: options.includeActiveValues,
source: options.source,
onlyCustom: options.onlyCustom
onlyCustom: options.onlyCustom,
}
);
if (!outcome) process.exitCode = 1;
Expand Down
79 changes: 79 additions & 0 deletions src/cli/iga/events/iga-events-delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { frodo, state } from '@rockcarver/frodo-lib';
import { Option } from 'commander';

import { getTokens } from '../../../ops/AuthenticateOps';
import { deleteEvent, deleteEvents } from '../../../ops/cloud/iga/IgaEventsOps';
import { printMessage, verboseMessage } from '../../../utils/Console.js';
import { FrodoCommand } from '../../FrodoCommand';

const { CLOUD_DEPLOYMENT_TYPE_KEY } = frodo.utils.constants;

const deploymentTypes = [CLOUD_DEPLOYMENT_TYPE_KEY];

export default function setup() {
const program = new FrodoCommand('frodo iga events delete');

program
.description('Delete events.')
.addOption(
new Option(
'-i, --event-id <event-id>',
'Event id. If specified, -a cannot be used.'
).conflicts(['all'])
)
.addOption(
new Option(
'-a, --all',
'Delete all events. If specified, -i cannot be used.'
).conflicts(['eventId'])
)
.action(
// implement command logic inside action handler
async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
if (!options.eventId && !options.all) {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
process.exitCode = 1;
program.help();
}
const getTokensIsSuccessful = await getTokens(
false,
true,
deploymentTypes
);
if (!getTokensIsSuccessful) process.exit(1);
if (!state.getIsIGA()) {
printMessage(
'Command not supported for non-IGA cloud tenants',
'error'
);
process.exit(1);
}
// delete by id
if (options.eventId) {
verboseMessage('Deleting event...');
const outcome = await deleteEvent(options.eventId);
if (!outcome) process.exit(1);
}
// --all -a
else if (options.all) {
verboseMessage('Deleting all events...');
const outcome = await deleteEvents();
if (!outcome) process.exit(1);
}
}
// end command logic inside action handler
);

return program;
}
66 changes: 66 additions & 0 deletions src/cli/iga/events/iga-events-describe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { frodo, state } from '@rockcarver/frodo-lib';
import { Option } from 'commander';

import { getTokens } from '../../../ops/AuthenticateOps';
import { describeEvent } from '../../../ops/cloud/iga/IgaEventsOps';
import { printMessage, verboseMessage } from '../../../utils/Console';
import { FrodoCommand } from '../../FrodoCommand';

const { CLOUD_DEPLOYMENT_TYPE_KEY } = frodo.utils.constants;

const deploymentTypes = [CLOUD_DEPLOYMENT_TYPE_KEY];

export default function setup() {
const program = new FrodoCommand('frodo iga events describe');

program
.description('Describe events.')
.addOption(
new Option(
'-i, --event-id <event-id>',
'event id. If not specified, will describe first event in the provided export file.'
)
)
.addOption(
new Option(
'-f, --file <file>',
'Name of the event export file to describe. If not specified, will automatically pull the event export data of the provided id from the tenant.'
)
)
.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
if (!options.eventId && !options.file) {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
process.exitCode = 1;
program.help();
}
const getTokensIsSuccessful = await getTokens(
false,
true,
deploymentTypes
);
if (!getTokensIsSuccessful) process.exit(1);
if (!state.getIsIGA()) {
printMessage(
'Command not supported for non-IGA cloud tenants',
'error'
);
process.exit(1);
}
verboseMessage(`Describing event ${options.eventId}...`);
const outcome = await describeEvent(options.eventId, options.file);
if (!outcome) process.exit(1);
});

return program;
}
150 changes: 150 additions & 0 deletions src/cli/iga/events/iga-events-export.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import { frodo, state } from '@rockcarver/frodo-lib';
import { Option } from 'commander';

import { getTokens } from '../../../ops/AuthenticateOps';
import {
exportEventsToFile,
exportEventsToFiles,
exportEventToFile,
} from '../../../ops/cloud/iga/IgaEventsOps';
import { printMessage, verboseMessage } from '../../../utils/Console.js';
import { FrodoCommand } from '../../FrodoCommand';

const { CLOUD_DEPLOYMENT_TYPE_KEY } = frodo.utils.constants;

const deploymentTypes = [CLOUD_DEPLOYMENT_TYPE_KEY];

export default function setup() {
const program = new FrodoCommand(
'frodo iga events export',
[],
deploymentTypes
);

program
.description('Export events.')
.addOption(
new Option(
'-i, --event-id <event-id>',
'event id. If specified, -a and -A cannot be used.'
).conflicts(['all', 'allSeparate'])
)
.addOption(
new Option(
'-f, --file [file]',
'Name of the export file. Cannot be used with -A. Defaults to <event-id>.event.json.'
).conflicts(['allSeparate'])
)
.addOption(
new Option(
'-a, --all',
'Export all events to a single file. Cannot be used with -i.'
).conflicts(['eventId'])
)
.addOption(
new Option(
'-A, --all-separate',
'Export all events as separate files <event-id>.event.json. Cannot be used with -i and -a.'
).conflicts(['eventId', 'all'])
)
.addOption(
new Option(
'-N, --no-metadata',
'Do not include metadata in the export file.'
)
)
.addOption(
new Option(
'-M, --modified-properties',
'Include modified properties in export (e.g. lastModifiedDate, lastModifiedBy, createdBy, creationDate, etc.)'
).default(false, 'false')
)
.addOption(
new Option(
'-x, --no-extract',
'Do not extract the scripts from the exported file and save them to separate files. Cannot be used with -a.'
)
.default(true, 'true')
.conflicts(['all'])
)
.addOption(
new Option(
'--no-deps',
'Do not include any dependencies (email templates, request forms, events, etc.).'
)
)
.action(
// implement command logic inside action handler
async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
if (!options.eventId && !options.all && !options.allSeparate) {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
return;
}
const getTokensIsSuccessful = await getTokens(
false,
true,
deploymentTypes
);
if (!getTokensIsSuccessful) process.exit(1);
if (!state.getIsIGA()) {
printMessage(
'Command not supported for non-IGA cloud tenants',
'error'
);
process.exitCode = 1;
return;
}
// --event-id -i
if (options.eventId) {
verboseMessage(`Exporting event "${options.eventId}"...`);
const outcome = await exportEventToFile(
options.eventId,
options.file,
options.metadata,
options.modifiedProperties,
options.extract,
{ deps: options.deps }
);
if (!outcome) process.exitCode = 1;
}
// --all -a
else if (options.all) {
verboseMessage('Exporting all events to a single file...');
const outcome = await exportEventsToFile(
options.file,
options.metadata,
options.modifiedProperties,
{ deps: options.deps }
);
if (!outcome) process.exitCode = 1;
}
// --all-separate -A
else if (options.allSeparate) {
verboseMessage('Exporting all events to separate files...');
const outcome = await exportEventsToFiles(
options.metadata,
options.modifiedProperties,
options.extract,
{ deps: options.deps }
);
if (!outcome) process.exitCode = 1;
}
}
// end command logic inside action handler
);

return program;
}
Loading