@hubspot/cli 6.3.0 → 6.4.0-beta.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/bin/cli.js +2 -0
- package/commands/doctor.d.ts +8 -0
- package/commands/doctor.js +60 -0
- package/commands/init.js +20 -7
- package/commands/lint.d.ts +4 -1
- package/commands/lint.js +11 -2
- package/commands/project/installDeps.js +5 -5
- package/commands/project/logs.js +1 -1
- package/commands/theme/preview.js +38 -20
- package/lang/en.lyaml +68 -0
- package/lib/DevServerManager.js +2 -5
- package/lib/commonOpts.d.ts +3 -2
- package/lib/commonOpts.js +2 -2
- package/lib/dependencyManagement.d.ts +3 -1
- package/lib/dependencyManagement.js +19 -0
- package/lib/doctor/Diagnosis.d.ts +27 -0
- package/lib/doctor/Diagnosis.js +119 -0
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +61 -0
- package/lib/doctor/DiagnosticInfoBuilder.js +158 -0
- package/lib/doctor/Doctor.d.ts +21 -0
- package/lib/doctor/Doctor.js +328 -0
- package/lib/errorHandlers/index.d.ts +14 -1
- package/lib/errorHandlers/index.js +43 -50
- package/lib/errorHandlers/suppressError.d.ts +2 -1
- package/lib/errorHandlers/suppressError.js +32 -37
- package/lib/interpolation.d.ts +3 -0
- package/lib/interpolation.js +4 -3
- package/lib/links.d.ts +9 -0
- package/lib/links.js +99 -97
- package/lib/projects.d.ts +4 -1
- package/lib/projects.js +5 -3
- package/lib/ui/SpinniesManager.d.ts +39 -1
- package/lib/ui/SpinniesManager.js +66 -35
- package/lib/ui/git.d.ts +1 -1
- package/lib/ui/git.js +17 -17
- package/lib/ui/index.d.ts +16 -1
- package/lib/ui/index.js +87 -114
- package/lib/ui/serverlessFunctionLogs.js +28 -19
- package/lib/ui/spinniesUtils.d.ts +31 -0
- package/lib/ui/spinniesUtils.js +45 -31
- package/lib/ui/supportHyperlinks.d.ts +6 -0
- package/lib/ui/supportHyperlinks.js +10 -10
- package/lib/ui/supportsColor.d.ts +16 -0
- package/lib/ui/supportsColor.js +19 -17
- package/lib/ui/table.d.ts +3 -1
- package/lib/ui/table.js +17 -11
- package/lib/usageTracking.d.ts +2 -1
- package/lib/usageTracking.js +2 -0
- package/package.json +10 -5
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// @ts-nocheck
|
|
3
2
|
/*
|
|
4
3
|
https://github.com/jbcarpanelli/spinnies
|
|
5
4
|
|
|
@@ -9,12 +8,30 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
9
8
|
|
|
10
9
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
11
10
|
**/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
12
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const readline_1 = __importDefault(require("readline"));
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const cli_cursor_1 = __importDefault(require("cli-cursor"));
|
|
18
|
+
const spinniesUtils_1 = require("./spinniesUtils");
|
|
19
|
+
function safeColor(text, color) {
|
|
20
|
+
const chalkFn = chalk_1.default[color];
|
|
21
|
+
if (typeof chalkFn === 'function') {
|
|
22
|
+
return chalkFn(text);
|
|
23
|
+
}
|
|
24
|
+
return text;
|
|
25
|
+
}
|
|
17
26
|
class SpinniesManager {
|
|
27
|
+
options;
|
|
28
|
+
spinners = {};
|
|
29
|
+
isCursorHidden = false;
|
|
30
|
+
currentInterval = null;
|
|
31
|
+
stream = process.stderr;
|
|
32
|
+
lineCount = 0;
|
|
33
|
+
currentFrameIndex = 0;
|
|
34
|
+
spin;
|
|
18
35
|
constructor() {
|
|
19
36
|
this.resetState();
|
|
20
37
|
}
|
|
@@ -23,9 +40,9 @@ class SpinniesManager {
|
|
|
23
40
|
spinnerColor: 'greenBright',
|
|
24
41
|
succeedColor: 'green',
|
|
25
42
|
failColor: 'red',
|
|
26
|
-
spinner: terminalSupportsUnicode() ? SPINNERS.dots : SPINNERS.dashes,
|
|
43
|
+
spinner: (0, spinniesUtils_1.terminalSupportsUnicode)() ? spinniesUtils_1.SPINNERS.dots : spinniesUtils_1.SPINNERS.dashes,
|
|
27
44
|
disableSpins: false,
|
|
28
|
-
...purgeSpinnersOptions(options),
|
|
45
|
+
...(0, spinniesUtils_1.purgeSpinnersOptions)(options),
|
|
29
46
|
};
|
|
30
47
|
this.spin =
|
|
31
48
|
!this.options.disableSpins &&
|
|
@@ -50,7 +67,7 @@ class SpinniesManager {
|
|
|
50
67
|
this.currentFrameIndex = 0;
|
|
51
68
|
}
|
|
52
69
|
pick(name) {
|
|
53
|
-
return this.spinners[name];
|
|
70
|
+
return this.spinners?.[name];
|
|
54
71
|
}
|
|
55
72
|
add(name, options = {}) {
|
|
56
73
|
// Support adding generic spinnies lines without specifying a name
|
|
@@ -59,11 +76,11 @@ class SpinniesManager {
|
|
|
59
76
|
options.text = resolvedName;
|
|
60
77
|
}
|
|
61
78
|
const spinnerProperties = {
|
|
62
|
-
...colorOptions(this.options),
|
|
79
|
+
...(0, spinniesUtils_1.colorOptions)(this.options),
|
|
63
80
|
succeedPrefix: this.options.succeedPrefix,
|
|
64
81
|
failPrefix: this.options.failPrefix,
|
|
65
82
|
status: 'spinning',
|
|
66
|
-
...purgeSpinnerOptions(options),
|
|
83
|
+
...(0, spinniesUtils_1.purgeSpinnerOptions)(options),
|
|
67
84
|
};
|
|
68
85
|
this.spinners[resolvedName] = spinnerProperties;
|
|
69
86
|
this.updateSpinnerState();
|
|
@@ -105,7 +122,7 @@ class SpinniesManager {
|
|
|
105
122
|
}
|
|
106
123
|
else {
|
|
107
124
|
this.spinners[name].status = 'stopped';
|
|
108
|
-
this.spinners[name].color = '
|
|
125
|
+
this.spinners[name].color = 'gray';
|
|
109
126
|
}
|
|
110
127
|
}
|
|
111
128
|
});
|
|
@@ -125,16 +142,18 @@ class SpinniesManager {
|
|
|
125
142
|
if (!this.spinners[name]) {
|
|
126
143
|
throw Error(`No spinner initialized with name ${name}`);
|
|
127
144
|
}
|
|
128
|
-
options = purgeSpinnerOptions(options);
|
|
145
|
+
options = (0, spinniesUtils_1.purgeSpinnerOptions)(options);
|
|
129
146
|
status = status || 'spinning';
|
|
130
147
|
this.spinners[name] = { ...this.spinners[name], ...options, status };
|
|
131
148
|
}
|
|
132
149
|
updateSpinnerState() {
|
|
133
150
|
if (this.spin) {
|
|
134
|
-
|
|
151
|
+
if (this.currentInterval) {
|
|
152
|
+
clearInterval(this.currentInterval);
|
|
153
|
+
}
|
|
135
154
|
this.currentInterval = this.loopStream();
|
|
136
155
|
if (!this.isCursorHidden) {
|
|
137
|
-
|
|
156
|
+
cli_cursor_1.default.hide();
|
|
138
157
|
}
|
|
139
158
|
this.isCursorHidden = true;
|
|
140
159
|
this.checkIfActiveSpinners();
|
|
@@ -144,7 +163,8 @@ class SpinniesManager {
|
|
|
144
163
|
}
|
|
145
164
|
}
|
|
146
165
|
loopStream() {
|
|
147
|
-
const
|
|
166
|
+
const frames = this.options.spinner?.frames || spinniesUtils_1.SPINNERS.dots.frames;
|
|
167
|
+
const interval = this.options.spinner?.interval || spinniesUtils_1.SPINNERS.dots.interval;
|
|
148
168
|
return setInterval(() => {
|
|
149
169
|
this.setStreamOutput(frames[this.currentFrameIndex]);
|
|
150
170
|
this.currentFrameIndex =
|
|
@@ -157,45 +177,52 @@ class SpinniesManager {
|
|
|
157
177
|
let output = '';
|
|
158
178
|
const linesLength = [];
|
|
159
179
|
const hasActiveSpinners = this.hasActiveSpinners();
|
|
160
|
-
Object.values(this.spinners).
|
|
180
|
+
Object.values(this.spinners).forEach(spinner => {
|
|
181
|
+
let { text } = spinner;
|
|
182
|
+
const { status, color, spinnerColor, succeedColor, failColor, indent = 0, succeedPrefix = (0, spinniesUtils_1.prefixOptions)(this.options).succeedPrefix, failPrefix = (0, spinniesUtils_1.prefixOptions)(this.options).failPrefix, } = spinner;
|
|
161
183
|
let line;
|
|
162
|
-
let prefixLength = indent
|
|
184
|
+
let prefixLength = indent;
|
|
185
|
+
text = text ?? '';
|
|
163
186
|
if (status === 'spinning') {
|
|
164
187
|
prefixLength += frame.length + 1;
|
|
165
|
-
text = breakText(text, prefixLength);
|
|
166
|
-
|
|
188
|
+
text = (0, spinniesUtils_1.breakText)(text, prefixLength);
|
|
189
|
+
const colorizedFrame = safeColor(frame, spinnerColor);
|
|
190
|
+
const colorizedText = safeColor(text, color);
|
|
191
|
+
line = `${colorizedFrame} ${colorizedText}`;
|
|
167
192
|
}
|
|
168
193
|
else {
|
|
169
194
|
if (status === 'succeed') {
|
|
170
195
|
prefixLength += succeedPrefix.length + 1;
|
|
171
196
|
if (hasActiveSpinners) {
|
|
172
|
-
text = breakText(text, prefixLength);
|
|
197
|
+
text = (0, spinniesUtils_1.breakText)(text, prefixLength);
|
|
173
198
|
}
|
|
174
|
-
|
|
199
|
+
const colorizedText = safeColor(text, succeedColor);
|
|
200
|
+
line = `${chalk_1.default.green(succeedPrefix)} ${colorizedText}`;
|
|
175
201
|
}
|
|
176
202
|
else if (status === 'fail') {
|
|
177
203
|
prefixLength += failPrefix.length + 1;
|
|
178
204
|
if (hasActiveSpinners) {
|
|
179
|
-
text = breakText(text, prefixLength);
|
|
205
|
+
text = (0, spinniesUtils_1.breakText)(text, prefixLength);
|
|
180
206
|
}
|
|
181
|
-
|
|
207
|
+
const colorizedText = safeColor(text, failColor);
|
|
208
|
+
line = `${chalk_1.default.red(failPrefix)} ${colorizedText}`;
|
|
182
209
|
}
|
|
183
210
|
else {
|
|
184
211
|
if (hasActiveSpinners) {
|
|
185
|
-
text = breakText(text, prefixLength);
|
|
212
|
+
text = (0, spinniesUtils_1.breakText)(text, prefixLength);
|
|
186
213
|
}
|
|
187
|
-
line =
|
|
214
|
+
line = safeColor(text, color);
|
|
188
215
|
}
|
|
189
216
|
}
|
|
190
|
-
linesLength.push(...getLinesLength(text, prefixLength));
|
|
217
|
+
linesLength.push(...(0, spinniesUtils_1.getLinesLength)(text, prefixLength));
|
|
191
218
|
output += indent ? `${' '.repeat(indent)}${line}\n` : `${line}\n`;
|
|
192
219
|
});
|
|
193
220
|
if (!hasActiveSpinners) {
|
|
194
|
-
|
|
221
|
+
readline_1.default.clearScreenDown(this.stream);
|
|
195
222
|
}
|
|
196
|
-
writeStream(this.stream, output, linesLength);
|
|
223
|
+
(0, spinniesUtils_1.writeStream)(this.stream, output, linesLength);
|
|
197
224
|
if (hasActiveSpinners) {
|
|
198
|
-
cleanStream(this.stream, linesLength);
|
|
225
|
+
(0, spinniesUtils_1.cleanStream)(this.stream, linesLength);
|
|
199
226
|
}
|
|
200
227
|
this.lineCount = linesLength.length;
|
|
201
228
|
}
|
|
@@ -208,10 +235,12 @@ class SpinniesManager {
|
|
|
208
235
|
if (!this.hasActiveSpinners()) {
|
|
209
236
|
if (this.spin) {
|
|
210
237
|
this.setStreamOutput();
|
|
211
|
-
|
|
212
|
-
|
|
238
|
+
readline_1.default.moveCursor(this.stream, 0, this.lineCount);
|
|
239
|
+
if (this.currentInterval) {
|
|
240
|
+
clearInterval(this.currentInterval);
|
|
241
|
+
}
|
|
213
242
|
this.isCursorHidden = false;
|
|
214
|
-
|
|
243
|
+
cli_cursor_1.default.show();
|
|
215
244
|
}
|
|
216
245
|
this.spinners = {};
|
|
217
246
|
}
|
|
@@ -219,10 +248,12 @@ class SpinniesManager {
|
|
|
219
248
|
bindSigint() {
|
|
220
249
|
process.removeAllListeners('SIGINT');
|
|
221
250
|
process.on('SIGINT', () => {
|
|
222
|
-
|
|
223
|
-
|
|
251
|
+
cli_cursor_1.default.show();
|
|
252
|
+
readline_1.default.moveCursor(process.stderr, 0, this.lineCount);
|
|
224
253
|
process.exit(0);
|
|
225
254
|
});
|
|
226
255
|
}
|
|
227
256
|
}
|
|
228
|
-
|
|
257
|
+
const toExport = new SpinniesManager();
|
|
258
|
+
exports.default = toExport;
|
|
259
|
+
module.exports = toExport;
|
package/lib/ui/git.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function checkAndWarnGitInclusion(configPath: string): void;
|
package/lib/ui/git.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
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
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
exports.checkAndWarnGitInclusion = checkAndWarnGitInclusion;
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const gitignore_1 = require("@hubspot/local-dev-lib/gitignore");
|
|
9
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
|
+
const lang_1 = require("../lang");
|
|
8
11
|
const i18nKey = 'lib.ui.git';
|
|
9
12
|
function checkAndWarnGitInclusion(configPath) {
|
|
10
13
|
try {
|
|
11
|
-
const { inGit, configIgnored } = checkGitInclusion(configPath);
|
|
14
|
+
const { inGit, configIgnored } = (0, gitignore_1.checkGitInclusion)(configPath);
|
|
12
15
|
if (!inGit || configIgnored)
|
|
13
16
|
return;
|
|
14
|
-
logger.warn(i18n(`${i18nKey}.securityIssue`));
|
|
15
|
-
logger.warn(i18n(`${i18nKey}.configFileTracked`));
|
|
16
|
-
logger.warn(i18n(`${i18nKey}.fileName`, { configPath }));
|
|
17
|
-
logger.warn(i18n(`${i18nKey}.remediate`));
|
|
18
|
-
logger.warn(i18n(`${i18nKey}.moveConfig`, { homeDir:
|
|
19
|
-
logger.warn(i18n(`${i18nKey}.addGitignore`, { configPath }));
|
|
20
|
-
logger.warn(i18n(`${i18nKey}.noRemote`));
|
|
17
|
+
logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.securityIssue`));
|
|
18
|
+
logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.configFileTracked`));
|
|
19
|
+
logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.fileName`, { configPath }));
|
|
20
|
+
logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.remediate`));
|
|
21
|
+
logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.moveConfig`, { homeDir: os_1.default.homedir() }));
|
|
22
|
+
logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.addGitignore`, { configPath }));
|
|
23
|
+
logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.noRemote`));
|
|
21
24
|
}
|
|
22
25
|
catch (e) {
|
|
23
26
|
// fail silently
|
|
24
|
-
logger.debug(i18n(`${i18nKey}.checkFailed`));
|
|
27
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.checkFailed`));
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
|
-
module.exports = {
|
|
28
|
-
checkAndWarnGitInclusion,
|
|
29
|
-
};
|
package/lib/ui/index.d.ts
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export declare const UI_COLORS: {
|
|
2
|
+
SORBET: string;
|
|
3
|
+
MARIGOLD: string;
|
|
4
|
+
MARIGOLD_DARK: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function uiLine(): void;
|
|
7
|
+
export declare function uiLink(linkText: string, url: string): string;
|
|
8
|
+
export declare function uiAccountDescription(accountId: number, bold?: boolean): string;
|
|
9
|
+
export declare function uiInfoSection(title: string, logContent: () => void): void;
|
|
10
|
+
export declare function uiCommandReference(command: string): string;
|
|
11
|
+
export declare function uiFeatureHighlight(commands: string[], title: string): void;
|
|
12
|
+
export declare function uiBetaTag(message: string, log?: boolean): void | string;
|
|
13
|
+
export declare function uiDeprecatedTag(message: string): void;
|
|
14
|
+
export declare function uiCommandDisabledBanner(command: string, url?: string, message?: string): void;
|
|
15
|
+
export declare function uiDeprecatedDescription(message: string, command: string, url?: string): void;
|
|
16
|
+
export declare function uiDeprecatedMessage(command: string, url?: string, message?: string): void;
|
package/lib/ui/index.js
CHANGED
|
@@ -1,46 +1,42 @@
|
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
exports.UI_COLORS = void 0;
|
|
7
|
+
exports.uiLine = uiLine;
|
|
8
|
+
exports.uiLink = uiLink;
|
|
9
|
+
exports.uiAccountDescription = uiAccountDescription;
|
|
10
|
+
exports.uiInfoSection = uiInfoSection;
|
|
11
|
+
exports.uiCommandReference = uiCommandReference;
|
|
12
|
+
exports.uiFeatureHighlight = uiFeatureHighlight;
|
|
13
|
+
exports.uiBetaTag = uiBetaTag;
|
|
14
|
+
exports.uiDeprecatedTag = uiDeprecatedTag;
|
|
15
|
+
exports.uiCommandDisabledBanner = uiCommandDisabledBanner;
|
|
16
|
+
exports.uiDeprecatedDescription = uiDeprecatedDescription;
|
|
17
|
+
exports.uiDeprecatedMessage = uiDeprecatedMessage;
|
|
18
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
19
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
20
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
21
|
+
const supportHyperlinks_1 = require("./supportHyperlinks");
|
|
22
|
+
const supportsColor_1 = require("./supportsColor");
|
|
23
|
+
const lang_1 = require("../lang");
|
|
10
24
|
const { HUBSPOT_ACCOUNT_TYPE_STRINGS, } = require('@hubspot/local-dev-lib/constants/config');
|
|
11
|
-
|
|
25
|
+
exports.UI_COLORS = {
|
|
12
26
|
SORBET: '#FF8F59',
|
|
13
27
|
MARIGOLD: '#f5c26b',
|
|
14
28
|
MARIGOLD_DARK: '#dbae60',
|
|
15
29
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
const uiLine = () => {
|
|
22
|
-
logger.log('-'.repeat(50));
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Returns an object that aggregates what the terminal supports (eg. hyperlinks and color)
|
|
26
|
-
*
|
|
27
|
-
* @returns {object}
|
|
28
|
-
*/
|
|
29
|
-
const getTerminalUISupport = () => {
|
|
30
|
+
function uiLine() {
|
|
31
|
+
logger_1.logger.log('-'.repeat(50));
|
|
32
|
+
}
|
|
33
|
+
function getTerminalUISupport() {
|
|
30
34
|
return {
|
|
31
|
-
hyperlinks:
|
|
32
|
-
color: supportsColor.stdout.hasBasic,
|
|
35
|
+
hyperlinks: supportHyperlinks_1.supportsHyperlinkModule.stdout,
|
|
36
|
+
color: supportsColor_1.supportsColor.stdout.hasBasic,
|
|
33
37
|
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
* Returns a hyperlink or link and description
|
|
37
|
-
*
|
|
38
|
-
* @param {string} linkText
|
|
39
|
-
* @param {string} url
|
|
40
|
-
* @param {object} options
|
|
41
|
-
* @returns {string}
|
|
42
|
-
*/
|
|
43
|
-
const uiLink = (linkText, url) => {
|
|
38
|
+
}
|
|
39
|
+
function uiLink(linkText, url) {
|
|
44
40
|
const terminalUISupport = getTerminalUISupport();
|
|
45
41
|
const encodedUrl = encodeURI(url);
|
|
46
42
|
if (terminalUISupport.hyperlinks) {
|
|
@@ -52,124 +48,101 @@ const uiLink = (linkText, url) => {
|
|
|
52
48
|
linkText,
|
|
53
49
|
CLOSE_SEQUENCE,
|
|
54
50
|
].join('');
|
|
55
|
-
return terminalUISupport.color ?
|
|
51
|
+
return terminalUISupport.color ? chalk_1.default.cyan(result) : result;
|
|
56
52
|
}
|
|
57
53
|
return terminalUISupport.color
|
|
58
|
-
? `${linkText}: ${
|
|
54
|
+
? `${linkText}: ${chalk_1.default.reset.cyan(encodedUrl)}`
|
|
59
55
|
: `${linkText}: ${encodedUrl}`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const message = `${account.name} [${HUBSPOT_ACCOUNT_TYPE_STRINGS[account.accountType]}] (${account.portalId})`;
|
|
71
|
-
return bold ? chalk.bold(message) : message;
|
|
72
|
-
};
|
|
73
|
-
const uiInfoSection = (title, logContent) => {
|
|
56
|
+
}
|
|
57
|
+
function uiAccountDescription(accountId, bold = true) {
|
|
58
|
+
const account = (0, config_1.getAccountConfig)(accountId);
|
|
59
|
+
let message;
|
|
60
|
+
if (account && account.accountType) {
|
|
61
|
+
message = `${account.name} [${HUBSPOT_ACCOUNT_TYPE_STRINGS[account.accountType]}] (${accountId})`;
|
|
62
|
+
}
|
|
63
|
+
return bold ? chalk_1.default.bold(message) : message || '';
|
|
64
|
+
}
|
|
65
|
+
function uiInfoSection(title, logContent) {
|
|
74
66
|
uiLine();
|
|
75
|
-
logger.log(
|
|
76
|
-
logger.log('');
|
|
67
|
+
logger_1.logger.log(chalk_1.default.bold(title));
|
|
68
|
+
logger_1.logger.log('');
|
|
77
69
|
logContent();
|
|
78
|
-
logger.log('');
|
|
70
|
+
logger_1.logger.log('');
|
|
79
71
|
uiLine();
|
|
80
|
-
}
|
|
81
|
-
|
|
72
|
+
}
|
|
73
|
+
function uiCommandReference(command) {
|
|
82
74
|
const terminalUISupport = getTerminalUISupport();
|
|
83
75
|
const commandReference = `\`${command}\``;
|
|
84
|
-
return
|
|
85
|
-
?
|
|
76
|
+
return chalk_1.default.bold(terminalUISupport.color
|
|
77
|
+
? chalk_1.default.hex(exports.UI_COLORS.MARIGOLD_DARK)(commandReference)
|
|
86
78
|
: commandReference);
|
|
87
|
-
}
|
|
88
|
-
|
|
79
|
+
}
|
|
80
|
+
function uiFeatureHighlight(commands, title) {
|
|
89
81
|
const i18nKey = 'lib.ui.featureHighlight';
|
|
90
|
-
uiInfoSection(title ? title : i18n(`${i18nKey}.defaultTitle`), () => {
|
|
82
|
+
uiInfoSection(title ? title : (0, lang_1.i18n)(`${i18nKey}.defaultTitle`), () => {
|
|
91
83
|
commands.forEach((c, i) => {
|
|
92
84
|
const commandKey = `${i18nKey}.commandKeys.${c}`;
|
|
93
|
-
const message = i18n(`${commandKey}.message`, {
|
|
94
|
-
command: uiCommandReference(i18n(`${commandKey}.command`)),
|
|
95
|
-
link: uiLink(i18n(`${commandKey}.linkText`), i18n(`${commandKey}.url`)),
|
|
85
|
+
const message = (0, lang_1.i18n)(`${commandKey}.message`, {
|
|
86
|
+
command: uiCommandReference((0, lang_1.i18n)(`${commandKey}.command`)),
|
|
87
|
+
link: uiLink((0, lang_1.i18n)(`${commandKey}.linkText`), (0, lang_1.i18n)(`${commandKey}.url`)),
|
|
96
88
|
});
|
|
97
89
|
if (i !== 0) {
|
|
98
|
-
logger.log('');
|
|
90
|
+
logger_1.logger.log('');
|
|
99
91
|
}
|
|
100
|
-
logger.log(message);
|
|
92
|
+
logger_1.logger.log(message);
|
|
101
93
|
});
|
|
102
94
|
});
|
|
103
|
-
}
|
|
104
|
-
|
|
95
|
+
}
|
|
96
|
+
function uiBetaTag(message, log = true) {
|
|
105
97
|
const i18nKey = 'lib.ui';
|
|
106
98
|
const terminalUISupport = getTerminalUISupport();
|
|
107
|
-
const tag = i18n(`${i18nKey}.betaTag`);
|
|
108
|
-
const result = `${terminalUISupport.color ?
|
|
99
|
+
const tag = (0, lang_1.i18n)(`${i18nKey}.betaTag`);
|
|
100
|
+
const result = `${terminalUISupport.color ? chalk_1.default.hex(exports.UI_COLORS.SORBET)(tag) : tag} ${message}`;
|
|
109
101
|
if (log) {
|
|
110
|
-
logger.log(result);
|
|
102
|
+
logger_1.logger.log(result);
|
|
111
103
|
}
|
|
112
104
|
else {
|
|
113
105
|
return result;
|
|
114
106
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
107
|
+
}
|
|
108
|
+
function uiDeprecatedTag(message) {
|
|
117
109
|
const i18nKey = 'lib.ui';
|
|
118
110
|
const terminalUISupport = getTerminalUISupport();
|
|
119
|
-
const tag = i18n(`${i18nKey}.deprecatedTag`);
|
|
120
|
-
const result = `${terminalUISupport.color ?
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
else {
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
const uiCommandDisabledBanner = (command, url = undefined, message = undefined) => {
|
|
111
|
+
const tag = (0, lang_1.i18n)(`${i18nKey}.deprecatedTag`);
|
|
112
|
+
const result = `${terminalUISupport.color ? chalk_1.default.yellow(tag) : tag} ${message}`;
|
|
113
|
+
logger_1.logger.log(result);
|
|
114
|
+
}
|
|
115
|
+
function uiCommandDisabledBanner(command, url, message) {
|
|
129
116
|
const i18nKey = 'lib.ui';
|
|
130
117
|
const tag = message ||
|
|
131
|
-
i18n(`${i18nKey}.disabledMessage`, {
|
|
118
|
+
(0, lang_1.i18n)(`${i18nKey}.disabledMessage`, {
|
|
132
119
|
command: uiCommandReference(command),
|
|
133
|
-
url: url ? uiLink(i18n(`${i18nKey}.disabledUrlText`), url) :
|
|
120
|
+
url: url ? uiLink((0, lang_1.i18n)(`${i18nKey}.disabledUrlText`), url) : '',
|
|
134
121
|
npmCommand: uiCommandReference('npm i -g @hubspot/cli@latest'),
|
|
135
122
|
});
|
|
136
|
-
logger.log();
|
|
123
|
+
logger_1.logger.log();
|
|
137
124
|
uiLine();
|
|
138
|
-
logger.error(tag);
|
|
125
|
+
logger_1.logger.error(tag);
|
|
139
126
|
uiLine();
|
|
140
|
-
logger.log();
|
|
141
|
-
}
|
|
142
|
-
|
|
127
|
+
logger_1.logger.log();
|
|
128
|
+
}
|
|
129
|
+
function uiDeprecatedDescription(message, command, url) {
|
|
143
130
|
const i18nKey = 'lib.ui';
|
|
144
|
-
const tag = i18n(`${i18nKey}.deprecatedDescription`, {
|
|
131
|
+
const tag = (0, lang_1.i18n)(`${i18nKey}.deprecatedDescription`, {
|
|
145
132
|
message,
|
|
146
133
|
command: uiCommandReference(command),
|
|
147
|
-
url,
|
|
134
|
+
url: url ? uiLink((0, lang_1.i18n)(`${i18nKey}.deprecatedUrlText`), url) : '',
|
|
148
135
|
});
|
|
149
|
-
return uiDeprecatedTag(tag
|
|
150
|
-
}
|
|
151
|
-
|
|
136
|
+
return uiDeprecatedTag(tag);
|
|
137
|
+
}
|
|
138
|
+
function uiDeprecatedMessage(command, url, message) {
|
|
152
139
|
const i18nKey = 'lib.ui';
|
|
153
140
|
const tag = message ||
|
|
154
|
-
i18n(`${i18nKey}.deprecatedMessage`, {
|
|
141
|
+
(0, lang_1.i18n)(`${i18nKey}.deprecatedMessage`, {
|
|
155
142
|
command: uiCommandReference(command),
|
|
156
|
-
url: url ? uiLink(i18n(`${i18nKey}.deprecatedUrlText`), url) :
|
|
143
|
+
url: url ? uiLink((0, lang_1.i18n)(`${i18nKey}.deprecatedUrlText`), url) : '',
|
|
157
144
|
});
|
|
158
|
-
logger.log();
|
|
159
|
-
uiDeprecatedTag(tag
|
|
160
|
-
logger.log();
|
|
161
|
-
}
|
|
162
|
-
module.exports = {
|
|
163
|
-
UI_COLORS,
|
|
164
|
-
uiAccountDescription,
|
|
165
|
-
uiCommandReference,
|
|
166
|
-
uiBetaTag,
|
|
167
|
-
uiDeprecatedTag,
|
|
168
|
-
uiFeatureHighlight,
|
|
169
|
-
uiInfoSection,
|
|
170
|
-
uiLine,
|
|
171
|
-
uiLink,
|
|
172
|
-
uiDeprecatedMessage,
|
|
173
|
-
uiDeprecatedDescription,
|
|
174
|
-
uiCommandDisabledBanner,
|
|
175
|
-
};
|
|
145
|
+
logger_1.logger.log();
|
|
146
|
+
uiDeprecatedTag(tag);
|
|
147
|
+
logger_1.logger.log();
|
|
148
|
+
}
|
|
@@ -1,17 +1,19 @@
|
|
|
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
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const { i18n } = require('../lang');
|
|
6
|
+
const moment_1 = __importDefault(require("moment"));
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
9
|
+
const lang_1 = require("../lang");
|
|
8
10
|
const i18nKey = 'lib.ui.serverlessFunctionLogs';
|
|
9
11
|
const SEPARATOR = ' - ';
|
|
10
12
|
const LOG_STATUS_COLORS = {
|
|
11
|
-
SUCCESS: Styles.success,
|
|
12
|
-
ERROR: Styles.error,
|
|
13
|
-
UNHANDLED_ERROR: Styles.error,
|
|
14
|
-
HANDLED_ERROR: Styles.error,
|
|
13
|
+
SUCCESS: logger_1.Styles.success,
|
|
14
|
+
ERROR: logger_1.Styles.error,
|
|
15
|
+
UNHANDLED_ERROR: logger_1.Styles.error,
|
|
16
|
+
HANDLED_ERROR: logger_1.Styles.error,
|
|
15
17
|
};
|
|
16
18
|
function errorHandler(log, options) {
|
|
17
19
|
return `${formatLogHeader(log, options)}${formatError(log, options)}`;
|
|
@@ -42,7 +44,7 @@ function formatLogHeader(log, options) {
|
|
|
42
44
|
return `${formatTimestamp(log)}${SEPARATOR}${color(log.status)}${headerInsertion ? `${SEPARATOR}${headerInsertion}` : ''}${SEPARATOR}${formatExecutionTime(log)}`;
|
|
43
45
|
}
|
|
44
46
|
function formatStackTrace(log) {
|
|
45
|
-
const stackTrace =
|
|
47
|
+
const stackTrace = log.error?.stackTrace || [];
|
|
46
48
|
return stackTrace
|
|
47
49
|
.map(trace => {
|
|
48
50
|
return ` at ${trace}\n`;
|
|
@@ -50,28 +52,35 @@ function formatStackTrace(log) {
|
|
|
50
52
|
.join('');
|
|
51
53
|
}
|
|
52
54
|
function formatTimestamp(log) {
|
|
53
|
-
return `${
|
|
55
|
+
return `${chalk_1.default.whiteBright((0, moment_1.default)(log.createdAt).toISOString())}`;
|
|
54
56
|
}
|
|
55
57
|
function formatExecutionTime(log) {
|
|
56
|
-
return `${
|
|
58
|
+
return `${chalk_1.default.whiteBright('Execution Time:')} ${log.executionTime}ms`;
|
|
57
59
|
}
|
|
58
60
|
function processLog(log, options) {
|
|
59
61
|
try {
|
|
60
62
|
return logHandler[log.status](log, options);
|
|
61
63
|
}
|
|
62
64
|
catch (e) {
|
|
63
|
-
logger.error(i18n(`${i18nKey}.unableToProcessLog`, {
|
|
65
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.unableToProcessLog`, {
|
|
64
66
|
log: JSON.stringify(log),
|
|
65
67
|
}));
|
|
66
68
|
}
|
|
67
69
|
}
|
|
70
|
+
function isLogsResponse(logsResp) {
|
|
71
|
+
return (logsResp &&
|
|
72
|
+
'results' in logsResp &&
|
|
73
|
+
Array.isArray(logsResp.results) &&
|
|
74
|
+
logsResp.results !== undefined);
|
|
75
|
+
}
|
|
68
76
|
function processLogs(logsResp, options) {
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
const isLogsResp = isLogsResponse(logsResp);
|
|
78
|
+
if (!logsResp || (isLogsResp && logsResp.results.length === 0)) {
|
|
79
|
+
return (0, lang_1.i18n)(`${i18nKey}.noLogsFound`);
|
|
71
80
|
}
|
|
72
|
-
else if (
|
|
73
|
-
return logsResp
|
|
74
|
-
.map(log => {
|
|
81
|
+
else if (isLogsResp) {
|
|
82
|
+
return logsResp
|
|
83
|
+
.results.map(log => {
|
|
75
84
|
return processLog(log, options);
|
|
76
85
|
})
|
|
77
86
|
.join('\n');
|
|
@@ -79,7 +88,7 @@ function processLogs(logsResp, options) {
|
|
|
79
88
|
return processLog(logsResp, options);
|
|
80
89
|
}
|
|
81
90
|
function outputLogs(logsResp, options) {
|
|
82
|
-
logger.log(processLogs(logsResp, options));
|
|
91
|
+
logger_1.logger.log(processLogs(logsResp, options));
|
|
83
92
|
}
|
|
84
93
|
module.exports = {
|
|
85
94
|
outputLogs,
|