-
-
Notifications
You must be signed in to change notification settings - Fork 116
/
delta.ts
110 lines (105 loc) · 3.32 KB
/
delta.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { flags, SfdxCommand } from '@salesforce/command'
import { Messages } from '@salesforce/core'
import { AnyJson } from '@salesforce/ts-types'
import * as sgd from '../../../main'
const {
TO_DEFAULT_VALUE,
REPO_DEFAULT_VALUE,
SOURCE_DEFAULT_VALUE,
OUTPUT_DEFAULT_VALUE,
} = require('../../../utils/cliHelper')
// Initialize Messages with the current plugin directory
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)
export default class SourceDeltaGenerate extends SfdxCommand {
public static description = messages.getMessage('command', [])
protected static flagsConfig = {
to: flags.string({
char: 't',
description: messages.getMessage('toFlag'),
default: TO_DEFAULT_VALUE,
}),
from: flags.string({
char: 'f',
description: messages.getMessage('fromFlag'),
required: true,
}),
repo: flags.filepath({
char: 'r',
description: messages.getMessage('repoFlag'),
default: REPO_DEFAULT_VALUE,
}),
ignore: flags.filepath({
char: 'i',
description: messages.getMessage('ignoreFlag'),
}),
'ignore-destructive': flags.filepath({
char: 'D',
description: messages.getMessage('ignoreDestructiveFlag'),
}),
source: flags.filepath({
char: 's',
description: messages.getMessage('sourceFlag'),
default: SOURCE_DEFAULT_VALUE,
}),
'ignore-whitespace': flags.boolean({
char: 'W',
description: messages.getMessage('ignoreWhitespaceFlag'),
}),
output: flags.filepath({
char: 'o',
description: messages.getMessage('outputFlag'),
default: OUTPUT_DEFAULT_VALUE,
}),
'api-version': flags.number({
char: 'a',
description: messages.getMessage('apiVersionFlag'),
}),
'generate-delta': flags.boolean({
char: 'd',
description: messages.getMessage('deltaFlag'),
}),
include: flags.filepath({
char: 'n',
description: messages.getMessage('includeFlag'),
}),
'include-destructive': flags.filepath({
char: 'N',
description: messages.getMessage('includeDestructiveFlag'),
}),
}
public async run(): Promise<AnyJson> {
const output = {
error: null,
output: this.flags.output,
success: true,
warnings: [],
}
try {
const jobResult = await sgd({
to: this.flags.to,
from: this.flags.from,
output: this.flags.output,
source: this.flags.source,
ignore: this.flags.ignore,
ignoreDestructive: this.flags['ignore-destructive'],
apiVersion: this.flags['api-version'],
repo: this.flags.repo,
ignoreWhitespace: this.flags['ignore-whitespace'],
generateDelta: this.flags['generate-delta'],
include: this.flags.include,
includeDestructive: this.flags['include-destructive'],
})
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
}
}