-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --ignore-destructive parameter (#112)
Co-authored-by: Mehdi Cherfaoui <>
- Loading branch information
Showing
6 changed files
with
199 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,84 @@ | ||
import { flags, SfdxCommand } from '@salesforce/command'; | ||
import { Messages } from '@salesforce/core'; | ||
import { AnyJson } from '@salesforce/ts-types'; | ||
import * as sgd from '../../../main.js'; | ||
import { flags, SfdxCommand } from '@salesforce/command' | ||
import { Messages } from '@salesforce/core' | ||
import { AnyJson } from '@salesforce/ts-types' | ||
import * as sgd from '../../../main.js' | ||
|
||
// Initialize Messages with the current plugin directory | ||
Messages.importMessagesDirectory(__dirname); | ||
const COMMAND_NAME = 'delta'; | ||
Messages.importMessagesDirectory(__dirname) | ||
const COMMAND_NAME = 'delta' | ||
|
||
// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core, | ||
// or any library that is using the messages framework can also be loaded this way. | ||
const messages = Messages.loadMessages('sfdx-git-delta', COMMAND_NAME); | ||
const messages = Messages.loadMessages('sfdx-git-delta', COMMAND_NAME) | ||
|
||
export default class SourceDeltaGenerate extends SfdxCommand { | ||
public static description = messages.getMessage('command', []) | ||
|
||
public static description = messages.getMessage('command', []); | ||
protected static flagsConfig = { | ||
to: flags.string({ | ||
char: 't', | ||
description: messages.getMessage('toFlag'), | ||
default: 'HEAD', | ||
}), | ||
from: flags.string({ | ||
char: 'f', | ||
description: messages.getMessage('fromFlag'), | ||
required: true, | ||
}), | ||
repo: flags.filepath({ | ||
char: 'r', | ||
description: messages.getMessage('repoFlag'), | ||
default: '.', | ||
}), | ||
ignore: flags.filepath({ | ||
char: 'i', | ||
description: messages.getMessage('ignoreFlag'), | ||
}), | ||
'ignore-destructive': flags.filepath({ | ||
char: 'D', | ||
description: messages.getMessage('ignoreDestructiveFlag'), | ||
}), | ||
output: flags.filepath({ | ||
char: 'o', | ||
description: messages.getMessage('outputFlag'), | ||
default: './output', | ||
}), | ||
'api-version': flags.number({ | ||
char: 'a', | ||
description: messages.getMessage('apiVersionFlag'), | ||
default: 50.0, | ||
}), | ||
'generate-delta': flags.boolean({ | ||
char: 'd', | ||
description: messages.getMessage('deltaFlag'), | ||
}), | ||
} | ||
|
||
protected static flagsConfig = { | ||
to: flags.string({ char: 't', description: messages.getMessage('toFlag'), default: 'HEAD' }), | ||
from: flags.string({ char: 'f', description: messages.getMessage('fromFlag'), required: true }), | ||
repo: flags.filepath({ char: 'r', description: messages.getMessage('repoFlag'), default: '.' }), | ||
ignore: flags.filepath({ char: 'i', description: messages.getMessage('ignoreFlag')}), | ||
output: flags.filepath({ char: 'o', description: messages.getMessage('outputFlag'), default: './output' }), | ||
'api-version': flags.number({ char: 'a', description: messages.getMessage('apiVersionFlag'), default: 50.0 }), | ||
'generate-delta': flags.boolean({ char: 'd', description: messages.getMessage('deltaFlag')}) | ||
}; | ||
|
||
public async run(): Promise<AnyJson> { | ||
|
||
const output = { | ||
error: null, | ||
public async run(): Promise<AnyJson> { | ||
const output = { | ||
error: null, | ||
output: this.flags.output, | ||
success: true, | ||
warnings: [], | ||
} | ||
try { | ||
const jobResult = sgd({ | ||
to: this.flags.to, | ||
from: this.flags.from, | ||
output: this.flags.output, | ||
success: true, | ||
warnings: [] | ||
}; | ||
try { | ||
const jobResult = sgd({ | ||
to: this.flags.to, | ||
from: this.flags.from, | ||
output: this.flags.output, | ||
ignore: this.flags.ignore, | ||
apiVersion: this.flags['api-version'], | ||
repo: this.flags.repo, | ||
generateDelta: this.flags['generate-delta'] | ||
}); | ||
output.warnings = jobResult?.warnings?.map(warning => warning.message); | ||
} catch (err) { | ||
output.success = false; | ||
output.error = err.message; | ||
process.exitCode = 1; | ||
} | ||
this.ux.log(JSON.stringify(output, null, 2)); | ||
return null; | ||
ignore: this.flags.ignore, | ||
ignoreDestructive: this.flags['ignore-destructive'], | ||
apiVersion: this.flags['api-version'], | ||
repo: this.flags.repo, | ||
generateDelta: this.flags['generate-delta'], | ||
}) | ||
output.warnings = jobResult?.warnings?.map(warning => warning.message) | ||
} catch (err) { | ||
output.success = false | ||
output.error = err.message | ||
process.exitCode = 1 | ||
} | ||
this.ux.log(JSON.stringify(output, null, 2)) | ||
return null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters