@hubspot/cli 8.3.1-experimental.1 → 8.3.1-experimental.2
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/lang/en.d.ts +6 -0
- package/lang/en.js +6 -0
- package/lib/app/logSystemTypes.d.ts +4 -0
- package/lib/app/logSystemTypes.js +17 -0
- package/lib/app/logs.d.ts +2 -4
- package/lib/app/logs.js +2 -17
- package/lib/crossPlatformSpawn/escape.d.ts +2 -0
- package/lib/crossPlatformSpawn/escape.js +38 -0
- package/lib/crossPlatformSpawn/index.d.ts +7 -0
- package/lib/crossPlatformSpawn/index.js +43 -0
- package/lib/crossPlatformSpawn/resolveCommand.d.ts +1 -0
- package/lib/crossPlatformSpawn/resolveCommand.js +69 -0
- package/lib/ui/appLogs.js +1 -1
- package/lib/ui/formatting.d.ts +13 -0
- package/lib/ui/formatting.js +39 -0
- package/lib/ui/index.d.ts +1 -13
- package/lib/ui/index.js +2 -38
- package/lib/ui/uiMessages.js +1 -1
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +1 -1
- package/mcp-server/tools/cms/HsListTool.js +4 -1
- package/mcp-server/utils/command.js +18 -26
- package/package.json +1 -3
package/lang/en.d.ts
CHANGED
|
@@ -3437,6 +3437,12 @@ export declare const lib: {
|
|
|
3437
3437
|
process: {
|
|
3438
3438
|
exitDebug: (signal: string) => string;
|
|
3439
3439
|
};
|
|
3440
|
+
hubSpotCommand: {
|
|
3441
|
+
argStartsWithDash: (arg: string) => string;
|
|
3442
|
+
};
|
|
3443
|
+
crossPlatformSpawn: {
|
|
3444
|
+
unsafeArg: (arg: string) => string;
|
|
3445
|
+
};
|
|
3440
3446
|
handlerLogFile: {
|
|
3441
3447
|
saved: (filePath: string) => string;
|
|
3442
3448
|
};
|
package/lang/en.js
CHANGED
|
@@ -3489,6 +3489,12 @@ export const lib = {
|
|
|
3489
3489
|
process: {
|
|
3490
3490
|
exitDebug: (signal) => `Attempting to gracefully exit. Triggered by ${signal}`,
|
|
3491
3491
|
},
|
|
3492
|
+
hubSpotCommand: {
|
|
3493
|
+
argStartsWithDash: (arg) => `Cannot pass ${JSON.stringify(arg)} as a positional argument because it starts with a dash and would be read as a flag. Remove the leading dash and try again.`,
|
|
3494
|
+
},
|
|
3495
|
+
crossPlatformSpawn: {
|
|
3496
|
+
unsafeArg: (arg) => `Cannot run this command on Windows because an argument contains a line break, contains one of these characters: " % ^ & | < >, or ends with two or more backslashes. Remove or rephrase them and try again. Argument: ${JSON.stringify(arg)}`,
|
|
3497
|
+
},
|
|
3492
3498
|
handlerLogFile: {
|
|
3493
3499
|
saved: (filePath) => `Debug logs can be viewed at ${filePath}`,
|
|
3494
3500
|
},
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const SYSTEM_TYPE_DISPLAY_NAMES = {
|
|
2
|
+
WEBHOOKS: 'Webhooks',
|
|
3
|
+
API_CALL: 'API Call',
|
|
4
|
+
SERVERLESS_EXECUTION: 'Serverless Function',
|
|
5
|
+
CRM_EXTENSIBILITY_CARD: 'CRM Card',
|
|
6
|
+
CRM_LEGACY_CARD: 'CRM Legacy Card',
|
|
7
|
+
EXTENSION_LOG: 'Extension Log',
|
|
8
|
+
EXTENSION_RENDER: 'Extension Render',
|
|
9
|
+
APP_SETTINGS: 'App Settings',
|
|
10
|
+
PROXY_EXECUTION: 'Proxy Execution',
|
|
11
|
+
SERVERLESS_GATEWAY_EXECUTION: 'Serverless Gateway Execution',
|
|
12
|
+
ACCEPTANCE_TEST: 'Acceptance Test',
|
|
13
|
+
OAUTH_AUTHORIZATION: 'OAuth Authorization',
|
|
14
|
+
};
|
|
15
|
+
export function toTypeChoice(systemType) {
|
|
16
|
+
return systemType.toLowerCase().replaceAll('_', '-');
|
|
17
|
+
}
|
package/lib/app/logs.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AppLogEntry as ApiAppLogEntry, SystemType } from '@hubspot/local-dev-lib/types/AppLogs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
2
|
+
import { SYSTEM_TYPE_DISPLAY_NAMES, toTypeChoice } from './logSystemTypes.js';
|
|
3
|
+
export { SYSTEM_TYPE_DISPLAY_NAMES, toTypeChoice };
|
|
5
4
|
export declare const SYSTEM_TYPE_CHOICES: string[];
|
|
6
5
|
export declare function parseSinceTime(sinceInput: string): {
|
|
7
6
|
startTime: number;
|
|
@@ -24,7 +23,6 @@ export type AppLogsOptions = {
|
|
|
24
23
|
limit?: number;
|
|
25
24
|
errorsOnly?: boolean;
|
|
26
25
|
};
|
|
27
|
-
export declare function toTypeChoice(systemType: string): string;
|
|
28
26
|
export declare function toSystemType(choice: string): string;
|
|
29
27
|
export declare function getTypeChoices(): {
|
|
30
28
|
name: string;
|
package/lib/app/logs.js
CHANGED
|
@@ -5,20 +5,8 @@ import { uiLogger } from '../ui/logger.js';
|
|
|
5
5
|
import SpinniesManager from '../ui/SpinniesManager.js';
|
|
6
6
|
import { handleExit, handleKeypress } from '../process.js';
|
|
7
7
|
import { commands } from '../../lang/en.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
API_CALL: 'API Call',
|
|
11
|
-
SERVERLESS_EXECUTION: 'Serverless Function',
|
|
12
|
-
CRM_EXTENSIBILITY_CARD: 'CRM Card',
|
|
13
|
-
CRM_LEGACY_CARD: 'CRM Legacy Card',
|
|
14
|
-
EXTENSION_LOG: 'Extension Log',
|
|
15
|
-
EXTENSION_RENDER: 'Extension Render',
|
|
16
|
-
APP_SETTINGS: 'App Settings',
|
|
17
|
-
PROXY_EXECUTION: 'Proxy Execution',
|
|
18
|
-
SERVERLESS_GATEWAY_EXECUTION: 'Serverless Gateway Execution',
|
|
19
|
-
ACCEPTANCE_TEST: 'Acceptance Test',
|
|
20
|
-
OAUTH_AUTHORIZATION: 'OAuth Authorization',
|
|
21
|
-
};
|
|
8
|
+
import { SYSTEM_TYPE_DISPLAY_NAMES, toTypeChoice } from './logSystemTypes.js';
|
|
9
|
+
export { SYSTEM_TYPE_DISPLAY_NAMES, toTypeChoice };
|
|
22
10
|
export const SYSTEM_TYPE_CHOICES = Object.keys(SYSTEM_TYPE_DISPLAY_NAMES).map(toTypeChoice);
|
|
23
11
|
export function parseSinceTime(sinceInput) {
|
|
24
12
|
const now = moment();
|
|
@@ -68,9 +56,6 @@ export function transformApiLogEntry(apiLog) {
|
|
|
68
56
|
};
|
|
69
57
|
}
|
|
70
58
|
const TAIL_DELAY = 5000;
|
|
71
|
-
export function toTypeChoice(systemType) {
|
|
72
|
-
return systemType.toLowerCase().replaceAll('_', '-');
|
|
73
|
-
}
|
|
74
59
|
export function toSystemType(choice) {
|
|
75
60
|
return choice.toUpperCase().replaceAll('-', '_');
|
|
76
61
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Adapted from cross-spawn 7.0.6 (lib/util/escape.js)
|
|
3
|
+
* https://github.com/moxystudio/node-cross-spawn
|
|
4
|
+
*
|
|
5
|
+
* The MIT License (MIT)
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2018 Made With MOXY Lda <hello@moxy.studio>
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in
|
|
17
|
+
* all copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
+
* THE SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
const META_CHARS_PATTERN = /([()\][%!^"`<>&|;, *?])/g;
|
|
28
|
+
const BACKSLASHES_BEFORE_QUOTE_PATTERN = /(?=(\\+?)?)\1"/g;
|
|
29
|
+
const TRAILING_BACKSLASHES_PATTERN = /(?=(\\+?)?)\1$/;
|
|
30
|
+
export function escapeMetaCharacters(value) {
|
|
31
|
+
return value.replace(META_CHARS_PATTERN, '^$1');
|
|
32
|
+
}
|
|
33
|
+
export function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
34
|
+
const quotesEscaped = arg.replace(BACKSLASHES_BEFORE_QUOTE_PATTERN, '$1$1\\"');
|
|
35
|
+
const trailingEscaped = quotesEscaped.replace(TRAILING_BACKSLASHES_PATTERN, '$1$1');
|
|
36
|
+
const escaped = escapeMetaCharacters(`"${trailingEscaped}"`);
|
|
37
|
+
return doubleEscapeMetaChars ? escapeMetaCharacters(escaped) : escaped;
|
|
38
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
|
+
type CrossPlatformSpawnOptions = {
|
|
3
|
+
cwd: string;
|
|
4
|
+
env: NodeJS.ProcessEnv;
|
|
5
|
+
};
|
|
6
|
+
export declare function crossPlatformSpawn(command: string, args: string[], options: CrossPlatformSpawnOptions): ChildProcessWithoutNullStreams;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Adapted from cross-spawn 7.0.6 (index.js and lib/parse.js)
|
|
3
|
+
* https://github.com/moxystudio/node-cross-spawn
|
|
4
|
+
* The cross-spawn license is reproduced in escape.ts.
|
|
5
|
+
*/
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { spawn } from 'node:child_process';
|
|
8
|
+
import { lib } from '../../lang/en.js';
|
|
9
|
+
import { escapeArgument, escapeMetaCharacters } from './escape.js';
|
|
10
|
+
import { resolveCommand } from './resolveCommand.js';
|
|
11
|
+
const DEFAULT_SHELL = 'cmd.exe';
|
|
12
|
+
const SKIP_CURRENT_DIRECTORY_ENV_VAR = 'NoDefaultCurrentDirectoryInExePath';
|
|
13
|
+
const CMD_SHIM_PATTERN = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
14
|
+
const UNSAFE_ARG_PATTERN = /["%^&|<>\r\n]/;
|
|
15
|
+
const TRAILING_BACKSLASHES = '\\\\';
|
|
16
|
+
function isUnsafeArg(arg) {
|
|
17
|
+
return UNSAFE_ARG_PATTERN.test(arg) || arg.endsWith(TRAILING_BACKSLASHES);
|
|
18
|
+
}
|
|
19
|
+
function assertArgsAreSafe(args) {
|
|
20
|
+
const unsafeArg = args.find(isUnsafeArg);
|
|
21
|
+
if (unsafeArg !== undefined) {
|
|
22
|
+
throw new Error(lib.crossPlatformSpawn.unsafeArg(unsafeArg));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function buildShellLine(command, args, env) {
|
|
26
|
+
const file = resolveCommand(command, env);
|
|
27
|
+
const doubleEscapeMetaChars = file !== undefined && CMD_SHIM_PATTERN.test(file);
|
|
28
|
+
return [
|
|
29
|
+
escapeMetaCharacters(path.win32.normalize(command)),
|
|
30
|
+
...args.map(arg => escapeArgument(arg, doubleEscapeMetaChars)),
|
|
31
|
+
].join(' ');
|
|
32
|
+
}
|
|
33
|
+
export function crossPlatformSpawn(command, args, options) {
|
|
34
|
+
if (process.platform !== 'win32') {
|
|
35
|
+
return spawn(command, args, options);
|
|
36
|
+
}
|
|
37
|
+
assertArgsAreSafe(args);
|
|
38
|
+
return spawn(process.env.comspec || DEFAULT_SHELL, ['/d', '/s', '/c', `"${buildShellLine(command, args, options.env)}"`], {
|
|
39
|
+
...options,
|
|
40
|
+
env: { ...options.env, [SKIP_CURRENT_DIRECTORY_ENV_VAR]: '1' },
|
|
41
|
+
windowsVerbatimArguments: true,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveCommand(command: string, env: NodeJS.ProcessEnv): string | undefined;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Adapted from cross-spawn 7.0.6 (lib/util/resolveCommand.js), whose
|
|
3
|
+
* license is reproduced in escape.ts, and from the packages below.
|
|
4
|
+
*
|
|
5
|
+
* which 2.0.2 (which.js) and isexe 2.0.0 (windows.js)
|
|
6
|
+
* https://github.com/isaacs/node-which
|
|
7
|
+
* https://github.com/isaacs/isexe
|
|
8
|
+
*
|
|
9
|
+
* The ISC License
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) Isaac Z. Schlueter and Contributors
|
|
12
|
+
*
|
|
13
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
15
|
+
* copyright notice and this permission notice appear in all copies.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
18
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
19
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
20
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
21
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
22
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
23
|
+
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
24
|
+
*
|
|
25
|
+
* path-key 3.1.1 (index.js)
|
|
26
|
+
* https://github.com/sindresorhus/path-key
|
|
27
|
+
*
|
|
28
|
+
* MIT License
|
|
29
|
+
*
|
|
30
|
+
* Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
31
|
+
*
|
|
32
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
33
|
+
*
|
|
34
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
35
|
+
*
|
|
36
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
37
|
+
*/
|
|
38
|
+
import fs from 'fs';
|
|
39
|
+
import path from 'path';
|
|
40
|
+
const PATH_DELIMITER = ';';
|
|
41
|
+
const DEFAULT_PATH_EXT = '.EXE;.CMD;.BAT;.COM';
|
|
42
|
+
const QUOTED_PATH_PATTERN = /^".*"$/;
|
|
43
|
+
function getPathKey(env) {
|
|
44
|
+
return (Object.keys(env)
|
|
45
|
+
.reverse()
|
|
46
|
+
.find(key => key.toUpperCase() === 'PATH') || 'Path');
|
|
47
|
+
}
|
|
48
|
+
function unquote(directory) {
|
|
49
|
+
return QUOTED_PATH_PATTERN.test(directory)
|
|
50
|
+
? directory.slice(1, -1)
|
|
51
|
+
: directory;
|
|
52
|
+
}
|
|
53
|
+
function isFile(filePath) {
|
|
54
|
+
try {
|
|
55
|
+
return fs.statSync(filePath).isFile();
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function resolveCommand(command, env) {
|
|
62
|
+
const directories = (env[getPathKey(env)] || process.env.PATH || '')
|
|
63
|
+
.split(PATH_DELIMITER)
|
|
64
|
+
.map(unquote);
|
|
65
|
+
const extensions = (process.env.PATHEXT || DEFAULT_PATH_EXT).split(PATH_DELIMITER);
|
|
66
|
+
return directories
|
|
67
|
+
.flatMap(directory => extensions.map(extension => path.win32.join(directory, command + extension)))
|
|
68
|
+
.find(isFile);
|
|
69
|
+
}
|
package/lib/ui/appLogs.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Styles } from '@hubspot/local-dev-lib/logger';
|
|
|
4
4
|
import { uiLogger } from './logger.js';
|
|
5
5
|
import { indent, logUiLine } from './index.js';
|
|
6
6
|
import { commands } from '../../lang/en.js';
|
|
7
|
-
import { SYSTEM_TYPE_DISPLAY_NAMES, toTypeChoice } from '../app/
|
|
7
|
+
import { SYSTEM_TYPE_DISPLAY_NAMES, toTypeChoice, } from '../app/logSystemTypes.js';
|
|
8
8
|
import { getAppLogDetailsUrl, getAppLogsUrl } from '../app/urls.js';
|
|
9
9
|
import { renderTable } from '../../ui/render.js';
|
|
10
10
|
const SEPARATOR = ' - ';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type TerminalSupport = {
|
|
2
|
+
hyperlinks: boolean;
|
|
3
|
+
color: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const UI_COLORS: {
|
|
6
|
+
SORBET: string;
|
|
7
|
+
MARIGOLD: string;
|
|
8
|
+
MARIGOLD_DARK: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function getTerminalUISupport(): TerminalSupport;
|
|
11
|
+
export declare function uiLink(linkText: string, url: string): string;
|
|
12
|
+
export declare function uiCommandReference(command: string, withQuotes?: boolean): string;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { supportsHyperlinkModule } from './supportHyperlinks.js';
|
|
3
|
+
import { isColorEnabled } from './supportsColor.js';
|
|
4
|
+
export const UI_COLORS = {
|
|
5
|
+
SORBET: '#FF8F59',
|
|
6
|
+
MARIGOLD: '#f5c26b',
|
|
7
|
+
MARIGOLD_DARK: '#dbae60',
|
|
8
|
+
};
|
|
9
|
+
export function getTerminalUISupport() {
|
|
10
|
+
return {
|
|
11
|
+
hyperlinks: supportsHyperlinkModule.stdout,
|
|
12
|
+
color: isColorEnabled(),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function uiLink(linkText, url) {
|
|
16
|
+
const terminalUISupport = getTerminalUISupport();
|
|
17
|
+
const encodedUrl = encodeURI(url);
|
|
18
|
+
if (terminalUISupport.hyperlinks) {
|
|
19
|
+
const CLOSE_SEQUENCE = '\u001B]8;;\u0007';
|
|
20
|
+
const result = [
|
|
21
|
+
'\u001B]8;;',
|
|
22
|
+
encodedUrl,
|
|
23
|
+
'\u0007',
|
|
24
|
+
linkText,
|
|
25
|
+
CLOSE_SEQUENCE,
|
|
26
|
+
].join('');
|
|
27
|
+
return terminalUISupport.color ? chalk.cyan(result) : result;
|
|
28
|
+
}
|
|
29
|
+
return terminalUISupport.color
|
|
30
|
+
? `${linkText}: ${chalk.reset.cyan(encodedUrl)}`
|
|
31
|
+
: `${linkText}: ${encodedUrl}`;
|
|
32
|
+
}
|
|
33
|
+
export function uiCommandReference(command, withQuotes = true) {
|
|
34
|
+
const terminalUISupport = getTerminalUISupport();
|
|
35
|
+
const commandReference = withQuotes ? `\`${command}\`` : command;
|
|
36
|
+
return chalk.bold(terminalUISupport.color
|
|
37
|
+
? chalk.hex(UI_COLORS.MARIGOLD_DARK)(commandReference)
|
|
38
|
+
: commandReference);
|
|
39
|
+
}
|
package/lib/ui/index.d.ts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
hyperlinks: boolean;
|
|
3
|
-
color: boolean;
|
|
4
|
-
};
|
|
5
|
-
export declare const UI_COLORS: {
|
|
6
|
-
SORBET: string;
|
|
7
|
-
MARIGOLD: string;
|
|
8
|
-
MARIGOLD_DARK: string;
|
|
9
|
-
};
|
|
1
|
+
export { getTerminalUISupport, UI_COLORS, uiCommandReference, uiLink, } from './formatting.js';
|
|
10
2
|
export declare function logUiLine(): void;
|
|
11
|
-
export declare function getTerminalUISupport(): TerminalSupport;
|
|
12
|
-
export declare function uiLink(linkText: string, url: string): string;
|
|
13
3
|
export declare function uiAccountDescription(accountId?: number | null, bold?: boolean): string;
|
|
14
4
|
export declare function logUiInfoSection(title: string, logContent: () => void): void;
|
|
15
|
-
export declare function uiCommandReference(command: string, withQuotes?: boolean): string;
|
|
16
5
|
export declare function uiAuthCommandReference({ accountId, qa, }?: {
|
|
17
6
|
accountId?: number | string;
|
|
18
7
|
qa?: boolean;
|
|
@@ -26,4 +15,3 @@ export declare function uiCommandRenamedDescription(describe: string | false | u
|
|
|
26
15
|
export declare function logUiDeprecatedMessage(command: string, url?: string, message?: string): void;
|
|
27
16
|
export declare function logUiCommandRelocatedMessage(newCommand: string): void;
|
|
28
17
|
export declare function indent(level: number): string;
|
|
29
|
-
export {};
|
package/lib/ui/index.js
CHANGED
|
@@ -1,42 +1,13 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { getConfigAccountIfExists, globalConfigFileExists, } from '@hubspot/local-dev-lib/config';
|
|
3
3
|
import { uiLogger } from './logger.js';
|
|
4
|
-
import { supportsHyperlinkModule } from './supportHyperlinks.js';
|
|
5
|
-
import { isColorEnabled } from './supportsColor.js';
|
|
6
4
|
import { uiMessages } from './uiMessages.js';
|
|
5
|
+
import { uiCommandReference, uiLink } from './formatting.js';
|
|
7
6
|
import { HUBSPOT_ACCOUNT_TYPE_STRINGS } from '@hubspot/local-dev-lib/constants/config';
|
|
8
|
-
export
|
|
9
|
-
SORBET: '#FF8F59',
|
|
10
|
-
MARIGOLD: '#f5c26b',
|
|
11
|
-
MARIGOLD_DARK: '#dbae60',
|
|
12
|
-
};
|
|
7
|
+
export { getTerminalUISupport, UI_COLORS, uiCommandReference, uiLink, } from './formatting.js';
|
|
13
8
|
export function logUiLine() {
|
|
14
9
|
uiLogger.log('-'.repeat(50));
|
|
15
10
|
}
|
|
16
|
-
export function getTerminalUISupport() {
|
|
17
|
-
return {
|
|
18
|
-
hyperlinks: supportsHyperlinkModule.stdout,
|
|
19
|
-
color: isColorEnabled(),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export function uiLink(linkText, url) {
|
|
23
|
-
const terminalUISupport = getTerminalUISupport();
|
|
24
|
-
const encodedUrl = encodeURI(url);
|
|
25
|
-
if (terminalUISupport.hyperlinks) {
|
|
26
|
-
const CLOSE_SEQUENCE = '\u001B]8;;\u0007';
|
|
27
|
-
const result = [
|
|
28
|
-
'\u001B]8;;',
|
|
29
|
-
encodedUrl,
|
|
30
|
-
'\u0007',
|
|
31
|
-
linkText,
|
|
32
|
-
CLOSE_SEQUENCE,
|
|
33
|
-
].join('');
|
|
34
|
-
return terminalUISupport.color ? chalk.cyan(result) : result;
|
|
35
|
-
}
|
|
36
|
-
return terminalUISupport.color
|
|
37
|
-
? `${linkText}: ${chalk.reset.cyan(encodedUrl)}`
|
|
38
|
-
: `${linkText}: ${encodedUrl}`;
|
|
39
|
-
}
|
|
40
11
|
export function uiAccountDescription(accountId, bold = true) {
|
|
41
12
|
const account = accountId ? getConfigAccountIfExists(accountId) : undefined;
|
|
42
13
|
let message;
|
|
@@ -59,13 +30,6 @@ export function logUiInfoSection(title, logContent) {
|
|
|
59
30
|
uiLogger.log('');
|
|
60
31
|
logUiLine();
|
|
61
32
|
}
|
|
62
|
-
export function uiCommandReference(command, withQuotes = true) {
|
|
63
|
-
const terminalUISupport = getTerminalUISupport();
|
|
64
|
-
const commandReference = withQuotes ? `\`${command}\`` : command;
|
|
65
|
-
return chalk.bold(terminalUISupport.color
|
|
66
|
-
? chalk.hex(UI_COLORS.MARIGOLD_DARK)(commandReference)
|
|
67
|
-
: commandReference);
|
|
68
|
-
}
|
|
69
33
|
export function uiAuthCommandReference({ accountId, qa, } = {}) {
|
|
70
34
|
const userIsUsingGlobalConfig = globalConfigFileExists();
|
|
71
35
|
let command = 'hs auth';
|
package/lib/ui/uiMessages.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// UI messages for the UI module - separate file to avoid circular imports with lang/en.ts
|
|
2
2
|
// This contains the same strings that would be in lib.ui.* from lang/en.ts
|
|
3
|
-
import { uiCommandReference, uiLink } from './
|
|
3
|
+
import { uiCommandReference, uiLink } from './formatting.js';
|
|
4
4
|
export const uiMessages = {
|
|
5
5
|
betaTag: '[BETA]',
|
|
6
6
|
deprecatedTag: '[DEPRECATED]',
|
|
@@ -91,7 +91,7 @@ export class HsFunctionLogsTool extends Tool {
|
|
|
91
91
|
const normalizedEndpoint = resolvedEndpoint.startsWith('/')
|
|
92
92
|
? resolvedEndpoint.slice(1)
|
|
93
93
|
: resolvedEndpoint;
|
|
94
|
-
const command = new HubSpotCommand(
|
|
94
|
+
const command = new HubSpotCommand('cms function logs').addArg(normalizedEndpoint);
|
|
95
95
|
if (latest) {
|
|
96
96
|
command.addFlag('latest', latest);
|
|
97
97
|
}
|
|
@@ -25,7 +25,10 @@ export class HsListTool extends Tool {
|
|
|
25
25
|
}
|
|
26
26
|
async handler({ path, account, absoluteCurrentWorkingDirectory }, extra) {
|
|
27
27
|
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
28
|
-
const command = new HubSpotCommand(
|
|
28
|
+
const command = new HubSpotCommand('cms list');
|
|
29
|
+
if (path) {
|
|
30
|
+
command.addArg(path);
|
|
31
|
+
}
|
|
29
32
|
if (account) {
|
|
30
33
|
command.addFlag('account', account);
|
|
31
34
|
}
|
|
@@ -2,7 +2,16 @@ import path from 'path';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import util from 'util';
|
|
4
4
|
import { exec } from 'node:child_process';
|
|
5
|
-
import {
|
|
5
|
+
import { crossPlatformSpawn } from '../../lib/crossPlatformSpawn/index.js';
|
|
6
|
+
import { lib } from '../../lang/en.js';
|
|
7
|
+
function formatFlag({ name, value }) {
|
|
8
|
+
const flag = `--${name}`;
|
|
9
|
+
const values = (Array.isArray(value) ? value : [value]).map(String);
|
|
10
|
+
if (values.some(item => item.startsWith('-'))) {
|
|
11
|
+
return values.map(item => `${flag}=${item}`);
|
|
12
|
+
}
|
|
13
|
+
return [flag, ...values];
|
|
14
|
+
}
|
|
6
15
|
export class HubSpotCommand {
|
|
7
16
|
executable = 'hs';
|
|
8
17
|
subcommandArgs;
|
|
@@ -14,6 +23,9 @@ export class HubSpotCommand {
|
|
|
14
23
|
this.flags = [...flags];
|
|
15
24
|
}
|
|
16
25
|
addArg(value) {
|
|
26
|
+
if (value.startsWith('-')) {
|
|
27
|
+
throw new Error(lib.hubSpotCommand.argStartsWithDash(value));
|
|
28
|
+
}
|
|
17
29
|
this.positionalArgs.push(value);
|
|
18
30
|
return this;
|
|
19
31
|
}
|
|
@@ -25,9 +37,7 @@ export class HubSpotCommand {
|
|
|
25
37
|
return [
|
|
26
38
|
...this.subcommandArgs,
|
|
27
39
|
...this.positionalArgs,
|
|
28
|
-
...this.flags.flatMap(
|
|
29
|
-
? [`--${name}`, ...value.map(String)]
|
|
30
|
-
: [`--${name}`, String(value)]),
|
|
40
|
+
...this.flags.flatMap(formatFlag),
|
|
31
41
|
];
|
|
32
42
|
}
|
|
33
43
|
}
|
|
@@ -38,9 +48,6 @@ export class NpxHubSpotCommand {
|
|
|
38
48
|
this.args = ['-y', '-p', cliPackage, 'hs', ...command.args];
|
|
39
49
|
}
|
|
40
50
|
}
|
|
41
|
-
const WINDOWS_UNSAFE_ARG_CHARACTERS = '" % ^ & | < >';
|
|
42
|
-
const WINDOWS_UNSAFE_ARG_PATTERN = /["%^&|<>]/;
|
|
43
|
-
const WINDOWS_TRAILING_BACKSLASHES_PATTERN = /\\{2,}$/;
|
|
44
51
|
export const execAsync = util.promisify(exec);
|
|
45
52
|
export function getCommandResultsFromError(error) {
|
|
46
53
|
if (typeof error !== 'object' || error === null) {
|
|
@@ -50,21 +57,10 @@ export function getCommandResultsFromError(error) {
|
|
|
50
57
|
const stderr = 'stderr' in error && typeof error.stderr === 'string' ? error.stderr : '';
|
|
51
58
|
return { stdout, stderr };
|
|
52
59
|
}
|
|
53
|
-
function isUnsafeForWindowsShell(arg) {
|
|
54
|
-
return (WINDOWS_UNSAFE_ARG_PATTERN.test(arg) ||
|
|
55
|
-
WINDOWS_TRAILING_BACKSLASHES_PATTERN.test(arg));
|
|
56
|
-
}
|
|
57
|
-
function assertArgsSafeForWindowsShell(args) {
|
|
58
|
-
if (process.platform !== 'win32') {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const unsafeArg = args.find(isUnsafeForWindowsShell);
|
|
62
|
-
if (unsafeArg === undefined) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
throw new Error(`Cannot run this command on Windows because an argument contains one of these characters: ${WINDOWS_UNSAFE_ARG_CHARACTERS}, or ends with two or more backslashes. Remove or rephrase them and try again. Argument: ${JSON.stringify(unsafeArg)}`);
|
|
66
|
-
}
|
|
67
60
|
export async function runCommandInDir(directory, command, onData) {
|
|
61
|
+
if (!fs.existsSync(directory)) {
|
|
62
|
+
fs.mkdirSync(directory);
|
|
63
|
+
}
|
|
68
64
|
let finalCommand = command;
|
|
69
65
|
if (command instanceof HubSpotCommand) {
|
|
70
66
|
command.addFlag('disable-usage-tracking', 'true');
|
|
@@ -75,15 +71,11 @@ export async function runCommandInDir(directory, command, onData) {
|
|
|
75
71
|
finalCommand = new NpxHubSpotCommand(command, cliPackage);
|
|
76
72
|
}
|
|
77
73
|
}
|
|
78
|
-
assertArgsSafeForWindowsShell(finalCommand.args);
|
|
79
|
-
if (!fs.existsSync(directory)) {
|
|
80
|
-
fs.mkdirSync(directory);
|
|
81
|
-
}
|
|
82
74
|
const resolvedDir = path.resolve(directory);
|
|
83
75
|
return new Promise((resolve, reject) => {
|
|
84
76
|
const stdoutChunks = [];
|
|
85
77
|
const stderrChunks = [];
|
|
86
|
-
const child =
|
|
78
|
+
const child = crossPlatformSpawn(finalCommand.executable, finalCommand.args, {
|
|
87
79
|
cwd: resolvedDir,
|
|
88
80
|
env: { ...process.env, INIT_CWD: resolvedDir },
|
|
89
81
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "8.3.1-experimental.
|
|
3
|
+
"version": "8.3.1-experimental.2",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"chokidar": "4.0.3",
|
|
21
21
|
"cli-cursor": "3.1.0",
|
|
22
22
|
"cli-progress": "3.12.0",
|
|
23
|
-
"cross-spawn": "7.0.6",
|
|
24
23
|
"express": "4.22.3",
|
|
25
24
|
"fs-extra": "8.1.0",
|
|
26
25
|
"ink": "6.8.0",
|
|
@@ -46,7 +45,6 @@
|
|
|
46
45
|
"@hubspot/npm-scripts": "^0.3.3",
|
|
47
46
|
"@types/archiver": "^6.0.3",
|
|
48
47
|
"@types/cli-progress": "^3.11.6",
|
|
49
|
-
"@types/cross-spawn": "^6.0.6",
|
|
50
48
|
"@types/express": "^5.0.0",
|
|
51
49
|
"@types/fs-extra": "^11.0.4",
|
|
52
50
|
"@types/js-yaml": "^4.0.9",
|