critiqs-react 0.3.0 → 0.4.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/AGENT_SETUP.md +198 -66
- package/README.md +214 -31
- package/bin/critiqs.mjs +3 -1
- package/dist/index.js +16877 -4770
- package/dist/server/index.d.ts +1 -87
- package/dist/server/index.js +1 -4889
- package/package.json +6 -5
- package/bin/cli.d.mts +0 -21
- package/bin/cli.mjs +0 -293
- package/bin/env.d.mts +0 -41
- package/bin/env.mjs +0 -384
- package/bin/init.d.mts +0 -126
- package/bin/init.mjs +0 -965
- package/bin/mcp.d.mts +0 -20
- package/bin/mcp.mjs +0 -314
- package/bin/setup.d.mts +0 -183
- package/bin/setup.mjs +0 -1054
- package/dist/backend/convex/_generated/api.d.ts +0 -95
- package/dist/backend/convex/_generated/api.js +0 -23
- package/dist/backend/convex/_generated/dataModel.d.ts +0 -60
- package/dist/backend/convex/_generated/server.d.ts +0 -162
- package/dist/backend/convex/_generated/server.js +0 -101
- package/dist/backend/convex/ai.ts +0 -93
- package/dist/backend/convex/aiSettings.ts +0 -43
- package/dist/backend/convex/auth.config.ts +0 -18
- package/dist/backend/convex/captureHttp.ts +0 -96
- package/dist/backend/convex/captures.ts +0 -167
- package/dist/backend/convex/crons.ts +0 -14
- package/dist/backend/convex/deviceSignIn.ts +0 -151
- package/dist/backend/convex/grouping.ts +0 -41
- package/dist/backend/convex/http.ts +0 -724
- package/dist/backend/convex/lib/ai.ts +0 -6
- package/dist/backend/convex/lib/links.ts +0 -12
- package/dist/backend/convex/lib/pages.ts +0 -207
- package/dist/backend/convex/lib/r2.ts +0 -75
- package/dist/backend/convex/lib/store.ts +0 -509
- package/dist/backend/convex/lib/tokens.ts +0 -101
- package/dist/backend/convex/lib/validators.ts +0 -73
- package/dist/backend/convex/lib/vendor/aws4fetch.js +0 -289
- package/dist/backend/convex/lib/vendor/critiqs_ai.js +0 -49081
- package/dist/backend/convex/lib/vendor/critiqs_core.js +0 -385
- package/dist/backend/convex/lib/vendor/critiqs_server.js +0 -3108
- package/dist/backend/convex/notificationEmails.ts +0 -61
- package/dist/backend/convex/notifications.ts +0 -182
- package/dist/backend/convex/plans.ts +0 -67
- package/dist/backend/convex/projects.ts +0 -46
- package/dist/backend/convex/schema.ts +0 -343
- package/dist/backend/convex/search.ts +0 -26
- package/dist/backend/convex/signIn.ts +0 -368
- package/dist/backend/convex/tags.ts +0 -68
- package/dist/backend/convex/threads.ts +0 -146
- package/dist/backend/convex/users.ts +0 -13
- package/dist/server/chunks/driver-n9zpr0k3.js +0 -21
- package/dist/server/chunks/index-9bg7tmnq.js +0 -522
- package/dist/server/chunks/index-askcfn7t.js +0 -148
- package/dist/server/chunks/providers-rv184xvj.js +0 -48444
- package/dist/server/chunks/token-kzddms7r.js +0 -63
- package/dist/server/chunks/token-util-k8bee1wc.js +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "critiqs-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Critiqs's React component: add <Critiqs /> to a prototype to comment on it, discuss feedback, and find its context.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"design review",
|
|
13
13
|
"nextjs"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://github.com/noahsjung/
|
|
15
|
+
"homepage": "https://github.com/noahsjung/critiqs/tree/main/packages/react#readme",
|
|
16
16
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/noahsjung/
|
|
17
|
+
"url": "https://github.com/noahsjung/critiqs/issues"
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
20
|
"exports": {
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"prepack": "bun run build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
+
"critiqs": "0.4.0",
|
|
40
41
|
"convex": "^1.46.0",
|
|
41
42
|
"modern-screenshot": "^4.6.0"
|
|
42
43
|
},
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"react-dom": ">=18"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@happy-dom/global-registrator": "^
|
|
49
|
+
"@happy-dom/global-registrator": "^21.0.4",
|
|
49
50
|
"@types/bun": "^1.4.2",
|
|
50
51
|
"@types/react": "^19.3.0",
|
|
51
52
|
"@types/react-dom": "^19.3.0",
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
],
|
|
68
69
|
"repository": {
|
|
69
70
|
"type": "git",
|
|
70
|
-
"url": "https://github.com/noahsjung/
|
|
71
|
+
"url": "https://github.com/noahsjung/critiqs.git",
|
|
71
72
|
"directory": "packages/react"
|
|
72
73
|
},
|
|
73
74
|
"engines": {
|
package/bin/cli.d.mts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare const USAGE: string;
|
|
2
|
-
export interface CommandOptions {
|
|
3
|
-
command: "init" | "doctor" | "mcp" | null;
|
|
4
|
-
projectId: string | null;
|
|
5
|
-
dir: string;
|
|
6
|
-
dryRun: boolean;
|
|
7
|
-
/** "cloud", "own-convex", or a backend URL. */
|
|
8
|
-
target: string | null;
|
|
9
|
-
name: string | null;
|
|
10
|
-
reviewUrl: string | null;
|
|
11
|
-
help: boolean;
|
|
12
|
-
entry: string | null;
|
|
13
|
-
mount: string | null;
|
|
14
|
-
signIn: "remote" | "browser" | null;
|
|
15
|
-
newProject: boolean;
|
|
16
|
-
json: boolean;
|
|
17
|
-
/** The .env file to set an environment-backed project ID in, relative to `dir`. */
|
|
18
|
-
envFile: string | null;
|
|
19
|
-
}
|
|
20
|
-
export declare function parseCommand(argv: string[]): CommandOptions | { error: string };
|
|
21
|
-
export declare function runCli(argv: string[], options?: { cwd?: string; print?: (message: string) => void }): Promise<number>;
|
package/bin/cli.mjs
DELETED
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `critiqs` command: `init` sets up Critiqs for a prototype, `doctor` checks
|
|
3
|
-
* the setup works, and `mcp` offers the same steps to coding agents.
|
|
4
|
-
*/
|
|
5
|
-
import { createInterface } from "node:readline";
|
|
6
|
-
import { resolve } from "node:path";
|
|
7
|
-
import { relative } from "node:path";
|
|
8
|
-
import { runInit, workspaceApps } from "./init.mjs";
|
|
9
|
-
import { beginSetup, CLOUD_BACKEND_URL, DOCTOR_NOTE, doctor, doctorReport, openBrowser, readiness, SetupError } from "./setup.mjs";
|
|
10
|
-
|
|
11
|
-
export const USAGE = `Usage:
|
|
12
|
-
critiqs init Add Critiqs to the prototype and connect it to a new Critiqs Cloud project
|
|
13
|
-
critiqs init <projectId> Write an existing project's ID into the prototype
|
|
14
|
-
critiqs doctor Check that the prototype's Critiqs setup works
|
|
15
|
-
critiqs mcp Run the MCP server that lets coding agents do the same
|
|
16
|
-
|
|
17
|
-
Init adds <Critiqs /> where the app renders (a React root, a Next.js root layout,
|
|
18
|
-
or a Next.js custom App) when the code has none, and keeps a project the code
|
|
19
|
-
already names. Critiqs Cloud is the default: there are no keys to enter.
|
|
20
|
-
In Vite and Next.js apps the component reads its project ID from the app's
|
|
21
|
-
public environment variable (such as VITE_CRITIQS_PROJECT_ID), which init sets
|
|
22
|
-
in .env.local; each deployment sets its own, and copies without one show
|
|
23
|
-
nothing. In a workspace, run init once per app with --dir.
|
|
24
|
-
|
|
25
|
-
Options for init:
|
|
26
|
-
--name <name> Project name (default: the app's package name)
|
|
27
|
-
--review-url <url> The prototype's deployed address, where mention emails link
|
|
28
|
-
--entry <file> The file where the app renders, relative to --dir
|
|
29
|
-
--mount <Element> The element in that file to add <Critiqs /> beside, such as App
|
|
30
|
-
--remote Approve sign-in from a browser on any device, with a short code
|
|
31
|
-
--browser Sign in through a browser on this computer
|
|
32
|
-
(default: --browser, or --remote over SSH or without a desktop)
|
|
33
|
-
--new-project Create a new project even if the code or your account has one
|
|
34
|
-
--dir <path> The app's folder (default: current folder)
|
|
35
|
-
--project-env-file <file> The .env file init writes or doctor checks, relative to --dir (default: .env.local)
|
|
36
|
-
--dry-run With a project ID, show the change without writing it
|
|
37
|
-
--json Print the result as JSON, for scripts and coding agents
|
|
38
|
-
|
|
39
|
-
Optional: keep feedback on your own backend instead of Critiqs Cloud
|
|
40
|
-
--own-convex Deploy Critiqs to your team's own Convex deployment
|
|
41
|
-
--backend <url> Use a Critiqs backend that is already deployed
|
|
42
|
-
--cloud Critiqs Cloud (the default)
|
|
43
|
-
|
|
44
|
-
Keys, read from the environment or asked for (own Convex only):
|
|
45
|
-
CONVEX_DEPLOY_KEY A production deploy key from your Convex project's settings
|
|
46
|
-
RESEND_API_KEY, CRITIQS_EMAIL_FROM
|
|
47
|
-
Optional: send mention emails through your Resend account
|
|
48
|
-
|
|
49
|
-
Options for doctor:
|
|
50
|
-
--backend <url> Check this backend instead of the one the code names
|
|
51
|
-
--dir <path> The prototype's folder (default: current folder)
|
|
52
|
-
--json Print the checks as JSON`;
|
|
53
|
-
|
|
54
|
-
/** Parses the command line; returns options or an error message. */
|
|
55
|
-
export function parseCommand(argv) {
|
|
56
|
-
const options = {
|
|
57
|
-
command: null,
|
|
58
|
-
projectId: null,
|
|
59
|
-
dir: ".",
|
|
60
|
-
dryRun: false,
|
|
61
|
-
target: null,
|
|
62
|
-
name: null,
|
|
63
|
-
reviewUrl: null,
|
|
64
|
-
help: false,
|
|
65
|
-
entry: null,
|
|
66
|
-
mount: null,
|
|
67
|
-
signIn: null,
|
|
68
|
-
newProject: false,
|
|
69
|
-
json: false,
|
|
70
|
-
envFile: null,
|
|
71
|
-
};
|
|
72
|
-
const positional = [];
|
|
73
|
-
for (let i = 0; i < argv.length; i++) {
|
|
74
|
-
const arg = argv[i] ?? "";
|
|
75
|
-
const value = (flag) => {
|
|
76
|
-
const next = arg.includes("=") ? arg.slice(arg.indexOf("=") + 1) : argv[++i];
|
|
77
|
-
if (next === undefined || next === "") throw new Error(`${flag} needs a value.`);
|
|
78
|
-
return next;
|
|
79
|
-
};
|
|
80
|
-
try {
|
|
81
|
-
if (arg === "-h" || arg === "--help") options.help = true;
|
|
82
|
-
else if (arg === "--dry-run") options.dryRun = true;
|
|
83
|
-
else if (arg === "--cloud") options.target = "cloud";
|
|
84
|
-
else if (arg === "--own-convex") options.target = "own-convex";
|
|
85
|
-
else if (arg === "--backend" || arg.startsWith("--backend=")) options.target = value("--backend");
|
|
86
|
-
else if (arg === "--name" || arg.startsWith("--name=")) options.name = value("--name");
|
|
87
|
-
else if (arg === "--review-url" || arg.startsWith("--review-url=")) options.reviewUrl = value("--review-url");
|
|
88
|
-
else if (arg === "--dir" || arg.startsWith("--dir=")) options.dir = value("--dir");
|
|
89
|
-
else if (arg === "--entry" || arg.startsWith("--entry=")) options.entry = value("--entry");
|
|
90
|
-
else if (arg === "--mount" || arg.startsWith("--mount=")) options.mount = value("--mount");
|
|
91
|
-
else if (arg === "--project-env-file" || arg.startsWith("--project-env-file=")) options.envFile = value("--project-env-file");
|
|
92
|
-
else if (arg === "--env-file" || arg.startsWith("--env-file=")) options.envFile = value("--env-file");
|
|
93
|
-
else if (arg === "--remote" || arg === "--browser") {
|
|
94
|
-
if (options.signIn !== null && options.signIn !== arg.slice(2)) throw new Error("Choose either --remote or --browser.");
|
|
95
|
-
options.signIn = arg.slice(2);
|
|
96
|
-
} else if (arg === "--new-project") options.newProject = true;
|
|
97
|
-
else if (arg === "--json") options.json = true;
|
|
98
|
-
else if (arg.startsWith("-")) return { error: `Unknown option ${arg}.` };
|
|
99
|
-
else positional.push(arg);
|
|
100
|
-
} catch (error) {
|
|
101
|
-
return { error: error.message };
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
options.command = positional[0] ?? null;
|
|
105
|
-
options.projectId = positional[1] ?? null;
|
|
106
|
-
if (options.help) return options;
|
|
107
|
-
if (!["init", "doctor", "mcp"].includes(options.command ?? "")) {
|
|
108
|
-
return { error: options.command === null ? "Missing command." : `Unknown command ${options.command}.` };
|
|
109
|
-
}
|
|
110
|
-
if (positional.length > (options.command === "init" ? 2 : 1)) return { error: `Unexpected argument ${positional.at(-1)}.` };
|
|
111
|
-
if (options.target !== null && options.target !== "cloud" && options.target !== "own-convex") {
|
|
112
|
-
try {
|
|
113
|
-
new URL(options.target);
|
|
114
|
-
} catch {
|
|
115
|
-
return { error: "--backend needs a URL such as https://<deployment>.convex.cloud." };
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return options;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** Asks questions on the terminal; hidden answers aren't echoed. */
|
|
122
|
-
function terminal() {
|
|
123
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout, terminal: true });
|
|
124
|
-
let muted = false;
|
|
125
|
-
const write = rl._writeToOutput?.bind(rl);
|
|
126
|
-
rl._writeToOutput = (text) => {
|
|
127
|
-
if (!muted || text.includes("\n")) write?.(muted ? "\n" : text);
|
|
128
|
-
};
|
|
129
|
-
return {
|
|
130
|
-
ask: (question, { hidden = false } = {}) =>
|
|
131
|
-
new Promise((answer) => {
|
|
132
|
-
rl.question(question, (text) => {
|
|
133
|
-
muted = false;
|
|
134
|
-
answer(text.trim());
|
|
135
|
-
});
|
|
136
|
-
muted = hidden;
|
|
137
|
-
}),
|
|
138
|
-
close: () => rl.close(),
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const SYMBOL = { pass: "✓", warn: "!", fail: "✗", info: "-", next: "→" };
|
|
143
|
-
|
|
144
|
-
/** In a workspace, asks which app to set up; null when the answer isn't one of them. */
|
|
145
|
-
async function chooseApp(io, apps, cwd) {
|
|
146
|
-
const names = apps.map((dir) => relative(cwd, dir) || ".");
|
|
147
|
-
const answer = await io.ask(`This is a workspace; each app gets its own Critiqs project. Which app?\n${names.map((name, index) => ` ${index + 1}. ${name}`).join("\n")}\nNumber: `);
|
|
148
|
-
const index = Number(answer) - 1;
|
|
149
|
-
return Number.isInteger(index) && index >= 0 && index < apps.length ? apps[index] : null;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async function runSetup(options, { cwd, print }) {
|
|
153
|
-
let root = resolve(cwd, options.dir);
|
|
154
|
-
// JSON goes to standard output alone; progress goes to standard error.
|
|
155
|
-
const say = options.json ? (message) => console.error(message) : print;
|
|
156
|
-
const interactive = process.stdin.isTTY === true && !options.json;
|
|
157
|
-
const io = interactive ? terminal() : null;
|
|
158
|
-
try {
|
|
159
|
-
// A person at a terminal picks the app; otherwise setup refuses with the exact --dir for each.
|
|
160
|
-
const apps = io === null ? null : workspaceApps(root);
|
|
161
|
-
if (apps !== null && apps.length > 0) {
|
|
162
|
-
const chosen = await chooseApp(io, apps, cwd);
|
|
163
|
-
if (chosen === null) throw new SetupError("No app was chosen, so nothing was changed. Run init again in the app's folder, or pass --dir <app folder>.");
|
|
164
|
-
root = chosen;
|
|
165
|
-
}
|
|
166
|
-
const target = options.target ?? "cloud";
|
|
167
|
-
const keys = {};
|
|
168
|
-
if (target === "own-convex") {
|
|
169
|
-
if (!process.env.CONVEX_DEPLOY_KEY && !process.env.CONVEX_SELF_HOSTED_ADMIN_KEY) {
|
|
170
|
-
if (io === null) throw new SetupError("Set CONVEX_DEPLOY_KEY to a production deploy key from your Convex project's settings.");
|
|
171
|
-
keys.convexDeployKey = await io.ask("Convex production deploy key (from your Convex project's settings): ", { hidden: true });
|
|
172
|
-
}
|
|
173
|
-
if (!process.env.RESEND_API_KEY && io !== null) {
|
|
174
|
-
const resendApiKey = await io.ask("Resend API key for mention emails (optional, Enter to skip): ", { hidden: true });
|
|
175
|
-
if (resendApiKey !== "") {
|
|
176
|
-
keys.resendApiKey = resendApiKey;
|
|
177
|
-
keys.emailFrom = process.env.CRITIQS_EMAIL_FROM ?? (await io.ask("Send mention emails from (such as Critiqs <critiqs@example.com>): "));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
const setup = await beginSetup({
|
|
182
|
-
root,
|
|
183
|
-
cwd,
|
|
184
|
-
// An explicit choice only; otherwise a project the code names is kept wherever it is.
|
|
185
|
-
target: options.target,
|
|
186
|
-
name: options.name ?? undefined,
|
|
187
|
-
reviewUrl: options.reviewUrl ?? undefined,
|
|
188
|
-
keys,
|
|
189
|
-
log: say,
|
|
190
|
-
entry: options.entry,
|
|
191
|
-
mount: options.mount,
|
|
192
|
-
newProject: options.newProject,
|
|
193
|
-
signIn: options.signIn ?? "auto",
|
|
194
|
-
envFile: options.envFile,
|
|
195
|
-
});
|
|
196
|
-
if (setup.connected) {
|
|
197
|
-
const where = setup.backendUrl === CLOUD_BACKEND_URL ? "Critiqs Cloud" : setup.backendUrl;
|
|
198
|
-
const from = setup.connected.env ? ` (${setup.connected.env.name} in ${relative(cwd, setup.connected.env.file) || setup.connected.env.file})` : "";
|
|
199
|
-
say(`The code already uses project ${setup.connected.projectId}${from} on ${where}, so nothing was created. Checking it…`);
|
|
200
|
-
const report = doctorReport(await doctor({ root, cwd, envFile: options.envFile }));
|
|
201
|
-
if (options.json) print(JSON.stringify({ ok: report.ok, connected: setup.connected, ...report }, null, 2));
|
|
202
|
-
else printChecks(report.checks, print);
|
|
203
|
-
say("Pass --new-project to replace it with a new project, or --review-url to set where mention emails link.");
|
|
204
|
-
return report.ok ? 0 : 1;
|
|
205
|
-
}
|
|
206
|
-
if (setup.method === "remote") {
|
|
207
|
-
say(
|
|
208
|
-
`\nApprove this setup from a browser on any device:\n 1. Open ${setup.url}\n 2. Enter the code ${setup.userCode}\n 3. Sign in with your email and choose Approve.\n` +
|
|
209
|
-
"The code works for 10 minutes. Waiting…",
|
|
210
|
-
);
|
|
211
|
-
} else {
|
|
212
|
-
say(`\nSign in to finish setup. Opening ${setup.url}\nIf no browser opens, open that address on this computer, or run again with --remote to approve from another device.`);
|
|
213
|
-
openBrowser(setup.url);
|
|
214
|
-
}
|
|
215
|
-
const result = await setup.finish();
|
|
216
|
-
if (result.approvedBy) say(`Approved by ${result.approvedBy.name} (${result.approvedBy.email}).`);
|
|
217
|
-
const stages = readiness(result);
|
|
218
|
-
if (options.json) {
|
|
219
|
-
const env = result.written.env ? { name: result.written.env.name, file: result.written.env.file } : null;
|
|
220
|
-
print(JSON.stringify({ ok: result.written.ok, projectId: result.projectId, projectName: result.projectName, backendUrl: result.backendUrl, reused: result.reused, env, stages }, null, 2));
|
|
221
|
-
} else {
|
|
222
|
-
print("");
|
|
223
|
-
printChecks(stages, print);
|
|
224
|
-
if (result.written.preview) print(result.written.preview.map((line) => ` ${line}`).join("\n"));
|
|
225
|
-
if (result.written.ok) print("\nRun critiqs doctor any time to check the setup.");
|
|
226
|
-
}
|
|
227
|
-
return result.written.ok ? 0 : 1;
|
|
228
|
-
} catch (error) {
|
|
229
|
-
if (!(error instanceof SetupError)) throw error;
|
|
230
|
-
if (options.json) print(JSON.stringify({ ok: false, error: error.message }, null, 2));
|
|
231
|
-
else print(error.message);
|
|
232
|
-
return 1;
|
|
233
|
-
} finally {
|
|
234
|
-
io?.close();
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function printChecks(checks, print) {
|
|
239
|
-
for (const check of checks) print(`${SYMBOL[check.status] ?? "-"} ${check.name}: ${check.detail}`);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
async function runDoctor(options, { cwd, print }) {
|
|
243
|
-
if (options.target === "cloud" || options.target === "own-convex") {
|
|
244
|
-
print(`doctor checks the backend the prototype names; use --backend <url> to check another.\n\n${USAGE}`);
|
|
245
|
-
return 2;
|
|
246
|
-
}
|
|
247
|
-
const report = doctorReport(await doctor({ root: resolve(cwd, options.dir), cwd, backendUrl: options.target ?? undefined, envFile: options.envFile }));
|
|
248
|
-
if (options.json) print(JSON.stringify(report, null, 2));
|
|
249
|
-
else {
|
|
250
|
-
printChecks(report.checks, print);
|
|
251
|
-
print(`\n${DOCTOR_NOTE}`);
|
|
252
|
-
}
|
|
253
|
-
return report.ok ? 0 : 1;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/** Runs the CLI; resolves to its exit code: 0 done, 1 not done, 2 usage error. */
|
|
257
|
-
export async function runCli(argv, { cwd = process.cwd(), print = console.log } = {}) {
|
|
258
|
-
const options = parseCommand(argv);
|
|
259
|
-
if ("error" in options) {
|
|
260
|
-
print(`${options.error}\n\n${USAGE}`);
|
|
261
|
-
return 2;
|
|
262
|
-
}
|
|
263
|
-
if (options.help) {
|
|
264
|
-
print(USAGE);
|
|
265
|
-
return 0;
|
|
266
|
-
}
|
|
267
|
-
if (options.command === "mcp") {
|
|
268
|
-
const { serveMcp } = await import("./mcp.mjs");
|
|
269
|
-
await serveMcp({ cwd });
|
|
270
|
-
return 0;
|
|
271
|
-
}
|
|
272
|
-
if (options.command === "doctor") return await runDoctor(options, { cwd, print });
|
|
273
|
-
if (options.projectId !== null) {
|
|
274
|
-
if (options.target !== null || options.name !== null || options.reviewUrl !== null || options.signIn !== null || options.newProject || options.json) {
|
|
275
|
-
print(`An existing project's ID is written as it is; --cloud, --own-convex, --backend, --name, --review-url, --remote, --browser, --new-project, and --json are for creating or connecting a project.\n\n${USAGE}`);
|
|
276
|
-
return 2;
|
|
277
|
-
}
|
|
278
|
-
return runInit(
|
|
279
|
-
[
|
|
280
|
-
"init",
|
|
281
|
-
options.projectId,
|
|
282
|
-
"--dir",
|
|
283
|
-
options.dir,
|
|
284
|
-
...(options.entry !== null ? ["--entry", options.entry] : []),
|
|
285
|
-
...(options.mount !== null ? ["--mount", options.mount] : []),
|
|
286
|
-
...(options.envFile !== null ? ["--project-env-file", options.envFile] : []),
|
|
287
|
-
...(options.dryRun ? ["--dry-run"] : []),
|
|
288
|
-
],
|
|
289
|
-
{ cwd, print },
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
return await runSetup(options, { cwd, print });
|
|
293
|
-
}
|
package/bin/env.d.mts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export type Framework = "next" | "vite";
|
|
2
|
-
export declare const FRAMEWORKS: Record<Framework, { name: string; access: "process.env" | "import.meta.env"; prefix: string }>;
|
|
3
|
-
export declare const ENV_FILES: string[];
|
|
4
|
-
|
|
5
|
-
export interface AppEnvironment {
|
|
6
|
-
root: string;
|
|
7
|
-
framework: Framework | null;
|
|
8
|
-
workspace: { root: string; name: string; label: string } | null;
|
|
9
|
-
projectName: string;
|
|
10
|
-
envDir: string;
|
|
11
|
-
envFile: string | null;
|
|
12
|
-
/** The app loads `.env` files from outside its own folder. */
|
|
13
|
-
sharedEnv: boolean;
|
|
14
|
-
variable: string | null;
|
|
15
|
-
access: "process.env" | "import.meta.env" | null;
|
|
16
|
-
customPrefix?: boolean;
|
|
17
|
-
problem: string | null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface EnvPlan {
|
|
21
|
-
name: string;
|
|
22
|
-
value: string;
|
|
23
|
-
file: string;
|
|
24
|
-
original: string | null;
|
|
25
|
-
source: string;
|
|
26
|
-
changed: boolean;
|
|
27
|
-
example: { file: string; original: string | null; source: string } | null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export declare function detectFramework(root: string): Framework | null;
|
|
31
|
-
export declare function workspacePatterns(dir: string): string[] | null;
|
|
32
|
-
export declare function workspaceMembers(workspaceRoot: string, patterns?: string[]): string[];
|
|
33
|
-
export declare function findWorkspace(root: string): { root: string; patterns: string[] } | null;
|
|
34
|
-
export declare function describeApp(root: string, options?: { envFile?: string | null }): AppEnvironment;
|
|
35
|
-
export declare function envVariableOf(text: string | undefined, app: AppEnvironment): string | null;
|
|
36
|
-
export declare function envFiles(app: AppEnvironment): string[];
|
|
37
|
-
export declare function readEnvValue(app: AppEnvironment, name: string): { value: string; file: string } | null;
|
|
38
|
-
export declare function planEnv(app: AppEnvironment, name: string, value: string): EnvPlan;
|
|
39
|
-
export declare function checkWritable(file: string): void;
|
|
40
|
-
export declare function applyEnv(plan: EnvPlan): { example: string | null };
|
|
41
|
-
export declare function gitIgnored(file: string): boolean | null;
|