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
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
4 changes: 4 additions & 0 deletions src/cli/iga/iga.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FrodoStubCommand } from '../FrodoCommand';
import RequestTypeCmd from './request-types/iga-request-type';
import WorkflowCmd from './workflow/iga-workflow';

export default function setup() {
Expand All @@ -7,6 +8,9 @@ export default function setup() {
);

program.addCommand(WorkflowCmd().name('workflow').showHelpAfterError());
program.addCommand(
RequestTypeCmd().name('request-type').showHelpAfterError()
);

program.showHelpAfterError();
return program;
Expand Down
86 changes: 86 additions & 0 deletions src/cli/iga/request-types/iga-request-type-delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { frodo, state } from '@rockcarver/frodo-lib';
import { Option } from 'commander';

import { getTokens } from '../../../ops/AuthenticateOps';
import {
deleteAllRequestTypes,
deleteRequestType,
} from '../../../ops/cloud/iga/IgaRequestTypesOps';
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 request-type delete');

program
.description('Delete request type.')
.addOption(
new Option(
'-n, --request-type-name <request-type-name>',
'Request type name. If specified, -a is ignored.'
)
)

.addOption(
new Option('-a, --all', 'Delete all request types. Ignored with -n.')
)
.action(
// implement command logic inside action handler
async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
if (!options.requestTypeName && !options.all) {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
return;
}
const getTokensIsSuccessful = await getTokens(
false,
true,
deploymentTypes
);
if (!getTokensIsSuccessful) {
printMessage('Error getting tokens', 'error');
process.exitCode = 1;
return;
}
if (!state.getIsIGA()) {
printMessage(
'Command not supported for non-IGA cloud tenants',
'error'
);
process.exitCode = 1;
return;
}
// delete by id
if (options.requestTypeName) {
verboseMessage('Deleting request type...');
const outcome = await deleteRequestType(options.requestTypeName);
if (!outcome) process.exitCode = 1;
}
// --all -a
else if (options.all) {
verboseMessage('Deleting all request types...');
const outcome = await deleteAllRequestTypes();
if (!outcome) process.exitCode = 1;
}
}
// end command logic inside action handler
);

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

import { getTokens } from '../../../ops/AuthenticateOps';
import { describeRequestType } from '../../../ops/cloud/iga/IgaRequestTypesOps';
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 request-type describe');

program
.description('Describe request type.')
.addOption(
new Option(
'-n, --request-type-name <request-type-name>',
'Request type name. If not specified, will describe first request type in the provided export file.'
)
)
.addOption(
new Option(
'-f, --file <file>',
'Name of the request type export file to describe. If not specified, will automatically pull the request type 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.requestTypeName && !options.file) {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
return;
}
const getTokensIsSuccessful = await getTokens(
false,
true,
deploymentTypes
);
if (!getTokensIsSuccessful) {
printMessage('Error getting tokens', 'error');
process.exitCode = 1;
return;
}
if (!state.getIsIGA()) {
printMessage(
'Command not supported for non-IGA cloud tenants',
'error'
);
process.exitCode = 1;
return;
}
verboseMessage(`Describing workflow ${options.requestTypeName}...`);
const outcome = await describeRequestType(
options.requestTypeName,
options.file
);
if (!outcome) process.exitCode = 1;
});

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

import { getTokens } from '../../../ops/AuthenticateOps';
import {
exportAllRequestTypesToFiles,
exportAllRequestTypeToFile,
exportRequestTypeToFile,
} from '../../../ops/cloud/iga/IgaRequestTypesOps';
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 request-type export',
[],
deploymentTypes
);

program
.description('Export request-type.')
.addOption(
new Option(
'-n, --request-type-name <request-type-name>',
'Request type name. If specified, -a and -A are ignored.'
)
)
.addOption(
new Option(
'-f, --file [file]',
'Name of the export file. Ignored with -A. Defaults to <request-type-id>.request-type.json.'
)
)
.addOption(
new Option(
'-a, --all',
'Export all request types to a single file. Ignored with -i.'
)
)
.addOption(
new Option(
'-A, --all-separate',
'Export all request types as separate files <request-type-id>.request-type.json. Ignored with -i, and -a.'
)
)
.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. Ignored with -a.'
).default(true, 'true')
)
.addOption(
new Option(
'--use-string-arrays',
'Where applicable, use string arrays to store scripts.'
).default(false, 'off')
)
.addOption(
new Option(
'-R, --read-only',
'Export non-mutable request-types in addition to the mutable request-types.'
)
)
.addOption(
new Option(
'--no-deps',
'Do not include any dependencies (email templates, request types, 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.requestTypeName && !options.all && !options.allSeparate) {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exit(1);
return;
}
const getTokensIsSuccessful = await getTokens(
false,
true,
deploymentTypes
);
if (!getTokensIsSuccessful) {
printMessage('Error getting tokens', 'error');
process.exit(1);
return;
}
if (!state.getIsIGA()) {
printMessage(
'Command not supported for non-IGA cloud tenants',
'error'
);
process.exit(1);
return;
}
// --request-type-name --n
if (options.requestTypeName) {
verboseMessage(`Exporting request "${options.requestTypeName}"...`);
const outcome = await exportRequestTypeToFile(
undefined,
options.requestTypeName,
options.file,
options.metadata,
options.modifiedProperties,
options.extract
);
if (!outcome) process.exit(1);
}
// --all -a
else if (options.all) {
verboseMessage('Exporting all request types to a single file...');
const outcome = await exportAllRequestTypeToFile(
options.file,
options.metadata,
options.modifiedProperties
);
if (!outcome) process.exit(1);
}
// --all-separate -A
else if (options.allSeparate) {
verboseMessage('Exporting all request types to separate files...');
const outcome = await exportAllRequestTypesToFiles(
options.metadata,
options.modifiedProperties,
options.extract,
{
onlyCustom: options.deps,
useStringArrays: options.useStringArrays,
}
);
if (!outcome) process.exit(1);
}
}
// end command logic inside action handler
);

return program;
}
Loading