@hubspot/local-dev-lib 0.5.0-experimental.1 → 0.5.0-experimental.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -122,9 +122,9 @@ exports.authorizedScopesForPortalAndUser = authorizedScopesForPortalAndUser;
122
122
  async function updateConfigWithAccessToken(token, personalAccessKey, env, name, makeDefault = false) {
123
123
  const { portalId, accessToken, expiresAt, accountType } = token;
124
124
  const account = name
125
- ? (0, config_1.getConfigAccountByName)(name)
126
- : (0, config_1.getConfigDefaultAccount)();
127
- const accountEnv = env || account.env;
125
+ ? (0, config_1.getConfigAccountIfExists)(name)
126
+ : (0, config_1.getConfigDefaultAccountIfExists)();
127
+ const accountEnv = env || account?.env || environments_1.ENVIRONMENTS.PROD;
128
128
  let parentAccountId;
129
129
  try {
130
130
  if (accountType === config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX ||
@@ -161,15 +161,21 @@ async function updateConfigWithAccessToken(token, personalAccessKey, env, name,
161
161
  accountId: portalId,
162
162
  accountType,
163
163
  personalAccessKey,
164
- name: name || account.name,
164
+ name: name || account?.name || token.hubName,
165
165
  authType: auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
166
166
  auth: { tokenInfo: { accessToken, expiresAt } },
167
167
  parentAccountId,
168
168
  env: accountEnv,
169
169
  };
170
- (0, config_1.updateConfigAccount)(updatedAccount);
171
- if (makeDefault && name) {
172
- (0, config_1.setConfigAccountAsDefault)(name);
170
+ // Add new account if it doesn't exist, otherwise update existing account
171
+ if (account) {
172
+ (0, config_1.updateConfigAccount)(updatedAccount);
173
+ }
174
+ else {
175
+ (0, config_1.addConfigAccount)(updatedAccount);
176
+ }
177
+ if (makeDefault) {
178
+ (0, config_1.setConfigAccountAsDefault)(updatedAccount.accountId);
173
179
  }
174
180
  return updatedAccount;
175
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "0.5.0-experimental.1",
3
+ "version": "0.5.0-experimental.2",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "repository": {
6
6
  "type": "git",