@vistagenic/vista 0.2.16 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/vista.js +184 -177
- package/dist/ai/agent.d.ts +37 -0
- package/dist/ai/agent.js +385 -0
- package/dist/ai/embeddings.d.ts +11 -0
- package/dist/ai/embeddings.js +71 -0
- package/dist/ai/index.d.ts +10 -0
- package/dist/ai/index.js +26 -0
- package/dist/ai/memory.d.ts +16 -0
- package/dist/ai/memory.js +39 -0
- package/dist/ai/observability.d.ts +21 -0
- package/dist/ai/observability.js +69 -0
- package/dist/ai/providers/anthropic.d.ts +2 -0
- package/dist/ai/providers/anthropic.js +190 -0
- package/dist/ai/providers/base.d.ts +7 -0
- package/dist/ai/providers/base.js +85 -0
- package/dist/ai/providers/gemini.d.ts +2 -0
- package/dist/ai/providers/gemini.js +194 -0
- package/dist/ai/providers/index.d.ts +5 -0
- package/dist/ai/providers/index.js +21 -0
- package/dist/ai/providers/mock.d.ts +8 -0
- package/dist/ai/providers/mock.js +77 -0
- package/dist/ai/providers/openai.d.ts +2 -0
- package/dist/ai/providers/openai.js +211 -0
- package/dist/ai/rag.d.ts +35 -0
- package/dist/ai/rag.js +110 -0
- package/dist/ai/react/index.d.ts +1 -0
- package/dist/ai/react/index.js +17 -0
- package/dist/ai/react/react-server.d.ts +1 -0
- package/dist/ai/react/react-server.js +17 -0
- package/dist/ai/react/use-agent.d.ts +23 -0
- package/dist/ai/react/use-agent.js +138 -0
- package/dist/ai/stream.d.ts +24 -0
- package/dist/ai/stream.js +109 -0
- package/dist/ai/tool.d.ts +11 -0
- package/dist/ai/tool.js +47 -0
- package/dist/ai/types.d.ts +117 -0
- package/dist/ai/types.js +5 -0
- package/dist/auth/core.d.ts +140 -0
- package/dist/auth/core.js +165 -0
- package/dist/auth/index.d.ts +20 -8
- package/dist/auth/index.js +369 -16
- package/dist/auth/react-server.d.ts +1 -0
- package/dist/auth/react-server.js +10 -0
- package/dist/auth/react.d.ts +18 -0
- package/dist/auth/react.js +71 -0
- package/dist/bin/build-rsc.js +602 -604
- package/dist/bin/build.js +389 -388
- package/dist/bin/deploy-output.d.ts +2 -7
- package/dist/bin/deploy-output.js +3 -76
- package/dist/bin/deploy.d.ts +7 -0
- package/dist/bin/deploy.js +102 -0
- package/dist/bin/dev-error-overlay-snippet.js +778 -552
- package/dist/bin/devtools-indicator-snippet.js +387 -387
- package/dist/bin/generate.js +510 -248
- package/dist/build/manifest.d.ts +169 -139
- package/dist/build/manifest.js +423 -367
- package/dist/build/rsc/client-manifest.d.ts +62 -52
- package/dist/build/rsc/client-manifest.js +295 -193
- package/dist/build/rsc/client-reference-plugin.d.ts +37 -37
- package/dist/build/rsc/client-reference-plugin.js +160 -160
- package/dist/build/rsc/native-scanner.d.ts +135 -123
- package/dist/build/rsc/native-scanner.js +203 -170
- package/dist/build/rsc/react-client-reference-manifest.d.ts +28 -22
- package/dist/build/rsc/react-client-reference-manifest.js +240 -219
- package/dist/build/rsc/rsc-renderer.d.ts +99 -99
- package/dist/build/rsc/rsc-renderer.js +263 -263
- package/dist/build/rsc/server-component-loader.d.ts +19 -19
- package/dist/build/rsc/server-component-loader.js +91 -91
- package/dist/build/rsc/server-manifest.d.ts +17 -0
- package/dist/build/rsc/server-manifest.js +20 -0
- package/dist/build/standalone.js +337 -334
- package/dist/build/webpack/plugins/vista-flight-plugin.js +5 -5
- package/dist/client/dynamic.react-server.d.ts +2 -0
- package/dist/client/dynamic.react-server.js +23 -0
- package/dist/client/link.react-server.d.ts +2 -0
- package/dist/client/link.react-server.js +11 -0
- package/dist/client/navigation.react-server.d.ts +1 -0
- package/dist/client/navigation.react-server.js +17 -0
- package/dist/client/router.react-server.d.ts +1 -0
- package/dist/client/router.react-server.js +17 -0
- package/dist/client/rsc-router.react-server.d.ts +1 -0
- package/dist/client/rsc-router.react-server.js +17 -0
- package/dist/client/script.react-server.d.ts +2 -0
- package/dist/client/script.react-server.js +23 -0
- package/dist/components/client-island.d.ts +34 -34
- package/dist/components/client-island.js +75 -75
- package/dist/config.d.ts +17 -0
- package/dist/config.js +60 -1
- package/dist/deploy/adapters/cloudflare.d.ts +2 -0
- package/dist/deploy/adapters/cloudflare.js +124 -0
- package/dist/deploy/adapters/docker.d.ts +2 -0
- package/dist/deploy/adapters/docker.js +112 -0
- package/dist/deploy/adapters/index.d.ts +15 -0
- package/dist/deploy/adapters/index.js +24 -0
- package/dist/deploy/adapters/netlify.d.ts +2 -0
- package/dist/deploy/adapters/netlify.js +115 -0
- package/dist/deploy/adapters/render.d.ts +2 -0
- package/dist/deploy/adapters/render.js +95 -0
- package/dist/deploy/adapters/vercel.d.ts +7 -0
- package/dist/deploy/adapters/vercel.js +164 -0
- package/dist/deploy/cli-runner.d.ts +8 -0
- package/dist/deploy/cli-runner.js +58 -0
- package/dist/deploy/detect.d.ts +6 -0
- package/dist/deploy/detect.js +77 -0
- package/dist/deploy/index.d.ts +24 -0
- package/dist/deploy/index.js +112 -0
- package/dist/deploy/preflight.d.ts +8 -0
- package/dist/deploy/preflight.js +80 -0
- package/dist/deploy/types.d.ts +48 -0
- package/dist/deploy/types.js +2 -0
- package/dist/deploy/utils.d.ts +18 -0
- package/dist/deploy/utils.js +70 -0
- package/dist/dev-error.d.ts +14 -0
- package/dist/dev-error.js +1763 -705
- package/dist/index.d.ts +23 -21
- package/dist/index.js +61 -57
- package/dist/server/cookie-parse.d.ts +4 -0
- package/dist/server/cookie-parse.js +14 -0
- package/dist/server/engine.js +7 -26
- package/dist/server/index.d.ts +109 -102
- package/dist/server/index.js +315 -286
- package/dist/server/middleware-runner.d.ts +125 -57
- package/dist/server/middleware-runner.js +615 -218
- package/dist/server/middleware-security.d.ts +36 -0
- package/dist/server/middleware-security.js +183 -0
- package/dist/server/module-compile-hook.js +695 -662
- package/dist/server/route-handler-registry.d.ts +65 -0
- package/dist/server/route-handler-registry.js +195 -0
- package/dist/server/route-patterns.d.ts +67 -0
- package/dist/server/route-patterns.js +186 -0
- package/dist/server/rsc-engine.js +75 -92
- package/dist/server/rsc-module-system.d.ts +33 -33
- package/dist/server/rsc-module-system.js +87 -87
- package/dist/server/rsc-upstream.js +892 -888
- package/dist/server/static-generator.js +10 -10
- package/dist/server/typed-api-runtime.d.ts +18 -0
- package/dist/server/typed-api-runtime.js +635 -507
- package/dist/server/vista-import-map.js +134 -123
- package/dist/stack/index.d.ts +34 -32
- package/dist/stack/index.js +49 -45
- package/dist/stack/server/caller.d.ts +13 -0
- package/dist/stack/server/caller.js +42 -0
- package/dist/stack/server/executor.d.ts +40 -36
- package/dist/stack/server/executor.js +222 -174
- package/dist/stack/server/index.d.ts +11 -10
- package/dist/stack/server/index.js +24 -23
- package/dist/stack/server/procedure.d.ts +20 -18
- package/dist/stack/server/procedure.js +66 -58
- package/dist/stack/server/types.d.ts +113 -100
- package/dist/theme/react-server.d.ts +10 -0
- package/dist/theme/react-server.js +16 -0
- package/package.json +28 -3
- package/LICENSE +0 -21
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.dockerAdapter = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const cli_runner_1 = require("../cli-runner");
|
|
9
|
+
const preflight_1 = require("../preflight");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const DOCKERFILE_TEMPLATE = `# syntax=docker/dockerfile:1
|
|
12
|
+
|
|
13
|
+
FROM node:20-alpine AS builder
|
|
14
|
+
WORKDIR /app
|
|
15
|
+
COPY package.json package-lock.json* pnpm-lock.yaml* yarn.lock* ./
|
|
16
|
+
RUN npm install --no-audit --no-fund
|
|
17
|
+
COPY . .
|
|
18
|
+
RUN npm run build
|
|
19
|
+
|
|
20
|
+
FROM node:20-alpine AS runner
|
|
21
|
+
WORKDIR /app
|
|
22
|
+
ENV NODE_ENV=production
|
|
23
|
+
ENV PORT=3003
|
|
24
|
+
COPY --from=builder /app/.vista ./.vista
|
|
25
|
+
COPY --from=builder /app/package.json ./package.json
|
|
26
|
+
EXPOSE 3003
|
|
27
|
+
CMD ["node", ".vista/standalone/server.js"]
|
|
28
|
+
`;
|
|
29
|
+
const DOCKERIGNORE_TEMPLATE = `node_modules
|
|
30
|
+
.git
|
|
31
|
+
.vista/cache
|
|
32
|
+
.flash
|
|
33
|
+
.next
|
|
34
|
+
.vercel
|
|
35
|
+
dist
|
|
36
|
+
coverage
|
|
37
|
+
*.log
|
|
38
|
+
.env*
|
|
39
|
+
`;
|
|
40
|
+
exports.dockerAdapter = {
|
|
41
|
+
id: 'docker',
|
|
42
|
+
requiredOutput: 'standalone',
|
|
43
|
+
supportsFullRuntime: true,
|
|
44
|
+
async preflight(ctx) {
|
|
45
|
+
return (0, preflight_1.runStandalonePreflight)(ctx);
|
|
46
|
+
},
|
|
47
|
+
async emit(ctx) {
|
|
48
|
+
const dockerfilePath = path_1.default.join(ctx.cwd, 'Dockerfile');
|
|
49
|
+
const dockerignorePath = path_1.default.join(ctx.cwd, '.dockerignore');
|
|
50
|
+
(0, utils_1.writeFileIfAllowed)(dockerfilePath, DOCKERFILE_TEMPLATE, ctx.force);
|
|
51
|
+
(0, utils_1.writeFileIfAllowed)(dockerignorePath, DOCKERIGNORE_TEMPLATE, ctx.force);
|
|
52
|
+
return {
|
|
53
|
+
status: 'emitted',
|
|
54
|
+
target: 'docker',
|
|
55
|
+
artifactPaths: [
|
|
56
|
+
path_1.default.join(ctx.vistaDir, 'standalone', 'server.js'),
|
|
57
|
+
dockerfilePath,
|
|
58
|
+
dockerignorePath,
|
|
59
|
+
],
|
|
60
|
+
instructions: [
|
|
61
|
+
'Build image: docker build -t my-vista-app .',
|
|
62
|
+
'Run container: docker run -p 3003:3003 -e PORT=3003 my-vista-app',
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
async deploy(ctx) {
|
|
67
|
+
const emitted = await exports.dockerAdapter.emit(ctx);
|
|
68
|
+
if (ctx.dryRun) {
|
|
69
|
+
return emitted;
|
|
70
|
+
}
|
|
71
|
+
const errors = await exports.dockerAdapter.preflight(ctx);
|
|
72
|
+
if (errors.length > 0) {
|
|
73
|
+
return {
|
|
74
|
+
status: 'failed',
|
|
75
|
+
target: 'docker',
|
|
76
|
+
warnings: errors,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (!(0, cli_runner_1.isCliAvailable)('docker')) {
|
|
80
|
+
return {
|
|
81
|
+
status: 'emitted',
|
|
82
|
+
target: 'docker',
|
|
83
|
+
artifactPaths: emitted.artifactPaths,
|
|
84
|
+
warnings: ['Docker CLI not found.'],
|
|
85
|
+
instructions: emitted.instructions,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const imageTag = 'my-vista-app';
|
|
89
|
+
const buildResult = (0, cli_runner_1.runCliCommand)(`docker build -t ${imageTag} .`, {
|
|
90
|
+
cwd: ctx.cwd,
|
|
91
|
+
dryRun: ctx.dryRun,
|
|
92
|
+
});
|
|
93
|
+
if (!buildResult.ok) {
|
|
94
|
+
return {
|
|
95
|
+
status: 'emitted',
|
|
96
|
+
target: 'docker',
|
|
97
|
+
artifactPaths: emitted.artifactPaths,
|
|
98
|
+
warnings: [buildResult.stderr || 'Docker build failed.'],
|
|
99
|
+
instructions: emitted.instructions,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
status: 'deployed',
|
|
104
|
+
target: 'docker',
|
|
105
|
+
artifactPaths: emitted.artifactPaths,
|
|
106
|
+
instructions: [
|
|
107
|
+
`Image built: ${imageTag}`,
|
|
108
|
+
`Run locally: docker run -p 3003:3003 -e PORT=3003 ${imageTag}`,
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ResolvedDeployTarget } from '../types';
|
|
2
|
+
import { cloudflareAdapter } from './cloudflare';
|
|
3
|
+
import { dockerAdapter } from './docker';
|
|
4
|
+
import { netlifyAdapter } from './netlify';
|
|
5
|
+
import { renderAdapter } from './render';
|
|
6
|
+
import { vercelAdapter } from './vercel';
|
|
7
|
+
export declare const deployAdapters: {
|
|
8
|
+
readonly render: import("../types").DeployAdapter;
|
|
9
|
+
readonly vercel: import("../types").DeployAdapter;
|
|
10
|
+
readonly cloudflare: import("../types").DeployAdapter;
|
|
11
|
+
readonly netlify: import("../types").DeployAdapter;
|
|
12
|
+
readonly docker: import("../types").DeployAdapter;
|
|
13
|
+
};
|
|
14
|
+
export declare function getDeployAdapter(target: ResolvedDeployTarget): import("../types").DeployAdapter;
|
|
15
|
+
export { cloudflareAdapter, dockerAdapter, netlifyAdapter, renderAdapter, vercelAdapter };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vercelAdapter = exports.renderAdapter = exports.netlifyAdapter = exports.dockerAdapter = exports.cloudflareAdapter = exports.deployAdapters = void 0;
|
|
4
|
+
exports.getDeployAdapter = getDeployAdapter;
|
|
5
|
+
const cloudflare_1 = require("./cloudflare");
|
|
6
|
+
Object.defineProperty(exports, "cloudflareAdapter", { enumerable: true, get: function () { return cloudflare_1.cloudflareAdapter; } });
|
|
7
|
+
const docker_1 = require("./docker");
|
|
8
|
+
Object.defineProperty(exports, "dockerAdapter", { enumerable: true, get: function () { return docker_1.dockerAdapter; } });
|
|
9
|
+
const netlify_1 = require("./netlify");
|
|
10
|
+
Object.defineProperty(exports, "netlifyAdapter", { enumerable: true, get: function () { return netlify_1.netlifyAdapter; } });
|
|
11
|
+
const render_1 = require("./render");
|
|
12
|
+
Object.defineProperty(exports, "renderAdapter", { enumerable: true, get: function () { return render_1.renderAdapter; } });
|
|
13
|
+
const vercel_1 = require("./vercel");
|
|
14
|
+
Object.defineProperty(exports, "vercelAdapter", { enumerable: true, get: function () { return vercel_1.vercelAdapter; } });
|
|
15
|
+
exports.deployAdapters = {
|
|
16
|
+
render: render_1.renderAdapter,
|
|
17
|
+
vercel: vercel_1.vercelAdapter,
|
|
18
|
+
cloudflare: cloudflare_1.cloudflareAdapter,
|
|
19
|
+
netlify: netlify_1.netlifyAdapter,
|
|
20
|
+
docker: docker_1.dockerAdapter,
|
|
21
|
+
};
|
|
22
|
+
function getDeployAdapter(target) {
|
|
23
|
+
return exports.deployAdapters[target];
|
|
24
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.netlifyAdapter = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const cli_runner_1 = require("../cli-runner");
|
|
10
|
+
const preflight_1 = require("../preflight");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
const NETLIFY_OUTPUT_DIR = '.vista/deploy/netlify';
|
|
13
|
+
function getNetlifyOutputDir(ctx) {
|
|
14
|
+
return path_1.default.join(ctx.cwd, NETLIFY_OUTPUT_DIR);
|
|
15
|
+
}
|
|
16
|
+
function writeNetlifyToml(ctx) {
|
|
17
|
+
const targetFile = path_1.default.join(ctx.cwd, 'netlify.toml');
|
|
18
|
+
const content = `[build]
|
|
19
|
+
command = "npm run build"
|
|
20
|
+
publish = ".vista/deploy/netlify"
|
|
21
|
+
|
|
22
|
+
[dev]
|
|
23
|
+
command = "npm run dev"
|
|
24
|
+
port = 3003
|
|
25
|
+
`;
|
|
26
|
+
(0, utils_1.writeFileIfAllowed)(targetFile, content, ctx.force);
|
|
27
|
+
return targetFile;
|
|
28
|
+
}
|
|
29
|
+
function writeRedirects(outputDir) {
|
|
30
|
+
const redirectsPath = path_1.default.join(outputDir, '_redirects');
|
|
31
|
+
const lines = [
|
|
32
|
+
'/_vista/* /:splat 200',
|
|
33
|
+
'/ /static/pages/index.html 200',
|
|
34
|
+
'/rsc /static/pages/index.rsc 200',
|
|
35
|
+
'/_rsc/* /static/pages/:splat.rsc 200',
|
|
36
|
+
'/* /static/pages/:splat.html 200',
|
|
37
|
+
];
|
|
38
|
+
fs_1.default.writeFileSync(redirectsPath, `${lines.join('\n')}\n`, 'utf8');
|
|
39
|
+
return redirectsPath;
|
|
40
|
+
}
|
|
41
|
+
exports.netlifyAdapter = {
|
|
42
|
+
id: 'netlify',
|
|
43
|
+
requiredOutput: 'static',
|
|
44
|
+
supportsFullRuntime: false,
|
|
45
|
+
async preflight(ctx) {
|
|
46
|
+
return (0, preflight_1.runStaticHostPreflight)(ctx);
|
|
47
|
+
},
|
|
48
|
+
async emit(ctx) {
|
|
49
|
+
const outputDir = getNetlifyOutputDir(ctx);
|
|
50
|
+
fs_1.default.rmSync(outputDir, { recursive: true, force: true });
|
|
51
|
+
(0, utils_1.ensureDir)(outputDir);
|
|
52
|
+
(0, utils_1.copyStaticHostAssets)(ctx.cwd, ctx.vistaDir, outputDir);
|
|
53
|
+
const redirectsPath = writeRedirects(outputDir);
|
|
54
|
+
const netlifyTomlPath = writeNetlifyToml(ctx);
|
|
55
|
+
return {
|
|
56
|
+
status: 'emitted',
|
|
57
|
+
target: 'netlify',
|
|
58
|
+
artifactPaths: [outputDir, redirectsPath, netlifyTomlPath],
|
|
59
|
+
instructions: [
|
|
60
|
+
'Netlify deploy uses pre-rendered static output from .vista/deploy/netlify.',
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
async deploy(ctx) {
|
|
65
|
+
const emitted = await exports.netlifyAdapter.emit(ctx);
|
|
66
|
+
if (ctx.dryRun) {
|
|
67
|
+
return emitted;
|
|
68
|
+
}
|
|
69
|
+
const preflightMessages = await exports.netlifyAdapter.preflight(ctx);
|
|
70
|
+
const { errors, warnings } = (0, preflight_1.splitPreflightMessages)(preflightMessages);
|
|
71
|
+
if (errors.length > 0) {
|
|
72
|
+
return {
|
|
73
|
+
status: 'failed',
|
|
74
|
+
target: 'netlify',
|
|
75
|
+
warnings: [...warnings, ...errors],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const outputDir = getNetlifyOutputDir(ctx);
|
|
79
|
+
if (!(0, cli_runner_1.isCliAvailable)('netlify')) {
|
|
80
|
+
return {
|
|
81
|
+
status: 'emitted',
|
|
82
|
+
target: 'netlify',
|
|
83
|
+
artifactPaths: emitted.artifactPaths,
|
|
84
|
+
warnings: [...warnings, 'Netlify CLI not found. Install with: npm i -g netlify-cli'],
|
|
85
|
+
instructions: [
|
|
86
|
+
'Install Netlify CLI: npm i -g netlify-cli',
|
|
87
|
+
`Then run: netlify deploy --prod --dir="${outputDir}"`,
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const command = ctx.prod
|
|
92
|
+
? `netlify deploy --prod --dir="${outputDir}"`
|
|
93
|
+
: `netlify deploy --dir="${outputDir}"`;
|
|
94
|
+
const result = (0, cli_runner_1.runCliCommand)(command, { cwd: ctx.cwd, dryRun: ctx.dryRun });
|
|
95
|
+
if (!result.ok) {
|
|
96
|
+
return {
|
|
97
|
+
status: 'emitted',
|
|
98
|
+
target: 'netlify',
|
|
99
|
+
artifactPaths: emitted.artifactPaths,
|
|
100
|
+
warnings: [...warnings, result.stderr || 'Netlify deploy failed.'],
|
|
101
|
+
instructions: [
|
|
102
|
+
'Run: netlify login',
|
|
103
|
+
'Or set NETLIFY_AUTH_TOKEN in your environment.',
|
|
104
|
+
],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
status: 'deployed',
|
|
109
|
+
target: 'netlify',
|
|
110
|
+
url: (0, cli_runner_1.extractDeploymentUrl)(`${result.stdout}\n${result.stderr}`),
|
|
111
|
+
artifactPaths: emitted.artifactPaths,
|
|
112
|
+
warnings,
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.renderAdapter = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const cli_runner_1 = require("../cli-runner");
|
|
9
|
+
const preflight_1 = require("../preflight");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const RENDER_YAML_TEMPLATE = `services:
|
|
12
|
+
- type: web
|
|
13
|
+
name: my-vista-app
|
|
14
|
+
runtime: node
|
|
15
|
+
region: oregon
|
|
16
|
+
plan: free
|
|
17
|
+
buildCommand: |
|
|
18
|
+
npm install --no-audit --no-fund
|
|
19
|
+
npm run build
|
|
20
|
+
startCommand: npm run start
|
|
21
|
+
envVars:
|
|
22
|
+
- key: NODE_ENV
|
|
23
|
+
value: production
|
|
24
|
+
- key: PORT
|
|
25
|
+
value: "3003"
|
|
26
|
+
healthCheckPath: /
|
|
27
|
+
`;
|
|
28
|
+
exports.renderAdapter = {
|
|
29
|
+
id: 'render',
|
|
30
|
+
requiredOutput: 'standalone',
|
|
31
|
+
supportsFullRuntime: true,
|
|
32
|
+
async preflight(ctx) {
|
|
33
|
+
return (0, preflight_1.runStandalonePreflight)(ctx);
|
|
34
|
+
},
|
|
35
|
+
async emit(ctx) {
|
|
36
|
+
const renderYamlPath = path_1.default.join(ctx.cwd, 'render.yaml');
|
|
37
|
+
const result = (0, utils_1.writeFileIfAllowed)(renderYamlPath, RENDER_YAML_TEMPLATE, ctx.force);
|
|
38
|
+
const artifactPaths = [path_1.default.join(ctx.vistaDir, 'standalone', 'server.js')];
|
|
39
|
+
if (result.written || result.skipped) {
|
|
40
|
+
artifactPaths.push(renderYamlPath);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
status: 'emitted',
|
|
44
|
+
target: 'render',
|
|
45
|
+
artifactPaths,
|
|
46
|
+
instructions: [
|
|
47
|
+
'Connect this repository on Render and select Blueprint (render.yaml).',
|
|
48
|
+
'Or create a Web Service with buildCommand "npm run build" and startCommand "npm run start".',
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
async deploy(ctx) {
|
|
53
|
+
const emitted = await exports.renderAdapter.emit(ctx);
|
|
54
|
+
if (ctx.dryRun) {
|
|
55
|
+
return emitted;
|
|
56
|
+
}
|
|
57
|
+
const errors = await exports.renderAdapter.preflight(ctx);
|
|
58
|
+
if (errors.length > 0) {
|
|
59
|
+
return {
|
|
60
|
+
status: 'failed',
|
|
61
|
+
target: 'render',
|
|
62
|
+
warnings: errors,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (!(0, cli_runner_1.isCliAvailable)('render')) {
|
|
66
|
+
return {
|
|
67
|
+
status: 'emitted',
|
|
68
|
+
target: 'render',
|
|
69
|
+
artifactPaths: emitted.artifactPaths,
|
|
70
|
+
instructions: [
|
|
71
|
+
'Push to GitHub and connect the repo on https://dashboard.render.com',
|
|
72
|
+
'Render will detect render.yaml automatically.',
|
|
73
|
+
'Ensure NODE_ENV=production and PORT are set in service env vars.',
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const command = ctx.prod ? 'render deploy --confirm' : 'render deploy';
|
|
78
|
+
const result = (0, cli_runner_1.runCliCommand)(command, { cwd: ctx.cwd, dryRun: ctx.dryRun });
|
|
79
|
+
if (!result.ok) {
|
|
80
|
+
return {
|
|
81
|
+
status: 'emitted',
|
|
82
|
+
target: 'render',
|
|
83
|
+
artifactPaths: emitted.artifactPaths,
|
|
84
|
+
warnings: [result.stderr || 'Render CLI deploy failed.'],
|
|
85
|
+
instructions: emitted.instructions,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
status: 'deployed',
|
|
90
|
+
target: 'render',
|
|
91
|
+
url: (0, cli_runner_1.extractDeploymentUrl)(`${result.stdout}\n${result.stderr}`),
|
|
92
|
+
artifactPaths: emitted.artifactPaths,
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BuildHookOptions, DeployAdapter } from '../types';
|
|
2
|
+
export declare function isVercelBuildEnvironment(): boolean;
|
|
3
|
+
export declare function hasUserVercelConfig(cwd: string): boolean;
|
|
4
|
+
export declare function writeVercelBuildOutput(options: BuildHookOptions & {
|
|
5
|
+
force?: boolean;
|
|
6
|
+
}): boolean;
|
|
7
|
+
export declare const vercelAdapter: DeployAdapter;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.vercelAdapter = void 0;
|
|
7
|
+
exports.isVercelBuildEnvironment = isVercelBuildEnvironment;
|
|
8
|
+
exports.hasUserVercelConfig = hasUserVercelConfig;
|
|
9
|
+
exports.writeVercelBuildOutput = writeVercelBuildOutput;
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const cli_runner_1 = require("../cli-runner");
|
|
13
|
+
const preflight_1 = require("../preflight");
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
function isVercelBuildEnvironment() {
|
|
16
|
+
return process.env.VERCEL === '1' || process.env.NOW_REGION !== undefined;
|
|
17
|
+
}
|
|
18
|
+
function hasUserVercelConfig(cwd) {
|
|
19
|
+
return fs_1.default.existsSync(path_1.default.join(cwd, 'vercel.json'));
|
|
20
|
+
}
|
|
21
|
+
function writeVercelBuildOutput(options) {
|
|
22
|
+
const { cwd, vistaDir, debug, force = false } = options;
|
|
23
|
+
if (!force && !isVercelBuildEnvironment()) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (!force && hasUserVercelConfig(cwd)) {
|
|
27
|
+
if (debug) {
|
|
28
|
+
console.log('[vista:deploy] Found custom vercel.json, skipping internal Vercel output.');
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const vercelOutputDir = path_1.default.join(cwd, '.vercel', 'output');
|
|
33
|
+
const vercelStaticDir = path_1.default.join(vercelOutputDir, 'static');
|
|
34
|
+
fs_1.default.rmSync(vercelOutputDir, { recursive: true, force: true });
|
|
35
|
+
(0, utils_1.ensureDir)(vercelStaticDir);
|
|
36
|
+
(0, utils_1.copyStaticHostAssets)(cwd, vistaDir, vercelStaticDir);
|
|
37
|
+
const config = {
|
|
38
|
+
version: 3,
|
|
39
|
+
routes: utils_1.STATIC_HOST_ROUTE_RULES,
|
|
40
|
+
};
|
|
41
|
+
fs_1.default.writeFileSync(path_1.default.join(vercelOutputDir, 'config.json'), JSON.stringify(config, null, 2));
|
|
42
|
+
if (debug) {
|
|
43
|
+
console.log('[vista:deploy] Generated internal Vercel Build Output at .vercel/output/');
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
function writeLegacyVercelJson(ctx) {
|
|
48
|
+
const targetFile = path_1.default.join(ctx.cwd, 'vercel.json');
|
|
49
|
+
const payload = {
|
|
50
|
+
version: 2,
|
|
51
|
+
buildCommand: 'npm run build',
|
|
52
|
+
outputDirectory: '.vista',
|
|
53
|
+
framework: null,
|
|
54
|
+
installCommand: 'npm install --legacy-peer-deps --no-audit --no-fund',
|
|
55
|
+
devCommand: 'npm run dev',
|
|
56
|
+
routes: utils_1.STATIC_HOST_ROUTE_RULES,
|
|
57
|
+
};
|
|
58
|
+
const result = (0, utils_1.writeFileIfAllowed)(targetFile, `${JSON.stringify(payload, null, 2)}\n`, ctx.force);
|
|
59
|
+
return result.written || result.skipped ? targetFile : null;
|
|
60
|
+
}
|
|
61
|
+
exports.vercelAdapter = {
|
|
62
|
+
id: 'vercel',
|
|
63
|
+
requiredOutput: 'static',
|
|
64
|
+
supportsFullRuntime: false,
|
|
65
|
+
async preflight(ctx) {
|
|
66
|
+
return (0, preflight_1.runStaticHostPreflight)(ctx);
|
|
67
|
+
},
|
|
68
|
+
async emit(ctx) {
|
|
69
|
+
const artifactPaths = [];
|
|
70
|
+
const warnings = [];
|
|
71
|
+
if (ctx.deployConfig.preferBuildOutputApi) {
|
|
72
|
+
const wrote = writeVercelBuildOutput({
|
|
73
|
+
cwd: ctx.cwd,
|
|
74
|
+
vistaDir: ctx.vistaDir,
|
|
75
|
+
debug: ctx.debug,
|
|
76
|
+
force: true,
|
|
77
|
+
});
|
|
78
|
+
if (wrote) {
|
|
79
|
+
artifactPaths.push(path_1.default.join(ctx.cwd, '.vercel', 'output'));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (!hasUserVercelConfig(ctx.cwd) || ctx.force) {
|
|
83
|
+
const legacyPath = writeLegacyVercelJson(ctx);
|
|
84
|
+
if (legacyPath)
|
|
85
|
+
artifactPaths.push(legacyPath);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
artifactPaths.push(path_1.default.join(ctx.cwd, 'vercel.json'));
|
|
89
|
+
}
|
|
90
|
+
(0, utils_1.copyStaticHostAssets)(ctx.cwd, ctx.vistaDir, path_1.default.join(ctx.vistaDir));
|
|
91
|
+
artifactPaths.push(path_1.default.join(ctx.vistaDir, 'static'));
|
|
92
|
+
return {
|
|
93
|
+
status: 'emitted',
|
|
94
|
+
target: 'vercel',
|
|
95
|
+
artifactPaths,
|
|
96
|
+
warnings,
|
|
97
|
+
instructions: [
|
|
98
|
+
'Vercel deploy uses pre-rendered static pages from .vista/static.',
|
|
99
|
+
'For full SSR, server actions, and typed API, deploy with --target render or --target docker.',
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
async deploy(ctx) {
|
|
104
|
+
const emitted = await exports.vercelAdapter.emit(ctx);
|
|
105
|
+
if (ctx.dryRun) {
|
|
106
|
+
return emitted;
|
|
107
|
+
}
|
|
108
|
+
const preflightMessages = await exports.vercelAdapter.preflight(ctx);
|
|
109
|
+
const { errors, warnings } = (0, preflight_1.splitPreflightMessages)(preflightMessages);
|
|
110
|
+
if (errors.length > 0) {
|
|
111
|
+
return {
|
|
112
|
+
status: 'failed',
|
|
113
|
+
target: 'vercel',
|
|
114
|
+
warnings: [...warnings, ...errors],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const hasBuildOutput = fs_1.default.existsSync(path_1.default.join(ctx.cwd, '.vercel', 'output', 'config.json'));
|
|
118
|
+
const command = hasBuildOutput
|
|
119
|
+
? ctx.prod
|
|
120
|
+
? 'vercel deploy --prebuilt --prod --yes'
|
|
121
|
+
: 'vercel deploy --prebuilt --yes'
|
|
122
|
+
: ctx.prod
|
|
123
|
+
? 'vercel deploy --prod --yes'
|
|
124
|
+
: 'vercel deploy --yes';
|
|
125
|
+
if (!(0, cli_runner_1.isCliAvailable)('vercel')) {
|
|
126
|
+
return {
|
|
127
|
+
status: 'emitted',
|
|
128
|
+
target: 'vercel',
|
|
129
|
+
artifactPaths: emitted.artifactPaths,
|
|
130
|
+
warnings: [
|
|
131
|
+
...warnings,
|
|
132
|
+
...(emitted.warnings ?? []),
|
|
133
|
+
'Vercel CLI not found. Install with: npm i -g vercel',
|
|
134
|
+
],
|
|
135
|
+
instructions: [
|
|
136
|
+
'Install Vercel CLI: npm i -g vercel',
|
|
137
|
+
'Then run: vercel deploy --prod',
|
|
138
|
+
'Or connect this repository in the Vercel dashboard with buildCommand "npm run build".',
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
const result = (0, cli_runner_1.runCliCommand)(command, { cwd: ctx.cwd, dryRun: ctx.dryRun });
|
|
143
|
+
if (!result.ok) {
|
|
144
|
+
return {
|
|
145
|
+
status: 'emitted',
|
|
146
|
+
target: 'vercel',
|
|
147
|
+
artifactPaths: emitted.artifactPaths,
|
|
148
|
+
warnings: [...warnings, result.stderr || 'Vercel deploy failed.'],
|
|
149
|
+
instructions: [
|
|
150
|
+
'Ensure you are logged in: vercel login',
|
|
151
|
+
'Or set VERCEL_TOKEN in your environment.',
|
|
152
|
+
'You can also deploy from the Vercel dashboard using npm run build.',
|
|
153
|
+
],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
status: 'deployed',
|
|
158
|
+
target: 'vercel',
|
|
159
|
+
url: (0, cli_runner_1.extractDeploymentUrl)(`${result.stdout}\n${result.stderr}`),
|
|
160
|
+
artifactPaths: emitted.artifactPaths,
|
|
161
|
+
warnings,
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CliRunResult } from './types';
|
|
2
|
+
export declare function isCliAvailable(command: string): boolean;
|
|
3
|
+
export declare function runCliCommand(command: string, options: {
|
|
4
|
+
cwd: string;
|
|
5
|
+
env?: NodeJS.ProcessEnv;
|
|
6
|
+
dryRun?: boolean;
|
|
7
|
+
}): CliRunResult;
|
|
8
|
+
export declare function extractDeploymentUrl(output: string): string | undefined;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCliAvailable = isCliAvailable;
|
|
4
|
+
exports.runCliCommand = runCliCommand;
|
|
5
|
+
exports.extractDeploymentUrl = extractDeploymentUrl;
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
function parseCommand(command) {
|
|
8
|
+
const parts = command.trim().split(/\s+/).filter(Boolean);
|
|
9
|
+
if (parts.length === 0) {
|
|
10
|
+
throw new Error('[vista:deploy] Empty CLI command.');
|
|
11
|
+
}
|
|
12
|
+
return { bin: parts[0], args: parts.slice(1) };
|
|
13
|
+
}
|
|
14
|
+
function isCliAvailable(command) {
|
|
15
|
+
const { bin } = parseCommand(command);
|
|
16
|
+
const which = process.platform === 'win32' ? 'where' : 'which';
|
|
17
|
+
const result = (0, child_process_1.spawnSync)(which, [bin], { stdio: 'ignore' });
|
|
18
|
+
return result.status === 0;
|
|
19
|
+
}
|
|
20
|
+
function runCliCommand(command, options) {
|
|
21
|
+
if (options.dryRun) {
|
|
22
|
+
return {
|
|
23
|
+
ok: true,
|
|
24
|
+
stdout: '',
|
|
25
|
+
stderr: '',
|
|
26
|
+
command,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const { bin, args } = parseCommand(command);
|
|
30
|
+
if (!isCliAvailable(bin)) {
|
|
31
|
+
return {
|
|
32
|
+
ok: false,
|
|
33
|
+
stdout: '',
|
|
34
|
+
stderr: `CLI not found: ${bin}`,
|
|
35
|
+
command,
|
|
36
|
+
missingCli: true,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const result = (0, child_process_1.spawnSync)(bin, args, {
|
|
40
|
+
cwd: options.cwd,
|
|
41
|
+
env: { ...process.env, ...(options.env ?? {}) },
|
|
42
|
+
encoding: 'utf8',
|
|
43
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
ok: result.status === 0,
|
|
47
|
+
stdout: result.stdout ?? '',
|
|
48
|
+
stderr: result.stderr ?? '',
|
|
49
|
+
command,
|
|
50
|
+
missingCli: false,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function extractDeploymentUrl(output) {
|
|
54
|
+
const match = output.match(/https?:\/\/[^\s]+/g);
|
|
55
|
+
if (!match || match.length === 0)
|
|
56
|
+
return undefined;
|
|
57
|
+
return match[match.length - 1].replace(/[)\]'"]+$/, '');
|
|
58
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DeployTarget, ResolvedDeployConfig } from '../config';
|
|
2
|
+
import type { ResolvedDeployTarget } from './types';
|
|
3
|
+
export declare function normalizeResolvedTarget(raw: unknown): ResolvedDeployTarget | null;
|
|
4
|
+
export declare function resolveDeployTarget(cwd: string, deployConfig: ResolvedDeployConfig, cliTarget?: string | null): ResolvedDeployTarget;
|
|
5
|
+
export declare function resolveEffectiveOutput(deployConfig: ResolvedDeployConfig, target: ResolvedDeployTarget): 'standalone' | 'static' | 'hybrid';
|
|
6
|
+
export declare function listKnownTargets(): DeployTarget[];
|