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
17 changes: 14 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import info from './cli/info/info';
import journey from './cli/journey/journey';
import log from './cli/log/log';
import mapping from './cli/mapping/mapping';
import node from './cli/node/node';
import oauth from './cli/oauth/oauth';
import promote from './cli/promote/promote';
import realm from './cli/realm/realm';
Expand Down Expand Up @@ -73,6 +74,7 @@ const { initTokenCache } = frodo.cache;
program.addCommand(journey());
await program.addCommand(log());
program.addCommand(mapping());
program.addCommand(node());
program.addCommand(oauth());
program.addCommand(promote());
program.addCommand(realm());
Expand Down
9 changes: 9 additions & 0 deletions src/cli/config/config-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
'Create new UUIDs for the scripts upon import. Use this to duplicate scripts or create a new versions of the same scripts.'
).default(false, 'off')
)
.addOption(
new Option(
'--re-uuid-custom-nodes',
'Create new UUIDs for the custom nodes upon import. Use this to duplicate custom nodes or create a new versions of the same custom nodes.'
).default(false, 'off')
)
.addOption(
new Option(
'-d, --default',
Expand Down Expand Up @@ -118,6 +124,7 @@
const outcome = await importEverythingFromFile(options.file, {
reUuidJourneys: options.reUuidJourneys,
reUuidScripts: options.reUuidScripts,
reUuidCustomNodes: options.reUuidCustomNodes,

Check failure on line 127 in src/cli/config/config-import.ts

View workflow job for this annotation

GitHub Actions / Build

Object literal may only specify known properties, and 'reUuidCustomNodes' does not exist in type 'FullImportOptions'.
cleanServices: options.clean,
includeDefault: options.default,
includeActiveValues: options.includeActiveValues,
Expand All @@ -140,6 +147,7 @@
const outcome = await importEverythingFromFiles({
reUuidJourneys: options.reUuidJourneys,
reUuidScripts: options.reUuidScripts,
reUuidCustomNodes: options.reUuidCustomNodes,

Check failure on line 150 in src/cli/config/config-import.ts

View workflow job for this annotation

GitHub Actions / Build

Object literal may only specify known properties, and 'reUuidCustomNodes' does not exist in type 'FullImportOptions'.
cleanServices: options.clean,
includeDefault: options.default,
includeActiveValues: options.includeActiveValues,
Expand All @@ -156,6 +164,7 @@
{
reUuidJourneys: options.reUuidJourneys,
reUuidScripts: options.reUuidScripts,
reUuidCustomNodes: options.reUuidCustomNodes,

Check failure on line 167 in src/cli/config/config-import.ts

View workflow job for this annotation

GitHub Actions / Build

Object literal may only specify known properties, and 'reUuidCustomNodes' does not exist in type 'FullImportOptions'.
cleanServices: options.clean,
includeDefault: options.default,
includeActiveValues: options.includeActiveValues,
Expand Down
61 changes: 61 additions & 0 deletions src/cli/node/node-delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Option } from 'commander';

import { getTokens } from '../../ops/AuthenticateOps';
import { deleteCustomNode, deleteCustomNodes } from '../../ops/NodeOps';
import { printMessage, verboseMessage } from '../../utils/Console';
import { FrodoCommand } from '../FrodoCommand';

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

program
.description('Delete custom nodes.')
.addOption(
new Option(
'-i, --node-id <node-id>',
'Custom node id or service name. If specified, only one custom node is deleted and the options -n, -a and -A are ignored.'
)
)
.addOption(
new Option(
'-n, --node-name <node-name>',
'Custom node display name. If specified, only one custom node is deleted and the options -a and -A are ignored.'
)
)
.addOption(
new Option('-a, --all', 'Delete all custom nodes. Ignored with -i or -n.')
)
.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
if ((options.nodeId || options.nodeName) && (await getTokens())) {
verboseMessage(
`Deleting custom node ${options.nodeName ? options.nodeName : options.nodeId}...`
);
const outcome = await deleteCustomNode(
options.nodeId,
options.nodeName
);
if (!outcome) process.exitCode = 1;
} else if (options.all && (await getTokens())) {
verboseMessage(`Deleting all custom nodes...`);
const outcome = await deleteCustomNodes();
if (!outcome) process.exitCode = 1;
} else {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
}
});

return program;
}
50 changes: 50 additions & 0 deletions src/cli/node/node-describe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Option } from 'commander';

import { getTokens } from '../../ops/AuthenticateOps';
import { describeCustomNode } from '../../ops/NodeOps';
import { printMessage, verboseMessage } from '../../utils/Console';
import { FrodoCommand } from '../FrodoCommand';

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

program
.description('Describe custom nodes.')
.addOption(
new Option('-i, --node-id <node-id>', 'Custom node id or service name.')
)
.addOption(
new Option('-n, --node-name <node-name>', 'Custom node display name.')
)
.addOption(new Option('--json', 'Output in JSON format.'))
.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
if (await getTokens()) {
verboseMessage(
`Describing custom node ${options.nodeName ? options.nodeName : options.nodeId}...`
);
const outcome = await describeCustomNode(
options.nodeId,
options.nodeName,
options.json
);
if (!outcome) process.exitCode = 1;
} else {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
}
});

