@hubspot/cli 7.8.11-experimental.0 → 7.8.12-experimental.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/bin/cli.js +31 -25
- package/commands/__tests__/auth.test.js +5 -0
- package/commands/__tests__/doctor.test.js +16 -16
- package/commands/account/clean.js +18 -27
- package/commands/account/createOverride.js +13 -31
- package/commands/account/info.js +20 -31
- package/commands/account/list.js +16 -22
- package/commands/account/remove.js +12 -20
- package/commands/account/removeOverride.js +11 -21
- package/commands/account/rename.js +6 -9
- package/commands/account/use.js +12 -26
- package/commands/account.js +2 -2
- package/commands/app/__tests__/migrate.test.js +5 -5
- package/commands/app/migrate.js +13 -18
- package/commands/auth.d.ts +1 -0
- package/commands/auth.js +16 -7
- package/commands/cms/convertFields.js +7 -9
- package/commands/cms/getReactModule.js +9 -14
- package/commands/cms/lighthouseScore.js +33 -36
- package/commands/cms.js +2 -2
- package/commands/completion.js +3 -3
- package/commands/config/set.d.ts +1 -1
- package/commands/config/set.js +64 -36
- package/commands/config.js +2 -2
- package/commands/create.js +2 -2
- package/commands/customObject/create.js +10 -12
- package/commands/customObject/schema/create.js +9 -11
- package/commands/customObject/schema/delete.js +16 -16
- package/commands/customObject/schema/fetch-all.js +12 -11
- package/commands/customObject/schema/fetch.js +15 -15
- package/commands/customObject/schema/list.js +4 -4
- package/commands/customObject/schema/update.js +13 -13
- package/commands/customObject/schema.js +2 -2
- package/commands/customObject.js +6 -7
- package/commands/doctor.js +8 -11
- package/commands/feedback.js +6 -11
- package/commands/fetch.js +8 -8
- package/commands/filemanager/fetch.js +7 -7
- package/commands/filemanager/upload.js +15 -34
- package/commands/filemanager.js +2 -2
- package/commands/function/deploy.js +11 -29
- package/commands/function/list.js +8 -8
- package/commands/function/server.js +9 -11
- package/commands/function.d.ts +1 -1
- package/commands/function.js +2 -2
- package/commands/getStarted.js +2 -2
- package/commands/hubdb/clear.js +7 -15
- package/commands/hubdb/create.js +9 -15
- package/commands/hubdb/delete.js +8 -15
- package/commands/hubdb/fetch.js +6 -9
- package/commands/hubdb.d.ts +1 -1
- package/commands/hubdb.js +2 -2
- package/commands/init.js +2 -3
- package/commands/lint.js +16 -16
- package/commands/list.js +8 -14
- package/commands/logs.js +14 -20
- package/commands/mv.js +6 -17
- package/commands/open.js +5 -5
- package/commands/project/__tests__/add.test.js +4 -2
- package/commands/project/__tests__/deploy.test.js +3 -4
- package/commands/project/__tests__/installDeps.test.js +8 -8
- package/commands/project/__tests__/logs.test.js +1 -1
- package/commands/project/__tests__/migrate.test.js +5 -5
- package/commands/project/__tests__/migrateApp.test.js +2 -5
- package/commands/project/__tests__/validate.test.js +98 -0
- package/commands/project/add.js +3 -3
- package/commands/project/cloneApp.js +14 -19
- package/commands/project/create.js +0 -1
- package/commands/project/deploy.js +3 -3
- package/commands/project/dev/deprecatedFlow.js +7 -16
- package/commands/project/dev/index.js +14 -12
- package/commands/project/dev/unifiedFlow.js +3 -1
- package/commands/project/download.js +10 -13
- package/commands/project/installDeps.js +8 -8
- package/commands/project/listBuilds.js +11 -20
- package/commands/project/logs.js +21 -24
- package/commands/project/migrate.js +14 -16
- package/commands/project/migrateApp.js +9 -15
- package/commands/project/open.js +6 -13
- package/commands/project/upload.js +16 -25
- package/commands/project/validate.js +6 -6
- package/commands/project/watch.js +13 -22
- package/commands/project.js +2 -2
- package/commands/sandbox/__tests__/create.test.js +5 -5
- package/commands/sandbox/create.js +22 -32
- package/commands/sandbox/delete.js +38 -63
- package/commands/sandbox.js +2 -2
- package/commands/secret/addSecret.js +7 -17
- package/commands/secret/deleteSecret.js +10 -20
- package/commands/secret/listSecret.js +8 -10
- package/commands/secret/updateSecret.js +9 -17
- package/commands/secret.js +2 -2
- package/commands/testAccount/__tests__/delete.test.js +2 -4
- package/commands/testAccount/delete.d.ts +4 -3
- package/commands/testAccount/delete.js +155 -14
- package/commands/theme/preview.js +1 -4
- package/lang/en.d.ts +310 -102
- package/lang/en.js +351 -147
- package/lang/en.lyaml +2 -2
- package/lib/__tests__/buildAccount.test.js +2 -1
- package/lib/__tests__/commonOpts.test.js +1 -1
- package/lib/__tests__/dependencyManagement.test.js +1 -1
- package/lib/__tests__/developerTestAccounts.test.js +3 -3
- package/lib/__tests__/npm.test.js +1 -1
- package/lib/__tests__/oauth.test.js +4 -4
- package/lib/__tests__/process.test.js +10 -5
- package/lib/__tests__/sandboxSync.test.js +8 -8
- package/lib/__tests__/sandboxes.test.js +8 -8
- package/lib/__tests__/serverlessLogs.test.js +1 -1
- package/lib/__tests__/usageTracking.test.js +5 -5
- package/lib/__tests__/validation.test.js +2 -1
- package/lib/__tests__/yargsUtils.test.js +83 -9
- package/lib/app/__tests__/migrate.test.js +5 -5
- package/lib/app/__tests__/migrate_legacy.test.js +1 -1
- package/lib/app/migrate.js +1 -1
- package/lib/app/migrate_legacy.js +20 -24
- package/lib/buildAccount.js +25 -57
- package/lib/commonOpts.d.ts +1 -1
- package/lib/commonOpts.js +25 -22
- package/lib/configOptions.js +7 -0
- package/lib/constants.d.ts +6 -1
- package/lib/constants.js +10 -1
- package/lib/dependencyManagement.js +9 -27
- package/lib/developerTestAccounts.js +9 -23
- package/lib/doctor/Diagnosis.js +11 -23
- package/lib/doctor/DiagnosticInfoBuilder.js +12 -11
- package/lib/doctor/Doctor.js +42 -90
- package/lib/doctor/__tests__/Doctor.test.js +4 -4
- package/lib/errorHandlers/index.js +12 -20
- package/lib/errorHandlers/suppressError.js +11 -18
- package/lib/lang.js +6 -5
- package/lib/links.js +4 -4
- package/lib/middleware/__test__/commandTargetingUtils.test.d.ts +1 -0
- package/lib/middleware/__test__/commandTargetingUtils.test.js +99 -0
- package/lib/middleware/__test__/configMiddleware.test.js +11 -11
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +6 -8
- package/lib/middleware/commandTargetingUtils.d.ts +8 -0
- package/lib/middleware/commandTargetingUtils.js +78 -0
- package/lib/middleware/configMiddleware.d.ts +1 -1
- package/lib/middleware/configMiddleware.js +21 -81
- package/lib/middleware/fireAlarmMiddleware.js +15 -17
- package/lib/middleware/gitMiddleware.js +5 -1
- package/lib/middleware/notificationsMiddleware.js +5 -11
- package/lib/middleware/yargsChecksMiddleware.js +6 -9
- package/lib/npm.js +2 -2
- package/lib/oauth.js +5 -5
- package/lib/process.js +5 -4
- package/lib/projects/__tests__/AppDevModeInterface.test.js +14 -34
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +70 -39
- package/lib/projects/__tests__/localDevProjectHelpers.test.js +2 -0
- package/lib/projects/__tests__/platformVersion.test.js +8 -8
- package/lib/projects/__tests__/projects.test.js +12 -12
- package/lib/projects/__tests__/structure.test.js +3 -3
- package/lib/projects/__tests__/upload.test.d.ts +1 -0
- package/lib/projects/__tests__/upload.test.js +82 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +6 -6
- package/lib/projects/add/__tests__/v3AddComponent.test.js +4 -4
- package/lib/projects/create/__tests__/legacy.test.js +5 -5
- package/lib/projects/create/__tests__/v3.test.js +1 -1
- package/lib/projects/create/index.js +2 -2
- package/lib/projects/create/legacy.js +2 -2
- package/lib/projects/create/v3.js +2 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +2 -0
- package/lib/projects/localDev/AppDevModeInterface.js +22 -20
- package/lib/projects/localDev/LocalDevLogger.js +10 -11
- package/lib/projects/localDev/LocalDevManager.js +4 -5
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +0 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.js +7 -10
- package/lib/projects/localDev/helpers/project.d.ts +1 -0
- package/lib/projects/localDev/helpers/project.js +37 -0
- package/lib/projects/platformVersion.d.ts +1 -1
- package/lib/projects/platformVersion.js +1 -1
- package/lib/projects/structure.js +6 -6
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +17 -8
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +1 -0
- package/lib/prompts/accountNamePrompt.js +14 -19
- package/lib/prompts/accountsPrompt.js +2 -2
- package/lib/prompts/cmsFieldPrompt.js +2 -2
- package/lib/prompts/createApiSamplePrompt.js +5 -5
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +10 -1
- package/lib/prompts/createFunctionPrompt.js +14 -14
- package/lib/prompts/createModulePrompt.js +9 -9
- package/lib/prompts/createTemplatePrompt.js +2 -2
- package/lib/prompts/downloadProjectPrompt.js +5 -8
- package/lib/prompts/personalAccessKeyPrompt.js +3 -3
- package/lib/prompts/previewPrompt.js +6 -6
- package/lib/prompts/projectAddPrompt.js +6 -0
- package/lib/prompts/projectDevTargetAccountPrompt.js +20 -32
- package/lib/prompts/projectNamePrompt.js +4 -8
- package/lib/prompts/projectsLogsPrompt.js +2 -4
- package/lib/prompts/promptUtils.js +27 -9
- package/lib/prompts/sandboxesPrompt.js +7 -7
- package/lib/prompts/secretPrompt.js +3 -3
- package/lib/prompts/selectAppPrompt.js +3 -3
- package/lib/prompts/selectHubDBTablePrompt.js +9 -13
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +15 -19
- package/lib/prompts/setAsDefaultAccountPrompt.js +4 -8
- package/lib/prompts/uploadPrompt.js +5 -5
- package/lib/sandboxSync.js +24 -41
- package/lib/sandboxes.js +19 -47
- package/lib/schema.js +3 -3
- package/lib/serverlessLogs.js +11 -13
- package/lib/theme/__tests__/migrate.test.js +3 -3
- package/lib/theme/migrate.js +2 -2
- package/lib/ui/SpinniesManager.d.ts +2 -0
- package/lib/ui/SpinniesManager.js +7 -0
- package/lib/ui/boxen.js +1 -2
- package/lib/ui/git.js +13 -10
- package/lib/ui/index.d.ts +4 -0
- package/lib/ui/index.js +47 -38
- package/lib/ui/serverlessFunctionLogs.js +9 -7
- package/lib/ui/uiMessages.d.ts +68 -0
- package/lib/ui/uiMessages.js +71 -0
- package/lib/usageTracking.js +7 -7
- package/lib/validation.js +20 -23
- package/lib/yargsUtils.d.ts +1 -1
- package/lib/yargsUtils.js +12 -5
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +23 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +68 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +11 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.js +49 -0
- package/mcp-server/tools/project/GetConfigValuesTool.js +2 -2
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +169 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +115 -0
- package/mcp-server/utils/toolUsageTracking.js +2 -2
- package/package.json +7 -7
- package/ui/components/BoxWithTitle.d.ts +8 -0
- package/ui/components/BoxWithTitle.js +9 -0
- package/ui/components/HorizontalSelectPrompt.d.ts +8 -0
- package/ui/components/HorizontalSelectPrompt.js +30 -0
- package/ui/components/StatusMessageBoxes.d.ts +12 -0
- package/ui/components/StatusMessageBoxes.js +31 -0
- package/ui/index.d.ts +1 -0
- package/ui/index.js +6 -0
- package/ui/lib/ui-testing-utils.d.ts +9 -0
- package/ui/lib/ui-testing-utils.js +47 -0
- package/ui/lib/useTerminalSize.d.ts +13 -0
- package/ui/lib/useTerminalSize.js +31 -0
- package/ui/styles.d.ts +18 -0
- package/ui/styles.js +18 -0
- package/ui/views/UiSandbox.d.ts +5 -0
- package/ui/views/UiSandbox.js +25 -0
- package/lib/middleware/__test__/utils.test.js +0 -51
- package/lib/middleware/utils.d.ts +0 -8
- package/lib/middleware/utils.js +0 -14
- /package/{lib/middleware/__test__/utils.test.d.ts → commands/project/__tests__/validate.test.d.ts} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text, useInput } from 'ink';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { CONTAINER_STYLES, INK_COLORS } from '../styles.js';
|
|
5
|
+
export function getHorizontalSelectPrompt(props) {
|
|
6
|
+
return _jsx(HorizontalSelectPrompt, { ...props });
|
|
7
|
+
}
|
|
8
|
+
export function HorizontalSelectPrompt({ defaultOption, options, onSelect, prompt, }) {
|
|
9
|
+
const [selectedIndex, setSelectedIndex] = useState(defaultOption && options.indexOf(defaultOption) !== -1
|
|
10
|
+
? options.indexOf(defaultOption)
|
|
11
|
+
: 0);
|
|
12
|
+
const moveRight = () => {
|
|
13
|
+
setSelectedIndex(prev => (prev < options.length - 1 ? prev + 1 : 0));
|
|
14
|
+
};
|
|
15
|
+
const moveLeft = () => {
|
|
16
|
+
setSelectedIndex(prev => (prev > 0 ? prev - 1 : options.length - 1));
|
|
17
|
+
};
|
|
18
|
+
useInput((_, key) => {
|
|
19
|
+
if (key.leftArrow) {
|
|
20
|
+
moveLeft();
|
|
21
|
+
}
|
|
22
|
+
else if (key.rightArrow) {
|
|
23
|
+
moveRight();
|
|
24
|
+
}
|
|
25
|
+
else if (key.return) {
|
|
26
|
+
onSelect(options[selectedIndex]);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return (_jsxs(Box, { ...CONTAINER_STYLES, flexDirection: "column", marginTop: 1, width: "100%", alignSelf: "center", justifyContent: "center", children: [prompt && (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { children: prompt }) })), _jsx(Box, { flexDirection: "row", justifyContent: "center", flexWrap: "wrap", width: "100%", gap: 1, children: options.map((option, index) => (_jsx(Box, { children: _jsx(Text, { backgroundColor: index === selectedIndex ? INK_COLORS.INFO_BLUE : undefined, bold: index === selectedIndex, children: ` ${option} ` }) }, index))) }), _jsx(Box, { marginTop: 1, alignSelf: "center", justifyContent: "center", children: _jsx(Text, { dimColor: true, children: "Use arrow keys to navigate, Enter to select" }) })] }));
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface StatusMessageBoxProps {
|
|
2
|
+
title: string;
|
|
3
|
+
message: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function getWarningBox(props: StatusMessageBoxProps): React.ReactNode;
|
|
6
|
+
export declare function WarningBox({ title, message, }: StatusMessageBoxProps): React.ReactNode;
|
|
7
|
+
export declare function getAlertBox(props: StatusMessageBoxProps): React.ReactNode;
|
|
8
|
+
export declare function AlertBox({ title, message, }: StatusMessageBoxProps): React.ReactNode;
|
|
9
|
+
export declare function getSuccessBox(props: StatusMessageBoxProps): React.ReactNode;
|
|
10
|
+
export declare function SuccessBox({ title, message, }: StatusMessageBoxProps): React.ReactNode;
|
|
11
|
+
export declare function getInfoBox(props: StatusMessageBoxProps): React.ReactNode;
|
|
12
|
+
export declare function InfoBox({ title, message, }: StatusMessageBoxProps): React.ReactNode;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { INK_COLORS } from '../styles.js';
|
|
3
|
+
import { BoxWithTitle } from './BoxWithTitle.js';
|
|
4
|
+
export function getWarningBox(props) {
|
|
5
|
+
return _jsx(WarningBox, { ...props });
|
|
6
|
+
}
|
|
7
|
+
export function WarningBox({ title, message, }) {
|
|
8
|
+
const color = INK_COLORS.WARNING_YELLOW;
|
|
9
|
+
return (_jsx(BoxWithTitle, { title: title, message: message, titleBackgroundColor: color, borderColor: color }));
|
|
10
|
+
}
|
|
11
|
+
export function getAlertBox(props) {
|
|
12
|
+
return _jsx(AlertBox, { ...props });
|
|
13
|
+
}
|
|
14
|
+
export function AlertBox({ title, message, }) {
|
|
15
|
+
const color = INK_COLORS.ALERT_RED;
|
|
16
|
+
return (_jsx(BoxWithTitle, { title: title, message: message, titleBackgroundColor: color, borderColor: color }));
|
|
17
|
+
}
|
|
18
|
+
export function getSuccessBox(props) {
|
|
19
|
+
return _jsx(SuccessBox, { ...props });
|
|
20
|
+
}
|
|
21
|
+
export function SuccessBox({ title, message, }) {
|
|
22
|
+
const color = INK_COLORS.SUCCESS_GREEN;
|
|
23
|
+
return (_jsx(BoxWithTitle, { title: title, message: message, titleBackgroundColor: color, borderColor: color }));
|
|
24
|
+
}
|
|
25
|
+
export function getInfoBox(props) {
|
|
26
|
+
return _jsx(InfoBox, { ...props });
|
|
27
|
+
}
|
|
28
|
+
export function InfoBox({ title, message, }) {
|
|
29
|
+
const color = INK_COLORS.INFO_BLUE;
|
|
30
|
+
return (_jsx(BoxWithTitle, { title: title, message: message, titleBackgroundColor: color, borderColor: color }));
|
|
31
|
+
}
|
package/ui/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderInline(component: React.ReactNode): Promise<void>;
|
package/ui/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ComponentPropPair = {
|
|
2
|
+
component: React.ReactNode;
|
|
3
|
+
signature: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* These components will be used by the sandbox ui. Please add any new components here.
|
|
7
|
+
*/
|
|
8
|
+
export declare const populatedComponents: Record<string, ComponentPropPair>;
|
|
9
|
+
export declare function getComponentOptions(): string[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { getSuccessBox, getInfoBox, getWarningBox, getAlertBox, } from '../components/StatusMessageBoxes.js';
|
|
2
|
+
import { getBoxWithTitle } from '../components/BoxWithTitle.js';
|
|
3
|
+
import { SuccessBox, InfoBox, WarningBox, AlertBox, } from '../components/StatusMessageBoxes.js';
|
|
4
|
+
import { BoxWithTitle } from '../components/BoxWithTitle.js';
|
|
5
|
+
/**
|
|
6
|
+
* These components will be used by the sandbox ui. Please add any new components here.
|
|
7
|
+
*/
|
|
8
|
+
export const populatedComponents = {
|
|
9
|
+
SuccessBox: {
|
|
10
|
+
component: getSuccessBox({
|
|
11
|
+
title: 'Success',
|
|
12
|
+
message: 'This is a success message',
|
|
13
|
+
}),
|
|
14
|
+
signature: SuccessBox.toString(),
|
|
15
|
+
},
|
|
16
|
+
InfoBox: {
|
|
17
|
+
component: getInfoBox({
|
|
18
|
+
title: 'Info',
|
|
19
|
+
message: 'This is an info message',
|
|
20
|
+
}),
|
|
21
|
+
signature: InfoBox.toString(),
|
|
22
|
+
},
|
|
23
|
+
WarningBox: {
|
|
24
|
+
component: getWarningBox({
|
|
25
|
+
title: 'Warning',
|
|
26
|
+
message: 'This is a warning message',
|
|
27
|
+
}),
|
|
28
|
+
signature: WarningBox.toString(),
|
|
29
|
+
},
|
|
30
|
+
AlertBox: {
|
|
31
|
+
component: getAlertBox({
|
|
32
|
+
title: 'Alert',
|
|
33
|
+
message: 'This is an alert message',
|
|
34
|
+
}),
|
|
35
|
+
signature: AlertBox.toString(),
|
|
36
|
+
},
|
|
37
|
+
BoxWithTitle: {
|
|
38
|
+
component: getBoxWithTitle({
|
|
39
|
+
title: 'Title',
|
|
40
|
+
message: 'This is a box with a title',
|
|
41
|
+
}),
|
|
42
|
+
signature: BoxWithTitle.toString(),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
export function getComponentOptions() {
|
|
46
|
+
return Object.keys(populatedComponents);
|
|
47
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This hook is used to get the current terminal size.
|
|
3
|
+
* It will return the current terminal size, and if a component is using this hook to set height/width,
|
|
4
|
+
* it will re-render when the terminal size changes.
|
|
5
|
+
* ONLY USE THIS HOOK WITH SCREENS. THIS HOOK WILL DESTROY ANY PRIOR LOG OUTPUT IF USED TO SET HEIGHT/WIDTH.
|
|
6
|
+
* @param minHeight - The minimum height of the terminal.
|
|
7
|
+
* @param minWidth - The minimum width of the terminal.
|
|
8
|
+
* @returns The current terminal size.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useTerminalSize(minHeight?: number, minWidth?: number): {
|
|
11
|
+
columns: number;
|
|
12
|
+
rows: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useStdout } from 'ink';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* This hook is used to get the current terminal size.
|
|
5
|
+
* It will return the current terminal size, and if a component is using this hook to set height/width,
|
|
6
|
+
* it will re-render when the terminal size changes.
|
|
7
|
+
* ONLY USE THIS HOOK WITH SCREENS. THIS HOOK WILL DESTROY ANY PRIOR LOG OUTPUT IF USED TO SET HEIGHT/WIDTH.
|
|
8
|
+
* @param minHeight - The minimum height of the terminal.
|
|
9
|
+
* @param minWidth - The minimum width of the terminal.
|
|
10
|
+
* @returns The current terminal size.
|
|
11
|
+
*/
|
|
12
|
+
export function useTerminalSize(minHeight, minWidth) {
|
|
13
|
+
const { stdout } = useStdout();
|
|
14
|
+
const [size, setSize] = useState({
|
|
15
|
+
columns: Math.max(stdout.columns, minWidth ?? 0),
|
|
16
|
+
rows: Math.max(stdout.rows, minHeight ?? 0),
|
|
17
|
+
});
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const handleResize = () => {
|
|
20
|
+
setSize({
|
|
21
|
+
columns: Math.max(stdout.columns, minWidth ?? 0),
|
|
22
|
+
rows: Math.max(stdout.rows, minHeight ?? 0),
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
stdout.on('resize', handleResize);
|
|
26
|
+
return () => {
|
|
27
|
+
stdout.off('resize', handleResize);
|
|
28
|
+
};
|
|
29
|
+
}, [stdout]);
|
|
30
|
+
return size;
|
|
31
|
+
}
|
package/ui/styles.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const CONTAINER_STYLES: {
|
|
2
|
+
readonly padding: 1;
|
|
3
|
+
readonly marginY: 0.5;
|
|
4
|
+
readonly flexDirection: "column";
|
|
5
|
+
readonly flexWrap: "wrap";
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Any color that can be used well in both WHITE and BLACK terminals.
|
|
9
|
+
* This is a best effort to ensure that the color is good looking in both
|
|
10
|
+
* light and dark modes.
|
|
11
|
+
*/
|
|
12
|
+
export declare const INK_COLORS: {
|
|
13
|
+
ALERT_RED: string;
|
|
14
|
+
SUCCESS_GREEN: string;
|
|
15
|
+
INFO_BLUE: string;
|
|
16
|
+
WARNING_YELLOW: string;
|
|
17
|
+
WHITE: string;
|
|
18
|
+
};
|
package/ui/styles.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const CONTAINER_STYLES = {
|
|
2
|
+
padding: 1,
|
|
3
|
+
marginY: 0.5,
|
|
4
|
+
flexDirection: 'column',
|
|
5
|
+
flexWrap: 'wrap',
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Any color that can be used well in both WHITE and BLACK terminals.
|
|
9
|
+
* This is a best effort to ensure that the color is good looking in both
|
|
10
|
+
* light and dark modes.
|
|
11
|
+
*/
|
|
12
|
+
export const INK_COLORS = {
|
|
13
|
+
ALERT_RED: '#fc7272',
|
|
14
|
+
SUCCESS_GREEN: '#4deb7a',
|
|
15
|
+
INFO_BLUE: '#4dcbeb',
|
|
16
|
+
WARNING_YELLOW: '#EEB117',
|
|
17
|
+
WHITE: 'white',
|
|
18
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { HorizontalSelectPrompt } from '../components/HorizontalSelectPrompt.js';
|
|
5
|
+
import { getComponentOptions, populatedComponents, } from '../lib/ui-testing-utils.js';
|
|
6
|
+
import { useTerminalSize } from '../lib/useTerminalSize.js';
|
|
7
|
+
import { CONTAINER_STYLES } from '../styles.js';
|
|
8
|
+
export function getUiSandbox(props) {
|
|
9
|
+
return _jsx(UiSandbox, { ...props });
|
|
10
|
+
}
|
|
11
|
+
export function UiSandbox({ componentName }) {
|
|
12
|
+
const componentOptions = getComponentOptions();
|
|
13
|
+
const [selectedComponent, setSelectedComponent] = useState(componentName ? populatedComponents[componentName] : undefined);
|
|
14
|
+
const mapStringToComponent = (str) => {
|
|
15
|
+
setSelectedComponent(populatedComponents[str] || undefined);
|
|
16
|
+
};
|
|
17
|
+
const getFunctionArguments = (signature) => {
|
|
18
|
+
const startIndex = signature.indexOf('(');
|
|
19
|
+
const endIndex = signature.indexOf(')');
|
|
20
|
+
const functionArgs = signature.slice(startIndex, endIndex + 1);
|
|
21
|
+
return functionArgs;
|
|
22
|
+
};
|
|
23
|
+
const size = useTerminalSize(20);
|
|
24
|
+
return (_jsxs(Box, { flexDirection: "column", height: size.rows, children: [_jsx(HorizontalSelectPrompt, { defaultOption: componentName, options: componentOptions, onSelect: mapStringToComponent }), selectedComponent?.component, selectedComponent?.signature && (_jsxs(Box, { ...CONTAINER_STYLES, gap: 1, borderStyle: "classic", children: [_jsx(Text, { children: "Signature:" }), _jsx(Text, { children: getFunctionArguments(selectedComponent?.signature) })] }))] }));
|
|
25
|
+
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { isTargetedCommand } from '../utils.js';
|
|
2
|
-
const targetCommandMap = {
|
|
3
|
-
init: { target: true },
|
|
4
|
-
account: {
|
|
5
|
-
target: true,
|
|
6
|
-
subCommands: {
|
|
7
|
-
use: { target: true },
|
|
8
|
-
},
|
|
9
|
-
},
|
|
10
|
-
project: {
|
|
11
|
-
subCommands: {
|
|
12
|
-
deploy: { target: true },
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
describe('lib/middleware/utils', () => {
|
|
17
|
-
describe('isTargetedCommand()', () => {
|
|
18
|
-
it('should return true for a direct target command', () => {
|
|
19
|
-
const result = isTargetedCommand(['init'], targetCommandMap);
|
|
20
|
-
expect(result).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
it('should return true for a command with a subcommand', () => {
|
|
23
|
-
const result = isTargetedCommand(['account'], targetCommandMap);
|
|
24
|
-
expect(result).toBe(true);
|
|
25
|
-
});
|
|
26
|
-
it('should return true for a nested target command', () => {
|
|
27
|
-
const result = isTargetedCommand(['project', 'deploy'], targetCommandMap);
|
|
28
|
-
expect(result).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
it('should return false for a non-existent command', () => {
|
|
31
|
-
const result = isTargetedCommand(['nonexistent'], targetCommandMap);
|
|
32
|
-
expect(result).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
it('should return false for a non-targeted command', () => {
|
|
35
|
-
const result = isTargetedCommand(['auth'], targetCommandMap);
|
|
36
|
-
expect(result).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
it('should return false for a command with a targeted subcommand', () => {
|
|
39
|
-
const result = isTargetedCommand(['project'], targetCommandMap);
|
|
40
|
-
expect(result).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
it('should return false for a non-existent subcommand', () => {
|
|
43
|
-
const result = isTargetedCommand(['auth', 'nonexistent'], targetCommandMap);
|
|
44
|
-
expect(result).toBe(false);
|
|
45
|
-
});
|
|
46
|
-
it('should return false for an empty command array', () => {
|
|
47
|
-
const result = isTargetedCommand([], targetCommandMap);
|
|
48
|
-
expect(result).toBe(false);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
package/lib/middleware/utils.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function isTargetedCommand(commandParts, targetCommandMap) {
|
|
2
|
-
const currentCommand = commandParts[0];
|
|
3
|
-
if (!targetCommandMap[currentCommand]) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
if (targetCommandMap[currentCommand].target) {
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
const subCommands = targetCommandMap[currentCommand].subCommands || {};
|
|
10
|
-
if (commandParts.length > 1) {
|
|
11
|
-
return isTargetedCommand(commandParts.slice(1), subCommands);
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
}
|
/package/{lib/middleware/__test__/utils.test.d.ts → commands/project/__tests__/validate.test.d.ts}
RENAMED
|
File without changes
|