Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with account middleware in hs project dev #1303

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions commands/project/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const { logger } = require('@hubspot/local-dev-lib/logger');
const {
getConfigAccounts,
getAccountConfig,
getAccountId: getAccountIdFromConfig,
getEnv,
} = require('@hubspot/local-dev-lib/config');
const {
Expand Down Expand Up @@ -57,7 +58,9 @@ exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);

exports.handler = async options => {
await loadAndValidateOptions(options);
const { derivedAccountId } = options;
const { derivedAccountId, providedAccountId } = options;
const parsedProvidedAccountId = getAccountIdFromConfig(providedAccountId);
const providedAccountConfig = getAccountConfig(parsedProvidedAccountId);
const accountConfig = getAccountConfig(derivedAccountId);
const env = getValidEnv(getEnv(derivedAccountId));

Expand Down Expand Up @@ -107,16 +110,20 @@ exports.handler = async options => {
(!hasPublicApps && isSandbox(accountConfig));

// The account that the project must exist in
let targetProjectAccountId = derivedAccountId;
let targetProjectAccountId = providedAccountId
? parsedProvidedAccountId
: null;
// The account that we are locally testing against
let targetTestingAccountId = derivedAccountId;
let targetTestingAccountId = providedAccountId
? parsedProvidedAccountId
: null;

// Check that the default account or flag option is valid for the type of app in this project
if (derivedAccountId) {
checkIfAccountFlagIsSupported(accountConfig, hasPublicApps);
if (providedAccountId) {
kemmerle marked this conversation as resolved.
Show resolved Hide resolved
checkIfAccountFlagIsSupported(providedAccountConfig, hasPublicApps);

if (hasPublicApps) {
targetProjectAccountId = accountConfig.parentAccountId;
targetProjectAccountId = providedAccountConfig.parentAccountId;
}
} else {
checkIfDefaultAccountIsSupported(accountConfig, hasPublicApps);
Expand Down
1 change: 0 additions & 1 deletion lib/commonOpts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export function addUseEnvironmentOptions(yargs: Argv): Argv {
.option('use-env', {
describe: i18n(`${i18nKey}.options.useEnv.describe`),
type: 'boolean',
default: false,
})
.conflicts('use-env', 'account');
}
Expand Down
12 changes: 7 additions & 5 deletions lib/localDev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const checkIfParentAccountIsAuthed = accountConfig => {
// Confirm the default account is a developer account if developing public apps
const checkIfAccountFlagIsSupported = (accountConfig, hasPublicApps) => {
if (hasPublicApps) {
if (!isDeveloperTestAccount) {
if (!isDeveloperTestAccount(accountConfig)) {
logger.error(
i18n(`${i18nKey}.validateAccountOption.invalidPublicAppAccount`, {
useCommand: uiCommandReference('hs accounts use'),
Expand Down Expand Up @@ -248,8 +248,9 @@ const createDeveloperTestAccountForLocalDev = async (
let currentPortalCount = 0;
let maxTestPortals = 10;
try {
const validateResult =
await validateDevTestAccountUsageLimits(accountConfig);
const validateResult = await validateDevTestAccountUsageLimits(
accountConfig
);
if (validateResult) {
currentPortalCount = validateResult.results
? validateResult.results.length
Expand Down Expand Up @@ -305,8 +306,9 @@ const createDeveloperTestAccountForLocalDev = async (

// Prompt user to confirm usage of an existing developer test account that is not currently in the config
const useExistingDevTestAccount = async (env, account) => {
const useExistingDevTestAcct =
await confirmUseExistingDeveloperTestAccountPrompt(account);
const useExistingDevTestAcct = await confirmUseExistingDeveloperTestAccountPrompt(
account
);
if (!useExistingDevTestAcct) {
logger.log('');
logger.log(
Expand Down
Loading