return program;
}
116 changes: 116 additions & 0 deletions src/cli/node/node-export.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { Option } from 'commander';

import { getTokens } from '../../ops/AuthenticateOps';
import {
exportCustomNodesToFile,
exportCustomNodesToFiles,
exportCustomNodeToFile,
} from '../../ops/NodeOps';
import { printMessage, verboseMessage } from '../../utils/Console';
import { FrodoCommand } from '../FrodoCommand';

export default function setup() {
const program = new FrodoCommand('frodo node export');

program
.description('Export custom nodes.')
.addOption(
new Option(
'-i, --node-id <node-id>',
'Custom node id or service name. If specified, only one custom node is exported and the options -n, -a and -A are ignored.'
)
)
.addOption(
new Option(
'-n, --node-name <node-name>',
'Custom node display name. If specified, only one custom node is exported and the options -a and -A are ignored.'
)
)
.addOption(new Option('-f, --file <file>', 'Name of the export file.'))
.addOption(
new Option(
'-a, --all',
'Export all custom nodes to a single file. Ignored with -i or -n.'
)
)
.addOption(
new Option(
'-A, --all-separate',
'Export all custom nodes to separate files (*.nodeTypes.json) in the current directory. Ignored with -i, -n, or -a.'
)
)
.addOption(
new Option(
'-N, --no-metadata',
'Does not include metadata in the export file.'
)
)
.addOption(
new Option(
'-x, --extract',
'Extract the script from the exported file, and save it to a separate file. Ignored with -a.'
)
)
.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
// export by id or name
if ((options.nodeId || options.nodeName) && (await getTokens())) {
verboseMessage(
`Exporting custom node ${options.nodeId || options.nodeName}...`
);
const outcome = await exportCustomNodeToFile(
options.nodeId,
options.nodeName,
options.file,
options.metadata,
options.extract,
{
useStringArrays: true,
}
);
if (!outcome) process.exitCode = 1;
}
// --all -a
else if (options.all && (await getTokens())) {
verboseMessage(`Exporting all custom nodes to a single file...`);
const outcome = await exportCustomNodesToFile(
options.file,
options.metadata,
{
useStringArrays: true,
}
);
if (!outcome) process.exitCode = 1;
}
// --all-separate -A
else if (options.allSeparate && (await getTokens())) {
verboseMessage('Exporting all custom nodes to separate files...');
const outcome = await exportCustomNodesToFiles(
options.metadata,
options.extract,
{
useStringArrays: true,
}
);
if (!outcome) process.exitCode = 1;
}
// unrecognized combination of options or no options
else {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
}
});

return program;
}
Loading