diff --git a/README.md b/README.md index 8045982cd..fcf053e93 100644 --- a/README.md +++ b/README.md @@ -142,23 +142,32 @@ Generate incremental package manifest and source content ``` USAGE - $ sf sgd source delta -f [--json] [--flags-dir ] [-a ] [-d] [-i ] [-D ] [-W] [-n - ] [-N ] [-o ] [-r ] [-s ] [-t ] + $ sf sgd source delta -f [--json] [--flags-dir ] [-a ] [-d] [--ignore ] [-i ] + [--ignore-destructive ] [-D ] [-W] [--include ] [-n ] [--include-destructive ] + [-N ] [--output ] [-o ] [--repo ] [-r ] [--source ] [-s ] [-t + ] FLAGS - -D, --ignore-destructive= file listing paths to explicitly ignore for any destructive actions - -N, --include-destructive= file listing paths to explicitly include for any destructive actions - -W, --ignore-whitespace ignore git diff whitespace (space, tab, eol) changes - -a, --api-version= salesforce metadata API version, default to sfdx-project.json "sourceApiVersion" - attribute or latest version - -d, --generate-delta generate delta files in [--output] folder - -f, --from= (required) commit sha from where the diff is done - -i, --ignore= file listing paths to explicitly ignore for any diff actions - -n, --include= file listing paths to explicitly include for any diff actions - -o, --output= [default: ./output] source package specific output - -r, --repo= [default: ./] git repository location - -s, --source= [default: ./] source folder focus location related to --repo - -t, --to= [default: HEAD] commit sha to where the diff is done + -D, --ignore-destructive-file= file listing paths to explicitly ignore for any destructive actions + -N, --include-destructive-file= file listing paths to explicitly include for any destructive actions + -W, --ignore-whitespace ignore git diff whitespace (space, tab, eol) changes + -a, --api-version= salesforce metadata API version, default to sfdx-project.json + "sourceApiVersion" attribute or latest version + -d, --generate-delta generate delta files in [--output] folder + -f, --from= (required) commit sha from where the diff is done + -i, --ignore-file= file listing paths to explicitly ignore for any diff actions + -n, --include-file= file listing paths to explicitly include for any diff actions + -o, --output-dir= [default: ./output] source package specific output + -r, --repo-dir= [default: ./] git repository location + -s, --source-dir= [default: ./] source folder focus location related to --repo + -t, --to= [default: HEAD] commit sha to where the diff is done + --ignore= /!\ deprecated, use '--ignore-file' instead. + --ignore-destructive= /!\ deprecated, use '--ignore-destructive-file' instead. + --include= /!\ deprecated, use '--include-file' instead. + --include-destructive= /!\ deprecated, use '--include-destructive-file' instead. + --output= /!\ deprecated, use '--output-dir' instead. + --repo= /!\ deprecated, use '--repo-dir' instead. + --source= /!\ deprecated, use '--source-dir' instead. GLOBAL FLAGS --flags-dir= Import flag values from a directory. diff --git a/__tests__/functional/delta.nut.ts b/__tests__/functional/delta.nut.ts index 67771f027..bbe785590 100644 --- a/__tests__/functional/delta.nut.ts +++ b/__tests__/functional/delta.nut.ts @@ -31,8 +31,7 @@ describe('sgd source delta NUTS', () => { ) expect(packageLineCount).to.equal(232) expect(destructiveChangesLineCount).to.equal(137) - expect(result).to.include('"error": null') - expect(result).to.include('"success": true') + expect(result).to.include('"status": 0') }) }) diff --git a/command-snapshot.json b/command-snapshot.json index 31583ea11..dd3885cd4 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -24,13 +24,20 @@ "generate-delta", "ignore", "ignore-destructive", + "ignore-destructive-file", + "ignore-file", "ignore-whitespace", "include", "include-destructive", + "include-destructive-file", + "include-file", "json", "output", + "output-dir", "repo", + "repo-dir", "source", + "source-dir", "to" ], "plugin": "sfdx-git-delta" diff --git a/messages/delta.md b/messages/delta.md index ce3f65826..e1f3c498c 100644 --- a/messages/delta.md +++ b/messages/delta.md @@ -64,6 +64,10 @@ file listing paths to explicitly include for any diff actions file listing paths to explicitly include for any destructive actions +# flags.deprecated + +/!\ deprecated, use '--%s' instead. + # error.ParameterIsNotGitSHA --%s is not a valid sha pointer: '%s' (If in CI/CD context, check the fetch depth is properly set) @@ -80,6 +84,10 @@ API version not found or not supported, using '%s' instead Attempt to delete the flow '%s' via destructiveChanges.xml may not work as expected (see https://github.com/scolladon/sfdx-git-delta#handle-flow-deletion) +# warning.oldParameters + +Using the '--%s' parameter is deprecated and will soon be obsolete. Use '--%s' parameter instead. + # info.CommandIsRunning Generating incremental package diff --git a/package.json b/package.json index c2bb6ee5d..59d62be31 100644 --- a/package.json +++ b/package.json @@ -206,7 +206,7 @@ ] }, "lint:deprecation-policy": { - "command": "./bin/dev.js snapshot:compare", + "command": "./bin/dev.js snapshot compare", "files": [ "lib/commands/**/*.ts" ], @@ -216,7 +216,7 @@ ] }, "lint:json-schema": { - "command": "./bin/dev.js schema:compare", + "command": "./bin/dev.js schema compare", "files": [ "lib/commands/**/*.ts", "schemas" diff --git a/schemas/sgd-source-delta.json b/schemas/sgd-source-delta.json index 59eecd901..491ee9af3 100644 --- a/schemas/sgd-source-delta.json +++ b/schemas/sgd-source-delta.json @@ -6,29 +6,14 @@ "type": "object", "properties": { "error": { - "type": [ - "string", - "null" - ] - }, - "output": { "type": "string" }, - "success": { - "type": "boolean" - }, - "warnings": { - "type": "array", - "items": { - "type": "string" - } + "output-dir": { + "type": "string" } }, "required": [ - "error", - "output", - "success", - "warnings" + "output-dir" ], "additionalProperties": false } diff --git a/src/commands/sgd/source/delta.ts b/src/commands/sgd/source/delta.ts index ebbd42eb6..f8a375084 100644 --- a/src/commands/sgd/source/delta.ts +++ b/src/commands/sgd/source/delta.ts @@ -11,6 +11,8 @@ import { TO_DEFAULT_VALUE, } from '../../../utils/cliConstants.js' +import { camelCase } from 'lodash-es' + const messages = new MessageService() export default class SourceDeltaGenerate extends SfCommand { @@ -34,11 +36,21 @@ export default class SourceDeltaGenerate extends SfCommand { summary: messages.getMessage('flags.generate-delta.summary'), }), ignore: Flags.file({ + summary: messages.getMessage('flags.deprecated', ['ignore-file']), + exists: true, + }), + 'ignore-file': Flags.file({ char: 'i', summary: messages.getMessage('flags.ignore.summary'), exists: true, }), 'ignore-destructive': Flags.file({ + summary: messages.getMessage('flags.deprecated', [ + 'ignore-destructive-file', + ]), + exists: true, + }), + 'ignore-destructive-file': Flags.file({ char: 'D', summary: messages.getMessage('flags.ignore-destructive.summary'), exists: true, @@ -48,28 +60,50 @@ export default class SourceDeltaGenerate extends SfCommand { summary: messages.getMessage('flags.ignore-whitespace.summary'), }), include: Flags.file({ + summary: messages.getMessage('flags.deprecated', ['include-file']), + exists: true, + }), + 'include-file': Flags.file({ char: 'n', summary: messages.getMessage('flags.include.summary'), exists: true, }), 'include-destructive': Flags.file({ + summary: messages.getMessage('flags.deprecated', [ + 'include-destructive-file', + ]), + exists: true, + }), + 'include-destructive-file': Flags.file({ char: 'N', summary: messages.getMessage('flags.include-destructive.summary'), exists: true, }), output: Flags.directory({ + summary: messages.getMessage('flags.deprecated', ['output-dir']), + exists: true, + }), + 'output-dir': Flags.directory({ char: 'o', summary: messages.getMessage('flags.output.summary'), default: OUTPUT_DEFAULT_VALUE, exists: true, }), repo: Flags.directory({ + summary: messages.getMessage('flags.deprecated', ['repo-dir']), + exists: true, + }), + 'repo-dir': Flags.directory({ char: 'r', summary: messages.getMessage('flags.repo.summary'), default: REPO_DEFAULT_VALUE, exists: true, }), source: Flags.directory({ + summary: messages.getMessage('flags.deprecated', ['source-dir']), + exists: true, + }), + 'source-dir': Flags.directory({ char: 's', summary: messages.getMessage('flags.source.summary'), default: SOURCE_DEFAULT_VALUE, @@ -84,46 +118,66 @@ export default class SourceDeltaGenerate extends SfCommand { public async run(): Promise { const { flags } = await this.parse(SourceDeltaGenerate) - const output: SgdResult = { - error: null, - output: flags['output'], - success: true, - warnings: [], - } + const config: Config = { apiVersion: flags['api-version'], from: flags['from'], generateDelta: flags['generate-delta'], - ignore: flags['ignore'], - ignoreDestructive: flags['ignore-destructive'], + ignore: flags['ignore-file'], + ignoreDestructive: flags['ignore-destructive-file'], ignoreWhitespace: flags['ignore-whitespace'], - include: flags['include'], - includeDestructive: flags['include-destructive'], - output: flags['output'], - repo: flags['repo'], - source: flags['source'], + include: flags['include-file'], + includeDestructive: flags['include-destructive-file'], + output: flags['output-dir'], + repo: flags['repo-dir'], + source: flags['source-dir'], to: flags['to'], } + + this.recoverOldParametersUsage(config, flags) + this.spinner.start( messages.getMessage('info.CommandIsRunning'), undefined, { stdout: true } ) + const output: SgdResult = { + 'output-dir': config.output, + } try { const jobResult = await sgd(config) - if (jobResult.warnings?.length > 0) { - output.warnings = jobResult.warnings.map( - (warning: Error) => warning.message - ) - } + jobResult.warnings?.forEach(this.warn) } catch (err) { if (err instanceof Error) { output.error = err.message } - output.success = false process.exitCode = 1 } this.spinner.stop(messages.getMessage('info.CommandHasRun')) return output } + + // biome-ignore lint/suspicious/noExplicitAny: + private recoverOldParametersUsage(config: Config, flags: any) { + for (const [oldParameter, newParameter] of Object.entries({ + ignore: 'ignore-file', + 'ignore-destructive': 'ignore-destructive-file', + include: 'include-file', + 'include-destructive': 'include-destructive-file', + output: 'output-dir', + repo: 'repo-dir', + source: 'source-dir', + })) { + if (oldParameter in flags) { + this.warn( + messages.getMessage('warning.oldParameters', [ + oldParameter, + newParameter, + ]) + ) + const configAttribut = camelCase(oldParameter) as never + config[configAttribut] = flags[oldParameter as never] as never + } + } + } } diff --git a/src/types/sgdResult.ts b/src/types/sgdResult.ts index af357a7bd..fc5bc8627 100644 --- a/src/types/sgdResult.ts +++ b/src/types/sgdResult.ts @@ -1,6 +1,4 @@ export type SgdResult = { - error: string | null - output: string - success: boolean - warnings: string[] + error?: string + 'output-dir': string }