@hubspot/local-dev-lib 0.7.8-experimental.0 → 0.7.9-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/projects.d.ts +3 -1
- package/api/projects.js +21 -0
- package/api/sandboxHubs.js +2 -0
- package/config/hsSettings.js +5 -2
- package/constants/ports.js +2 -0
- package/constants/projects.d.ts +1 -0
- package/constants/projects.js +1 -0
- package/lib/cms/functions.js +1 -1
- package/lib/github.js +1 -1
- package/lib/portManager.d.ts +2 -2
- package/lib/portManager.js +13 -11
- package/models/HubSpotHttpError.js +7 -1
- package/package.json +3 -3
- package/types/Project.d.ts +9 -0
- package/utils/PortManagerServer.d.ts +6 -7
- package/utils/PortManagerServer.js +14 -5
package/api/projects.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HubSpotPromise, QueryParams } from '../types/Http.js';
|
|
2
|
-
import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse, WarnLogsResponse, UploadIRResponse, Release, FetchListReleasesResponse } from '../types/Project.js';
|
|
2
|
+
import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse, WarnLogsResponse, UploadIRResponse, Release, FetchListReleasesResponse, AutoReleaseResponse, AutoReleaseStatusResponse } from '../types/Project.js';
|
|
3
3
|
import { Build, FetchProjectBuildsResponse } from '../types/Build.js';
|
|
4
4
|
import { ComponentStructureResponse, ProjectComponentsMetadata } from '../types/ComponentStructure.js';
|
|
5
5
|
import { Deploy, ProjectDeployResponse, ProjectDeployResponseV1, ProjectDeletionResponse } from '../types/Deploy.js';
|
|
@@ -42,6 +42,8 @@ export declare function fetchDeployWarnLogs(accountId: number, projectName: stri
|
|
|
42
42
|
export declare function createRelease(accountId: number, projectName: string, buildId: number): HubSpotPromise<Release>;
|
|
43
43
|
export declare function listReleases(accountId: number, projectName: string, params?: QueryParams): HubSpotPromise<FetchListReleasesResponse>;
|
|
44
44
|
export declare function getReleaseInfo(accountId: number, projectName: string, releaseTag: string): HubSpotPromise<Release>;
|
|
45
|
+
export declare function triggerAutoRelease(accountId: number, projectId: number, buildId: number, targetPortalId: number): HubSpotPromise<AutoReleaseResponse>;
|
|
46
|
+
export declare function getAutoReleaseStatus(accountId: number, projectId: number, targetPortalId: number, expectedReleaseTag: string, appId: number): HubSpotPromise<AutoReleaseStatusResponse>;
|
|
45
47
|
/**
|
|
46
48
|
* @deprecated
|
|
47
49
|
*/
|
package/api/projects.js
CHANGED
|
@@ -232,6 +232,27 @@ export function getReleaseInfo(accountId, projectName, releaseTag) {
|
|
|
232
232
|
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/releases/${encodeURIComponent(releaseTag)}`,
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
|
+
export function triggerAutoRelease(accountId, projectId, buildId, targetPortalId) {
|
|
236
|
+
return http.post(accountId, {
|
|
237
|
+
url: `${PROJECTS_DEPLOY_API_PATH}/auto-release`,
|
|
238
|
+
data: {
|
|
239
|
+
projectId,
|
|
240
|
+
buildId,
|
|
241
|
+
targetPortalId,
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
export function getAutoReleaseStatus(accountId, projectId, targetPortalId, expectedReleaseTag, appId) {
|
|
246
|
+
return http.get(accountId, {
|
|
247
|
+
url: `${PROJECTS_DEPLOY_API_PATH}/auto-release/status`,
|
|
248
|
+
params: {
|
|
249
|
+
projectId,
|
|
250
|
+
targetPortalId,
|
|
251
|
+
expectedReleaseTag,
|
|
252
|
+
appId,
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
}
|
|
235
256
|
/**
|
|
236
257
|
* @deprecated
|
|
237
258
|
*/
|
package/api/sandboxHubs.js
CHANGED
|
@@ -16,6 +16,7 @@ export function createSandbox(accountId, name, type) {
|
|
|
16
16
|
export function deleteSandbox(parentAccountId, sandboxAccountId) {
|
|
17
17
|
return http.delete(parentAccountId, {
|
|
18
18
|
url: `${SANDBOX_API_PATH}/${sandboxAccountId}`,
|
|
19
|
+
timeout: SANDBOX_TIMEOUT,
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
export function getSandboxUsageLimits(parentAccountId) {
|
|
@@ -27,6 +28,7 @@ export function createV2Sandbox(accountId, name, type, syncObjectRecords) {
|
|
|
27
28
|
return http.post(accountId, {
|
|
28
29
|
url: `${SANDBOX_API_PATH_V2}/sandboxes`,
|
|
29
30
|
data: { name, type, syncObjectRecords },
|
|
31
|
+
timeout: SANDBOX_TIMEOUT,
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
export function getSandboxPersonalAccessKey(accountId, sandboxId) {
|
package/config/hsSettings.js
CHANGED
|
@@ -36,12 +36,15 @@ export function getHsSettingsFileIfExists() {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
export function writeHsSettingsFile(settingsFile) {
|
|
39
|
+
const existingFilePath = getHsSettingsFilePath();
|
|
39
40
|
const dir = getCwd();
|
|
40
|
-
const hsFolderPath =
|
|
41
|
+
const hsFolderPath = existingFilePath
|
|
42
|
+
? path.dirname(existingFilePath)
|
|
43
|
+
: path.join(dir, HS_FOLDER);
|
|
41
44
|
const isFirstScaffold = !fs.existsSync(hsFolderPath);
|
|
42
45
|
try {
|
|
43
46
|
fs.mkdirSync(hsFolderPath, { recursive: true });
|
|
44
|
-
fs.writeFileSync(path.join(
|
|
47
|
+
fs.writeFileSync(path.join(hsFolderPath, HS_SETTINGS_FILENAME), JSON.stringify(settingsFile, null, 2), 'utf8');
|
|
45
48
|
if (isFirstScaffold) {
|
|
46
49
|
fs.writeFileSync(path.join(hsFolderPath, HS_README_FILENAME), HS_README_CONTENTS, 'utf8');
|
|
47
50
|
}
|
package/constants/ports.js
CHANGED
package/constants/projects.d.ts
CHANGED
package/constants/projects.js
CHANGED
package/lib/cms/functions.js
CHANGED
|
@@ -19,7 +19,7 @@ export function createEndpoint(endpointMethod, filename) {
|
|
|
19
19
|
}
|
|
20
20
|
export function createConfig({ endpointPath, endpointMethod, functionFile, }) {
|
|
21
21
|
return {
|
|
22
|
-
runtime: '
|
|
22
|
+
runtime: 'nodejs20.x',
|
|
23
23
|
version: '1.0',
|
|
24
24
|
environment: {},
|
|
25
25
|
secrets: [],
|
package/lib/github.js
CHANGED
|
@@ -96,7 +96,7 @@ export async function fetchGitHubRepoContentFromDownloadUrl(dest, downloadUrl) {
|
|
|
96
96
|
const resp = await fetchRepoFileByDownloadUrl(downloadUrl);
|
|
97
97
|
const contentType = resp.headers['content-type'];
|
|
98
98
|
let fileContents;
|
|
99
|
-
if (contentType.startsWith('text')) {
|
|
99
|
+
if (typeof contentType === 'string' && contentType.startsWith('text')) {
|
|
100
100
|
fileContents = Buffer.from(resp.data).toString('utf8');
|
|
101
101
|
}
|
|
102
102
|
else {
|
package/lib/portManager.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RequestPortsData, ServerPortMap } from '../types/PortManager.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function isPortAvailable(port: number): Promise<boolean>;
|
|
3
3
|
export declare function isPortManagerPortAvailable(): Promise<boolean>;
|
|
4
4
|
export declare function isPortManagerServerRunning(): Promise<boolean>;
|
|
5
|
-
export declare function startPortManagerServer(): Promise<void>;
|
|
5
|
+
export declare function startPortManagerServer(port?: number): Promise<void>;
|
|
6
6
|
export declare function stopPortManagerServer(): Promise<void>;
|
|
7
7
|
export declare function requestPorts(portData: Array<RequestPortsData>): Promise<{
|
|
8
8
|
[instanceId: string]: number;
|
package/lib/portManager.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { HEALTH_CHECK_PATH, PortManagerServer, SERVICE_HEALTHY, } from '../utils/PortManagerServer.js';
|
|
3
|
-
import {
|
|
3
|
+
import { detectPort } from '../utils/detectPort.js';
|
|
4
4
|
import { logger } from './logger.js';
|
|
5
|
-
export
|
|
5
|
+
export async function isPortAvailable(port) {
|
|
6
|
+
return (await detectPort(port)) === port;
|
|
7
|
+
}
|
|
6
8
|
export async function isPortManagerPortAvailable() {
|
|
7
9
|
return PortManagerServer.portAvailable();
|
|
8
10
|
}
|
|
9
11
|
export async function isPortManagerServerRunning() {
|
|
10
12
|
try {
|
|
11
|
-
const { data } = await axios.get(`${
|
|
13
|
+
const { data } = await axios.get(`${PortManagerServer.baseUrl}${HEALTH_CHECK_PATH}`);
|
|
12
14
|
return data.status === SERVICE_HEALTHY;
|
|
13
15
|
}
|
|
14
16
|
catch (e) {
|
|
@@ -16,36 +18,36 @@ export async function isPortManagerServerRunning() {
|
|
|
16
18
|
return false;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
|
-
export async function startPortManagerServer() {
|
|
21
|
+
export async function startPortManagerServer(port) {
|
|
20
22
|
const isRunning = await isPortManagerServerRunning();
|
|
21
23
|
if (!isRunning) {
|
|
22
|
-
await PortManagerServer.init();
|
|
24
|
+
await PortManagerServer.init(port);
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
export async function stopPortManagerServer() {
|
|
26
28
|
const isRunning = await isPortManagerServerRunning();
|
|
27
29
|
if (isRunning) {
|
|
28
|
-
await axios.post(`${
|
|
30
|
+
await axios.post(`${PortManagerServer.baseUrl}/close`);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
export async function requestPorts(portData) {
|
|
32
|
-
const { data } = await axios.post(`${
|
|
34
|
+
const { data } = await axios.post(`${PortManagerServer.baseUrl}/servers`, {
|
|
33
35
|
portData: portData,
|
|
34
36
|
});
|
|
35
37
|
return data.ports;
|
|
36
38
|
}
|
|
37
39
|
export async function getActiveServers() {
|
|
38
|
-
const { data } = await axios.get(`${
|
|
40
|
+
const { data } = await axios.get(`${PortManagerServer.baseUrl}/servers`);
|
|
39
41
|
return data.servers;
|
|
40
42
|
}
|
|
41
43
|
export async function getServerPortByInstanceId(serverInstanceId) {
|
|
42
|
-
const { data } = await axios.get(`${
|
|
44
|
+
const { data } = await axios.get(`${PortManagerServer.baseUrl}/servers/${serverInstanceId}`);
|
|
43
45
|
return data.port;
|
|
44
46
|
}
|
|
45
47
|
export async function deleteServerInstance(serverInstanceId) {
|
|
46
|
-
await axios.delete(`${
|
|
48
|
+
await axios.delete(`${PortManagerServer.baseUrl}/servers/${serverInstanceId}`);
|
|
47
49
|
}
|
|
48
50
|
export async function portManagerHasActiveServers() {
|
|
49
|
-
const { data } = await axios.get(`${
|
|
51
|
+
const { data } = await axios.get(`${PortManagerServer.baseUrl}/servers`);
|
|
50
52
|
return data.count > 0;
|
|
51
53
|
}
|
|
@@ -101,7 +101,13 @@ export class HubSpotHttpError extends Error {
|
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
generatedContext.accountId = cause.config?.params?.portalId;
|
|
104
|
-
|
|
104
|
+
// Axios serializes request bodies before the error fires, so `config.data`
|
|
105
|
+
// is often already a JSON string. Avoid re-stringifying so debug output is
|
|
106
|
+
// readable instead of escape-soup.
|
|
107
|
+
generatedContext.payload =
|
|
108
|
+
typeof cause.config?.data === 'string'
|
|
109
|
+
? cause.config.data
|
|
110
|
+
: JSON.stringify(cause.config?.data);
|
|
105
111
|
// This will just be the url path
|
|
106
112
|
generatedContext.request = cause.config?.url;
|
|
107
113
|
// Allow the provided context to override the generated context
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/local-dev-lib",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9-experimental.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
|
|
6
6
|
"files": [
|
|
@@ -71,13 +71,13 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"address": "2.0.2",
|
|
74
|
-
"axios": "1.
|
|
74
|
+
"axios": "1.15.2",
|
|
75
75
|
"chalk": "5.6.2",
|
|
76
76
|
"chokidar": "3.6.0",
|
|
77
77
|
"content-disposition": "0.5.4",
|
|
78
78
|
"cors": "2.8.5",
|
|
79
79
|
"debounce": "1.2.1",
|
|
80
|
-
"express": "4.
|
|
80
|
+
"express": "4.22.1",
|
|
81
81
|
"extract-zip": "2.0.1",
|
|
82
82
|
"findup-sync": "5.0.0",
|
|
83
83
|
"form-data": "^4.0.4",
|
package/types/Project.d.ts
CHANGED
|
@@ -69,3 +69,12 @@ export type FetchListReleasesResponse = {
|
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
+
export type AutoReleaseResponse = {
|
|
73
|
+
releaseTag: string;
|
|
74
|
+
status: string;
|
|
75
|
+
appId: number;
|
|
76
|
+
};
|
|
77
|
+
export type AutoReleaseStatusResponse = {
|
|
78
|
+
status: 'PENDING' | 'COMPLETE';
|
|
79
|
+
currentReleaseTag?: string;
|
|
80
|
+
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { Express } from 'express';
|
|
2
|
-
import { Server } from 'http';
|
|
3
|
-
import { ServerPortMap } from '../types/PortManager.js';
|
|
4
1
|
export declare const HEALTH_CHECK_PATH = "/port-manager-health-check";
|
|
5
2
|
export declare const SERVICE_HEALTHY = "OK";
|
|
6
3
|
declare class _PortManagerServer {
|
|
7
|
-
app
|
|
8
|
-
server
|
|
9
|
-
serverPortMap
|
|
4
|
+
private app?;
|
|
5
|
+
private server?;
|
|
6
|
+
private serverPortMap;
|
|
7
|
+
private port;
|
|
10
8
|
constructor();
|
|
11
|
-
|
|
9
|
+
get baseUrl(): string;
|
|
10
|
+
init(port?: number): Promise<void>;
|
|
12
11
|
private reset;
|
|
13
12
|
portAvailable(): Promise<boolean>;
|
|
14
13
|
private listen;
|
|
@@ -11,13 +11,21 @@ class _PortManagerServer {
|
|
|
11
11
|
app;
|
|
12
12
|
server;
|
|
13
13
|
serverPortMap;
|
|
14
|
+
port;
|
|
14
15
|
constructor() {
|
|
15
16
|
this.serverPortMap = {};
|
|
17
|
+
this.port = PORT_MANAGER_SERVER_PORT;
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
get baseUrl() {
|
|
20
|
+
return `http://localhost:${this.port}`;
|
|
21
|
+
}
|
|
22
|
+
async init(port) {
|
|
23
|
+
if (port) {
|
|
24
|
+
this.port = port;
|
|
25
|
+
}
|
|
18
26
|
if (!(await this.portAvailable())) {
|
|
19
27
|
throw new Error(i18n(`${i18nKey}.errors.portInUse`, {
|
|
20
|
-
port:
|
|
28
|
+
port: this.port,
|
|
21
29
|
}));
|
|
22
30
|
}
|
|
23
31
|
if (this.app) {
|
|
@@ -34,15 +42,16 @@ class _PortManagerServer {
|
|
|
34
42
|
this.app = undefined;
|
|
35
43
|
this.server = undefined;
|
|
36
44
|
this.serverPortMap = {};
|
|
45
|
+
this.port = PORT_MANAGER_SERVER_PORT;
|
|
37
46
|
}
|
|
38
47
|
async portAvailable() {
|
|
39
|
-
return (
|
|
48
|
+
return (await detectPort(this.port)) === this.port;
|
|
40
49
|
}
|
|
41
50
|
listen() {
|
|
42
51
|
return new Promise((resolve, reject) => {
|
|
43
|
-
const server = this.app.listen(
|
|
52
|
+
const server = this.app.listen(this.port, () => {
|
|
44
53
|
logger.debug(i18n(`${i18nKey}.started`, {
|
|
45
|
-
port:
|
|
54
|
+
port: this.port,
|
|
46
55
|
}));
|
|
47
56
|
resolve(server);
|
|
48
57
|
}).on('error', (err) => {
|