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
2 changes: 2 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 ScopeCmd from './scope/iga-scope';
import WorkflowCmd from './workflow/iga-workflow';

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

program.addCommand(WorkflowCmd().name('workflow').showHelpAfterError());
program.addCommand(ScopeCmd().name('scope').showHelpAfterError());

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

import { getTokens } from '../../../ops/AuthenticateOps';
import {
deleteScopeByName,
deleteScopes,
} from '../../../ops/cloud/iga/IgaScopeOps';
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 scope delete');

program
.description('Delete scopes.')
.addOption(
new Option(
'-n, --scope-name <scope-name>',
'Scope name. If specified, -a is ignored.'
)
)
.addOption(new Option('-a, --all', 'Delete all scopes. 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.scopeName && !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.scopeName) {
verboseMessage('Deleting scope...');
const outcome = await deleteScopeByName(options.scopeName);
if (!outcome) process.exitCode = 1;
}
// --all -a
else if (options.all) {
verboseMessage('Deleting all scopes...');
const outcome = await deleteScopes();
if (!outcome) process.exitCode = 1;
}
}
// end command logic inside action handler
);

return program;
}
66 changes: 66 additions & 0 deletions src/cli/iga/scope/iga-scope-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 { describeScope } from '../../../ops/cloud/iga/IgaScopeOps';
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 scope describe');
program
.description('Describe scopes.')
.addOption(
new Option(
'-n, --name <scope-name>',
'Scope name. If not specified, will describe the first scope in the provided export file, or the first scope in the tenant if no file is provided.'
)
)
.addOption(
new Option(
'-f, --file <file>',
'Name of the scope export file to describe. If not specified, will pull scope data from the tenant.'
)
)
.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
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(
options.name
? `Describing scope ${options.name}...`
: options.file
? `Describing first scope in ${options.file}...`
: 'Describing first scope in tenant...'
);
const outcome = await describeScope(options.name, options.file);
if (!outcome) process.exitCode = 1;
});
return program;
}
136 changes: 136 additions & 0 deletions src/cli/iga/scope/iga-scope-export.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { frodo, state } from '@rockcarver/frodo-lib';
import { Option } from 'commander';

import { getTokens } from '../../../ops/AuthenticateOps';
import {
exportScopesToFile,
exportScopesToFiles,
exportScopeToFile,
} from '../../../ops/cloud/iga/IgaScopeOps';
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 scope export',
[],
deploymentTypes
);

program
.description('Export scopes.')
.addOption(
new Option(
'-n, --scope-name <scope-name>',
'Scope name. If specified, -a and -A are ignored.'
)
)
.addOption(
new Option(
'-f, --file [file]',
'Name of the export file. Ignored with -A. Defaults to <scope-name>.scope.json.'
)
)
.addOption(
new Option(
'-a, --all',
'Export all scopes to a single file. Ignored with -i.'
)
)
.addOption(
new Option(
'-A, --all-separate',
'Export all scopes as separate files <scope-name>.scope.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')
)

.action(
// implement command logic inside action handler
async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
if (!options.scopeName && !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) {
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;
}
// --scopeName -i
if (options.scopeName) {
verboseMessage(`Exporting scope "${options.scopeName}"...`);
const outcome = await exportScopeToFile(
options.scopeName,
options.file,
options.metadata,
options.modifiedProperties
);
if (!outcome) process.exitCode = 1;
}
// --all -a
else if (options.all) {
verboseMessage('Exporting all scopes to a single file...');
const outcome = await exportScopesToFile(
options.file,
options.metadata,
options.modifiedProperties
);
if (!outcome) process.exitCode = 1;
}
// --all-separate -A
else if (options.allSeparate) {
verboseMessage('Exporting all scopes to separate files...');
const outcome = await exportScopesToFiles(
options.metadata,
options.modifiedProperties
);
if (!outcome) process.exitCode = 1;
}
}
// end command logic inside action handler
);

return program;
}
Loading