@hubspot/local-dev-lib 0.7.8-experimental.0 → 0.7.9-experimental.1
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 +1 -4
- package/api/projects.js +0 -17
- 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/LogBuffer.d.ts +26 -0
- package/lib/LogBuffer.js +95 -0
- package/lib/cms/functions.js +1 -1
- package/lib/github.js +1 -1
- package/lib/logger.d.ts +5 -1
- package/lib/logger.js +18 -0
- 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 +0 -21
- 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
|
|
2
|
+
import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse, WarnLogsResponse, UploadIRResponse } 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';
|
|
@@ -39,9 +39,6 @@ export declare function deleteFileFromBuild(accountId: number, projectName: stri
|
|
|
39
39
|
export declare function cancelStagedBuild(accountId: number, projectName: string): HubSpotPromise<void>;
|
|
40
40
|
export declare function fetchBuildWarnLogs(accountId: number, projectName: string, buildId: number): HubSpotPromise<WarnLogsResponse>;
|
|
41
41
|
export declare function fetchDeployWarnLogs(accountId: number, projectName: string, deployId: number): HubSpotPromise<WarnLogsResponse>;
|
|
42
|
-
export declare function createRelease(accountId: number, projectName: string, buildId: number): HubSpotPromise<Release>;
|
|
43
|
-
export declare function listReleases(accountId: number, projectName: string, params?: QueryParams): HubSpotPromise<FetchListReleasesResponse>;
|
|
44
|
-
export declare function getReleaseInfo(accountId: number, projectName: string, releaseTag: string): HubSpotPromise<Release>;
|
|
45
42
|
/**
|
|
46
43
|
* @deprecated
|
|
47
44
|
*/
|
package/api/projects.js
CHANGED
|
@@ -215,23 +215,6 @@ export function fetchDeployWarnLogs(accountId, projectName, deployId) {
|
|
|
215
215
|
url: `${PROJECTS_LOGS_API_PATH}/logs/projects/${encodeURIComponent(projectName)}/deploys/${deployId}/combined/warn`,
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
|
-
export function createRelease(accountId, projectName, buildId) {
|
|
219
|
-
return http.post(accountId, {
|
|
220
|
-
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/releases`,
|
|
221
|
-
data: { buildId },
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
export function listReleases(accountId, projectName, params = {}) {
|
|
225
|
-
return http.get(accountId, {
|
|
226
|
-
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/releases`,
|
|
227
|
-
params,
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
export function getReleaseInfo(accountId, projectName, releaseTag) {
|
|
231
|
-
return http.get(accountId, {
|
|
232
|
-
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/releases/${encodeURIComponent(releaseTag)}`,
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
218
|
/**
|
|
236
219
|
* @deprecated
|
|
237
220
|
*/
|
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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type LogBufferOptions = {
|
|
2
|
+
byteLimit?: number;
|
|
3
|
+
};
|
|
4
|
+
export type WriteBufferedLogsOptions = {
|
|
5
|
+
dir: string;
|
|
6
|
+
filenamePrefix: string;
|
|
7
|
+
maxFiles?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* In-memory ring buffer of log entries with a byte cap. Designed to be
|
|
11
|
+
* composed into a logger so that recent log output can be flushed to a file
|
|
12
|
+
* after a failure. Each record is timestamped and tagged with the level the
|
|
13
|
+
* caller provides.
|
|
14
|
+
*/
|
|
15
|
+
export declare class LogBuffer {
|
|
16
|
+
private entries;
|
|
17
|
+
private bytes;
|
|
18
|
+
private byteLimit;
|
|
19
|
+
constructor(options?: LogBufferOptions);
|
|
20
|
+
private static entrySize;
|
|
21
|
+
private trimToByteLimit;
|
|
22
|
+
record(level: string, args: unknown[]): void;
|
|
23
|
+
view(): string;
|
|
24
|
+
flush(): string;
|
|
25
|
+
writeToFile(options: WriteBufferedLogsOptions): string | null;
|
|
26
|
+
}
|
package/lib/LogBuffer.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
// 128 MiB
|
|
4
|
+
const DEFAULT_BYTE_LIMIT = 128 * 1024 * 1024;
|
|
5
|
+
const DEFAULT_MAX_LOG_FILES = 3;
|
|
6
|
+
function sanitizeFilenamePart(name) {
|
|
7
|
+
return name.replace(/[^a-zA-Z0-9._-]+/g, '-');
|
|
8
|
+
}
|
|
9
|
+
function timestampForFilename() {
|
|
10
|
+
const d = new Date();
|
|
11
|
+
const pad = (n, w = 2) => String(n).padStart(w, '0');
|
|
12
|
+
const date = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
|
13
|
+
const time = `${pad(d.getHours())}-${pad(d.getMinutes())}-${pad(d.getSeconds())}`;
|
|
14
|
+
return `${date}T${time}-${pad(d.getMilliseconds(), 3)}`;
|
|
15
|
+
}
|
|
16
|
+
function rotateLogFiles(dir, maxFiles) {
|
|
17
|
+
const entries = fs
|
|
18
|
+
.readdirSync(dir)
|
|
19
|
+
.map(name => {
|
|
20
|
+
const full = path.join(dir, name);
|
|
21
|
+
const stat = fs.statSync(full);
|
|
22
|
+
return { full, mtimeMs: stat.mtimeMs, isFile: stat.isFile() };
|
|
23
|
+
})
|
|
24
|
+
.filter(entry => entry.isFile)
|
|
25
|
+
.sort((a, b) => a.mtimeMs - b.mtimeMs);
|
|
26
|
+
while (entries.length >= maxFiles) {
|
|
27
|
+
const oldest = entries.shift();
|
|
28
|
+
if (oldest) {
|
|
29
|
+
fs.unlinkSync(oldest.full);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* In-memory ring buffer of log entries with a byte cap. Designed to be
|
|
35
|
+
* composed into a logger so that recent log output can be flushed to a file
|
|
36
|
+
* after a failure. Each record is timestamped and tagged with the level the
|
|
37
|
+
* caller provides.
|
|
38
|
+
*/
|
|
39
|
+
export class LogBuffer {
|
|
40
|
+
entries = [];
|
|
41
|
+
bytes = 0;
|
|
42
|
+
byteLimit;
|
|
43
|
+
constructor(options = {}) {
|
|
44
|
+
this.byteLimit = options.byteLimit ?? DEFAULT_BYTE_LIMIT;
|
|
45
|
+
}
|
|
46
|
+
// +1 accounts for the '\n' separator that join('\n') will insert between entries.
|
|
47
|
+
static entrySize(entry) {
|
|
48
|
+
return Buffer.byteLength(entry, 'utf8') + 1;
|
|
49
|
+
}
|
|
50
|
+
// Drop oldest entries until under the cap. Always retains at least the most
|
|
51
|
+
// recent entry so a single oversized message is still captured.
|
|
52
|
+
trimToByteLimit() {
|
|
53
|
+
while (this.bytes > this.byteLimit && this.entries.length > 1) {
|
|
54
|
+
const removed = this.entries.shift();
|
|
55
|
+
this.bytes -= LogBuffer.entrySize(removed);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
record(level, args) {
|
|
59
|
+
const message = args.map(arg => String(arg)).join(' ');
|
|
60
|
+
const entry = `[${new Date().toISOString()}] [${level}] ${message}`;
|
|
61
|
+
this.entries.push(entry);
|
|
62
|
+
this.bytes += LogBuffer.entrySize(entry);
|
|
63
|
+
this.trimToByteLimit();
|
|
64
|
+
}
|
|
65
|
+
view() {
|
|
66
|
+
return this.entries.join('\n');
|
|
67
|
+
}
|
|
68
|
+
flush() {
|
|
69
|
+
const out = this.entries.join('\n');
|
|
70
|
+
this.entries.length = 0;
|
|
71
|
+
this.bytes = 0;
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
// Flush the buffer to a rotating log file. Always clears the buffer (even
|
|
75
|
+
// on write failure). Returns the written file path on success, or null if
|
|
76
|
+
// the buffer was empty or the write failed.
|
|
77
|
+
writeToFile(options) {
|
|
78
|
+
const { dir, filenamePrefix, maxFiles = DEFAULT_MAX_LOG_FILES } = options;
|
|
79
|
+
const contents = this.flush();
|
|
80
|
+
if (!contents) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
85
|
+
rotateLogFiles(dir, maxFiles);
|
|
86
|
+
const filename = `${sanitizeFilenamePart(filenamePrefix)}-${timestampForFilename()}.log`;
|
|
87
|
+
const filePath = path.join(dir, filename);
|
|
88
|
+
fs.writeFileSync(filePath, contents, 'utf8');
|
|
89
|
+
return filePath;
|
|
90
|
+
}
|
|
91
|
+
catch (_e) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
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/logger.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type ChalkInstance } from 'chalk';
|
|
2
|
+
import { WriteBufferedLogsOptions } from './LogBuffer.js';
|
|
3
|
+
export type { WriteBufferedLogsOptions };
|
|
2
4
|
export declare const LOG_LEVEL: {
|
|
3
5
|
NONE: number;
|
|
4
6
|
DEBUG: number;
|
|
@@ -50,5 +52,7 @@ export declare const logger: {
|
|
|
50
52
|
debug(...args: any[]): void;
|
|
51
53
|
group(...args: any[]): void;
|
|
52
54
|
groupEnd(): void;
|
|
55
|
+
viewLogBuffer(): string;
|
|
56
|
+
flushLogBuffer(): string;
|
|
57
|
+
writeBufferedLogsToFile(options: WriteBufferedLogsOptions): string | null;
|
|
53
58
|
};
|
|
54
|
-
export {};
|
package/lib/logger.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { isUnicodeSupported } from './isUnicodeSupported.js';
|
|
4
|
+
import { LogBuffer } from './LogBuffer.js';
|
|
4
5
|
export const LOG_LEVEL = {
|
|
5
6
|
NONE: 0,
|
|
6
7
|
DEBUG: 1,
|
|
@@ -127,41 +128,58 @@ export function getLogLevel() {
|
|
|
127
128
|
return LOG_LEVEL.NONE;
|
|
128
129
|
}
|
|
129
130
|
}
|
|
131
|
+
const _logBuffer = new LogBuffer();
|
|
130
132
|
export const logger = {
|
|
131
133
|
error(...args) {
|
|
134
|
+
_logBuffer.record('ERROR', args);
|
|
132
135
|
if (shouldLog(LOG_LEVEL.ERROR)) {
|
|
133
136
|
currentLogger.error(...args);
|
|
134
137
|
}
|
|
135
138
|
},
|
|
136
139
|
warn(...args) {
|
|
140
|
+
_logBuffer.record('WARN', args);
|
|
137
141
|
if (shouldLog(LOG_LEVEL.WARN)) {
|
|
138
142
|
currentLogger.warn(...args);
|
|
139
143
|
}
|
|
140
144
|
},
|
|
141
145
|
log(...args) {
|
|
146
|
+
_logBuffer.record('LOG', args);
|
|
142
147
|
if (shouldLog(LOG_LEVEL.LOG)) {
|
|
143
148
|
currentLogger.log(...args);
|
|
144
149
|
}
|
|
145
150
|
},
|
|
146
151
|
success(...args) {
|
|
152
|
+
_logBuffer.record('SUCCESS', args);
|
|
147
153
|
if (shouldLog(LOG_LEVEL.LOG)) {
|
|
148
154
|
currentLogger.success(...args);
|
|
149
155
|
}
|
|
150
156
|
},
|
|
151
157
|
info(...args) {
|
|
158
|
+
_logBuffer.record('INFO', args);
|
|
152
159
|
if (shouldLog(LOG_LEVEL.LOG)) {
|
|
153
160
|
currentLogger.info(...args);
|
|
154
161
|
}
|
|
155
162
|
},
|
|
156
163
|
debug(...args) {
|
|
164
|
+
_logBuffer.record('DEBUG', args);
|
|
157
165
|
if (shouldLog(LOG_LEVEL.DEBUG)) {
|
|
158
166
|
currentLogger.debug(...args);
|
|
159
167
|
}
|
|
160
168
|
},
|
|
161
169
|
group(...args) {
|
|
170
|
+
_logBuffer.record('GROUP', args);
|
|
162
171
|
currentLogger.group(...args);
|
|
163
172
|
},
|
|
164
173
|
groupEnd() {
|
|
165
174
|
currentLogger.groupEnd();
|
|
166
175
|
},
|
|
176
|
+
viewLogBuffer() {
|
|
177
|
+
return _logBuffer.view();
|
|
178
|
+
},
|
|
179
|
+
flushLogBuffer() {
|
|
180
|
+
return _logBuffer.flush();
|
|
181
|
+
},
|
|
182
|
+
writeBufferedLogsToFile(options) {
|
|
183
|
+
return _logBuffer.writeToFile(options);
|
|
184
|
+
},
|
|
167
185
|
};
|
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.1",
|
|
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
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Build } from './Build.js';
|
|
2
2
|
import { GithubSourceData } from './Github.js';
|
|
3
3
|
import { ProjectLog } from './ProjectLog.js';
|
|
4
|
-
import { ValueOf } from './Utils.js';
|
|
5
|
-
import { SUBBUILD_TYPES } from '../enums/build.js';
|
|
6
4
|
export type Project = {
|
|
7
5
|
createdAt: number;
|
|
8
6
|
deletedAt: number;
|
|
@@ -50,22 +48,3 @@ export type FetchPlatformVersionResponse = {
|
|
|
50
48
|
export type WarnLogsResponse = {
|
|
51
49
|
logs: Array<ProjectLog>;
|
|
52
50
|
};
|
|
53
|
-
export type Release = {
|
|
54
|
-
releaseTag: string;
|
|
55
|
-
buildId: number;
|
|
56
|
-
createdAt: string;
|
|
57
|
-
components?: Array<{
|
|
58
|
-
buildType: ValueOf<typeof SUBBUILD_TYPES>;
|
|
59
|
-
buildName?: string;
|
|
60
|
-
rootPath?: string;
|
|
61
|
-
id?: string;
|
|
62
|
-
}>;
|
|
63
|
-
};
|
|
64
|
-
export type FetchListReleasesResponse = {
|
|
65
|
-
results: Array<Release>;
|
|
66
|
-
paging: {
|
|
67
|
-
next: {
|
|
68
|
-
after: string;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
};
|
|
@@ -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) => {
|