UNPKG

sfdx-hardis

Version:

Swiss-army-knife Toolbox for Salesforce. Allows you to define a complete CD/CD Pipeline. Orchestrate base commands and assist users with interactive wizards

82 lines 3.62 kB
/* jscpd:ignore-start */ import { SfCommand, Flags, requiredHubFlagWithDeprecations } from '@salesforce/sf-plugins-core'; import { Messages } from '@salesforce/core'; import c from 'chalk'; import { execSfdxJson, uxLog } from '../../../common/utils/index.js'; import { prompts } from '../../../common/utils/prompts.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('sfdx-hardis', 'org'); export default class PackageCreate extends SfCommand { static title = 'Create a new package'; static description = messages.getMessage('packageCreate'); static examples = ['$ sf hardis:package:create']; // public static args = [{name: 'file'}]; static flags = { debug: Flags.boolean({ char: 'd', default: false, description: messages.getMessage('debugMode'), }), websocket: Flags.string({ description: messages.getMessage('websocket'), }), skipauth: Flags.boolean({ description: 'Skip authentication check when a default username is required', }), 'target-dev-hub': requiredHubFlagWithDeprecations, }; // Set this to true if your command requires a project workspace; 'requiresProject' is false by default static requiresProject = true; /* jscpd:ignore-end */ async run() { const { flags } = await this.parse(PackageCreate); const debugMode = flags.debug || false; // Request questions to user const packageResponse = await prompts([ { type: 'text', name: 'packageName', message: c.cyanBright(`Please input the name of the package (ex: MyPackage)`), }, { type: 'text', name: 'packagePath', message: c.cyanBright(`Please input the path of the package (ex: sfdx-source/apex-mocks)`), }, { type: 'select', name: 'packageType', message: c.cyanBright(`Please select the type of the package`), choices: [ { title: 'Managed', value: 'Managed', description: 'Managed packages code is hidden in orgs where it is installed. Suited for AppExchanges packages', }, { title: 'Unlocked', value: 'Unlocked', description: 'Unlocked packages code is readable and modifiable in orgs where it is installed. Use it for client project or shared tooling', }, ], }, ]); // Create package const packageCreateCommand = 'sf package create' + ` --name "${packageResponse.packageName}"` + ` --package-type ${packageResponse.packageType}` + ` --path "${packageResponse.packagePath}"`; const packageCreateResult = await execSfdxJson(packageCreateCommand, this, { output: true, fail: true, debug: debugMode, }); uxLog(this, c.cyan(`Created package Id: ${c.green(packageCreateResult.result.Id)} associated to DevHub ${c.green(flags['target-dev-hub'].getUsername())}`)); // Return an object to be displayed with --json return { outputString: `Create new package ${packageCreateResult.result.Id}`, packageId: packageCreateResult.result.Id, }; } } //# sourceMappingURL=create.js.map