@hubspot/local-dev-lib 4.0.4 → 5.0.0-beta.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/appsDev.d.ts +2 -2
- package/api/appsDev.js +13 -22
- package/api/crm.d.ts +2 -2
- package/api/crm.js +9 -16
- package/api/customObjects.d.ts +2 -2
- package/api/customObjects.js +13 -22
- package/api/designManager.d.ts +2 -2
- package/api/designManager.js +5 -10
- package/api/devSecrets.d.ts +2 -2
- package/api/devSecrets.js +9 -16
- package/api/developerTestAccounts.d.ts +2 -4
- package/api/developerTestAccounts.js +23 -52
- package/api/fileManager.d.ts +2 -2
- package/api/fileManager.js +14 -24
- package/api/fileMapper.d.ts +2 -3
- package/api/fileMapper.js +34 -49
- package/api/fileTransport.d.ts +1 -1
- package/api/fileTransport.js +12 -21
- package/api/fireAlarm.d.ts +2 -3
- package/api/fireAlarm.js +5 -9
- package/api/functions.d.ts +2 -2
- package/api/functions.js +11 -19
- package/api/github.d.ts +2 -4
- package/api/github.js +16 -27
- package/api/hubdb.d.ts +2 -2
- package/api/hubdb.js +19 -31
- package/api/lighthouseScore.d.ts +2 -2
- package/api/lighthouseScore.js +7 -13
- package/api/localDevAuth.d.ts +3 -6
- package/api/localDevAuth.js +10 -37
- package/api/marketplaceValidation.d.ts +2 -2
- package/api/marketplaceValidation.js +7 -13
- package/api/projects.d.ts +6 -8
- package/api/projects.js +65 -100
- package/api/sandboxHubs.d.ts +2 -5
- package/api/sandboxHubs.js +15 -42
- package/api/sandboxSync.d.ts +2 -2
- package/api/sandboxSync.js +7 -12
- package/api/secrets.d.ts +2 -2
- package/api/secrets.js +9 -16
- package/api/validateHubl.d.ts +2 -2
- package/api/validateHubl.js +3 -7
- package/config/defaultAccountOverride.d.ts +2 -1
- package/config/defaultAccountOverride.js +16 -26
- package/config/index.d.ts +4 -4
- package/config/index.js +141 -177
- package/config/migrate.d.ts +2 -2
- package/config/migrate.js +26 -37
- package/config/state.d.ts +1 -1
- package/config/state.js +17 -45
- package/config/utils.d.ts +4 -4
- package/config/utils.js +85 -108
- package/constants/api.js +3 -6
- package/constants/auth.js +9 -12
- package/constants/config.js +37 -43
- package/constants/endpoints.d.ts +6 -0
- package/constants/endpoints.js +6 -0
- package/constants/environments.js +1 -4
- package/constants/extensions.js +6 -9
- package/constants/files.js +5 -8
- package/constants/ports.js +3 -6
- package/constants/projects.js +2 -5
- package/enums/build.d.ts +1 -0
- package/enums/build.js +6 -8
- package/enums/deploy.js +2 -5
- package/enums/project.js +1 -4
- package/errors/index.d.ts +4 -5
- package/errors/index.js +17 -39
- package/errors/isSystemError.d.ts +2 -0
- package/errors/isSystemError.js +9 -0
- package/http/addQueryParams.d.ts +1 -1
- package/http/addQueryParams.js +1 -5
- package/http/client.js +14 -42
- package/http/getAxiosConfig.d.ts +1 -1
- package/http/getAxiosConfig.js +21 -31
- package/http/index.d.ts +2 -2
- package/http/index.js +39 -46
- package/http/unauthed.d.ts +1 -1
- package/http/unauthed.js +15 -18
- package/lang/en.json +1 -1
- package/lib/archive.d.ts +1 -3
- package/lib/archive.js +37 -67
- package/lib/cms/functions.d.ts +1 -1
- package/lib/cms/functions.js +45 -55
- package/lib/cms/handleFieldsJS.js +36 -44
- package/lib/cms/modules.d.ts +2 -2
- package/lib/cms/modules.js +49 -59
- package/lib/cms/processFieldsJs.js +17 -32
- package/lib/cms/templates.js +17 -26
- package/lib/cms/themes.js +10 -18
- package/lib/cms/uploadFolder.d.ts +4 -4
- package/lib/cms/uploadFolder.js +55 -64
- package/lib/cms/validate.d.ts +1 -1
- package/lib/cms/validate.js +11 -18
- package/lib/cms/watch.d.ts +2 -2
- package/lib/cms/watch.js +66 -73
- package/lib/crm.d.ts +1 -1
- package/lib/crm.js +15 -23
- package/lib/customObjects.d.ts +1 -1
- package/lib/customObjects.js +15 -25
- package/lib/environment.d.ts +1 -1
- package/lib/environment.js +5 -11
- package/lib/escapeRegExp.js +1 -5
- package/lib/fileManager.js +43 -51
- package/lib/fileMapper.d.ts +1 -1
- package/lib/fileMapper.js +68 -84
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +18 -27
- package/lib/github.d.ts +1 -3
- package/lib/github.js +39 -51
- package/lib/gitignore.d.ts +1 -1
- package/lib/gitignore.js +16 -24
- package/lib/hubdb.d.ts +1 -1
- package/lib/hubdb.js +29 -40
- package/lib/ignoreRules.js +25 -34
- package/lib/isDeepEqual.js +1 -5
- package/lib/logger.d.ts +8 -20
- package/lib/logger.js +47 -59
- package/lib/notify.js +9 -16
- package/lib/oauth.d.ts +2 -2
- package/lib/oauth.js +12 -17
- package/lib/path.d.ts +0 -1
- package/lib/path.js +30 -48
- package/lib/personalAccessKey.d.ts +2 -4
- package/lib/personalAccessKey.js +43 -60
- package/lib/portManager.d.ts +2 -2
- package/lib/portManager.js +26 -41
- package/lib/text.js +2 -7
- package/lib/trackUsage.d.ts +0 -2
- package/lib/trackUsage.js +23 -29
- package/lib/urls.js +4 -9
- package/models/FileSystemError.d.ts +1 -1
- package/models/FileSystemError.js +12 -16
- package/models/HubSpotConfigError.d.ts +1 -1
- package/models/HubSpotConfigError.js +8 -12
- package/models/HubSpotHttpError.d.ts +1 -1
- package/models/HubSpotHttpError.js +22 -26
- package/models/OAuth2Manager.d.ts +1 -1
- package/models/OAuth2Manager.js +17 -24
- package/package.json +20 -16
- package/types/Accounts.d.ts +6 -5
- package/types/Accounts.js +1 -2
- package/types/Activity.d.ts +3 -3
- package/types/Activity.js +1 -2
- package/types/Api.d.ts +1 -1
- package/types/Api.js +1 -2
- package/types/Apps.js +1 -2
- package/types/Archive.js +1 -2
- package/types/Build.d.ts +4 -5
- package/types/Build.js +1 -2
- package/types/CLIOptions.js +1 -2
- package/types/ComponentStructure.d.ts +2 -2
- package/types/ComponentStructure.js +1 -2
- package/types/Config.d.ts +4 -6
- package/types/Config.js +1 -2
- package/types/Crm.js +1 -2
- package/types/Deploy.d.ts +5 -11
- package/types/Deploy.js +1 -2
- package/types/DesignManager.js +1 -2
- package/types/DevSecrets.js +1 -2
- package/types/Error.js +1 -2
- package/types/FieldsJS.js +1 -2
- package/types/FileManager.js +1 -2
- package/types/Files.d.ts +4 -4
- package/types/Files.js +1 -2
- package/types/FireAlarm.js +1 -2
- package/types/Functions.js +1 -2
- package/types/Github.d.ts +1 -1
- package/types/Github.js +1 -2
- package/types/Http.d.ts +0 -4
- package/types/Http.js +1 -2
- package/types/Hubdb.js +1 -2
- package/types/HublValidation.js +1 -2
- package/types/Lang.d.ts +1 -1
- package/types/Lang.js +1 -2
- package/types/Lighthouse.js +1 -2
- package/types/MarketplaceValidation.js +1 -2
- package/types/Migration.d.ts +2 -2
- package/types/Migration.js +1 -4
- package/types/Modules.js +1 -2
- package/types/PortManager.js +1 -2
- package/types/Project.d.ts +3 -21
- package/types/Project.js +1 -2
- package/types/ProjectComponents.d.ts +24 -0
- package/types/ProjectComponents.js +1 -0
- package/types/ProjectLog.js +1 -2
- package/types/Sandbox.js +2 -5
- package/types/Schemas.js +1 -2
- package/types/Secrets.js +1 -2
- package/types/Utils.js +1 -2
- package/types/developerTestAccounts.js +1 -2
- package/utils/PortManagerServer.d.ts +1 -2
- package/utils/PortManagerServer.js +32 -38
- package/utils/cms/fieldsJS.d.ts +1 -1
- package/utils/cms/fieldsJS.js +1 -5
- package/utils/cms/modules.d.ts +1 -1
- package/utils/cms/modules.js +13 -22
- package/utils/detectPort.js +12 -19
- package/utils/git.js +17 -26
- package/utils/lang.d.ts +1 -1
- package/utils/lang.js +5 -14
- package/utils/personalAccessKey.d.ts +8 -0
- package/utils/personalAccessKey.js +51 -0
- package/errors/errors_DEPRECATED.d.ts +0 -3
- package/errors/errors_DEPRECATED.js +0 -60
package/types/Project.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Build } from './Build';
|
|
2
|
-
import { GithubSourceData } from './Github';
|
|
3
|
-
import { ProjectLog } from './ProjectLog';
|
|
1
|
+
import type { Build } from './Build.js';
|
|
2
|
+
import { GithubSourceData } from './Github.js';
|
|
3
|
+
import { ProjectLog } from './ProjectLog.js';
|
|
4
4
|
export type Project = {
|
|
5
5
|
createdAt: number;
|
|
6
6
|
deletedAt: number;
|
|
@@ -45,24 +45,6 @@ export type FetchPlatformVersionResponse = {
|
|
|
45
45
|
defaultPlatformVersion: string;
|
|
46
46
|
activePlatformVersions: Array<string>;
|
|
47
47
|
};
|
|
48
|
-
export type ProjectStandardError = {
|
|
49
|
-
status: string;
|
|
50
|
-
id?: string;
|
|
51
|
-
category: string;
|
|
52
|
-
subCategory?: string;
|
|
53
|
-
message?: string;
|
|
54
|
-
errors?: Array<{
|
|
55
|
-
message: string;
|
|
56
|
-
in?: string;
|
|
57
|
-
code?: string;
|
|
58
|
-
subcateogy?: string;
|
|
59
|
-
context: object;
|
|
60
|
-
}>;
|
|
61
|
-
context: object;
|
|
62
|
-
links: {
|
|
63
|
-
[key: string]: string;
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
48
|
export type WarnLogsResponse = {
|
|
67
49
|
logs: Array<ProjectLog>;
|
|
68
50
|
};
|
package/types/Project.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type DeployStatusTaskLocator = {
|
|
2
|
+
id: string;
|
|
3
|
+
links: Array<{
|
|
4
|
+
status: string;
|
|
5
|
+
}>;
|
|
6
|
+
};
|
|
7
|
+
export type ProjectStandardError = {
|
|
8
|
+
status: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
category: string;
|
|
11
|
+
subCategory?: string;
|
|
12
|
+
message?: string;
|
|
13
|
+
errors?: Array<{
|
|
14
|
+
message: string;
|
|
15
|
+
in?: string;
|
|
16
|
+
code?: string;
|
|
17
|
+
subcateogy?: string;
|
|
18
|
+
context: object;
|
|
19
|
+
}>;
|
|
20
|
+
context: object;
|
|
21
|
+
links: {
|
|
22
|
+
[key: string]: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/ProjectLog.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/types/Sandbox.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SandboxStatus = exports.SandboxVersioning = void 0;
|
|
4
|
-
exports.SandboxVersioning = {
|
|
1
|
+
export const SandboxVersioning = {
|
|
5
2
|
V1: 'V1',
|
|
6
3
|
V2: 'V2',
|
|
7
4
|
};
|
|
8
|
-
|
|
5
|
+
export const SandboxStatus = {
|
|
9
6
|
PENDING: 'PENDING',
|
|
10
7
|
READY: 'READY',
|
|
11
8
|
FAILED: 'FAILED',
|
package/types/Schemas.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/types/Secrets.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/types/Utils.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Express } from 'express';
|
|
3
2
|
import { Server } from 'http';
|
|
4
|
-
import { ServerPortMap } from '../types/PortManager';
|
|
3
|
+
import { ServerPortMap } from '../types/PortManager.js';
|
|
5
4
|
export declare const HEALTH_CHECK_PATH = "/port-manager-health-check";
|
|
6
5
|
export declare const SERVICE_HEALTHY = "OK";
|
|
7
6
|
declare class _PortManagerServer {
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const express_1 = __importDefault(require("express"));
|
|
8
|
-
const cors_1 = __importDefault(require("cors"));
|
|
9
|
-
const detectPort_1 = require("./detectPort");
|
|
10
|
-
const ports_1 = require("../constants/ports");
|
|
11
|
-
const logger_1 = require("../lib/logger");
|
|
12
|
-
const lang_1 = require("./lang");
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import cors from 'cors';
|
|
3
|
+
import { detectPort } from './detectPort.js';
|
|
4
|
+
import { MIN_PORT_NUMBER, MAX_PORT_NUMBER, PORT_MANAGER_SERVER_PORT, } from '../constants/ports.js';
|
|
5
|
+
import { logger } from '../lib/logger.js';
|
|
6
|
+
import { i18n } from './lang.js';
|
|
13
7
|
const i18nKey = 'utils.PortManagerServer';
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
export const HEALTH_CHECK_PATH = '/port-manager-health-check';
|
|
9
|
+
export const SERVICE_HEALTHY = 'OK';
|
|
16
10
|
class _PortManagerServer {
|
|
17
11
|
app;
|
|
18
12
|
server;
|
|
@@ -22,19 +16,19 @@ class _PortManagerServer {
|
|
|
22
16
|
}
|
|
23
17
|
async init() {
|
|
24
18
|
if (!(await this.portAvailable())) {
|
|
25
|
-
throw new Error(
|
|
26
|
-
port:
|
|
19
|
+
throw new Error(i18n(`${i18nKey}.errors.portInUse`, {
|
|
20
|
+
port: PORT_MANAGER_SERVER_PORT,
|
|
27
21
|
}));
|
|
28
22
|
}
|
|
29
23
|
if (this.app) {
|
|
30
|
-
throw new Error(
|
|
24
|
+
throw new Error(i18n(`${i18nKey}.errors.duplicateInstance`));
|
|
31
25
|
}
|
|
32
|
-
this.app = (
|
|
33
|
-
this.app.use(
|
|
34
|
-
this.app.use((
|
|
26
|
+
this.app = express();
|
|
27
|
+
this.app.use(express.json());
|
|
28
|
+
this.app.use(cors());
|
|
35
29
|
this.setupRoutes();
|
|
36
30
|
this.server = await this.listen();
|
|
37
|
-
|
|
31
|
+
logger.debug(this.server);
|
|
38
32
|
}
|
|
39
33
|
reset() {
|
|
40
34
|
this.app = undefined;
|
|
@@ -42,13 +36,13 @@ class _PortManagerServer {
|
|
|
42
36
|
this.serverPortMap = {};
|
|
43
37
|
}
|
|
44
38
|
async portAvailable() {
|
|
45
|
-
return ((await
|
|
39
|
+
return ((await detectPort(PORT_MANAGER_SERVER_PORT)) === PORT_MANAGER_SERVER_PORT);
|
|
46
40
|
}
|
|
47
41
|
listen() {
|
|
48
42
|
return new Promise((resolve, reject) => {
|
|
49
|
-
const server = this.app.listen(
|
|
50
|
-
|
|
51
|
-
port:
|
|
43
|
+
const server = this.app.listen(PORT_MANAGER_SERVER_PORT, () => {
|
|
44
|
+
logger.debug(i18n(`${i18nKey}.started`, {
|
|
45
|
+
port: PORT_MANAGER_SERVER_PORT,
|
|
52
46
|
}));
|
|
53
47
|
resolve(server);
|
|
54
48
|
}).on('error', (err) => {
|
|
@@ -65,16 +59,16 @@ class _PortManagerServer {
|
|
|
65
59
|
this.app.post('/servers', this.assignPortsToServers);
|
|
66
60
|
this.app.delete('/servers/:instanceId', this.deleteServerInstance);
|
|
67
61
|
this.app.post('/close', this.closeServer);
|
|
68
|
-
this.app.use(
|
|
69
|
-
res.status(200).send({ status:
|
|
62
|
+
this.app.use(HEALTH_CHECK_PATH, (req, res) => {
|
|
63
|
+
res.status(200).send({ status: SERVICE_HEALTHY });
|
|
70
64
|
});
|
|
71
65
|
}
|
|
72
66
|
setPort(instanceId, port) {
|
|
73
|
-
|
|
67
|
+
logger.debug(i18n(`${i18nKey}.setPort`, { instanceId, port }));
|
|
74
68
|
this.serverPortMap[instanceId] = port;
|
|
75
69
|
}
|
|
76
70
|
deletePort(instanceId) {
|
|
77
|
-
|
|
71
|
+
logger.debug(i18n(`${i18nKey}.deletedPort`, {
|
|
78
72
|
instanceId,
|
|
79
73
|
port: this.serverPortMap[instanceId],
|
|
80
74
|
}));
|
|
@@ -83,7 +77,7 @@ class _PortManagerServer {
|
|
|
83
77
|
send404(res, instanceId) {
|
|
84
78
|
res
|
|
85
79
|
.status(404)
|
|
86
|
-
.send(
|
|
80
|
+
.send(i18n(`${i18nKey}.errors.404`, { instanceId: instanceId }));
|
|
87
81
|
}
|
|
88
82
|
getServers = async (req, res) => {
|
|
89
83
|
res.send({
|
|
@@ -107,22 +101,22 @@ class _PortManagerServer {
|
|
|
107
101
|
for (let i = 0; i < portData.length; i++) {
|
|
108
102
|
const { port, instanceId } = portData[i];
|
|
109
103
|
if (this.serverPortMap[instanceId]) {
|
|
110
|
-
res.status(409).send(
|
|
104
|
+
res.status(409).send(i18n(`${i18nKey}.errors.409`, {
|
|
111
105
|
instanceId,
|
|
112
106
|
port: this.serverPortMap[instanceId],
|
|
113
107
|
}));
|
|
114
108
|
return;
|
|
115
109
|
}
|
|
116
|
-
else if (port && (port <
|
|
117
|
-
res.status(400).send(
|
|
118
|
-
minPort:
|
|
119
|
-
maxPort:
|
|
110
|
+
else if (port && (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER)) {
|
|
111
|
+
res.status(400).send(i18n(`${i18nKey}.errors.400`, {
|
|
112
|
+
minPort: MIN_PORT_NUMBER,
|
|
113
|
+
maxPort: MAX_PORT_NUMBER,
|
|
120
114
|
}));
|
|
121
115
|
return;
|
|
122
116
|
}
|
|
123
117
|
else {
|
|
124
118
|
const promise = new Promise(resolve => {
|
|
125
|
-
|
|
119
|
+
detectPort(port, Object.values(this.serverPortMap)).then(resolvedPort => {
|
|
126
120
|
resolve({
|
|
127
121
|
[instanceId]: resolvedPort,
|
|
128
122
|
});
|
|
@@ -151,11 +145,11 @@ class _PortManagerServer {
|
|
|
151
145
|
};
|
|
152
146
|
closeServer = (req, res) => {
|
|
153
147
|
if (this.server) {
|
|
154
|
-
|
|
148
|
+
logger.debug(i18n(`${i18nKey}.close`));
|
|
155
149
|
res.sendStatus(200);
|
|
156
150
|
this.server.close();
|
|
157
151
|
this.reset();
|
|
158
152
|
}
|
|
159
153
|
};
|
|
160
154
|
}
|
|
161
|
-
|
|
155
|
+
export const PortManagerServer = new _PortManagerServer();
|
package/utils/cms/fieldsJS.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FieldsArray } from '../../types/FieldsJS';
|
|
1
|
+
import { FieldsArray } from '../../types/FieldsJS.js';
|
|
2
2
|
export declare function fieldsArrayToJson<T>(fields: FieldsArray<T>): string;
|
package/utils/cms/fieldsJS.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fieldsArrayToJson = void 0;
|
|
4
1
|
/*
|
|
5
2
|
* Polyfill for `Array.flat(Infinity)` since the `flat` is only available for Node v11+
|
|
6
3
|
* https://stackoverflow.com/a/15030117
|
|
@@ -11,8 +8,7 @@ function flattenArray(arr) {
|
|
|
11
8
|
}, []);
|
|
12
9
|
}
|
|
13
10
|
//Transform fields array to JSON
|
|
14
|
-
function fieldsArrayToJson(fields) {
|
|
11
|
+
export function fieldsArrayToJson(fields) {
|
|
15
12
|
const flattened = flattenArray(fields);
|
|
16
13
|
return JSON.stringify(flattened, null, 2);
|
|
17
14
|
}
|
|
18
|
-
exports.fieldsArrayToJson = fieldsArrayToJson;
|
package/utils/cms/modules.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PathInput } from '../../types/Modules';
|
|
1
|
+
import { PathInput } from '../../types/Modules.js';
|
|
2
2
|
export declare function isPathInput(pathInput?: PathInput): boolean;
|
|
3
3
|
export declare function isModuleFolder(pathInput: PathInput): boolean;
|
|
4
4
|
export declare function isModuleFolderChild(pathInput: PathInput, ignoreLocales?: boolean): boolean;
|
package/utils/cms/modules.js
CHANGED
|
@@ -1,42 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isModuleFolderChild = exports.isModuleFolder = exports.isPathInput = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const path_2 = require("../../lib/path");
|
|
9
|
-
const extensions_1 = require("../../constants/extensions");
|
|
10
|
-
const lang_1 = require("../lang");
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { getExt, splitHubSpotPath, splitLocalPath } from '../../lib/path.js';
|
|
3
|
+
import { MODULE_EXTENSION } from '../../constants/extensions.js';
|
|
4
|
+
import { i18n } from '../lang.js';
|
|
11
5
|
const i18nKey = 'utils.cms.modules';
|
|
12
6
|
const isBool = (x) => !!x === x;
|
|
13
|
-
function isPathInput(pathInput) {
|
|
7
|
+
export function isPathInput(pathInput) {
|
|
14
8
|
return !!(pathInput &&
|
|
15
9
|
typeof pathInput.path === 'string' &&
|
|
16
10
|
(isBool(pathInput.isLocal) || isBool(pathInput.isHubSpot)));
|
|
17
11
|
}
|
|
18
|
-
exports.isPathInput = isPathInput;
|
|
19
12
|
function throwInvalidPathInput(pathInput) {
|
|
20
13
|
if (isPathInput(pathInput))
|
|
21
14
|
return;
|
|
22
|
-
throw new Error(
|
|
15
|
+
throw new Error(i18n(`${i18nKey}.throwInvalidPathInput`));
|
|
23
16
|
}
|
|
24
|
-
function isModuleFolder(pathInput) {
|
|
17
|
+
export function isModuleFolder(pathInput) {
|
|
25
18
|
throwInvalidPathInput(pathInput);
|
|
26
19
|
const _path = pathInput.isHubSpot
|
|
27
|
-
?
|
|
28
|
-
:
|
|
29
|
-
return
|
|
20
|
+
? path.posix.normalize(pathInput.path)
|
|
21
|
+
: path.normalize(pathInput.path);
|
|
22
|
+
return getExt(_path) === MODULE_EXTENSION;
|
|
30
23
|
}
|
|
31
|
-
|
|
32
|
-
function isModuleFolderChild(pathInput, ignoreLocales = false) {
|
|
24
|
+
export function isModuleFolderChild(pathInput, ignoreLocales = false) {
|
|
33
25
|
throwInvalidPathInput(pathInput);
|
|
34
26
|
let pathParts = [];
|
|
35
27
|
if (pathInput.isLocal) {
|
|
36
|
-
pathParts =
|
|
28
|
+
pathParts = splitLocalPath(pathInput.path);
|
|
37
29
|
}
|
|
38
30
|
else if (pathInput.isHubSpot) {
|
|
39
|
-
pathParts =
|
|
31
|
+
pathParts = splitHubSpotPath(pathInput.path);
|
|
40
32
|
}
|
|
41
33
|
const { length } = pathParts;
|
|
42
34
|
// Not a child path?
|
|
@@ -51,4 +43,3 @@ function isModuleFolderChild(pathInput, ignoreLocales = false) {
|
|
|
51
43
|
.slice(0, length - 1)
|
|
52
44
|
.some(part => isModuleFolder({ ...pathInput, path: part }));
|
|
53
45
|
}
|
|
54
|
-
exports.isModuleFolderChild = isModuleFolderChild;
|
package/utils/detectPort.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
From https://github.com/node-modules/detect-port/tree/master
|
|
4
3
|
|
|
@@ -23,32 +22,26 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
23
22
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
24
23
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
24
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
exports.detectPort = void 0;
|
|
31
|
-
const net_1 = __importDefault(require("net"));
|
|
32
|
-
const address_1 = require("address");
|
|
33
|
-
const ports_1 = require("../constants/ports");
|
|
34
|
-
const lang_1 = require("./lang");
|
|
25
|
+
import net from 'net';
|
|
26
|
+
import { ip } from 'address';
|
|
27
|
+
import { MIN_PORT_NUMBER, MAX_PORT_NUMBER } from '../constants/ports.js';
|
|
28
|
+
import { i18n } from './lang.js';
|
|
35
29
|
const i18nKey = 'utils.detectPort';
|
|
36
|
-
function detectPort(port, exclude = []) {
|
|
37
|
-
if (port && (port <
|
|
38
|
-
throw new Error(
|
|
39
|
-
minPort:
|
|
40
|
-
maxPort:
|
|
30
|
+
export function detectPort(port, exclude = []) {
|
|
31
|
+
if (port && (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER)) {
|
|
32
|
+
throw new Error(i18n(`${i18nKey}.errors.invalidPort`, {
|
|
33
|
+
minPort: MIN_PORT_NUMBER,
|
|
34
|
+
maxPort: MAX_PORT_NUMBER,
|
|
41
35
|
}));
|
|
42
36
|
}
|
|
43
37
|
const portToUse = port || 0;
|
|
44
|
-
const maxPort = Math.min(portToUse + 10,
|
|
38
|
+
const maxPort = Math.min(portToUse + 10, MAX_PORT_NUMBER);
|
|
45
39
|
return new Promise(resolve => {
|
|
46
40
|
tryListen(portToUse, maxPort, exclude, (_, resolvedPort) => {
|
|
47
41
|
resolve(resolvedPort);
|
|
48
42
|
});
|
|
49
43
|
});
|
|
50
44
|
}
|
|
51
|
-
exports.detectPort = detectPort;
|
|
52
45
|
function tryListen(port, maxPort, exclude, callback) {
|
|
53
46
|
const shouldGiveUp = port >= maxPort;
|
|
54
47
|
const nextPort = shouldGiveUp ? 0 : port + 1;
|
|
@@ -75,7 +68,7 @@ function tryListen(port, maxPort, exclude, callback) {
|
|
|
75
68
|
return tryListen(nextPort, nextMaxPort, exclude, callback);
|
|
76
69
|
}
|
|
77
70
|
// 4. check current ip
|
|
78
|
-
listen(port,
|
|
71
|
+
listen(port, ip(), (err, realPort) => {
|
|
79
72
|
if (err) {
|
|
80
73
|
return tryListen(nextPort, nextMaxPort, exclude, callback);
|
|
81
74
|
}
|
|
@@ -86,7 +79,7 @@ function tryListen(port, maxPort, exclude, callback) {
|
|
|
86
79
|
});
|
|
87
80
|
}
|
|
88
81
|
function listen(port, hostname, callback) {
|
|
89
|
-
const server = new
|
|
82
|
+
const server = new net.Server();
|
|
90
83
|
server.on('error', (err) => {
|
|
91
84
|
server.close();
|
|
92
85
|
if (err.code === 'ENOTFOUND') {
|
package/utils/git.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.configFilenameIsIgnoredByGitignore = exports.isConfigPathInGitRepo = exports.getGitignoreFiles = void 0;
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const ignore_1 = __importDefault(require("ignore"));
|
|
10
|
-
const findup_sync_1 = __importDefault(require("findup-sync"));
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import ignore from 'ignore';
|
|
4
|
+
import findup from 'findup-sync';
|
|
11
5
|
const GITIGNORE_FILE = '.gitignore';
|
|
12
6
|
function makeComparisonDir(filepath) {
|
|
13
7
|
if (typeof filepath !== 'string')
|
|
14
8
|
return null;
|
|
15
|
-
const dir =
|
|
9
|
+
const dir = path.dirname(path.resolve(filepath)).toLowerCase();
|
|
16
10
|
// Append sep to make comparisons easier e.g. 'foos'.startsWith('foo')
|
|
17
|
-
return dir + (!dir.endsWith(
|
|
11
|
+
return dir + (!dir.endsWith(path.sep) ? path.sep : '');
|
|
18
12
|
}
|
|
19
13
|
function getGitComparisonDir() {
|
|
20
|
-
return makeComparisonDir((
|
|
14
|
+
return makeComparisonDir(findup('.git'));
|
|
21
15
|
}
|
|
22
16
|
// Get all .gitignore files since they can cascade down directory structures
|
|
23
|
-
function getGitignoreFiles(configPath) {
|
|
17
|
+
export function getGitignoreFiles(configPath) {
|
|
24
18
|
const gitDir = getGitComparisonDir();
|
|
25
19
|
const files = [];
|
|
26
20
|
if (!gitDir) {
|
|
@@ -28,9 +22,9 @@ function getGitignoreFiles(configPath) {
|
|
|
28
22
|
return files;
|
|
29
23
|
}
|
|
30
24
|
// Start findup from config dir
|
|
31
|
-
let cwd = configPath &&
|
|
25
|
+
let cwd = configPath && path.dirname(configPath);
|
|
32
26
|
while (cwd) {
|
|
33
|
-
const ignorePath = (
|
|
27
|
+
const ignorePath = findup(GITIGNORE_FILE, { cwd });
|
|
34
28
|
const cmpIgnorePath = makeComparisonDir(ignorePath);
|
|
35
29
|
const cmpGitDir = makeComparisonDir(gitDir);
|
|
36
30
|
if (ignorePath &&
|
|
@@ -38,9 +32,9 @@ function getGitignoreFiles(configPath) {
|
|
|
38
32
|
cmpGitDir &&
|
|
39
33
|
// Stop findup after .git dir is reached
|
|
40
34
|
cmpIgnorePath.startsWith(cmpGitDir)) {
|
|
41
|
-
const file =
|
|
35
|
+
const file = path.resolve(ignorePath);
|
|
42
36
|
files.push(file);
|
|
43
|
-
cwd =
|
|
37
|
+
cwd = path.resolve(path.dirname(file) + '..');
|
|
44
38
|
}
|
|
45
39
|
else {
|
|
46
40
|
cwd = null;
|
|
@@ -48,8 +42,7 @@ function getGitignoreFiles(configPath) {
|
|
|
48
42
|
}
|
|
49
43
|
return files;
|
|
50
44
|
}
|
|
51
|
-
|
|
52
|
-
function isConfigPathInGitRepo(configPath) {
|
|
45
|
+
export function isConfigPathInGitRepo(configPath) {
|
|
53
46
|
const gitDir = getGitComparisonDir();
|
|
54
47
|
if (!gitDir)
|
|
55
48
|
return false;
|
|
@@ -58,15 +51,13 @@ function isConfigPathInGitRepo(configPath) {
|
|
|
58
51
|
return false;
|
|
59
52
|
return configDir.startsWith(gitDir);
|
|
60
53
|
}
|
|
61
|
-
|
|
62
|
-
function configFilenameIsIgnoredByGitignore(ignoreFiles, configPath) {
|
|
54
|
+
export function configFilenameIsIgnoredByGitignore(ignoreFiles, configPath) {
|
|
63
55
|
return ignoreFiles.some(gitignore => {
|
|
64
|
-
const gitignoreContents =
|
|
65
|
-
const gitignoreConfig = (
|
|
66
|
-
if (gitignoreConfig.ignores(
|
|
56
|
+
const gitignoreContents = fs.readFileSync(gitignore).toString();
|
|
57
|
+
const gitignoreConfig = ignore().add(gitignoreContents);
|
|
58
|
+
if (gitignoreConfig.ignores(path.relative(path.dirname(gitignore), configPath))) {
|
|
67
59
|
return true;
|
|
68
60
|
}
|
|
69
61
|
return false;
|
|
70
62
|
});
|
|
71
63
|
}
|
|
72
|
-
exports.configFilenameIsIgnoredByGitignore = configFilenameIsIgnoredByGitignore;
|
package/utils/lang.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LanguageObject, LangKey, InterpolationData } from '../types/Lang';
|
|
1
|
+
import { LanguageObject, LangKey, InterpolationData } from '../types/Lang.js';
|
|
2
2
|
export declare function interpolate(stringValue: string, interpolationData: InterpolationData): string;
|
|
3
3
|
export declare function i18n(lookupDotNotation: LangKey, options?: {
|
|
4
4
|
[identifier: string]: string | number;
|
package/utils/lang.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setLangData = exports.i18n = exports.interpolate = void 0;
|
|
7
|
-
const en_json_1 = __importDefault(require("../lang/en.json"));
|
|
1
|
+
import en from '../lang/en.json' with { type: 'json' };
|
|
8
2
|
const LANGUAGES = {
|
|
9
|
-
en
|
|
3
|
+
en,
|
|
10
4
|
};
|
|
11
5
|
const MISSING_LANGUAGE_DATA_PREFIX = '[Missing language data]';
|
|
12
6
|
let languageObj;
|
|
@@ -53,7 +47,7 @@ function generateReplaceFn(matchedText, startIndex, replacementString) {
|
|
|
53
47
|
return `${currentStringValue.slice(0, startIndex)}${replacementString || ''}${currentStringValue.slice(startIndex + matchedText.length)}`;
|
|
54
48
|
};
|
|
55
49
|
}
|
|
56
|
-
function interpolate(stringValue, interpolationData) {
|
|
50
|
+
export function interpolate(stringValue, interpolationData) {
|
|
57
51
|
const interpolationIdentifierRegEx = new RegExp(`${delimiters.interpolation.start}(.*?)${delimiters.interpolation.end}`, 'g');
|
|
58
52
|
const replaceQueue = [];
|
|
59
53
|
let match;
|
|
@@ -69,8 +63,7 @@ function interpolate(stringValue, interpolationData) {
|
|
|
69
63
|
const compiledString = replaceQueue.reduce((currentValue, replaceFn) => replaceFn(currentValue), stringValue);
|
|
70
64
|
return compiledString;
|
|
71
65
|
}
|
|
72
|
-
|
|
73
|
-
function i18n(lookupDotNotation, options = {}) {
|
|
66
|
+
export function i18n(lookupDotNotation, options = {}) {
|
|
74
67
|
if (!languageObj) {
|
|
75
68
|
loadLanguageForLocale();
|
|
76
69
|
}
|
|
@@ -81,8 +74,6 @@ function i18n(lookupDotNotation, options = {}) {
|
|
|
81
74
|
const shouldInterpolate = !textValue.startsWith(MISSING_LANGUAGE_DATA_PREFIX);
|
|
82
75
|
return shouldInterpolate ? interpolate(textValue, options) : textValue;
|
|
83
76
|
}
|
|
84
|
-
|
|
85
|
-
const setLangData = (newLocale, newLangObj) => {
|
|
77
|
+
export const setLangData = (newLocale, newLangObj) => {
|
|
86
78
|
languageObj = newLangObj;
|
|
87
79
|
};
|
|
88
|
-
exports.setLangData = setLangData;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosPromise } from 'axios';
|
|
2
|
+
import { AccessTokenResponse, Environment } from '../types/Accounts.js';
|
|
3
|
+
import { DeveloperTestAccount } from '../types/developerTestAccounts.js';
|
|
4
|
+
import { SandboxHubData } from '../types/Sandbox.js';
|
|
5
|
+
import { HubSpotPromise } from '../types/Http.js';
|
|
6
|
+
export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): HubSpotPromise<AccessTokenResponse>;
|
|
7
|
+
export declare function fetchSandboxHubData(accessToken: string, accountId: number, env?: Environment): AxiosPromise<SandboxHubData>;
|
|
8
|
+
export declare function fetchDeveloperTestAccountData(accessToken: string, accountId: number, env?: Environment): HubSpotPromise<DeveloperTestAccount>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { httpClient } from '../http/client.js';
|
|
2
|
+
import { getAxiosConfig } from '../http/getAxiosConfig.js';
|
|
3
|
+
import { ENVIRONMENTS } from '../constants/environments.js';
|
|
4
|
+
import { LOCALDEVAUTH_ACCESS_TOKEN_PATH } from '../constants/endpoints.js';
|
|
5
|
+
const SANDBOX_API_PATH = 'sandbox-hubs/v1';
|
|
6
|
+
const TEST_ACCOUNTS_API_PATH = 'integrators/test-portals/v2';
|
|
7
|
+
export function fetchAccessToken(personalAccessKey, env = ENVIRONMENTS.PROD, portalId) {
|
|
8
|
+
const axiosConfig = getAxiosConfig({
|
|
9
|
+
env,
|
|
10
|
+
localHostOverride: true,
|
|
11
|
+
url: LOCALDEVAUTH_ACCESS_TOKEN_PATH,
|
|
12
|
+
data: {
|
|
13
|
+
encodedOAuthRefreshToken: personalAccessKey,
|
|
14
|
+
},
|
|
15
|
+
params: portalId ? { portalId } : {},
|
|
16
|
+
});
|
|
17
|
+
return httpClient({
|
|
18
|
+
...axiosConfig,
|
|
19
|
+
method: 'post',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function fetchSandboxHubData(accessToken, accountId, env = ENVIRONMENTS.PROD) {
|
|
23
|
+
const axiosConfig = getAxiosConfig({
|
|
24
|
+
env,
|
|
25
|
+
url: `${SANDBOX_API_PATH}/self`,
|
|
26
|
+
params: { portalId: accountId },
|
|
27
|
+
});
|
|
28
|
+
const reqWithToken = {
|
|
29
|
+
...axiosConfig,
|
|
30
|
+
headers: {
|
|
31
|
+
...axiosConfig.headers,
|
|
32
|
+
Authorization: `Bearer ${accessToken}`,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
return httpClient(reqWithToken);
|
|
36
|
+
}
|
|
37
|
+
export function fetchDeveloperTestAccountData(accessToken, accountId, env = ENVIRONMENTS.PROD) {
|
|
38
|
+
const axiosConfig = getAxiosConfig({
|
|
39
|
+
env,
|
|
40
|
+
url: `${TEST_ACCOUNTS_API_PATH}/self`,
|
|
41
|
+
params: { portalId: accountId },
|
|
42
|
+
});
|
|
43
|
+
const reqWithToken = {
|
|
44
|
+
...axiosConfig,
|
|
45
|
+
headers: {
|
|
46
|
+
...axiosConfig.headers,
|
|
47
|
+
Authorization: `Bearer ${accessToken}`,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
return httpClient(reqWithToken);
|
|
51
|
+
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { BaseError, FileSystemErrorContext, ErrorContext } from '../types/Error';
|
|
2
|
-
export declare function logErrorInstance(error: BaseError, context?: ErrorContext): void;
|
|
3
|
-
export declare function logFileSystemErrorInstance(error: BaseError, context: FileSystemErrorContext): void;
|