@vite-hub/cli 0.0.4 → 0.3.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 +82 -12
- package/dist/commands-DPg3kL8m.js +3104 -0
- package/dist/console-auth-xl7kLQNt.js +315 -0
- package/dist/console-env-C5YeAm2-.js +198 -0
- package/dist/env-DzoVtVJO.js +5820 -0
- package/dist/envelope-Cf56AJLa.js +88 -0
- package/dist/index.d.ts +38 -10
- package/dist/index.js +1462 -218
- package/dist/provision-C9p1wSzq.d.ts +170 -0
- package/dist/provision-D8OvBBzi.js +2262 -0
- package/dist/setup/index.d.ts +919 -0
- package/dist/setup/index.js +231 -0
- package/package.json +46 -16
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import "nostics";
|
|
2
|
+
//#region ../internal/dist/host-credentials-MN0OQ2os.d.ts
|
|
3
|
+
//#region src/host-credentials.d.ts
|
|
4
|
+
type CredentialHost = "cloudflare" | "vercel" | "netlify" | "deno";
|
|
5
|
+
type CredentialSource = "env" | "host-cli";
|
|
6
|
+
type HostCredentials = {
|
|
7
|
+
ok: true;
|
|
8
|
+
host: CredentialHost;
|
|
9
|
+
source: CredentialSource;
|
|
10
|
+
token: string;
|
|
11
|
+
accountId?: string;
|
|
12
|
+
teamId?: string;
|
|
13
|
+
} | {
|
|
14
|
+
ok: false;
|
|
15
|
+
host: CredentialHost;
|
|
16
|
+
missing: readonly string[];
|
|
17
|
+
fix: string;
|
|
18
|
+
};
|
|
19
|
+
/** Credential status without the token, safe for `status` and JSON output. */
|
|
20
|
+
type HostCredentialsDescription = {
|
|
21
|
+
ok: true;
|
|
22
|
+
host: CredentialHost;
|
|
23
|
+
source: CredentialSource;
|
|
24
|
+
accountId?: string;
|
|
25
|
+
teamId?: string;
|
|
26
|
+
} | {
|
|
27
|
+
ok: false;
|
|
28
|
+
host: CredentialHost;
|
|
29
|
+
missing: readonly string[];
|
|
30
|
+
fix: string;
|
|
31
|
+
};
|
|
32
|
+
interface HostCliRunResult {
|
|
33
|
+
exitCode: number | null;
|
|
34
|
+
stdout: string;
|
|
35
|
+
}
|
|
36
|
+
/** Runs a host CLI with an argument array and no shell, and returns its stdout. */
|
|
37
|
+
type HostCliRun = (command: string, args: readonly string[], options: {
|
|
38
|
+
cwd?: string;
|
|
39
|
+
env: NodeJS.ProcessEnv;
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
}) => Promise<HostCliRunResult>;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region ../internal/dist/provision-k67k9T1h.d.ts
|
|
44
|
+
//#region src/provision.d.ts
|
|
45
|
+
type ProvisionProvider = "cloudflare" | "vercel";
|
|
46
|
+
interface ProvisionLogger {
|
|
47
|
+
log: (message: string) => void;
|
|
48
|
+
warn: (message: string) => void;
|
|
49
|
+
}
|
|
50
|
+
interface ProvisionContext {
|
|
51
|
+
env: Record<string, string | undefined>;
|
|
52
|
+
fetch: typeof globalThis.fetch;
|
|
53
|
+
logger: ProvisionLogger;
|
|
54
|
+
markPlanUnchecked?: () => void;
|
|
55
|
+
}
|
|
56
|
+
interface ProvisionState {
|
|
57
|
+
cloudflare?: Record<string, Record<string, string>>;
|
|
58
|
+
vercel?: Record<string, Record<string, string>>;
|
|
59
|
+
}
|
|
60
|
+
interface ProvisionResult {
|
|
61
|
+
ids?: ProvisionState;
|
|
62
|
+
}
|
|
63
|
+
interface ProvisionAction {
|
|
64
|
+
kind: string;
|
|
65
|
+
name: string;
|
|
66
|
+
exists: boolean;
|
|
67
|
+
pending?: boolean;
|
|
68
|
+
/** Describes the change that `apply()` makes to an existing resource, for example `read replication: disabled -> auto`. */
|
|
69
|
+
update?: string;
|
|
70
|
+
apply: () => Promise<ProvisionResult>;
|
|
71
|
+
}
|
|
72
|
+
/** One Provision State category that a step records, with the keys that current Definitions use. */
|
|
73
|
+
interface ProvisionStateCategory {
|
|
74
|
+
category: string;
|
|
75
|
+
declared: readonly string[];
|
|
76
|
+
/** Provider resource identity for shared-resource checks. Return undefined when the recorded id lacks enough information. Defaults to the recorded id. */
|
|
77
|
+
resourceIdentity?: (entry: {
|
|
78
|
+
id: string;
|
|
79
|
+
key: string;
|
|
80
|
+
}) => string | undefined;
|
|
81
|
+
/** Identity expected by current config for a declared key. Omit when it cannot be established without provider access. */
|
|
82
|
+
declaredResourceIdentity?: (key: string) => string | undefined;
|
|
83
|
+
/** Tells a developer how to delete the resource of a recorded entry that no Definition declares. ViteHub never runs it. */
|
|
84
|
+
deleteHint: (entry: {
|
|
85
|
+
id: string;
|
|
86
|
+
key: string;
|
|
87
|
+
}) => string;
|
|
88
|
+
}
|
|
89
|
+
interface ProvisionStep {
|
|
90
|
+
id: string;
|
|
91
|
+
provider: ProvisionProvider;
|
|
92
|
+
plan: (context: ProvisionContext) => Promise<ProvisionAction[]>;
|
|
93
|
+
/** Describes the Provision State this step records. Runs without network access, also without credentials. */
|
|
94
|
+
recordedState?: (context: Pick<ProvisionContext, "env">) => ProvisionStateCategory[];
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region ../internal/dist/cli.d.ts
|
|
98
|
+
//#region src/cli.d.ts
|
|
99
|
+
interface ViteHubCliStreams {
|
|
100
|
+
stderr: {
|
|
101
|
+
write: (chunk: string | Uint8Array, encoding?: BufferEncoding | StdoutWriteCallback, callback?: StdoutWriteCallback) => unknown;
|
|
102
|
+
};
|
|
103
|
+
stdout: {
|
|
104
|
+
write: (chunk: string | Uint8Array) => unknown;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
interface ViteHubCliSpawnResult {
|
|
108
|
+
exitCode: number | null;
|
|
109
|
+
signal?: NodeJS.Signals | null;
|
|
110
|
+
/** The output of the child when `stdout` is `pipe`. */
|
|
111
|
+
stdout?: string;
|
|
112
|
+
}
|
|
113
|
+
interface ViteHubCliSpawnOptions {
|
|
114
|
+
cwd?: string;
|
|
115
|
+
env?: NodeJS.ProcessEnv;
|
|
116
|
+
stderr?: "inherit" | "pipe";
|
|
117
|
+
/** `ignore` gives the child no terminal input, so a tool that asks questions on a terminal does not ask. */
|
|
118
|
+
stdin?: "ignore" | "inherit";
|
|
119
|
+
/** `stderr` sends the child's stdout to the parent's stderr, so the parent's stdout keeps only its own output. */
|
|
120
|
+
stdout?: "inherit" | "pipe" | "stderr";
|
|
121
|
+
}
|
|
122
|
+
type ViteHubCliSpawn = (command: string, args: string[], options?: ViteHubCliSpawnOptions) => Promise<ViteHubCliSpawnResult>;
|
|
123
|
+
interface ViteHubCliContext extends ViteHubCliStreams {
|
|
124
|
+
cwd: string;
|
|
125
|
+
env: NodeJS.ProcessEnv;
|
|
126
|
+
/** Replaces `fetch` for commands that call a running app, so tests need no server. */
|
|
127
|
+
fetch?: typeof fetch;
|
|
128
|
+
/**
|
|
129
|
+
* Loads the project config for a build on `host` and returns the Provision Steps of its plugins, with the config root
|
|
130
|
+
* that holds `.vitehub/provision.json`. Setup commands, such as `vitehub deploy`, call it only when they need the
|
|
131
|
+
* steps, so they still run on a config that throws.
|
|
132
|
+
*/
|
|
133
|
+
loadProvision?: (host: ProvisionProvider) => Promise<ViteHubCliProvision>;
|
|
134
|
+
/** The deployed app's public origin from `vitehub({ publicUrl })`, when it is one string. */
|
|
135
|
+
publicUrl?: string;
|
|
136
|
+
rootDir: string;
|
|
137
|
+
/** Replaces the host CLI runner, such as for `wrangler auth token`, so tests need no real host CLI. */
|
|
138
|
+
runHostCli?: HostCliRun;
|
|
139
|
+
spawn: ViteHubCliSpawn;
|
|
140
|
+
}
|
|
141
|
+
interface ViteHubCliProvision {
|
|
142
|
+
rootDir: string;
|
|
143
|
+
steps: readonly ProvisionStep[];
|
|
144
|
+
}
|
|
145
|
+
interface ViteHubCliFeature {
|
|
146
|
+
description?: string;
|
|
147
|
+
name: string;
|
|
148
|
+
run: (args: string[], context: ViteHubCliContext) => Promise<number | void> | number | void;
|
|
149
|
+
usage?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A top-level command, such as `vitehub status`. It runs before the CLI loads the project config, with `rootDir` set to
|
|
153
|
+
* the working directory, so it works in an empty directory and on a project whose config throws.
|
|
154
|
+
*/
|
|
155
|
+
interface ViteHubCliCommand {
|
|
156
|
+
name: string;
|
|
157
|
+
description: string;
|
|
158
|
+
usage: string;
|
|
159
|
+
run: (args: string[], context: ViteHubCliContext) => Promise<number>;
|
|
160
|
+
}
|
|
161
|
+
interface ViteHubCliCommandNamespace {
|
|
162
|
+
/** The feature that `vitehub <name>` runs when the next argument names no other feature. It gets every argument after `<name>`. */
|
|
163
|
+
defaultFeature?: string;
|
|
164
|
+
description?: string;
|
|
165
|
+
features: ViteHubCliFeature[];
|
|
166
|
+
name: string;
|
|
167
|
+
}
|
|
168
|
+
type StdoutWriteCallback = (error?: Error | null) => void;
|
|
169
|
+
//#endregion
|
|
170
|
+
export { ProvisionProvider as a, HostCliRun as c, ViteHubCliProvision as i, HostCredentials as l, ViteHubCliCommandNamespace as n, CredentialHost as o, ViteHubCliContext as r, CredentialSource as s, ViteHubCliCommand as t, HostCredentialsDescription as u };
|