diff --git a/packages/sfpowerscripts-cli/messages/install_data_package.json b/packages/sfpowerscripts-cli/messages/install_data_package.json index f11673135..5b883e245 100644 --- a/packages/sfpowerscripts-cli/messages/install_data_package.json +++ b/packages/sfpowerscripts-cli/messages/install_data_package.json @@ -1,5 +1,5 @@ { - "commandDescription": "Installs a SFDMU-based data package consisting of csvfiles and export.json to a target org", + "commandDescription": "(DEPRECATED) Installs a SFDMU-based data package consisting of csvfiles and export.json to a target org", "packageFlagDescription": "Name of the package to be installed", "targetOrgFlagDescription": "Alias/User Name of the target environment", "artifactDirectoryFlagDescription": "The directory where the artifact is located", diff --git a/packages/sfpowerscripts-cli/messages/install_package.json b/packages/sfpowerscripts-cli/messages/install_package.json new file mode 100644 index 000000000..89db89720 --- /dev/null +++ b/packages/sfpowerscripts-cli/messages/install_package.json @@ -0,0 +1,14 @@ +{ + "commandDescription": "Installs a sfpowerscripts artifact to an org", + "packageFlagDescription": "Name of the package to be installed", + "targetOrgFlagDescription": "Alias/User Name of the target environment", + "apexCompileOnlyPackageFlagDescription": "(unlocked) package installation triggers a compilation of apex, flag to trigger compilation of package only", + "artifactDirectoryFlagDescription": "The directory where the artifact is located", + "securityTypeFlagDescription": "(unlocked) Select the security access for the package installation", + "optimizedeployment": "(source) Optimize deployment by triggering test classes that are in the package, rather than using the whole tests in the org", + "skiptesting": "(source) Skips running test when deploying to a sandbox", + "upgradeTypeFlagDescription": "(unlocked)the upgrade type for the package installation", + "waitTimeFlagDescription": "wait time for command to finish in minutes", + "publishWaitTimeFlagDescription": "(unlocked) number of minutes to wait for subscriber package version ID to become available in the target org", + "skipIfAlreadyInstalled": "Skip the installation if the package is already installed in the org" +} diff --git a/packages/sfpowerscripts-cli/messages/install_source_package.json b/packages/sfpowerscripts-cli/messages/install_source_package.json index fb6a45f47..11e743801 100644 --- a/packages/sfpowerscripts-cli/messages/install_source_package.json +++ b/packages/sfpowerscripts-cli/messages/install_source_package.json @@ -1,5 +1,5 @@ { - "commandDescription": "Installs a sfpowerscripts source package to the target org", + "commandDescription": "(DEPRECATED) Installs a sfpowerscripts source package to the target org", "packageFlagDescription": "Name of the package to be installed", "targetOrgFlagDescription": "Alias/User Name of the target environment", "artifactDirectoryFlagDescription": "The directory where the artifact is located", diff --git a/packages/sfpowerscripts-cli/messages/install_unlocked_package.json b/packages/sfpowerscripts-cli/messages/install_unlocked_package.json index fd458efa9..454034c9d 100644 --- a/packages/sfpowerscripts-cli/messages/install_unlocked_package.json +++ b/packages/sfpowerscripts-cli/messages/install_unlocked_package.json @@ -1,5 +1,5 @@ { - "commandDescription": "Installs an unlocked package using sfpowerscripts metadata", + "commandDescription": "(DEPRECATED) Installs an unlocked package using sfpowerscripts metadata", "packageFlagDescription": "Name of the package to be installed", "targetOrgFlagDescription": "Alias/User Name of the target environment", "packageInstalledFromFlagDescription": "automatically retrieve the version ID of the package to be installed, from the build artifact", diff --git a/packages/sfpowerscripts-cli/src/InstallPackageCommand.ts b/packages/sfpowerscripts-cli/src/InstallPackageCommand.ts index 74f6eebc8..ed6767c53 100644 --- a/packages/sfpowerscripts-cli/src/InstallPackageCommand.ts +++ b/packages/sfpowerscripts-cli/src/InstallPackageCommand.ts @@ -34,10 +34,6 @@ export default abstract class InstallPackageCommand extends SfpowerscriptsComman description: messages.getMessage('artifactDirectoryFlagDescription'), default: 'artifacts', }), - skiponmissingartifact: Flags.boolean({ - char: 's', - description: messages.getMessage('skipOnMissingArtifactFlagDescription'), - }), }; protected artifact: Artifact; diff --git a/packages/sfpowerscripts-cli/src/commands/package/data/install.ts b/packages/sfpowerscripts-cli/src/commands/package/data/install.ts index 318a9968a..945d078d7 100644 --- a/packages/sfpowerscripts-cli/src/commands/package/data/install.ts +++ b/packages/sfpowerscripts-cli/src/commands/package/data/install.ts @@ -1,7 +1,7 @@ import { Messages } from '@salesforce/core'; import InstallPackageCommand from '../../../InstallPackageCommand'; import { PackageInstallationStatus } from '@dxatscale/sfpowerscripts.core/lib/package/packageInstallers/PackageInstallationResult'; -import { ConsoleLogger } from '@dxatscale/sfp-logger'; +import SFPLogger, { ConsoleLogger, LoggerLevel } from '@dxatscale/sfp-logger'; import SfpPackageInstaller from '@dxatscale/sfpowerscripts.core/lib/package/SfpPackageInstaller'; import { SfpPackageInstallationOptions } from '@dxatscale/sfpowerscripts.core/lib/package/packageInstallers/InstallPackage'; import { Flags } from '@oclif/core'; @@ -20,6 +20,8 @@ export default class InstallDataPackage extends InstallPackageCommand { public static examples = [`$ sfp package:data:install -n mypackage -u `]; + public static deprecated:boolean = true; + public static flags = { package: Flags.string({ char: 'n', @@ -45,6 +47,9 @@ export default class InstallDataPackage extends InstallPackageCommand { public async install() { try { + SFPLogger.log(`This command is now deprecated, please proceed to use sfp package:install instead`,LoggerLevel.WARN) + + const skipIfAlreadyInstalled = this.flags.skipifalreadyinstalled; let options: SfpPackageInstallationOptions = { skipIfPackageInstalled: skipIfAlreadyInstalled diff --git a/packages/sfpowerscripts-cli/src/commands/package/install.ts b/packages/sfpowerscripts-cli/src/commands/package/install.ts new file mode 100644 index 000000000..b21ecaf35 --- /dev/null +++ b/packages/sfpowerscripts-cli/src/commands/package/install.ts @@ -0,0 +1,141 @@ +import { Messages } from '@salesforce/core'; +import InstallPackageCommand from '../../InstallPackageCommand'; +import { PackageInstallationStatus } from '@dxatscale/sfpowerscripts.core/lib/package/packageInstallers/PackageInstallationResult'; +import SFPLogger, { COLOR_HEADER, COLOR_KEY_MESSAGE, ConsoleLogger, LoggerLevel } from '@dxatscale/sfp-logger'; +import { SfpPackageInstallationOptions } from '@dxatscale/sfpowerscripts.core/lib/package/packageInstallers/InstallPackage'; +import SfpPackageInstaller from '@dxatscale/sfpowerscripts.core/lib/package/SfpPackageInstaller'; +import { Flags } from '@oclif/core'; +import { loglevel, requiredUserNameFlag } from '../../flags/sfdxflags'; +import { PackageType } from '@dxatscale/sfpowerscripts.core/lib/package/SfpPackage'; + + +Messages.importMessagesDirectory(__dirname); +const messages = Messages.loadMessages('@dxatscale/sfpowerscripts', 'install_package'); + +export default class Install extends InstallPackageCommand { + public static description = messages.getMessage('commandDescription'); + + public static examples = [`$ sfp package:install -n packagename -u sandboxalias -i`]; + + public static flags = { + package: Flags.string({ + char: 'n', + description: messages.getMessage('packageFlagDescription'), + }), + targetorg: requiredUserNameFlag, + apexcompileonlypackage: Flags.boolean({ + char: 'a', + description: messages.getMessage('apexCompileOnlyPackageFlagDescription'), + }), + artifactdir: Flags.directory({ + description: messages.getMessage('artifactDirectoryFlagDescription'), + default: 'artifacts', + }), + securitytype: Flags.string({ + description: messages.getMessage('securityTypeFlagDescription'), + options: ['full', 'none'], + default: 'none', + }), + skipifalreadyinstalled: Flags.boolean({ + char: 'f', + description: messages.getMessage('skipIfAlreadyInstalled'), + }), + upgradetype: Flags.string({ + description: messages.getMessage('upgradeTypeFlagDescription'), + options: ['delete-only', 'deprecate-only', 'mixed-mode'], + default: 'mixed-mode', + }), + optimizedeployment: Flags.boolean({ + char: 'o', + description: messages.getMessage('optimizedeployment'), + default: false, + required: false, + }), + skiptesting: Flags.boolean({ + char: 't', + description: messages.getMessage('skiptesting'), + default: false, + required: false, + }), + waittime: Flags.string({ + description: messages.getMessage('waitTimeFlagDescription'), + default: '120', + }), + publishwaittime: Flags.string({ + description: messages.getMessage('publishWaitTimeFlagDescription'), + default: '10', + }), + loglevel + }; + + protected static requiresUsername = true; + protected static requiresDevhubUsername = false; + + public async install() { + try { + const installationkey = this.flags.installationkey; + const apexcompileonlypackage = this.flags.apexcompileonlypackage; + const security_type = this.flags.securitytype; + const upgrade_type = this.flags.upgradetype; + const waitTime = this.flags.waittime; + const publishWaitTime = this.flags.publishwaittime; + const skipIfAlreadyInstalled = this.flags.skipifalreadyinstalled; + const optimizeDeployment: boolean = this.flags.optimizedeployment; + const skipTesting: boolean = this.flags.skiptesting; + + + SFPLogger.log(COLOR_HEADER(`command: ${COLOR_KEY_MESSAGE(`install`)}`)); + SFPLogger.log(COLOR_HEADER(`Package Name: ${this.sfpPackage.packageName}`)); + SFPLogger.log(COLOR_HEADER(`Package Type: ${this.sfpPackage.packageType}`)); + SFPLogger.log(COLOR_HEADER(`Skip Packages If Already Installed: ${this.flags.skipifalreadyinstalled?`true`:`false`}`)); + SFPLogger.log(COLOR_HEADER(`Artifact Directory: ${this.flags.artifactdir}`)); + SFPLogger.log(COLOR_HEADER(`Target Environment: ${this.flags.targetorg}`)); + + + if(this.sfpPackage.packageType == PackageType.Unlocked) + { + + SFPLogger.log(COLOR_HEADER(`Security Type: ${this.flags.securitytype}`)); + SFPLogger.log(COLOR_HEADER(`Upgrade Type: ${this.flags.upgradetype}`)); + SFPLogger.log(COLOR_HEADER(`Apex Compile Mode: ${ apexcompileonlypackage ? `package` : `all`}`)); + } + else if(this.sfpPackage.packageType == PackageType.Source) + { + SFPLogger.log(COLOR_HEADER(`Optimize Deployment: ${this.flags.optimizedeployment}`)); + SFPLogger.log(COLOR_HEADER(`Skip Testing: ${this.flags.skiptesting}`)); + } + + + SFPLogger.printHeaderLine('',COLOR_HEADER,LoggerLevel.INFO); + + + let options: SfpPackageInstallationOptions = { + installationkey: installationkey, + apexcompile: apexcompileonlypackage ? `package` : `all`, + securitytype: security_type, + optimizeDeployment: optimizeDeployment, + skipTesting: skipTesting, + upgradetype: upgrade_type, + waitTime: waitTime, + publishWaitTime: publishWaitTime, + disableArtifactCommit: false, + skipIfPackageInstalled: skipIfAlreadyInstalled, + apiVersion: this.sfpPackage.apiVersion + }; + + let result = await SfpPackageInstaller.installPackage( + new ConsoleLogger(), + this.sfpPackage, + this.sfpOrg, + options + ); + + if (result.result === PackageInstallationStatus.Failed) { + throw new Error(result.message); + } + } catch (err) { + console.log(err); + process.exitCode = 1; + } + } +} diff --git a/packages/sfpowerscripts-cli/src/commands/package/source/install.ts b/packages/sfpowerscripts-cli/src/commands/package/source/install.ts index 94219d470..f553bc66a 100644 --- a/packages/sfpowerscripts-cli/src/commands/package/source/install.ts +++ b/packages/sfpowerscripts-cli/src/commands/package/source/install.ts @@ -2,7 +2,7 @@ import { Messages } from '@salesforce/core'; import InstallPackageCommand from '../../../InstallPackageCommand'; import * as fs from 'fs-extra'; import { PackageInstallationStatus } from '@dxatscale/sfpowerscripts.core/lib/package/packageInstallers/PackageInstallationResult'; -import { ConsoleLogger } from '@dxatscale/sfp-logger'; +import SFPLogger, { ConsoleLogger, LoggerLevel } from '@dxatscale/sfp-logger'; import { DeploymentType } from '@dxatscale/sfpowerscripts.core/lib/deployers/DeploymentExecutor'; import { SfpPackageInstallationOptions } from '@dxatscale/sfpowerscripts.core/lib/package/packageInstallers/InstallPackage'; import SfpPackageInstaller from '@dxatscale/sfpowerscripts.core/lib/package/SfpPackageInstaller'; @@ -21,6 +21,8 @@ export default class InstallSourcePackage extends InstallPackageCommand { public static examples = [`$ sfp package:source:install -n mypackage -u `]; + public static deprecated:boolean = true; + public static flags = { package: Flags.string({ char: 'n', @@ -63,6 +65,9 @@ export default class InstallSourcePackage extends InstallPackageCommand { public async install(): Promise { + SFPLogger.log(`This command is now deprecated, please proceed to use sfp package:install instead`,LoggerLevel.WARN) + + const sfdx_package: string = this.flags.package; const optimizeDeployment: boolean = this.flags.optimizedeployment; const skipTesting: boolean = this.flags.skiptesting; diff --git a/packages/sfpowerscripts-cli/src/commands/package/unlocked/install.ts b/packages/sfpowerscripts-cli/src/commands/package/unlocked/install.ts index d7e6e5d88..e41fdb666 100644 --- a/packages/sfpowerscripts-cli/src/commands/package/unlocked/install.ts +++ b/packages/sfpowerscripts-cli/src/commands/package/unlocked/install.ts @@ -1,7 +1,7 @@ import { Messages } from '@salesforce/core'; import InstallPackageCommand from '../../../InstallPackageCommand'; import { PackageInstallationStatus } from '@dxatscale/sfpowerscripts.core/lib/package/packageInstallers/PackageInstallationResult'; -import { ConsoleLogger } from '@dxatscale/sfp-logger'; +import SFPLogger, { ConsoleLogger, LoggerLevel } from '@dxatscale/sfp-logger'; import { SfpPackageInstallationOptions } from '@dxatscale/sfpowerscripts.core/lib/package/packageInstallers/InstallPackage'; import SfpPackageInstaller from '@dxatscale/sfpowerscripts.core/lib/package/SfpPackageInstaller'; import { Flags } from '@oclif/core'; @@ -20,6 +20,8 @@ export default class InstallUnlockedPackage extends InstallPackageCommand { public static examples = [`$ sfp package:unlocked:install -n packagename -u sandboxalias -i`]; + public static deprecated:boolean = true; + public static flags = { package: Flags.string({ char: 'n', @@ -72,6 +74,9 @@ export default class InstallUnlockedPackage extends InstallPackageCommand { protected static requiresDevhubUsername = false; public async install() { + + SFPLogger.log(`This command is now deprecated, please proceed to use sfp package:install instead`,LoggerLevel.WARN) + try { const installationkey = this.flags.installationkey; const apexcompileonlypackage = this.flags.apexcompileonlypackage;