diff --git a/package.json b/package.json index b970514..a29c336 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "texei-sfdx-plugin", "description": "Texeï's plugin for sfdx", - "version": "2.1.1", + "version": "2.1.2", "author": "Texeï", "bugs": "https://github.com/texei/texei-sfdx-plugin/issues", "dependencies": { diff --git a/src/commands/texei/package/dependencies/install.ts b/src/commands/texei/package/dependencies/install.ts index 1e4b277..77ac7ba 100644 --- a/src/commands/texei/package/dependencies/install.ts +++ b/src/commands/texei/package/dependencies/install.ts @@ -15,7 +15,7 @@ import { Flags, orgApiVersionFlagWithDeprecations, requiredOrgFlagWithDeprecations, - requiredHubFlagWithDeprecations, + optionalHubFlagWithDeprecations, loglevel, } from '@salesforce/sf-plugins-core'; import { JsonArray, JsonMap } from '@salesforce/ts-types'; @@ -49,7 +49,7 @@ export default class Install extends SfCommand public static readonly flags = { 'target-org': requiredOrgFlagWithDeprecations, - 'target-dev-hub': requiredHubFlagWithDeprecations, + 'target-dev-hub': optionalHubFlagWithDeprecations, 'api-version': orgApiVersionFlagWithDeprecations, installationkeys: Flags.string({ char: 'k', @@ -339,11 +339,16 @@ export default class Install extends SfCommand query += ' ORDER BY BuildNumber DESC Limit 1'; // Query DevHub to get the expected Package2Version - const connDevHub = flags['target-dev-hub'].getConnection(flags['api-version']); - const resultPackageId = await connDevHub.tooling.query(query); + // Check there is a DevHub + if (flags['target-dev-hub'] !== undefined) { + const connDevHub = flags['target-dev-hub'].getConnection(flags['api-version']); + const resultPackageId = await connDevHub.tooling.query(query); - if (resultPackageId.size > 0) { - packageId = resultPackageId.records[0].SubscriberPackageVersionId; + if (resultPackageId.size > 0) { + packageId = resultPackageId.records[0].SubscriberPackageVersionId; + } + } else { + throw new SfError('No default dev hub found. Use -v or --target-dev-hub to specify an environment.'); } }