skybridge 0.0.0-dev.cb3b28d → 0.0.0-dev.cb51733
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/README.md +123 -124
- package/dist/cli/detect-port.js.map +1 -1
- package/dist/cli/header.js.map +1 -1
- package/dist/cli/run-command.js.map +1 -1
- package/dist/cli/telemetry.js.map +1 -1
- package/dist/cli/tunnel-control-server.js.map +1 -1
- package/dist/cli/tunnel-control-server.test.js.map +1 -1
- package/dist/cli/tunnel-handler.js.map +1 -1
- package/dist/cli/tunnel-handler.test.js.map +1 -1
- package/dist/cli/tunnel.js +2 -2
- package/dist/cli/tunnel.js.map +1 -1
- package/dist/cli/tunnel.test.js.map +1 -1
- package/dist/cli/types.js.map +1 -1
- package/dist/cli/use-execute-steps.js.map +1 -1
- package/dist/cli/use-messages.js.map +1 -1
- package/dist/cli/use-nodemon.js +11 -2
- package/dist/cli/use-nodemon.js.map +1 -1
- package/dist/cli/use-open-browser.js.map +1 -1
- package/dist/cli/use-tunnel.js.map +1 -1
- package/dist/cli/use-typescript-check.js +1 -1
- package/dist/cli/use-typescript-check.js.map +1 -1
- package/dist/commands/build-helpers.d.ts +26 -0
- package/dist/commands/build-helpers.js +93 -0
- package/dist/commands/build-helpers.js.map +1 -0
- package/dist/commands/build-helpers.test.d.ts +1 -0
- package/dist/commands/build-helpers.test.js +116 -0
- package/dist/commands/build-helpers.test.js.map +1 -0
- package/dist/commands/build.d.ts +6 -1
- package/dist/commands/build.js +106 -48
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/create.d.ts +9 -0
- package/dist/commands/create.js +30 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.js +4 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/telemetry/disable.js.map +1 -1
- package/dist/commands/telemetry/enable.js.map +1 -1
- package/dist/commands/telemetry/status.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.d.ts +1 -0
- package/dist/server/asset-base-url-transform-plugin.js +16 -1
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.test.js +51 -1
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
- package/dist/server/auth.d.ts +20 -0
- package/dist/server/auth.js +28 -0
- package/dist/server/auth.js.map +1 -0
- package/dist/server/content-helpers.d.ts +40 -0
- package/dist/server/content-helpers.js +33 -0
- package/dist/server/content-helpers.js.map +1 -1
- package/dist/server/content-helpers.test.js.map +1 -1
- package/dist/server/express.d.ts +1 -5
- package/dist/server/express.js +5 -5
- package/dist/server/express.js.map +1 -1
- package/dist/server/express.test.js +211 -71
- package/dist/server/express.test.js.map +1 -1
- package/dist/server/file-ref.d.ts +28 -0
- package/dist/server/file-ref.js +27 -0
- package/dist/server/file-ref.js.map +1 -0
- package/dist/server/index.d.ts +3 -1
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/inferUtilityTypes.js.map +1 -1
- package/dist/server/metric.js.map +1 -1
- package/dist/server/middleware.d.ts +16 -3
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/middleware.test-d.js.map +1 -1
- package/dist/server/middleware.test.js.map +1 -1
- package/dist/server/server.d.ts +221 -6
- package/dist/server/server.js +183 -71
- package/dist/server/server.js.map +1 -1
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates.generated.js.map +1 -1
- package/dist/server/tunnel-proxy-router.js.map +1 -1
- package/dist/server/tunnel-proxy-router.test.js.map +1 -1
- package/dist/server/viewsDevServer.js.map +1 -1
- package/dist/test/utils.js.map +1 -1
- package/dist/test/view.test.js +45 -0
- package/dist/test/view.test.js.map +1 -1
- package/dist/version.js.map +1 -1
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +6 -2
- package/dist/web/bridges/apps-sdk/adaptor.js +23 -3
- package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -1
- package/dist/web/bridges/apps-sdk/bridge.d.ts +1 -0
- package/dist/web/bridges/apps-sdk/bridge.js +1 -0
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
- package/dist/web/bridges/apps-sdk/index.js.map +1 -1
- package/dist/web/bridges/apps-sdk/types.d.ts +8 -1
- package/dist/web/bridges/apps-sdk/types.js.map +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +11 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +11 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
- package/dist/web/bridges/get-adaptor.d.ts +7 -0
- package/dist/web/bridges/get-adaptor.js +7 -0
- package/dist/web/bridges/get-adaptor.js.map +1 -1
- package/dist/web/bridges/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/adaptor.d.ts +6 -2
- package/dist/web/bridges/mcp-app/adaptor.js +18 -6
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.d.ts +1 -0
- package/dist/web/bridges/mcp-app/bridge.js +1 -0
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/types.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +12 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +12 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
- package/dist/web/bridges/types.d.ts +65 -3
- package/dist/web/bridges/types.js.map +1 -1
- package/dist/web/bridges/use-host-context.d.ts +5 -0
- package/dist/web/bridges/use-host-context.js +5 -0
- package/dist/web/bridges/use-host-context.js.map +1 -1
- package/dist/web/components/modal-provider.js.map +1 -1
- package/dist/web/create-store.d.ts +26 -0
- package/dist/web/create-store.js +26 -0
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.d.ts +33 -0
- package/dist/web/data-llm.js +28 -0
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +2 -0
- package/dist/web/generate-helpers.js +2 -0
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js.map +1 -1
- package/dist/web/generate-helpers.test.js.map +1 -1
- package/dist/web/helpers/state.js.map +1 -1
- package/dist/web/helpers/state.test.js.map +1 -1
- package/dist/web/hooks/index.d.ts +3 -0
- package/dist/web/hooks/index.js +3 -0
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.d.ts +6 -2
- package/dist/web/hooks/test/utils.js +13 -2
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-call-tool.d.ts +45 -0
- package/dist/web/hooks/use-call-tool.js +28 -0
- package/dist/web/hooks/use-call-tool.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test.js +27 -6
- package/dist/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/web/hooks/use-display-mode.d.ts +20 -0
- package/dist/web/hooks/use-display-mode.js +20 -0
- package/dist/web/hooks/use-display-mode.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test-d.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/web/hooks/use-download.d.ts +5 -0
- package/dist/web/hooks/use-download.js +8 -0
- package/dist/web/hooks/use-download.js.map +1 -0
- package/dist/web/hooks/use-download.test.d.ts +1 -0
- package/dist/web/hooks/use-download.test.js +95 -0
- package/dist/web/hooks/use-download.test.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +32 -0
- package/dist/web/hooks/use-files.js +32 -0
- package/dist/web/hooks/use-files.js.map +1 -1
- package/dist/web/hooks/use-files.test.js.map +1 -1
- package/dist/web/hooks/use-layout.d.ts +2 -0
- package/dist/web/hooks/use-layout.js +2 -0
- package/dist/web/hooks/use-layout.js.map +1 -1
- package/dist/web/hooks/use-layout.test.js.map +1 -1
- package/dist/web/hooks/use-open-external.d.ts +17 -0
- package/dist/web/hooks/use-open-external.js +16 -0
- package/dist/web/hooks/use-open-external.js.map +1 -1
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-request-close.d.ts +16 -0
- package/dist/web/hooks/use-request-close.js +21 -0
- package/dist/web/hooks/use-request-close.js.map +1 -0
- package/dist/web/hooks/use-request-close.test.d.ts +1 -0
- package/dist/web/hooks/use-request-close.test.js +52 -0
- package/dist/web/hooks/use-request-close.test.js.map +1 -0
- package/dist/web/hooks/use-request-modal.d.ts +16 -1
- package/dist/web/hooks/use-request-modal.js +16 -1
- package/dist/web/hooks/use-request-modal.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-request-size.d.ts +20 -0
- package/dist/web/hooks/use-request-size.js +24 -0
- package/dist/web/hooks/use-request-size.js.map +1 -0
- package/dist/web/hooks/use-request-size.test.d.ts +1 -0
- package/dist/web/hooks/use-request-size.test.js +65 -0
- package/dist/web/hooks/use-request-size.test.js.map +1 -0
- package/dist/web/hooks/use-send-follow-up-message.d.ts +19 -1
- package/dist/web/hooks/use-send-follow-up-message.js +19 -2
- package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.d.ts +17 -0
- package/dist/web/hooks/use-set-open-in-app-url.js +17 -0
- package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
- package/dist/web/hooks/use-tool-info.d.ts +33 -0
- package/dist/web/hooks/use-tool-info.js +26 -0
- package/dist/web/hooks/use-tool-info.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.d.ts +2 -0
- package/dist/web/hooks/use-user.js +2 -0
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-view-state.d.ts +21 -0
- package/dist/web/hooks/use-view-state.js.map +1 -1
- package/dist/web/hooks/use-view-state.test.js.map +1 -1
- package/dist/web/index.js.map +1 -1
- package/dist/web/mount-view.d.ts +19 -0
- package/dist/web/mount-view.js +19 -0
- package/dist/web/mount-view.js.map +1 -1
- package/dist/web/plugin/data-llm.test.js.map +1 -1
- package/dist/web/plugin/plugin.d.ts +28 -0
- package/dist/web/plugin/plugin.js +33 -0
- package/dist/web/plugin/plugin.js.map +1 -1
- package/dist/web/plugin/scan-views.js.map +1 -1
- package/dist/web/plugin/scan-views.test.js.map +1 -1
- package/dist/web/plugin/transform-data-llm.js.map +1 -1
- package/dist/web/plugin/transform-data-llm.test.js.map +1 -1
- package/dist/web/plugin/validate-view.js.map +1 -1
- package/dist/web/plugin/validate-view.test.js.map +1 -1
- package/dist/web/proxy.js.map +1 -1
- package/dist/web/types.d.ts +4 -0
- package/dist/web/types.js.map +1 -1
- package/package.json +21 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-messages.js","sourceRoot":"","sources":["../../src/cli/use-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG9C,MAAM,YAAY,GAAG,EAAE,CAAC;AAIxB,MAAM,UAAU,WAAW;IACzB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAiB,EAAE,CAAC,CAAC;IAE7D,MAAM,IAAI,GAAG,WAAW,CAAc,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACnD,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE,CACnB,CAAC,GAAG,IAAI,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CACjE,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"use-messages.js","sourceRoot":"","sources":["../../src/cli/use-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG9C,MAAM,YAAY,GAAG,EAAE,CAAC;AAIxB,MAAM,UAAU,WAAW;IACzB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAiB,EAAE,CAAC,CAAC;IAE7D,MAAM,IAAI,GAAG,WAAW,CAAc,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACnD,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE,CACnB,CAAC,GAAG,IAAI,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CACjE,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { useCallback, useState } from \"react\";\nimport type { Message } from \"./types.js\";\n\nconst MAX_MESSAGES = 10;\n\nexport type PushMessage = (text: string, type: Message[\"type\"]) => void;\n\nexport function useMessages(): [Array<Message>, PushMessage] {\n const [messages, setMessages] = useState<Array<Message>>([]);\n\n const push = useCallback<PushMessage>((text, type) => {\n setMessages((prev) =>\n [...prev, { id: randomUUID(), text, type }].slice(-MAX_MESSAGES),\n );\n }, []);\n\n return [messages, push];\n}\n"]}
|
package/dist/cli/use-nodemon.js
CHANGED
|
@@ -3,6 +3,7 @@ import { resolve } from "node:path";
|
|
|
3
3
|
import nodemonOriginal from "nodemon";
|
|
4
4
|
import { useEffect } from "react";
|
|
5
5
|
const nodemon = nodemonOriginal;
|
|
6
|
+
const SOURCEMAP_WARNING = /^Sourcemap for ".*" points to missing source files$/;
|
|
6
7
|
export function useNodemon(env, pushMessage) {
|
|
7
8
|
useEffect(() => {
|
|
8
9
|
const configFile = resolve(process.cwd(), "nodemon.json");
|
|
@@ -24,8 +25,16 @@ export function useNodemon(env, pushMessage) {
|
|
|
24
25
|
};
|
|
25
26
|
const handleStderrData = (chunk) => {
|
|
26
27
|
const message = chunk.toString().trim();
|
|
27
|
-
if (message) {
|
|
28
|
-
|
|
28
|
+
if (!message) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Node's source-map warnings for third-party deps (superjson, @mcp/sdk, …) — not actionable.
|
|
32
|
+
const filtered = message
|
|
33
|
+
.split("\n")
|
|
34
|
+
.filter((line) => !SOURCEMAP_WARNING.test(line))
|
|
35
|
+
.join("\n");
|
|
36
|
+
if (filtered) {
|
|
37
|
+
pushMessage(filtered, "error");
|
|
29
38
|
}
|
|
30
39
|
};
|
|
31
40
|
const setupStdoutListener = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-nodemon.js","sourceRoot":"","sources":["../../src/cli/use-nodemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,eAAe,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,MAAM,OAAO,GAAG,eAAkC,CAAC;AAEnD,MAAM,UAAU,UAAU,CACxB,GAAsB,EACtB,WAAwB;IAExB,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAA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C;YAC9C,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,mBAAmB,GAAG,GAAG,EAAE;YAC/B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;gBAC7C,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC,CAAC;QAEF,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE;YAC1B,mBAAmB,EAAE,CAAC;YACtB,mBAAmB,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,KAAe,EAAE,EAAE;YACxC,MAAM,cAAc,GAAG,yCAAyC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACnF,WAAW,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;YACvC,mBAAmB,EAAE,CAAC;YACtB,mBAAmB,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;YAC/C,CAAC;YACD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;YAC/C,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport nodemonOriginal from \"nodemon\";\nimport { useEffect } from \"react\";\nimport type { ExtendedNodemon } from \"./nodemon.d.ts\";\nimport type { PushMessage } from \"./use-messages.js\";\n\nconst nodemon = nodemonOriginal as ExtendedNodemon;\n\nconst SOURCEMAP_WARNING = /^Sourcemap for \".*\" points to missing source files$/;\n\nexport function useNodemon(\n env: NodeJS.ProcessEnv,\n pushMessage: PushMessage,\n): void {\n useEffect(() => {\n const configFile = resolve(process.cwd(), \"nodemon.json\");\n\n const config = existsSync(configFile)\n ? {\n configFile,\n }\n : {\n watch: [\"src\"],\n ext: \"ts,json\",\n exec: \"tsx src/server.ts\",\n };\n\n nodemon({ ...config, env, stdout: false });\n\n const handleStdoutData = (chunk: Buffer) => {\n const message = chunk.toString().trim();\n if (message) {\n pushMessage(message, \"log\");\n }\n };\n\n const handleStderrData = (chunk: Buffer) => {\n const message = chunk.toString().trim();\n if (!message) {\n return;\n }\n // Node's source-map warnings for third-party deps (superjson, @mcp/sdk, …) — not actionable.\n const filtered = message\n .split(\"\\n\")\n .filter((line) => !SOURCEMAP_WARNING.test(line))\n .join(\"\\n\");\n if (filtered) {\n pushMessage(filtered, \"error\");\n }\n };\n\n const setupStdoutListener = () => {\n if (nodemon.stdout) {\n nodemon.stdout.off(\"data\", handleStdoutData);\n nodemon.stdout.on(\"data\", handleStdoutData);\n }\n };\n\n const setupStderrListener = () => {\n if (nodemon.stderr) {\n nodemon.stderr.off(\"data\", handleStderrData);\n nodemon.stderr.on(\"data\", handleStderrData);\n }\n };\n\n nodemon.on(\"readable\", () => {\n setupStdoutListener();\n setupStderrListener();\n });\n\n nodemon.on(\"restart\", (files: string[]) => {\n const restartMessage = `Server restarted due to file changes: ${files.join(\", \")}`;\n pushMessage(restartMessage, \"restart\");\n setupStdoutListener();\n setupStderrListener();\n });\n\n return () => {\n if (nodemon.stdout) {\n nodemon.stdout.off(\"data\", handleStdoutData);\n }\n if (nodemon.stderr) {\n nodemon.stderr.off(\"data\", handleStderrData);\n }\n nodemon.emit(\"quit\");\n };\n }, [env, pushMessage]);\n}\n"]}
|
|
@@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IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AACtB,CAAC","sourcesContent":["import net from \"node:net\";\nimport open from \"open\";\nimport { useEffect, useRef } from \"react\";\n\nconst POLL_INTERVAL_MS = 200;\nconst POLL_TIMEOUT_MS = 5_000;\n\nconst isPortListening = (port: number): Promise<boolean> =>\n new Promise((resolve) => {\n const socket = net.createConnection({ port, host: \"127.0.0.1\" });\n socket.once(\"connect\", () => {\n socket.end();\n resolve(true);\n });\n socket.once(\"error\", () => {\n socket.destroy();\n resolve(false);\n });\n });\n\nexport function useOpenBrowser(port: number, enabled: boolean): void {\n const opened = useRef(false);\n\n useEffect(() => {\n if (!enabled || opened.current) {\n return;\n }\n\n let cancelled = false;\n const deadline = Date.now() + POLL_TIMEOUT_MS;\n\n const tick = async () => {\n while (!cancelled && Date.now() < deadline) {\n if (await isPortListening(port)) {\n if (cancelled || opened.current) {\n return;\n }\n opened.current = true;\n await open(`http://localhost:${port}/`).catch(() => {});\n return;\n }\n await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));\n }\n };\n\n void tick();\n\n return () => {\n cancelled = true;\n };\n }, [port, enabled]);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tunnel.js","sourceRoot":"","sources":["../../src/cli/use-tunnel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAe5C,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,MAAM,UAAU,SAAS,CACvB,IAAmB,EACnB,WAAwB,EACxB,OAAgB,EAChB,SAAkB;IAElB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAChC,IAAI,KAAK,IAAI,IAAI,SAAS;QACxB,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAkB,EAAE;QACrD,CAAC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O,GAAG,KAAK,IAAI,EAAE;YACzB,OAAO,CAAC,SAAS,EAAE,CAAC;gBAClB,IAAI,CAAC;oBACH,MAAM,UAAU,EAAE,CAAC;gBACrB,CAAC;gBAAC,MAAM,CAAC;oBACP,mEAAmE;gBACrE,CAAC;gBACD,IAAI,SAAS,EAAE,CAAC;oBACd,OAAO;gBACT,CAAC;gBACD,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC,CAAC;QAEF,0EAA0E;QAC1E,0EAA0E;QAC1E,wCAAwC;QACxC,IAAI,SAAS,EAAE,CAAC;YACd,KAAK,gBAAgB,EAAE,CAAC;QAC1B,CAAC;QACD,KAAK,OAAO,EAAE,CAAC;QAEf,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;YACjB,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;IAE5C,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { useEffect, useState } from \"react\";\nimport type { PushMessage } from \"./use-messages.js\";\n\nexport type TunnelState =\n | { status: \"idle\" }\n | { status: \"starting\"; message: string }\n | { status: \"connected\"; url: string }\n | { status: \"error\"; message: string };\n\ntype TunnelActivity = {\n time: string;\n text: string;\n level: \"log\" | \"error\";\n};\n\nconst POST_RETRY_DELAY_MS = 250;\n\nexport function useTunnel(\n port: number | null,\n pushMessage: PushMessage,\n verbose: boolean,\n autoStart: boolean,\n): TunnelState {\n const [state, setState] = useState<TunnelState>(\n port !== null && autoStart\n ? { status: \"starting\", message: \"Starting tunnel…\" }\n : { status: \"idle\" },\n );\n\n useEffect(() => {\n if (port === null) {\n return;\n }\n\n const baseUrl = `http://localhost:${port}`;\n const controller = new AbortController();\n let cancelled = false;\n\n const pushLog = (text: string, type: \"log\" | \"error\") => {\n const time = new Date().toLocaleTimeString(\"en-US\", {\n hour: \"numeric\",\n minute: \"2-digit\",\n second: \"2-digit\",\n hour12: true,\n });\n pushMessage(`${time} [tunnel] ${text}`, type);\n };\n\n const handleEvent = (event: string, data: string) => {\n if (event === \"state\") {\n const next = JSON.parse(data) as TunnelState;\n setState(next);\n return;\n }\n if (event === \"activity\") {\n if (!verbose) {\n return;\n }\n const activity = JSON.parse(data) as TunnelActivity;\n pushLog(activity.text, activity.level);\n }\n };\n\n const consumeSse = async () => {\n const res = await fetch(`${baseUrl}/__skybridge/tunnel/events`, {\n signal: controller.signal,\n headers: { Accept: \"text/event-stream\" },\n });\n if (!res.ok || !res.body) {\n throw new Error(`SSE connection failed (${res.status})`);\n }\n\n const reader = res.body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n while (!cancelled) {\n const { value, done } = await reader.read();\n if (done) {\n return;\n }\n buffer += decoder.decode(value, { stream: true });\n\n // SSE frames are separated by a blank line (\"\\n\\n\").\n let sep = buffer.indexOf(\"\\n\\n\");\n while (sep !== -1) {\n const frame = buffer.slice(0, sep);\n buffer = buffer.slice(sep + 2);\n let eventName = \"message\";\n const dataLines: string[] = [];\n for (const rawLine of frame.split(\"\\n\")) {\n const line = rawLine.replace(/\\r$/, \"\");\n if (line.startsWith(\"event:\")) {\n eventName = line.slice(6).trim();\n } else if (line.startsWith(\"data:\")) {\n dataLines.push(line.slice(5).trimStart());\n }\n }\n if (dataLines.length > 0) {\n handleEvent(eventName, dataLines.join(\"\\n\"));\n }\n sep = buffer.indexOf(\"\\n\\n\");\n }\n }\n };\n\n const postUntilStarted = async () => {\n // Retry indefinitely until POST lands once. Bounded by the effect\n // lifetime via controller.abort() on unmount. Once the manager has\n // been started, this returns and never POSTs again — a user-driven\n // DELETE /tunnel won't be auto-undone.\n while (!cancelled) {\n try {\n const res = await fetch(`${baseUrl}/__skybridge/tunnel`, {\n method: \"POST\",\n signal: controller.signal,\n });\n if (res.ok) {\n return;\n }\n } catch {\n // dev server not up yet (or restarting under nodemon) — wait, retry\n }\n await new Promise((r) => setTimeout(r, POST_RETRY_DELAY_MS));\n }\n };\n\n // Always observe the tunnel state so external triggers (curl, future\n // devtools UI) update the cli UI. `autoStart` only decides whether we\n // also POST /tunnel on mount. Reconnects indefinitely so we survive\n // dev-server boot delay and nodemon restarts; the cli owns the actual\n // subprocess so a temporarily-unreachable dev server is fine.\n const observe = async () => {\n while (!cancelled) {\n try {\n await consumeSse();\n } catch {\n // network error or stream ended abnormally — fall through to retry\n }\n if (cancelled) {\n return;\n }\n await new Promise((r) => setTimeout(r, POST_RETRY_DELAY_MS));\n }\n };\n\n // observe() always runs — it owns the cli's view of tunnel state. POST is\n // a fire-and-forget side-effect that nudges the manager into starting and\n // retries until it lands at least once.\n if (autoStart) {\n void postUntilStarted();\n }\n void observe();\n\n return () => {\n cancelled = true;\n controller.abort();\n };\n }, [port, pushMessage, verbose, autoStart]);\n\n return state;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
1
|
import { isAbsolute, relative } from "node:path";
|
|
2
|
+
import spawn from "cross-spawn";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
// TypeScript nests from general to specific — the deepest line is the root cause.
|
|
5
5
|
function extractBestMessage(message, continuationLines) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-typescript-check.js","sourceRoot":"","sources":["../../src/cli/use-typescript-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-typescript-check.js","sourceRoot":"","sources":["../../src/cli/use-typescript-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EA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9B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { isAbsolute, relative } from \"node:path\";\nimport spawn from \"cross-spawn\";\nimport { useEffect, useRef, useState } from \"react\";\n\ntype TsError = {\n file: string;\n line: number;\n col: number;\n code: string;\n message: string;\n};\n\n// TypeScript nests from general to specific — the deepest line is the root cause.\nfunction extractBestMessage(\n message: string,\n continuationLines: Array<string>,\n): string {\n if (!continuationLines.length) {\n return message;\n }\n let maxIndent = 0;\n for (const line of continuationLines) {\n const indent = line.length - line.trimStart().length;\n if (indent > maxIndent) {\n maxIndent = indent;\n }\n }\n const deepest = continuationLines\n .filter((l) => l.length - l.trimStart().length === maxIndent)\n .map((l) => l.trim())\n .filter(Boolean)[0];\n return deepest ?? message;\n}\n\nexport function useTypeScriptCheck(): Array<TsError> {\n const tsProcessRef = useRef<ReturnType<typeof spawn> | null>(null);\n const [tsErrors, setTsErrors] = useState<Array<TsError>>([]);\n\n useEffect(() => {\n const tsProcess = spawn(\n \"npx\",\n [\"tsc\", \"--noEmit\", \"--watch\", \"--pretty\", \"false\"],\n {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n shell: true,\n },\n );\n\n tsProcessRef.current = tsProcess;\n\n let outputBuffer = \"\";\n let currentErrors: Array<TsError> = [];\n let pendingError: TsError | null = null;\n let continuationLines: Array<string> = [];\n\n const flushPending = () => {\n if (!pendingError) {\n return;\n }\n pendingError.message = extractBestMessage(\n pendingError.message,\n continuationLines,\n );\n currentErrors.push(pendingError);\n pendingError = null;\n continuationLines = [];\n };\n\n const processOutput = (data: Buffer) => {\n outputBuffer += data.toString();\n const lines = outputBuffer.split(\"\\n\");\n outputBuffer = lines.pop() || \"\";\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n const errorMatch = trimmed.match(\n /^(.+?)\\((\\d+),(\\d+)\\):\\s+error\\s+(TS\\d+)?\\s*:?\\s*(.+)$/,\n );\n if (errorMatch) {\n flushPending();\n const [, file, lineStr, colStr, code, message] = errorMatch;\n if (file && lineStr && colStr && message) {\n let cleanFile = file.trim();\n if (isAbsolute(cleanFile)) {\n cleanFile = relative(process.cwd(), cleanFile);\n }\n pendingError = {\n file: cleanFile,\n line: Number.parseInt(lineStr, 10),\n col: Number.parseInt(colStr, 10),\n code: code ?? \"\",\n message: message.trim(),\n };\n }\n continue;\n }\n\n if (pendingError && line.startsWith(\" \")) {\n continuationLines.push(line);\n continue;\n }\n\n if (trimmed.includes(\"Found\") && trimmed.includes(\"error\")) {\n flushPending();\n setTsErrors(trimmed.match(/Found 0 error/) ? [] : [...currentErrors]);\n currentErrors = [];\n }\n }\n };\n\n if (tsProcess.stdout) {\n tsProcess.stdout.on(\"data\", processOutput);\n }\n if (tsProcess.stderr) {\n tsProcess.stderr.on(\"data\", processOutput);\n }\n\n return () => {\n if (tsProcessRef.current) {\n tsProcessRef.current.kill();\n }\n };\n }, []);\n\n return tsErrors;\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare function emitManifestModule(manifestPath: string, outPath: string): void;
|
|
2
|
+
export declare const VERCEL_API_ENTRY_CONTENT = "export { default } from \"../dist/server.js\";\n";
|
|
3
|
+
export declare function emitVercelFunction(root: string): void;
|
|
4
|
+
export declare const DEFAULT_VERCEL_JSON: {
|
|
5
|
+
$schema: string;
|
|
6
|
+
framework: null;
|
|
7
|
+
installCommand: string;
|
|
8
|
+
buildCommand: string;
|
|
9
|
+
outputDirectory: string;
|
|
10
|
+
rewrites: {
|
|
11
|
+
source: string;
|
|
12
|
+
destination: string;
|
|
13
|
+
}[];
|
|
14
|
+
headers: {
|
|
15
|
+
source: string;
|
|
16
|
+
headers: {
|
|
17
|
+
key: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}[];
|
|
20
|
+
}[];
|
|
21
|
+
};
|
|
22
|
+
export declare function inspectVercelJson(json: unknown): string[];
|
|
23
|
+
export declare function ensureVercelJson(root: string): {
|
|
24
|
+
written: boolean;
|
|
25
|
+
warnings: string[];
|
|
26
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export function emitManifestModule(manifestPath, outPath) {
|
|
4
|
+
const manifest = readFileSync(manifestPath, "utf-8");
|
|
5
|
+
writeFileSync(outPath, `export default ${manifest};\n`);
|
|
6
|
+
}
|
|
7
|
+
export const VERCEL_API_ENTRY_CONTENT = `export { default } from "../dist/server.js";\n`;
|
|
8
|
+
export function emitVercelFunction(root) {
|
|
9
|
+
const apiDir = path.join(root, "api");
|
|
10
|
+
mkdirSync(apiDir, { recursive: true });
|
|
11
|
+
writeFileSync(path.join(apiDir, "mcp.js"), VERCEL_API_ENTRY_CONTENT);
|
|
12
|
+
}
|
|
13
|
+
export const DEFAULT_VERCEL_JSON = {
|
|
14
|
+
$schema: "https://openapi.vercel.sh/vercel.json",
|
|
15
|
+
// Disable framework auto-detection: Skybridge projects ship a vite.config.ts
|
|
16
|
+
// that Vercel would otherwise pick up as a SPA, running `vite` instead of
|
|
17
|
+
// our serverless function. Filesystem + functions only.
|
|
18
|
+
framework: null,
|
|
19
|
+
// Skip Vercel's install + build — `skybridge build --target vercel` has
|
|
20
|
+
// already produced dist/, public/, and api/. Empty strings fall through
|
|
21
|
+
// to framework defaults; `true` is the unix no-op that satisfies Vercel.
|
|
22
|
+
installCommand: "true",
|
|
23
|
+
buildCommand: "true",
|
|
24
|
+
outputDirectory: "public",
|
|
25
|
+
rewrites: [{ source: "/(.*)", destination: "/api/mcp" }],
|
|
26
|
+
headers: [
|
|
27
|
+
{
|
|
28
|
+
source: "/assets/(.*)",
|
|
29
|
+
headers: [{ key: "Access-Control-Allow-Origin", value: "*" }],
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
export function inspectVercelJson(json) {
|
|
34
|
+
const warnings = [];
|
|
35
|
+
if (typeof json !== "object" || json === null) {
|
|
36
|
+
warnings.push("vercel.json is not a JSON object.");
|
|
37
|
+
return warnings;
|
|
38
|
+
}
|
|
39
|
+
const cfg = json;
|
|
40
|
+
if (cfg.framework !== null) {
|
|
41
|
+
warnings.push("vercel.json: missing or wrong `framework: null` (required to prevent Vercel from auto-detecting Vite and running `vite` instead of the serverless function).");
|
|
42
|
+
}
|
|
43
|
+
if (cfg.installCommand !== "true") {
|
|
44
|
+
warnings.push('vercel.json: missing or wrong `installCommand: "true"` (no-op needed so Vercel\'s sandbox install does not run against a possibly-mismatched package manager).');
|
|
45
|
+
}
|
|
46
|
+
if (cfg.buildCommand !== "true") {
|
|
47
|
+
warnings.push('vercel.json: missing or wrong `buildCommand: "true"` (no-op needed so Vercel does not re-run `skybridge build` without `--target vercel` on its build machine, which would leave `public/assets/` stale).');
|
|
48
|
+
}
|
|
49
|
+
if (cfg.outputDirectory !== "public") {
|
|
50
|
+
warnings.push('vercel.json: missing or wrong `outputDirectory: "public"`.');
|
|
51
|
+
}
|
|
52
|
+
const rewrites = Array.isArray(cfg.rewrites)
|
|
53
|
+
? cfg.rewrites
|
|
54
|
+
: [];
|
|
55
|
+
const hasMcpRewrite = rewrites.some((r) => r.destination === "/api/mcp" && typeof r.source === "string");
|
|
56
|
+
if (!hasMcpRewrite) {
|
|
57
|
+
warnings.push("vercel.json: missing a rewrite to `/api/mcp` (needed so all routes hit the MCP function).");
|
|
58
|
+
}
|
|
59
|
+
const headers = Array.isArray(cfg.headers)
|
|
60
|
+
? cfg.headers
|
|
61
|
+
: [];
|
|
62
|
+
const assetsCors = headers.some((h) => {
|
|
63
|
+
if (h.source !== "/assets/(.*)") {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const list = Array.isArray(h.headers)
|
|
67
|
+
? h.headers
|
|
68
|
+
: [];
|
|
69
|
+
return list.some((entry) => entry.key === "Access-Control-Allow-Origin" && entry.value === "*");
|
|
70
|
+
});
|
|
71
|
+
if (!assetsCors) {
|
|
72
|
+
warnings.push("vercel.json: missing CORS header `Access-Control-Allow-Origin: *` on `/assets/(.*)`.");
|
|
73
|
+
}
|
|
74
|
+
return warnings;
|
|
75
|
+
}
|
|
76
|
+
export function ensureVercelJson(root) {
|
|
77
|
+
const target = path.join(root, "vercel.json");
|
|
78
|
+
if (!existsSync(target)) {
|
|
79
|
+
writeFileSync(target, `${JSON.stringify(DEFAULT_VERCEL_JSON, null, 2)}\n`);
|
|
80
|
+
return { written: true, warnings: [] };
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const parsed = JSON.parse(readFileSync(target, "utf-8"));
|
|
84
|
+
return { written: false, warnings: inspectVercelJson(parsed) };
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return {
|
|
88
|
+
written: false,
|
|
89
|
+
warnings: [`vercel.json: failed to parse (${String(error)}).`],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=build-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-helpers.js","sourceRoot":"","sources":["../../src/commands/build-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,kBAAkB,CAChC,YAAoB,EACpB,OAAe;IAEf,MAAM,QAAQ,GAAG,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACrD,aAAa,CAAC,OAAO,EAAE,kBAAkB,QAAQ,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,gDAAgD,CAAC;AAEzF,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC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AChB,QAAQ,CAAC,IAAI,CACX,sFAAsF,CACvF,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAI3C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IAC9C,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,aAAa,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IACzC,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACzD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,CAAC,iCAAiC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;SAC/D,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\n\nexport function emitManifestModule(\n manifestPath: string,\n outPath: string,\n): void {\n const manifest = readFileSync(manifestPath, \"utf-8\");\n writeFileSync(outPath, `export default ${manifest};\\n`);\n}\n\nexport const VERCEL_API_ENTRY_CONTENT = `export { default } from \"../dist/server.js\";\\n`;\n\nexport function emitVercelFunction(root: string): void {\n const apiDir = path.join(root, \"api\");\n mkdirSync(apiDir, { recursive: true });\n writeFileSync(path.join(apiDir, \"mcp.js\"), VERCEL_API_ENTRY_CONTENT);\n}\n\nexport const DEFAULT_VERCEL_JSON = {\n $schema: \"https://openapi.vercel.sh/vercel.json\",\n // Disable framework auto-detection: Skybridge projects ship a vite.config.ts\n // that Vercel would otherwise pick up as a SPA, running `vite` instead of\n // our serverless function. Filesystem + functions only.\n framework: null,\n // Skip Vercel's install + build — `skybridge build --target vercel` has\n // already produced dist/, public/, and api/. Empty strings fall through\n // to framework defaults; `true` is the unix no-op that satisfies Vercel.\n installCommand: \"true\",\n buildCommand: \"true\",\n outputDirectory: \"public\",\n rewrites: [{ source: \"/(.*)\", destination: \"/api/mcp\" }],\n headers: [\n {\n source: \"/assets/(.*)\",\n headers: [{ key: \"Access-Control-Allow-Origin\", value: \"*\" }],\n },\n ],\n};\n\nexport function inspectVercelJson(json: unknown): string[] {\n const warnings: string[] = [];\n if (typeof json !== \"object\" || json === null) {\n warnings.push(\"vercel.json is not a JSON object.\");\n return warnings;\n }\n const cfg = json as Record<string, unknown>;\n if (cfg.framework !== null) {\n warnings.push(\n \"vercel.json: missing or wrong `framework: null` (required to prevent Vercel from auto-detecting Vite and running `vite` instead of the serverless function).\",\n );\n }\n if (cfg.installCommand !== \"true\") {\n warnings.push(\n 'vercel.json: missing or wrong `installCommand: \"true\"` (no-op needed so Vercel\\'s sandbox install does not run against a possibly-mismatched package manager).',\n );\n }\n if (cfg.buildCommand !== \"true\") {\n warnings.push(\n 'vercel.json: missing or wrong `buildCommand: \"true\"` (no-op needed so Vercel does not re-run `skybridge build` without `--target vercel` on its build machine, which would leave `public/assets/` stale).',\n );\n }\n if (cfg.outputDirectory !== \"public\") {\n warnings.push('vercel.json: missing or wrong `outputDirectory: \"public\"`.');\n }\n const rewrites = Array.isArray(cfg.rewrites)\n ? (cfg.rewrites as Array<Record<string, unknown>>)\n : [];\n const hasMcpRewrite = rewrites.some(\n (r) => r.destination === \"/api/mcp\" && typeof r.source === \"string\",\n );\n if (!hasMcpRewrite) {\n warnings.push(\n \"vercel.json: missing a rewrite to `/api/mcp` (needed so all routes hit the MCP function).\",\n );\n }\n const headers = Array.isArray(cfg.headers)\n ? (cfg.headers as Array<Record<string, unknown>>)\n : [];\n const assetsCors = headers.some((h) => {\n if (h.source !== \"/assets/(.*)\") {\n return false;\n }\n const list = Array.isArray(h.headers)\n ? (h.headers as Array<Record<string, unknown>>)\n : [];\n return list.some(\n (entry) =>\n entry.key === \"Access-Control-Allow-Origin\" && entry.value === \"*\",\n );\n });\n if (!assetsCors) {\n warnings.push(\n \"vercel.json: missing CORS header `Access-Control-Allow-Origin: *` on `/assets/(.*)`.\",\n );\n }\n return warnings;\n}\n\nexport function ensureVercelJson(root: string): {\n written: boolean;\n warnings: string[];\n} {\n const target = path.join(root, \"vercel.json\");\n if (!existsSync(target)) {\n writeFileSync(target, `${JSON.stringify(DEFAULT_VERCEL_JSON, null, 2)}\\n`);\n return { written: true, warnings: [] };\n }\n try {\n const parsed = JSON.parse(readFileSync(target, \"utf-8\"));\n return { written: false, warnings: inspectVercelJson(parsed) };\n } catch (error) {\n return {\n written: false,\n warnings: [`vercel.json: failed to parse (${String(error)}).`],\n };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import { DEFAULT_VERCEL_JSON, emitManifestModule, emitVercelFunction, ensureVercelJson, inspectVercelJson, VERCEL_API_ENTRY_CONTENT, } from "./build-helpers.js";
|
|
6
|
+
function mkTmp(prefix = "skybridge-build-helpers-") {
|
|
7
|
+
return mkdtempSync(path.join(tmpdir(), prefix));
|
|
8
|
+
}
|
|
9
|
+
describe("emitManifestModule", () => {
|
|
10
|
+
it("inlines the JSON manifest as an ESM default export", () => {
|
|
11
|
+
const dir = mkTmp();
|
|
12
|
+
const inPath = path.join(dir, "manifest.json");
|
|
13
|
+
const outPath = path.join(dir, "vite-manifest.js");
|
|
14
|
+
const manifest = { "src/views/foo.tsx": { file: "assets/foo-abc.js" } };
|
|
15
|
+
writeFileSync(inPath, JSON.stringify(manifest));
|
|
16
|
+
emitManifestModule(inPath, outPath);
|
|
17
|
+
const out = readFileSync(outPath, "utf-8");
|
|
18
|
+
expect(out.startsWith("export default ")).toBe(true);
|
|
19
|
+
const literal = out
|
|
20
|
+
.slice("export default ".length)
|
|
21
|
+
.trim()
|
|
22
|
+
.replace(/;$/, "");
|
|
23
|
+
expect(JSON.parse(literal)).toEqual(manifest);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe("VERCEL_API_ENTRY_CONTENT", () => {
|
|
27
|
+
it("re-exports the default export from dist/server.js", () => {
|
|
28
|
+
expect(VERCEL_API_ENTRY_CONTENT).toBe('export { default } from "../dist/server.js";\n');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe("emitVercelFunction", () => {
|
|
32
|
+
it("writes api/mcp.js pointing at dist/server.js", () => {
|
|
33
|
+
const dir = mkTmp();
|
|
34
|
+
emitVercelFunction(dir);
|
|
35
|
+
const out = readFileSync(path.join(dir, "api", "mcp.js"), "utf-8");
|
|
36
|
+
expect(out).toBe(VERCEL_API_ENTRY_CONTENT);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe("inspectVercelJson", () => {
|
|
40
|
+
it("returns no warnings for the canonical config", () => {
|
|
41
|
+
expect(inspectVercelJson(DEFAULT_VERCEL_JSON)).toEqual([]);
|
|
42
|
+
});
|
|
43
|
+
it("warns when framework is missing or not null", () => {
|
|
44
|
+
const { framework: _omit, ...rest } = DEFAULT_VERCEL_JSON;
|
|
45
|
+
expect(inspectVercelJson(rest).some((w) => w.includes("framework: null"))).toBe(true);
|
|
46
|
+
expect(inspectVercelJson({ ...DEFAULT_VERCEL_JSON, framework: "vite" }).some((w) => w.includes("framework: null"))).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
it("warns when installCommand is missing or not the no-op", () => {
|
|
49
|
+
const { installCommand: _omit, ...rest } = DEFAULT_VERCEL_JSON;
|
|
50
|
+
expect(inspectVercelJson(rest).some((w) => w.includes("installCommand"))).toBe(true);
|
|
51
|
+
expect(inspectVercelJson({
|
|
52
|
+
...DEFAULT_VERCEL_JSON,
|
|
53
|
+
installCommand: "pnpm install",
|
|
54
|
+
}).some((w) => w.includes("installCommand"))).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
it("warns when buildCommand is missing or not the no-op", () => {
|
|
57
|
+
const { buildCommand: _omit, ...rest } = DEFAULT_VERCEL_JSON;
|
|
58
|
+
expect(inspectVercelJson(rest).some((w) => w.includes("buildCommand"))).toBe(true);
|
|
59
|
+
expect(inspectVercelJson({
|
|
60
|
+
...DEFAULT_VERCEL_JSON,
|
|
61
|
+
buildCommand: "skybridge build",
|
|
62
|
+
}).some((w) => w.includes("buildCommand"))).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
it("warns when outputDirectory is missing", () => {
|
|
65
|
+
const { outputDirectory: _omit, ...rest } = DEFAULT_VERCEL_JSON;
|
|
66
|
+
const warnings = inspectVercelJson(rest);
|
|
67
|
+
expect(warnings.some((w) => w.includes("outputDirectory"))).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
it("warns when outputDirectory is wrong", () => {
|
|
70
|
+
const warnings = inspectVercelJson({
|
|
71
|
+
...DEFAULT_VERCEL_JSON,
|
|
72
|
+
outputDirectory: "dist",
|
|
73
|
+
});
|
|
74
|
+
expect(warnings.some((w) => w.includes("outputDirectory"))).toBe(true);
|
|
75
|
+
});
|
|
76
|
+
it("warns when the /api/mcp rewrite is missing", () => {
|
|
77
|
+
const warnings = inspectVercelJson({
|
|
78
|
+
...DEFAULT_VERCEL_JSON,
|
|
79
|
+
rewrites: [{ source: "/(.*)", destination: "/api/other" }],
|
|
80
|
+
});
|
|
81
|
+
expect(warnings.some((w) => w.includes("/api/mcp"))).toBe(true);
|
|
82
|
+
});
|
|
83
|
+
it("warns when CORS on /assets/(.*) is missing", () => {
|
|
84
|
+
const warnings = inspectVercelJson({
|
|
85
|
+
...DEFAULT_VERCEL_JSON,
|
|
86
|
+
headers: [],
|
|
87
|
+
});
|
|
88
|
+
expect(warnings.some((w) => w.includes("Access-Control-Allow-Origin"))).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
it("warns when the input is not an object", () => {
|
|
91
|
+
expect(inspectVercelJson("nope").length).toBeGreaterThan(0);
|
|
92
|
+
expect(inspectVercelJson(null).length).toBeGreaterThan(0);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
describe("ensureVercelJson", () => {
|
|
96
|
+
it("writes a default vercel.json when none exists", () => {
|
|
97
|
+
const dir = mkTmp();
|
|
98
|
+
const { written, warnings } = ensureVercelJson(dir);
|
|
99
|
+
expect(written).toBe(true);
|
|
100
|
+
expect(warnings).toEqual([]);
|
|
101
|
+
expect(existsSync(path.join(dir, "vercel.json"))).toBe(true);
|
|
102
|
+
const onDisk = JSON.parse(readFileSync(path.join(dir, "vercel.json"), "utf-8"));
|
|
103
|
+
expect(onDisk).toEqual(DEFAULT_VERCEL_JSON);
|
|
104
|
+
});
|
|
105
|
+
it("does not overwrite an existing vercel.json; returns inspection warnings", () => {
|
|
106
|
+
const dir = mkTmp();
|
|
107
|
+
const existing = { outputDirectory: "dist" };
|
|
108
|
+
writeFileSync(path.join(dir, "vercel.json"), JSON.stringify(existing, null, 2));
|
|
109
|
+
const { written, warnings } = ensureVercelJson(dir);
|
|
110
|
+
expect(written).toBe(false);
|
|
111
|
+
expect(warnings.length).toBeGreaterThan(0);
|
|
112
|
+
const onDisk = JSON.parse(readFileSync(path.join(dir, "vercel.json"), "utf-8"));
|
|
113
|
+
expect(onDisk).toEqual(existing);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=build-helpers.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-helpers.test.js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AC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CACvB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,OAAO,CAAC,CACrD,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QACjF,MAAM,GAAG,GAAG,KAAK,EAAE,CAAC;QACpB,MAAM,QAAQ,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC;QAC7C,aAAa,CACX,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,EAC7B,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAClC,CAAC;QACF,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACpD,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5B,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CACvB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,OAAO,CAAC,CACrD,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { existsSync, mkdtempSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { describe, expect, it } from \"vitest\";\nimport {\n DEFAULT_VERCEL_JSON,\n emitManifestModule,\n emitVercelFunction,\n ensureVercelJson,\n inspectVercelJson,\n VERCEL_API_ENTRY_CONTENT,\n} from \"./build-helpers.js\";\n\nfunction mkTmp(prefix = \"skybridge-build-helpers-\") {\n return mkdtempSync(path.join(tmpdir(), prefix));\n}\n\ndescribe(\"emitManifestModule\", () => {\n it(\"inlines the JSON manifest as an ESM default export\", () => {\n const dir = mkTmp();\n const inPath = path.join(dir, \"manifest.json\");\n const outPath = path.join(dir, \"vite-manifest.js\");\n const manifest = { \"src/views/foo.tsx\": { file: \"assets/foo-abc.js\" } };\n writeFileSync(inPath, JSON.stringify(manifest));\n emitManifestModule(inPath, outPath);\n const out = readFileSync(outPath, \"utf-8\");\n expect(out.startsWith(\"export default \")).toBe(true);\n const literal = out\n .slice(\"export default \".length)\n .trim()\n .replace(/;$/, \"\");\n expect(JSON.parse(literal)).toEqual(manifest);\n });\n});\n\ndescribe(\"VERCEL_API_ENTRY_CONTENT\", () => {\n it(\"re-exports the default export from dist/server.js\", () => {\n expect(VERCEL_API_ENTRY_CONTENT).toBe(\n 'export { default } from \"../dist/server.js\";\\n',\n );\n });\n});\n\ndescribe(\"emitVercelFunction\", () => {\n it(\"writes api/mcp.js pointing at dist/server.js\", () => {\n const dir = mkTmp();\n emitVercelFunction(dir);\n const out = readFileSync(path.join(dir, \"api\", \"mcp.js\"), \"utf-8\");\n expect(out).toBe(VERCEL_API_ENTRY_CONTENT);\n });\n});\n\ndescribe(\"inspectVercelJson\", () => {\n it(\"returns no warnings for the canonical config\", () => {\n expect(inspectVercelJson(DEFAULT_VERCEL_JSON)).toEqual([]);\n });\n\n it(\"warns when framework is missing or not null\", () => {\n const { framework: _omit, ...rest } = DEFAULT_VERCEL_JSON;\n expect(\n inspectVercelJson(rest).some((w) => w.includes(\"framework: null\")),\n ).toBe(true);\n expect(\n inspectVercelJson({ ...DEFAULT_VERCEL_JSON, framework: \"vite\" }).some(\n (w) => w.includes(\"framework: null\"),\n ),\n ).toBe(true);\n });\n\n it(\"warns when installCommand is missing or not the no-op\", () => {\n const { installCommand: _omit, ...rest } = DEFAULT_VERCEL_JSON;\n expect(\n inspectVercelJson(rest).some((w) => w.includes(\"installCommand\")),\n ).toBe(true);\n expect(\n inspectVercelJson({\n ...DEFAULT_VERCEL_JSON,\n installCommand: \"pnpm install\",\n }).some((w) => w.includes(\"installCommand\")),\n ).toBe(true);\n });\n\n it(\"warns when buildCommand is missing or not the no-op\", () => {\n const { buildCommand: _omit, ...rest } = DEFAULT_VERCEL_JSON;\n expect(\n inspectVercelJson(rest).some((w) => w.includes(\"buildCommand\")),\n ).toBe(true);\n expect(\n inspectVercelJson({\n ...DEFAULT_VERCEL_JSON,\n buildCommand: \"skybridge build\",\n }).some((w) => w.includes(\"buildCommand\")),\n ).toBe(true);\n });\n\n it(\"warns when outputDirectory is missing\", () => {\n const { outputDirectory: _omit, ...rest } = DEFAULT_VERCEL_JSON;\n const warnings = inspectVercelJson(rest);\n expect(warnings.some((w) => w.includes(\"outputDirectory\"))).toBe(true);\n });\n\n it(\"warns when outputDirectory is wrong\", () => {\n const warnings = inspectVercelJson({\n ...DEFAULT_VERCEL_JSON,\n outputDirectory: \"dist\",\n });\n expect(warnings.some((w) => w.includes(\"outputDirectory\"))).toBe(true);\n });\n\n it(\"warns when the /api/mcp rewrite is missing\", () => {\n const warnings = inspectVercelJson({\n ...DEFAULT_VERCEL_JSON,\n rewrites: [{ source: \"/(.*)\", destination: \"/api/other\" }],\n });\n expect(warnings.some((w) => w.includes(\"/api/mcp\"))).toBe(true);\n });\n\n it(\"warns when CORS on /assets/(.*) is missing\", () => {\n const warnings = inspectVercelJson({\n ...DEFAULT_VERCEL_JSON,\n headers: [],\n });\n expect(\n warnings.some((w) => w.includes(\"Access-Control-Allow-Origin\")),\n ).toBe(true);\n });\n\n it(\"warns when the input is not an object\", () => {\n expect(inspectVercelJson(\"nope\").length).toBeGreaterThan(0);\n expect(inspectVercelJson(null).length).toBeGreaterThan(0);\n });\n});\n\ndescribe(\"ensureVercelJson\", () => {\n it(\"writes a default vercel.json when none exists\", () => {\n const dir = mkTmp();\n const { written, warnings } = ensureVercelJson(dir);\n expect(written).toBe(true);\n expect(warnings).toEqual([]);\n expect(existsSync(path.join(dir, \"vercel.json\"))).toBe(true);\n const onDisk = JSON.parse(\n readFileSync(path.join(dir, \"vercel.json\"), \"utf-8\"),\n );\n expect(onDisk).toEqual(DEFAULT_VERCEL_JSON);\n });\n\n it(\"does not overwrite an existing vercel.json; returns inspection warnings\", () => {\n const dir = mkTmp();\n const existing = { outputDirectory: \"dist\" };\n writeFileSync(\n path.join(dir, \"vercel.json\"),\n JSON.stringify(existing, null, 2),\n );\n const { written, warnings } = ensureVercelJson(dir);\n expect(written).toBe(false);\n expect(warnings.length).toBeGreaterThan(0);\n const onDisk = JSON.parse(\n readFileSync(path.join(dir, \"vercel.json\"), \"utf-8\"),\n );\n expect(onDisk).toEqual(existing);\n });\n});\n"]}
|
package/dist/commands/build.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
2
|
import { type CommandStep } from "../cli/use-execute-steps.js";
|
|
3
|
+
export declare function buildSteps(target: "default" | "vercel", warnings: {
|
|
4
|
+
current: string[];
|
|
5
|
+
}): CommandStep[];
|
|
3
6
|
export declare const commandSteps: CommandStep[];
|
|
4
7
|
export default class Build extends Command {
|
|
5
8
|
static description: string;
|
|
6
9
|
static examples: string[];
|
|
7
|
-
static flags: {
|
|
10
|
+
static flags: {
|
|
11
|
+
target: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
};
|
|
8
13
|
run(): Promise<void>;
|
|
9
14
|
}
|