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
105 changes: 102 additions & 3 deletions cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ import {
runListControls,
runListControlConfigurations,
ListOptions,
BumpOptions,
runBumpArchitecture,
runBumpPattern,
runBumpStandard,
runBumpControlRequirement,
runBumpControlConfiguration,
} from './command-helpers/hub-commands';
import type { ResourceChangeType } from '@finos/calm-shared';

Expand Down Expand Up @@ -474,6 +480,7 @@ Example:
.option(NAME_OPTION, 'Name for the architecture in CALM Hub; overrides `title` field if set.')
.option(DESCRIPTION_OPTION, 'Description for the architecture; overrides `description` field if set.')
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
.option('--fail-if-exists', 'Push the exact version from $id without auto-bumping; fail if that version already exists on the hub.')
.addOption(hubOutputOption)
.addOption(hubVersionBumpOption)
.action(async (architectureFile, options) => {
Expand All @@ -483,7 +490,8 @@ Example:
description: options.description,
file: architectureFile,
format: options.format,
changeType: options.changeType.toUpperCase() as ResourceChangeType
changeType: options.changeType.toUpperCase() as ResourceChangeType,
failIfExists: options.failIfExists ?? false,
};
await runPushArchitecture(pushOptions);
});
Expand All @@ -494,6 +502,7 @@ Example:
.option(NAME_OPTION, 'Name for the pattern in CALM Hub; overrides `title` field if set.')
.option(DESCRIPTION_OPTION, 'Description for the pattern')
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
.option('--fail-if-exists', 'Push the exact version from $id without auto-bumping; fail if that version already exists on the hub.')
.addOption(hubOutputOption)
.addOption(hubVersionBumpOption)
.action(async (patternFile, options) => {
Expand All @@ -504,6 +513,7 @@ Example:
file: patternFile,
format: options.format,
changeType: options.changeType.toUpperCase() as ResourceChangeType,
failIfExists: options.failIfExists ?? false,
};
await runPushPattern(pushPatternOptions);
});
Expand All @@ -514,6 +524,7 @@ Example:
.option(NAME_OPTION, 'Name for the standard in CALM Hub')
.option(DESCRIPTION_OPTION, 'Description for the standard')
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
.option('--fail-if-exists', 'Push the exact version from $id without auto-bumping; fail if that version already exists on the hub.')
.addOption(hubOutputOption)
.addOption(hubVersionBumpOption)
.action(async (standardFile, options) => {
Expand All @@ -524,6 +535,7 @@ Example:
file: standardFile,
format: options.format,
changeType: options.changeType.toUpperCase() as ResourceChangeType,
failIfExists: options.failIfExists ?? false,
};
await runPushStandard(pushStandardOptions);
});
Expand All @@ -532,14 +544,16 @@ Example:
.command('control-requirement <requirement-file>')
.description('Push a control requirement version to CALM Hub. $id of document must contain a full control requirement document ID including domain, control name and version.')
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
.option('--fail-if-exists', 'Push the exact version from $id without auto-bumping; fail if that version already exists on the hub.')
.addOption(hubOutputOption)
.addOption(hubVersionBumpOption)
.action(async (requirementFile, options) => {
const pushOptions: PushControlOptions = {
calmHubOptions: { calmHubUrl: options.calmHubUrl },
file: requirementFile,
format: options.format,
changeType: options.changeType.toUpperCase() as ResourceChangeType
changeType: options.changeType.toUpperCase() as ResourceChangeType,
failIfExists: options.failIfExists ?? false,
};
await runPushControlRequirement(pushOptions);
});
Expand All @@ -548,18 +562,103 @@ Example:
.command('control-configuration <config-file>')
.description('Push a control configuration version to CALM Hub. $id of document must contain a full control configuration document ID including domain, control name, configuration name and version.')
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
.option('--fail-if-exists', 'Push the exact version from $id without auto-bumping; fail if that version already exists on the hub.')
.addOption(hubOutputOption)
.addOption(hubVersionBumpOption)
.action(async (configFile, options) => {
const pushOptions: PushControlOptions = {
calmHubOptions: { calmHubUrl: options.calmHubUrl },
file: configFile,
format: options.format,
changeType: options.changeType.toUpperCase() as ResourceChangeType
changeType: options.changeType.toUpperCase() as ResourceChangeType,
failIfExists: options.failIfExists ?? false,
};
await runPushControlConfiguration(pushOptions);
});

// hub bump
const hubBumpCmd = hubCmd.command('bump').description('Bump the version of a CALM document on disk if the current version already exists on the hub. Intended for dev-time use before committing, so CI can push with --fail-if-exists.');

hubBumpCmd
.command('architecture <architecture-file>')
.description('Bump the version of a CALM architecture on disk if that version already exists on the hub.')
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
.addOption(hubOutputOption)
.addOption(hubVersionBumpOption)
.action(async (architectureFile, options) => {
const bumpOptions: BumpOptions = {
calmHubOptions: { calmHubUrl: options.calmHubUrl },
file: architectureFile,
format: options.format,
changeType: options.changeType.toUpperCase() as ResourceChangeType,
};
await runBumpArchitecture(bumpOptions);
});

hubBumpCmd
.command('pattern <pattern-file>')
.description('Bump the version of a CALM pattern on disk if that version already exists on the hub.')
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
.addOption(hubOutputOption)
.addOption(hubVersionBumpOption)
.action(async (patternFile, options) => {
const bumpOptions: BumpOptions = {
calmHubOptions: { calmHubUrl: options.calmHubUrl },
file: patternFile,
format: options.format,
changeType: options.changeType.toUpperCase() as ResourceChangeType,
};
await runBumpPattern(bumpOptions);
});

hubBumpCmd
.command('standard <standard-file>')
.description('Bump the version of a CALM standard on disk if that version already exists on the hub.')
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
.addOption(hubOutputOption)
.addOption(hubVersionBumpOption)
.action(async (standardFile, options) => {
const bumpOptions: BumpOptions = {
calmHubOptions: { calmHubUrl: options.calmHubUrl },
file: standardFile,
format: options.format,
changeType: options.changeType.toUpperCase() as ResourceChangeType,
};
await runBumpStandard(bumpOptions);
});

hubBumpCmd
.command('control-requirement <requirement-file>')
.description('Bump the version of a control requirement on disk if that version already exists on the hub.')
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
.addOption(hubOutputOption)
.addOption(hubVersionBumpOption)
.action(async (requirementFile, options) => {
const bumpOptions: BumpOptions = {
calmHubOptions: { calmHubUrl: options.calmHubUrl },
file: requirementFile,
format: options.format,
changeType: options.changeType.toUpperCase() as ResourceChangeType,
};
await runBumpControlRequirement(bumpOptions);
});

hubBumpCmd
.command('control-configuration <config-file>')
.description('Bump the version of a control configuration on disk if that version already exists on the hub.')
.option(CALMHUB_URL_OPTION, 'URL to CALMHub instance')
.addOption(hubOutputOption)
.addOption(hubVersionBumpOption)
.action(async (configFile, options) => {
const bumpOptions: BumpOptions = {
calmHubOptions: { calmHubUrl: options.calmHubUrl },
file: configFile,
format: options.format,
changeType: options.changeType.toUpperCase() as ResourceChangeType,
};
await runBumpControlConfiguration(bumpOptions);
});

// hub pull
const hubPullCmd = hubCmd.command('pull').description('Pull a CALM document from CALM Hub');

Expand Down
Loading
Loading