@vite-hub/cli 0.5.1 → 0.6.0
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/dist/{commands-C003KqWY.js → commands-D0WSlS7h.js} +6 -7
- package/dist/{console-env-CsBruJnE.js → console-env-CYHb4owT.js} +1 -3
- package/dist/{deploy-BZ2iQjZL.js → deploy-DwNjKrHq.js} +91 -11
- package/dist/{env-DRI0QH4-.js → env-BiVwma4a.js} +153 -485
- package/dist/index.js +56 -12
- package/dist/{provision-DlknnTAt.js → provision-akHsvf-B.js} +1138 -34
- package/dist/setup/index.d.ts +25 -3
- package/dist/setup/index.js +4 -6
- package/package.json +4 -4
- package/dist/console-auth-CpOpbA7U.js +0 -311
- package/dist/envelope-DbplCDko.js +0 -87
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
|
|
2
|
-
import {
|
|
3
|
-
import { i as setupFailure, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-DbplCDko.js";
|
|
2
|
+
import { A as resolveDeploymentPlan, B as readConsoleCredential, D as shellQuote, E as setupStatus, G as setupFailure, H as isSetupFailure, J as writeSetupJson, Mt as isRecord, W as setupExitCodes, Y as cliErrorDiagnostics, _ as consoleAppUrl, b as listConsoleApps, c as createNetlifyApiClient, f as resolveHostCredentials, g as checkProblem, h as checkConsoleApp, k as hostFromNitroPreset, l as createVercelProvisionClient, nt as withViteStageEnvironment, o as createCloudflareApiClient, p as runHostCli, q as writeSetupError, s as createCloudflareProvisionClient, tt as loadAllEnv, u as isProvisionRequestError, wt as invariant, x as openConsole, y as linkConsoleApp } from "./provision-akHsvf-B.js";
|
|
4
3
|
import { createRequire } from "node:module";
|
|
5
4
|
import { spawn } from "node:child_process";
|
|
6
|
-
import { existsSync, readFileSync,
|
|
7
|
-
import process
|
|
5
|
+
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
6
|
+
import process from "node:process";
|
|
8
7
|
import { basename, dirname, join, relative, resolve } from "pathe";
|
|
9
8
|
import { mkdir, mkdtemp, open, readFile, readdir, realpath, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
10
9
|
import { basename as basename$1, delimiter, sep } from "node:path";
|
|
11
10
|
import { createInterface } from "node:readline/promises";
|
|
12
11
|
import { constants, homedir, tmpdir } from "node:os";
|
|
12
|
+
import { parseArgs, parseEnv } from "node:util";
|
|
13
13
|
import { parse as parse$1 } from "@babel/parser";
|
|
14
14
|
import { parse as parse$2 } from "rc9";
|
|
15
|
-
import {
|
|
15
|
+
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
16
|
+
import { normalizeConsoleProjectUrl } from "@vite-hub/runtime/internal/console";
|
|
16
17
|
import { createPublicKey, diffieHellman, generateKeyPairSync, randomBytes } from "node:crypto";
|
|
17
18
|
import { hsalsa, xsalsa20poly1305 } from "@noble/ciphers/salsa.js";
|
|
18
19
|
import { blake2b } from "@noble/hashes/blake2.js";
|
|
@@ -2358,7 +2359,7 @@ async function nuxtServerDirs(root, config, env) {
|
|
|
2358
2359
|
return [resolve(appRoot, serverDir?.kind === "literal" && typeof serverDir.value === "string" ? serverDir.value || "server" : "server")];
|
|
2359
2360
|
}
|
|
2360
2361
|
function globalPackageDirs(name) {
|
|
2361
|
-
return (process
|
|
2362
|
+
return (process.env.NODE_PATH ?? "").split(delimiter).filter(Boolean).flatMap((dir) => {
|
|
2362
2363
|
try {
|
|
2363
2364
|
return [realpathSync(join(dir, name))];
|
|
2364
2365
|
} catch {
|
|
@@ -2412,458 +2413,6 @@ async function readSetupProject(root, env) {
|
|
|
2412
2413
|
serverDirs: framework === "nuxt" ? await nuxtServerDirs(root, config, env) : [join(root, "server")]
|
|
2413
2414
|
};
|
|
2414
2415
|
}
|
|
2415
|
-
// ../internal/dist/definition-catalog.js
|
|
2416
|
-
const sourceFilePattern = /\.(?:c|m)?[jt]sx?$/i;
|
|
2417
|
-
const declarationFilePattern = /\.d\.(?:c|m)?[jt]sx?$/i;
|
|
2418
|
-
const testFilePattern = /\.(?:test|spec)\.(?:c|m)?[jt]sx?$/i;
|
|
2419
|
-
const ignoredDirs = /* @__PURE__ */ new Set([
|
|
2420
|
-
"node_modules",
|
|
2421
|
-
"dist",
|
|
2422
|
-
".output",
|
|
2423
|
-
".nuxt",
|
|
2424
|
-
".vercel",
|
|
2425
|
-
".git",
|
|
2426
|
-
".vitehub"
|
|
2427
|
-
]);
|
|
2428
|
-
function readDirEntries(root) {
|
|
2429
|
-
try {
|
|
2430
|
-
return readdirSync(root, { withFileTypes: true });
|
|
2431
|
-
} catch (error) {
|
|
2432
|
-
if (error.code === "ENOENT") return [];
|
|
2433
|
-
throw error;
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
function isGitRepositoryDirectory(directory) {
|
|
2437
|
-
return existsSync(resolve(directory, ".git"));
|
|
2438
|
-
}
|
|
2439
|
-
function listMatchingFiles(root, predicate, options = {}) {
|
|
2440
|
-
const files = [];
|
|
2441
|
-
for (const entry of readDirEntries(root)) {
|
|
2442
|
-
const absolute = resolve(root, entry.name);
|
|
2443
|
-
if (entry.isDirectory() && !entry.isSymbolicLink()) {
|
|
2444
|
-
if (isGitRepositoryDirectory(absolute)) continue;
|
|
2445
|
-
if (entry.name.startsWith(".")) continue;
|
|
2446
|
-
if (ignoredDirs.has(entry.name)) continue;
|
|
2447
|
-
files.push(...listMatchingFiles(absolute, predicate, options));
|
|
2448
|
-
continue;
|
|
2449
|
-
}
|
|
2450
|
-
if (entry.name.startsWith(".") && !options.includeHidden) continue;
|
|
2451
|
-
if (entry.isFile() && predicate(entry.name)) files.push(absolute);
|
|
2452
|
-
}
|
|
2453
|
-
return files.sort();
|
|
2454
|
-
}
|
|
2455
|
-
/** A module that a Definitions folder can hold: JavaScript or TypeScript, and not a declaration, test, or spec file. */
|
|
2456
|
-
function isDefinitionSourceFile(name) {
|
|
2457
|
-
return sourceFilePattern.test(name) && !declarationFilePattern.test(name) && !testFilePattern.test(name);
|
|
2458
|
-
}
|
|
2459
|
-
function listSourceFiles(root, options = {}) {
|
|
2460
|
-
return listMatchingFiles(root, isDefinitionSourceFile, options);
|
|
2461
|
-
}
|
|
2462
|
-
/**
|
|
2463
|
-
* Whether `path` is a file, or a folder that holds a Definition source file. A Definition file in a server directory,
|
|
2464
|
-
* such as `server/auth.ts` or a file in `server/queues/`, turns its feature on without a key. An empty folder, which
|
|
2465
|
-
* Git does not keep, turns nothing on.
|
|
2466
|
-
*/
|
|
2467
|
-
function hasDefinitionFiles(path) {
|
|
2468
|
-
if (!existsSync(path)) return false;
|
|
2469
|
-
return statSync(path).isFile() || listSourceFiles(path).length > 0;
|
|
2470
|
-
}
|
|
2471
|
-
// ../internal/dist/deployment.js
|
|
2472
|
-
const unsupported = (reason) => ({
|
|
2473
|
-
reason,
|
|
2474
|
-
supported: false
|
|
2475
|
-
});
|
|
2476
|
-
const plans = {
|
|
2477
|
-
cloudflare: {
|
|
2478
|
-
host: "cloudflare",
|
|
2479
|
-
nitroPreset: "cloudflare-module",
|
|
2480
|
-
output: {
|
|
2481
|
-
directory: ".output",
|
|
2482
|
-
entry: "server/index.mjs",
|
|
2483
|
-
packaging: "none"
|
|
2484
|
-
},
|
|
2485
|
-
runtime: "workerd",
|
|
2486
|
-
services: {
|
|
2487
|
-
blob: {
|
|
2488
|
-
driver: "cloudflare",
|
|
2489
|
-
guarantee: "native",
|
|
2490
|
-
supported: true
|
|
2491
|
-
},
|
|
2492
|
-
browser: {
|
|
2493
|
-
driver: "cloudflare",
|
|
2494
|
-
guarantee: "native",
|
|
2495
|
-
supported: true
|
|
2496
|
-
},
|
|
2497
|
-
queue: {
|
|
2498
|
-
driver: "cloudflare",
|
|
2499
|
-
guarantee: "native",
|
|
2500
|
-
supported: true
|
|
2501
|
-
},
|
|
2502
|
-
rateLimit: {
|
|
2503
|
-
driver: "cloudflare",
|
|
2504
|
-
guarantee: "native",
|
|
2505
|
-
supported: true
|
|
2506
|
-
},
|
|
2507
|
-
realtime: {
|
|
2508
|
-
driver: "cloudflare",
|
|
2509
|
-
guarantee: "native",
|
|
2510
|
-
supported: true
|
|
2511
|
-
},
|
|
2512
|
-
sandbox: {
|
|
2513
|
-
driver: "cloudflare",
|
|
2514
|
-
guarantee: "native",
|
|
2515
|
-
supported: true
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
},
|
|
2519
|
-
deno: {
|
|
2520
|
-
host: "deno",
|
|
2521
|
-
nitroPreset: "deno-deploy",
|
|
2522
|
-
output: {
|
|
2523
|
-
directory: ".output",
|
|
2524
|
-
entry: "server/index.mjs",
|
|
2525
|
-
packaging: "deno-node-modules"
|
|
2526
|
-
},
|
|
2527
|
-
runtime: "deno",
|
|
2528
|
-
services: {
|
|
2529
|
-
blob: unsupported("Deno Deploy has no built-in durable Blob Store with ViteHub's object-storage contract."),
|
|
2530
|
-
browser: unsupported("Deno Deploy has no built-in Browser Provider."),
|
|
2531
|
-
queue: unsupported("Deno Deploy has no built-in Queue Provider with ViteHub's delivery contract."),
|
|
2532
|
-
rateLimit: unsupported("Deno Deploy has no built-in distributed Rate Limit driver."),
|
|
2533
|
-
realtime: unsupported("Deno Deploy has no shared room authority for Realtime."),
|
|
2534
|
-
sandbox: unsupported("Deno Deploy has no built-in isolated Sandbox Provider.")
|
|
2535
|
-
}
|
|
2536
|
-
},
|
|
2537
|
-
netlify: {
|
|
2538
|
-
host: "netlify",
|
|
2539
|
-
nitroPreset: "netlify",
|
|
2540
|
-
output: {
|
|
2541
|
-
directory: ".netlify",
|
|
2542
|
-
entry: "v1/functions/server/server.mjs",
|
|
2543
|
-
packaging: "none"
|
|
2544
|
-
},
|
|
2545
|
-
runtime: "node",
|
|
2546
|
-
services: {
|
|
2547
|
-
blob: {
|
|
2548
|
-
driver: "netlify-blobs",
|
|
2549
|
-
guarantee: "native",
|
|
2550
|
-
supported: true
|
|
2551
|
-
},
|
|
2552
|
-
browser: unsupported("Netlify has no built-in Browser Provider."),
|
|
2553
|
-
queue: unsupported("Netlify has no built-in Queue Provider with ViteHub's delivery contract."),
|
|
2554
|
-
rateLimit: unsupported("Netlify has no built-in distributed Rate Limit driver."),
|
|
2555
|
-
realtime: unsupported("Netlify has no shared room authority for Realtime."),
|
|
2556
|
-
sandbox: unsupported("Netlify has no built-in isolated Sandbox Provider.")
|
|
2557
|
-
}
|
|
2558
|
-
},
|
|
2559
|
-
node: {
|
|
2560
|
-
host: "node",
|
|
2561
|
-
nitroPreset: "node-server",
|
|
2562
|
-
output: {
|
|
2563
|
-
directory: ".output",
|
|
2564
|
-
entry: "server/index.mjs",
|
|
2565
|
-
packaging: "none"
|
|
2566
|
-
},
|
|
2567
|
-
runtime: "node",
|
|
2568
|
-
services: {
|
|
2569
|
-
blob: {
|
|
2570
|
-
driver: "fs",
|
|
2571
|
-
guarantee: "single-host",
|
|
2572
|
-
supported: true
|
|
2573
|
-
},
|
|
2574
|
-
browser: unsupported("The Node host has no built-in Browser Provider."),
|
|
2575
|
-
queue: {
|
|
2576
|
-
driver: "local",
|
|
2577
|
-
guarantee: "single-host",
|
|
2578
|
-
supported: true
|
|
2579
|
-
},
|
|
2580
|
-
rateLimit: {
|
|
2581
|
-
driver: "memory",
|
|
2582
|
-
guarantee: "process-local",
|
|
2583
|
-
supported: true
|
|
2584
|
-
},
|
|
2585
|
-
realtime: {
|
|
2586
|
-
driver: "node",
|
|
2587
|
-
guarantee: "native",
|
|
2588
|
-
supported: true
|
|
2589
|
-
},
|
|
2590
|
-
sandbox: unsupported("The Node host has no built-in isolated Sandbox Provider.")
|
|
2591
|
-
}
|
|
2592
|
-
},
|
|
2593
|
-
vercel: {
|
|
2594
|
-
host: "vercel",
|
|
2595
|
-
nitroPreset: "vercel",
|
|
2596
|
-
output: {
|
|
2597
|
-
directory: ".vercel/output",
|
|
2598
|
-
entry: "functions/__server.func/index.mjs",
|
|
2599
|
-
packaging: "none"
|
|
2600
|
-
},
|
|
2601
|
-
runtime: "node",
|
|
2602
|
-
services: {
|
|
2603
|
-
blob: {
|
|
2604
|
-
driver: "vercel",
|
|
2605
|
-
guarantee: "native",
|
|
2606
|
-
supported: true
|
|
2607
|
-
},
|
|
2608
|
-
browser: unsupported("Vercel has no built-in Browser Provider."),
|
|
2609
|
-
queue: {
|
|
2610
|
-
driver: "vercel",
|
|
2611
|
-
guarantee: "native",
|
|
2612
|
-
supported: true
|
|
2613
|
-
},
|
|
2614
|
-
rateLimit: unsupported("Vercel has no built-in distributed Rate Limit driver."),
|
|
2615
|
-
realtime: unsupported("Vercel has no shared room authority for Realtime."),
|
|
2616
|
-
sandbox: {
|
|
2617
|
-
driver: "vercel",
|
|
2618
|
-
guarantee: "native",
|
|
2619
|
-
supported: true
|
|
2620
|
-
}
|
|
2621
|
-
}
|
|
2622
|
-
}
|
|
2623
|
-
};
|
|
2624
|
-
function resolveDeploymentPlan(host) {
|
|
2625
|
-
const plan = plans[host];
|
|
2626
|
-
if (!plan) throw internalErrorDiagnostics.INTERNAL_R0001({ message: `Unknown ViteHub host: ${JSON.stringify(host)}.` });
|
|
2627
|
-
return plan;
|
|
2628
|
-
}
|
|
2629
|
-
/** Maps a host name or a Nitro preset name, such as `cloudflare-module` or `node-server`, to its ViteHub host. */
|
|
2630
|
-
function hostFromNitroPreset(value) {
|
|
2631
|
-
const normalized = value?.trim().toLowerCase().replaceAll("_", "-");
|
|
2632
|
-
if (!normalized) return;
|
|
2633
|
-
if (normalized.startsWith("cloudflare")) return "cloudflare";
|
|
2634
|
-
if (normalized.startsWith("deno")) return "deno";
|
|
2635
|
-
if (normalized.startsWith("netlify")) return "netlify";
|
|
2636
|
-
if (normalized === "node" || normalized.startsWith("node-")) return "node";
|
|
2637
|
-
if (normalized.startsWith("vercel")) return "vercel";
|
|
2638
|
-
}
|
|
2639
|
-
const providerHosts = [
|
|
2640
|
-
["WORKERS_CI", "cloudflare"],
|
|
2641
|
-
["NETLIFY", "netlify"],
|
|
2642
|
-
["NOW_BUILDER", "vercel"],
|
|
2643
|
-
["VERCEL", "vercel"],
|
|
2644
|
-
["VERCEL_ENV", "vercel"],
|
|
2645
|
-
["DENO_DEPLOY", "deno"],
|
|
2646
|
-
["DENO_DEPLOYMENT_ID", "deno"]
|
|
2647
|
-
];
|
|
2648
|
-
/**
|
|
2649
|
-
* Returns the ViteHub host that this process builds or runs on, or `undefined` when no variable names a host.
|
|
2650
|
-
* The order is `VITEHUB_HOST`, `NITRO_PRESET`, `SERVER_PRESET`, then the provider variables:
|
|
2651
|
-
* `WORKERS_CI` (Cloudflare Workers Builds), `NETLIFY`, `NOW_BUILDER`, `VERCEL` or `VERCEL_ENV`, then `DENO_DEPLOY` or `DENO_DEPLOYMENT_ID`.
|
|
2652
|
-
* `vitehub()` uses this result when `host` is omitted, and `"node"` when it is `undefined`.
|
|
2653
|
-
*/
|
|
2654
|
-
function detectHost(env = process.env) {
|
|
2655
|
-
for (const name of [
|
|
2656
|
-
"VITEHUB_HOST",
|
|
2657
|
-
"NITRO_PRESET",
|
|
2658
|
-
"SERVER_PRESET"
|
|
2659
|
-
]) {
|
|
2660
|
-
const host = hostFromNitroPreset(env[name]);
|
|
2661
|
-
if (host) return host;
|
|
2662
|
-
}
|
|
2663
|
-
return providerHosts.find(([name]) => env[name]?.trim())?.[1];
|
|
2664
|
-
}
|
|
2665
|
-
// src/setup/status.ts
|
|
2666
|
-
const addArgs = {
|
|
2667
|
-
bun: {
|
|
2668
|
-
dev: ["add", "-d"],
|
|
2669
|
-
prod: ["add"]
|
|
2670
|
-
},
|
|
2671
|
-
npm: {
|
|
2672
|
-
dev: ["install", "-D"],
|
|
2673
|
-
prod: ["install"]
|
|
2674
|
-
},
|
|
2675
|
-
pnpm: {
|
|
2676
|
-
dev: ["add", "-D"],
|
|
2677
|
-
prod: ["add"]
|
|
2678
|
-
},
|
|
2679
|
-
yarn: {
|
|
2680
|
-
dev: ["add", "-D"],
|
|
2681
|
-
prod: ["add"]
|
|
2682
|
-
}
|
|
2683
|
-
};
|
|
2684
|
-
/** Quotes `value` for a POSIX shell when it needs quotes. */
|
|
2685
|
-
function shellQuote(value) {
|
|
2686
|
-
return /^[\w@%+=:,./-]+$/u.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
|
|
2687
|
-
}
|
|
2688
|
-
/** The arguments of the `packageManager` command that installs `packages`, such as `["add", "-D", "drizzle-kit"]`. */
|
|
2689
|
-
function installArgs(packageManager, packages, dev) {
|
|
2690
|
-
return [...addArgs[packageManager][dev ? "dev" : "prod"], ...packages];
|
|
2691
|
-
}
|
|
2692
|
-
const removeArgs = {
|
|
2693
|
-
bun: ["remove"],
|
|
2694
|
-
npm: ["uninstall"],
|
|
2695
|
-
pnpm: ["remove"],
|
|
2696
|
-
yarn: ["remove"]
|
|
2697
|
-
};
|
|
2698
|
-
/** The arguments of the `packageManager` command that uninstalls `packages`, such as `["remove", "@vite-hub/queue"]`. */
|
|
2699
|
-
function uninstallArgs(packageManager, packages) {
|
|
2700
|
-
return [...removeArgs[packageManager], ...packages];
|
|
2701
|
-
}
|
|
2702
|
-
function formatInstallCommand(command, args) {
|
|
2703
|
-
return [command, ...args].map(formatInstallArgument).join(" ");
|
|
2704
|
-
}
|
|
2705
|
-
function installCommand(packageManager, prod, dev) {
|
|
2706
|
-
const commands = [...prod.length ? [formatInstallCommand(packageManager, installArgs(packageManager, prod, false))] : [], ...dev.length ? [formatInstallCommand(packageManager, installArgs(packageManager, dev, true))] : []];
|
|
2707
|
-
return commands.length ? commands.join(" && ") : void 0;
|
|
2708
|
-
}
|
|
2709
|
-
function readHost(project, env) {
|
|
2710
|
-
const config = project.config;
|
|
2711
|
-
if (config && !config.ok && config.reason !== "no-vitehub") return {
|
|
2712
|
-
name: "unknown",
|
|
2713
|
-
source: "config"
|
|
2714
|
-
};
|
|
2715
|
-
const site = config?.ok ? config.site : void 0;
|
|
2716
|
-
const host = site?.keys.host;
|
|
2717
|
-
const fromConfig = host?.kind === "literal" && typeof host.value === "string" ? hostFromNitroPreset(host.value) : void 0;
|
|
2718
|
-
if (fromConfig) return {
|
|
2719
|
-
name: fromConfig,
|
|
2720
|
-
source: "config"
|
|
2721
|
-
};
|
|
2722
|
-
if (host || site?.spread) return {
|
|
2723
|
-
name: "unknown",
|
|
2724
|
-
source: "config"
|
|
2725
|
-
};
|
|
2726
|
-
const fromEnv = detectHost(env);
|
|
2727
|
-
return fromEnv ? {
|
|
2728
|
-
name: fromEnv,
|
|
2729
|
-
source: "env"
|
|
2730
|
-
} : {
|
|
2731
|
-
name: "node",
|
|
2732
|
-
source: "default"
|
|
2733
|
-
};
|
|
2734
|
-
}
|
|
2735
|
-
function readEnabled(project, id, withoutDefinitions) {
|
|
2736
|
-
const config = project.config;
|
|
2737
|
-
if (!config || !config.ok && config.reason === "no-vitehub") return {
|
|
2738
|
-
enabled: "off",
|
|
2739
|
-
reason: "default"
|
|
2740
|
-
};
|
|
2741
|
-
if (!config.ok) return {
|
|
2742
|
-
enabled: "unknown",
|
|
2743
|
-
reason: "config"
|
|
2744
|
-
};
|
|
2745
|
-
const value = config.site.keys[id];
|
|
2746
|
-
if (value?.kind === "expression") return {
|
|
2747
|
-
enabled: "unknown",
|
|
2748
|
-
reason: "config"
|
|
2749
|
-
};
|
|
2750
|
-
if (value) return {
|
|
2751
|
-
enabled: value.value === false ? "off" : "on",
|
|
2752
|
-
reason: "config"
|
|
2753
|
-
};
|
|
2754
|
-
if (config.site.spread) return {
|
|
2755
|
-
enabled: "unknown",
|
|
2756
|
-
reason: "config"
|
|
2757
|
-
};
|
|
2758
|
-
if (features[id].enabledByDefault) return {
|
|
2759
|
-
enabled: "on",
|
|
2760
|
-
reason: "default"
|
|
2761
|
-
};
|
|
2762
|
-
if (withoutDefinitions?.has(id)) return {
|
|
2763
|
-
enabled: "off",
|
|
2764
|
-
reason: "default"
|
|
2765
|
-
};
|
|
2766
|
-
const discovery = features[id].enabledByDiscovery;
|
|
2767
|
-
const directories = project.serverDirs ?? (project.framework === "nuxt" ? void 0 : [join(project.root, "server")]);
|
|
2768
|
-
if (discovery && !directories) return {
|
|
2769
|
-
enabled: "unknown",
|
|
2770
|
-
reason: "default"
|
|
2771
|
-
};
|
|
2772
|
-
return {
|
|
2773
|
-
enabled: discovery?.some((file) => directories?.some((directory) => hasDefinitionFiles(join(directory, file)))) ? "on" : "off",
|
|
2774
|
-
reason: "default"
|
|
2775
|
-
};
|
|
2776
|
-
}
|
|
2777
|
-
const kvDefaultStoreOption = "kv.stores.default.driver";
|
|
2778
|
-
function kvStores(value) {
|
|
2779
|
-
return isRecord(value) && isRecord(value.stores) ? value.stores : void 0;
|
|
2780
|
-
}
|
|
2781
|
-
function missingProviderOption(project, option, value) {
|
|
2782
|
-
const [id, key] = option.split(".");
|
|
2783
|
-
const configured = project.config?.ok ? project.config.site.keys[id] : void 0;
|
|
2784
|
-
if (configured?.kind === "expression") return;
|
|
2785
|
-
const options = value ?? configured?.value;
|
|
2786
|
-
const stores = option === "kv.driver" ? kvStores(options) : void 0;
|
|
2787
|
-
if (stores) {
|
|
2788
|
-
const store = stores.default;
|
|
2789
|
-
const driver = isRecord(store) ? store.driver : void 0;
|
|
2790
|
-
if (driver !== "upstash" && driver !== "redis" && driver !== "database") return kvDefaultStoreOption;
|
|
2791
|
-
return;
|
|
2792
|
-
}
|
|
2793
|
-
if (!isRecord(options) || !(key in options)) return option;
|
|
2794
|
-
}
|
|
2795
|
-
function featureFix(project, id, support, host, missing, providerChosen) {
|
|
2796
|
-
const install = installCommand(project.packageManager, missing.prod.map(installSpecifier), missing.dev.map(installSpecifier));
|
|
2797
|
-
if (install) return install;
|
|
2798
|
-
if (support.level === "unsupported") return `Set \`${id}: false\`, or build for another host than ${host}.`;
|
|
2799
|
-
if (support.level === "explicit" && !providerChosen) {
|
|
2800
|
-
const option = missingProviderOption(project, support.option);
|
|
2801
|
-
if (option) return `Set \`${option}\` in vitehub() to choose a provider on ${host}.`;
|
|
2802
|
-
}
|
|
2803
|
-
}
|
|
2804
|
-
/** What the project enables, on which host, and what each enabled feature still needs. Reads the config without running it. */
|
|
2805
|
-
function setupStatus(project, env, withoutDefinitions) {
|
|
2806
|
-
const host = readHost(project, env);
|
|
2807
|
-
const enabled = new Map(featureIds.map((id) => [id, readEnabled(project, id, withoutDefinitions)]));
|
|
2808
|
-
const on = featureIds.filter((id) => enabled.get(id).enabled === "on");
|
|
2809
|
-
const keep = featureIds.filter((id) => enabled.get(id).enabled !== "on" && enabled.get(id).reason === "config");
|
|
2810
|
-
const maybeOn = featureIds.filter((id) => enabled.get(id).enabled !== "off");
|
|
2811
|
-
const disabled = keep.filter((id) => enabled.get(id).enabled === "off");
|
|
2812
|
-
const definite = impliedFeatures(on, keep);
|
|
2813
|
-
for (const id of impliedFeatures(maybeOn, disabled)) {
|
|
2814
|
-
const state = enabled.get(id);
|
|
2815
|
-
if (state.enabled === "off" && state.reason === "default") enabled.set(id, {
|
|
2816
|
-
enabled: definite.includes(id) ? "on" : "unknown",
|
|
2817
|
-
reason: "implied"
|
|
2818
|
-
});
|
|
2819
|
-
}
|
|
2820
|
-
return {
|
|
2821
|
-
config: !project.config ? { manual: "no-vitehub" } : project.config.ok ? {
|
|
2822
|
-
file: project.configFile,
|
|
2823
|
-
form: project.config.site.form
|
|
2824
|
-
} : {
|
|
2825
|
-
file: project.configFile,
|
|
2826
|
-
manual: project.config.reason,
|
|
2827
|
-
...project.config.line === void 0 ? {} : { line: project.config.line }
|
|
2828
|
-
},
|
|
2829
|
-
features: featureIds.map((id) => {
|
|
2830
|
-
const state = enabled.get(id);
|
|
2831
|
-
const support = host.name === "unknown" ? {
|
|
2832
|
-
level: "unknown",
|
|
2833
|
-
detail: "The config does not statically identify the deployment host."
|
|
2834
|
-
} : featureSupport(id, host.name);
|
|
2835
|
-
const definition = features[id];
|
|
2836
|
-
const value = project.config?.ok ? project.config.site.keys[id] : void 0;
|
|
2837
|
-
const literal = value?.kind === "literal" ? value.value : void 0;
|
|
2838
|
-
const packages = featurePackages(id, literal, host.name, featureIds.filter((feature) => enabled.get(feature)?.enabled === "on"));
|
|
2839
|
-
const missing = state.enabled === "on" ? {
|
|
2840
|
-
dev: definition.devPackages.filter((name) => !project.installed(name)),
|
|
2841
|
-
prod: packages.filter((name) => !project.installed(name))
|
|
2842
|
-
} : {
|
|
2843
|
-
dev: [],
|
|
2844
|
-
prod: []
|
|
2845
|
-
};
|
|
2846
|
-
const providerChosen = id === "workflow" && host.name !== "netlify" && packages.includes("openworkflow");
|
|
2847
|
-
const fix = state.enabled === "on" ? featureFix(project, id, support, host.name, missing, providerChosen) : void 0;
|
|
2848
|
-
const resolvedSupport = support.level === "explicit" && support.option === "kv.driver" && kvStores(literal) ? {
|
|
2849
|
-
...support,
|
|
2850
|
-
option: kvDefaultStoreOption
|
|
2851
|
-
} : support;
|
|
2852
|
-
return {
|
|
2853
|
-
id,
|
|
2854
|
-
...state,
|
|
2855
|
-
missingPackages: [...missing.prod, ...missing.dev],
|
|
2856
|
-
support: resolvedSupport,
|
|
2857
|
-
...fix ? { fix } : {}
|
|
2858
|
-
};
|
|
2859
|
-
}),
|
|
2860
|
-
framework: project.framework,
|
|
2861
|
-
host,
|
|
2862
|
-
packageManager: project.packageManager,
|
|
2863
|
-
root: project.root,
|
|
2864
|
-
schemaVersion: 1
|
|
2865
|
-
};
|
|
2866
|
-
}
|
|
2867
2416
|
// src/setup/deploy/host.ts
|
|
2868
2417
|
/** A failed host CLI that may print values on stdout, such as `vercel env ls --json`: only stderr goes into the reason. */
|
|
2869
2418
|
function hostListFailed(step, result, secrets) {
|
|
@@ -2888,14 +2437,14 @@ async function untilInterrupted(work) {
|
|
|
2888
2437
|
received ??= signal;
|
|
2889
2438
|
controller.abort();
|
|
2890
2439
|
};
|
|
2891
|
-
process
|
|
2892
|
-
process
|
|
2440
|
+
process.on("SIGINT", stop);
|
|
2441
|
+
process.on("SIGTERM", stop);
|
|
2893
2442
|
try {
|
|
2894
2443
|
return await work(controller.signal);
|
|
2895
2444
|
} finally {
|
|
2896
|
-
process
|
|
2897
|
-
process
|
|
2898
|
-
if (received) process
|
|
2445
|
+
process.off("SIGINT", stop);
|
|
2446
|
+
process.off("SIGTERM", stop);
|
|
2447
|
+
if (received) process.exit(128 + constants.signals[received]);
|
|
2899
2448
|
}
|
|
2900
2449
|
}
|
|
2901
2450
|
/**
|
|
@@ -2941,7 +2490,7 @@ function createDeployRun(stderr, secrets) {
|
|
|
2941
2490
|
"pipe",
|
|
2942
2491
|
"pipe"
|
|
2943
2492
|
],
|
|
2944
|
-
detached: process
|
|
2493
|
+
detached: process.platform !== "win32"
|
|
2945
2494
|
});
|
|
2946
2495
|
const output = {
|
|
2947
2496
|
stderr: "",
|
|
@@ -3005,7 +2554,7 @@ function createDeployRun(stderr, secrets) {
|
|
|
3005
2554
|
};
|
|
3006
2555
|
const killTree = (signal) => {
|
|
3007
2556
|
if (!child.pid) return;
|
|
3008
|
-
if (process
|
|
2557
|
+
if (process.platform === "win32") spawn("taskkill", [
|
|
3009
2558
|
"/pid",
|
|
3010
2559
|
String(child.pid),
|
|
3011
2560
|
"/T",
|
|
@@ -3017,7 +2566,7 @@ function createDeployRun(stderr, secrets) {
|
|
|
3017
2566
|
child.kill(signal);
|
|
3018
2567
|
});
|
|
3019
2568
|
else try {
|
|
3020
|
-
process
|
|
2569
|
+
process.kill(-child.pid, signal);
|
|
3021
2570
|
} catch (error) {
|
|
3022
2571
|
if (error.code !== "ESRCH") child.kill(signal);
|
|
3023
2572
|
}
|
|
@@ -3064,7 +2613,7 @@ function windowsNodeEntry(file) {
|
|
|
3064
2613
|
if (/\.(?:exe|cmd|bat)$/iu.test(file)) return;
|
|
3065
2614
|
if (!existsSync(file)) return;
|
|
3066
2615
|
const source = readFileSync(file, "utf8");
|
|
3067
|
-
if (/\.[cm]?js$/iu.test(file) || /^#![^\r\n]*\bnode(?:\.exe)?(?:\s|$)/u.test(source)) return [process
|
|
2616
|
+
if (/\.[cm]?js$/iu.test(file) || /^#![^\r\n]*\bnode(?:\.exe)?(?:\s|$)/u.test(source)) return [process.execPath, file];
|
|
3068
2617
|
}
|
|
3069
2618
|
function executableIn(folder, name, platform) {
|
|
3070
2619
|
const file = join(folder, name);
|
|
@@ -3081,7 +2630,7 @@ function executableIn(folder, name, platform) {
|
|
|
3081
2630
|
* The host CLI as a command and its first arguments: the project's `node_modules/.bin` (walking up), then `PATH`,
|
|
3082
2631
|
* then `npx --yes <package>`, which the build output also names.
|
|
3083
2632
|
*/
|
|
3084
|
-
function hostCli(name, npmPackage, root, env, platform = process
|
|
2633
|
+
function hostCli(name, npmPackage, root, env, platform = process.platform) {
|
|
3085
2634
|
for (let folder = root;; folder = dirname(folder)) {
|
|
3086
2635
|
const found = executableIn(join(folder, "node_modules", ".bin"), name, platform);
|
|
3087
2636
|
if (found) return found;
|
|
@@ -3093,7 +2642,7 @@ function hostCli(name, npmPackage, root, env, platform = process$1.platform) {
|
|
|
3093
2642
|
if (found) return found;
|
|
3094
2643
|
}
|
|
3095
2644
|
if (platform === "win32") {
|
|
3096
|
-
for (const folder of [...path, dirname(process
|
|
2645
|
+
for (const folder of [...path, dirname(process.execPath)]) {
|
|
3097
2646
|
const npx = executableIn(folder, "npx", platform);
|
|
3098
2647
|
if (npx) return [
|
|
3099
2648
|
...npx,
|
|
@@ -3300,6 +2849,84 @@ async function readBuildOutput(root, host) {
|
|
|
3300
2849
|
...identityName ? { identityName } : {}
|
|
3301
2850
|
};
|
|
3302
2851
|
}
|
|
2852
|
+
// src/setup/deploy/console.ts
|
|
2853
|
+
const consoleKeyPrefix = "VITEHUB_CONSOLE_KEY_";
|
|
2854
|
+
const checkDelays = [
|
|
2855
|
+
1e3,
|
|
2856
|
+
2e3,
|
|
2857
|
+
4e3
|
|
2858
|
+
];
|
|
2859
|
+
/** True when the build reads `VITEHUB_CONSOLE_KEY_<NAME>`, which `console: true` adds. */
|
|
2860
|
+
function readsConsoleKey(entries) {
|
|
2861
|
+
return entries.some((entry) => entry.prefix === consoleKeyPrefix);
|
|
2862
|
+
}
|
|
2863
|
+
async function openDeployConsole(context) {
|
|
2864
|
+
if (!await readConsoleCredential(context.env)) return;
|
|
2865
|
+
try {
|
|
2866
|
+
const client = await openConsole(context);
|
|
2867
|
+
const apps = await listConsoleApps(client);
|
|
2868
|
+
return {
|
|
2869
|
+
apps,
|
|
2870
|
+
client,
|
|
2871
|
+
keys: Object.fromEntries(apps.flatMap((app) => app.keyVariable && app.publicKey ? [[app.keyVariable, app.publicKey]] : []))
|
|
2872
|
+
};
|
|
2873
|
+
} catch (error) {
|
|
2874
|
+
context.stderr.write(`Warning: deploy does not link the app in the Console, because the Console failed: ${errorMessage(error)}\n`);
|
|
2875
|
+
return "unavailable";
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
async function linkDeployedApp(options) {
|
|
2879
|
+
const { client } = options.console;
|
|
2880
|
+
try {
|
|
2881
|
+
const target = normalizeConsoleProjectUrl(options.url);
|
|
2882
|
+
const installed = options.console.apps.filter((app) => app.keyVariable && options.onHost.has(app.keyVariable));
|
|
2883
|
+
const known = installed.find((app) => app.url === target);
|
|
2884
|
+
if (!known && installed.length) {
|
|
2885
|
+
options.context.stderr.write(`Warning: the installed Console key links to ${installed.map((app) => app.url).join(", ")}, not ${options.url}. Link the current production URL and set its key with \`vitehub apps link ${options.url}\`.\n`);
|
|
2886
|
+
return;
|
|
2887
|
+
}
|
|
2888
|
+
const { app, created } = known ? {
|
|
2889
|
+
app: known,
|
|
2890
|
+
created: false
|
|
2891
|
+
} : await linkConsoleApp(client, {
|
|
2892
|
+
label: options.label,
|
|
2893
|
+
url: options.url
|
|
2894
|
+
});
|
|
2895
|
+
const keySet = app.keyVariable && app.publicKey && !options.onHost.has(app.keyVariable) ? app.keyVariable : void 0;
|
|
2896
|
+
const liveUrl = keySet && app.publicKey ? await options.setKey(keySet, app.publicKey) : options.url;
|
|
2897
|
+
if (!liveUrl || normalizeConsoleProjectUrl(liveUrl) !== app.url) {
|
|
2898
|
+
options.context.stderr.write(`Warning: the Console record for ${app.url} does not match the final production URL (${liveUrl ?? "not reported"}). Check the production URL before linking the app.\n`);
|
|
2899
|
+
return;
|
|
2900
|
+
}
|
|
2901
|
+
let check = await checkConsoleApp(client, app.id);
|
|
2902
|
+
for (const delay of checkDelays) {
|
|
2903
|
+
if (check.linked) break;
|
|
2904
|
+
await setTimeout$1(delay);
|
|
2905
|
+
check = await checkConsoleApp(client, app.id);
|
|
2906
|
+
}
|
|
2907
|
+
return {
|
|
2908
|
+
app: app.id,
|
|
2909
|
+
console: client.origin,
|
|
2910
|
+
created,
|
|
2911
|
+
...keySet ? { keySet } : {},
|
|
2912
|
+
linked: check.linked,
|
|
2913
|
+
...check.linked ? {} : { problem: checkProblem(check) },
|
|
2914
|
+
url: consoleAppUrl(client.origin, app)
|
|
2915
|
+
};
|
|
2916
|
+
} catch (error) {
|
|
2917
|
+
options.context.stderr.write(`Warning: the app is deployed, but deploy could not link it in the Console: ${errorMessage(error)} Run \`vitehub apps link ${options.url}\`.\n`);
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
function formatDeployConsole(output) {
|
|
2921
|
+
return `${[
|
|
2922
|
+
...output.created ? [`Linked the app in ${output.console} as ${output.app}.`] : [],
|
|
2923
|
+
...output.keySet ? [`Set ${output.keySet} on the host.`] : [],
|
|
2924
|
+
output.linked ? `Console: ${output.url}` : `The app does not accept the Console yet: ${output.problem ?? "no answer"}. Run \`vitehub apps check ${output.app}\`.`
|
|
2925
|
+
].join("\n")}\n`;
|
|
2926
|
+
}
|
|
2927
|
+
function errorMessage(error) {
|
|
2928
|
+
return error instanceof Error ? error.message : String(error);
|
|
2929
|
+
}
|
|
3303
2930
|
// src/setup/deploy/cloudflare.ts
|
|
3304
2931
|
const valueFlags = /* @__PURE__ */ new Set(["--config"]);
|
|
3305
2932
|
const plainFlags = /* @__PURE__ */ new Set(["--containers-rollout=gradual"]);
|
|
@@ -3400,6 +3027,28 @@ async function readWranglerOutput(file) {
|
|
|
3400
3027
|
}
|
|
3401
3028
|
});
|
|
3402
3029
|
}
|
|
3030
|
+
/**
|
|
3031
|
+
* Wrangler 4.157 writes the `workers.dev` target as an `https://` URL, a custom domain as a bare host, such as
|
|
3032
|
+
* `example.com (custom domain)`, and a route as its pattern. A route with one host and the path `/*` serves every path
|
|
3033
|
+
* of that host. A wildcard host, a narrower path, triggers, and a custom domain with `production: disabled` have no
|
|
3034
|
+
* URL to request.
|
|
3035
|
+
*/
|
|
3036
|
+
function wranglerTargetUrl(targets) {
|
|
3037
|
+
const texts = Array.isArray(targets) ? targets.filter((target) => typeof target === "string") : [];
|
|
3038
|
+
return [...texts.map(directTargetUrl), ...texts.map(routeTargetUrl)].find((url) => url !== void 0 && URL.canParse(url));
|
|
3039
|
+
}
|
|
3040
|
+
const workersDevTarget = /^https:\/\/[^\s*/]+\.workers\.dev\/?$/u;
|
|
3041
|
+
const customDomainTarget = /^([^\s*/:]+) \(custom domain[ )]/u;
|
|
3042
|
+
const catchAllRouteTarget = /^(?:https:\/\/)?([^\s*/:]+)\/\*(?: \(zone (?:id|name): [^)]+\))?$/u;
|
|
3043
|
+
function directTargetUrl(target) {
|
|
3044
|
+
if (workersDevTarget.test(target)) return target;
|
|
3045
|
+
const domain = customDomainTarget.exec(target)?.[1];
|
|
3046
|
+
return domain && !target.includes("production: disabled") ? `https://${domain}` : void 0;
|
|
3047
|
+
}
|
|
3048
|
+
function routeTargetUrl(target) {
|
|
3049
|
+
const host = catchAllRouteTarget.exec(target)?.[1];
|
|
3050
|
+
return host ? `https://${host}` : void 0;
|
|
3051
|
+
}
|
|
3403
3052
|
const durationUnits = {
|
|
3404
3053
|
second: 1e3,
|
|
3405
3054
|
minute: 6e4,
|
|
@@ -3508,18 +3157,19 @@ async function cloudflareAdapter(context) {
|
|
|
3508
3157
|
show: true,
|
|
3509
3158
|
signal
|
|
3510
3159
|
});
|
|
3511
|
-
|
|
3160
|
+
const step = context.preview ? "wrangler versions upload" : "wrangler deploy";
|
|
3161
|
+
if (result.exitCode !== 0) throw hostCliFailed(step, result, context.secrets);
|
|
3512
3162
|
const entry = (await readWranglerOutput(outputFile)).findLast((item) => item.type === (context.preview ? "version-upload" : "deploy"));
|
|
3513
3163
|
const text = `${result.stdout}\n${result.stderr}`;
|
|
3514
|
-
const
|
|
3515
|
-
const url = (
|
|
3516
|
-
if (!url) throw hostCliFailed(
|
|
3164
|
+
const fromTargets = entry && !context.preview;
|
|
3165
|
+
const url = fromTargets ? wranglerTargetUrl(entry.targets) : optionalString$1(entry?.preview_url) ?? findUrl(text, /\.workers\.dev$/u);
|
|
3166
|
+
if (!url && !fromTargets) throw hostCliFailed(`${step} printed no URL`, result, context.secrets);
|
|
3517
3167
|
const version = optionalString$1(entry?.version_id);
|
|
3518
3168
|
const claimUrl = /Claim URL:\s*(https:\/\/\S+)/u.exec(text)?.[1];
|
|
3519
3169
|
const expiresAt = claimExpiry(text);
|
|
3520
3170
|
const name = optionalString$1(entry?.worker_name);
|
|
3521
3171
|
return {
|
|
3522
|
-
url,
|
|
3172
|
+
...url ? { url } : {},
|
|
3523
3173
|
...version ? { version } : {},
|
|
3524
3174
|
...claimUrl ? { claim: {
|
|
3525
3175
|
url: claimUrl,
|
|
@@ -3737,7 +3387,7 @@ async function denoAdapter(context, organization) {
|
|
|
3737
3387
|
DENO_DEPLOY_ORG: organization
|
|
3738
3388
|
};
|
|
3739
3389
|
return { async deploy() {
|
|
3740
|
-
const result = await context.run(process
|
|
3390
|
+
const result = await context.run(process.execPath, [runner], {
|
|
3741
3391
|
cwd: context.root,
|
|
3742
3392
|
env,
|
|
3743
3393
|
show: true
|
|
@@ -3813,7 +3463,7 @@ function denoEnv(context) {
|
|
|
3813
3463
|
return Array.isArray(value) ? value.flatMap((item) => isRecord(item) && typeof item.key === "string" ? [item.key] : []) : [];
|
|
3814
3464
|
},
|
|
3815
3465
|
async setSecret(name, value, { secret }) {
|
|
3816
|
-
if (process
|
|
3466
|
+
if (process.platform === "win32") throw setupFailure(cliErrorDiagnostics.SETUP_ENV_VALUE_UNSUPPORTED({
|
|
3817
3467
|
host: "deno",
|
|
3818
3468
|
name,
|
|
3819
3469
|
reason: "Windows has no /dev/stdin for `deno deploy env load`."
|
|
@@ -4257,12 +3907,14 @@ function vercelAdapter(context) {
|
|
|
4257
3907
|
if (result.exitCode !== 0) throw hostCliFailed("vercel deploy", result, context.secrets);
|
|
4258
3908
|
const json = lastJsonObject(result.stdout);
|
|
4259
3909
|
const deployment = isRecord(json?.deployment) ? json.deployment : json;
|
|
4260
|
-
const
|
|
3910
|
+
const productionUrl = context.preview ? void 0 : optionalString$1(deployment?.productionUrl);
|
|
3911
|
+
const url = productionUrl ?? optionalString$1(deployment?.url);
|
|
4261
3912
|
if (!url) throw hostCliFailed("vercel deploy printed no URL", result, context.secrets);
|
|
4262
3913
|
const id = optionalString$1(deployment?.id);
|
|
4263
3914
|
const claim = context.temporary ? await readClaim(context.root) : void 0;
|
|
4264
3915
|
return {
|
|
4265
3916
|
url,
|
|
3917
|
+
...productionUrl ? { productionUrl } : {},
|
|
4266
3918
|
...id ? { deploymentId: id } : {},
|
|
4267
3919
|
...claim ? { claim } : {},
|
|
4268
3920
|
...context.temporary ? {} : { project: {
|
|
@@ -5736,8 +5388,8 @@ async function decryptPlanned(planned, root, env, secrets) {
|
|
|
5736
5388
|
}
|
|
5737
5389
|
async function confirmPush(planned, label) {
|
|
5738
5390
|
const terminal = createInterface({
|
|
5739
|
-
input: process
|
|
5740
|
-
output: process
|
|
5391
|
+
input: process.stdin,
|
|
5392
|
+
output: process.stderr
|
|
5741
5393
|
});
|
|
5742
5394
|
try {
|
|
5743
5395
|
return /^y(?:es)?$/iu.test((await terminal.question(`Push ${planned.map((item) => item.name).join(", ")} to ${label}? [y/N] `)).trim());
|
|
@@ -5765,7 +5417,7 @@ function addRedactions(planned, secrets) {
|
|
|
5765
5417
|
for (const item of planned) if (item.secret || item.value.length >= 4) secrets.push(item.value);
|
|
5766
5418
|
}
|
|
5767
5419
|
function sourceLabel(source) {
|
|
5768
|
-
return source === "process" ? "the shell" : source === "generated" ? "a generated value" : source;
|
|
5420
|
+
return source === "process" ? "the shell" : source === "generated" ? "a generated value" : source === "console" ? "the Console" : source;
|
|
5769
5421
|
}
|
|
5770
5422
|
function writePush(output, context) {
|
|
5771
5423
|
const lines = output.pushed.length ? [`Pushed to ${targetLabel(output)}:`, ...output.pushed.map((item) => ` ${item.name} from ${sourceLabel(item.source)}${item.encrypted ? ", decrypted" : ""}${item.replaced ? ", replaced" : ""}`)] : [`Nothing to push to ${targetLabel(output)}.`];
|
|
@@ -5790,7 +5442,7 @@ async function runPush(args, context) {
|
|
|
5790
5442
|
await assertUntracked(stored, target.project.root, target.run, context.env, context.stderr);
|
|
5791
5443
|
const planned = await decryptPlanned(stored, target.project.root, context.env, target.secrets);
|
|
5792
5444
|
if (!args.yes) {
|
|
5793
|
-
if (!(!args.json && !!process
|
|
5445
|
+
if (!(!args.json && !!process.stdin.isTTY && !!process.stderr.isTTY)) throw setupFailure(cliErrorDiagnostics.CLI_R0004({ message: `[vitehub] \`vitehub env push\` changes ${target.github ? "GitHub Actions secrets" : "host variables"} and was not confirmed. Without a terminal, pass --yes.` }), setupExitCodes.inputNeeded, { rerun: pushRerun(args) });
|
|
5794
5446
|
if (!await confirmPush(planned, targetLabel(output))) throw setupFailure(cliErrorDiagnostics.CLI_R0004({ message: "[vitehub] The push was not confirmed. Nothing was pushed." }), setupExitCodes.error);
|
|
5795
5447
|
}
|
|
5796
5448
|
const remoteName = (name) => target.github ? name.toUpperCase() : name;
|
|
@@ -5812,8 +5464,8 @@ async function runPush(args, context) {
|
|
|
5812
5464
|
const appSecretName = "VITEHUB_SECRET";
|
|
5813
5465
|
async function confirmGenerate(label) {
|
|
5814
5466
|
const terminal = createInterface({
|
|
5815
|
-
input: process
|
|
5816
|
-
output: process
|
|
5467
|
+
input: process.stdin,
|
|
5468
|
+
output: process.stderr
|
|
5817
5469
|
});
|
|
5818
5470
|
try {
|
|
5819
5471
|
return /^y(?:es)?$/iu.test((await terminal.question(`${appSecretName} is not set on ${label} and has no local value. Generate one and set it? [y/N] `)).trim());
|
|
@@ -5842,6 +5494,7 @@ async function checkDeployEnv(options) {
|
|
|
5842
5494
|
};
|
|
5843
5495
|
if (!entries.length) return {
|
|
5844
5496
|
apply: async () => {},
|
|
5497
|
+
onHost: /* @__PURE__ */ new Set(),
|
|
5845
5498
|
output,
|
|
5846
5499
|
upload: {}
|
|
5847
5500
|
};
|
|
@@ -5857,6 +5510,12 @@ async function checkDeployEnv(options) {
|
|
|
5857
5510
|
}) : void 0;
|
|
5858
5511
|
const onHost = new Set(hostEnv ? await hostEnv.listSecretNames() : []);
|
|
5859
5512
|
const values = await readLocalEnvValues(options.root, options.envDir, stage, context.env);
|
|
5513
|
+
for (const [name, value] of Object.entries(host === "cloudflare" ? options.consoleKeys ?? {} : {})) if (onHost.has(name) && !values.has(name)) values.set(name, {
|
|
5514
|
+
encrypted: false,
|
|
5515
|
+
files: [],
|
|
5516
|
+
source: "console",
|
|
5517
|
+
value
|
|
5518
|
+
});
|
|
5860
5519
|
const configVars = await configVarNames(host, options.outputDir);
|
|
5861
5520
|
const stored = planPush(entries, values, [], options.pushEnv || host === "cloudflare" ? configVars : onHost).planned;
|
|
5862
5521
|
if (host === "cloudflare") {
|
|
@@ -5870,6 +5529,7 @@ async function checkDeployEnv(options) {
|
|
|
5870
5529
|
}
|
|
5871
5530
|
const unavailable = [...onHost].filter((name) => !values.has(name));
|
|
5872
5531
|
if (unavailable.length) throw setupFailure(cliErrorDiagnostics.SETUP_DEPLOY_ENV_STAGE_UNSAFE({
|
|
5532
|
+
console: unavailable.some((name) => name.startsWith(consoleKeyPrefix)),
|
|
5873
5533
|
names: unavailable.join(", "),
|
|
5874
5534
|
stage
|
|
5875
5535
|
}), setupExitCodes.inputNeeded);
|
|
@@ -5893,11 +5553,12 @@ async function checkDeployEnv(options) {
|
|
|
5893
5553
|
output.generated = [appSecretName];
|
|
5894
5554
|
}
|
|
5895
5555
|
addRedactions(stored, options.secrets);
|
|
5896
|
-
const missing = unset();
|
|
5556
|
+
const missing = unset().filter((entry) => !options.deferConsoleKey || entry.prefix !== "VITEHUB_CONSOLE_KEY_");
|
|
5897
5557
|
const required = missing.filter(isRequired);
|
|
5898
5558
|
if (required.length) {
|
|
5899
5559
|
const names = required.map((entry) => entryLabel(diffEntry(entry))).join(", ");
|
|
5900
5560
|
throw setupFailure(cliErrorDiagnostics.SETUP_DEPLOY_ENV_MISSING({
|
|
5561
|
+
console: required.some((entry) => entry.prefix === consoleKeyPrefix),
|
|
5901
5562
|
firstDeploy: !link,
|
|
5902
5563
|
host,
|
|
5903
5564
|
names,
|
|
@@ -5920,8 +5581,14 @@ async function checkDeployEnv(options) {
|
|
|
5920
5581
|
output.pushed = planned.map((item) => item.name);
|
|
5921
5582
|
if (output.missing.length) context.stderr.write(`Warning: optional env not set on ${host}: ${output.missing.map(entryLabel).join(", ")}.\n`);
|
|
5922
5583
|
for (const item of planned) context.stderr.write(item.source === "generated" ? `Generated ${item.name} and set it on ${host}.\n` : `Setting ${item.name} on ${host}${host === "cloudflare" ? " with the new version" : ""} from ${sourceLabel(item.source)}${item.encrypted ? ", decrypted" : ""}${onHost.has(item.name) ? ", replaced" : ""}.\n`);
|
|
5584
|
+
const deployedNames = /* @__PURE__ */ new Set([
|
|
5585
|
+
...onHost,
|
|
5586
|
+
...configVars,
|
|
5587
|
+
...output.pushed
|
|
5588
|
+
]);
|
|
5923
5589
|
if (host === "cloudflare" || !hostEnv) return {
|
|
5924
5590
|
apply: async () => {},
|
|
5591
|
+
onHost: deployedNames,
|
|
5925
5592
|
output,
|
|
5926
5593
|
upload: host === "cloudflare" ? Object.fromEntries(planned.map((item) => [item.name, item.value])) : {}
|
|
5927
5594
|
};
|
|
@@ -5929,6 +5596,7 @@ async function checkDeployEnv(options) {
|
|
|
5929
5596
|
apply: async () => {
|
|
5930
5597
|
for (const item of planned) await hostEnv.setSecret(item.name, item.value, { secret: item.secret });
|
|
5931
5598
|
},
|
|
5599
|
+
onHost: deployedNames,
|
|
5932
5600
|
output,
|
|
5933
5601
|
upload: {}
|
|
5934
5602
|
};
|
|
@@ -5948,4 +5616,4 @@ async function runEnvCommand(feature, args, context) {
|
|
|
5948
5616
|
return writeSetupError(context, json, error);
|
|
5949
5617
|
}
|
|
5950
5618
|
}
|
|
5951
|
-
export {
|
|
5619
|
+
export { openDeployConsole as A, insertViteHubConfig as B, denoAdapter as C, listCloudflareDeployments as D, cloudflareAdapter as E, readDeployCommit as F, detectPackageManager as I, readSetupProject as L, build as M, readBuildOutput as N, formatDeployConsole as O, createDeployRun as P, setupLockfiles as R, abortable as S, listDenoDeployments as T, locateViteHubConfig as V, hasVercelLogin as _, addSetupLink as a, listNetlifyDeployments as b, hostRequired as c, readSetupLinkState as d, readSetupLinkStatus as f, writeSeparateResourcesNote as g, unlinkSetupProject as h, SETUP_LINK_FILE as i, readsConsoleKey as j, linkDeployedApp as k, linkSetupProject as l, selectSetupLink as m, env_exports as n, ensureViteHubGitignore as o, readSetupLinks as p, hostEnvs as r, gitignoreWithViteHub as s, checkDeployEnv as t, readLinkHostOption as u, listVercelDeployments as v, denoOrganization as w, netlifyAdapter as x, vercelAdapter as y, editViteHubConfig as z };
|