@hubspot/local-dev-lib 0.6.3-experimental.0 → 0.7.0-experimental.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/appsDev.d.ts +1 -0
- package/api/appsDev.js +9 -0
- package/api/functions.d.ts +1 -1
- package/config/hsSettings.d.ts +4 -0
- package/config/hsSettings.js +41 -0
- package/config/index.d.ts +1 -1
- package/config/index.js +13 -2
- package/constants/config.d.ts +3 -0
- package/constants/config.js +4 -0
- package/package.json +2 -1
- package/types/HsSettings.d.ts +4 -0
- package/types/HsSettings.js +1 -0
package/api/appsDev.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export declare function fetchPublicAppProductionInstallCounts(appId: number, acc
|
|
|
6
6
|
export declare function fetchPublicAppMetadata(appId: number, accountId: number): HubSpotPromise<PublicApp>;
|
|
7
7
|
export declare function installStaticAuthAppOnTestAccount(appId: number, accountId: number, scopeGroupIds: number[]): HubSpotPromise<void>;
|
|
8
8
|
export declare function fetchAppMetadataByUid(appUid: string, accountId: number): HubSpotPromise<PublicApp>;
|
|
9
|
+
export declare function fetchAppMetadataBySourceId(projectId: number, appUid: string, accountId: number): HubSpotPromise<PublicApp>;
|
package/api/appsDev.js
CHANGED
|
@@ -39,3 +39,12 @@ export function fetchAppMetadataByUid(appUid, accountId) {
|
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
+
// Note: This is intentionally Project ID and not name
|
|
43
|
+
export function fetchAppMetadataBySourceId(projectId, appUid, accountId) {
|
|
44
|
+
return http.get(accountId, {
|
|
45
|
+
url: `${APPS_DEV_API_PATH}/project-id/${projectId}/source-id/${appUid}`,
|
|
46
|
+
params: {
|
|
47
|
+
sourceId: appUid,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
package/api/functions.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export declare function getRoutes(accountId: number): HubSpotPromise<GetRoutesRe
|
|
|
4
4
|
export declare function getFunctionLogs(accountId: number, route: string, params?: QueryParams): HubSpotPromise<GetFunctionLogsResponse>;
|
|
5
5
|
export declare function getLatestFunctionLog(accountId: number, route: string): HubSpotPromise<FunctionLog>;
|
|
6
6
|
export declare function buildPackage(accountId: number, folderPath: string): HubSpotPromise<string>;
|
|
7
|
-
export declare function getBuildStatus(accountId: number, buildId: number): HubSpotPromise<GetBuildStatusResponse>;
|
|
7
|
+
export declare function getBuildStatus(accountId: number, buildId: number | string): HubSpotPromise<GetBuildStatusResponse>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HsSettingsFile } from '../types/HsSettings.js';
|
|
2
|
+
export declare function getHsSettingsFilePath(): string | null;
|
|
3
|
+
export declare function getHsSettingsFile(): HsSettingsFile | null;
|
|
4
|
+
export declare function writeHsSettingsFile(settingsFile: HsSettingsFile): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import findupSync from 'findup-sync';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { HS_FOLDER, HS_SETTINGS_FILENAME, HS_SETTINGS_PATH, } from '../constants/config.js';
|
|
5
|
+
import { getCwd } from '../lib/path.js';
|
|
6
|
+
import { FileSystemError } from '../models/FileSystemError.js';
|
|
7
|
+
export function getHsSettingsFilePath() {
|
|
8
|
+
return findupSync([`${HS_FOLDER}/${HS_SETTINGS_FILENAME}`], {
|
|
9
|
+
cwd: getCwd(),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function getHsSettingsFile() {
|
|
13
|
+
const hsSettingsFilePath = getHsSettingsFilePath();
|
|
14
|
+
if (!hsSettingsFilePath) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
let hsSettingsFile;
|
|
18
|
+
try {
|
|
19
|
+
hsSettingsFile = JSON.parse(fs.readFileSync(hsSettingsFilePath, 'utf-8'));
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
throw new FileSystemError({ cause: e }, {
|
|
23
|
+
filepath: hsSettingsFilePath,
|
|
24
|
+
operation: 'read',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return hsSettingsFile;
|
|
28
|
+
}
|
|
29
|
+
export function writeHsSettingsFile(settingsFile) {
|
|
30
|
+
const dir = getCwd();
|
|
31
|
+
try {
|
|
32
|
+
fs.mkdirSync(path.join(dir, HS_FOLDER), { recursive: true });
|
|
33
|
+
fs.writeFileSync(HS_SETTINGS_PATH, JSON.stringify(settingsFile, null, 2), 'utf8');
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
throw new FileSystemError({ cause: err }, {
|
|
37
|
+
filepath: dir,
|
|
38
|
+
operation: 'write',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
package/config/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare function getConfigAccountByName(accountName: string): HubSpotConf
|
|
|
17
17
|
export declare function getConfigAccountIfExists(identifier: number | string): HubSpotConfigAccount | undefined;
|
|
18
18
|
export declare function getConfigDefaultAccount(): HubSpotConfigAccount;
|
|
19
19
|
export declare function getConfigDefaultAccountIfExists(): HubSpotConfigAccount | undefined;
|
|
20
|
-
export declare function getAllConfigAccounts(): HubSpotConfigAccount[];
|
|
20
|
+
export declare function getAllConfigAccounts(showAll?: boolean): HubSpotConfigAccount[];
|
|
21
21
|
export declare function getConfigAccountEnvironment(identifier: number | string): Environment;
|
|
22
22
|
export declare function addConfigAccount(accountToAdd: HubSpotConfigAccount): void;
|
|
23
23
|
export declare function updateConfigAccount(updatedAccount: HubSpotConfigAccount): void;
|
package/config/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { HubSpotConfigError } from '../models/HubSpotConfigError.js';
|
|
|
11
11
|
import { HUBSPOT_CONFIG_ERROR_TYPES } from '../constants/config.js';
|
|
12
12
|
import { isDeepEqual } from '../lib/isDeepEqual.js';
|
|
13
13
|
import { getCwd } from '../lib/path.js';
|
|
14
|
+
import { getHsSettingsFile } from './hsSettings.js';
|
|
14
15
|
const EMPTY_CONFIG = { accounts: [] };
|
|
15
16
|
export function getGlobalConfigFilePath() {
|
|
16
17
|
return GLOBAL_CONFIG_PATH;
|
|
@@ -179,14 +180,24 @@ export function getConfigDefaultAccountIfExists() {
|
|
|
179
180
|
const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId(accounts);
|
|
180
181
|
defaultAccountToUse = defaultAccountOverrideAccountId || defaultAccount;
|
|
181
182
|
}
|
|
183
|
+
// Use the default account if .hs/settings.json is present
|
|
184
|
+
const hsSettingsFile = getHsSettingsFile();
|
|
185
|
+
if (hsSettingsFile && hsSettingsFile.localDefaultAccount) {
|
|
186
|
+
defaultAccountToUse = hsSettingsFile.localDefaultAccount;
|
|
187
|
+
}
|
|
182
188
|
if (!defaultAccountToUse) {
|
|
183
189
|
return;
|
|
184
190
|
}
|
|
185
191
|
const account = getConfigAccountByInferredIdentifier(accounts, defaultAccountToUse);
|
|
186
192
|
return account;
|
|
187
193
|
}
|
|
188
|
-
export function getAllConfigAccounts() {
|
|
189
|
-
|
|
194
|
+
export function getAllConfigAccounts(showAll) {
|
|
195
|
+
let { accounts } = getConfig();
|
|
196
|
+
// Show only accounts in the .hs/settings.json file
|
|
197
|
+
if (!showAll) {
|
|
198
|
+
const hsSettingsFile = getHsSettingsFile();
|
|
199
|
+
accounts = accounts.filter(a => hsSettingsFile ? hsSettingsFile.accounts.includes(a.accountId) : true);
|
|
200
|
+
}
|
|
190
201
|
return accounts;
|
|
191
202
|
}
|
|
192
203
|
export function getConfigAccountEnvironment(identifier) {
|
package/constants/config.d.ts
CHANGED
|
@@ -102,3 +102,6 @@ export declare const HUBSPOT_CONFIG_OPERATIONS: {
|
|
|
102
102
|
readonly WRITE: "WRITE";
|
|
103
103
|
readonly DELETE: "DELETE";
|
|
104
104
|
};
|
|
105
|
+
export declare const HS_FOLDER = ".hs";
|
|
106
|
+
export declare const HS_SETTINGS_FILENAME = "settings.json";
|
|
107
|
+
export declare const HS_SETTINGS_PATH: string;
|
package/constants/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { i18n } from '../utils/lang.js';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import os from 'os';
|
|
4
|
+
import { getCwd } from '../lib/path.js';
|
|
4
5
|
export const DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
|
|
5
6
|
export const ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME = 'archived.hubspot.config.yml';
|
|
6
7
|
export const HUBSPOT_CONFIGURATION_FOLDER = '.hscli';
|
|
@@ -105,3 +106,6 @@ export const HUBSPOT_CONFIG_OPERATIONS = {
|
|
|
105
106
|
WRITE: 'WRITE',
|
|
106
107
|
DELETE: 'DELETE',
|
|
107
108
|
};
|
|
109
|
+
export const HS_FOLDER = '.hs';
|
|
110
|
+
export const HS_SETTINGS_FILENAME = 'settings.json';
|
|
111
|
+
export const HS_SETTINGS_PATH = path.join(getCwd(), HS_FOLDER, HS_SETTINGS_FILENAME);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/local-dev-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-experimental.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
|
|
6
6
|
"repository": {
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"./config/defaultAccountOverride": "./config/defaultAccountOverride.js",
|
|
56
56
|
"./config/migrate": "./config/migrate.js",
|
|
57
57
|
"./config/state": "./config/state.js",
|
|
58
|
+
"./config/hsSettings": "./config/hsSettings.js",
|
|
58
59
|
"./config": "./config/index.js",
|
|
59
60
|
"./constants/*": "./constants/*.js",
|
|
60
61
|
"./enums/*": "./enums/*.js",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|