@supatype/cli 0.1.1 → 0.1.3
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +126 -99
- package/.turbo/turbo-typecheck.log +2 -2
- package/dist/binary-cache.d.ts +2 -0
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +36 -0
- package/dist/binary-cache.js.map +1 -1
- package/dist/binary-download-lock.d.ts +12 -0
- package/dist/binary-download-lock.d.ts.map +1 -0
- package/dist/binary-download-lock.js +106 -0
- package/dist/binary-download-lock.js.map +1 -0
- package/dist/cli-package-version.d.ts +3 -0
- package/dist/cli-package-version.d.ts.map +1 -0
- package/dist/cli-package-version.js +15 -0
- package/dist/cli-package-version.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/add.js +25 -19
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/admin.d.ts +12 -0
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +116 -26
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/cache.d.ts +1 -1
- package/dist/commands/cache.d.ts.map +1 -1
- package/dist/commands/cache.js +98 -5
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +26 -22
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.d.ts +3 -4
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +296 -121
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/link-helpers.d.ts.map +1 -1
- package/dist/commands/link-helpers.js +26 -25
- package/dist/commands/link-helpers.js.map +1 -1
- package/dist/compose-local-server-image.d.ts +13 -0
- package/dist/compose-local-server-image.d.ts.map +1 -0
- package/dist/compose-local-server-image.js +57 -0
- package/dist/compose-local-server-image.js.map +1 -0
- package/dist/compose-rename.d.ts.map +1 -1
- package/dist/compose-rename.js +5 -8
- package/dist/compose-rename.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +12 -1
- package/dist/config.js.map +1 -1
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +113 -56
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-log-bus.d.ts +5 -0
- package/dist/dev-log-bus.d.ts.map +1 -1
- package/dist/dev-log-bus.js +16 -0
- package/dist/dev-log-bus.js.map +1 -1
- package/dist/dev-log-filter.d.ts +4 -0
- package/dist/dev-log-filter.d.ts.map +1 -1
- package/dist/dev-log-filter.js +52 -0
- package/dist/dev-log-filter.js.map +1 -1
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +19 -12
- package/dist/dev-ports.js.map +1 -1
- package/dist/dev-ready-panel.d.ts +21 -0
- package/dist/dev-ready-panel.d.ts.map +1 -0
- package/dist/dev-ready-panel.js +67 -0
- package/dist/dev-ready-panel.js.map +1 -0
- package/dist/dev-session-lock.d.ts.map +1 -1
- package/dist/dev-session-lock.js +5 -8
- package/dist/dev-session-lock.js.map +1 -1
- package/dist/dev-session.d.ts +18 -5
- package/dist/dev-session.d.ts.map +1 -1
- package/dist/dev-session.js +91 -18
- package/dist/dev-session.js.map +1 -1
- package/dist/dev-shutdown.d.ts +2 -0
- package/dist/dev-shutdown.d.ts.map +1 -1
- package/dist/dev-shutdown.js +29 -15
- package/dist/dev-shutdown.js.map +1 -1
- package/dist/dev-task-colors.d.ts +3 -1
- package/dist/dev-task-colors.d.ts.map +1 -1
- package/dist/dev-task-colors.js +23 -3
- package/dist/dev-task-colors.js.map +1 -1
- package/dist/docker-runtime.js +1 -1
- package/dist/docker-runtime.js.map +1 -1
- package/dist/engine-push-output.d.ts +1 -0
- package/dist/engine-push-output.d.ts.map +1 -1
- package/dist/engine-push-output.js +4 -1
- package/dist/engine-push-output.js.map +1 -1
- package/dist/ensure-binary.d.ts.map +1 -1
- package/dist/ensure-binary.js +14 -2
- package/dist/ensure-binary.js.map +1 -1
- package/dist/ensure-component-binaries.d.ts +17 -0
- package/dist/ensure-component-binaries.d.ts.map +1 -0
- package/dist/ensure-component-binaries.js +45 -0
- package/dist/ensure-component-binaries.js.map +1 -0
- package/dist/ensure-dev-api-config.d.ts +3 -0
- package/dist/ensure-dev-api-config.d.ts.map +1 -0
- package/dist/ensure-dev-api-config.js +17 -0
- package/dist/ensure-dev-api-config.js.map +1 -0
- package/dist/init-dependency-versions.d.ts +13 -0
- package/dist/init-dependency-versions.d.ts.map +1 -0
- package/dist/init-dependency-versions.js +53 -0
- package/dist/init-dependency-versions.js.map +1 -0
- package/dist/init-package-json.d.ts +21 -0
- package/dist/init-package-json.d.ts.map +1 -0
- package/dist/init-package-json.js +46 -0
- package/dist/init-package-json.js.map +1 -0
- package/dist/init-project-detect.d.ts +14 -0
- package/dist/init-project-detect.d.ts.map +1 -0
- package/dist/init-project-detect.js +89 -0
- package/dist/init-project-detect.js.map +1 -0
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +2 -1
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/required-host-components.d.ts +11 -0
- package/dist/required-host-components.d.ts.map +1 -0
- package/dist/required-host-components.js +25 -0
- package/dist/required-host-components.js.map +1 -0
- package/dist/resolve-api-url.d.ts +6 -0
- package/dist/resolve-api-url.d.ts.map +1 -0
- package/dist/resolve-api-url.js +39 -0
- package/dist/resolve-api-url.js.map +1 -0
- package/dist/rest-cache-admin.d.ts +33 -0
- package/dist/rest-cache-admin.d.ts.map +1 -0
- package/dist/rest-cache-admin.js +96 -0
- package/dist/rest-cache-admin.js.map +1 -0
- package/dist/scripts/postinstall.d.ts +4 -6
- package/dist/scripts/postinstall.d.ts.map +1 -1
- package/dist/scripts/postinstall.js +8 -41
- package/dist/scripts/postinstall.js.map +1 -1
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +23 -13
- package/dist/self-host-compose.js.map +1 -1
- package/dist/studio-dev-server.d.ts +4 -2
- package/dist/studio-dev-server.d.ts.map +1 -1
- package/dist/studio-dev-server.js +3 -2
- package/dist/studio-dev-server.js.map +1 -1
- package/dist/ui/brand.d.ts +2 -5
- package/dist/ui/brand.d.ts.map +1 -1
- package/dist/ui/brand.js +2 -7
- package/dist/ui/brand.js.map +1 -1
- package/dist/ui/clack-api.d.ts +44 -0
- package/dist/ui/clack-api.d.ts.map +1 -0
- package/dist/ui/clack-api.js +76 -0
- package/dist/ui/clack-api.js.map +1 -0
- package/dist/ui/clack.d.ts +14 -0
- package/dist/ui/clack.d.ts.map +1 -0
- package/dist/ui/clack.js +147 -0
- package/dist/ui/clack.js.map +1 -0
- package/dist/ui/components/FlowSpinner.d.ts +5 -0
- package/dist/ui/components/FlowSpinner.d.ts.map +1 -0
- package/dist/ui/components/FlowSpinner.js +8 -0
- package/dist/ui/components/FlowSpinner.js.map +1 -0
- package/dist/ui/components/LogoWordmark.d.ts +9 -0
- package/dist/ui/components/LogoWordmark.d.ts.map +1 -0
- package/dist/ui/components/LogoWordmark.js +17 -0
- package/dist/ui/components/LogoWordmark.js.map +1 -0
- package/dist/ui/components/PromptPanel.d.ts +5 -0
- package/dist/ui/components/PromptPanel.d.ts.map +1 -0
- package/dist/ui/components/PromptPanel.js +7 -0
- package/dist/ui/components/PromptPanel.js.map +1 -0
- package/dist/ui/components/SelectField.d.ts +11 -0
- package/dist/ui/components/SelectField.d.ts.map +1 -0
- package/dist/ui/components/SelectField.js +19 -0
- package/dist/ui/components/SelectField.js.map +1 -0
- package/dist/ui/confirm.d.ts +2 -1
- package/dist/ui/confirm.d.ts.map +1 -1
- package/dist/ui/confirm.js +4 -4
- package/dist/ui/confirm.js.map +1 -1
- package/dist/ui/dev/DevDashboard.d.ts +8 -0
- package/dist/ui/dev/DevDashboard.d.ts.map +1 -0
- package/dist/ui/dev/DevDashboard.js +158 -0
- package/dist/ui/dev/DevDashboard.js.map +1 -0
- package/dist/ui/dev/DevReadyPanelView.d.ts +8 -0
- package/dist/ui/dev/DevReadyPanelView.d.ts.map +1 -0
- package/dist/ui/dev/DevReadyPanelView.js +48 -0
- package/dist/ui/dev/DevReadyPanelView.js.map +1 -0
- package/dist/ui/fatal.d.ts.map +1 -1
- package/dist/ui/fatal.js +5 -11
- package/dist/ui/fatal.js.map +1 -1
- package/dist/ui/flows/FlowApp.d.ts +8 -0
- package/dist/ui/flows/FlowApp.d.ts.map +1 -0
- package/dist/ui/flows/FlowApp.js +44 -0
- package/dist/ui/flows/FlowApp.js.map +1 -0
- package/dist/ui/flows/prompt-fields.d.ts +48 -0
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -0
- package/dist/ui/flows/prompt-fields.js +92 -0
- package/dist/ui/flows/prompt-fields.js.map +1 -0
- package/dist/ui/flows/types.d.ts +41 -0
- package/dist/ui/flows/types.d.ts.map +1 -0
- package/dist/ui/flows/types.js +2 -0
- package/dist/ui/flows/types.js.map +1 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/messages.d.ts +1 -0
- package/dist/ui/messages.d.ts.map +1 -1
- package/dist/ui/messages.js +48 -8
- package/dist/ui/messages.js.map +1 -1
- package/dist/ui/progress.d.ts +5 -1
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +12 -3
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/prompts.d.ts +7 -5
- package/dist/ui/prompts.d.ts.map +1 -1
- package/dist/ui/prompts.js +15 -8
- package/dist/ui/prompts.js.map +1 -1
- package/dist/ui/runtime/cancel.d.ts +4 -0
- package/dist/ui/runtime/cancel.d.ts.map +1 -0
- package/dist/ui/runtime/cancel.js +6 -0
- package/dist/ui/runtime/cancel.js.map +1 -0
- package/dist/ui/runtime/command-chrome.d.ts +17 -0
- package/dist/ui/runtime/command-chrome.d.ts.map +1 -0
- package/dist/ui/runtime/command-chrome.js +123 -0
- package/dist/ui/runtime/command-chrome.js.map +1 -0
- package/dist/ui/runtime/dev-prompt-queue.d.ts +30 -0
- package/dist/ui/runtime/dev-prompt-queue.d.ts.map +1 -0
- package/dist/ui/runtime/dev-prompt-queue.js +57 -0
- package/dist/ui/runtime/dev-prompt-queue.js.map +1 -0
- package/dist/ui/runtime/flow-session.d.ts +4 -0
- package/dist/ui/runtime/flow-session.d.ts.map +1 -0
- package/dist/ui/runtime/flow-session.js +8 -0
- package/dist/ui/runtime/flow-session.js.map +1 -0
- package/dist/ui/runtime/run-clack-flow.d.ts +5 -0
- package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -0
- package/dist/ui/runtime/run-clack-flow.js +46 -0
- package/dist/ui/runtime/run-clack-flow.js.map +1 -0
- package/dist/ui/runtime/stdin-after-ink.d.ts +3 -0
- package/dist/ui/runtime/stdin-after-ink.d.ts.map +1 -0
- package/dist/ui/runtime/stdin-after-ink.js +16 -0
- package/dist/ui/runtime/stdin-after-ink.js.map +1 -0
- package/dist/ui/theme.d.ts +24 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/dist/ui/theme.js +34 -0
- package/dist/ui/theme.js.map +1 -0
- package/dist/valkey-sidecar.d.ts +17 -0
- package/dist/valkey-sidecar.d.ts.map +1 -0
- package/dist/valkey-sidecar.js +94 -0
- package/dist/valkey-sidecar.js.map +1 -0
- package/package.json +9 -3
- package/src/binary-cache.ts +61 -0
- package/src/binary-download-lock.ts +124 -0
- package/src/cli-package-version.ts +15 -0
- package/src/cli.ts +6 -2
- package/src/commands/add.ts +26 -19
- package/src/commands/admin.ts +156 -29
- package/src/commands/cache.ts +105 -5
- package/src/commands/dev.ts +26 -21
- package/src/commands/init.ts +473 -247
- package/src/commands/link-helpers.ts +30 -29
- package/src/compose-local-server-image.ts +68 -0
- package/src/compose-rename.ts +5 -8
- package/src/config.ts +13 -1
- package/src/dev-compose.ts +139 -54
- package/src/dev-log-bus.ts +20 -0
- package/src/dev-log-filter.ts +42 -0
- package/src/dev-ports.ts +22 -11
- package/src/dev-ready-panel.ts +80 -0
- package/src/dev-session-lock.ts +5 -8
- package/src/dev-session.ts +98 -18
- package/src/dev-shutdown.ts +29 -17
- package/src/dev-task-colors.ts +22 -3
- package/src/docker-runtime.ts +1 -1
- package/src/engine-push-output.ts +5 -1
- package/src/ensure-binary.ts +21 -1
- package/src/ensure-component-binaries.ts +71 -0
- package/src/ensure-dev-api-config.ts +18 -0
- package/src/init-dependency-versions.ts +69 -0
- package/src/init-package-json.ts +63 -0
- package/src/init-project-detect.ts +99 -0
- package/src/postgres-ctl.ts +2 -1
- package/src/required-host-components.ts +37 -0
- package/src/resolve-api-url.ts +43 -0
- package/src/rest-cache-admin.ts +135 -0
- package/src/scripts/postinstall.ts +9 -46
- package/src/self-host-compose.ts +22 -12
- package/src/studio-dev-server.ts +5 -4
- package/src/ui/README.md +13 -9
- package/src/ui/brand.ts +2 -8
- package/src/ui/clack-api.ts +123 -0
- package/src/ui/clack.ts +153 -0
- package/src/ui/components/FlowSpinner.tsx +15 -0
- package/src/ui/components/LogoWordmark.tsx +36 -0
- package/src/ui/components/PromptPanel.tsx +17 -0
- package/src/ui/components/SelectField.tsx +58 -0
- package/src/ui/confirm.ts +5 -4
- package/src/ui/dev/DevDashboard.tsx +223 -0
- package/src/ui/dev/DevReadyPanelView.tsx +134 -0
- package/src/ui/fatal.ts +5 -10
- package/src/ui/flows/FlowApp.tsx +69 -0
- package/src/ui/flows/prompt-fields.tsx +198 -0
- package/src/ui/flows/types.ts +50 -0
- package/src/ui/index.ts +1 -1
- package/src/ui/messages.ts +50 -8
- package/src/ui/progress.ts +14 -3
- package/src/ui/prompts.ts +17 -9
- package/src/ui/runtime/cancel.ts +6 -0
- package/src/ui/runtime/command-chrome.ts +147 -0
- package/src/ui/runtime/dev-prompt-queue.ts +84 -0
- package/src/ui/runtime/flow-session.ts +11 -0
- package/src/ui/runtime/run-clack-flow.tsx +65 -0
- package/src/ui/runtime/stdin-after-ink.ts +18 -0
- package/src/ui/theme.ts +41 -0
- package/src/valkey-sidecar.ts +126 -0
- package/tests/admin-ensure.test.ts +80 -0
- package/tests/binary-cache-cloud-overrides.test.ts +2 -2
- package/tests/binary-download-lock.test.ts +41 -0
- package/tests/cli-help.test.ts +7 -4
- package/tests/cli-package-version.test.ts +15 -0
- package/tests/command-chrome-coverage.test.ts +149 -0
- package/tests/command-chrome-wrap.test.ts +51 -0
- package/tests/config.test.ts +27 -4
- package/tests/dev-ready-panel.test.ts +37 -0
- package/tests/dev-ui.test.ts +42 -2
- package/tests/docker-runtime.test.ts +9 -20
- package/tests/ensure-dev-api-config.test.ts +22 -0
- package/tests/init-dependency-versions.test.ts +62 -0
- package/tests/init-package-json.test.ts +18 -0
- package/tests/init-project-detect.test.ts +53 -0
- package/tests/init.test.ts +30 -3
- package/tests/required-host-components.test.ts +51 -0
- package/tests/resolve-api-url.test.ts +23 -0
- package/tests/rest-cache-admin.test.ts +28 -0
- package/tests/runtime-contract.test.ts +12 -3
- package/tests/stdin-after-ink.test.ts +8 -0
- package/tests/tsconfig.json +8 -2
- package/tests/ui-confirm.test.ts +13 -9
- package/tests/ui-messages.test.ts +4 -18
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/vitest.config.ts +3 -0
- package/dist/dev-tui.d.ts +0 -24
- package/dist/dev-tui.d.ts.map +0 -1
- package/dist/dev-tui.js +0 -188
- package/dist/dev-tui.js.map +0 -1
- package/src/dev-tui.ts +0 -232
package/dist/ui/prompts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { SUPATYPE_ASCII_LOGO_WORDMARK, colorLogoLines } from "../dev-logo.js";
|
|
3
|
-
import { plain } from "./messages.js";
|
|
1
|
+
import { colorLogoLines, SUPATYPE_ASCII_LOGO_WORDMARK } from "../dev-logo.js";
|
|
4
2
|
import { isInteractive } from "./interactive.js";
|
|
3
|
+
import { plain } from "./messages.js";
|
|
4
|
+
import { isCancel, p } from "./clack.js";
|
|
5
5
|
/** Print the coloured Supatype ASCII wordmark at the top of an interactive command. */
|
|
6
6
|
export function printLogo() {
|
|
7
7
|
plain();
|
|
@@ -9,16 +9,15 @@ export function printLogo() {
|
|
|
9
9
|
plain();
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Unwrap a
|
|
12
|
+
* Unwrap a prompt result, exiting cleanly when the user cancels (Ctrl-C).
|
|
13
13
|
*/
|
|
14
14
|
export function ensureNotCancelled(value, cancelMessage = "Cancelled.") {
|
|
15
|
-
if (
|
|
15
|
+
if (isCancel(value)) {
|
|
16
16
|
p.cancel(cancelMessage);
|
|
17
|
-
process.exit(0);
|
|
18
17
|
}
|
|
19
18
|
return value;
|
|
20
19
|
}
|
|
21
|
-
/** Single-line text input
|
|
20
|
+
/** Single-line text input (TTY only). */
|
|
22
21
|
export async function promptText(message, opts) {
|
|
23
22
|
if (!isInteractive()) {
|
|
24
23
|
throw new Error(`Cannot prompt for "${message}" in non-interactive mode.`);
|
|
@@ -30,5 +29,13 @@ export async function promptText(message, opts) {
|
|
|
30
29
|
});
|
|
31
30
|
return ensureNotCancelled(value).trim();
|
|
32
31
|
}
|
|
33
|
-
|
|
32
|
+
/** Masked password input (TTY only). */
|
|
33
|
+
export async function promptPassword(message) {
|
|
34
|
+
if (!isInteractive()) {
|
|
35
|
+
throw new Error(`Cannot prompt for "${message}" in non-interactive mode.`);
|
|
36
|
+
}
|
|
37
|
+
const value = await p.password({ message });
|
|
38
|
+
return ensureNotCancelled(value).trim();
|
|
39
|
+
}
|
|
40
|
+
export { p, clack, isCancel, CLACK_CANCEL, runClackFlow } from "./clack.js";
|
|
34
41
|
//# sourceMappingURL=prompts.js.map
|
package/dist/ui/prompts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/ui/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/ui/prompts.ts"],"names":[],"mappings":"AAAA,OA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,CAAC,IAAI,EAAE,CAAA;AACzC,CAAC;AAED,wCAAwC;AACxC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAe;IAClD,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,sBAAsB,OAAO,4BAA4B,CAAC,CAAA;IAC5E,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;IAC3C,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAA;AACzC,CAAC;AAED,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel.d.ts","sourceRoot":"","sources":["../../../src/ui/runtime/cancel.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,eAAO,MAAM,YAAY,eAA4B,CAAA;AAErD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,YAAY,CAErE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/ui/runtime/cancel.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAA;AAErD,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,KAAK,KAAK,YAAY,CAAA;AAC/B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Branded Ink chrome for one-shot CLI commands (push, diff, adopt, …).
|
|
3
|
+
* Reuses the flow shell: figlet logo, coloured log pane, ink-spinner, prompts.
|
|
4
|
+
*/
|
|
5
|
+
import type { Command } from "commander";
|
|
6
|
+
/**
|
|
7
|
+
* Run a command body inside the branded Ink shell (logo + logs + spinner).
|
|
8
|
+
* Falls back to plain stdout when not interactive.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runCommandChrome<T>(fn: () => Promise<T>): Promise<T>;
|
|
11
|
+
/** True while `runCommandChrome` / `runClackFlow` is active. */
|
|
12
|
+
export declare function isCommandChromeActive(): boolean;
|
|
13
|
+
/** Whether a registered command path should skip automatic command chrome. */
|
|
14
|
+
export declare function shouldExcludeCommandChrome(commandPath: string): boolean;
|
|
15
|
+
/** Wrap every leaf command action with branded Ink chrome (see exclusions above). */
|
|
16
|
+
export declare function wrapProgramActionsWithChrome(program: Command): void;
|
|
17
|
+
//# sourceMappingURL=command-chrome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-chrome.d.ts","sourceRoot":"","sources":["../../../src/ui/runtime/command-chrome.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA8DxC;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAa1E;AAED,gEAAgE;AAChE,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAqBD,8EAA8E;AAC9E,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAKvE;AAqBD,qFAAqF;AACrF,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAQnE"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Branded Ink chrome for one-shot CLI commands (push, diff, adopt, …).
|
|
3
|
+
* Reuses the flow shell: figlet logo, coloured log pane, ink-spinner, prompts.
|
|
4
|
+
*/
|
|
5
|
+
import { getActiveFlowApi } from "./flow-session.js";
|
|
6
|
+
import { runClackFlow } from "../clack.js";
|
|
7
|
+
import { isInteractive } from "../interactive.js";
|
|
8
|
+
import { filterCommandLogLine, formatConsoleArgs, stripAnsi, } from "../../dev-log-filter.js";
|
|
9
|
+
function patchConsoleForCommand(api) {
|
|
10
|
+
const original = {
|
|
11
|
+
log: console.log,
|
|
12
|
+
warn: console.warn,
|
|
13
|
+
error: console.error,
|
|
14
|
+
};
|
|
15
|
+
const emitLine = (raw, stream) => {
|
|
16
|
+
if (!filterCommandLogLine(raw))
|
|
17
|
+
return;
|
|
18
|
+
const t = stripAnsi(raw).trim();
|
|
19
|
+
if (!t)
|
|
20
|
+
return;
|
|
21
|
+
const stripped = t.replace(/^\[supatype\]\s*/, "");
|
|
22
|
+
if (stream === "error" || stripped.startsWith("✗")) {
|
|
23
|
+
api.log.error(stripped.replace(/^✗\s*/, ""));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (stream === "warn" || stripped.startsWith("⚠")) {
|
|
27
|
+
api.log.warn(stripped.replace(/^⚠\s*/, ""));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (stripped.startsWith("✓")) {
|
|
31
|
+
api.log.success(stripped.replace(/^✓\s*/, ""));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (/\[supatype\]/.test(raw)) {
|
|
35
|
+
api.log.info(stripped);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
api.note(t);
|
|
39
|
+
};
|
|
40
|
+
const wrap = (stream) => (...args) => {
|
|
41
|
+
for (const part of formatConsoleArgs(args).split(/\r?\n/)) {
|
|
42
|
+
emitLine(part, stream);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
console.log = wrap("log");
|
|
46
|
+
console.warn = wrap("warn");
|
|
47
|
+
console.error = wrap("error");
|
|
48
|
+
return () => {
|
|
49
|
+
console.log = original.log;
|
|
50
|
+
console.warn = original.warn;
|
|
51
|
+
console.error = original.error;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Run a command body inside the branded Ink shell (logo + logs + spinner).
|
|
56
|
+
* Falls back to plain stdout when not interactive.
|
|
57
|
+
*/
|
|
58
|
+
export async function runCommandChrome(fn) {
|
|
59
|
+
if (!isInteractive() || isCommandChromeActive()) {
|
|
60
|
+
return fn();
|
|
61
|
+
}
|
|
62
|
+
return runClackFlow(async (api) => {
|
|
63
|
+
const restore = patchConsoleForCommand(api);
|
|
64
|
+
try {
|
|
65
|
+
return await fn();
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
restore();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** True while `runCommandChrome` / `runClackFlow` is active. */
|
|
73
|
+
export function isCommandChromeActive() {
|
|
74
|
+
return getActiveFlowApi() !== null;
|
|
75
|
+
}
|
|
76
|
+
/** Commands that mount their own Ink UI — do not wrap with command chrome. */
|
|
77
|
+
const WIZARD_COMMAND_PATHS = new Set(["dev", "init", "link"]);
|
|
78
|
+
/** Prefixes for subcommands that call `runClackFlow` internally. */
|
|
79
|
+
const WIZARD_COMMAND_PREFIXES = ["add "];
|
|
80
|
+
/** Long-running or stdio-inherit commands where chrome would fight subprocess output. */
|
|
81
|
+
const STREAMING_COMMAND_PATHS = new Set([
|
|
82
|
+
"logs",
|
|
83
|
+
"pg psql",
|
|
84
|
+
"functions serve",
|
|
85
|
+
"self-host compose logs",
|
|
86
|
+
]);
|
|
87
|
+
/** Whether a registered command path should skip automatic command chrome. */
|
|
88
|
+
export function shouldExcludeCommandChrome(commandPath) {
|
|
89
|
+
if (WIZARD_COMMAND_PATHS.has(commandPath))
|
|
90
|
+
return true;
|
|
91
|
+
if (WIZARD_COMMAND_PREFIXES.some((prefix) => commandPath.startsWith(prefix)))
|
|
92
|
+
return true;
|
|
93
|
+
if (STREAMING_COMMAND_PATHS.has(commandPath))
|
|
94
|
+
return true;
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
function commandPath(cmd, root) {
|
|
98
|
+
const segments = [];
|
|
99
|
+
let current = cmd;
|
|
100
|
+
while (current && current !== root) {
|
|
101
|
+
segments.unshift(current.name());
|
|
102
|
+
current = current.parent ?? null;
|
|
103
|
+
}
|
|
104
|
+
return segments.join(" ");
|
|
105
|
+
}
|
|
106
|
+
function wrapCommandAction(cmd, root) {
|
|
107
|
+
const path = commandPath(cmd, root);
|
|
108
|
+
const handler = cmd._actionHandler;
|
|
109
|
+
if (!handler || shouldExcludeCommandChrome(path))
|
|
110
|
+
return;
|
|
111
|
+
cmd._actionHandler = (args) => runCommandChrome(() => Promise.resolve(handler(args)));
|
|
112
|
+
}
|
|
113
|
+
/** Wrap every leaf command action with branded Ink chrome (see exclusions above). */
|
|
114
|
+
export function wrapProgramActionsWithChrome(program) {
|
|
115
|
+
const walk = (cmd) => {
|
|
116
|
+
wrapCommandAction(cmd, program);
|
|
117
|
+
for (const sub of cmd.commands) {
|
|
118
|
+
walk(sub);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
walk(program);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=command-chrome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-chrome.js","sourceRoot":"","sources":["../../../src/ui/runtime/command-chrome.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,SAAS,GACV,MAAM,yBAAyB,CAAA;AAEhC,SAAS,sBAAsB,CAAC,GAAa;IAC3C,MAAM,QAAQ,GAAG;QACf,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAA;IAED,MAAM,QAAQ,GAAG,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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,4BAA4B,CAAC,OAAgB;IAC3D,MAAM,IAAI,GAAG,CAAC,GAAsB,EAAQ,EAAE;QAC5C,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC/B,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC,GAAwB,CAAC,CAAA;QAChC,CAAC;IACH,CAAC,CAAA;IACD,IAAI,CAAC,OAA4B,CAAC,CAAA;AACpC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Imperative prompt queue for the dev dashboard overlay.
|
|
3
|
+
*/
|
|
4
|
+
import { CLACK_CANCEL } from "./cancel.js";
|
|
5
|
+
export type DevPromptKind = "confirm" | "text" | "password" | "select";
|
|
6
|
+
export interface DevSelectOption<T extends string = string> {
|
|
7
|
+
value: T;
|
|
8
|
+
label: string;
|
|
9
|
+
hint?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DevPromptRequest<T = unknown> {
|
|
12
|
+
id: number;
|
|
13
|
+
kind: DevPromptKind;
|
|
14
|
+
message: string;
|
|
15
|
+
initialValue?: string | boolean;
|
|
16
|
+
defaultValue?: string;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
mask?: boolean;
|
|
19
|
+
options?: DevSelectOption[];
|
|
20
|
+
validate?: (value: string) => string | undefined;
|
|
21
|
+
resolve: (value: T | typeof CLACK_CANCEL) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function subscribeDevPrompts(listener: () => void): () => void;
|
|
24
|
+
export declare function getActiveDevPrompt(): DevPromptRequest | null;
|
|
25
|
+
export declare function enqueueDevPrompt<T>(spec: Omit<DevPromptRequest<T>, "id" | "resolve">): Promise<T | typeof CLACK_CANCEL>;
|
|
26
|
+
export declare function resolveDevPrompt(value: unknown): void;
|
|
27
|
+
export declare function clearDevPromptQueue(): void;
|
|
28
|
+
/** @internal Tests */
|
|
29
|
+
export declare function resetDevPromptQueueForTests(): void;
|
|
30
|
+
//# sourceMappingURL=dev-prompt-queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-prompt-queue.d.ts","sourceRoot":"","sources":["../../../src/ui/runtime/dev-prompt-queue.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEtE,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACxD,KAAK,EAAE,CAAC,CAAA;IACR,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC3C,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,aAAa,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,eAAe,EAAE,CAAA;IAC3B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;IAChD,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,YAAY,KAAK,IAAI,CAAA;CAClD;AAWD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAGpE;AAED,wBAAgB,kBAAkB,IAAI,gBAAgB,GAAG,IAAI,CAE5D;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,YAAY,CAAC,CAavH;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAMrD;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAS1C;AAED,sBAAsB;AACtB,wBAAgB,2BAA2B,IAAI,IAAI,CAGlD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Imperative prompt queue for the dev dashboard overlay.
|
|
3
|
+
*/
|
|
4
|
+
import { CLACK_CANCEL } from "./cancel.js";
|
|
5
|
+
let nextId = 0;
|
|
6
|
+
let active = null;
|
|
7
|
+
const waiters = [];
|
|
8
|
+
const listeners = new Set();
|
|
9
|
+
function notify() {
|
|
10
|
+
for (const listener of listeners)
|
|
11
|
+
listener();
|
|
12
|
+
}
|
|
13
|
+
export function subscribeDevPrompts(listener) {
|
|
14
|
+
listeners.add(listener);
|
|
15
|
+
return () => listeners.delete(listener);
|
|
16
|
+
}
|
|
17
|
+
export function getActiveDevPrompt() {
|
|
18
|
+
return active;
|
|
19
|
+
}
|
|
20
|
+
export function enqueueDevPrompt(spec) {
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
const request = {
|
|
23
|
+
...spec,
|
|
24
|
+
id: nextId++,
|
|
25
|
+
resolve: resolve,
|
|
26
|
+
};
|
|
27
|
+
waiters.push(request);
|
|
28
|
+
if (!active) {
|
|
29
|
+
active = waiters.shift() ?? null;
|
|
30
|
+
}
|
|
31
|
+
notify();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export function resolveDevPrompt(value) {
|
|
35
|
+
if (!active)
|
|
36
|
+
return;
|
|
37
|
+
const current = active;
|
|
38
|
+
active = waiters.shift() ?? null;
|
|
39
|
+
current.resolve(value);
|
|
40
|
+
notify();
|
|
41
|
+
}
|
|
42
|
+
export function clearDevPromptQueue() {
|
|
43
|
+
while (active) {
|
|
44
|
+
active.resolve(CLACK_CANCEL);
|
|
45
|
+
active = waiters.shift() ?? null;
|
|
46
|
+
}
|
|
47
|
+
for (const pending of waiters.splice(0)) {
|
|
48
|
+
pending.resolve(CLACK_CANCEL);
|
|
49
|
+
}
|
|
50
|
+
notify();
|
|
51
|
+
}
|
|
52
|
+
/** @internal Tests */
|
|
53
|
+
export function resetDevPromptQueueForTests() {
|
|
54
|
+
clearDevPromptQueue();
|
|
55
|
+
nextId = 0;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=dev-prompt-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-prompt-queue.js","sourceRoot":"","sources":["../../../src/ui/runtime/dev-prompt-queue.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAuB1C,IAAI,MAAM,GAAG,CAAC,CAAA;AACd,IAAI,MAAM,GAA4B,IAAI,CAAA;AAC1C,MAAM,OAAO,GAAuB,EAAE,CAAA;AACtC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;AAEvC,SAAS,MAAM;IACb,KAAK,MAAM,QAAQ,IAAI,SAAS;QAAE,QAAQ,EAAE,CAAA;AAC9C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAAoB;IACtD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACvB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAI,IAAiD;IACnF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAwB;YACnC,GAAG,IAAI;YACP,EAAE,EAAE,MAAM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AgB,gBAAgB,IAAI,QAAQ,GAAG,IAAI,CAElD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-session.js","sourceRoot":"","sources":["../../../src/ui/runtime/flow-session.ts"],"names":[],"mappings":"AAEA,IAAI,aAAa,GAAoB,IAAI,CAAA;AAEzC,MAAM,UAAU,gBAAgB,CAAC,GAAoB;IACnD,aAAa,GAAG,GAAG,CAAA;AACrB,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAA;AACtB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ClackApi } from "../clack-api.js";
|
|
2
|
+
/** Mount a single Ink flow session (init wizard, standalone confirm, etc.). */
|
|
3
|
+
export declare function runClackFlow<T>(run: (api: ClackApi) => Promise<T>): Promise<T>;
|
|
4
|
+
export { CLACK_CANCEL } from "./cancel.js";
|
|
5
|
+
//# sourceMappingURL=run-clack-flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-clack-flow.d.ts","sourceRoot":"","sources":["../../../src/ui/runtime/run-clack-flow.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AA0B/D,+EAA+E;AAC/E,wBAAsB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAqBpF;AAaD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { render } from "ink";
|
|
4
|
+
import { isInteractive } from "../interactive.js";
|
|
5
|
+
import { createClackApi } from "../clack-api.js";
|
|
6
|
+
import { FlowApp } from "../flows/FlowApp.js";
|
|
7
|
+
import { restoreStdinAfterInk } from "./stdin-after-ink.js";
|
|
8
|
+
function RunClackFlowRoot({ run, onComplete, onError }) {
|
|
9
|
+
const started = useRef(false);
|
|
10
|
+
return (_jsx(FlowApp, { bind: (controller) => {
|
|
11
|
+
if (started.current)
|
|
12
|
+
return;
|
|
13
|
+
started.current = true;
|
|
14
|
+
void run(createClackApi(controller))
|
|
15
|
+
.then(onComplete)
|
|
16
|
+
.catch(onError);
|
|
17
|
+
} }));
|
|
18
|
+
}
|
|
19
|
+
/** Mount a single Ink flow session (init wizard, standalone confirm, etc.). */
|
|
20
|
+
export async function runClackFlow(run) {
|
|
21
|
+
if (!isInteractive()) {
|
|
22
|
+
throw new Error("Interactive Ink flow requires a TTY.");
|
|
23
|
+
}
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
const instance = render(_jsx(RunClackFlowRoot, { run: run, onComplete: (value) => {
|
|
26
|
+
teardownInk(instance);
|
|
27
|
+
resolve(value);
|
|
28
|
+
}, onError: (err) => {
|
|
29
|
+
teardownInk(instance);
|
|
30
|
+
reject(err);
|
|
31
|
+
} }), { patchConsole: false });
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function teardownInk(instance) {
|
|
35
|
+
try {
|
|
36
|
+
instance.clear();
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// ignore — terminal may already be reset
|
|
40
|
+
}
|
|
41
|
+
instance.unmount();
|
|
42
|
+
instance.cleanup();
|
|
43
|
+
restoreStdinAfterInk();
|
|
44
|
+
}
|
|
45
|
+
export { CLACK_CANCEL } from "./cancel.js";
|
|
46
|
+
//# sourceMappingURL=run-clack-flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-clack-flow.js","sourceRoot":"","sources":["../../../src/ui/runtime/run-clack-flow.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,EAAE,MAAM,EAAiB,MAAM,K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,GACD,EACF,EAAE,YAAY,EAAE,KAAK,EAAE,CACxB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,QAAkB;IACrC,IAAI,CAAC;QACH,QAAQ,CAAC,KAAK,EAAE,CAAA;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,yCAAyC;IAC3C,CAAC;IACD,QAAQ,CAAC,OAAO,EAAE,CAAA;IAClB,QAAQ,CAAC,OAAO,EAAE,CAAA;IAClB,oBAAoB,EAAE,CAAA;AACxB,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin-after-ink.d.ts","sourceRoot":"","sources":["../../../src/ui/runtime/stdin-after-ink.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,wBAAgB,oBAAoB,IAAI,IAAI,CAgB3C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Restore stdin after Ink unmount so one-shot commands (init, link) can exit cleanly. */
|
|
2
|
+
export function restoreStdinAfterInk() {
|
|
3
|
+
if (!process.stdin.isTTY)
|
|
4
|
+
return;
|
|
5
|
+
const stdin = process.stdin;
|
|
6
|
+
try {
|
|
7
|
+
if (stdin.isRaw)
|
|
8
|
+
stdin.setRawMode?.(false);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
// ignore — stdin may already be restored
|
|
12
|
+
}
|
|
13
|
+
stdin.resume();
|
|
14
|
+
process.stdout.write("\n");
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=stdin-after-ink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin-after-ink.js","sourceRoot":"","sources":["../../../src/ui/runtime/stdin-after-ink.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,MAAM,UAAU,oBAAoB;IAClC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK;QAAE,OAAM;IAEhC,MAAM,KAAK,GAAG,OAAO,CAAC,KAGrB,CAAA;IAED,IAAI,CAAC;QACH,IAAI,KAAK,CAAC,KAAK;YAAE,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAA;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,yCAAyC;IAC3C,CAAC;IAED,KAAK,CAAC,MAAM,EAAE,CAAA;IACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supatype terminal design tokens — shared by Ink components and plain CI output.
|
|
3
|
+
*/
|
|
4
|
+
export declare const RESET = "\u001B[0m";
|
|
5
|
+
export declare const DIM = "\u001B[2m";
|
|
6
|
+
export declare const BOLD = "\u001B[1m";
|
|
7
|
+
export declare const theme: {
|
|
8
|
+
readonly brand: "magenta";
|
|
9
|
+
readonly brandHex: "#c084fc";
|
|
10
|
+
readonly info: "cyan";
|
|
11
|
+
readonly warn: "yellow";
|
|
12
|
+
readonly error: "red";
|
|
13
|
+
readonly success: "green";
|
|
14
|
+
readonly dim: "gray";
|
|
15
|
+
readonly muted: "gray";
|
|
16
|
+
};
|
|
17
|
+
/** Legacy ANSI exports used by dev-logo / dev-task-colors. */
|
|
18
|
+
export declare const BRAND_COLOR = "\u001B[35m";
|
|
19
|
+
export declare function brandStyle(text: string): string;
|
|
20
|
+
export declare function plainInfo(message: string): string;
|
|
21
|
+
export declare function plainWarn(message: string): string;
|
|
22
|
+
export declare function plainError(message: string): string;
|
|
23
|
+
export declare function plainSuccess(message: string): string;
|
|
24
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/ui/theme.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,KAAK,cAAY,CAAA;AAC9B,eAAO,MAAM,GAAG,cAAY,CAAA;AAC5B,eAAO,MAAM,IAAI,cAAY,CAAA;AAE7B,eAAO,MAAM,KAAK;;;;;;;;;CASR,CAAA;AAEV,8DAA8D;AAC9D,eAAO,MAAM,WAAW,eAAa,CAAA;AAErC,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
package/dist/ui/theme.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supatype terminal design tokens — shared by Ink components and plain CI output.
|
|
3
|
+
*/
|
|
4
|
+
export const RESET = "\x1b[0m";
|
|
5
|
+
export const DIM = "\x1b[2m";
|
|
6
|
+
export const BOLD = "\x1b[1m";
|
|
7
|
+
export const theme = {
|
|
8
|
+
brand: "magenta",
|
|
9
|
+
brandHex: "#c084fc",
|
|
10
|
+
info: "cyan",
|
|
11
|
+
warn: "yellow",
|
|
12
|
+
error: "red",
|
|
13
|
+
success: "green",
|
|
14
|
+
dim: "gray",
|
|
15
|
+
muted: "gray",
|
|
16
|
+
};
|
|
17
|
+
/** Legacy ANSI exports used by dev-logo / dev-task-colors. */
|
|
18
|
+
export const BRAND_COLOR = "\x1b[35m";
|
|
19
|
+
export function brandStyle(text) {
|
|
20
|
+
return `${BRAND_COLOR}${BOLD}${text}${RESET}`;
|
|
21
|
+
}
|
|
22
|
+
export function plainInfo(message) {
|
|
23
|
+
return `${theme.info === "cyan" ? "\x1b[36m" : ""}ℹ ${message}${RESET}`;
|
|
24
|
+
}
|
|
25
|
+
export function plainWarn(message) {
|
|
26
|
+
return `\x1b[33m⚠ ${message}${RESET}`;
|
|
27
|
+
}
|
|
28
|
+
export function plainError(message) {
|
|
29
|
+
return `\x1b[31m✗ ${message}${RESET}`;
|
|
30
|
+
}
|
|
31
|
+
export function plainSuccess(message) {
|
|
32
|
+
return `\x1b[32m✓ ${message}${RESET}`;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/ui/theme.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAA;AAC9B,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAA;AAC5B,MAAM,CAAC,MAAM,IAAI,GAAG,SAAS,CAAA;AAE7B,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,SAAkB;IACzB,QAAQ,EAAE,SAAS;IACnB,IAAI,EAAE,MAAe;IACrB,IAAI,EAAE,QAAiB;IACvB,KAAK,EAAE,KAAc;IACrB,OAAO,EAAE,OAAgB;IACzB,GAAG,EAAE,MAAe;IACpB,KAAK,EAAE,MAAe;CACd,CAAA;AAEV,8DAA8D;AAC9D,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAA;AAErC,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,GAAG,WAAW,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,EAAE,CAAA;AAC/C,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO,GAAG,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,GAAG,KAAK,EAAE,CAAA;AACzE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO,aAAa,OAAO,GAAG,KAAK,EAAE,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,OAAO,aAAa,OAAO,GAAG,KAAK,EAAE,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,OAAO,aAAa,OAAO,GAAG,KAAK,EAAE,CAAA;AACvC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight Valkey container for native `supatype dev` (REST response cache).
|
|
3
|
+
*/
|
|
4
|
+
export interface ValkeySidecarResult {
|
|
5
|
+
addr: string;
|
|
6
|
+
containerName: string | null;
|
|
7
|
+
started: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Ensure Valkey is reachable at 127.0.0.1:6379 for native dev.
|
|
11
|
+
* Starts a named Docker container when Docker is available and nothing is listening.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ensureValkeySidecar(projectName: string): ValkeySidecarResult;
|
|
14
|
+
export declare function stopValkeySidecar(containerName: string | null): void;
|
|
15
|
+
/** @internal Test helper — probe without subprocess. */
|
|
16
|
+
export declare function probeTcp(host: string, port: number): Promise<boolean>;
|
|
17
|
+
//# sourceMappingURL=valkey-sidecar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valkey-sidecar.d.ts","sourceRoot":"","sources":["../src/valkey-sidecar.ts"],"names":[],"mappings":"AAAA;;GAEG;AA4CH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;CACjB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,mBAAmB,CAgD5E;AAED,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAGpE;AAED,wDAAwD;AACxD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAarE"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight Valkey container for native `supatype dev` (REST response cache).
|
|
3
|
+
*/
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { createConnection } from "node:net";
|
|
6
|
+
const DEFAULT_HOST = "127.0.0.1";
|
|
7
|
+
const DEFAULT_PORT = 6379;
|
|
8
|
+
const IMAGE = "valkey/valkey:8-alpine";
|
|
9
|
+
function containerName(projectName) {
|
|
10
|
+
const safe = projectName.replace(/[^a-zA-Z0-9_-]/g, "-").slice(0, 48);
|
|
11
|
+
return `supatype-valkey-dev-${safe}`;
|
|
12
|
+
}
|
|
13
|
+
function dockerAvailable() {
|
|
14
|
+
const r = spawnSync("docker", ["info"], { stdio: "ignore" });
|
|
15
|
+
return r.status === 0;
|
|
16
|
+
}
|
|
17
|
+
function isAddrReachable(host, port, timeoutMs = 800) {
|
|
18
|
+
try {
|
|
19
|
+
const r = spawnSync(process.execPath, [
|
|
20
|
+
"-e",
|
|
21
|
+
`const n=require('net');const s=n.createConnection({host:${JSON.stringify(host)},port:${port}});` +
|
|
22
|
+
`s.on('connect',()=>{s.end();process.exit(0)});s.on('error',()=>process.exit(1));` +
|
|
23
|
+
`setTimeout(()=>process.exit(1),${timeoutMs})`,
|
|
24
|
+
], { stdio: "ignore" });
|
|
25
|
+
return r.status === 0;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function sleepMs(ms) {
|
|
32
|
+
const end = Date.now() + ms;
|
|
33
|
+
while (Date.now() < end) {
|
|
34
|
+
/* spin */
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Ensure Valkey is reachable at 127.0.0.1:6379 for native dev.
|
|
39
|
+
* Starts a named Docker container when Docker is available and nothing is listening.
|
|
40
|
+
*/
|
|
41
|
+
export function ensureValkeySidecar(projectName) {
|
|
42
|
+
const envAddr = process.env["SUPATYPE_VALKEY_ADDR"]?.trim();
|
|
43
|
+
if (envAddr) {
|
|
44
|
+
return { addr: envAddr, containerName: null, started: false };
|
|
45
|
+
}
|
|
46
|
+
const addr = `${DEFAULT_HOST}:${DEFAULT_PORT}`;
|
|
47
|
+
if (isAddrReachable(DEFAULT_HOST, DEFAULT_PORT)) {
|
|
48
|
+
return { addr, containerName: null, started: false };
|
|
49
|
+
}
|
|
50
|
+
if (!dockerAvailable()) {
|
|
51
|
+
console.warn("[supatype] ⚠ Valkey not available (Docker not running). " +
|
|
52
|
+
"REST server cache (`cache({ server: true })`) will bypass until Valkey is reachable.");
|
|
53
|
+
return { addr: "", containerName: null, started: false };
|
|
54
|
+
}
|
|
55
|
+
const name = containerName(projectName);
|
|
56
|
+
spawnSync("docker", ["rm", "-f", name], { stdio: "ignore" });
|
|
57
|
+
const run = spawnSync("docker", ["run", "-d", "--name", name, "-p", `${DEFAULT_PORT}:6379`, IMAGE], { encoding: "utf8" });
|
|
58
|
+
if (run.status !== 0) {
|
|
59
|
+
const detail = (run.stderr || run.stdout || "").trim();
|
|
60
|
+
console.warn(`[supatype] ⚠ Could not start Valkey sidecar: ${detail || `exit ${run.status}`}\n` +
|
|
61
|
+
" REST server cache will bypass until Valkey is available.");
|
|
62
|
+
return { addr: "", containerName: null, started: false };
|
|
63
|
+
}
|
|
64
|
+
for (let i = 0; i < 30; i++) {
|
|
65
|
+
if (isAddrReachable(DEFAULT_HOST, DEFAULT_PORT)) {
|
|
66
|
+
console.log(`[supatype] Valkey sidecar running (${addr})`);
|
|
67
|
+
return { addr, containerName: name, started: true };
|
|
68
|
+
}
|
|
69
|
+
sleepMs(100);
|
|
70
|
+
}
|
|
71
|
+
console.warn("[supatype] ⚠ Valkey sidecar started but not reachable yet — cache may bypass initially.");
|
|
72
|
+
return { addr, containerName: name, started: true };
|
|
73
|
+
}
|
|
74
|
+
export function stopValkeySidecar(containerName) {
|
|
75
|
+
if (!containerName)
|
|
76
|
+
return;
|
|
77
|
+
spawnSync("docker", ["rm", "-f", containerName], { stdio: "ignore" });
|
|
78
|
+
}
|
|
79
|
+
/** @internal Test helper — probe without subprocess. */
|
|
80
|
+
export function probeTcp(host, port) {
|
|
81
|
+
return new Promise((resolve) => {
|
|
82
|
+
const s = createConnection({ host, port });
|
|
83
|
+
s.once("connect", () => {
|
|
84
|
+
s.destroy();
|
|
85
|
+
resolve(true);
|
|
86
|
+
});
|
|
87
|
+
s.once("error", () => resolve(false));
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
s.destroy();
|
|
90
|
+
resolve(false);
|
|
91
|
+
}, 800);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=valkey-sidecar.js.map
|