@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/lib/logger.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type ChalkInstance } from 'chalk';
|
|
2
2
|
export declare const LOG_LEVEL: {
|
|
3
3
|
NONE: number;
|
|
4
4
|
DEBUG: number;
|
|
@@ -10,26 +10,14 @@ export declare const LOG_LEVEL: {
|
|
|
10
10
|
* Chalk styles for logger strings.
|
|
11
11
|
*/
|
|
12
12
|
export declare const Styles: {
|
|
13
|
-
debug:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
success: Chalk & {
|
|
20
|
-
supportsColor: import("chalk").ColorSupport;
|
|
21
|
-
};
|
|
22
|
-
info: Chalk & {
|
|
23
|
-
supportsColor: import("chalk").ColorSupport;
|
|
24
|
-
};
|
|
25
|
-
warn: Chalk & {
|
|
26
|
-
supportsColor: import("chalk").ColorSupport;
|
|
27
|
-
};
|
|
28
|
-
error: Chalk & {
|
|
29
|
-
supportsColor: import("chalk").ColorSupport;
|
|
30
|
-
};
|
|
13
|
+
debug: ChalkInstance;
|
|
14
|
+
log: ChalkInstance;
|
|
15
|
+
success: ChalkInstance;
|
|
16
|
+
info: ChalkInstance;
|
|
17
|
+
warn: ChalkInstance;
|
|
18
|
+
error: ChalkInstance;
|
|
31
19
|
};
|
|
32
|
-
export declare function stylize(label: string, style:
|
|
20
|
+
export declare function stylize(label: string, style: ChalkInstance, args: any[]): any[];
|
|
33
21
|
export declare class Logger {
|
|
34
22
|
error(...args: any[]): void;
|
|
35
23
|
warn(...args: any[]): void;
|
package/lib/logger.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.logger = exports.getLogLevel = exports.shouldLog = exports.setLogLevel = exports.setLogger = exports.Logger = exports.stylize = exports.Styles = exports.LOG_LEVEL = void 0;
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
exports.LOG_LEVEL = {
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
export const LOG_LEVEL = {
|
|
10
4
|
NONE: 0,
|
|
11
5
|
DEBUG: 1,
|
|
12
6
|
LOG: 2,
|
|
@@ -16,15 +10,15 @@ exports.LOG_LEVEL = {
|
|
|
16
10
|
/**
|
|
17
11
|
* Chalk styles for logger strings.
|
|
18
12
|
*/
|
|
19
|
-
|
|
20
|
-
debug:
|
|
21
|
-
log:
|
|
22
|
-
success:
|
|
23
|
-
info:
|
|
24
|
-
warn:
|
|
25
|
-
error:
|
|
13
|
+
export const Styles = {
|
|
14
|
+
debug: chalk.reset.blue,
|
|
15
|
+
log: chalk.reset.white,
|
|
16
|
+
success: chalk.reset.green,
|
|
17
|
+
info: chalk.reset.white,
|
|
18
|
+
warn: chalk.reset.yellow,
|
|
19
|
+
error: chalk.reset.red,
|
|
26
20
|
};
|
|
27
|
-
function stylize(label, style, args) {
|
|
21
|
+
export function stylize(label, style, args) {
|
|
28
22
|
const styledLabel = style(label);
|
|
29
23
|
const [firstArg, ...rest] = args;
|
|
30
24
|
if (typeof firstArg === 'string') {
|
|
@@ -32,25 +26,24 @@ function stylize(label, style, args) {
|
|
|
32
26
|
}
|
|
33
27
|
return [styledLabel, ...args];
|
|
34
28
|
}
|
|
35
|
-
|
|
36
|
-
class Logger {
|
|
29
|
+
export class Logger {
|
|
37
30
|
error(...args) {
|
|
38
|
-
console.error(...stylize('[ERROR]',
|
|
31
|
+
console.error(...stylize('[ERROR]', Styles.error, args));
|
|
39
32
|
}
|
|
40
33
|
warn(...args) {
|
|
41
|
-
console.warn(...stylize('[WARNING]',
|
|
34
|
+
console.warn(...stylize('[WARNING]', Styles.warn, args));
|
|
42
35
|
}
|
|
43
36
|
log(...args) {
|
|
44
37
|
console.log(...args);
|
|
45
38
|
}
|
|
46
39
|
success(...args) {
|
|
47
|
-
console.log(...stylize('[SUCCESS]',
|
|
40
|
+
console.log(...stylize('[SUCCESS]', Styles.success, args));
|
|
48
41
|
}
|
|
49
42
|
info(...args) {
|
|
50
|
-
console.info(...stylize('[INFO]',
|
|
43
|
+
console.info(...stylize('[INFO]', Styles.info, args));
|
|
51
44
|
}
|
|
52
45
|
debug(...args) {
|
|
53
|
-
console.debug(...stylize('[DEBUG]',
|
|
46
|
+
console.debug(...stylize('[DEBUG]', Styles.log, args));
|
|
54
47
|
}
|
|
55
48
|
group(...args) {
|
|
56
49
|
console.group(...args);
|
|
@@ -59,81 +52,76 @@ class Logger {
|
|
|
59
52
|
console.groupEnd();
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
|
-
exports.Logger = Logger;
|
|
63
55
|
let currentLogger = new Logger();
|
|
64
|
-
let currentLogLevel =
|
|
65
|
-
function setLogger(logger) {
|
|
56
|
+
let currentLogLevel = LOG_LEVEL.ERROR;
|
|
57
|
+
export function setLogger(logger) {
|
|
66
58
|
currentLogger = logger;
|
|
67
59
|
}
|
|
68
|
-
|
|
69
|
-
function setLogLevel(level) {
|
|
60
|
+
export function setLogLevel(level) {
|
|
70
61
|
switch (level) {
|
|
71
|
-
case
|
|
62
|
+
case LOG_LEVEL.DEBUG:
|
|
72
63
|
currentLogLevel =
|
|
73
|
-
|
|
64
|
+
LOG_LEVEL.DEBUG | LOG_LEVEL.LOG | LOG_LEVEL.WARN | LOG_LEVEL.ERROR;
|
|
74
65
|
break;
|
|
75
|
-
case
|
|
76
|
-
currentLogLevel =
|
|
66
|
+
case LOG_LEVEL.LOG:
|
|
67
|
+
currentLogLevel = LOG_LEVEL.LOG | LOG_LEVEL.WARN | LOG_LEVEL.ERROR;
|
|
77
68
|
break;
|
|
78
|
-
case
|
|
79
|
-
currentLogLevel =
|
|
69
|
+
case LOG_LEVEL.WARN:
|
|
70
|
+
currentLogLevel = LOG_LEVEL.WARN | LOG_LEVEL.ERROR;
|
|
80
71
|
break;
|
|
81
|
-
case
|
|
82
|
-
currentLogLevel =
|
|
72
|
+
case LOG_LEVEL.ERROR:
|
|
73
|
+
currentLogLevel = LOG_LEVEL.ERROR;
|
|
83
74
|
break;
|
|
84
|
-
case
|
|
75
|
+
case LOG_LEVEL.NONE:
|
|
85
76
|
default:
|
|
86
|
-
currentLogLevel =
|
|
77
|
+
currentLogLevel = LOG_LEVEL.NONE;
|
|
87
78
|
}
|
|
88
79
|
}
|
|
89
|
-
|
|
90
|
-
function shouldLog(level) {
|
|
80
|
+
export function shouldLog(level) {
|
|
91
81
|
return !!(currentLogLevel & level);
|
|
92
82
|
}
|
|
93
|
-
|
|
94
|
-
function getLogLevel() {
|
|
83
|
+
export function getLogLevel() {
|
|
95
84
|
switch (currentLogLevel) {
|
|
96
|
-
case
|
|
97
|
-
return
|
|
98
|
-
case
|
|
99
|
-
return
|
|
100
|
-
case
|
|
101
|
-
return
|
|
102
|
-
case
|
|
103
|
-
return
|
|
85
|
+
case LOG_LEVEL.DEBUG | LOG_LEVEL.LOG | LOG_LEVEL.WARN | LOG_LEVEL.ERROR:
|
|
86
|
+
return LOG_LEVEL.DEBUG;
|
|
87
|
+
case LOG_LEVEL.LOG | LOG_LEVEL.WARN | LOG_LEVEL.ERROR:
|
|
88
|
+
return LOG_LEVEL.LOG;
|
|
89
|
+
case LOG_LEVEL.WARN | LOG_LEVEL.ERROR:
|
|
90
|
+
return LOG_LEVEL.WARN;
|
|
91
|
+
case LOG_LEVEL.ERROR:
|
|
92
|
+
return LOG_LEVEL.ERROR;
|
|
104
93
|
default:
|
|
105
|
-
return
|
|
94
|
+
return LOG_LEVEL.NONE;
|
|
106
95
|
}
|
|
107
96
|
}
|
|
108
|
-
|
|
109
|
-
exports.logger = {
|
|
97
|
+
export const logger = {
|
|
110
98
|
error(...args) {
|
|
111
|
-
if (shouldLog(
|
|
99
|
+
if (shouldLog(LOG_LEVEL.ERROR)) {
|
|
112
100
|
currentLogger.error(...args);
|
|
113
101
|
}
|
|
114
102
|
},
|
|
115
103
|
warn(...args) {
|
|
116
|
-
if (shouldLog(
|
|
104
|
+
if (shouldLog(LOG_LEVEL.WARN)) {
|
|
117
105
|
currentLogger.warn(...args);
|
|
118
106
|
}
|
|
119
107
|
},
|
|
120
108
|
log(...args) {
|
|
121
|
-
if (shouldLog(
|
|
109
|
+
if (shouldLog(LOG_LEVEL.LOG)) {
|
|
122
110
|
currentLogger.log(...args);
|
|
123
111
|
}
|
|
124
112
|
},
|
|
125
113
|
success(...args) {
|
|
126
|
-
if (shouldLog(
|
|
114
|
+
if (shouldLog(LOG_LEVEL.LOG)) {
|
|
127
115
|
currentLogger.success(...args);
|
|
128
116
|
}
|
|
129
117
|
},
|
|
130
118
|
info(...args) {
|
|
131
|
-
if (shouldLog(
|
|
119
|
+
if (shouldLog(LOG_LEVEL.LOG)) {
|
|
132
120
|
currentLogger.info(...args);
|
|
133
121
|
}
|
|
134
122
|
},
|
|
135
123
|
debug(...args) {
|
|
136
|
-
if (shouldLog(
|
|
124
|
+
if (shouldLog(LOG_LEVEL.DEBUG)) {
|
|
137
125
|
currentLogger.debug(...args);
|
|
138
126
|
}
|
|
139
127
|
},
|
package/lib/notify.js
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.triggerNotify = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const moment_1 = __importDefault(require("moment"));
|
|
9
|
-
const debounce_1 = __importDefault(require("debounce"));
|
|
10
|
-
const lang_1 = require("../utils/lang");
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
import debounce from 'debounce';
|
|
4
|
+
import { i18n } from '../utils/lang.js';
|
|
11
5
|
const i18nKey = 'utils.notify';
|
|
12
6
|
const notifyQueue = [];
|
|
13
7
|
const notifyPromises = [];
|
|
14
|
-
const debouncedWaitForActionsToCompleteAndWriteQueueToFile = (
|
|
8
|
+
const debouncedWaitForActionsToCompleteAndWriteQueueToFile = debounce(waitForActionsToCompleteAndWriteQueueToFile, 500);
|
|
15
9
|
// Collects actions that have been taken on files and the corresponding Promise
|
|
16
10
|
// for the remote action that is in-process
|
|
17
|
-
function triggerNotify(filePathToNotify, actionType, filePath, actionPromise) {
|
|
11
|
+
export function triggerNotify(filePathToNotify, actionType, filePath, actionPromise) {
|
|
18
12
|
if (filePathToNotify) {
|
|
19
|
-
notifyQueue.push(`${(
|
|
13
|
+
notifyQueue.push(`${moment().toISOString()} ${actionType}: ${filePath}\n`);
|
|
20
14
|
notifyPromises.push(actionPromise);
|
|
21
15
|
debouncedWaitForActionsToCompleteAndWriteQueueToFile(filePathToNotify);
|
|
22
16
|
}
|
|
23
17
|
}
|
|
24
|
-
exports.triggerNotify = triggerNotify;
|
|
25
18
|
// Clears both the notifyQueue and notifyPromises array, generates the output
|
|
26
19
|
// string that will be eventually logged, and waits for all promises currently
|
|
27
20
|
// in the notifyPromises array to resolve before logging the output
|
|
@@ -34,10 +27,10 @@ function waitForActionsToCompleteAndWriteQueueToFile(filePathToNotify) {
|
|
|
34
27
|
function notifyFilePath(filePathToNotify, outputToWrite) {
|
|
35
28
|
if (filePathToNotify) {
|
|
36
29
|
try {
|
|
37
|
-
|
|
30
|
+
fs.appendFileSync(filePathToNotify, outputToWrite);
|
|
38
31
|
}
|
|
39
32
|
catch (e) {
|
|
40
|
-
throw new Error(
|
|
33
|
+
throw new Error(i18n(`${i18nKey}.errors.filePath`, { filePath: filePathToNotify }), { cause: e });
|
|
41
34
|
}
|
|
42
35
|
}
|
|
43
36
|
}
|
package/lib/oauth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OAuth2Manager } from '../models/OAuth2Manager';
|
|
2
|
-
import { OAuthConfigAccount } from '../types/Accounts';
|
|
1
|
+
import { OAuth2Manager } from '../models/OAuth2Manager.js';
|
|
2
|
+
import { OAuthConfigAccount } from '../types/Accounts.js';
|
|
3
3
|
export declare function getOauthManager(account: OAuthConfigAccount): OAuth2Manager | undefined;
|
|
4
4
|
export declare function addOauthToAccountConfig(oauth: OAuth2Manager): void;
|
package/lib/oauth.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const logger_1 = require("./logger");
|
|
6
|
-
const config_1 = require("../config");
|
|
7
|
-
const lang_1 = require("../utils/lang");
|
|
1
|
+
import { OAuth2Manager } from '../models/OAuth2Manager.js';
|
|
2
|
+
import { logger } from './logger.js';
|
|
3
|
+
import { updateConfigAccount } from '../config/index.js';
|
|
4
|
+
import { i18n } from '../utils/lang.js';
|
|
8
5
|
const i18nKey = 'lib.oauth';
|
|
9
6
|
const oauthManagers = new Map();
|
|
10
7
|
function writeOauthTokenInfo(account) {
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
logger.debug(i18n(`${i18nKey}.writeTokenInfo`, { portalId: account.accountId }));
|
|
9
|
+
updateConfigAccount(account);
|
|
13
10
|
}
|
|
14
|
-
function getOauthManager(account) {
|
|
11
|
+
export function getOauthManager(account) {
|
|
15
12
|
if (!oauthManagers.has(account.accountId)) {
|
|
16
|
-
oauthManagers.set(account.accountId, new
|
|
13
|
+
oauthManagers.set(account.accountId, new OAuth2Manager(account, () => writeOauthTokenInfo(account)));
|
|
17
14
|
}
|
|
18
15
|
return oauthManagers.get(account.accountId);
|
|
19
16
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.addOauthToAccountConfig.success`));
|
|
17
|
+
export function addOauthToAccountConfig(oauth) {
|
|
18
|
+
logger.log(i18n(`${i18nKey}.addOauthToAccountConfig.init`));
|
|
19
|
+
updateConfigAccount(oauth.account);
|
|
20
|
+
logger.success(i18n(`${i18nKey}.addOauthToAccountConfig.success`));
|
|
25
21
|
}
|
|
26
|
-
exports.addOauthToAccountConfig = addOauthToAccountConfig;
|
package/lib/path.d.ts
CHANGED
package/lib/path.js
CHANGED
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const unixify_1 = __importDefault(require("unixify"));
|
|
9
|
-
const extensions_1 = require("../constants/extensions");
|
|
10
|
-
const os_1 = __importDefault(require("os"));
|
|
11
|
-
function convertToUnixPath(_path) {
|
|
12
|
-
return (0, unixify_1.default)(path_1.default.normalize(_path));
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import unixify from 'unixify';
|
|
3
|
+
import { ALLOWED_EXTENSIONS } from '../constants/extensions.js';
|
|
4
|
+
import os from 'os';
|
|
5
|
+
export function convertToUnixPath(_path) {
|
|
6
|
+
return unixify(path.normalize(_path));
|
|
13
7
|
}
|
|
14
|
-
exports.convertToUnixPath = convertToUnixPath;
|
|
15
8
|
function convertToWindowsPath(_path) {
|
|
16
|
-
const rgx = new RegExp(`\\${
|
|
17
|
-
return
|
|
9
|
+
const rgx = new RegExp(`\\${path.posix.sep}`, 'g');
|
|
10
|
+
return path.normalize(_path).replace(rgx, path.win32.sep);
|
|
18
11
|
}
|
|
19
|
-
function convertToLocalFileSystemPath(_path) {
|
|
20
|
-
switch (
|
|
21
|
-
case
|
|
12
|
+
export function convertToLocalFileSystemPath(_path) {
|
|
13
|
+
switch (path.sep) {
|
|
14
|
+
case path.posix.sep:
|
|
22
15
|
return convertToUnixPath(_path);
|
|
23
|
-
case
|
|
16
|
+
case path.win32.sep:
|
|
24
17
|
return convertToWindowsPath(_path);
|
|
25
18
|
default:
|
|
26
|
-
return
|
|
19
|
+
return path.normalize(_path);
|
|
27
20
|
}
|
|
28
21
|
}
|
|
29
|
-
exports.convertToLocalFileSystemPath = convertToLocalFileSystemPath;
|
|
30
22
|
function removeTrailingSlashFromSplits(parts) {
|
|
31
23
|
if (parts.length > 1 && parts[parts.length - 1] === '') {
|
|
32
24
|
return parts.slice(0, parts.length - 1);
|
|
@@ -34,24 +26,23 @@ function removeTrailingSlashFromSplits(parts) {
|
|
|
34
26
|
return parts;
|
|
35
27
|
}
|
|
36
28
|
// Splits a filepath for local file system sources.
|
|
37
|
-
function splitLocalPath(filepath, pathImplementation =
|
|
29
|
+
export function splitLocalPath(filepath, pathImplementation = path) {
|
|
38
30
|
if (!filepath)
|
|
39
31
|
return [];
|
|
40
32
|
const { sep } = pathImplementation;
|
|
41
33
|
const rgx = new RegExp(`\\${sep}+`, 'g');
|
|
42
34
|
const parts = pathImplementation.normalize(filepath).split(rgx);
|
|
43
35
|
// Restore posix root if present
|
|
44
|
-
if (sep ===
|
|
36
|
+
if (sep === path.posix.sep && parts[0] === '') {
|
|
45
37
|
parts[0] = '/';
|
|
46
38
|
}
|
|
47
39
|
return removeTrailingSlashFromSplits(parts);
|
|
48
40
|
}
|
|
49
|
-
exports.splitLocalPath = splitLocalPath;
|
|
50
41
|
// Splits a filepath for remote sources (HubSpot).
|
|
51
|
-
function splitHubSpotPath(filepath) {
|
|
42
|
+
export function splitHubSpotPath(filepath) {
|
|
52
43
|
if (!filepath)
|
|
53
44
|
return [];
|
|
54
|
-
const rgx = new RegExp(`\\${
|
|
45
|
+
const rgx = new RegExp(`\\${path.posix.sep}+`, 'g');
|
|
55
46
|
const parts = convertToUnixPath(filepath).split(rgx);
|
|
56
47
|
// Restore root if present
|
|
57
48
|
if (parts[0] === '') {
|
|
@@ -59,39 +50,33 @@ function splitHubSpotPath(filepath) {
|
|
|
59
50
|
}
|
|
60
51
|
return removeTrailingSlashFromSplits(parts);
|
|
61
52
|
}
|
|
62
|
-
|
|
63
|
-
function getCwd() {
|
|
53
|
+
export function getCwd() {
|
|
64
54
|
if (process.env.INIT_CWD) {
|
|
65
55
|
return process.env.INIT_CWD;
|
|
66
56
|
}
|
|
67
57
|
return process.cwd();
|
|
68
58
|
}
|
|
69
|
-
|
|
70
|
-
function getExt(filepath) {
|
|
59
|
+
export function getExt(filepath) {
|
|
71
60
|
if (typeof filepath !== 'string')
|
|
72
61
|
return '';
|
|
73
|
-
const ext =
|
|
62
|
+
const ext = path.extname(filepath).trim().toLowerCase();
|
|
74
63
|
return ext[0] === '.' ? ext.slice(1) : ext;
|
|
75
64
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return new Set([...Array.from(extensions_1.ALLOWED_EXTENSIONS), ...allowList]);
|
|
65
|
+
export function getAllowedExtensions(allowList = []) {
|
|
66
|
+
return new Set([...Array.from(ALLOWED_EXTENSIONS), ...allowList]);
|
|
79
67
|
}
|
|
80
|
-
|
|
81
|
-
function isAllowedExtension(filepath, allowList = []) {
|
|
68
|
+
export function isAllowedExtension(filepath, allowList = []) {
|
|
82
69
|
const ext = getExt(filepath);
|
|
83
70
|
const allowedExtensions = getAllowedExtensions(allowList);
|
|
84
71
|
return allowedExtensions.has(ext);
|
|
85
72
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return path_1.default.resolve(getCwd(), _path);
|
|
73
|
+
export function getAbsoluteFilePath(_path) {
|
|
74
|
+
return path.resolve(getCwd(), _path);
|
|
89
75
|
}
|
|
90
|
-
exports.getAbsoluteFilePath = getAbsoluteFilePath;
|
|
91
76
|
// Reserved names (Windows specific)
|
|
92
77
|
const reservedNames = /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;
|
|
93
78
|
// Based on the node-sanitize-filename package: https://github.com/parshap/node-sanitize-filename/blob/master/index.js
|
|
94
|
-
function sanitizeFileName(fileName) {
|
|
79
|
+
export function sanitizeFileName(fileName) {
|
|
95
80
|
// Windows invalid/control characters
|
|
96
81
|
// eslint-disable-next-line no-control-regex
|
|
97
82
|
const invalidChars = /[<>:"/|?*\x00-\x1F]/g;
|
|
@@ -105,13 +90,12 @@ function sanitizeFileName(fileName) {
|
|
|
105
90
|
}
|
|
106
91
|
return sanitizedFileName;
|
|
107
92
|
}
|
|
108
|
-
exports.sanitizeFileName = sanitizeFileName;
|
|
109
93
|
// Based on the node-sanitize-filename package: https://github.com/parshap/node-sanitize-filename/blob/master/index.js
|
|
110
|
-
function isValidPath(_path) {
|
|
94
|
+
export function isValidPath(_path) {
|
|
111
95
|
// Invalid characters excluding forward slash
|
|
112
96
|
// eslint-disable-next-line no-control-regex
|
|
113
97
|
const invalidChars = /[<>:"|?*\x00-\x1F]/;
|
|
114
|
-
const baseName =
|
|
98
|
+
const baseName = path.basename(_path);
|
|
115
99
|
if (invalidChars.test(baseName)) {
|
|
116
100
|
return false;
|
|
117
101
|
}
|
|
@@ -120,10 +104,9 @@ function isValidPath(_path) {
|
|
|
120
104
|
}
|
|
121
105
|
return true;
|
|
122
106
|
}
|
|
123
|
-
exports.isValidPath = isValidPath;
|
|
124
107
|
// Based on the untildify package: https://github.com/sindresorhus/untildify/blob/main/index.js
|
|
125
|
-
function untildify(pathWithTilde) {
|
|
126
|
-
const homeDirectory =
|
|
108
|
+
export function untildify(pathWithTilde) {
|
|
109
|
+
const homeDirectory = os.homedir();
|
|
127
110
|
if (typeof pathWithTilde !== 'string') {
|
|
128
111
|
throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`);
|
|
129
112
|
}
|
|
@@ -131,4 +114,3 @@ function untildify(pathWithTilde) {
|
|
|
131
114
|
? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory)
|
|
132
115
|
: pathWithTilde;
|
|
133
116
|
}
|
|
134
|
-
exports.untildify = untildify;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { PersonalAccessKeyConfigAccount,
|
|
2
|
-
import {
|
|
3
|
-
import { AccessToken } from '../types/Accounts';
|
|
1
|
+
import { PersonalAccessKeyConfigAccount, Environment } from '../types/Accounts.js';
|
|
2
|
+
import { AccessToken } from '../types/Accounts.js';
|
|
4
3
|
export declare function getAccessToken(personalAccessKey: string, env?: Environment, accountId?: number): Promise<AccessToken>;
|
|
5
4
|
export declare function accessTokenForPersonalAccessKey(accountId: number, forceRefresh?: boolean): Promise<string | undefined>;
|
|
6
5
|
export declare function enabledFeaturesForPersonalAccessKey(accountId: number): Promise<{
|
|
7
6
|
[key: string]: number;
|
|
8
7
|
} | undefined>;
|
|
9
8
|
export declare function scopesOnAccessToken(accountId: number): Promise<Array<string>>;
|
|
10
|
-
export declare function authorizedScopesForPortalAndUser(accountId: number): Promise<Array<ScopeGroupAuthorization>>;
|
|
11
9
|
export declare function updateConfigWithAccessToken(token: AccessToken, personalAccessKey: string, env?: Environment, name?: string, makeDefault?: boolean): Promise<PersonalAccessKeyConfigAccount>;
|