Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Option } from 'commander';

import { configManagerImportJourneys } from '../../../configManagerOps/FrConfigJourneysOps';
import { getTokens } from '../../../ops/AuthenticateOps';
import { verboseMessage } from '../../../utils/Console';
import { FrodoCommand } from '../../FrodoCommand';

export default function setup() {
const program = new FrodoCommand('frodo config-manager push journeys', []);

program
.description('Import journeys.')
.addOption(
new Option(
'-n, --name <name>',
'Journey name, imports the specified Journey.'
)
)

.addOption(
new Option('-d, --push-dependencies', 'Push scripts and inner journeys')
)

.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);

const getTokensIsSuccessful = await getTokens(false, true);
if (!getTokensIsSuccessful) process.exit(1);
verboseMessage('Importing email provider configuration.');
const outcome = await configManagerImportJourneys(
options.name,
realm,
options.pushDependencies
);
if (!outcome) process.exitCode = 1;
});

return program;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import EmailProvider from './config-manager-push-email-provider';
import EmailTemplates from './config-manager-push-email-templates';
import Endpoints from './config-manager-push-endpoints';
import InternalRoles from './config-manager-push-internal-roles';
import Journeys from './config-manager-push-journeys';
import Kba from './config-manager-push-kba';
import Locales from './config-manager-push-locales';
import ManagedObjects from './config-manager-push-managed-objects';
Expand Down Expand Up @@ -56,6 +57,7 @@ export default function setup() {
program.addCommand(CustomNodes().name('custom-nodes'));
program.addCommand(CSP().name('csp'));
program.addCommand(Restart().name('restart'));
program.addCommand(Journeys().name('journeys'));

return program;
}
13 changes: 12 additions & 1 deletion src/configManagerOps/FrConfigAuthenticationOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { frodo, state } from '@rockcarver/frodo-lib';
import { AuthenticationSettingsExportInterface } from '@rockcarver/frodo-lib/types/ops/AuthenticationSettingsOps';
import fs from 'fs';

import { printError } from '../utils/Console';
import { printError, verboseMessage } from '../utils/Console';
import { realmList } from '../utils/FrConfig';

const {
Expand Down Expand Up @@ -65,6 +65,12 @@ export async function configManagerImportAuthentication(
const filePath = getFilePath(
`realms/${realm}/realm-config/authentication.json`
);

if (!fs.existsSync(filePath)) {
verboseMessage('No authentication file found to import.');
return false;
}

const fileContent = fs.readFileSync(filePath, 'utf-8');
const authData = JSON.parse(fileContent);
delete authData._rev;
Expand All @@ -76,6 +82,7 @@ export async function configManagerImportAuthentication(
} else {
const realmsPath = getFilePath(`realms/`);
const realmDirs = fs.readdirSync(realmsPath);

for (const realmName of realmDirs) {
await state.setRealm(realmName);
let realmPath;
Expand All @@ -90,6 +97,10 @@ export async function configManagerImportAuthentication(
);
}

if (!fs.existsSync(realmPath)) {
continue;
}

const fileContent = fs.readFileSync(realmPath, 'utf-8');
const authData = JSON.parse(fileContent);
delete authData._rev;
Expand Down
Loading