Skip to content

Commit

Permalink
Removed DevHub as mandatory #57
Browse files Browse the repository at this point in the history
  • Loading branch information
FabienTaillon committed Sep 29, 2023
1 parent 8ff53b7 commit 5c072ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
17 changes: 11 additions & 6 deletions src/commands/texei/package/dependencies/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
Flags,
orgApiVersionFlagWithDeprecations,
requiredOrgFlagWithDeprecations,
requiredHubFlagWithDeprecations,
optionalHubFlagWithDeprecations,
loglevel,
} from '@salesforce/sf-plugins-core';
import { JsonArray, JsonMap } from '@salesforce/ts-types';
Expand Down Expand Up @@ -49,7 +49,7 @@ export default class Install extends SfCommand<PackageDependenciesInstallResult>

public static readonly flags = {
'target-org': requiredOrgFlagWithDeprecations,
'target-dev-hub': requiredHubFlagWithDeprecations,
'target-dev-hub': optionalHubFlagWithDeprecations,
'api-version': orgApiVersionFlagWithDeprecations,
installationkeys: Flags.string({
char: 'k',
Expand Down Expand Up @@ -339,11 +339,16 @@ export default class Install extends SfCommand<PackageDependenciesInstallResult>
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.');
}
}

Expand Down

0 comments on commit 5c072ee

Please sign in to comment.