@vite-hub/cli 0.7.0 → 0.8.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/README.md +2 -1
- package/dist/{commands-o_CHzNS9.js → commands-w7tEEJph.js} +57 -62
- package/dist/console-apps-BQX-Np9Q.js +271 -0
- package/dist/console-auth-cCodgT_T.js +2813 -0
- package/dist/{console-env-MPzeOLqu.js → console-env-eXdVI6kw.js} +4 -14
- package/dist/{deploy-CGRf9Pq-.js → deploy-CqR6pJa-.js} +9 -4
- package/dist/{env-DSPUdOVC.js → env-D_CN5DyX.js} +8 -2
- package/dist/envelope-BJQ7xPyX.js +99 -0
- package/dist/help-cache-BI6y5pN8.js +195 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +64 -27
- package/dist/link-BRNWNqT9.js +663 -0
- package/dist/provision-9QsGgeiq.js +1741 -0
- package/dist/provision-Fiosv3Un.js +1391 -0
- package/dist/setup/index.js +8 -7
- package/dist/status-gjvZVutV.js +599 -0
- package/dist/vercel-B5CJLsT0.js +701 -0
- package/package.json +4 -4
- package/dist/provision-DWEZYLWJ.js +0 -8091
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as getStableStdoutWrite, C as setupCommandNames, D as createCliDiscoveryNitroCloser, E as collectViteHubCliContribution, M as rethrowCliViteImportError, N as viteCliProjectConfig, O as createNuxtConfigImport, P as withStdoutOnStderr, S as reservedOperationNamespaces, T as appUrlError, _ as operationCliOptions, b as parseOperationInput, f as callOperation, g as operationCall, h as createOperationRegistry, j as isCliViteMissing, k as findViteHubDevServerUrl, m as collectOperationContributions, s as PROVISION_STATE_FILE, t as createProvisionNamespace, u as readProvisionStateSync, v as operationCliPath, w as resolveViteHubProjectRoot, x as operationInputJsonSchema, y as operationsOf } from "./provision-Fiosv3Un.js";
|
|
2
|
+
import { S as quoteSupportedInstallSpecifier, T as isRecordOrFunction, d as cliErrorDiagnostics, f as loadAllEnv, p as withViteStageEnvironment, w as isRecord } from "./provision-9QsGgeiq.js";
|
|
2
3
|
import { spawn } from "node:child_process";
|
|
3
4
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
4
5
|
import process$1 from "node:process";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
7
|
import { basename, dirname, relative, resolve } from "pathe";
|
|
6
8
|
import { isAbsolute, resolve as resolve$1 } from "node:path";
|
|
7
9
|
import { createInterface } from "node:readline/promises";
|
|
8
|
-
import { pathToFileURL } from "node:url";
|
|
9
|
-
import { formatRuntimeDiagnosticError } from "@vite-hub/runtime";
|
|
10
10
|
// ../internal/dist/inspect.js
|
|
11
11
|
async function collectContributors(plugins) {
|
|
12
12
|
const contributors = [];
|
|
@@ -607,7 +607,7 @@ async function importWithVite(modules, resolution) {
|
|
|
607
607
|
const code = `export default await Promise.allSettled([${modules.map((module) => `import(${JSON.stringify(module)})`).join(", ")}])`;
|
|
608
608
|
const { runnerImport } = await import("vite");
|
|
609
609
|
try {
|
|
610
|
-
const { module } = await runnerImport(entry, {
|
|
610
|
+
const { dependencies, module } = await runnerImport(entry, {
|
|
611
611
|
configFile: false,
|
|
612
612
|
logLevel: "silent",
|
|
613
613
|
plugins: [{
|
|
@@ -621,6 +621,7 @@ async function importWithVite(modules, resolution) {
|
|
|
621
621
|
},
|
|
622
622
|
root: resolution.root
|
|
623
623
|
});
|
|
624
|
+
resolution.onViteDependencies?.(dependencies);
|
|
624
625
|
return new Map(modules.map((name, index) => [name, module.default[index]]));
|
|
625
626
|
} catch (reason) {
|
|
626
627
|
return new Map(modules.map((name) => [name, {
|
|
@@ -639,6 +640,7 @@ async function loadCliOperations(plugins, resolution, stderr) {
|
|
|
639
640
|
const contributions = await collectOperationContributions(await flattenPluginOptions(plugins));
|
|
640
641
|
const loaded = await loadOperationContributions(contributions, resolution);
|
|
641
642
|
const sources = [];
|
|
643
|
+
let complete = true;
|
|
642
644
|
for (const [index, contribution] of contributions.entries()) {
|
|
643
645
|
const result = loaded[index];
|
|
644
646
|
if (result.status === "fulfilled") {
|
|
@@ -648,15 +650,19 @@ async function loadCliOperations(plugins, resolution, stderr) {
|
|
|
648
650
|
});
|
|
649
651
|
continue;
|
|
650
652
|
}
|
|
653
|
+
complete = false;
|
|
651
654
|
const reason = result.reason instanceof Error ? result.reason.message : String(result.reason);
|
|
652
|
-
stderr.write(`${formatRuntimeDiagnosticError(cliErrorDiagnostics.CLI_OPERATIONS_LOAD_FAILED({
|
|
655
|
+
stderr.write(`${(await import("@vite-hub/runtime")).formatRuntimeDiagnosticError(cliErrorDiagnostics.CLI_OPERATIONS_LOAD_FAILED({
|
|
653
656
|
export: contribution.export,
|
|
654
657
|
module: contribution.module,
|
|
655
658
|
plugin: contribution.plugin,
|
|
656
659
|
reason
|
|
657
660
|
}))}\n`);
|
|
658
661
|
}
|
|
659
|
-
return
|
|
662
|
+
return {
|
|
663
|
+
complete,
|
|
664
|
+
operations: createOperationRegistry(sources).list()
|
|
665
|
+
};
|
|
660
666
|
}
|
|
661
667
|
function kebab(key) {
|
|
662
668
|
return key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
@@ -664,9 +670,6 @@ function kebab(key) {
|
|
|
664
670
|
function camel(flag) {
|
|
665
671
|
return flag.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase());
|
|
666
672
|
}
|
|
667
|
-
function isObject(value) {
|
|
668
|
-
return value !== null && Object(value) === value && !Array.isArray(value);
|
|
669
|
-
}
|
|
670
673
|
const scalarTypes = /* @__PURE__ */ new Set([
|
|
671
674
|
"boolean",
|
|
672
675
|
"integer",
|
|
@@ -674,7 +677,7 @@ const scalarTypes = /* @__PURE__ */ new Set([
|
|
|
674
677
|
"string"
|
|
675
678
|
]);
|
|
676
679
|
function readType(schema) {
|
|
677
|
-
if (!
|
|
680
|
+
if (!isRecordOrFunction(schema)) return {
|
|
678
681
|
alternatives: [],
|
|
679
682
|
nullable: false,
|
|
680
683
|
type: "json"
|
|
@@ -682,8 +685,8 @@ function readType(schema) {
|
|
|
682
685
|
const options = Array.isArray(schema.anyOf) ? schema.anyOf : Array.isArray(schema.oneOf) ? schema.oneOf : void 0;
|
|
683
686
|
if (options) {
|
|
684
687
|
const parts = options.map(readType);
|
|
685
|
-
const nulls = options.filter((option) =>
|
|
686
|
-
const present = parts.filter((_part, index) => !(
|
|
688
|
+
const nulls = options.filter((option) => isRecordOrFunction(option) && option.type === "null").length;
|
|
689
|
+
const present = parts.filter((_part, index) => !(isRecordOrFunction(options[index]) && options[index].type === "null"));
|
|
687
690
|
const nullable = nulls > 0 || parts.some((part) => part.nullable);
|
|
688
691
|
if (present.length === 1) return {
|
|
689
692
|
...present[0],
|
|
@@ -753,9 +756,9 @@ function readType(schema) {
|
|
|
753
756
|
}
|
|
754
757
|
function flagsOf(operation) {
|
|
755
758
|
const schema = operationInputJsonSchema(operation);
|
|
756
|
-
const shapes = (Array.isArray(schema.anyOf) ? schema.anyOf : [schema]).filter(
|
|
757
|
-
return [...new Map(shapes.flatMap((shape) =>
|
|
758
|
-
const description =
|
|
759
|
+
const shapes = (Array.isArray(schema.anyOf) ? schema.anyOf : [schema]).filter(isRecordOrFunction);
|
|
760
|
+
return [...new Map(shapes.flatMap((shape) => isRecordOrFunction(shape.properties) ? Object.entries(shape.properties) : []))].map(([key, property]) => {
|
|
761
|
+
const description = isRecordOrFunction(property) ? property.description : void 0;
|
|
759
762
|
const required = shapes.every((shape) => Array.isArray(shape.required) && shape.required.includes(key));
|
|
760
763
|
return {
|
|
761
764
|
...readType(property),
|
|
@@ -862,7 +865,7 @@ function readWholeInput(raw, cwd) {
|
|
|
862
865
|
throw usageError(`--input could not read ${raw.slice(1)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
863
866
|
}
|
|
864
867
|
const value = parseJson(text, "input");
|
|
865
|
-
if (!
|
|
868
|
+
if (!isRecordOrFunction(value)) throw usageError("--input must be a JSON object.");
|
|
866
869
|
return value;
|
|
867
870
|
}
|
|
868
871
|
function positionalKeysSkippingLeadingOptionals(positional, flags, named, count) {
|
|
@@ -997,6 +1000,7 @@ async function throughConsole(url, context, signal) {
|
|
|
997
1000
|
context.stderr.write("Warning: Console discovery failed. The CLI will call the app directly if time remains.\n");
|
|
998
1001
|
};
|
|
999
1002
|
try {
|
|
1003
|
+
const [{ selectConsole }, { consoleClient }] = await Promise.all([import("./console-auth-cCodgT_T.js").then((n) => n.a), import("./console-apps-BQX-Np9Q.js").then((n) => n.o)]);
|
|
1000
1004
|
const { credential } = await selectConsole(context, void 0, signal);
|
|
1001
1005
|
if (!credential) return;
|
|
1002
1006
|
const { body } = await consoleClient(context, credential, signal).request("/api/projects");
|
|
@@ -1486,7 +1490,7 @@ const hostEnvFeatures = {
|
|
|
1486
1490
|
{
|
|
1487
1491
|
description: "Compare the env names of the last build with the names on the linked host. Exits with 1 when a required name is missing. Never reads values.",
|
|
1488
1492
|
name: "diff",
|
|
1489
|
-
run: async (args, context) => await (await import("./env-
|
|
1493
|
+
run: async (args, context) => await (await import("./env-D_CN5DyX.js").then((n) => n.n)).runEnvCommand({
|
|
1490
1494
|
...hostEnvFeatures.features[0],
|
|
1491
1495
|
name: "diff"
|
|
1492
1496
|
}, args, context),
|
|
@@ -1495,7 +1499,7 @@ const hostEnvFeatures = {
|
|
|
1495
1499
|
{
|
|
1496
1500
|
description: "Set the host variables of the build's env names from the shell and .env.<stage>, with the host CLI. Prints names, never values. Never deletes a host variable.",
|
|
1497
1501
|
name: "push",
|
|
1498
|
-
run: async (args, context) => await (await import("./env-
|
|
1502
|
+
run: async (args, context) => await (await import("./env-D_CN5DyX.js").then((n) => n.n)).runEnvCommand({
|
|
1499
1503
|
...hostEnvFeatures.features[1],
|
|
1500
1504
|
name: "push"
|
|
1501
1505
|
}, args, context),
|
|
@@ -1504,14 +1508,14 @@ const hostEnvFeatures = {
|
|
|
1504
1508
|
{
|
|
1505
1509
|
description: "Write the env values of a stage from a self-hosted Console to .env.<stage>. Needs `vitehub login` and the owner or admin role.",
|
|
1506
1510
|
name: "pull",
|
|
1507
|
-
run: async (args, context) => await (await import("./console-env-
|
|
1511
|
+
run: async (args, context) => await (await import("./console-env-eXdVI6kw.js").then((n) => n.t)).envPullFeature.run(args, context),
|
|
1508
1512
|
usage: "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]"
|
|
1509
1513
|
}
|
|
1510
1514
|
],
|
|
1511
1515
|
name: "env"
|
|
1512
1516
|
};
|
|
1513
1517
|
async function loadSetupCommands() {
|
|
1514
|
-
return (await import("./commands-
|
|
1518
|
+
return (await import("./commands-w7tEEJph.js").then((n) => n.t)).setupCommands;
|
|
1515
1519
|
}
|
|
1516
1520
|
async function loadNuxtViteConfig(rootDir, command, mode) {
|
|
1517
1521
|
if (![
|
|
@@ -1529,9 +1533,11 @@ async function loadNuxtViteConfig(rootDir, command, mode) {
|
|
|
1529
1533
|
} catch {
|
|
1530
1534
|
throw cliErrorDiagnostics.CLI_R0001({ message: "[vitehub] Nuxt config was found, but Nuxt could not be loaded for CLI discovery." });
|
|
1531
1535
|
}
|
|
1536
|
+
const importConfig = await createNuxtConfigImport(rootDir, fileURLToPath(import.meta.resolve("nuxt/kit")));
|
|
1532
1537
|
const options = {
|
|
1533
1538
|
cwd: rootDir,
|
|
1534
1539
|
dev: command === "serve",
|
|
1540
|
+
...importConfig ? { import: importConfig.import } : {},
|
|
1535
1541
|
envName: mode ?? (command === "build" ? "production" : "development"),
|
|
1536
1542
|
overrides: {
|
|
1537
1543
|
devtools: { enabled: false },
|
|
@@ -1567,6 +1573,7 @@ async function loadNuxtViteConfig(rootDir, command, mode) {
|
|
|
1567
1573
|
vitehubCliDiscovery: true
|
|
1568
1574
|
}, command, mode ?? (command === "build" ? "production" : "development"));
|
|
1569
1575
|
return {
|
|
1576
|
+
inputs: [...nuxt.options._layers.map((layer) => layer.config.rootDir), ...importConfig?.files ?? []],
|
|
1570
1577
|
nitro: { handlers: [...resolveRouteHandlers({
|
|
1571
1578
|
...Object(Reflect.get(config, "nitro")),
|
|
1572
1579
|
alias: {
|
|
@@ -1667,7 +1674,11 @@ async function loadViteConfig(rootDir, command, mode) {
|
|
|
1667
1674
|
vitehubCliDiscovery: true
|
|
1668
1675
|
};
|
|
1669
1676
|
try {
|
|
1670
|
-
|
|
1677
|
+
const config = await resolveConfig(inlineConfig, command, resolvedMode);
|
|
1678
|
+
return {
|
|
1679
|
+
...config,
|
|
1680
|
+
inputs: config.configFileDependencies
|
|
1681
|
+
};
|
|
1671
1682
|
} finally {
|
|
1672
1683
|
await nitro.close();
|
|
1673
1684
|
}
|
|
@@ -1757,7 +1768,7 @@ async function runViteHubCli(options = {}) {
|
|
|
1757
1768
|
}
|
|
1758
1769
|
const spawn = options.spawn || defaultSpawn;
|
|
1759
1770
|
const stage = args[0] === "channels" && (args[1] === "sync" || args[1] === "history") || args[0] === "seed" ? readStageArg(args) : void 0;
|
|
1760
|
-
const loadProject = (command) => withStdoutOnStderr(async () => {
|
|
1771
|
+
const loadProject = (command, recordHelpInputs = false) => withStdoutOnStderr(async () => {
|
|
1761
1772
|
const loadConfig = options.loadConfig || loadViteConfig;
|
|
1762
1773
|
const loadNuxtConfig = options.loadNuxtViteConfig || loadNuxtViteConfig;
|
|
1763
1774
|
const config = await (stage ? loadConfig(cwd, command, stage) : loadConfig(cwd, command));
|
|
@@ -1765,11 +1776,18 @@ async function runViteHubCli(options = {}) {
|
|
|
1765
1776
|
const plugins = nuxtConfig?.plugins ?? config.plugins;
|
|
1766
1777
|
const rootDir = resolve(nuxtConfig?.root || config.root || cwd);
|
|
1767
1778
|
const { alias, tsconfigPaths } = (nuxtConfig ?? config).resolve ?? {};
|
|
1779
|
+
const inputs = [
|
|
1780
|
+
...config.inputs ?? [],
|
|
1781
|
+
...nuxtConfig?.inputs ?? [],
|
|
1782
|
+
rootDir
|
|
1783
|
+
];
|
|
1768
1784
|
return {
|
|
1785
|
+
inputs,
|
|
1769
1786
|
contribution: await collectViteHubCliContribution(plugins),
|
|
1770
1787
|
handlers: resolveRouteHandlers(nuxtConfig ? nuxtConfig.nitro : config.nitro, nuxtConfig?.root || config.root || cwd),
|
|
1771
|
-
|
|
1788
|
+
discovery: await loadCliOperations(plugins, {
|
|
1772
1789
|
alias,
|
|
1790
|
+
...recordHelpInputs ? { onViteDependencies: (files) => inputs.push(...files) } : {},
|
|
1773
1791
|
root: rootDir,
|
|
1774
1792
|
tsconfigPaths
|
|
1775
1793
|
}, stderr),
|
|
@@ -1858,16 +1876,29 @@ async function runViteHubCli(options = {}) {
|
|
|
1858
1876
|
stderr,
|
|
1859
1877
|
stdout
|
|
1860
1878
|
});
|
|
1879
|
+
const helpCache = options.helpCache && !stage && (!args.length || isRootHelp(args) || args.length === 2 && isHelpFlag(args[1])) ? await import("./help-cache-BI6y5pN8.js") : void 0;
|
|
1880
|
+
const cached = helpCache?.readHelpCache(cwd, env);
|
|
1881
|
+
if (cached && args.length < 2) {
|
|
1882
|
+
writeRootHelp(cached.namespaces, cached.commands, stdout);
|
|
1883
|
+
return 0;
|
|
1884
|
+
}
|
|
1885
|
+
const cachedNamespace = cached?.namespaces.find((namespace) => namespace.name === args[0]);
|
|
1886
|
+
if (cachedNamespace && !(cachedNamespace.defaultFeature === cachedNamespace.name && cachedNamespace.features.length === 1)) {
|
|
1887
|
+
writeNamespaceHelp(cachedNamespace, stdout);
|
|
1888
|
+
return 0;
|
|
1889
|
+
}
|
|
1890
|
+
const helpRecording = cached ? void 0 : helpCache?.recordHelpCache(cwd, env);
|
|
1861
1891
|
const command = args[0] === "inspect" && (args[1] === "output" || args[1] === "resources" || args[1] === "routes") ? "build" : "serve";
|
|
1862
1892
|
const runtimeNamespaces = (options.runtimeNamespaces ?? []).filter((namespace) => !BUILTIN_NAMESPACE_NAMES.has(namespace.name));
|
|
1863
1893
|
let project;
|
|
1864
1894
|
try {
|
|
1865
|
-
project = await (stage ? withViteStageEnvironment(env, () => loadProject(command)) : loadProject(command));
|
|
1895
|
+
project = await (stage ? withViteStageEnvironment(env, () => loadProject(command)) : loadProject(command, !!helpRecording));
|
|
1866
1896
|
} catch (error) {
|
|
1897
|
+
helpRecording?.stop();
|
|
1867
1898
|
const envHelp = args[0] === hostEnvFeatures.name && isHelpFlag(args[1]);
|
|
1868
1899
|
const helpWithoutVite = isCliViteMissing(error) && isDiscoveryHelp(args);
|
|
1869
1900
|
if (!helpWithoutVite && args.length && !isRootHelp(args) && !envHelp) throw error;
|
|
1870
|
-
stderr.write(helpWithoutVite ? `${HELP_WITHOUT_VITE}\n\n` : `${formatRuntimeDiagnosticError(error)}\n${envHelp ? ENV_HELP_WITHOUT_CONFIG : ROOT_HELP_WITHOUT_CONFIG}\n\n`);
|
|
1901
|
+
stderr.write(helpWithoutVite ? `${HELP_WITHOUT_VITE}\n\n` : `${(await import("@vite-hub/runtime")).formatRuntimeDiagnosticError(error)}\n${envHelp ? ENV_HELP_WITHOUT_CONFIG : ROOT_HELP_WITHOUT_CONFIG}\n\n`);
|
|
1871
1902
|
if (envHelp) writeNamespaceHelp(hostEnvFeatures, stdout);
|
|
1872
1903
|
else writeRootHelp([
|
|
1873
1904
|
provisionNamespace,
|
|
@@ -1876,7 +1907,8 @@ async function runViteHubCli(options = {}) {
|
|
|
1876
1907
|
], await loadCommands(), stdout);
|
|
1877
1908
|
return helpWithoutVite ? 0 : 1;
|
|
1878
1909
|
}
|
|
1879
|
-
const { contribution,
|
|
1910
|
+
const { contribution, discovery: { complete, operations }, handlers, inputs, plugins, rootDir } = project;
|
|
1911
|
+
if (!complete) helpRecording?.stop();
|
|
1880
1912
|
const runtimeNames = new Set(runtimeNamespaces.map((namespace) => namespace.name));
|
|
1881
1913
|
const namespaces = [
|
|
1882
1914
|
...mergeOperationNamespaces(contribution.namespaces, createOperationNamespaces(operations)).filter((namespace) => !BUILTIN_NAMESPACE_NAMES.has(namespace.name) && !runtimeNames.has(namespace.name)),
|
|
@@ -1904,6 +1936,10 @@ async function runViteHubCli(options = {}) {
|
|
|
1904
1936
|
stderr,
|
|
1905
1937
|
stdout
|
|
1906
1938
|
};
|
|
1939
|
+
if (complete) helpRecording?.write(namespaces, (await loadCommands()).map(({ description, name }) => ({
|
|
1940
|
+
description,
|
|
1941
|
+
name
|
|
1942
|
+
})), inputs);
|
|
1907
1943
|
if (!args.length || isRootHelp(args)) {
|
|
1908
1944
|
writeRootHelp(namespaces, await loadCommands(), stdout);
|
|
1909
1945
|
return 0;
|
|
@@ -1991,13 +2027,14 @@ function runViteHubCliEntrypoint(options = {}) {
|
|
|
1991
2027
|
let exitCode;
|
|
1992
2028
|
try {
|
|
1993
2029
|
exitCode = await runViteHubCli({
|
|
2030
|
+
helpCache: true,
|
|
1994
2031
|
...options,
|
|
1995
2032
|
stderr: stderr.stream,
|
|
1996
2033
|
stdout: stdout.stream
|
|
1997
2034
|
});
|
|
1998
2035
|
} catch (error) {
|
|
1999
2036
|
try {
|
|
2000
|
-
stderr.stream.write(`${formatRuntimeDiagnosticError(error)}\n`);
|
|
2037
|
+
stderr.stream.write(`${(await import("@vite-hub/runtime")).formatRuntimeDiagnosticError(error)}\n`);
|
|
2001
2038
|
} catch {}
|
|
2002
2039
|
exitCode = 1;
|
|
2003
2040
|
}
|