Skip to content

Fix dev test account creation #1457

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

Merged
merged 4 commits into from
Apr 24, 2025
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
2 changes: 1 addition & 1 deletion lib/__tests__/buildAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('lib/buildAccount', () => {
mockParentAccountConfig.env,
10
);
expect(result).toEqual(mockDeveloperTestAccount);
expect(result).toEqual(mockDeveloperTestAccount.id);
});

it('should throw error if account ID is not found', async () => {
Expand Down
20 changes: 13 additions & 7 deletions lib/buildAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import { SANDBOX_API_TYPE_MAP, handleSandboxCreateError } from './sandboxes';
import { handleDeveloperTestAccountCreateError } from './developerTestAccounts';
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
import { DeveloperTestAccount } from '@hubspot/local-dev-lib/types/developerTestAccounts';
import { SandboxResponse } from '@hubspot/local-dev-lib/types/Sandbox';
import { SandboxAccountType } from '../types/Sandboxes';

Expand Down Expand Up @@ -91,7 +90,7 @@
parentAccountConfig: CLIAccount,
env: Environment,
portalLimit: number
): Promise<DeveloperTestAccount> {
): Promise<number> {
const i18nKey = 'lib.developerTestAccount.create.loading';

const id = getAccountIdentifier(parentAccountConfig);
Expand All @@ -112,20 +111,22 @@
}),
});

let developerTestAccount: DeveloperTestAccount;
let developerTestAccountId: number;
let developerTestAccountPersonalAccessKey: string;

try {
const { data } = await createDeveloperTestAccount(
parentAccountId,
testAccountName
);

developerTestAccount = data;
developerTestAccountId = data.id;
developerTestAccountPersonalAccessKey = data.personalAccessKey;

Check failure on line 124 in lib/buildAccount.ts

View workflow job for this annotation

GitHub Actions / build

Property 'personalAccessKey' does not exist on type 'DeveloperTestAccount'.

SpinniesManager.succeed('buildDeveloperTestAccount', {
text: i18n(`${i18nKey}.succeed`, {
accountName: testAccountName,
accountId: developerTestAccount.id,
accountId: developerTestAccountId,
}),
});
} catch (e) {
Expand All @@ -141,13 +142,18 @@
}

try {
await saveAccountToConfig(developerTestAccount.id, testAccountName, env);
await saveAccountToConfig(
developerTestAccountId,
testAccountName,
env,
developerTestAccountPersonalAccessKey
);
} catch (err) {
logError(err);
throw err;
}

return developerTestAccount;
return developerTestAccountId;
}

type SandboxAccount = SandboxResponse & {
Expand Down
4 changes: 2 additions & 2 deletions lib/localDev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,14 @@ export async function createDeveloperTestAccountForLocalDev(
accountId
);

const result = await buildDeveloperTestAccount(
const devTestAccountId = await buildDeveloperTestAccount(
name,
accountConfig,
env,
maxTestPortals
);

return result.id;
return devTestAccountId;
} catch (err) {
logError(err);
process.exit(EXIT_CODES.ERROR);
Expand Down
Loading