Skip to content

Commit

Permalink
Added documentation to the delta cli command
Browse files Browse the repository at this point in the history
Signed-off-by: George M Dias <[email protected]>
  • Loading branch information
georgedias committed Dec 3, 2024
1 parent 149ed77 commit 7a412cd
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/commands/generate/delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,10 @@ export default class GenerateDelta extends BaseCommand<typeof GenerateDelta> {
logger.info(' Updating controls with new control number')
printCyan('Updating Controls ===========================================================================')

// For each control, modify the control file in the old controls directory
// then regenerate json profile
// We need to update controls that a mapping were found executing the mapControls method.
// This is needed because when we re-generate the new profile summary we need the controls
// to have the new name/Id. So, for each control, modify the control file in the old controls
// directory with the proper name and Id, than regenerate json profile summary.
// eslint-disable-next-line guard-for-in
for (const key in controls) {
const sourceShortControlFile = path.join(shortProfileDir, `${controls[key]}.rb`)
Expand Down Expand Up @@ -349,7 +351,7 @@ export default class GenerateDelta extends BaseCommand<typeof GenerateDelta> {
}
}

// Regenerate the profile json based on the updated mapped controls
// Regenerate the profile json summary based on the updated mapped controls
try {
logger.info(` Generating the profile json using the new mapped controls on: '${mappedDir}'`)
// Get the directory name without the trailing "controls" directory
Expand Down Expand Up @@ -455,7 +457,14 @@ export default class GenerateDelta extends BaseCommand<typeof GenerateDelta> {
// Call the .toRuby verbose if the log level is debug or verbose
const processLogLevel = Boolean(logLevel === 'debug' || logLevel === 'verbose')
if (index >= 0) {
// We found a mapping for this control
// We found a mapping for this control (aka index >=0)
// The new control (control) has the new metadata but doesn't have
// the describe block (code). Using the updateControl method with the new
// control so we can get the code with the new metadata.

// eslint-disable-next-line no-warning-comments
// TODO: Can use the getExistingDescribeFromControl(existingProfile.controls[index])
// method from inspect-objects
const newControl = updateControl(existingProfile.controls[index], control, logger)

logger.debug(`Writing updated control with code block for: ${control.id}.`)
Expand Down

0 comments on commit 7a412cd

Please sign in to comment.