@hubspot/local-dev-lib 2.0.1 → 2.1.0
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.
- package/api/hubdb.d.ts +2 -1
- package/api/hubdb.js +7 -1
- package/config/CLIConfiguration.d.ts +4 -3
- package/config/CLIConfiguration.js +41 -16
- package/config/getAccountIdentifier.d.ts +2 -0
- package/config/getAccountIdentifier.js +15 -0
- package/config/index.d.ts +9 -7
- package/config/index.js +35 -11
- package/constants/config.d.ts +1 -1
- package/constants/config.js +1 -1
- package/lib/cms/modules.js +2 -2
- package/lib/oauth.js +1 -1
- package/lib/personalAccessKey.js +6 -3
- package/lib/portManager.d.ts +1 -0
- package/lib/portManager.js +2 -1
- package/models/OAuth2Manager.js +1 -1
- package/package.json +2 -1
- package/types/Hubdb.d.ts +9 -0
- package/types/Modules.d.ts +1 -0
- package/utils/{getAccountIdentifier.d.ts → accounts.d.ts} +1 -2
- package/utils/{getAccountIdentifier.js → accounts.js} +1 -13
package/api/hubdb.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AxiosPromise } from 'axios';
|
|
2
2
|
import { QueryParams } from '../types/Http';
|
|
3
|
-
import { CreateRowsResponse, FetchRowsResponse, Row, Schema, Table } from '../types/Hubdb';
|
|
3
|
+
import { CreateRowsResponse, FetchRowsResponse, Row, Schema, Table, FetchTablesResponse } from '../types/Hubdb';
|
|
4
|
+
export declare function fetchTables(accountId: number): AxiosPromise<FetchTablesResponse>;
|
|
4
5
|
export declare function fetchTable(accountId: number, tableId: string): AxiosPromise<Table>;
|
|
5
6
|
export declare function createTable(accountId: number, schema: Schema): AxiosPromise<Table>;
|
|
6
7
|
export declare function updateTable(accountId: number, tableId: string, schema: Schema): AxiosPromise<Table>;
|
package/api/hubdb.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteRows = exports.fetchRows = exports.createRows = exports.deleteTable = exports.publishTable = exports.updateTable = exports.createTable = exports.fetchTable = void 0;
|
|
3
|
+
exports.deleteRows = exports.fetchRows = exports.createRows = exports.deleteTable = exports.publishTable = exports.updateTable = exports.createTable = exports.fetchTable = exports.fetchTables = void 0;
|
|
4
4
|
const http_1 = require("../http");
|
|
5
5
|
const HUBDB_API_PATH = 'cms/v3/hubdb';
|
|
6
|
+
function fetchTables(accountId) {
|
|
7
|
+
return http_1.http.get(accountId, {
|
|
8
|
+
url: `${HUBDB_API_PATH}/tables`,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.fetchTables = fetchTables;
|
|
6
12
|
function fetchTable(accountId, tableId) {
|
|
7
13
|
return http_1.http.get(accountId, {
|
|
8
14
|
url: `${HUBDB_API_PATH}/tables/${tableId}`,
|
|
@@ -20,16 +20,17 @@ declare class _CLIConfiguration {
|
|
|
20
20
|
getAccountId(nameOrId?: string | number): number | null;
|
|
21
21
|
getDefaultAccount(): string | number | null;
|
|
22
22
|
getResolvedDefaultAccountForCWD(nameOrId: string | number): CLIAccount_NEW | null;
|
|
23
|
-
|
|
23
|
+
getAccountIndex(accountId: number): number;
|
|
24
24
|
getConfigForAccount(accountId?: number): CLIAccount_NEW | null;
|
|
25
|
+
getConfigAccounts(): Array<CLIAccount_NEW> | null;
|
|
25
26
|
isAccountInConfig(nameOrId: string | number): boolean;
|
|
26
27
|
getAndLoadConfigIfNeeded(options?: CLIOptions): CLIConfig_NEW;
|
|
27
28
|
getEnv(nameOrId?: string | number): Environment;
|
|
28
|
-
getAccountType(accountType?: AccountType, sandboxAccountType?: string | null): AccountType;
|
|
29
|
+
getAccountType(accountType?: AccountType | null, sandboxAccountType?: string | null): AccountType;
|
|
29
30
|
/**
|
|
30
31
|
* @throws {Error}
|
|
31
32
|
*/
|
|
32
|
-
|
|
33
|
+
addOrUpdateAccount(updatedAccountFields: Partial<FlatAccountFields_NEW>, writeUpdate?: boolean): FlatAccountFields_NEW | null;
|
|
33
34
|
/**
|
|
34
35
|
* @throws {Error}
|
|
35
36
|
*/
|
|
@@ -116,7 +116,7 @@ class _CLIConfiguration {
|
|
|
116
116
|
return false;
|
|
117
117
|
}
|
|
118
118
|
if (accountConfig.name) {
|
|
119
|
-
if (accountNamesMap[accountConfig.name]) {
|
|
119
|
+
if (accountNamesMap[accountConfig.name.toLowerCase()]) {
|
|
120
120
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.validate.duplicateAccountNames`, {
|
|
121
121
|
accountName: accountConfig.name,
|
|
122
122
|
}));
|
|
@@ -131,7 +131,7 @@ class _CLIConfiguration {
|
|
|
131
131
|
accountNamesMap[accountConfig.name] = true;
|
|
132
132
|
}
|
|
133
133
|
if (!accountConfig.accountType) {
|
|
134
|
-
this.
|
|
134
|
+
this.addOrUpdateAccount({
|
|
135
135
|
...accountConfig,
|
|
136
136
|
accountId: accountConfig.accountId,
|
|
137
137
|
accountType: this.getAccountType(undefined, accountConfig.sandboxAccountType),
|
|
@@ -194,19 +194,30 @@ class _CLIConfiguration {
|
|
|
194
194
|
getResolvedDefaultAccountForCWD(nameOrId) {
|
|
195
195
|
return this.getAccount(nameOrId);
|
|
196
196
|
}
|
|
197
|
-
|
|
197
|
+
getAccountIndex(accountId) {
|
|
198
198
|
return this.config
|
|
199
199
|
? this.config.accounts.findIndex(account => account.accountId === accountId)
|
|
200
200
|
: -1;
|
|
201
201
|
}
|
|
202
202
|
getConfigForAccount(accountId) {
|
|
203
203
|
if (this.config) {
|
|
204
|
-
this.config.accounts.find(account => account.accountId === accountId) ||
|
|
205
|
-
null;
|
|
204
|
+
return (this.config.accounts.find(account => account.accountId === accountId) ||
|
|
205
|
+
null);
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
getConfigAccounts() {
|
|
210
|
+
if (this.config) {
|
|
211
|
+
return this.config.accounts || null;
|
|
206
212
|
}
|
|
207
213
|
return null;
|
|
208
214
|
}
|
|
209
215
|
isAccountInConfig(nameOrId) {
|
|
216
|
+
if (typeof nameOrId === 'string') {
|
|
217
|
+
return (!!this.config &&
|
|
218
|
+
this.config.accounts &&
|
|
219
|
+
!!this.getAccountId(nameOrId.toLowerCase()));
|
|
220
|
+
}
|
|
210
221
|
return (!!this.config && this.config.accounts && !!this.getAccountId(nameOrId));
|
|
211
222
|
}
|
|
212
223
|
getAndLoadConfigIfNeeded(options) {
|
|
@@ -246,7 +257,7 @@ class _CLIConfiguration {
|
|
|
246
257
|
/**
|
|
247
258
|
* @throws {Error}
|
|
248
259
|
*/
|
|
249
|
-
|
|
260
|
+
addOrUpdateAccount(updatedAccountFields, writeUpdate = true) {
|
|
250
261
|
const { accountId, accountType, apiKey, authType, clientId, clientSecret, defaultMode, env, name, parentAccountId, personalAccessKey, sandboxAccountType, scopes, tokenInfo, } = updatedAccountFields;
|
|
251
262
|
if (!accountId) {
|
|
252
263
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.updateAccount.errors.accountIdRequired`));
|
|
@@ -255,8 +266,11 @@ class _CLIConfiguration {
|
|
|
255
266
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.updateAccount.noConfigToUpdate`));
|
|
256
267
|
return null;
|
|
257
268
|
}
|
|
269
|
+
// Check whether the account is already listed in the config.yml file.
|
|
258
270
|
const currentAccountConfig = this.getAccount(accountId);
|
|
271
|
+
// For accounts that are already in the config.yml file, sets the auth property.
|
|
259
272
|
let auth = (currentAccountConfig && currentAccountConfig.auth) || {};
|
|
273
|
+
// For accounts not already in the config.yml file, sets the auth property.
|
|
260
274
|
if (clientId || clientSecret || scopes || tokenInfo) {
|
|
261
275
|
auth = {
|
|
262
276
|
...(currentAccountConfig ? currentAccountConfig.auth : {}),
|
|
@@ -279,6 +293,7 @@ class _CLIConfiguration {
|
|
|
279
293
|
}
|
|
280
294
|
const updatedEnv = (0, environment_2.getValidEnv)(env || (currentAccountConfig && currentAccountConfig.env));
|
|
281
295
|
const updatedDefaultMode = defaultMode && defaultMode.toLowerCase();
|
|
296
|
+
const updatedAccountType = accountType || (currentAccountConfig && currentAccountConfig.accountType);
|
|
282
297
|
safelyApplyUpdates('name', name);
|
|
283
298
|
safelyApplyUpdates('env', updatedEnv);
|
|
284
299
|
safelyApplyUpdates('accountId', accountId);
|
|
@@ -294,24 +309,29 @@ class _CLIConfiguration {
|
|
|
294
309
|
safelyApplyUpdates('personalAccessKey', personalAccessKey);
|
|
295
310
|
// Deprecating sandboxAccountType in favor of the more generic accountType
|
|
296
311
|
safelyApplyUpdates('sandboxAccountType', sandboxAccountType);
|
|
297
|
-
safelyApplyUpdates('accountType', this.getAccountType(
|
|
312
|
+
safelyApplyUpdates('accountType', this.getAccountType(updatedAccountType, sandboxAccountType));
|
|
298
313
|
safelyApplyUpdates('parentAccountId', parentAccountId);
|
|
299
314
|
const completedAccountConfig = nextAccountConfig;
|
|
315
|
+
if (!Object.hasOwn(this.config, 'accounts')) {
|
|
316
|
+
this.config.accounts = [];
|
|
317
|
+
}
|
|
300
318
|
if (currentAccountConfig) {
|
|
301
319
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.updateAccount.updating`, {
|
|
302
320
|
accountId,
|
|
303
321
|
}));
|
|
304
|
-
const index = this.
|
|
305
|
-
|
|
306
|
-
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.updateAccount.addingConfigEntry`, {
|
|
307
|
-
accountId,
|
|
308
|
-
}));
|
|
309
|
-
if (this.config.accounts) {
|
|
322
|
+
const index = this.getAccountIndex(accountId);
|
|
323
|
+
if (index < 0) {
|
|
310
324
|
this.config.accounts.push(completedAccountConfig);
|
|
311
325
|
}
|
|
312
326
|
else {
|
|
313
|
-
this.config.accounts =
|
|
327
|
+
this.config.accounts[index] = completedAccountConfig;
|
|
314
328
|
}
|
|
329
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.updateAccount.addingConfigEntry`, {
|
|
330
|
+
accountId,
|
|
331
|
+
}));
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
this.config.accounts.push(completedAccountConfig);
|
|
315
335
|
}
|
|
316
336
|
if (writeUpdate) {
|
|
317
337
|
this.write();
|
|
@@ -350,7 +370,12 @@ class _CLIConfiguration {
|
|
|
350
370
|
}));
|
|
351
371
|
}
|
|
352
372
|
if (accountId) {
|
|
353
|
-
this.
|
|
373
|
+
this.addOrUpdateAccount({
|
|
374
|
+
accountId,
|
|
375
|
+
name: newName,
|
|
376
|
+
env: this.getEnv(),
|
|
377
|
+
accountType: accountConfigToRename.accountType,
|
|
378
|
+
});
|
|
354
379
|
}
|
|
355
380
|
if (accountConfigToRename.name === this.getDefaultAccount()) {
|
|
356
381
|
this.updateDefaultAccount(newName);
|
|
@@ -374,7 +399,7 @@ class _CLIConfiguration {
|
|
|
374
399
|
const accountConfig = this.getAccount(accountId);
|
|
375
400
|
if (accountConfig) {
|
|
376
401
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.removeAccountFromConfig.deleting`, { accountId }));
|
|
377
|
-
const index = this.
|
|
402
|
+
const index = this.getAccountIndex(accountId);
|
|
378
403
|
this.config.accounts.splice(index, 1);
|
|
379
404
|
if (this.getDefaultAccount() === accountConfig.name) {
|
|
380
405
|
removedAccountIsDefault = true;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAccountIdentifier = void 0;
|
|
4
|
+
function getAccountIdentifier(account) {
|
|
5
|
+
if (!account) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
else if (Object.hasOwn(account, 'portalId')) {
|
|
9
|
+
return account.portalId;
|
|
10
|
+
}
|
|
11
|
+
else if (Object.hasOwn(account, 'accountId')) {
|
|
12
|
+
return account.accountId;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.getAccountIdentifier = getAccountIdentifier;
|
package/config/index.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import * as config_DEPRECATED from './config_DEPRECATED';
|
|
2
|
-
import { CLIConfig } from '../types/Config';
|
|
2
|
+
import { CLIConfig_NEW, CLIConfig } from '../types/Config';
|
|
3
3
|
import { CLIOptions, WriteConfigOptions } from '../types/CLIOptions';
|
|
4
|
-
import { AccountType, CLIAccount, FlatAccountFields } from '../types/Accounts';
|
|
4
|
+
import { AccountType, CLIAccount, CLIAccount_NEW, CLIAccount_DEPRECATED, FlatAccountFields } from '../types/Accounts';
|
|
5
|
+
import { Mode } from '../types/Files';
|
|
5
6
|
export declare function loadConfig(path: string, options?: CLIOptions): CLIConfig | null;
|
|
6
7
|
export declare function getAndLoadConfigIfNeeded(options?: CLIOptions): Partial<CLIConfig> | null;
|
|
7
8
|
export declare function validateConfig(): boolean;
|
|
8
9
|
export declare function loadConfigFromEnvironment(): boolean;
|
|
9
10
|
export declare function createEmptyConfigFile(options?: {
|
|
10
11
|
path?: string;
|
|
11
|
-
},
|
|
12
|
+
}, useHiddenConfig?: boolean): void;
|
|
12
13
|
export declare function deleteEmptyConfigFile(): void;
|
|
13
14
|
export declare function getConfig(): CLIConfig | null;
|
|
14
15
|
export declare function writeConfig(options?: WriteConfigOptions): void;
|
|
15
|
-
export declare function getConfigPath(path?: string): string | null;
|
|
16
|
+
export declare function getConfigPath(path?: string, useHiddenConfig?: boolean): string | null;
|
|
17
|
+
export declare function configFileExists(useHiddenConfig?: boolean): boolean;
|
|
16
18
|
export declare function getAccountConfig(accountId?: number): CLIAccount | null;
|
|
17
19
|
export declare function accountNameExistsInConfig(name: string): boolean;
|
|
18
20
|
export declare function updateAccountConfig(configOptions: Partial<FlatAccountFields>): FlatAccountFields | null;
|
|
@@ -28,12 +30,12 @@ export declare function isConfigFlagEnabled(flag: keyof CLIConfig): boolean;
|
|
|
28
30
|
export declare function isTrackingAllowed(): boolean;
|
|
29
31
|
export declare function getEnv(nameOrId?: string | number): import("../types/Config").Environment;
|
|
30
32
|
export declare function getAccountType(accountType?: AccountType, sandboxAccountType?: string | null): AccountType;
|
|
31
|
-
export declare
|
|
32
|
-
export declare
|
|
33
|
+
export declare function getDefaultAccount(): string | number | null | undefined;
|
|
34
|
+
export declare function getAccounts(): Array<CLIAccount_NEW> | Array<CLIAccount_DEPRECATED> | null | undefined;
|
|
35
|
+
export declare function updateDefaultMode(mode: Mode): void | CLIConfig_NEW | null;
|
|
33
36
|
export declare const getConfigAccountId: typeof config_DEPRECATED.getConfigAccountId;
|
|
34
37
|
export declare const getOrderedAccount: typeof config_DEPRECATED.getOrderedAccount;
|
|
35
38
|
export declare const getOrderedConfig: typeof config_DEPRECATED.getOrderedConfig;
|
|
36
39
|
export declare const setConfig: typeof config_DEPRECATED.setConfig;
|
|
37
40
|
export declare const setConfigPath: typeof config_DEPRECATED.setConfigPath;
|
|
38
41
|
export declare const findConfig: typeof config_DEPRECATED.findConfig;
|
|
39
|
-
export declare const updateDefaultMode: typeof config_DEPRECATED.updateDefaultMode;
|
package/config/index.js
CHANGED
|
@@ -23,11 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.findConfig = exports.setConfigPath = exports.setConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.getConfigAccountId = exports.updateDefaultMode = exports.getAccounts = exports.getDefaultAccount = exports.getAccountType = exports.getEnv = exports.isTrackingAllowed = exports.isConfigFlagEnabled = exports.deleteConfigFile = exports.updateAllowUsageTracking = exports.updateHttpTimeout = exports.deleteAccount = exports.removeSandboxAccountFromConfig = exports.getAccountId = exports.renameAccount = exports.updateDefaultAccount = exports.updateAccountConfig = exports.accountNameExistsInConfig = exports.getAccountConfig = exports.configFileExists = exports.getConfigPath = exports.writeConfig = exports.getConfig = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.loadConfigFromEnvironment = exports.validateConfig = exports.getAndLoadConfigIfNeeded = exports.loadConfig = void 0;
|
|
27
27
|
const config_DEPRECATED = __importStar(require("./config_DEPRECATED"));
|
|
28
28
|
const CLIConfiguration_1 = require("./CLIConfiguration");
|
|
29
29
|
const configFile_1 = require("./configFile");
|
|
30
|
-
const getAccountIdentifier_1 = require("
|
|
30
|
+
const getAccountIdentifier_1 = require("./getAccountIdentifier");
|
|
31
31
|
// Use new config if it exists
|
|
32
32
|
function loadConfig(path, options = {}) {
|
|
33
33
|
// Attempt to load the root config
|
|
@@ -58,8 +58,8 @@ function loadConfigFromEnvironment() {
|
|
|
58
58
|
return Boolean(config_DEPRECATED.loadConfigFromEnvironment());
|
|
59
59
|
}
|
|
60
60
|
exports.loadConfigFromEnvironment = loadConfigFromEnvironment;
|
|
61
|
-
function createEmptyConfigFile(options = {},
|
|
62
|
-
if (
|
|
61
|
+
function createEmptyConfigFile(options = {}, useHiddenConfig = false) {
|
|
62
|
+
if (useHiddenConfig) {
|
|
63
63
|
CLIConfiguration_1.CLIConfiguration.write({ accounts: [] });
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
@@ -93,13 +93,19 @@ function writeConfig(options = {}) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
exports.writeConfig = writeConfig;
|
|
96
|
-
function getConfigPath(path) {
|
|
97
|
-
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
96
|
+
function getConfigPath(path, useHiddenConfig = false) {
|
|
97
|
+
if (useHiddenConfig || CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
98
98
|
return (0, configFile_1.getConfigFilePath)();
|
|
99
99
|
}
|
|
100
100
|
return config_DEPRECATED.getConfigPath(path);
|
|
101
101
|
}
|
|
102
102
|
exports.getConfigPath = getConfigPath;
|
|
103
|
+
function configFileExists(useHiddenConfig) {
|
|
104
|
+
return useHiddenConfig
|
|
105
|
+
? (0, configFile_1.configFileExists)()
|
|
106
|
+
: Boolean(config_DEPRECATED.getConfigPath());
|
|
107
|
+
}
|
|
108
|
+
exports.configFileExists = configFileExists;
|
|
103
109
|
function getAccountConfig(accountId) {
|
|
104
110
|
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
105
111
|
return CLIConfiguration_1.CLIConfiguration.getConfigForAccount(accountId);
|
|
@@ -117,7 +123,7 @@ exports.accountNameExistsInConfig = accountNameExistsInConfig;
|
|
|
117
123
|
function updateAccountConfig(configOptions) {
|
|
118
124
|
const accountIdentifier = (0, getAccountIdentifier_1.getAccountIdentifier)(configOptions);
|
|
119
125
|
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
120
|
-
return CLIConfiguration_1.CLIConfiguration.
|
|
126
|
+
return CLIConfiguration_1.CLIConfiguration.addOrUpdateAccount({
|
|
121
127
|
...configOptions,
|
|
122
128
|
accountId: accountIdentifier,
|
|
123
129
|
});
|
|
@@ -224,13 +230,31 @@ function getAccountType(accountType, sandboxAccountType) {
|
|
|
224
230
|
return config_DEPRECATED.getAccountType(accountType, sandboxAccountType);
|
|
225
231
|
}
|
|
226
232
|
exports.getAccountType = getAccountType;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
233
|
+
function getDefaultAccount() {
|
|
234
|
+
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
235
|
+
return CLIConfiguration_1.CLIConfiguration.getDefaultAccount();
|
|
236
|
+
}
|
|
237
|
+
return config_DEPRECATED.getConfigDefaultAccount();
|
|
238
|
+
}
|
|
239
|
+
exports.getDefaultAccount = getDefaultAccount;
|
|
240
|
+
function getAccounts() {
|
|
241
|
+
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
242
|
+
return CLIConfiguration_1.CLIConfiguration.getConfigAccounts();
|
|
243
|
+
}
|
|
244
|
+
return config_DEPRECATED.getConfigAccounts();
|
|
245
|
+
}
|
|
246
|
+
exports.getAccounts = getAccounts;
|
|
247
|
+
function updateDefaultMode(mode) {
|
|
248
|
+
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
249
|
+
return CLIConfiguration_1.CLIConfiguration.updateDefaultMode(mode);
|
|
250
|
+
}
|
|
251
|
+
return config_DEPRECATED.updateDefaultMode(mode);
|
|
252
|
+
}
|
|
253
|
+
exports.updateDefaultMode = updateDefaultMode;
|
|
254
|
+
// These functions are not supported with the new config setup
|
|
230
255
|
exports.getConfigAccountId = config_DEPRECATED.getConfigAccountId;
|
|
231
256
|
exports.getOrderedAccount = config_DEPRECATED.getOrderedAccount;
|
|
232
257
|
exports.getOrderedConfig = config_DEPRECATED.getOrderedConfig;
|
|
233
258
|
exports.setConfig = config_DEPRECATED.setConfig;
|
|
234
259
|
exports.setConfigPath = config_DEPRECATED.setConfigPath;
|
|
235
260
|
exports.findConfig = config_DEPRECATED.findConfig;
|
|
236
|
-
exports.updateDefaultMode = config_DEPRECATED.updateDefaultMode;
|
package/constants/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = "hubspot.config.yml";
|
|
2
|
-
export declare const HUBSPOT_CONFIGURATION_FOLDER = ".hubspot";
|
|
2
|
+
export declare const HUBSPOT_CONFIGURATION_FOLDER = ".hubspot-cli";
|
|
3
3
|
export declare const HUBSPOT_CONFIGURATION_FILE = "config.yml";
|
|
4
4
|
export declare const MIN_HTTP_TIMEOUT = 3000;
|
|
5
5
|
export declare const HUBSPOT_ACCOUNT_TYPES: {
|
package/constants/config.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
|
|
4
4
|
const lang_1 = require("../utils/lang");
|
|
5
5
|
exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
|
|
6
|
-
exports.HUBSPOT_CONFIGURATION_FOLDER = '.hubspot';
|
|
6
|
+
exports.HUBSPOT_CONFIGURATION_FOLDER = '.hubspot-cli';
|
|
7
7
|
exports.HUBSPOT_CONFIGURATION_FILE = 'config.yml';
|
|
8
8
|
exports.MIN_HTTP_TIMEOUT = 3000;
|
|
9
9
|
exports.HUBSPOT_ACCOUNT_TYPES = {
|
package/lib/cms/modules.js
CHANGED
|
@@ -106,7 +106,7 @@ const updateFileContents = async (file, metaData, getInternalVersion) => {
|
|
|
106
106
|
async function createModule(moduleDefinition, name, dest, getInternalVersion, options = {
|
|
107
107
|
allowExistingDir: false,
|
|
108
108
|
}) {
|
|
109
|
-
const { moduleLabel, contentTypes, global, reactType: isReactModule, } = moduleDefinition;
|
|
109
|
+
const { moduleLabel, contentTypes, global, reactType: isReactModule, availableForNewContent, } = moduleDefinition;
|
|
110
110
|
const moduleMetaData = {
|
|
111
111
|
label: moduleLabel,
|
|
112
112
|
css_assets: [],
|
|
@@ -118,7 +118,7 @@ async function createModule(moduleDefinition, name, dest, getInternalVersion, op
|
|
|
118
118
|
other_assets: [],
|
|
119
119
|
smart_type: 'NOT_SMART',
|
|
120
120
|
tags: [],
|
|
121
|
-
is_available_for_new_content:
|
|
121
|
+
is_available_for_new_content: availableForNewContent,
|
|
122
122
|
};
|
|
123
123
|
const folderName = name.endsWith('.module') ? name : `${name}.module`;
|
|
124
124
|
const destPath = !isReactModule
|
package/lib/oauth.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.addOauthToAccountConfig = exports.getOauthManager = void 0;
|
|
|
4
4
|
const OAuth2Manager_1 = require("../models/OAuth2Manager");
|
|
5
5
|
const auth_1 = require("../constants/auth");
|
|
6
6
|
const logger_1 = require("./logger");
|
|
7
|
-
const getAccountIdentifier_1 = require("../
|
|
7
|
+
const getAccountIdentifier_1 = require("../config/getAccountIdentifier");
|
|
8
8
|
const config_1 = require("../config");
|
|
9
9
|
const lang_1 = require("../utils/lang");
|
|
10
10
|
const i18nKey = 'lib.oauth';
|
package/lib/personalAccessKey.js
CHANGED
|
@@ -13,6 +13,7 @@ const config_1 = require("../config");
|
|
|
13
13
|
const config_2 = require("../constants/config");
|
|
14
14
|
const developerTestAccounts_1 = require("../api/developerTestAccounts");
|
|
15
15
|
const logger_1 = require("./logger");
|
|
16
|
+
const CLIConfiguration_1 = require("../config/CLIConfiguration");
|
|
16
17
|
const lang_1 = require("../utils/lang");
|
|
17
18
|
const errors_1 = require("../errors");
|
|
18
19
|
const i18nKey = 'lib.personalAccessKey';
|
|
@@ -141,7 +142,7 @@ async function updateConfigWithAccessToken(token, personalAccessKey, env, name,
|
|
|
141
142
|
}
|
|
142
143
|
logger_1.logger.debug(err);
|
|
143
144
|
}
|
|
144
|
-
const
|
|
145
|
+
const updatedAccount = (0, config_1.updateAccountConfig)({
|
|
145
146
|
accountId: portalId,
|
|
146
147
|
accountType,
|
|
147
148
|
personalAccessKey,
|
|
@@ -151,10 +152,12 @@ async function updateConfigWithAccessToken(token, personalAccessKey, env, name,
|
|
|
151
152
|
parentAccountId,
|
|
152
153
|
env: accountEnv,
|
|
153
154
|
});
|
|
154
|
-
(
|
|
155
|
+
if (!CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
156
|
+
(0, config_1.writeConfig)();
|
|
157
|
+
}
|
|
155
158
|
if (makeDefault && name) {
|
|
156
159
|
(0, config_1.updateDefaultAccount)(name);
|
|
157
160
|
}
|
|
158
|
-
return
|
|
161
|
+
return updatedAccount;
|
|
159
162
|
}
|
|
160
163
|
exports.updateConfigWithAccessToken = updateConfigWithAccessToken;
|
package/lib/portManager.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RequestPortsData } from '../types/PortManager';
|
|
2
2
|
export declare const BASE_URL: string;
|
|
3
|
+
export declare function isPortManagerServerRunning(): Promise<boolean>;
|
|
3
4
|
export declare function startPortManagerServer(): Promise<void>;
|
|
4
5
|
export declare function stopPortManagerServer(): Promise<void>;
|
|
5
6
|
export declare function requestPorts(portData: Array<RequestPortsData>): Promise<{
|
package/lib/portManager.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.portManagerHasActiveServers = exports.deleteServerInstance = exports.requestPorts = exports.stopPortManagerServer = exports.startPortManagerServer = exports.BASE_URL = void 0;
|
|
6
|
+
exports.portManagerHasActiveServers = exports.deleteServerInstance = exports.requestPorts = exports.stopPortManagerServer = exports.startPortManagerServer = exports.isPortManagerServerRunning = exports.BASE_URL = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const PortManagerServer_1 = require("../utils/PortManagerServer");
|
|
9
9
|
const detectPort_1 = require("../utils/detectPort");
|
|
@@ -13,6 +13,7 @@ async function isPortManagerServerRunning() {
|
|
|
13
13
|
const port = await (0, detectPort_1.detectPort)(ports_1.PORT_MANAGER_SERVER_PORT);
|
|
14
14
|
return port !== ports_1.PORT_MANAGER_SERVER_PORT;
|
|
15
15
|
}
|
|
16
|
+
exports.isPortManagerServerRunning = isPortManagerServerRunning;
|
|
16
17
|
async function startPortManagerServer() {
|
|
17
18
|
const isRunning = await isPortManagerServerRunning();
|
|
18
19
|
if (!isRunning) {
|
package/models/OAuth2Manager.js
CHANGED
|
@@ -9,7 +9,7 @@ const moment_1 = __importDefault(require("moment"));
|
|
|
9
9
|
const urls_1 = require("../lib/urls");
|
|
10
10
|
const environment_1 = require("../lib/environment");
|
|
11
11
|
const logger_1 = require("../lib/logger");
|
|
12
|
-
const getAccountIdentifier_1 = require("../
|
|
12
|
+
const getAccountIdentifier_1 = require("../config/getAccountIdentifier");
|
|
13
13
|
const auth_1 = require("../constants/auth");
|
|
14
14
|
const lang_1 = require("../utils/lang");
|
|
15
15
|
const i18nKey = 'models.OAuth2Manager';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/local-dev-lib",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"./errors/*": "./errors/*.js",
|
|
54
54
|
"./http": "./http/index.js",
|
|
55
55
|
"./http/*": "./http/*.js",
|
|
56
|
+
"./config/getAccountIdentifier": "./config/getAccountIdentifier.js",
|
|
56
57
|
"./config": "./config/index.js",
|
|
57
58
|
"./constants/*": "./constants/*.js",
|
|
58
59
|
"./models/*": "./models/*.js",
|
package/types/Hubdb.d.ts
CHANGED
package/types/Modules.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CLIAccount
|
|
1
|
+
import { CLIAccount } from '../types/Accounts';
|
|
2
2
|
import { CLIConfig } from '../types/Config';
|
|
3
|
-
export declare function getAccountIdentifier(account?: GenericAccount | null): number | undefined;
|
|
4
3
|
export declare function getAccounts(config?: CLIConfig | null): Array<CLIAccount>;
|
|
5
4
|
export declare function getDefaultAccount(config?: CLIConfig | null): string | number | undefined;
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDefaultAccount = exports.getAccounts =
|
|
4
|
-
function getAccountIdentifier(account) {
|
|
5
|
-
if (!account) {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
else if (Object.hasOwn(account, 'portalId')) {
|
|
9
|
-
return account.portalId;
|
|
10
|
-
}
|
|
11
|
-
else if (Object.hasOwn(account, 'accountId')) {
|
|
12
|
-
return account.accountId;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.getAccountIdentifier = getAccountIdentifier;
|
|
3
|
+
exports.getDefaultAccount = exports.getAccounts = void 0;
|
|
16
4
|
function getAccounts(config) {
|
|
17
5
|
if (!config) {
|
|
18
6
|
return [];
|