diff --git a/.github/linters/.cspell.json b/.github/linters/.cspell.json index c184e26ce9..f3a74863f8 100644 --- a/.github/linters/.cspell.json +++ b/.github/linters/.cspell.json @@ -658,6 +658,7 @@ "httprequest", "huggingface", "iframe", + "ignoreconflicts", "ignoreerrors", "ignorerights", "ignorewarnings", @@ -998,6 +999,7 @@ "somevalue", "sont", "soql", + "sourcedir", "sourcepath", "sourceusername", "squidfunk", diff --git a/src/commands/hardis/source/retrieve.ts b/src/commands/hardis/source/retrieve.ts index 8acb8fd532..9225c762dd 100644 --- a/src/commands/hardis/source/retrieve.ts +++ b/src/commands/hardis/source/retrieve.ts @@ -43,48 +43,56 @@ This command acts as an intelligent wrapper around the Salesforce CLI's source r // @ts-ignore force char override for backward compat char: 'a', }), - sourcepath: Flags.string({ + sourcepath: Flags.string({ // deprecated, replaced by sourcedir char: 'p', description: 'sourcePath', longDescription: 'sourcePath', exclusive: ['manifest', 'metadata'], multiple: true, }), - wait: Flags.integer({ - char: 'w', - description: 'wait', + sourcedir: Flags.string({ + char: 'd', + description: 'sourceDir', + longDescription: 'sourceDir', + exclusive: ['manifest', 'metadata'], + multiple: true, }), manifest: Flags.directory({ char: 'x', description: 'manifest', - exclusive: ['metadata', 'sourcepath'], + exclusive: ['metadata', 'sourcepath', 'sourcedir'], }), metadata: Flags.string({ char: 'm', description: 'metadata', longDescription: 'metadata', - exclusive: ['manifest', 'sourcepath'], + exclusive: ['manifest', 'sourcepath', 'sourcedir'], multiple: true, }), packagenames: Flags.string({ char: 'n', + aliases: ['package-name'], description: 'packagenames', multiple: true, }), - tracksource: Flags.boolean({ + tracksource: Flags.boolean({ // deprecated char: 't', description: 'tracksource', }), - forceoverwrite: Flags.boolean({ + forceoverwrite: Flags.boolean({ // deprecated char: 'f', description: 'forceoverwrite', dependsOn: ['tracksource'], }), + ignoreconflicts: Flags.boolean({ + char: 'c', + description: 'ignoreconflicts' + }), verbose: Flags.boolean({ description: 'verbose', }), debug: Flags.boolean({ - char: 'd', + // char: 'd', // deprecated, used by sourcedir, force --debug instead default: false, description: 'debugMode', }), @@ -99,6 +107,72 @@ This command acts as an intelligent wrapper around the Salesforce CLI's source r public async run(): Promise { const { flags } = await this.parse(SourceRetrieve); + const args = this.argv; + + if(args.includes('-d')){ + uxLog("warning", this, c.red('The -d flag is deprecated for debug mode. Please use --debug instead.')); + } + if(flags.tracksource) { + uxLog("error", this, c.red('The --tracksource flag is not supported anymore.')); + process.exitCode = 1; + } + if(flags.forceoverwrite) { + uxLog("warning", this, c.red('The --forceoverwrite (-f) flag is not supported anymore. It is being automatically replaced by --ignore-conflicts (-c). Please use it going forward.')); + flags.ignoreconflicts = true; + if(args.includes('--forceoverwrite')) { + args.splice(args.indexOf('--forceoverwrite'), 1); + args.push('--ignore-conflicts'); + } + if(args.includes('-f')) { + args.splice(args.indexOf('-f'), 1); + args.push('-c'); + } + delete flags.forceoverwrite; + } + if(flags.packagenames) { + uxLog("warning", this, c.red('The --packagenames flag is not supported anymore. It is being automatically replaced by --package-names. Please use it going forward.')); + flags['package-name'] = flags.packagenames; + if(args.includes('--packagenames')) { + args.splice(args.indexOf('--packagenames'), 1); + args.push('--package-names'); + } + delete flags.packagenames; + } + if(flags.sourcepath) { + uxLog("warning", this, c.red('The --sourcepath (-p) flag is not supported anymore. It is being automatically replaced by --source-dir (-d). Please use it going forward.')); + flags['source-dir'] = flags.sourcepath; + if(args.includes('--sourcepath')) { + args.splice(args.indexOf('--sourcepath'), 1); + args.push('--source-dir'); + } + if(args.includes('-p')) { + args.splice(args.indexOf('-p'), 1); + args.push('--source-dir'); // wrap utils considers -d for debug only + } + delete flags.sourcepath; + } + if(flags.apiversion){ + uxLog("warning", this, c.red('The --apiversion flag is not supported anymore. It is being automatically replaced by --api-version. Please use it going forward.')); + flags['api-version'] = flags.apiversion; + if(args.includes('--apiversion')) { + args.splice(args.indexOf('--apiversion'), 1); + args.push('--api-version'); + } + delete flags.apiversion; + } + if(flags.targetusername){ + uxLog("warning", this, c.red('The --target-username (-u) flag is not supported anymore. It is being automatically replaced by --target-org (-o). Please use it going forward.')); + flags['target-org'] = flags.targetusername; + if(args.includes('--targetusername')) { + args.splice(args.indexOf('--targetusername'), 1); + args.push('--target-org'); + } + if(args.includes('-u')) { + args.splice(args.indexOf('-u'), 1); + args.push('-o'); + } + delete flags.targetusername; + } uxLog("error", this, c.red('This command will be removed by Salesforce in November 2024.')); uxLog("error", this, c.red('Please migrate to command sf hardis project retrieve start')); uxLog( @@ -108,7 +182,7 @@ This command acts as an intelligent wrapper around the Salesforce CLI's source r 'See https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_mig_deploy_retrieve.htm' ) ); - const args = this.argv; + // Manage user selection for metadatas if (!isCI && !flags.sourcepath && !flags.manifest && !flags.metadata && !flags.packagenames) { const metadatas = await MetadataUtils.promptMetadataTypes(); @@ -125,7 +199,7 @@ This command acts as an intelligent wrapper around the Salesforce CLI's source r throw new SfError(c.yellow('For technical reasons, run again this command and select your org in the list 😊')); } } - return await wrapSfdxCoreCommand('sfdx force:source:retrieve', args, this, flags.debug); + return await wrapSfdxCoreCommand('sf project retrieve start', args, this, flags.debug); } } /* jscpd:ignore-end */ \ No newline at end of file