@hubspot/local-dev-lib 0.4.0-experimental.1 → 0.4.1-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/appsDev.d.ts +1 -0
- package/api/appsDev.js +13 -1
- package/api/developerTestAccounts.d.ts +7 -8
- package/api/developerTestAccounts.js +38 -5
- package/api/projects.d.ts +1 -1
- package/api/projects.js +3 -1
- package/api/sandboxHubs.d.ts +3 -1
- package/api/sandboxHubs.js +18 -1
- package/config/CLIConfiguration.d.ts +4 -0
- package/config/CLIConfiguration.js +34 -0
- package/config/config_DEPRECATED.d.ts +7 -1
- package/config/config_DEPRECATED.js +39 -4
- package/config/index.d.ts +5 -1
- package/config/index.js +38 -4
- package/config/migrate.js +6 -0
- package/errors/index.d.ts +1 -0
- package/errors/index.js +10 -1
- package/lang/en.json +6 -0
- package/lib/archive.d.ts +1 -1
- package/lib/archive.js +63 -6
- package/lib/github.js +14 -1
- package/package.json +1 -1
- package/types/Archive.d.ts +7 -1
- package/types/Config.d.ts +4 -0
- package/types/Deploy.d.ts +17 -1
- package/types/Github.d.ts +3 -1
- package/types/Sandbox.d.ts +33 -0
- package/types/Sandbox.js +10 -0
- package/types/developerTestAccounts.d.ts +29 -0
package/api/appsDev.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export declare function fetchPublicAppsForPortal(accountId: number): HubSpotProm
|
|
|
4
4
|
export declare function fetchPublicAppDeveloperTestAccountInstallData(appId: number, accountId: number): HubSpotPromise<PublicAppDeveloperTestAccountInstallData>;
|
|
5
5
|
export declare function fetchPublicAppProductionInstallCounts(appId: number, accountId: number): HubSpotPromise<PublicAppInstallCounts>;
|
|
6
6
|
export declare function fetchPublicAppMetadata(appId: number, accountId: number): HubSpotPromise<PublicApp>;
|
|
7
|
+
export declare function installStaticAuthAppOnTestAccount(appId: number, accountId: number, scopeGroupIds: number[]): HubSpotPromise<void>;
|
package/api/appsDev.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchPublicAppMetadata = exports.fetchPublicAppProductionInstallCounts = exports.fetchPublicAppDeveloperTestAccountInstallData = exports.fetchPublicAppsForPortal = void 0;
|
|
3
|
+
exports.installStaticAuthAppOnTestAccount = exports.fetchPublicAppMetadata = exports.fetchPublicAppProductionInstallCounts = exports.fetchPublicAppDeveloperTestAccountInstallData = exports.fetchPublicAppsForPortal = void 0;
|
|
4
4
|
const http_1 = require("../http");
|
|
5
5
|
const APPS_DEV_API_PATH = 'apps-dev/external/public/v3';
|
|
6
|
+
const APPS_HUBLETS_API_PATH = 'apps-hublets/external/static-token/v3';
|
|
6
7
|
function fetchPublicAppsForPortal(accountId) {
|
|
7
8
|
return http_1.http.get(accountId, {
|
|
8
9
|
url: `${APPS_DEV_API_PATH}/full/portal`,
|
|
@@ -27,3 +28,14 @@ function fetchPublicAppMetadata(appId, accountId) {
|
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
exports.fetchPublicAppMetadata = fetchPublicAppMetadata;
|
|
31
|
+
function installStaticAuthAppOnTestAccount(appId, accountId, scopeGroupIds) {
|
|
32
|
+
return http_1.http.post(accountId, {
|
|
33
|
+
url: APPS_HUBLETS_API_PATH,
|
|
34
|
+
data: {
|
|
35
|
+
appId,
|
|
36
|
+
targetInstallPortalId: accountId,
|
|
37
|
+
scopeGroupIds,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.installStaticAuthAppOnTestAccount = installStaticAuthAppOnTestAccount;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { DeveloperTestAccount, CreateDeveloperTestAccountResponse, FetchDeveloperTestAccountsResponse } from '../types/developerTestAccounts';
|
|
1
|
+
import { DeveloperTestAccount, CreateDeveloperTestAccountResponse, FetchDeveloperTestAccountsResponse, DeveloperTestAccountConfig, CreateDeveloperTestAccountV3Response, InstallOauthAppIntoDeveloperTestAccountResponse, TestPortalStatusResponse, GenerateDeveloperTestAccountPersonalAccessKeyResponse } from '../types/developerTestAccounts';
|
|
2
2
|
import { Environment } from '../types/Config';
|
|
3
3
|
import { HubSpotPromise } from '../types/Http';
|
|
4
4
|
export declare function fetchDeveloperTestAccounts(accountId: number): HubSpotPromise<FetchDeveloperTestAccountsResponse>;
|
|
5
|
-
export declare function createDeveloperTestAccount(accountId: number,
|
|
6
|
-
|
|
7
|
-
opsLevel?: string;
|
|
8
|
-
serviceLevel?: string;
|
|
9
|
-
salesLevel?: string;
|
|
10
|
-
contentLevel?: string;
|
|
11
|
-
}): HubSpotPromise<CreateDeveloperTestAccountResponse>;
|
|
5
|
+
export declare function createDeveloperTestAccount(accountId: number, accountInfo: string): HubSpotPromise<CreateDeveloperTestAccountResponse>;
|
|
6
|
+
export declare function createDeveloperTestAccount(accountId: number, accountInfo: DeveloperTestAccountConfig): HubSpotPromise<CreateDeveloperTestAccountV3Response>;
|
|
12
7
|
export declare function deleteDeveloperTestAccount(accountId: number, testAccountId: number, useV3?: boolean): HubSpotPromise<void>;
|
|
13
8
|
export declare function fetchDeveloperTestAccountData(accessToken: string, accountId: number, env?: Environment): HubSpotPromise<DeveloperTestAccount>;
|
|
9
|
+
export declare function installOauthAppIntoDeveloperTestAccount(accountId: number, testAccountId: number, projectName: string, appUId: string): HubSpotPromise<InstallOauthAppIntoDeveloperTestAccountResponse>;
|
|
10
|
+
export declare function fetchDeveloperTestAccountOauthAppInstallStatus(accountId: number, projectName: string, appUId: string): HubSpotPromise<TestPortalStatusResponse>;
|
|
11
|
+
export declare function fetchDeveloperTestAccountGateSyncStatus(accountId: number, testAccountId: number): HubSpotPromise<TestPortalStatusResponse>;
|
|
12
|
+
export declare function generateDeveloperTestAccountPersonalAccessKey(accountId: number, testAccountId: number): HubSpotPromise<GenerateDeveloperTestAccountPersonalAccessKeyResponse>;
|
|
@@ -3,7 +3,7 @@ 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.fetchDeveloperTestAccountData = exports.deleteDeveloperTestAccount = exports.createDeveloperTestAccount = exports.fetchDeveloperTestAccounts = void 0;
|
|
6
|
+
exports.generateDeveloperTestAccountPersonalAccessKey = exports.fetchDeveloperTestAccountGateSyncStatus = exports.fetchDeveloperTestAccountOauthAppInstallStatus = exports.installOauthAppIntoDeveloperTestAccount = exports.fetchDeveloperTestAccountData = exports.deleteDeveloperTestAccount = exports.createDeveloperTestAccount = exports.fetchDeveloperTestAccounts = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const http_1 = require("../http");
|
|
9
9
|
const getAxiosConfig_1 = require("../http/getAxiosConfig");
|
|
@@ -17,17 +17,17 @@ function fetchDeveloperTestAccounts(accountId) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
exports.fetchDeveloperTestAccounts = fetchDeveloperTestAccounts;
|
|
20
|
-
function createDeveloperTestAccount(accountId,
|
|
21
|
-
if (
|
|
20
|
+
function createDeveloperTestAccount(accountId, accountInfo) {
|
|
21
|
+
if (typeof accountInfo === 'object') {
|
|
22
22
|
return http_1.http.post(accountId, {
|
|
23
23
|
url: TEST_ACCOUNTS_API_PATH_V3,
|
|
24
|
-
data:
|
|
24
|
+
data: accountInfo,
|
|
25
25
|
timeout: api_1.SANDBOX_TIMEOUT,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
return http_1.http.post(accountId, {
|
|
29
29
|
url: TEST_ACCOUNTS_API_PATH,
|
|
30
|
-
data: { accountName, generatePersonalAccessKey: true },
|
|
30
|
+
data: { accountName: accountInfo, generatePersonalAccessKey: true },
|
|
31
31
|
timeout: api_1.SANDBOX_TIMEOUT,
|
|
32
32
|
});
|
|
33
33
|
}
|
|
@@ -59,3 +59,36 @@ function fetchDeveloperTestAccountData(accessToken, accountId, env = environment
|
|
|
59
59
|
return (0, axios_1.default)(reqWithToken);
|
|
60
60
|
}
|
|
61
61
|
exports.fetchDeveloperTestAccountData = fetchDeveloperTestAccountData;
|
|
62
|
+
function installOauthAppIntoDeveloperTestAccount(accountId, testAccountId, projectName, appUId) {
|
|
63
|
+
return http_1.http.post(accountId, {
|
|
64
|
+
url: `${TEST_ACCOUNTS_API_PATH_V3}/install-apps`,
|
|
65
|
+
data: {
|
|
66
|
+
testPortalId: testAccountId,
|
|
67
|
+
developerQualifiedSymbol: { developerSymbol: appUId, projectName },
|
|
68
|
+
},
|
|
69
|
+
timeout: api_1.SANDBOX_TIMEOUT,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
exports.installOauthAppIntoDeveloperTestAccount = installOauthAppIntoDeveloperTestAccount;
|
|
73
|
+
function fetchDeveloperTestAccountOauthAppInstallStatus(accountId, projectName, appUId) {
|
|
74
|
+
return http_1.http.post(accountId, {
|
|
75
|
+
url: `${TEST_ACCOUNTS_API_PATH_V3}/install-apps/readiness`,
|
|
76
|
+
data: {
|
|
77
|
+
developerQualifiedSymbol: { developerSymbol: appUId, projectName },
|
|
78
|
+
},
|
|
79
|
+
timeout: api_1.SANDBOX_TIMEOUT,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
exports.fetchDeveloperTestAccountOauthAppInstallStatus = fetchDeveloperTestAccountOauthAppInstallStatus;
|
|
83
|
+
function fetchDeveloperTestAccountGateSyncStatus(accountId, testAccountId) {
|
|
84
|
+
return http_1.http.get(accountId, {
|
|
85
|
+
url: `${TEST_ACCOUNTS_API_PATH_V3}/gate-sync-status/${testAccountId}`,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exports.fetchDeveloperTestAccountGateSyncStatus = fetchDeveloperTestAccountGateSyncStatus;
|
|
89
|
+
function generateDeveloperTestAccountPersonalAccessKey(accountId, testAccountId) {
|
|
90
|
+
return http_1.http.get(accountId, {
|
|
91
|
+
url: `${TEST_ACCOUNTS_API_PATH_V3}/generate-pak/${testAccountId}`,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
exports.generateDeveloperTestAccountPersonalAccessKey = generateDeveloperTestAccountPersonalAccessKey;
|
package/api/projects.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare function fetchPlatformVersions(accountId: number): HubSpotPromise
|
|
|
17
17
|
export declare function fetchProjectBuilds(accountId: number, projectName: string, params?: QueryParams): HubSpotPromise<FetchProjectBuildsResponse>;
|
|
18
18
|
export declare function getBuildStatus(accountId: number, projectName: string, buildId: number): HubSpotPromise<Build>;
|
|
19
19
|
export declare function getBuildStructure(accountId: number, projectName: string, buildId: number): HubSpotPromise<ComponentStructureResponse>;
|
|
20
|
-
export declare function deployProject(accountId: number, projectName: string, buildId: number, useNewDeployApi?: boolean): HubSpotPromise<ProjectDeployResponse>;
|
|
20
|
+
export declare function deployProject(accountId: number, projectName: string, buildId: number, useNewDeployApi?: boolean, force?: boolean): HubSpotPromise<ProjectDeployResponse>;
|
|
21
21
|
export declare function getDeployStatus(accountId: number, projectName: string, deployId: number): HubSpotPromise<Deploy>;
|
|
22
22
|
export declare function getDeployStructure(accountId: number, projectName: string, deployId: number): HubSpotPromise<ComponentStructureResponse>;
|
|
23
23
|
export declare function fetchProjectSettings(accountId: number, projectName: string): HubSpotPromise<ProjectSettings>;
|
package/api/projects.js
CHANGED
|
@@ -116,13 +116,14 @@ function getBuildStructure(accountId, projectName, buildId) {
|
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
exports.getBuildStructure = getBuildStructure;
|
|
119
|
-
function deployProject(accountId, projectName, buildId, useNewDeployApi = false) {
|
|
119
|
+
function deployProject(accountId, projectName, buildId, useNewDeployApi = false, force = false) {
|
|
120
120
|
if (useNewDeployApi) {
|
|
121
121
|
return http_1.http.post(accountId, {
|
|
122
122
|
url: `${PROJECTS_DEPLOY_API_PATH_V3}/deploys/queue/async`,
|
|
123
123
|
data: {
|
|
124
124
|
projectName,
|
|
125
125
|
targetBuildId: buildId,
|
|
126
|
+
ignoreWarnings: force,
|
|
126
127
|
},
|
|
127
128
|
});
|
|
128
129
|
}
|
|
@@ -131,6 +132,7 @@ function deployProject(accountId, projectName, buildId, useNewDeployApi = false)
|
|
|
131
132
|
data: {
|
|
132
133
|
projectName,
|
|
133
134
|
buildId,
|
|
135
|
+
skipRemovalWarning: force,
|
|
134
136
|
},
|
|
135
137
|
});
|
|
136
138
|
}
|
package/api/sandboxHubs.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AxiosPromise } from 'axios';
|
|
2
2
|
import { Environment } from '../types/Config';
|
|
3
|
-
import { SandboxHubData, SandboxResponse, SandboxUsageLimitsResponse } from '../types/Sandbox';
|
|
3
|
+
import { SandboxPersonalAccessKey, SandboxHubData, SandboxResponse, SandboxUsageLimitsResponse, V2Sandbox } from '../types/Sandbox';
|
|
4
4
|
import { HubSpotPromise } from '../types/Http';
|
|
5
5
|
export declare function createSandbox(accountId: number, name: string, type: 1 | 2): HubSpotPromise<SandboxResponse>;
|
|
6
6
|
export declare function deleteSandbox(parentAccountId: number, sandboxAccountId: number): HubSpotPromise<void>;
|
|
7
7
|
export declare function getSandboxUsageLimits(parentAccountId: number): HubSpotPromise<SandboxUsageLimitsResponse>;
|
|
8
8
|
export declare function fetchSandboxHubData(accessToken: string, accountId: number, env?: Environment): AxiosPromise<SandboxHubData>;
|
|
9
|
+
export declare function createV2Sandbox(accountId: number, name: string, type: 'STANDARD' | 'DEVELOPER', syncObjectRecords: boolean): HubSpotPromise<V2Sandbox>;
|
|
10
|
+
export declare function getSandboxPersonalAccessKey(accountId: number, sandboxId: number): HubSpotPromise<SandboxPersonalAccessKey>;
|
package/api/sandboxHubs.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.fetchSandboxHubData = exports.getSandboxUsageLimits = exports.deleteSandbox = exports.createSandbox = void 0;
|
|
6
|
+
exports.getSandboxPersonalAccessKey = exports.createV2Sandbox = exports.fetchSandboxHubData = exports.getSandboxUsageLimits = exports.deleteSandbox = exports.createSandbox = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const http_1 = require("../http");
|
|
9
9
|
const getAxiosConfig_1 = require("../http/getAxiosConfig");
|
|
@@ -47,3 +47,20 @@ function fetchSandboxHubData(accessToken, accountId, env = environments_1.ENVIRO
|
|
|
47
47
|
return (0, axios_1.default)(reqWithToken);
|
|
48
48
|
}
|
|
49
49
|
exports.fetchSandboxHubData = fetchSandboxHubData;
|
|
50
|
+
function createV2Sandbox(accountId, name, type, syncObjectRecords) {
|
|
51
|
+
return http_1.http.post(accountId, {
|
|
52
|
+
url: `${SANDBOX_API_PATH_V2}/sandboxes`,
|
|
53
|
+
data: { name, type, syncObjectRecords },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.createV2Sandbox = createV2Sandbox;
|
|
57
|
+
function getSandboxPersonalAccessKey(accountId, sandboxId) {
|
|
58
|
+
return http_1.http.post(accountId, {
|
|
59
|
+
url: `${SANDBOX_API_PATH_V2}/sandboxes/${sandboxId}/personal-access-key`,
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
},
|
|
63
|
+
timeout: api_1.SANDBOX_TIMEOUT,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.getSandboxPersonalAccessKey = getSandboxPersonalAccessKey;
|
|
@@ -61,8 +61,12 @@ declare class _CLIConfiguration {
|
|
|
61
61
|
* @throws {Error}
|
|
62
62
|
*/
|
|
63
63
|
updateAllowUsageTracking(isEnabled: boolean): CLIConfig_NEW | null;
|
|
64
|
+
updateAutoOpenBrowser(isEnabled: boolean): CLIConfig_NEW | null;
|
|
64
65
|
isTrackingAllowed(): boolean;
|
|
65
66
|
handleLegacyCmsPublishMode(config: CLIConfig_NEW | null): CLIConfig_NEW | null;
|
|
67
|
+
hasLocalStateFlag(flag: string): boolean;
|
|
68
|
+
addLocalStateFlag(flag: string): void;
|
|
69
|
+
removeLocalStateFlag(flag: string): void;
|
|
66
70
|
}
|
|
67
71
|
export declare const CLIConfiguration: _CLIConfiguration;
|
|
68
72
|
export {};
|
|
@@ -497,6 +497,18 @@ class _CLIConfiguration {
|
|
|
497
497
|
this.config.allowUsageTracking = isEnabled;
|
|
498
498
|
return this.write();
|
|
499
499
|
}
|
|
500
|
+
updateAutoOpenBrowser(isEnabled) {
|
|
501
|
+
if (!this.config) {
|
|
502
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
|
|
503
|
+
}
|
|
504
|
+
if (typeof isEnabled !== 'boolean') {
|
|
505
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.updateAutoOpenBrowser.errors.invalidInput`, {
|
|
506
|
+
isEnabled: `${isEnabled}`,
|
|
507
|
+
}));
|
|
508
|
+
}
|
|
509
|
+
this.config.autoOpenBrowser = isEnabled;
|
|
510
|
+
return this.write();
|
|
511
|
+
}
|
|
500
512
|
isTrackingAllowed() {
|
|
501
513
|
if (!this.config) {
|
|
502
514
|
return true;
|
|
@@ -510,5 +522,27 @@ class _CLIConfiguration {
|
|
|
510
522
|
}
|
|
511
523
|
return config;
|
|
512
524
|
}
|
|
525
|
+
hasLocalStateFlag(flag) {
|
|
526
|
+
if (!this.config) {
|
|
527
|
+
return false;
|
|
528
|
+
}
|
|
529
|
+
return this.config.flags?.includes(flag) || false;
|
|
530
|
+
}
|
|
531
|
+
addLocalStateFlag(flag) {
|
|
532
|
+
if (!this.config) {
|
|
533
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
|
|
534
|
+
}
|
|
535
|
+
if (!this.hasLocalStateFlag(flag)) {
|
|
536
|
+
this.config.flags = [...(this.config.flags || []), flag];
|
|
537
|
+
}
|
|
538
|
+
this.write();
|
|
539
|
+
}
|
|
540
|
+
removeLocalStateFlag(flag) {
|
|
541
|
+
if (!this.config) {
|
|
542
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
|
|
543
|
+
}
|
|
544
|
+
this.config.flags = this.config.flags?.filter(f => f !== flag) || [];
|
|
545
|
+
this.write();
|
|
546
|
+
}
|
|
513
547
|
}
|
|
514
548
|
exports.CLIConfiguration = new _CLIConfiguration();
|
|
@@ -18,6 +18,8 @@ export declare function getOrderedConfig(unorderedConfig: CLIConfig_DEPRECATED):
|
|
|
18
18
|
defaultMode?: CmsPublishMode | undefined;
|
|
19
19
|
env?: Environment | undefined;
|
|
20
20
|
httpUseLocalhost?: boolean | undefined;
|
|
21
|
+
autoOpenBrowser?: boolean | undefined;
|
|
22
|
+
flags?: string[] | undefined;
|
|
21
23
|
defaultCmsPublishMode: CmsPublishMode | undefined;
|
|
22
24
|
httpTimeout: number | undefined;
|
|
23
25
|
allowUsageTracking: boolean | undefined;
|
|
@@ -60,6 +62,7 @@ export declare function updateAllowAutoUpdates(enabled: boolean): void;
|
|
|
60
62
|
* @throws {Error}
|
|
61
63
|
*/
|
|
62
64
|
export declare function updateAllowUsageTracking(isEnabled: boolean): void;
|
|
65
|
+
export declare function updateAutoOpenBrowser(isEnabled: boolean): void;
|
|
63
66
|
/**
|
|
64
67
|
* @throws {Error}
|
|
65
68
|
*/
|
|
@@ -78,4 +81,7 @@ export declare function loadConfigFromEnvironment({ useEnv, }?: {
|
|
|
78
81
|
}): {
|
|
79
82
|
portals: Array<CLIAccount_DEPRECATED>;
|
|
80
83
|
} | undefined;
|
|
81
|
-
export declare function isConfigFlagEnabled(flag: keyof CLIConfig_DEPRECATED): boolean;
|
|
84
|
+
export declare function isConfigFlagEnabled(flag: keyof CLIConfig_DEPRECATED, defaultValue?: boolean): boolean;
|
|
85
|
+
export declare function hasLocalStateFlag(flag: string): boolean;
|
|
86
|
+
export declare function addLocalStateFlag(flag: string): void;
|
|
87
|
+
export declare function removeLocalStateFlag(flag: string): void;
|
|
@@ -3,7 +3,7 @@ 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.isConfigFlagEnabled = exports.loadConfigFromEnvironment = exports.deleteConfigFile = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.deleteAccount = exports.renameAccount = exports.updateAllowUsageTracking = exports.updateAllowAutoUpdates = exports.updateHttpTimeout = exports.updateDefaultCmsPublishMode = exports.updateDefaultAccount = exports.updateAccountConfig = exports.removeSandboxAccountFromConfig = exports.getAccountId = exports.getAccountConfig = exports.getAccountType = exports.getEnv = exports.findConfig = exports.getAndLoadConfigIfNeeded = exports.isTrackingAllowed = exports.loadConfig = exports.writeConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.accountNameExistsInConfig = exports.validateConfig = exports.getConfigPath = exports.setConfigPath = exports.getConfigAccountId = exports.getConfigDefaultAccount = exports.getConfigAccounts = exports.setConfig = exports.getConfig = void 0;
|
|
6
|
+
exports.removeLocalStateFlag = exports.addLocalStateFlag = exports.hasLocalStateFlag = exports.isConfigFlagEnabled = exports.loadConfigFromEnvironment = exports.deleteConfigFile = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.deleteAccount = exports.renameAccount = exports.updateAutoOpenBrowser = exports.updateAllowUsageTracking = exports.updateAllowAutoUpdates = exports.updateHttpTimeout = exports.updateDefaultCmsPublishMode = exports.updateDefaultAccount = exports.updateAccountConfig = exports.removeSandboxAccountFromConfig = exports.getAccountId = exports.getAccountConfig = exports.getAccountType = exports.getEnv = exports.findConfig = exports.getAndLoadConfigIfNeeded = exports.isTrackingAllowed = exports.loadConfig = exports.writeConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.accountNameExistsInConfig = exports.validateConfig = exports.getConfigPath = exports.setConfigPath = exports.getConfigAccountId = exports.getConfigDefaultAccount = exports.getConfigAccounts = exports.setConfig = exports.getConfig = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
9
9
|
const findup_sync_1 = __importDefault(require("findup-sync"));
|
|
@@ -517,6 +517,16 @@ function updateAllowUsageTracking(isEnabled) {
|
|
|
517
517
|
writeConfig();
|
|
518
518
|
}
|
|
519
519
|
exports.updateAllowUsageTracking = updateAllowUsageTracking;
|
|
520
|
+
function updateAutoOpenBrowser(isEnabled) {
|
|
521
|
+
if (typeof isEnabled !== 'boolean') {
|
|
522
|
+
throw new Error(`Unable to update autoOpenBrowser. The value ${isEnabled} is invalid. The value must be a boolean.`);
|
|
523
|
+
}
|
|
524
|
+
const config = getAndLoadConfigIfNeeded();
|
|
525
|
+
config.autoOpenBrowser = isEnabled;
|
|
526
|
+
setDefaultConfigPathIfUnset();
|
|
527
|
+
writeConfig();
|
|
528
|
+
}
|
|
529
|
+
exports.updateAutoOpenBrowser = updateAutoOpenBrowser;
|
|
520
530
|
/**
|
|
521
531
|
* @throws {Error}
|
|
522
532
|
*/
|
|
@@ -688,12 +698,12 @@ function loadEnvironmentVariableConfig(options) {
|
|
|
688
698
|
logger_1.logger.debug(`Loaded config from environment variables for account ${portalId}`);
|
|
689
699
|
return setConfig(handleLegacyCmsPublishMode(envConfig));
|
|
690
700
|
}
|
|
691
|
-
function isConfigFlagEnabled(flag) {
|
|
701
|
+
function isConfigFlagEnabled(flag, defaultValue = false) {
|
|
692
702
|
if (!configFileExists() || configFileIsBlank()) {
|
|
693
|
-
return
|
|
703
|
+
return defaultValue;
|
|
694
704
|
}
|
|
695
705
|
const config = getAndLoadConfigIfNeeded();
|
|
696
|
-
return Boolean(config[flag] ||
|
|
706
|
+
return Boolean(config[flag] || defaultValue);
|
|
697
707
|
}
|
|
698
708
|
exports.isConfigFlagEnabled = isConfigFlagEnabled;
|
|
699
709
|
function handleLegacyCmsPublishMode(config) {
|
|
@@ -703,3 +713,28 @@ function handleLegacyCmsPublishMode(config) {
|
|
|
703
713
|
}
|
|
704
714
|
return config;
|
|
705
715
|
}
|
|
716
|
+
function hasLocalStateFlag(flag) {
|
|
717
|
+
if (!_config) {
|
|
718
|
+
return false;
|
|
719
|
+
}
|
|
720
|
+
return _config.flags?.includes(flag) || false;
|
|
721
|
+
}
|
|
722
|
+
exports.hasLocalStateFlag = hasLocalStateFlag;
|
|
723
|
+
function addLocalStateFlag(flag) {
|
|
724
|
+
if (!_config) {
|
|
725
|
+
throw new Error('No config loaded');
|
|
726
|
+
}
|
|
727
|
+
if (!hasLocalStateFlag(flag)) {
|
|
728
|
+
_config.flags = [...(_config.flags || []), flag];
|
|
729
|
+
}
|
|
730
|
+
writeConfig();
|
|
731
|
+
}
|
|
732
|
+
exports.addLocalStateFlag = addLocalStateFlag;
|
|
733
|
+
function removeLocalStateFlag(flag) {
|
|
734
|
+
if (!_config) {
|
|
735
|
+
throw new Error('No config loaded');
|
|
736
|
+
}
|
|
737
|
+
_config.flags = _config.flags?.filter(f => f !== flag) || [];
|
|
738
|
+
writeConfig();
|
|
739
|
+
}
|
|
740
|
+
exports.removeLocalStateFlag = removeLocalStateFlag;
|
package/config/index.d.ts
CHANGED
|
@@ -26,8 +26,9 @@ export declare function deleteAccount(accountName: string): Promise<void | boole
|
|
|
26
26
|
export declare function updateHttpTimeout(timeout: string): void;
|
|
27
27
|
export declare function updateAllowAutoUpdates(enabled: boolean): void;
|
|
28
28
|
export declare function updateAllowUsageTracking(isEnabled: boolean): void;
|
|
29
|
+
export declare function updateAutoOpenBrowser(isEnabled: boolean): void;
|
|
29
30
|
export declare function deleteConfigFile(): void;
|
|
30
|
-
export declare function isConfigFlagEnabled(flag: keyof CLIConfig): boolean;
|
|
31
|
+
export declare function isConfigFlagEnabled(flag: keyof CLIConfig, defaultValue?: boolean): boolean;
|
|
31
32
|
export declare function isTrackingAllowed(): boolean;
|
|
32
33
|
export declare function getEnv(nameOrId?: string | number): import("../types/Config").Environment;
|
|
33
34
|
export declare function getAccountType(accountType?: AccountType, sandboxAccountType?: string | null): AccountType;
|
|
@@ -37,6 +38,9 @@ export declare function getConfigAccounts(): Array<CLIAccount_NEW> | Array<CLIAc
|
|
|
37
38
|
export declare function updateDefaultCmsPublishMode(cmsPublishMode: CmsPublishMode): void | CLIConfig_NEW | null;
|
|
38
39
|
export declare function getCWDAccountOverride(): string | number | null | undefined;
|
|
39
40
|
export declare function getDefaultAccountOverrideFilePath(): string | null | undefined;
|
|
41
|
+
export declare function hasLocalStateFlag(flag: string): boolean;
|
|
42
|
+
export declare function addLocalStateFlag(flag: string): void;
|
|
43
|
+
export declare function removeLocalStateFlag(flag: string): void;
|
|
40
44
|
export declare const getConfigAccountId: typeof config_DEPRECATED.getConfigAccountId;
|
|
41
45
|
export declare const getOrderedAccount: typeof config_DEPRECATED.getOrderedAccount;
|
|
42
46
|
export declare const getOrderedConfig: typeof config_DEPRECATED.getOrderedConfig;
|
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.getDisplayDefaultAccount = exports.getConfigDefaultAccount = exports.getAccountType = exports.getEnv = exports.isTrackingAllowed = exports.isConfigFlagEnabled = exports.deleteConfigFile = exports.updateAllowUsageTracking = exports.updateAllowAutoUpdates = 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.removeLocalStateFlag = exports.addLocalStateFlag = exports.hasLocalStateFlag = exports.getDefaultAccountOverrideFilePath = exports.getCWDAccountOverride = exports.updateDefaultCmsPublishMode = exports.getConfigAccounts = exports.getDisplayDefaultAccount = exports.getConfigDefaultAccount = exports.getAccountType = exports.getEnv = exports.isTrackingAllowed = exports.isConfigFlagEnabled = exports.deleteConfigFile = exports.updateAutoOpenBrowser = exports.updateAllowUsageTracking = exports.updateAllowAutoUpdates = 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");
|
|
@@ -202,6 +202,15 @@ function updateAllowUsageTracking(isEnabled) {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
exports.updateAllowUsageTracking = updateAllowUsageTracking;
|
|
205
|
+
function updateAutoOpenBrowser(isEnabled) {
|
|
206
|
+
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
207
|
+
CLIConfiguration_1.CLIConfiguration.updateAutoOpenBrowser(isEnabled);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
config_DEPRECATED.updateAutoOpenBrowser(isEnabled);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.updateAutoOpenBrowser = updateAutoOpenBrowser;
|
|
205
214
|
function deleteConfigFile() {
|
|
206
215
|
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
207
216
|
(0, configFile_1.deleteConfigFile)();
|
|
@@ -211,11 +220,11 @@ function deleteConfigFile() {
|
|
|
211
220
|
}
|
|
212
221
|
}
|
|
213
222
|
exports.deleteConfigFile = deleteConfigFile;
|
|
214
|
-
function isConfigFlagEnabled(flag) {
|
|
223
|
+
function isConfigFlagEnabled(flag, defaultValue = false) {
|
|
215
224
|
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
216
|
-
return CLIConfiguration_1.CLIConfiguration.isConfigFlagEnabled(flag);
|
|
225
|
+
return CLIConfiguration_1.CLIConfiguration.isConfigFlagEnabled(flag, defaultValue);
|
|
217
226
|
}
|
|
218
|
-
return config_DEPRECATED.isConfigFlagEnabled(flag);
|
|
227
|
+
return config_DEPRECATED.isConfigFlagEnabled(flag, defaultValue);
|
|
219
228
|
}
|
|
220
229
|
exports.isConfigFlagEnabled = isConfigFlagEnabled;
|
|
221
230
|
function isTrackingAllowed() {
|
|
@@ -279,6 +288,31 @@ function getDefaultAccountOverrideFilePath() {
|
|
|
279
288
|
}
|
|
280
289
|
}
|
|
281
290
|
exports.getDefaultAccountOverrideFilePath = getDefaultAccountOverrideFilePath;
|
|
291
|
+
function hasLocalStateFlag(flag) {
|
|
292
|
+
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
293
|
+
return CLIConfiguration_1.CLIConfiguration.hasLocalStateFlag(flag);
|
|
294
|
+
}
|
|
295
|
+
return config_DEPRECATED.hasLocalStateFlag(flag);
|
|
296
|
+
}
|
|
297
|
+
exports.hasLocalStateFlag = hasLocalStateFlag;
|
|
298
|
+
function addLocalStateFlag(flag) {
|
|
299
|
+
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
300
|
+
CLIConfiguration_1.CLIConfiguration.addLocalStateFlag(flag);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
config_DEPRECATED.addLocalStateFlag(flag);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
exports.addLocalStateFlag = addLocalStateFlag;
|
|
307
|
+
function removeLocalStateFlag(flag) {
|
|
308
|
+
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
309
|
+
CLIConfiguration_1.CLIConfiguration.removeLocalStateFlag(flag);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
config_DEPRECATED.removeLocalStateFlag(flag);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
exports.removeLocalStateFlag = removeLocalStateFlag;
|
|
282
316
|
// These functions are not supported with the new config setup
|
|
283
317
|
exports.getConfigAccountId = config_DEPRECATED.getConfigAccountId;
|
|
284
318
|
exports.getOrderedAccount = config_DEPRECATED.getOrderedAccount;
|
package/config/migrate.js
CHANGED
|
@@ -124,6 +124,12 @@ function mergeConfigProperties(globalConfig, deprecatedConfig, force) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
|
+
if (globalConfig.flags || deprecatedConfig.flags) {
|
|
128
|
+
globalConfig.flags = Array.from(new Set([
|
|
129
|
+
...(globalConfig.flags || []),
|
|
130
|
+
...(deprecatedConfig.flags || []),
|
|
131
|
+
]));
|
|
132
|
+
}
|
|
127
133
|
if (config_1.DEFAULT_ACCOUNT in globalConfig &&
|
|
128
134
|
config_1.DEFAULT_PORTAL in deprecatedConfig &&
|
|
129
135
|
globalConfig.defaultAccount !== deprecatedConfig.defaultPortal) {
|
package/errors/index.d.ts
CHANGED
|
@@ -14,5 +14,6 @@ export declare function isTimeoutError(err: unknown): err is HubSpotHttpError;
|
|
|
14
14
|
export declare function isAuthError(err: unknown): err is HubSpotHttpError;
|
|
15
15
|
export declare function isValidationError(err: unknown): boolean;
|
|
16
16
|
export declare function isHubSpotHttpError(error?: unknown): error is HubSpotHttpError;
|
|
17
|
+
export declare function isGithubRateLimitError(err: unknown): boolean;
|
|
17
18
|
export declare function isSystemError(err: unknown): err is BaseError;
|
|
18
19
|
export declare function isFileSystemError(err: unknown): err is FileSystemError;
|
package/errors/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFileSystemError = exports.isSystemError = exports.isHubSpotHttpError = exports.isValidationError = exports.isAuthError = exports.isTimeoutError = exports.isGatingError = exports.isMissingScopeError = exports.isSpecifiedError = void 0;
|
|
3
|
+
exports.isFileSystemError = exports.isSystemError = exports.isGithubRateLimitError = exports.isHubSpotHttpError = exports.isValidationError = exports.isAuthError = exports.isTimeoutError = exports.isGatingError = exports.isMissingScopeError = exports.isSpecifiedError = void 0;
|
|
4
4
|
const HubSpotHttpError_1 = require("../models/HubSpotHttpError");
|
|
5
5
|
const FileSystemError_1 = require("../models/FileSystemError");
|
|
6
6
|
function isSpecifiedError(err, { statusCode, category, subCategory, errorType, code, }) {
|
|
@@ -47,6 +47,15 @@ function isHubSpotHttpError(error) {
|
|
|
47
47
|
return !!error && error instanceof HubSpotHttpError_1.HubSpotHttpError;
|
|
48
48
|
}
|
|
49
49
|
exports.isHubSpotHttpError = isHubSpotHttpError;
|
|
50
|
+
function isGithubRateLimitError(err) {
|
|
51
|
+
if (!isHubSpotHttpError(err)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return (!!err.headers &&
|
|
55
|
+
err.headers['x-ratelimit-remaining'] === '0' &&
|
|
56
|
+
'x-github-request-id' in err.headers);
|
|
57
|
+
}
|
|
58
|
+
exports.isGithubRateLimitError = isGithubRateLimitError;
|
|
50
59
|
function isSystemError(err) {
|
|
51
60
|
return (err instanceof Error &&
|
|
52
61
|
'errno' in err &&
|
package/lang/en.json
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"github": {
|
|
34
|
+
"rateLimitError": "Github rate limit hit. Set the GITHUB_TOKEN env variable with your github PATH. This will increase the github api's rate limit.",
|
|
34
35
|
"fetchFileFromRepository": {
|
|
35
36
|
"fetching": "Fetching {{ path }}...",
|
|
36
37
|
"errors": {
|
|
@@ -292,6 +293,11 @@
|
|
|
292
293
|
"errors": {
|
|
293
294
|
"invalidInput": "Unable to update allowUsageTracking. The value {{ isEnabled }} is invalid. The value must be a boolean."
|
|
294
295
|
}
|
|
296
|
+
},
|
|
297
|
+
"updateAutoOpenBrowser": {
|
|
298
|
+
"errors": {
|
|
299
|
+
"invalidInput": "Unable to update autoOpenBrowser. The value {{ isEnabled }} is invalid. The value must be a boolean."
|
|
300
|
+
}
|
|
295
301
|
}
|
|
296
302
|
},
|
|
297
303
|
"configFile": {
|
package/lib/archive.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { CopySourceToDestOptions } from '../types/Archive';
|
|
4
|
-
export declare function extractZipArchive(zip: Buffer, name: string, dest: string, { sourceDir, includesRootDir, hideLogs }?: CopySourceToDestOptions): Promise<boolean>;
|
|
4
|
+
export declare function extractZipArchive(zip: Buffer, name: string, dest: string, { sourceDir, includesRootDir, hideLogs, handleCollision, }?: CopySourceToDestOptions): Promise<boolean>;
|
package/lib/archive.js
CHANGED
|
@@ -1,16 +1,40 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.extractZipArchive = void 0;
|
|
7
30
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const path_1 = require("path");
|
|
31
|
+
const path_1 = __importStar(require("path"));
|
|
9
32
|
const os_1 = require("os");
|
|
10
33
|
const extract_zip_1 = __importDefault(require("extract-zip"));
|
|
11
34
|
const logger_1 = require("./logger");
|
|
12
35
|
const lang_1 = require("../utils/lang");
|
|
13
36
|
const FileSystemError_1 = require("../models/FileSystemError");
|
|
37
|
+
const fs_1 = require("./fs");
|
|
14
38
|
const i18nKey = 'lib.archive';
|
|
15
39
|
async function extractZip(name, zip, hideLogs = false) {
|
|
16
40
|
const result = { extractDir: '', tmpDir: '' };
|
|
@@ -55,7 +79,7 @@ async function extractZip(name, zip, hideLogs = false) {
|
|
|
55
79
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.extractZip.success`));
|
|
56
80
|
return result;
|
|
57
81
|
}
|
|
58
|
-
async function copySourceToDest(src, dest, { sourceDir, includesRootDir = true, hideLogs = false, } = {}) {
|
|
82
|
+
async function copySourceToDest(src, dest, { sourceDir, includesRootDir = true, hideLogs = false, handleCollision, } = {}) {
|
|
59
83
|
try {
|
|
60
84
|
if (!hideLogs) {
|
|
61
85
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.copySourceToDest.init`));
|
|
@@ -73,11 +97,43 @@ async function copySourceToDest(src, dest, { sourceDir, includesRootDir = true,
|
|
|
73
97
|
}
|
|
74
98
|
srcDirPath.push(rootDir);
|
|
75
99
|
}
|
|
100
|
+
const sourceDirs = [];
|
|
76
101
|
if (sourceDir) {
|
|
77
|
-
|
|
102
|
+
sourceDirs.push(...(Array.isArray(sourceDir) ? new Set(sourceDir) : [sourceDir]));
|
|
103
|
+
}
|
|
104
|
+
if (sourceDirs.length === 0) {
|
|
105
|
+
const projectSrcDir = (0, path_1.join)(...srcDirPath);
|
|
106
|
+
await fs_extra_1.default.copy(projectSrcDir, dest);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
for (let i = 0; i < sourceDirs.length; i++) {
|
|
110
|
+
const projectSrcDir = (0, path_1.join)(...srcDirPath, sourceDirs[i]);
|
|
111
|
+
let collisions = [];
|
|
112
|
+
let filesWithoutCollisions = [];
|
|
113
|
+
if (fs_extra_1.default.existsSync(dest) &&
|
|
114
|
+
handleCollision &&
|
|
115
|
+
typeof handleCollision === 'function') {
|
|
116
|
+
const existingFiles = (await (0, fs_1.walk)(dest, ['node_modules'])).map(file => path_1.default.normalize(path_1.default.relative(dest, file)));
|
|
117
|
+
const newFiles = (await (0, fs_1.walk)(projectSrcDir, ['node_modules'])).map(file => path_1.default.relative(projectSrcDir, file));
|
|
118
|
+
// Find files that exist in the same positions in both directories
|
|
119
|
+
collisions = existingFiles.filter(currentFile => newFiles.includes(currentFile));
|
|
120
|
+
filesWithoutCollisions = newFiles.filter(currentFile => !collisions.includes(currentFile));
|
|
121
|
+
}
|
|
122
|
+
if (collisions.length &&
|
|
123
|
+
handleCollision &&
|
|
124
|
+
typeof handleCollision === 'function') {
|
|
125
|
+
await handleCollision({
|
|
126
|
+
dest,
|
|
127
|
+
src: projectSrcDir,
|
|
128
|
+
collisions,
|
|
129
|
+
});
|
|
130
|
+
await Promise.all(filesWithoutCollisions.map(currentFile => fs_extra_1.default.copy(path_1.default.join(projectSrcDir, currentFile), path_1.default.join(dest, currentFile))));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
await fs_extra_1.default.copy(projectSrcDir, dest);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
78
136
|
}
|
|
79
|
-
const projectSrcDir = (0, path_1.join)(...srcDirPath);
|
|
80
|
-
await fs_extra_1.default.copy(projectSrcDir, dest);
|
|
81
137
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.copySourceToDest.success`));
|
|
82
138
|
return true;
|
|
83
139
|
}
|
|
@@ -99,7 +155,7 @@ async function cleanupTempDir(tmpDir) {
|
|
|
99
155
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.cleanupTempDir.error`, { tmpDir }));
|
|
100
156
|
}
|
|
101
157
|
}
|
|
102
|
-
async function extractZipArchive(zip, name, dest, { sourceDir, includesRootDir, hideLogs } = {}) {
|
|
158
|
+
async function extractZipArchive(zip, name, dest, { sourceDir, includesRootDir, hideLogs, handleCollision, } = {}) {
|
|
103
159
|
let success = false;
|
|
104
160
|
if (zip) {
|
|
105
161
|
const { extractDir, tmpDir } = await extractZip(name, zip, hideLogs);
|
|
@@ -108,6 +164,7 @@ async function extractZipArchive(zip, name, dest, { sourceDir, includesRootDir,
|
|
|
108
164
|
sourceDir,
|
|
109
165
|
includesRootDir,
|
|
110
166
|
hideLogs,
|
|
167
|
+
handleCollision,
|
|
111
168
|
});
|
|
112
169
|
}
|
|
113
170
|
await cleanupTempDir(tmpDir);
|
package/lib/github.js
CHANGED
|
@@ -24,6 +24,7 @@ async function fetchFileFromRepository(repoPath, filePath, ref) {
|
|
|
24
24
|
return data;
|
|
25
25
|
}
|
|
26
26
|
catch (err) {
|
|
27
|
+
checkGithubRateLimit(err);
|
|
27
28
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.fetchFileFromRepository.errors.fetchFail`), {
|
|
28
29
|
cause: err,
|
|
29
30
|
});
|
|
@@ -43,6 +44,7 @@ async function fetchReleaseData(repoPath, tag) {
|
|
|
43
44
|
return data;
|
|
44
45
|
}
|
|
45
46
|
catch (err) {
|
|
47
|
+
checkGithubRateLimit(err);
|
|
46
48
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.fetchReleaseData.errors.fetchFail`, {
|
|
47
49
|
tag: tag || 'latest',
|
|
48
50
|
}), { cause: err });
|
|
@@ -72,13 +74,14 @@ async function downloadGithubRepoZip(repoPath, isRelease = false, options = {})
|
|
|
72
74
|
return data;
|
|
73
75
|
}
|
|
74
76
|
catch (err) {
|
|
77
|
+
checkGithubRateLimit(err);
|
|
75
78
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.downloadGithubRepoZip.errors.fetchFail`), {
|
|
76
79
|
cause: err,
|
|
77
80
|
});
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
async function cloneGithubRepo(repoPath, dest, options = {}) {
|
|
81
|
-
const { tag, isRelease, branch, sourceDir, type, hideLogs } = options;
|
|
84
|
+
const { tag, isRelease, branch, sourceDir, type, hideLogs, handleCollision } = options;
|
|
82
85
|
const zip = await downloadGithubRepoZip(repoPath, isRelease, {
|
|
83
86
|
tag,
|
|
84
87
|
branch,
|
|
@@ -87,6 +90,7 @@ async function cloneGithubRepo(repoPath, dest, options = {}) {
|
|
|
87
90
|
const success = await (0, archive_1.extractZipArchive)(zip, repoName, dest, {
|
|
88
91
|
sourceDir,
|
|
89
92
|
hideLogs,
|
|
93
|
+
handleCollision,
|
|
90
94
|
});
|
|
91
95
|
if (success && !hideLogs) {
|
|
92
96
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.cloneGithubRepo.success`, {
|
|
@@ -146,6 +150,7 @@ async function downloadGithubRepoContents(repoPath, contentPath, dest, ref, filt
|
|
|
146
150
|
await Promise.all(contentPromises);
|
|
147
151
|
}
|
|
148
152
|
catch (e) {
|
|
153
|
+
checkGithubRateLimit(e);
|
|
149
154
|
if ((0, errors_1.isSystemError)(e) && e?.error?.message) {
|
|
150
155
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.downloadGithubRepoContents.errors.fetchFail`, {
|
|
151
156
|
errorMessage: e.error.message,
|
|
@@ -165,6 +170,7 @@ async function listGithubRepoContents(repoPath, contentPath, fileFilter) {
|
|
|
165
170
|
return filteredFiles;
|
|
166
171
|
}
|
|
167
172
|
catch (e) {
|
|
173
|
+
checkGithubRateLimit(e);
|
|
168
174
|
if ((0, errors_1.isHubSpotHttpError)(e) && e.data.message) {
|
|
169
175
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.downloadGithubRepoContents.errors.fetchFail`, {
|
|
170
176
|
errorMessage: e.data.message,
|
|
@@ -174,3 +180,10 @@ async function listGithubRepoContents(repoPath, contentPath, fileFilter) {
|
|
|
174
180
|
}
|
|
175
181
|
}
|
|
176
182
|
exports.listGithubRepoContents = listGithubRepoContents;
|
|
183
|
+
function checkGithubRateLimit(err) {
|
|
184
|
+
if ((0, errors_1.isGithubRateLimitError)(err)) {
|
|
185
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.rateLimitError`), {
|
|
186
|
+
cause: err,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
package/package.json
CHANGED
package/types/Archive.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
export interface Collision {
|
|
2
|
+
dest: string;
|
|
3
|
+
src: string;
|
|
4
|
+
collisions: string[];
|
|
5
|
+
}
|
|
1
6
|
export type ZipData = {
|
|
2
7
|
extractDir: string;
|
|
3
8
|
tmpDir: string;
|
|
4
9
|
};
|
|
5
10
|
export type CopySourceToDestOptions = {
|
|
6
|
-
sourceDir?: string;
|
|
11
|
+
sourceDir?: string | string[];
|
|
7
12
|
includesRootDir?: boolean;
|
|
8
13
|
hideLogs?: boolean;
|
|
14
|
+
handleCollision?: (collision: Collision) => void | Promise<void>;
|
|
9
15
|
};
|
package/types/Config.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface CLIConfig_NEW {
|
|
|
12
12
|
httpTimeout?: number;
|
|
13
13
|
env?: Environment;
|
|
14
14
|
httpUseLocalhost?: boolean;
|
|
15
|
+
autoOpenBrowser?: boolean;
|
|
16
|
+
flags?: Array<string>;
|
|
15
17
|
}
|
|
16
18
|
export interface CLIConfig_DEPRECATED {
|
|
17
19
|
portals: Array<CLIAccount_DEPRECATED>;
|
|
@@ -23,6 +25,8 @@ export interface CLIConfig_DEPRECATED {
|
|
|
23
25
|
httpTimeout?: number;
|
|
24
26
|
env?: Environment;
|
|
25
27
|
httpUseLocalhost?: boolean;
|
|
28
|
+
autoOpenBrowser?: boolean;
|
|
29
|
+
flags?: Array<string>;
|
|
26
30
|
}
|
|
27
31
|
export type CLIConfig = CLIConfig_NEW | CLIConfig_DEPRECATED;
|
|
28
32
|
export type Environment = ValueOf<typeof ENVIRONMENTS> | '';
|
package/types/Deploy.d.ts
CHANGED
|
@@ -35,9 +35,25 @@ export type DeployStatusTaskLocator = {
|
|
|
35
35
|
status: string;
|
|
36
36
|
}>;
|
|
37
37
|
};
|
|
38
|
-
export type
|
|
38
|
+
export type ProjectDeployResponseQueued = {
|
|
39
39
|
id: string;
|
|
40
|
+
buildResultType: 'DEPLOY_QUEUED';
|
|
40
41
|
links: {
|
|
41
42
|
status: string;
|
|
42
43
|
};
|
|
43
44
|
};
|
|
45
|
+
type SubdeployValidationIssue = {
|
|
46
|
+
uid: string;
|
|
47
|
+
componentTypeName: string;
|
|
48
|
+
errorMessages: string[];
|
|
49
|
+
blockingMessages: {
|
|
50
|
+
message: string;
|
|
51
|
+
isWarning: boolean;
|
|
52
|
+
}[];
|
|
53
|
+
};
|
|
54
|
+
export type ProjectDeployResponseBlocked = {
|
|
55
|
+
buildResultType: 'DEPLOY_BLOCKED';
|
|
56
|
+
issues: SubdeployValidationIssue[];
|
|
57
|
+
};
|
|
58
|
+
export type ProjectDeployResponse = ProjectDeployResponseQueued | ProjectDeployResponseBlocked;
|
|
59
|
+
export {};
|
package/types/Github.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Collision } from './Archive';
|
|
1
2
|
type GithubAuthor = {
|
|
2
3
|
login: string;
|
|
3
4
|
id: number;
|
|
@@ -71,7 +72,8 @@ export type CloneGithubRepoOptions = {
|
|
|
71
72
|
type?: string;
|
|
72
73
|
branch?: string;
|
|
73
74
|
tag?: string;
|
|
74
|
-
sourceDir?: string;
|
|
75
|
+
sourceDir?: string | string[];
|
|
75
76
|
hideLogs?: boolean;
|
|
77
|
+
handleCollision?: (collision: Collision) => void;
|
|
76
78
|
};
|
|
77
79
|
export {};
|
package/types/Sandbox.d.ts
CHANGED
|
@@ -111,6 +111,33 @@ export type Sandbox = {
|
|
|
111
111
|
requestAccessFrom?: User | null;
|
|
112
112
|
superAdminsInSandbox?: number;
|
|
113
113
|
};
|
|
114
|
+
export declare const SandboxVersioning: {
|
|
115
|
+
readonly V1: "V1";
|
|
116
|
+
readonly V2: "V2";
|
|
117
|
+
};
|
|
118
|
+
export declare const SandboxStatus: {
|
|
119
|
+
readonly PENDING: "PENDING";
|
|
120
|
+
readonly READY: "READY";
|
|
121
|
+
readonly FAILED: "FAILED";
|
|
122
|
+
};
|
|
123
|
+
export type SandboxVersion = keyof typeof SandboxVersioning;
|
|
124
|
+
export type V2SandboxStatus = keyof typeof SandboxStatus;
|
|
125
|
+
export type V2Sandbox = {
|
|
126
|
+
sandboxHubId: number;
|
|
127
|
+
parentHubId: number;
|
|
128
|
+
name: string;
|
|
129
|
+
version: SandboxVersion;
|
|
130
|
+
type: string;
|
|
131
|
+
status: V2SandboxStatus;
|
|
132
|
+
createdAt: string;
|
|
133
|
+
createdByUser: User;
|
|
134
|
+
currentUserHasAccess?: boolean;
|
|
135
|
+
currentUserHasSuperAdminAccess?: boolean;
|
|
136
|
+
superAdminsInSandbox?: number;
|
|
137
|
+
requestAccessFrom?: User | null;
|
|
138
|
+
updatedAt?: string;
|
|
139
|
+
updatedByUser?: User | null;
|
|
140
|
+
};
|
|
114
141
|
export type SandboxResponse = {
|
|
115
142
|
sandbox: Sandbox;
|
|
116
143
|
personalAccessKey: string;
|
|
@@ -152,4 +179,10 @@ export type SandboxType = {
|
|
|
152
179
|
export type FetchTypesResponse = {
|
|
153
180
|
results: Array<SandboxType>;
|
|
154
181
|
};
|
|
182
|
+
export type SandboxPersonalAccessKey = {
|
|
183
|
+
personalAccessKey: {
|
|
184
|
+
encodedOAuthRefreshToken: string;
|
|
185
|
+
oauthAccessToken: string;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
155
188
|
export {};
|
package/types/Sandbox.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SandboxStatus = exports.SandboxVersioning = void 0;
|
|
4
|
+
exports.SandboxVersioning = {
|
|
5
|
+
V1: 'V1',
|
|
6
|
+
V2: 'V2',
|
|
7
|
+
};
|
|
8
|
+
exports.SandboxStatus = {
|
|
9
|
+
PENDING: 'PENDING',
|
|
10
|
+
READY: 'READY',
|
|
11
|
+
FAILED: 'FAILED',
|
|
12
|
+
};
|
|
@@ -17,7 +17,36 @@ export type CreateDeveloperTestAccountResponse = {
|
|
|
17
17
|
currentUserHasAccess: boolean;
|
|
18
18
|
personalAccessKey: string;
|
|
19
19
|
};
|
|
20
|
+
export type CreateDeveloperTestAccountV3Response = {
|
|
21
|
+
id: number;
|
|
22
|
+
accountName: string;
|
|
23
|
+
};
|
|
20
24
|
export type FetchDeveloperTestAccountsResponse = {
|
|
21
25
|
results: DeveloperTestAccount[];
|
|
22
26
|
maxTestPortals: number;
|
|
23
27
|
};
|
|
28
|
+
export type AccountLevel = 'FREE' | 'STARTER' | 'PROFESSIONAL' | 'ENTERPRISE';
|
|
29
|
+
export type DeveloperTestAccountConfig = {
|
|
30
|
+
accountName: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
marketingLevel?: AccountLevel;
|
|
33
|
+
opsLevel?: AccountLevel;
|
|
34
|
+
serviceLevel?: AccountLevel;
|
|
35
|
+
salesLevel?: AccountLevel;
|
|
36
|
+
contentLevel?: AccountLevel;
|
|
37
|
+
};
|
|
38
|
+
export type InstallOauthAppIntoDeveloperTestAccountResponse = {
|
|
39
|
+
authCodes: Array<{
|
|
40
|
+
developerQualifiedSymbol: {
|
|
41
|
+
projectName: string;
|
|
42
|
+
developerSymbol: string;
|
|
43
|
+
};
|
|
44
|
+
authCode: string;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
export type TestPortalStatusResponse = {
|
|
48
|
+
status: 'IN_PROGRESS' | 'SUCCESS';
|
|
49
|
+
};
|
|
50
|
+
export type GenerateDeveloperTestAccountPersonalAccessKeyResponse = {
|
|
51
|
+
personalAccessKey: string;
|
|
52
|
+
};
|