@hubspot/local-dev-lib 0.2.6-experimental.0 → 0.3.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/fireAlarm.d.ts +3 -0
- package/api/fireAlarm.js +11 -0
- package/api/projects.d.ts +11 -45
- package/api/projects.js +27 -17
- package/config/configFile.js +1 -3
- package/config/index.d.ts +1 -0
- package/config/index.js +8 -1
- package/config/migrate.d.ts +22 -0
- package/config/migrate.js +166 -0
- package/constants/config.d.ts +8 -0
- package/constants/config.js +14 -1
- package/constants/projects.d.ts +11 -0
- package/constants/projects.js +14 -0
- package/lang/en.json +6 -0
- package/models/HubSpotHttpError.d.ts +1 -0
- package/models/HubSpotHttpError.js +2 -0
- package/package.json +2 -1
- package/types/FireAlarm.d.ts +8 -0
- package/types/FireAlarm.js +2 -0
- package/types/Migration.d.ts +29 -0
- package/types/Migration.js +2 -0
- package/types/Project.d.ts +32 -0
- package/constants/platformVersion.d.ts +0 -6
- package/constants/platformVersion.js +0 -9
package/api/fireAlarm.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchFireAlarms = void 0;
|
|
4
|
+
const http_1 = require("../http");
|
|
5
|
+
const FIREALARM_API_AUTH_PATH = 'firealarm/v4/alarm';
|
|
6
|
+
function fetchFireAlarms(accountId) {
|
|
7
|
+
return http_1.http.get(accountId, {
|
|
8
|
+
url: `${FIREALARM_API_AUTH_PATH}/hubspot-cli/${accountId}`,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.fetchFireAlarms = fetchFireAlarms;
|
package/api/projects.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { HubSpotPromise, QueryParams } from '../types/Http';
|
|
4
|
-
import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse, WarnLogsResponse, UploadIRResponse } from '../types/Project';
|
|
4
|
+
import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse, WarnLogsResponse, UploadIRResponse, ListAppsResponse, InitializeMigrationResponse, ContinueMigrationResponse } from '../types/Project';
|
|
5
5
|
import { Build, FetchProjectBuildsResponse } from '../types/Build';
|
|
6
6
|
import { ComponentStructureResponse, ProjectComponentsMetadata } from '../types/ComponentStructure';
|
|
7
7
|
import { Deploy, ProjectDeployResponse } from '../types/Deploy';
|
|
8
|
-
import { MigrateAppResponse, CloneAppResponse, PollAppResponse } from '../types/Migration';
|
|
8
|
+
import { MigrateAppResponse, CloneAppResponse, PollAppResponse, MigrationStatus } from '../types/Migration';
|
|
9
9
|
export declare function fetchProjects(accountId: number): HubSpotPromise<FetchProjectResponse>;
|
|
10
10
|
export declare function createProject(accountId: number, name: string): HubSpotPromise<Project>;
|
|
11
11
|
export declare function uploadProject(accountId: number, projectName: string, projectFile: string, uploadMessage: string, platformVersion?: string, intermediateRepresentation?: unknown): HubSpotPromise<UploadProjectResponse | UploadIRResponse>;
|
|
@@ -28,51 +28,17 @@ export declare function deleteFileFromBuild(accountId: number, projectName: stri
|
|
|
28
28
|
export declare function cancelStagedBuild(accountId: number, projectName: string): HubSpotPromise<void>;
|
|
29
29
|
export declare function fetchBuildWarnLogs(accountId: number, projectName: string, buildId: number): HubSpotPromise<WarnLogsResponse>;
|
|
30
30
|
export declare function fetchDeployWarnLogs(accountId: number, projectName: string, deployId: number): HubSpotPromise<WarnLogsResponse>;
|
|
31
|
-
export interface MigrationStageOneResponse {
|
|
32
|
-
migrationId: number;
|
|
33
|
-
componentsRequiringUids: Record<string, {
|
|
34
|
-
componentType: string;
|
|
35
|
-
componentHint: string | null;
|
|
36
|
-
}>;
|
|
37
|
-
}
|
|
38
|
-
export interface ListAppsMigrationComponent {
|
|
39
|
-
id: string;
|
|
40
|
-
componentType: string;
|
|
41
|
-
isSupported: boolean;
|
|
42
|
-
}
|
|
43
|
-
export declare const UNMIGRATABLE_REASONS: {
|
|
44
|
-
UP_TO_DATE: string;
|
|
45
|
-
IS_A_PRIVATE_APP: string;
|
|
46
|
-
LISTED_IN_MARKETPLACE: string;
|
|
47
|
-
};
|
|
48
|
-
interface BaseMigrationApp {
|
|
49
|
-
appId: number;
|
|
50
|
-
appName: string;
|
|
51
|
-
isMigratable: boolean;
|
|
52
|
-
migrationComponents: ListAppsMigrationComponent[];
|
|
53
|
-
}
|
|
54
|
-
export interface MigratableApp extends BaseMigrationApp {
|
|
55
|
-
isMigratable: true;
|
|
56
|
-
}
|
|
57
|
-
export interface UnmigratableApp extends BaseMigrationApp {
|
|
58
|
-
isMigratable: false;
|
|
59
|
-
unmigratableReason: keyof typeof UNMIGRATABLE_REASONS;
|
|
60
|
-
}
|
|
61
|
-
export type MigrationApp = MigratableApp | UnmigratableApp;
|
|
62
|
-
export interface ListAppsResponse {
|
|
63
|
-
migratableApps: MigratableApp[];
|
|
64
|
-
unmigratableApps: UnmigratableApp[];
|
|
65
|
-
}
|
|
66
31
|
export declare function listAppsForMigration(accountId: number): HubSpotPromise<ListAppsResponse>;
|
|
67
|
-
export declare function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
32
|
+
export declare function initializeMigration(accountId: number, applicationId: number, platformVersion: string): HubSpotPromise<InitializeMigrationResponse>;
|
|
33
|
+
export declare function continueMigration(portalId: number, migrationId: number, componentUids: Record<string, string>, projectName: string): HubSpotPromise<ContinueMigrationResponse>;
|
|
34
|
+
export declare function migrateApp(accountId: number, appId: number, projectName: string): HubSpotPromise<MigrateAppResponse>;
|
|
35
|
+
export declare function checkMigrationStatusV2(accountId: number, id: number): HubSpotPromise<MigrationStatus>;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated
|
|
38
|
+
* @param accountId
|
|
39
|
+
* @param id
|
|
40
|
+
*/
|
|
74
41
|
export declare function checkMigrationStatus(accountId: number, id: number): HubSpotPromise<PollAppResponse>;
|
|
75
42
|
export declare function cloneApp(accountId: number, appId: number): HubSpotPromise<CloneAppResponse>;
|
|
76
43
|
export declare function checkCloneStatus(accountId: number, exportId: number): HubSpotPromise<CloneAppResponse>;
|
|
77
44
|
export declare function downloadClonedProject(accountId: number, exportId: number): HubSpotPromise<Buffer>;
|
|
78
|
-
export {};
|
package/api/projects.js
CHANGED
|
@@ -3,10 +3,10 @@ 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.downloadClonedProject = exports.checkCloneStatus = exports.cloneApp = exports.checkMigrationStatus = exports.
|
|
6
|
+
exports.downloadClonedProject = exports.checkCloneStatus = exports.cloneApp = exports.checkMigrationStatus = exports.checkMigrationStatusV2 = exports.migrateApp = exports.continueMigration = exports.initializeMigration = exports.listAppsForMigration = exports.fetchDeployWarnLogs = exports.fetchBuildWarnLogs = exports.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProjectComponentsMetadata = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0;
|
|
7
7
|
const http_1 = require("../http");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const
|
|
9
|
+
const projects_1 = require("../constants/projects");
|
|
10
10
|
const PROJECTS_API_PATH = 'dfs/v1/projects';
|
|
11
11
|
const DEVELOPER_FILE_SYSTEM_PATH = 'dfs/v1';
|
|
12
12
|
const PROJECTS_DEPLOY_API_PATH = 'dfs/deploy/v1';
|
|
@@ -207,32 +207,31 @@ function fetchDeployWarnLogs(accountId, projectName, deployId) {
|
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
exports.fetchDeployWarnLogs = fetchDeployWarnLogs;
|
|
210
|
-
exports.UNMIGRATABLE_REASONS = {
|
|
211
|
-
UP_TO_DATE: 'UP_TO_DATE',
|
|
212
|
-
IS_A_PRIVATE_APP: 'IS_A_PRIVATE_APP',
|
|
213
|
-
LISTED_IN_MARKETPLACE: 'LISTED_IN_MARKETPLACE',
|
|
214
|
-
};
|
|
215
210
|
async function listAppsForMigration(accountId) {
|
|
216
211
|
return http_1.http.get(accountId, {
|
|
217
212
|
url: `${MIGRATIONS_API_PATH_V2}/list-apps`,
|
|
218
213
|
});
|
|
219
214
|
}
|
|
220
215
|
exports.listAppsForMigration = listAppsForMigration;
|
|
221
|
-
|
|
216
|
+
function mapPlatformVersionToEnum(platformVersion) {
|
|
217
|
+
if (platformVersion === projects_1.PLATFORM_VERSIONS.unstable) {
|
|
218
|
+
return projects_1.PLATFORM_VERSIONS.unstable.toUpperCase();
|
|
219
|
+
}
|
|
220
|
+
return `V${platformVersion.replace('.', '_')}`;
|
|
221
|
+
}
|
|
222
|
+
async function initializeMigration(accountId, applicationId, platformVersion) {
|
|
222
223
|
return http_1.http.post(accountId, {
|
|
223
224
|
url: `${MIGRATIONS_API_PATH_V2}/migrations`,
|
|
224
225
|
data: {
|
|
225
226
|
applicationId,
|
|
227
|
+
platformVersion: mapPlatformVersionToEnum(platformVersion),
|
|
226
228
|
},
|
|
227
229
|
});
|
|
228
230
|
}
|
|
229
|
-
exports.
|
|
230
|
-
async function
|
|
231
|
-
const pathPlatformVersion = targetPlatformVersion === platformVersion_1.PLATFORM_VERSIONS.unstable
|
|
232
|
-
? targetPlatformVersion
|
|
233
|
-
: `v${targetPlatformVersion.replace('.', '')}`;
|
|
231
|
+
exports.initializeMigration = initializeMigration;
|
|
232
|
+
async function continueMigration(portalId, migrationId, componentUids, projectName) {
|
|
234
233
|
return http_1.http.post(portalId, {
|
|
235
|
-
url: `${MIGRATIONS_API_PATH_V2}/migrations/
|
|
234
|
+
url: `${MIGRATIONS_API_PATH_V2}/migrations/continue`,
|
|
236
235
|
data: {
|
|
237
236
|
migrationId,
|
|
238
237
|
projectName,
|
|
@@ -240,8 +239,8 @@ async function finishMigration(portalId, migrationId, componentUids, projectName
|
|
|
240
239
|
},
|
|
241
240
|
});
|
|
242
241
|
}
|
|
243
|
-
exports.
|
|
244
|
-
function
|
|
242
|
+
exports.continueMigration = continueMigration;
|
|
243
|
+
function migrateApp(accountId, appId, projectName) {
|
|
245
244
|
return http_1.http.post(accountId, {
|
|
246
245
|
url: `${MIGRATIONS_API_PATH_V1}/migrations`,
|
|
247
246
|
data: {
|
|
@@ -251,7 +250,18 @@ function migrateNonProjectApp_v2023_2(accountId, appId, projectName) {
|
|
|
251
250
|
},
|
|
252
251
|
});
|
|
253
252
|
}
|
|
254
|
-
exports.
|
|
253
|
+
exports.migrateApp = migrateApp;
|
|
254
|
+
function checkMigrationStatusV2(accountId, id) {
|
|
255
|
+
return http_1.http.get(accountId, {
|
|
256
|
+
url: `${MIGRATIONS_API_PATH_V2}/migrations/${id}/status`,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
exports.checkMigrationStatusV2 = checkMigrationStatusV2;
|
|
260
|
+
/**
|
|
261
|
+
* @deprecated
|
|
262
|
+
* @param accountId
|
|
263
|
+
* @param id
|
|
264
|
+
*/
|
|
255
265
|
function checkMigrationStatus(accountId, id) {
|
|
256
266
|
return http_1.http.get(accountId, {
|
|
257
267
|
url: `${MIGRATIONS_API_PATH_V1}/migrations/${id}`,
|
package/config/configFile.js
CHANGED
|
@@ -5,8 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.writeConfigToFile = exports.loadConfigFromFile = exports.parseConfig = exports.readConfigFile = exports.deleteConfigFile = exports.configFileIsBlank = exports.configFileExists = exports.getConfigFilePath = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const os_1 = __importDefault(require("os"));
|
|
10
8
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
11
9
|
const logger_1 = require("../lib/logger");
|
|
12
10
|
const config_1 = require("../constants/config");
|
|
@@ -15,7 +13,7 @@ const lang_1 = require("../utils/lang");
|
|
|
15
13
|
const FileSystemError_1 = require("../models/FileSystemError");
|
|
16
14
|
const i18nKey = 'config.configFile';
|
|
17
15
|
function getConfigFilePath() {
|
|
18
|
-
return
|
|
16
|
+
return config_1.GLOBAL_CONFIG_PATH;
|
|
19
17
|
}
|
|
20
18
|
exports.getConfigFilePath = getConfigFilePath;
|
|
21
19
|
function configFileExists() {
|
package/config/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export declare function isTrackingAllowed(): boolean;
|
|
|
31
31
|
export declare function getEnv(nameOrId?: string | number): import("../types/Config").Environment;
|
|
32
32
|
export declare function getAccountType(accountType?: AccountType, sandboxAccountType?: string | null): AccountType;
|
|
33
33
|
export declare function getConfigDefaultAccount(): string | number | null | undefined;
|
|
34
|
+
export declare function getDisplayDefaultAccount(): string | number | null | undefined;
|
|
34
35
|
export declare function getConfigAccounts(): Array<CLIAccount_NEW> | Array<CLIAccount_DEPRECATED> | null | undefined;
|
|
35
36
|
export declare function updateDefaultCmsPublishMode(cmsPublishMode: CmsPublishMode): void | CLIConfig_NEW | null;
|
|
36
37
|
export declare function getCWDAccountOverride(): string | number | null | undefined;
|
package/config/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.findConfig = exports.setConfigPath = exports.setConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.getConfigAccountId = exports.getDefaultAccountOverrideFilePath = exports.getCWDAccountOverride = exports.updateDefaultCmsPublishMode = exports.getConfigAccounts = exports.getConfigDefaultAccount = 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;
|
|
26
|
+
exports.findConfig = exports.setConfigPath = exports.setConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.getConfigAccountId = exports.getDefaultAccountOverrideFilePath = exports.getCWDAccountOverride = exports.updateDefaultCmsPublishMode = exports.getConfigAccounts = exports.getDisplayDefaultAccount = exports.getConfigDefaultAccount = 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");
|
|
@@ -237,6 +237,13 @@ function getConfigDefaultAccount() {
|
|
|
237
237
|
return config_DEPRECATED.getConfigDefaultAccount();
|
|
238
238
|
}
|
|
239
239
|
exports.getConfigDefaultAccount = getConfigDefaultAccount;
|
|
240
|
+
function getDisplayDefaultAccount() {
|
|
241
|
+
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
242
|
+
return CLIConfiguration_1.CLIConfiguration.config?.defaultAccount;
|
|
243
|
+
}
|
|
244
|
+
return config_DEPRECATED.getConfigDefaultAccount();
|
|
245
|
+
}
|
|
246
|
+
exports.getDisplayDefaultAccount = getDisplayDefaultAccount;
|
|
240
247
|
function getConfigAccounts() {
|
|
241
248
|
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
242
249
|
return CLIConfiguration_1.CLIConfiguration.getConfigAccounts();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CLIConfig_DEPRECATED, CLIConfig_NEW, Environment } from '../types/Config';
|
|
2
|
+
import { CmsPublishMode } from '../types/Files';
|
|
3
|
+
export declare function getDeprecatedConfig(configPath?: string): CLIConfig_DEPRECATED | null;
|
|
4
|
+
export declare function getGlobalConfig(): CLIConfig_NEW | null;
|
|
5
|
+
export declare function configFileExists(useHiddenConfig?: boolean, configPath?: string): boolean;
|
|
6
|
+
export declare function getConfigPath(configPath?: string, useHiddenConfig?: boolean): string | null;
|
|
7
|
+
export declare function migrateConfig(deprecatedConfig: CLIConfig_DEPRECATED | null): void;
|
|
8
|
+
type ConflictValue = boolean | string | number | CmsPublishMode | Environment;
|
|
9
|
+
export type ConflictProperty = {
|
|
10
|
+
property: keyof CLIConfig_NEW;
|
|
11
|
+
oldValue: ConflictValue;
|
|
12
|
+
newValue: ConflictValue;
|
|
13
|
+
};
|
|
14
|
+
export declare function mergeConfigProperties(globalConfig: CLIConfig_NEW, deprecatedConfig: CLIConfig_DEPRECATED, force?: boolean): {
|
|
15
|
+
initialConfig: CLIConfig_NEW;
|
|
16
|
+
conflicts: Array<ConflictProperty>;
|
|
17
|
+
};
|
|
18
|
+
export declare function mergeExistingConfigs(globalConfig: CLIConfig_NEW, deprecatedConfig: CLIConfig_DEPRECATED): {
|
|
19
|
+
finalConfig: CLIConfig_NEW;
|
|
20
|
+
skippedAccountIds: Array<string | number>;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.mergeExistingConfigs = exports.mergeConfigProperties = exports.migrateConfig = exports.getConfigPath = exports.configFileExists = exports.getGlobalConfig = exports.getDeprecatedConfig = void 0;
|
|
27
|
+
const config_DEPRECATED = __importStar(require("./config_DEPRECATED"));
|
|
28
|
+
const CLIConfiguration_1 = require("./CLIConfiguration");
|
|
29
|
+
const index_1 = require("./index");
|
|
30
|
+
const configFile_1 = require("./configFile");
|
|
31
|
+
const config_1 = require("../constants/config");
|
|
32
|
+
const lang_1 = require("../utils/lang");
|
|
33
|
+
const i18nKey = 'config.migrate';
|
|
34
|
+
function getDeprecatedConfig(configPath) {
|
|
35
|
+
return config_DEPRECATED.loadConfig(configPath);
|
|
36
|
+
}
|
|
37
|
+
exports.getDeprecatedConfig = getDeprecatedConfig;
|
|
38
|
+
function getGlobalConfig() {
|
|
39
|
+
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
40
|
+
return CLIConfiguration_1.CLIConfiguration.config;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
exports.getGlobalConfig = getGlobalConfig;
|
|
45
|
+
function configFileExists(useHiddenConfig = false, configPath) {
|
|
46
|
+
return useHiddenConfig
|
|
47
|
+
? (0, configFile_1.configFileExists)()
|
|
48
|
+
: Boolean(config_DEPRECATED.getConfigPath(configPath));
|
|
49
|
+
}
|
|
50
|
+
exports.configFileExists = configFileExists;
|
|
51
|
+
function getConfigPath(configPath, useHiddenConfig = false) {
|
|
52
|
+
if (useHiddenConfig) {
|
|
53
|
+
return (0, configFile_1.getConfigFilePath)();
|
|
54
|
+
}
|
|
55
|
+
return config_DEPRECATED.getConfigPath(configPath);
|
|
56
|
+
}
|
|
57
|
+
exports.getConfigPath = getConfigPath;
|
|
58
|
+
function writeGlobalConfigFile(updatedConfig, isMigrating = false) {
|
|
59
|
+
const updatedConfigJson = JSON.stringify(updatedConfig);
|
|
60
|
+
if (isMigrating) {
|
|
61
|
+
(0, index_1.createEmptyConfigFile)({}, true);
|
|
62
|
+
}
|
|
63
|
+
(0, index_1.loadConfig)('');
|
|
64
|
+
try {
|
|
65
|
+
(0, index_1.writeConfig)({ source: updatedConfigJson });
|
|
66
|
+
config_DEPRECATED.deleteConfigFile();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
(0, index_1.deleteEmptyConfigFile)();
|
|
70
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.writeConfig`, { configPath: config_1.GLOBAL_CONFIG_PATH }), { cause: error });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function migrateConfig(deprecatedConfig) {
|
|
74
|
+
if (!deprecatedConfig) {
|
|
75
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noDeprecatedConfig`));
|
|
76
|
+
}
|
|
77
|
+
const { defaultPortal, portals, ...rest } = deprecatedConfig;
|
|
78
|
+
const updatedConfig = {
|
|
79
|
+
...rest,
|
|
80
|
+
defaultAccount: defaultPortal,
|
|
81
|
+
accounts: portals
|
|
82
|
+
.filter(({ portalId }) => portalId !== undefined)
|
|
83
|
+
.map(({ portalId, ...rest }) => ({
|
|
84
|
+
...rest,
|
|
85
|
+
accountId: portalId,
|
|
86
|
+
})),
|
|
87
|
+
};
|
|
88
|
+
writeGlobalConfigFile(updatedConfig, true);
|
|
89
|
+
}
|
|
90
|
+
exports.migrateConfig = migrateConfig;
|
|
91
|
+
function mergeConfigProperties(globalConfig, deprecatedConfig, force) {
|
|
92
|
+
const propertiesToCheck = [
|
|
93
|
+
config_1.DEFAULT_CMS_PUBLISH_MODE,
|
|
94
|
+
config_1.HTTP_TIMEOUT,
|
|
95
|
+
config_1.ENV,
|
|
96
|
+
config_1.HTTP_USE_LOCALHOST,
|
|
97
|
+
config_1.ALLOW_USAGE_TRACKING,
|
|
98
|
+
];
|
|
99
|
+
const conflicts = [];
|
|
100
|
+
propertiesToCheck.forEach(prop => {
|
|
101
|
+
if (prop in globalConfig && prop in deprecatedConfig) {
|
|
102
|
+
if (force || globalConfig[prop] === deprecatedConfig[prop]) {
|
|
103
|
+
// @ts-expect-error Cannot reconcile CLIConfig_NEW and CLIConfig_DEPRECATED types
|
|
104
|
+
globalConfig[prop] = deprecatedConfig[prop];
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
conflicts.push({
|
|
108
|
+
property: prop,
|
|
109
|
+
oldValue: deprecatedConfig[prop],
|
|
110
|
+
newValue: globalConfig[prop],
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
if (config_1.DEFAULT_ACCOUNT in globalConfig &&
|
|
116
|
+
config_1.DEFAULT_PORTAL in deprecatedConfig &&
|
|
117
|
+
globalConfig.defaultAccount !== deprecatedConfig.defaultPortal) {
|
|
118
|
+
if (force) {
|
|
119
|
+
globalConfig.defaultAccount = deprecatedConfig.defaultPortal;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
conflicts.push({
|
|
123
|
+
property: config_1.DEFAULT_ACCOUNT,
|
|
124
|
+
oldValue: deprecatedConfig.defaultPortal,
|
|
125
|
+
newValue: globalConfig.defaultAccount,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else if (config_1.DEFAULT_PORTAL in deprecatedConfig) {
|
|
130
|
+
globalConfig.defaultAccount = deprecatedConfig.defaultPortal;
|
|
131
|
+
}
|
|
132
|
+
return { initialConfig: globalConfig, conflicts };
|
|
133
|
+
}
|
|
134
|
+
exports.mergeConfigProperties = mergeConfigProperties;
|
|
135
|
+
function mergeAccounts(globalConfig, deprecatedConfig) {
|
|
136
|
+
let existingAccountIds = [];
|
|
137
|
+
const skippedAccountIds = [];
|
|
138
|
+
if (globalConfig.accounts && deprecatedConfig.portals) {
|
|
139
|
+
existingAccountIds = globalConfig.accounts.map(account => account.accountId);
|
|
140
|
+
const newAccounts = deprecatedConfig.portals
|
|
141
|
+
.filter(portal => {
|
|
142
|
+
const isExisting = existingAccountIds.includes(portal.portalId);
|
|
143
|
+
if (isExisting) {
|
|
144
|
+
skippedAccountIds.push(portal.portalId);
|
|
145
|
+
}
|
|
146
|
+
return !isExisting;
|
|
147
|
+
})
|
|
148
|
+
.map(({ portalId, ...rest }) => ({
|
|
149
|
+
...rest,
|
|
150
|
+
accountId: portalId,
|
|
151
|
+
}));
|
|
152
|
+
if (newAccounts.length > 0) {
|
|
153
|
+
globalConfig.accounts.push(...newAccounts);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
finalConfig: globalConfig,
|
|
158
|
+
skippedAccountIds,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function mergeExistingConfigs(globalConfig, deprecatedConfig) {
|
|
162
|
+
const { finalConfig, skippedAccountIds } = mergeAccounts(globalConfig, deprecatedConfig);
|
|
163
|
+
writeGlobalConfigFile(finalConfig);
|
|
164
|
+
return { finalConfig, skippedAccountIds };
|
|
165
|
+
}
|
|
166
|
+
exports.mergeExistingConfigs = mergeExistingConfigs;
|
package/constants/config.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
export declare const DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = "hubspot.config.yml";
|
|
2
2
|
export declare const HUBSPOT_CONFIGURATION_FOLDER = ".hscli";
|
|
3
3
|
export declare const HUBSPOT_CONFIGURATION_FILE = "config.yml";
|
|
4
|
+
export declare const GLOBAL_CONFIG_PATH: string;
|
|
4
5
|
export declare const DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = ".hsaccount";
|
|
5
6
|
export declare const DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = "DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID";
|
|
6
7
|
export declare const DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = "DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND";
|
|
8
|
+
export declare const DEFAULT_CMS_PUBLISH_MODE = "defaultCmsPublishMode";
|
|
9
|
+
export declare const HTTP_TIMEOUT = "httpTimeout";
|
|
10
|
+
export declare const ENV = "env";
|
|
11
|
+
export declare const HTTP_USE_LOCALHOST = "httpUseLocalhost";
|
|
12
|
+
export declare const ALLOW_USAGE_TRACKING = "allowUsageTracking";
|
|
13
|
+
export declare const DEFAULT_ACCOUNT = "defaultAccount";
|
|
14
|
+
export declare const DEFAULT_PORTAL = "defaultPortal";
|
|
7
15
|
export declare const MIN_HTTP_TIMEOUT = 3000;
|
|
8
16
|
export declare const HUBSPOT_ACCOUNT_TYPES: {
|
|
9
17
|
readonly DEVELOPMENT_SANDBOX: "DEVELOPMENT_SANDBOX";
|
package/constants/config.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
|
|
6
|
+
exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.DEFAULT_PORTAL = exports.DEFAULT_ACCOUNT = exports.ALLOW_USAGE_TRACKING = exports.HTTP_USE_LOCALHOST = exports.ENV = exports.HTTP_TIMEOUT = exports.DEFAULT_CMS_PUBLISH_MODE = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = exports.GLOBAL_CONFIG_PATH = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
|
|
4
7
|
const lang_1 = require("../utils/lang");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
5
10
|
exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
|
|
6
11
|
exports.HUBSPOT_CONFIGURATION_FOLDER = '.hscli';
|
|
7
12
|
exports.HUBSPOT_CONFIGURATION_FILE = 'config.yml';
|
|
13
|
+
exports.GLOBAL_CONFIG_PATH = path_1.default.join(os_1.default.homedir(), exports.HUBSPOT_CONFIGURATION_FOLDER, exports.HUBSPOT_CONFIGURATION_FILE);
|
|
8
14
|
exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = '.hsaccount';
|
|
9
15
|
exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = 'DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID';
|
|
10
16
|
exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = 'DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND';
|
|
17
|
+
exports.DEFAULT_CMS_PUBLISH_MODE = 'defaultCmsPublishMode';
|
|
18
|
+
exports.HTTP_TIMEOUT = 'httpTimeout';
|
|
19
|
+
exports.ENV = 'env';
|
|
20
|
+
exports.HTTP_USE_LOCALHOST = 'httpUseLocalhost';
|
|
21
|
+
exports.ALLOW_USAGE_TRACKING = 'allowUsageTracking';
|
|
22
|
+
exports.DEFAULT_ACCOUNT = 'defaultAccount';
|
|
23
|
+
exports.DEFAULT_PORTAL = 'defaultPortal';
|
|
11
24
|
exports.MIN_HTTP_TIMEOUT = 3000;
|
|
12
25
|
exports.HUBSPOT_ACCOUNT_TYPES = {
|
|
13
26
|
DEVELOPMENT_SANDBOX: 'DEVELOPMENT_SANDBOX',
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const UNMIGRATABLE_REASONS: {
|
|
2
|
+
UP_TO_DATE: string;
|
|
3
|
+
IS_A_PRIVATE_APP: string;
|
|
4
|
+
LISTED_IN_MARKETPLACE: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const PLATFORM_VERSIONS: {
|
|
7
|
+
v2023_2: string;
|
|
8
|
+
v2025_1: string;
|
|
9
|
+
v2025_2: string;
|
|
10
|
+
unstable: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PLATFORM_VERSIONS = exports.UNMIGRATABLE_REASONS = void 0;
|
|
4
|
+
exports.UNMIGRATABLE_REASONS = {
|
|
5
|
+
UP_TO_DATE: 'UP_TO_DATE',
|
|
6
|
+
IS_A_PRIVATE_APP: 'IS_A_PRIVATE_APP',
|
|
7
|
+
LISTED_IN_MARKETPLACE: 'LISTED_IN_MARKETPLACE',
|
|
8
|
+
};
|
|
9
|
+
exports.PLATFORM_VERSIONS = {
|
|
10
|
+
v2023_2: '2023.2',
|
|
11
|
+
v2025_1: '2025.1',
|
|
12
|
+
v2025_2: '2025.2',
|
|
13
|
+
unstable: 'unstable',
|
|
14
|
+
};
|
package/lang/en.json
CHANGED
|
@@ -311,6 +311,12 @@
|
|
|
311
311
|
"missingEnv": "Unable to load config from environment variables: Missing env",
|
|
312
312
|
"unknownAuthType": "Unable to load config from environment variables: Unknown auth type"
|
|
313
313
|
}
|
|
314
|
+
},
|
|
315
|
+
"migrate": {
|
|
316
|
+
"errors": {
|
|
317
|
+
"writeConfig": "Unable to write global configuration file at {{ configPath }}.",
|
|
318
|
+
"noDeprecatedConfig": "No deprecated configuration file found. Skipping migration to global config."
|
|
319
|
+
}
|
|
314
320
|
}
|
|
315
321
|
},
|
|
316
322
|
"models": {
|
|
@@ -14,6 +14,7 @@ export declare class HubSpotHttpError<T = any> extends Error {
|
|
|
14
14
|
detailedMessage?: string;
|
|
15
15
|
private divider;
|
|
16
16
|
cause: ErrorOptions['cause'];
|
|
17
|
+
timeout?: number;
|
|
17
18
|
constructor(message?: string, options?: ErrorOptions, context?: HubSpotHttpErrorContext);
|
|
18
19
|
updateContext(context: Partial<HubSpotHttpErrorContext>): void;
|
|
19
20
|
toString(): string;
|
|
@@ -18,6 +18,7 @@ class HubSpotHttpError extends Error {
|
|
|
18
18
|
detailedMessage;
|
|
19
19
|
divider = `\n- `;
|
|
20
20
|
cause;
|
|
21
|
+
timeout;
|
|
21
22
|
constructor(message, options, context) {
|
|
22
23
|
super(message, options);
|
|
23
24
|
this.name = 'HubSpotHttpError';
|
|
@@ -32,6 +33,7 @@ class HubSpotHttpError extends Error {
|
|
|
32
33
|
this.detailedMessage = this.joinErrorMessages(options.cause, this.context);
|
|
33
34
|
this.code = code;
|
|
34
35
|
this.method = config?.method;
|
|
36
|
+
this.timeout = config?.timeout;
|
|
35
37
|
// Pull the request fields to the top level
|
|
36
38
|
if (response) {
|
|
37
39
|
this.status = response.status;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/local-dev-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-experimental.0",
|
|
4
4
|
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"./http": "./http/index.js",
|
|
51
51
|
"./http/*": "./http/*.js",
|
|
52
52
|
"./config/getAccountIdentifier": "./config/getAccountIdentifier.js",
|
|
53
|
+
"./config/migrate": "./config/migrate.js",
|
|
53
54
|
"./config": "./config/index.js",
|
|
54
55
|
"./constants/*": "./constants/*.js",
|
|
55
56
|
"./models/*": "./models/*.js",
|
package/types/Migration.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export declare const MIGRATION_STATUS: {
|
|
|
6
6
|
readonly PREPARING: "PREPARING";
|
|
7
7
|
readonly PENDING: "PENDING";
|
|
8
8
|
readonly SUCCESS: "SUCCESS";
|
|
9
|
+
readonly IN_PROGRESS: "IN_PROGRESS";
|
|
10
|
+
readonly INPUT_REQUIRED: "INPUT_REQUIRED";
|
|
9
11
|
};
|
|
10
12
|
export type MigrateAppResponse = {
|
|
11
13
|
id: number;
|
|
@@ -25,4 +27,31 @@ export type PollAppResponse = {
|
|
|
25
27
|
};
|
|
26
28
|
error: ProjectStandardError | null;
|
|
27
29
|
status: ValueOf<typeof MIGRATION_STATUS>;
|
|
30
|
+
componentsRequiringUids?: Record<string, {
|
|
31
|
+
componentType: string;
|
|
32
|
+
componentHint: string | null;
|
|
33
|
+
}>;
|
|
28
34
|
};
|
|
35
|
+
export interface MigrationBaseStatus {
|
|
36
|
+
id: number;
|
|
37
|
+
}
|
|
38
|
+
export interface MigrationInProgress extends MigrationBaseStatus {
|
|
39
|
+
status: typeof MIGRATION_STATUS.IN_PROGRESS;
|
|
40
|
+
}
|
|
41
|
+
export interface MigrationInputRequired extends MigrationBaseStatus {
|
|
42
|
+
status: typeof MIGRATION_STATUS.INPUT_REQUIRED;
|
|
43
|
+
componentsRequiringUids: Record<string, {
|
|
44
|
+
componentType: string;
|
|
45
|
+
componentHint: string;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export interface MigrationSuccess extends MigrationBaseStatus {
|
|
49
|
+
status: typeof MIGRATION_STATUS.SUCCESS;
|
|
50
|
+
buildId: number;
|
|
51
|
+
}
|
|
52
|
+
export interface MigrationFailed extends MigrationBaseStatus {
|
|
53
|
+
status: typeof MIGRATION_STATUS.FAILURE;
|
|
54
|
+
projectErrorsDetail?: string;
|
|
55
|
+
componentErrorDetails: Record<string, string>;
|
|
56
|
+
}
|
|
57
|
+
export type MigrationStatus = MigrationInProgress | MigrationInputRequired | MigrationSuccess | MigrationFailed;
|
package/types/Migration.js
CHANGED
package/types/Project.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Build } from './Build';
|
|
2
2
|
import { GithubSourceData } from './Github';
|
|
3
3
|
import { ProjectLog } from './ProjectLog';
|
|
4
|
+
import { UNMIGRATABLE_REASONS } from '../constants/projects';
|
|
4
5
|
export type Project = {
|
|
5
6
|
createdAt: number;
|
|
6
7
|
deletedAt: number;
|
|
@@ -66,3 +67,34 @@ export type ProjectStandardError = {
|
|
|
66
67
|
export type WarnLogsResponse = {
|
|
67
68
|
logs: Array<ProjectLog>;
|
|
68
69
|
};
|
|
70
|
+
interface BaseMigrationApp {
|
|
71
|
+
appId: number;
|
|
72
|
+
appName: string;
|
|
73
|
+
isMigratable: boolean;
|
|
74
|
+
migrationComponents: ListAppsMigrationComponent[];
|
|
75
|
+
projectName?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface MigratableApp extends BaseMigrationApp {
|
|
78
|
+
isMigratable: true;
|
|
79
|
+
}
|
|
80
|
+
export interface UnmigratableApp extends BaseMigrationApp {
|
|
81
|
+
isMigratable: false;
|
|
82
|
+
unmigratableReason: keyof typeof UNMIGRATABLE_REASONS;
|
|
83
|
+
}
|
|
84
|
+
export type MigrationApp = MigratableApp | UnmigratableApp;
|
|
85
|
+
export interface ListAppsResponse {
|
|
86
|
+
migratableApps: MigratableApp[];
|
|
87
|
+
unmigratableApps: UnmigratableApp[];
|
|
88
|
+
}
|
|
89
|
+
export interface InitializeMigrationResponse {
|
|
90
|
+
migrationId: number;
|
|
91
|
+
}
|
|
92
|
+
export interface ListAppsMigrationComponent {
|
|
93
|
+
id: string;
|
|
94
|
+
componentType: string;
|
|
95
|
+
isSupported: boolean;
|
|
96
|
+
}
|
|
97
|
+
export type ContinueMigrationResponse = {
|
|
98
|
+
migrationId: number;
|
|
99
|
+
};
|
|
100
|
+
export {};
|