convex 1.48.0 → 1.49.0-alpha.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/CHANGELOG.md +7 -0
- package/dist/browser.bundle.js +1 -1
- package/dist/browser.bundle.js.map +1 -1
- package/dist/cjs/bundler/context.js +7 -5
- package/dist/cjs/bundler/context.js.map +2 -2
- package/dist/cjs/bundler/fs.js +47 -6
- package/dist/cjs/bundler/fs.js.map +2 -2
- package/dist/cjs/cli/account.js +237 -0
- package/dist/cjs/cli/account.js.map +7 -0
- package/dist/cjs/cli/configure.js +15 -2
- package/dist/cjs/cli/configure.js.map +2 -2
- package/dist/cjs/cli/lib/accountManagement.js +196 -0
- package/dist/cjs/cli/lib/accountManagement.js.map +7 -0
- package/dist/cjs/cli/lib/accounts.js +334 -0
- package/dist/cjs/cli/lib/accounts.js.map +7 -0
- package/dist/cjs/cli/lib/deployKeyWarning.js +43 -0
- package/dist/cjs/cli/lib/deployKeyWarning.js.map +7 -0
- package/dist/cjs/cli/lib/deployment.js +2 -0
- package/dist/cjs/cli/lib/deployment.js.map +2 -2
- package/dist/cjs/cli/lib/deploymentSelection.js +27 -18
- package/dist/cjs/cli/lib/deploymentSelection.js.map +2 -2
- package/dist/cjs/cli/lib/envvars.js +32 -0
- package/dist/cjs/cli/lib/envvars.js.map +2 -2
- package/dist/cjs/cli/lib/fsUtils.js +1 -1
- package/dist/cjs/cli/lib/fsUtils.js.map +2 -2
- package/dist/cjs/cli/lib/generateDocs.js +1 -1
- package/dist/cjs/cli/lib/generateDocs.js.map +1 -1
- package/dist/cjs/cli/lib/login.js +42 -4
- package/dist/cjs/cli/lib/login.js.map +3 -3
- package/dist/cjs/cli/lib/mcp/requestContext.js +5 -1
- package/dist/cjs/cli/lib/mcp/requestContext.js.map +2 -2
- package/dist/cjs/cli/lib/plugins/claudeCode.js +188 -0
- package/dist/cjs/cli/lib/plugins/claudeCode.js.map +7 -0
- package/dist/cjs/cli/lib/plugins/codex.js +167 -0
- package/dist/cjs/cli/lib/plugins/codex.js.map +7 -0
- package/dist/cjs/cli/lib/plugins/harness.js +50 -0
- package/dist/cjs/cli/lib/plugins/harness.js.map +7 -0
- package/dist/cjs/cli/lib/plugins/marketplaces.js +76 -0
- package/dist/cjs/cli/lib/plugins/marketplaces.js.map +7 -0
- package/dist/cjs/cli/lib/plugins/skills.js +98 -0
- package/dist/cjs/cli/lib/plugins/skills.js.map +7 -0
- package/dist/cjs/cli/lib/plugins/utils.js +125 -0
- package/dist/cjs/cli/lib/plugins/utils.js.map +7 -0
- package/dist/cjs/cli/lib/utils/utils.js +18 -9
- package/dist/cjs/cli/lib/utils/utils.js.map +2 -2
- package/dist/cjs/cli/login.js +213 -114
- package/dist/cjs/cli/login.js.map +3 -3
- package/dist/cjs/cli/logout.js +113 -12
- package/dist/cjs/cli/logout.js.map +3 -3
- package/dist/cjs/cli/mcp.js +43 -10
- package/dist/cjs/cli/mcp.js.map +3 -3
- package/dist/cjs/cli/plugins.js +114 -0
- package/dist/cjs/cli/plugins.js.map +7 -0
- package/dist/cjs/cli/program.js +3 -1
- package/dist/cjs/cli/program.js.map +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server/impl/actions_impl.js.map +2 -2
- package/dist/cjs-types/bundler/context.d.ts +5 -0
- package/dist/cjs-types/bundler/context.d.ts.map +1 -1
- package/dist/cjs-types/bundler/fs.d.ts +7 -2
- package/dist/cjs-types/bundler/fs.d.ts.map +1 -1
- package/dist/cjs-types/cli/account.d.ts +6 -0
- package/dist/cjs-types/cli/account.d.ts.map +1 -0
- package/dist/cjs-types/cli/configure.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/accountManagement.d.ts +10 -0
- package/dist/cjs-types/cli/lib/accountManagement.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/accounts.d.ts +59 -0
- package/dist/cjs-types/cli/lib/accounts.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/deployKeyWarning.d.ts +3 -0
- package/dist/cjs-types/cli/lib/deployKeyWarning.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/deployment.d.ts +2 -0
- package/dist/cjs-types/cli/lib/deployment.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deploymentSelection.d.ts +2 -1
- package/dist/cjs-types/cli/lib/deploymentSelection.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/envvars.d.ts +6 -0
- package/dist/cjs-types/cli/lib/envvars.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/fsUtils.d.ts +1 -0
- package/dist/cjs-types/cli/lib/fsUtils.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/login.d.ts +3 -1
- package/dist/cjs-types/cli/lib/login.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/mcp/requestContext.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/mcp/tools/insights.d.ts +2 -2
- package/dist/cjs-types/cli/lib/plugins/claudeCode.d.ts +25 -0
- package/dist/cjs-types/cli/lib/plugins/claudeCode.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/plugins/codex.d.ts +25 -0
- package/dist/cjs-types/cli/lib/plugins/codex.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/plugins/harness.d.ts +33 -0
- package/dist/cjs-types/cli/lib/plugins/harness.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/plugins/marketplaces.d.ts +40 -0
- package/dist/cjs-types/cli/lib/plugins/marketplaces.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/plugins/skills.d.ts +18 -0
- package/dist/cjs-types/cli/lib/plugins/skills.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/plugins/utils.d.ts +21 -0
- package/dist/cjs-types/cli/lib/plugins/utils.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/utils/utils.d.ts +5 -0
- package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/cjs-types/cli/login.d.ts +21 -0
- package/dist/cjs-types/cli/login.d.ts.map +1 -1
- package/dist/cjs-types/cli/logout.d.ts +8 -1
- package/dist/cjs-types/cli/logout.d.ts.map +1 -1
- package/dist/cjs-types/cli/mcp.d.ts.map +1 -1
- package/dist/cjs-types/cli/plugins.d.ts +3 -0
- package/dist/cjs-types/cli/plugins.d.ts.map +1 -0
- package/dist/cjs-types/cli/program.d.ts.map +1 -1
- package/dist/cjs-types/index.d.ts +1 -1
- package/dist/cjs-types/index.d.ts.map +1 -1
- package/dist/cjs-types/server/impl/actions_impl.d.ts +3 -2
- package/dist/cjs-types/server/impl/actions_impl.d.ts.map +1 -1
- package/dist/cli.bundle.cjs +10059 -7094
- package/dist/cli.bundle.cjs.map +4 -4
- package/dist/esm/bundler/context.js +7 -5
- package/dist/esm/bundler/context.js.map +2 -2
- package/dist/esm/bundler/fs.js +47 -6
- package/dist/esm/bundler/fs.js.map +2 -2
- package/dist/esm/cli/account.js +221 -0
- package/dist/esm/cli/account.js.map +7 -0
- package/dist/esm/cli/configure.js +15 -2
- package/dist/esm/cli/configure.js.map +2 -2
- package/dist/esm/cli/lib/accountManagement.js +179 -0
- package/dist/esm/cli/lib/accountManagement.js.map +7 -0
- package/dist/esm/cli/lib/accounts.js +289 -0
- package/dist/esm/cli/lib/accounts.js.map +7 -0
- package/dist/esm/cli/lib/deployKeyWarning.js +27 -0
- package/dist/esm/cli/lib/deployKeyWarning.js.map +7 -0
- package/dist/esm/cli/lib/deployment.js +2 -2
- package/dist/esm/cli/lib/deployment.js.map +2 -2
- package/dist/esm/cli/lib/deploymentSelection.js +35 -20
- package/dist/esm/cli/lib/deploymentSelection.js.map +2 -2
- package/dist/esm/cli/lib/envvars.js +35 -1
- package/dist/esm/cli/lib/envvars.js.map +2 -2
- package/dist/esm/cli/lib/fsUtils.js +1 -1
- package/dist/esm/cli/lib/fsUtils.js.map +2 -2
- package/dist/esm/cli/lib/generateDocs.js +1 -1
- package/dist/esm/cli/lib/generateDocs.js.map +1 -1
- package/dist/esm/cli/lib/login.js +52 -4
- package/dist/esm/cli/lib/login.js.map +3 -3
- package/dist/esm/cli/lib/mcp/requestContext.js +5 -1
- package/dist/esm/cli/lib/mcp/requestContext.js.map +2 -2
- package/dist/esm/cli/lib/plugins/claudeCode.js +160 -0
- package/dist/esm/cli/lib/plugins/claudeCode.js.map +7 -0
- package/dist/esm/cli/lib/plugins/codex.js +140 -0
- package/dist/esm/cli/lib/plugins/codex.js.map +7 -0
- package/dist/esm/cli/lib/plugins/harness.js +17 -0
- package/dist/esm/cli/lib/plugins/harness.js.map +7 -0
- package/dist/esm/cli/lib/plugins/marketplaces.js +53 -0
- package/dist/esm/cli/lib/plugins/marketplaces.js.map +7 -0
- package/dist/esm/cli/lib/plugins/skills.js +65 -0
- package/dist/esm/cli/lib/plugins/skills.js.map +7 -0
- package/dist/esm/cli/lib/plugins/utils.js +86 -0
- package/dist/esm/cli/lib/plugins/utils.js.map +7 -0
- package/dist/esm/cli/lib/utils/utils.js +16 -9
- package/dist/esm/cli/lib/utils/utils.js.map +2 -2
- package/dist/esm/cli/login.js +225 -112
- package/dist/esm/cli/login.js.map +3 -3
- package/dist/esm/cli/logout.js +110 -13
- package/dist/esm/cli/logout.js.map +2 -2
- package/dist/esm/cli/mcp.js +34 -10
- package/dist/esm/cli/mcp.js.map +2 -2
- package/dist/esm/cli/plugins.js +99 -0
- package/dist/esm/cli/plugins.js.map +7 -0
- package/dist/esm/cli/program.js +3 -1
- package/dist/esm/cli/program.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/impl/actions_impl.js.map +2 -2
- package/dist/esm-types/bundler/context.d.ts +5 -0
- package/dist/esm-types/bundler/context.d.ts.map +1 -1
- package/dist/esm-types/bundler/fs.d.ts +7 -2
- package/dist/esm-types/bundler/fs.d.ts.map +1 -1
- package/dist/esm-types/cli/account.d.ts +6 -0
- package/dist/esm-types/cli/account.d.ts.map +1 -0
- package/dist/esm-types/cli/configure.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/accountManagement.d.ts +10 -0
- package/dist/esm-types/cli/lib/accountManagement.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/accounts.d.ts +59 -0
- package/dist/esm-types/cli/lib/accounts.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/deployKeyWarning.d.ts +3 -0
- package/dist/esm-types/cli/lib/deployKeyWarning.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/deployment.d.ts +2 -0
- package/dist/esm-types/cli/lib/deployment.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deploymentSelection.d.ts +2 -1
- package/dist/esm-types/cli/lib/deploymentSelection.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/envvars.d.ts +6 -0
- package/dist/esm-types/cli/lib/envvars.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/fsUtils.d.ts +1 -0
- package/dist/esm-types/cli/lib/fsUtils.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/login.d.ts +3 -1
- package/dist/esm-types/cli/lib/login.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/mcp/requestContext.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/mcp/tools/insights.d.ts +2 -2
- package/dist/esm-types/cli/lib/plugins/claudeCode.d.ts +25 -0
- package/dist/esm-types/cli/lib/plugins/claudeCode.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/plugins/codex.d.ts +25 -0
- package/dist/esm-types/cli/lib/plugins/codex.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/plugins/harness.d.ts +33 -0
- package/dist/esm-types/cli/lib/plugins/harness.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/plugins/marketplaces.d.ts +40 -0
- package/dist/esm-types/cli/lib/plugins/marketplaces.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/plugins/skills.d.ts +18 -0
- package/dist/esm-types/cli/lib/plugins/skills.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/plugins/utils.d.ts +21 -0
- package/dist/esm-types/cli/lib/plugins/utils.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/utils/utils.d.ts +5 -0
- package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/esm-types/cli/login.d.ts +21 -0
- package/dist/esm-types/cli/login.d.ts.map +1 -1
- package/dist/esm-types/cli/logout.d.ts +8 -1
- package/dist/esm-types/cli/logout.d.ts.map +1 -1
- package/dist/esm-types/cli/mcp.d.ts.map +1 -1
- package/dist/esm-types/cli/plugins.d.ts +3 -0
- package/dist/esm-types/cli/plugins.d.ts.map +1 -0
- package/dist/esm-types/cli/program.d.ts.map +1 -1
- package/dist/esm-types/index.d.ts +1 -1
- package/dist/esm-types/index.d.ts.map +1 -1
- package/dist/esm-types/server/impl/actions_impl.d.ts +3 -2
- package/dist/esm-types/server/impl/actions_impl.d.ts.map +1 -1
- package/dist/react.bundle.js +1 -1
- package/dist/react.bundle.js.map +1 -1
- package/package.json +2 -2
- package/src/bundler/context.ts +9 -5
- package/src/bundler/fs.ts +54 -5
- package/src/cli/account.ts +320 -0
- package/src/cli/configure.ts +18 -2
- package/src/cli/lib/accountManagement.ts +262 -0
- package/src/cli/lib/accounts.ts +400 -0
- package/src/cli/lib/deployKeyWarning.ts +43 -0
- package/src/cli/lib/deployment.ts +2 -2
- package/src/cli/lib/deploymentSelection.ts +37 -18
- package/src/cli/lib/envvars.ts +43 -1
- package/src/cli/lib/fsUtils.ts +5 -2
- package/src/cli/lib/generateDocs.ts +1 -1
- package/src/cli/lib/login.ts +64 -3
- package/src/cli/lib/mcp/requestContext.ts +7 -1
- package/src/cli/lib/plugins/claudeCode.ts +201 -0
- package/src/cli/lib/plugins/codex.ts +177 -0
- package/src/cli/lib/plugins/harness.ts +49 -0
- package/src/cli/lib/plugins/marketplaces.ts +94 -0
- package/src/cli/lib/plugins/skills.ts +101 -0
- package/src/cli/lib/plugins/utils.ts +121 -0
- package/src/cli/lib/utils/utils.ts +19 -15
- package/src/cli/login.ts +293 -168
- package/src/cli/logout.ts +142 -17
- package/src/cli/mcp.ts +48 -11
- package/src/cli/plugins.ts +154 -0
- package/src/cli/program.ts +4 -0
- package/src/index.ts +1 -1
- package/src/server/impl/actions_impl.ts +3 -2
|
@@ -86,11 +86,13 @@ export const oneoffContext = async (args) => {
|
|
|
86
86
|
ctx,
|
|
87
87
|
!!process.env.CONVEX_IGNORE_SUSPICIOUS_ENV_VARS
|
|
88
88
|
);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
if (!args.skipAuth) {
|
|
90
|
+
await initializeBigBrainAuth(ctx, {
|
|
91
|
+
url: args.url,
|
|
92
|
+
adminKey: args.adminKey,
|
|
93
|
+
envFile: args.envFile
|
|
94
|
+
});
|
|
95
|
+
}
|
|
94
96
|
return ctx;
|
|
95
97
|
};
|
|
96
98
|
//# sourceMappingURL=context.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/bundler/context.ts"],
|
|
4
|
-
"sourcesContent": ["import * as Sentry from \"@sentry/node\";\nimport { Ora } from \"ora\";\nimport { Filesystem, nodeFs } from \"./fs.js\";\nimport { initializeBigBrainAuth } from \"../cli/lib/deploymentSelection.js\";\nimport { detectSuspiciousEnvironmentVariables } from \"../cli/lib/envvars.js\";\nimport { logFailure, logVerbose } from \"./log.js\";\n// How the error should be handled when running `npx convex dev`.\nexport type ErrorType =\n // The error was likely caused by the state of the developer's local\n // file system (e.g. `tsc` fails due to a syntax error). The `convex dev`\n // command will then print out the error and wait for the file to change before\n // retrying.\n | \"invalid filesystem data\"\n // The error was caused by either the local state (ie schema.ts content)\n // or the state of the db (ie documents not matching the new schema).\n // The `convex dev` command will wait for either file OR table data change\n // to retry (if a table name is specified as the value in this Object).\n | {\n \"invalid filesystem or db data\": {\n tableName: string;\n componentPath?: string;\n } | null;\n }\n // The error was caused by either the local state (ie schema.ts content)\n // or the state of the deployment environment variables.\n // The `convex dev` command will wait for either file OR env var change\n // before retrying.\n | \"invalid filesystem or env vars\"\n // The error was some transient issue (e.g. a network\n // error). This will then cause a retry after an exponential backoff.\n | \"transient\"\n // This error was caught, handled, and now all that needs to happen\n // is for the proces to restart. No error is logged or reported.\n | \"already handled\"\n // This error is truly permanent. Exit `npx convex dev` because the\n // developer will need to take a manual commandline action.\n | \"fatal\";\n\nexport type BigBrainAuth = {\n header: string;\n} & (\n | {\n kind: \"projectKey\";\n projectKey: string;\n }\n | {\n kind: \"deploymentKey\";\n deploymentKey: string;\n }\n | {\n kind: \"previewDeployKey\";\n previewDeployKey: string;\n }\n | {\n kind: \"accessToken\";\n accessToken: string;\n }\n);\n\nexport interface Context {\n fs: Filesystem;\n deprecationMessagePrinted: boolean;\n // Reports to Sentry and either throws FatalError or exits the process.\n // Prints the `printedMessage` if provided\n crash(args: {\n exitCode: number;\n errorType: ErrorType;\n errForSentry?: any;\n printedMessage: string | null;\n }): Promise<never>;\n registerCleanup(fn: (exitCode: number, err?: any) => Promise<void>): string;\n removeCleanup(\n handle: string,\n ): (exitCode: number, err?: any) => Promise<void> | null;\n bigBrainAuth(): BigBrainAuth | null;\n /**\n * Prefer using `updateBigBrainAuthAfterLogin` in `deploymentSelection.ts` instead\n */\n _updateBigBrainAuth(auth: BigBrainAuth | null): void;\n}\n\nasync function flushAndExit(exitCode: number, err?: any) {\n if (err) {\n Sentry.captureException(err);\n }\n await Sentry.close();\n return process.exit(exitCode);\n}\n\nexport type OneoffCtx = Context & {\n // Generally `ctx.crash` is better to use since it handles printing a message\n // for the user, and then calls this.\n //\n // This function reports to Sentry + exits the process, but does not handle\n // printing a message for the user.\n flushAndExit: (exitCode: number, err?: any) => Promise<never>;\n};\n\nclass OneoffContextImpl {\n private _cleanupFns: Record<\n string,\n (exitCode: number, err?: any) => Promise<void>\n > = {};\n public fs: Filesystem = nodeFs;\n public deprecationMessagePrinted: boolean = false;\n public spinner: Ora | undefined = undefined;\n private _bigBrainAuth: BigBrainAuth | null = null;\n\n crash = async (args: {\n exitCode: number;\n errorType?: ErrorType;\n errForSentry?: any;\n printedMessage: string | null;\n }) => {\n if (args.printedMessage !== null) {\n logFailure(args.printedMessage);\n }\n return await this.flushAndExit(args.exitCode, args.errForSentry);\n };\n flushAndExit = async (exitCode: number, err?: any) => {\n logVerbose(\"Flushing and exiting, error:\", err);\n if (err) {\n logVerbose(err.stack);\n }\n const cleanupFns = this._cleanupFns;\n // Clear the cleanup functions so that there's no risk of running them twice\n // if this somehow gets triggered twice.\n this._cleanupFns = {};\n const fns = Object.values(cleanupFns);\n logVerbose(`Running ${fns.length} cleanup functions`);\n for (const fn of fns) {\n await fn(exitCode, err);\n }\n logVerbose(\"All cleanup functions ran\");\n return flushAndExit(exitCode, err);\n };\n registerCleanup(fn: (exitCode: number, err?: any) => Promise<void>) {\n const handle = Math.random().toString(36).slice(2);\n this._cleanupFns[handle] = fn;\n return handle;\n }\n removeCleanup(handle: string) {\n const value = this._cleanupFns[handle];\n delete this._cleanupFns[handle];\n return value ?? null;\n }\n bigBrainAuth(): BigBrainAuth | null {\n return this._bigBrainAuth;\n }\n _updateBigBrainAuth(auth: BigBrainAuth | null): void {\n logVerbose(`Updating big brain auth to ${auth?.kind ?? \"null\"}`);\n this._bigBrainAuth = auth;\n }\n}\n\n/**\n * Install a SIGINT handler that gracefully exits via ctx.flushAndExit.\n *\n * `bun run` and `npm run` can deliver a duplicate SIGINT to the child\n * process immediately while the first handler is still starting cleanup:\n * bun: https://github.com/oven-sh/bun/issues/14799\n * https://github.com/oven-sh/bun/issues/11400\n * npm: https://github.com/npm/cli/issues/5021\n * https://github.com/npm/cli/issues/8164\n * https://github.com/npm/cli/issues/7693\n * We ignore a second signal within 500ms of the first to avoid\n * double-cleanup, but treat a later Ctrl+C as a force-exit escape hatch.\n */\nexport function installSigintHandler(ctx: OneoffCtx) {\n const DUPLICATE_GRACE_MS = 500;\n let cleanupStartTime: number | null = null;\n process.on(\"SIGINT\", async () => {\n if (cleanupStartTime !== null) {\n if (Date.now() - cleanupStartTime < DUPLICATE_GRACE_MS) {\n logVerbose(\n \"Received SIGINT during cleanup, ignoring duplicate signal...\",\n );\n return;\n }\n logVerbose(\"Received SIGINT during cleanup, exiting immediately...\");\n process.exit(130);\n }\n cleanupStartTime = Date.now();\n logVerbose(\"Received SIGINT, cleaning up...\");\n await ctx.flushAndExit(130);\n });\n}\n\nexport const oneoffContext: (args: {\n url?: string | undefined;\n adminKey?: string | undefined;\n envFile?: string | undefined;\n}) => Promise<OneoffCtx> = async (args) => {\n const ctx = new OneoffContextImpl();\n await detectSuspiciousEnvironmentVariables(\n ctx,\n !!process.env.CONVEX_IGNORE_SUSPICIOUS_ENV_VARS,\n );\n await initializeBigBrainAuth(ctx, {\n
|
|
5
|
-
"mappings": ";;;;AAAA,YAAY,YAAY;AAExB,SAAqB,cAAc;AACnC,SAAS,8BAA8B;AACvC,SAAS,4CAA4C;AACrD,SAAS,YAAY,kBAAkB;
|
|
4
|
+
"sourcesContent": ["import * as Sentry from \"@sentry/node\";\nimport { Ora } from \"ora\";\nimport { Filesystem, nodeFs } from \"./fs.js\";\nimport { initializeBigBrainAuth } from \"../cli/lib/deploymentSelection.js\";\nimport { detectSuspiciousEnvironmentVariables } from \"../cli/lib/envvars.js\";\nimport { logFailure, logVerbose } from \"./log.js\";\n// How the error should be handled when running `npx convex dev`.\nexport type ErrorType =\n // The error was likely caused by the state of the developer's local\n // file system (e.g. `tsc` fails due to a syntax error). The `convex dev`\n // command will then print out the error and wait for the file to change before\n // retrying.\n | \"invalid filesystem data\"\n // The error was caused by either the local state (ie schema.ts content)\n // or the state of the db (ie documents not matching the new schema).\n // The `convex dev` command will wait for either file OR table data change\n // to retry (if a table name is specified as the value in this Object).\n | {\n \"invalid filesystem or db data\": {\n tableName: string;\n componentPath?: string;\n } | null;\n }\n // The error was caused by either the local state (ie schema.ts content)\n // or the state of the deployment environment variables.\n // The `convex dev` command will wait for either file OR env var change\n // before retrying.\n | \"invalid filesystem or env vars\"\n // The error was some transient issue (e.g. a network\n // error). This will then cause a retry after an exponential backoff.\n | \"transient\"\n // This error was caught, handled, and now all that needs to happen\n // is for the proces to restart. No error is logged or reported.\n | \"already handled\"\n // This error is truly permanent. Exit `npx convex dev` because the\n // developer will need to take a manual commandline action.\n | \"fatal\";\n\nexport type BigBrainAuth = {\n header: string;\n} & (\n | {\n kind: \"projectKey\";\n projectKey: string;\n }\n | {\n kind: \"deploymentKey\";\n deploymentKey: string;\n }\n | {\n kind: \"previewDeployKey\";\n previewDeployKey: string;\n }\n | {\n kind: \"accessToken\";\n accessToken: string;\n account?: { name: string; source: string } | null;\n }\n);\n\nexport interface Context {\n fs: Filesystem;\n deprecationMessagePrinted: boolean;\n // Reports to Sentry and either throws FatalError or exits the process.\n // Prints the `printedMessage` if provided\n crash(args: {\n exitCode: number;\n errorType: ErrorType;\n errForSentry?: any;\n printedMessage: string | null;\n }): Promise<never>;\n registerCleanup(fn: (exitCode: number, err?: any) => Promise<void>): string;\n removeCleanup(\n handle: string,\n ): (exitCode: number, err?: any) => Promise<void> | null;\n bigBrainAuth(): BigBrainAuth | null;\n /**\n * Prefer using `updateBigBrainAuthAfterLogin` in `deploymentSelection.ts` instead\n */\n _updateBigBrainAuth(auth: BigBrainAuth | null): void;\n}\n\nasync function flushAndExit(exitCode: number, err?: any) {\n if (err) {\n Sentry.captureException(err);\n }\n await Sentry.close();\n return process.exit(exitCode);\n}\n\nexport type OneoffCtx = Context & {\n // Generally `ctx.crash` is better to use since it handles printing a message\n // for the user, and then calls this.\n //\n // This function reports to Sentry + exits the process, but does not handle\n // printing a message for the user.\n flushAndExit: (exitCode: number, err?: any) => Promise<never>;\n};\n\nclass OneoffContextImpl {\n private _cleanupFns: Record<\n string,\n (exitCode: number, err?: any) => Promise<void>\n > = {};\n public fs: Filesystem = nodeFs;\n public deprecationMessagePrinted: boolean = false;\n public spinner: Ora | undefined = undefined;\n private _bigBrainAuth: BigBrainAuth | null = null;\n\n crash = async (args: {\n exitCode: number;\n errorType?: ErrorType;\n errForSentry?: any;\n printedMessage: string | null;\n }) => {\n if (args.printedMessage !== null) {\n logFailure(args.printedMessage);\n }\n return await this.flushAndExit(args.exitCode, args.errForSentry);\n };\n flushAndExit = async (exitCode: number, err?: any) => {\n logVerbose(\"Flushing and exiting, error:\", err);\n if (err) {\n logVerbose(err.stack);\n }\n const cleanupFns = this._cleanupFns;\n // Clear the cleanup functions so that there's no risk of running them twice\n // if this somehow gets triggered twice.\n this._cleanupFns = {};\n const fns = Object.values(cleanupFns);\n logVerbose(`Running ${fns.length} cleanup functions`);\n for (const fn of fns) {\n await fn(exitCode, err);\n }\n logVerbose(\"All cleanup functions ran\");\n return flushAndExit(exitCode, err);\n };\n registerCleanup(fn: (exitCode: number, err?: any) => Promise<void>) {\n const handle = Math.random().toString(36).slice(2);\n this._cleanupFns[handle] = fn;\n return handle;\n }\n removeCleanup(handle: string) {\n const value = this._cleanupFns[handle];\n delete this._cleanupFns[handle];\n return value ?? null;\n }\n bigBrainAuth(): BigBrainAuth | null {\n return this._bigBrainAuth;\n }\n _updateBigBrainAuth(auth: BigBrainAuth | null): void {\n logVerbose(`Updating big brain auth to ${auth?.kind ?? \"null\"}`);\n this._bigBrainAuth = auth;\n }\n}\n\n/**\n * Install a SIGINT handler that gracefully exits via ctx.flushAndExit.\n *\n * `bun run` and `npm run` can deliver a duplicate SIGINT to the child\n * process immediately while the first handler is still starting cleanup:\n * bun: https://github.com/oven-sh/bun/issues/14799\n * https://github.com/oven-sh/bun/issues/11400\n * npm: https://github.com/npm/cli/issues/5021\n * https://github.com/npm/cli/issues/8164\n * https://github.com/npm/cli/issues/7693\n * We ignore a second signal within 500ms of the first to avoid\n * double-cleanup, but treat a later Ctrl+C as a force-exit escape hatch.\n */\nexport function installSigintHandler(ctx: OneoffCtx) {\n const DUPLICATE_GRACE_MS = 500;\n let cleanupStartTime: number | null = null;\n process.on(\"SIGINT\", async () => {\n if (cleanupStartTime !== null) {\n if (Date.now() - cleanupStartTime < DUPLICATE_GRACE_MS) {\n logVerbose(\n \"Received SIGINT during cleanup, ignoring duplicate signal...\",\n );\n return;\n }\n logVerbose(\"Received SIGINT during cleanup, exiting immediately...\");\n process.exit(130);\n }\n cleanupStartTime = Date.now();\n logVerbose(\"Received SIGINT, cleaning up...\");\n await ctx.flushAndExit(130);\n });\n}\n\nexport const oneoffContext: (args: {\n url?: string | undefined;\n adminKey?: string | undefined;\n envFile?: string | undefined;\n skipAuth?: boolean;\n}) => Promise<OneoffCtx> = async (args) => {\n const ctx = new OneoffContextImpl();\n await detectSuspiciousEnvironmentVariables(\n ctx,\n !!process.env.CONVEX_IGNORE_SUSPICIOUS_ENV_VARS,\n );\n if (!args.skipAuth) {\n await initializeBigBrainAuth(ctx, {\n url: args.url,\n adminKey: args.adminKey,\n envFile: args.envFile,\n });\n }\n return ctx;\n};\n"],
|
|
5
|
+
"mappings": ";;;;AAAA,YAAY,YAAY;AAExB,SAAqB,cAAc;AACnC,SAAS,8BAA8B;AACvC,SAAS,4CAA4C;AACrD,SAAS,YAAY,kBAAkB;AA6EvC,eAAe,aAAa,UAAkB,KAAW;AACvD,MAAI,KAAK;AACP,WAAO,iBAAiB,GAAG;AAAA,EAC7B;AACA,QAAM,OAAO,MAAM;AACnB,SAAO,QAAQ,KAAK,QAAQ;AAC9B;AAWA,MAAM,kBAAkB;AAAA,EAAxB;AACE,wBAAQ,eAGJ,CAAC;AACL,wBAAO,MAAiB;AACxB,wBAAO,6BAAqC;AAC5C,wBAAO;AACP,wBAAQ,iBAAqC;AAE7C,iCAAQ,OAAO,SAKT;AACJ,UAAI,KAAK,mBAAmB,MAAM;AAChC,mBAAW,KAAK,cAAc;AAAA,MAChC;AACA,aAAO,MAAM,KAAK,aAAa,KAAK,UAAU,KAAK,YAAY;AAAA,IACjE;AACA,wCAAe,OAAO,UAAkB,QAAc;AACpD,iBAAW,gCAAgC,GAAG;AAC9C,UAAI,KAAK;AACP,mBAAW,IAAI,KAAK;AAAA,MACtB;AAC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AAClB,UAAM,uBAAuB,KAAK;AAAA,MAChC,KAAK,KAAK;AAAA,MACV,UAAU,KAAK;AAAA,MACf,SAAS,KAAK;AAAA,IAChB,CAAC;AAAA,EACH;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/bundler/fs.js
CHANGED
|
@@ -80,6 +80,9 @@ export class NodeFs {
|
|
|
80
80
|
stat(path2) {
|
|
81
81
|
return stdFs.statSync(path2);
|
|
82
82
|
}
|
|
83
|
+
lstat(path2) {
|
|
84
|
+
return stdFs.lstatSync(path2);
|
|
85
|
+
}
|
|
83
86
|
readUtf8File(path2) {
|
|
84
87
|
return stdFs.readFileSync(path2, { encoding: "utf-8" });
|
|
85
88
|
}
|
|
@@ -160,6 +163,8 @@ export class RecordingFs {
|
|
|
160
163
|
__publicField(this, "observedDirectories", /* @__PURE__ */ new Map());
|
|
161
164
|
// Absolute path -> observed stat (or null if observed nonexistent)
|
|
162
165
|
__publicField(this, "observedFiles", /* @__PURE__ */ new Map());
|
|
166
|
+
// lstat observes the link itself, while stat observes its target.
|
|
167
|
+
__publicField(this, "observedLstats", /* @__PURE__ */ new Map());
|
|
163
168
|
// Have we noticed that files have changed while recording?
|
|
164
169
|
__publicField(this, "invalidated", false);
|
|
165
170
|
__publicField(this, "traceEvents");
|
|
@@ -192,6 +197,19 @@ export class RecordingFs {
|
|
|
192
197
|
this.observedDirectories.set(absDirPath, observedNames);
|
|
193
198
|
return entries;
|
|
194
199
|
}
|
|
200
|
+
lstat(filePath) {
|
|
201
|
+
const absPath = path.resolve(filePath);
|
|
202
|
+
try {
|
|
203
|
+
const st = nodeFs.lstat(filePath);
|
|
204
|
+
this.registerNormalized(absPath, st, this.observedLstats);
|
|
205
|
+
return st;
|
|
206
|
+
} catch (err) {
|
|
207
|
+
if (err.code === "ENOENT") {
|
|
208
|
+
this.registerNormalized(absPath, null, this.observedLstats);
|
|
209
|
+
}
|
|
210
|
+
throw err;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
195
213
|
exists(path2) {
|
|
196
214
|
try {
|
|
197
215
|
const st = nodeFs.stat(path2);
|
|
@@ -290,6 +308,8 @@ export class RecordingFs {
|
|
|
290
308
|
updateOnWrite(absPath) {
|
|
291
309
|
const newSt = nodeFs.stat(absPath);
|
|
292
310
|
this.observedFiles.set(absPath, newSt);
|
|
311
|
+
if (this.observedLstats.has(absPath))
|
|
312
|
+
this.observedLstats.set(absPath, nodeFs.lstat(absPath));
|
|
293
313
|
const parentPath = path.resolve(path.dirname(absPath));
|
|
294
314
|
const observedParent = this.observedDirectories.get(parentPath);
|
|
295
315
|
if (observedParent !== void 0) {
|
|
@@ -298,6 +318,8 @@ export class RecordingFs {
|
|
|
298
318
|
}
|
|
299
319
|
updateOnDelete(absPath) {
|
|
300
320
|
this.observedFiles.set(absPath, null);
|
|
321
|
+
if (this.observedLstats.has(absPath))
|
|
322
|
+
this.observedLstats.set(absPath, null);
|
|
301
323
|
const parentPath = path.resolve(path.dirname(absPath));
|
|
302
324
|
const observedParent = this.observedDirectories.get(parentPath);
|
|
303
325
|
if (observedParent !== void 0) {
|
|
@@ -311,8 +333,8 @@ export class RecordingFs {
|
|
|
311
333
|
invalidate() {
|
|
312
334
|
this.invalidated = true;
|
|
313
335
|
}
|
|
314
|
-
registerNormalized(absPath, observed) {
|
|
315
|
-
const existing =
|
|
336
|
+
registerNormalized(absPath, observed, observations = this.observedFiles) {
|
|
337
|
+
const existing = observations.get(absPath);
|
|
316
338
|
if (existing !== void 0) {
|
|
317
339
|
const stMatch = stMatches(observed, existing);
|
|
318
340
|
if (!stMatch.matches) {
|
|
@@ -328,17 +350,22 @@ export class RecordingFs {
|
|
|
328
350
|
this.invalidated = true;
|
|
329
351
|
}
|
|
330
352
|
}
|
|
331
|
-
|
|
353
|
+
observations.set(absPath, observed);
|
|
332
354
|
}
|
|
333
355
|
finalize() {
|
|
334
356
|
if (this.invalidated) {
|
|
335
357
|
return "invalidated";
|
|
336
358
|
}
|
|
337
|
-
return new Observations(
|
|
359
|
+
return new Observations(
|
|
360
|
+
this.observedDirectories,
|
|
361
|
+
this.observedFiles,
|
|
362
|
+
this.observedLstats
|
|
363
|
+
);
|
|
338
364
|
}
|
|
339
365
|
}
|
|
340
366
|
export class Observations {
|
|
341
|
-
constructor(directories, files) {
|
|
367
|
+
constructor(directories, files, lstats = /* @__PURE__ */ new Map()) {
|
|
368
|
+
this.lstats = lstats;
|
|
342
369
|
__publicField(this, "directories");
|
|
343
370
|
__publicField(this, "files");
|
|
344
371
|
this.directories = directories;
|
|
@@ -352,7 +379,8 @@ export class Observations {
|
|
|
352
379
|
for (const path2 of this.files.keys()) {
|
|
353
380
|
out.push(path2);
|
|
354
381
|
}
|
|
355
|
-
|
|
382
|
+
for (const path2 of this.lstats.keys()) out.push(path2);
|
|
383
|
+
return [...new Set(out)];
|
|
356
384
|
}
|
|
357
385
|
overlaps({
|
|
358
386
|
absPath
|
|
@@ -375,6 +403,19 @@ export class Observations {
|
|
|
375
403
|
return { overlaps: true, reason };
|
|
376
404
|
}
|
|
377
405
|
}
|
|
406
|
+
const observedLstat = this.lstats.get(absPath);
|
|
407
|
+
if (observedLstat !== void 0) {
|
|
408
|
+
let currentLstat;
|
|
409
|
+
try {
|
|
410
|
+
currentLstat = nodeFs.lstat(absPath);
|
|
411
|
+
} catch (err) {
|
|
412
|
+
if (err.code !== "ENOENT") throw err;
|
|
413
|
+
currentLstat = null;
|
|
414
|
+
}
|
|
415
|
+
const match = stMatches(observedLstat, currentLstat);
|
|
416
|
+
if (!match.matches)
|
|
417
|
+
return { overlaps: true, reason: `modified (${match.reason})` };
|
|
418
|
+
}
|
|
378
419
|
const parentPath = path.resolve(path.dirname(absPath));
|
|
379
420
|
const observedParent = this.directories.get(parentPath);
|
|
380
421
|
if (observedParent !== void 0) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/bundler/fs.ts"],
|
|
4
|
-
"sourcesContent": ["// Disable our restriction on `throw` because these aren't developer-facing\n// error messages.\n/* eslint-disable no-restricted-imports */\n/* eslint-disable no-restricted-syntax */\nimport { chalkStderr } from \"chalk\";\nimport stdFs, { Dirent, Mode, ReadStream, Stats } from \"fs\";\nimport * as fsPromises from \"fs/promises\";\nimport os from \"os\";\nimport path from \"path\";\nimport crypto from \"crypto\";\nimport { Readable } from \"stream\";\n\nexport type NormalizedPath = string;\n\nconst tmpDirOverrideVar = \"CONVEX_TMPDIR\";\nfunction tmpDirPath() {\n // Allow users to override the temporary directory path with an environment variable.\n // This override needs to (1) be project-specific, since the user may have projects\n // on different filesystems, but also (2) be device-specific and not checked in, since\n // it's dependent on where the user has checked out their project. So, we don't want\n // this state in the project-specific `convex.json`, which is shared across all\n // devices, or in the top-level `~/.convex` directory, which is shared across all\n // projects on the local machine.\n //\n // Therefore, just let advanced users configure this behavior with an environment\n // variable that they're responsible for managing themselves for now.\n const envTmpDir = process.env[tmpDirOverrideVar];\n return envTmpDir ?? os.tmpdir();\n}\nconst tmpDirRoot = tmpDirPath();\n\nlet warned = false;\nfunction warnCrossFilesystem(dstPath: string) {\n const dstDir = path.dirname(dstPath);\n if (!warned) {\n // It's hard for these to use `logMessage` without creating a circular dependency, so just log directly.\n // eslint-disable-next-line no-console\n console.warn(\n chalkStderr.yellow(\n `Temporary directory '${tmpDirRoot}' and project directory '${dstDir}' are on different filesystems.`,\n ),\n );\n // eslint-disable-next-line no-console\n console.warn(\n chalkStderr.gray(\n ` If you're running into errors with other tools watching the project directory, override the temporary directory location with the ${chalkStderr.bold(\n tmpDirOverrideVar,\n )} environment variable.`,\n ),\n );\n // eslint-disable-next-line no-console\n console.warn(\n chalkStderr.gray(\n ` Be sure to pick a temporary directory that's on the same filesystem as your project.`,\n ),\n );\n warned = true;\n }\n}\n\nexport interface Filesystem {\n listDir(dirPath: string): Dirent[];\n\n exists(path: string): boolean;\n stat(path: string): Stats;\n readUtf8File(path: string): string;\n // createReadStream returns a stream for which [Symbol.asyncIterator]\n // yields chunks of size highWaterMark (until the last one), or 64KB if\n // highWaterMark isn't specified.\n // https://nodejs.org/api/stream.html#readablesymbolasynciterator\n createReadStream(\n path: string,\n options: { highWaterMark?: number },\n ): ReadStream;\n access(path: string): void;\n\n writeUtf8File(path: string, contents: string, mode?: Mode): void;\n mkdir(\n dirPath: string,\n options?: { allowExisting?: boolean; recursive?: boolean },\n ): void;\n rmdir(path: string): void;\n unlink(path: string): void;\n swapTmpFile(fromPath: TempPath, toPath: string): void;\n\n registerPath(path: string, st: Stats | null): void;\n invalidate(): void;\n}\n\nexport type TempPath = string & { __tempPath: \"tempPath\" };\n\nexport interface TempDir {\n writeUtf8File(contents: string): TempPath;\n writeFileStream(\n path: TempPath,\n stream: Readable,\n onData?: (chunk: any) => void,\n ): Promise<void>;\n registerTempPath(st: Stats | null): TempPath;\n path: TempPath;\n}\n\nexport async function withTmpDir(\n callback: (tmpDir: TempDir) => Promise<void>,\n): Promise<void> {\n // Create temporary directories inside `tmpDirRoot` of the form `convex-<random>`.\n const tmpPath = stdFs.mkdtempSync(path.join(tmpDirRoot, \"convex\"));\n const tmpDir = {\n writeUtf8File(contents: string): TempPath {\n const filePath = path.join(tmpPath, crypto.randomUUID());\n nodeFs.writeUtf8File(filePath, contents);\n return filePath as TempPath;\n },\n registerTempPath(st: Stats | null): TempPath {\n const filePath = path.join(tmpPath, crypto.randomUUID());\n nodeFs.registerPath(filePath, st);\n return filePath as TempPath;\n },\n writeFileStream(\n path: TempPath,\n stream: Readable,\n onData?: (chunk: any) => void,\n ): Promise<void> {\n return nodeFs.writeFileStream(path, stream, onData);\n },\n path: tmpPath as TempPath,\n };\n try {\n await callback(tmpDir);\n } finally {\n stdFs.rmSync(tmpPath, { force: true, recursive: true });\n }\n}\n\n// Use `nodeFs` when you just want to read and write to the local filesystem\n// and don't care about collecting the paths touched. One-off commands\n// should use the singleton `nodeFs`.\nexport class NodeFs implements Filesystem {\n listDir(dirPath: string) {\n return stdFs.readdirSync(dirPath, { withFileTypes: true });\n }\n exists(path: string) {\n try {\n stdFs.statSync(path);\n return true;\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n return false;\n }\n throw e;\n }\n }\n stat(path: string) {\n return stdFs.statSync(path);\n }\n readUtf8File(path: string) {\n return stdFs.readFileSync(path, { encoding: \"utf-8\" });\n }\n createReadStream(\n path: string,\n options: { highWaterMark?: number },\n ): ReadStream {\n return stdFs.createReadStream(path, options);\n }\n // To avoid issues with filesystem events triggering for our own streamed file\n // writes, writeFileStream is intentionally not on the Filesystem interface\n // and not implemented by RecordingFs.\n async writeFileStream(\n path: string,\n stream: Readable,\n onData?: (chunk: any) => void,\n ): Promise<void> {\n // 'wx' means O_CREAT | O_EXCL | O_WRONLY\n // 0o644 means owner has readwrite access, everyone else has read access.\n const fileHandle = await fsPromises.open(path, \"wx\", 0o644);\n try {\n for await (const chunk of stream) {\n // For some reason, adding `stream.on(\"data\", onData)` causes issues with\n // the stream, but calling a callback here works.\n if (onData) {\n onData(chunk);\n }\n await fileHandle.write(chunk);\n }\n } finally {\n await fileHandle.close();\n }\n }\n access(path: string) {\n return stdFs.accessSync(path);\n }\n writeUtf8File(path: string, contents: string, mode?: Mode) {\n const fd = stdFs.openSync(path, \"w\", mode);\n try {\n stdFs.writeFileSync(fd, contents, { encoding: \"utf-8\" });\n try {\n stdFs.fsyncSync(fd);\n } catch (e: any) {\n // fsync(2) returns EINVAL on file descriptors that don't support\n // synchronization, e.g. FIFOs/pipes. Some integrations (such as\n // 1Password's Local Environment File) expose `.env.local` as a\n // FIFO so secrets can be streamed on demand; the write itself\n // succeeded, so treat the missing sync as best-effort.\n if (e?.code !== \"EINVAL\") {\n throw e;\n }\n }\n } finally {\n stdFs.closeSync(fd);\n }\n }\n mkdir(\n dirPath: string,\n options?: { allowExisting?: boolean; recursive?: boolean },\n ): void {\n try {\n stdFs.mkdirSync(dirPath, { recursive: options?.recursive });\n } catch (e: any) {\n if (options?.allowExisting && e.code === \"EEXIST\") {\n return;\n }\n throw e;\n }\n }\n rmdir(path: string) {\n stdFs.rmdirSync(path);\n }\n unlink(path: string) {\n return stdFs.unlinkSync(path);\n }\n swapTmpFile(fromPath: TempPath, toPath: string) {\n try {\n return stdFs.renameSync(fromPath, toPath);\n } catch (e: any) {\n // Fallback to copying the file if we're on different volumes.\n if (e.code === \"EXDEV\") {\n warnCrossFilesystem(toPath);\n stdFs.copyFileSync(fromPath, toPath);\n return;\n }\n throw e;\n }\n }\n registerPath(_path: string, _st: Stats | null) {\n // The node filesystem doesn't track reads, so we don't need to do anything here.\n }\n invalidate() {\n // We don't track invalidations for the node filesystem either.\n }\n}\nexport const nodeFs = new NodeFs();\n\n// Filesystem implementation that records all paths observed. This is useful\n// for implementing continuous watch commands that need to manage a filesystem\n// watcher and know when a command's inputs were invalidated.\nexport class RecordingFs implements Filesystem {\n // Absolute path -> Set of observed child names\n private observedDirectories: Map<string, Set<string>> = new Map();\n\n // Absolute path -> observed stat (or null if observed nonexistent)\n private observedFiles: Map<string, Stats | null> = new Map();\n\n // Have we noticed that files have changed while recording?\n private invalidated = false;\n\n private traceEvents: boolean;\n\n constructor(traceEvents: boolean) {\n this.traceEvents = traceEvents;\n }\n\n listDir(dirPath: string): Dirent[] {\n const absDirPath = path.resolve(dirPath);\n\n // Register observing the directory itself.\n const dirSt = nodeFs.stat(absDirPath);\n this.registerNormalized(absDirPath, dirSt);\n\n // List the directory and register observing all of its children.\n const entries = nodeFs.listDir(dirPath);\n for (const entry of entries) {\n const childPath = path.join(absDirPath, entry.name);\n const childSt = nodeFs.stat(childPath);\n this.registerPath(childPath, childSt);\n }\n\n // Register observing the directory's children.\n const observedNames = new Set(entries.map((e) => e.name));\n const existingNames = this.observedDirectories.get(absDirPath);\n if (existingNames) {\n if (!setsEqual(observedNames, existingNames)) {\n if (this.traceEvents) {\n // eslint-disable-next-line no-console\n console.log(\n \"Invalidating due to directory children mismatch\",\n observedNames,\n existingNames,\n );\n }\n this.invalidated = true;\n }\n }\n this.observedDirectories.set(absDirPath, observedNames);\n\n return entries;\n }\n\n exists(path: string): boolean {\n try {\n const st = nodeFs.stat(path);\n this.registerPath(path, st);\n return true;\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n this.registerPath(path, null);\n return false;\n }\n throw err;\n }\n }\n stat(path: string): Stats {\n try {\n const st = nodeFs.stat(path);\n this.registerPath(path, st);\n return st;\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n this.registerPath(path, null);\n }\n throw err;\n }\n }\n readUtf8File(path: string): string {\n try {\n const st = nodeFs.stat(path);\n this.registerPath(path, st);\n return nodeFs.readUtf8File(path);\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n this.registerPath(path, null);\n }\n throw err;\n }\n }\n createReadStream(\n path: string,\n options: { highWaterMark?: number },\n ): ReadStream {\n try {\n const st = nodeFs.stat(path);\n this.registerPath(path, st);\n return nodeFs.createReadStream(path, options);\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n this.registerPath(path, null);\n }\n throw err;\n }\n }\n access(path: string) {\n try {\n const st = nodeFs.stat(path);\n this.registerPath(path, st);\n return nodeFs.access(path);\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n this.registerPath(path, null);\n }\n throw err;\n }\n }\n\n writeUtf8File(filePath: string, contents: string, mode?: Mode) {\n const absPath = path.resolve(filePath);\n\n nodeFs.writeUtf8File(filePath, contents, mode);\n\n this.updateOnWrite(absPath);\n }\n\n mkdir(\n dirPath: string,\n options?: { allowExisting?: boolean; recursive?: boolean },\n ): void {\n const absPath = path.resolve(dirPath);\n try {\n stdFs.mkdirSync(absPath, { recursive: options?.recursive });\n } catch (e: any) {\n if (options?.allowExisting && e.code === \"EEXIST\") {\n const st = nodeFs.stat(absPath);\n this.registerNormalized(absPath, st);\n return;\n }\n throw e;\n }\n this.updateOnWrite(absPath);\n }\n\n rmdir(dirPath: string) {\n const absPath = path.resolve(dirPath);\n stdFs.rmdirSync(absPath);\n this.updateOnDelete(absPath);\n }\n unlink(filePath: string) {\n const absPath = path.resolve(filePath);\n stdFs.unlinkSync(absPath);\n this.updateOnDelete(absPath);\n }\n swapTmpFile(fromPath: TempPath, toPath: string) {\n const absToPath = path.resolve(toPath);\n nodeFs.swapTmpFile(fromPath, absToPath);\n this.updateOnWrite(absToPath);\n }\n\n private updateOnWrite(absPath: string) {\n // Stat the file or dir after writing and make it our expected observation. If we read the file after\n // writing it and it doesn't match this stat (implying a subsequent write), we'll invalidate\n // the current reader.\n const newSt = nodeFs.stat(absPath);\n // Skip invalidation checking since we don't want to conflict if we previously read this file.\n this.observedFiles.set(absPath, newSt);\n\n // If we observed the parent, add our newly created file.\n const parentPath = path.resolve(path.dirname(absPath));\n const observedParent = this.observedDirectories.get(parentPath);\n if (observedParent !== undefined) {\n observedParent.add(path.basename(absPath));\n }\n }\n private updateOnDelete(absPath: string) {\n // Expect this file to be gone.\n this.observedFiles.set(absPath, null);\n\n // Unlink it from our parent if observed.\n const parentPath = path.resolve(path.dirname(absPath));\n const observedParent = this.observedDirectories.get(parentPath);\n if (observedParent !== undefined) {\n observedParent.delete(path.basename(absPath));\n }\n }\n\n registerPath(p: string, st: Stats | null) {\n const absPath = path.resolve(p);\n this.registerNormalized(absPath, st);\n }\n\n invalidate() {\n this.invalidated = true;\n }\n\n registerNormalized(absPath: string, observed: Stats | null): void {\n const existing = this.observedFiles.get(absPath);\n if (existing !== undefined) {\n const stMatch = stMatches(observed, existing);\n if (!stMatch.matches) {\n if (this.traceEvents) {\n // eslint-disable-next-line no-console\n console.log(\n \"Invalidating due to st mismatch\",\n absPath,\n observed,\n existing,\n stMatch.reason,\n );\n }\n this.invalidated = true;\n }\n }\n this.observedFiles.set(absPath, observed);\n }\n\n finalize(): Observations | \"invalidated\" {\n if (this.invalidated) {\n return \"invalidated\";\n }\n return new Observations(this.observedDirectories, this.observedFiles);\n }\n}\n\nexport type WatchEvent = {\n name: \"add\" | \"addDir\" | \"change\" | \"unlink\" | \"unlinkDir\";\n absPath: string;\n};\n\nexport class Observations {\n directories: Map<string, Set<string>>;\n files: Map<string, Stats | null>;\n\n constructor(\n directories: Map<string, Set<string>>,\n files: Map<string, Stats | null>,\n ) {\n this.directories = directories;\n this.files = files;\n }\n\n paths(): string[] {\n const out = [];\n for (const path of this.directories.keys()) {\n out.push(path);\n }\n for (const path of this.files.keys()) {\n out.push(path);\n }\n return out;\n }\n\n overlaps({\n absPath,\n }: WatchEvent): { overlaps: false } | { overlaps: true; reason: string } {\n let currentSt: null | Stats;\n try {\n currentSt = nodeFs.stat(absPath);\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n currentSt = null;\n } else {\n throw e;\n }\n }\n\n // First, check to see if we observed `absPath` as a file.\n const observedSt = this.files.get(absPath);\n if (observedSt !== undefined) {\n const stMatch = stMatches(observedSt, currentSt);\n if (!stMatch.matches) {\n const reason = `modified (${stMatch.reason})`;\n return { overlaps: true, reason };\n }\n }\n\n // Second, check if we listed the directory this file is in.\n const parentPath = path.resolve(path.dirname(absPath));\n const observedParent = this.directories.get(parentPath);\n if (observedParent !== undefined) {\n const filename = path.basename(absPath);\n\n // If the file is gone now, but we observed it in its directory, then\n // it was deleted.\n if (currentSt === null && observedParent.has(filename)) {\n return { overlaps: true, reason: \"deleted\" };\n }\n\n // If the file exists now, but we didn't see it when listing its directory,\n // then it was added.\n if (currentSt !== null && !observedParent.has(filename)) {\n return { overlaps: true, reason: \"added\" };\n }\n }\n\n return { overlaps: false };\n }\n}\n\nfunction setsEqual<T>(a: Set<T>, b: Set<T>): boolean {\n if (a.size !== b.size) {\n return false;\n }\n for (const elem of a.keys()) {\n if (!b.has(elem)) {\n return false;\n }\n }\n return true;\n}\n\nexport function stMatches(\n a: Stats | null,\n b: Stats | null,\n): { matches: true } | { matches: false; reason: string } {\n if (a === null && b === null) {\n return { matches: true };\n }\n if (a !== null && b !== null) {\n if (a.dev !== b.dev) {\n return { matches: false, reason: \"device boundary\" };\n }\n if (a.isFile() || b.isFile()) {\n if (!a.isFile() || !b.isFile()) {\n return { matches: false, reason: \"file type\" };\n }\n if (a.ino !== b.ino) {\n return {\n matches: false,\n reason: `file inode (${a.ino} vs. ${b.ino})`,\n };\n }\n if (a.size !== b.size) {\n return {\n matches: false,\n reason: `file size (${a.size} vs. ${b.size})`,\n };\n }\n if (a.mtimeMs !== b.mtimeMs) {\n return {\n matches: false,\n reason: `file mtime (${a.mtimeMs} vs. ${b.mtimeMs})`,\n };\n }\n return { matches: true };\n }\n if (a.isDirectory() || b.isDirectory()) {\n if (!b.isDirectory() || !b.isDirectory()) {\n return { matches: false, reason: \"dir file type\" };\n }\n if (a.ino !== b.ino) {\n return {\n matches: false,\n reason: `dir inode (${a.ino} vs. ${b.ino})`,\n };\n }\n return { matches: true };\n }\n // If we have something other than a file or directory, just compare inodes.\n if (a.ino !== b.ino) {\n return {\n matches: false,\n reason: `special inode (${a.ino} vs. ${b.ino})`,\n };\n }\n return { matches: true };\n }\n return { matches: false, reason: \"deleted mismatch\" };\n}\n\n// Sort consistent with unix directory listings.\nexport function consistentPathSort(a: Dirent, b: Dirent) {\n for (let i = 0; i < Math.min(a.name.length, b.name.length); i++) {\n if (a.name.charCodeAt(i) !== b.name.charCodeAt(i)) {\n return a.name.charCodeAt(i) - b.name.charCodeAt(i);\n }\n }\n return a.name.length - b.name.length;\n}\n"],
|
|
5
|
-
"mappings": ";;;;AAIA,SAAS,mBAAmB;AAC5B,OAAO,WAAgD;AACvD,YAAY,gBAAgB;AAC5B,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,YAAY;AAKnB,MAAM,oBAAoB;AAC1B,SAAS,aAAa;AAWpB,QAAM,YAAY,QAAQ,IAAI,iBAAiB;AAC/C,SAAO,aAAa,GAAG,OAAO;AAChC;AACA,MAAM,aAAa,WAAW;AAE9B,IAAI,SAAS;AACb,SAAS,oBAAoB,SAAiB;AAC5C,QAAM,SAAS,KAAK,QAAQ,OAAO;AACnC,MAAI,CAAC,QAAQ;AAGX,YAAQ;AAAA,MACN,YAAY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EAAE,QAAQ,EAAE,KAAK;AACnB,aAAO;AAAA,QACL,SAAS;AAAA,QACT,QAAQ,kBAAkB,EAAE,GAAG,QAAQ,EAAE,GAAG;AAAA,MAC9C;AAAA,IACF;AACA,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB;AACA,SAAO,EAAE,SAAS,OAAO,QAAQ,mBAAmB;AACtD;AAGO,gBAAS,mBAAmB,GAAW,GAAW;AACvD,WAAS,IAAI,GAAG,IAAI,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,GAAG,KAAK;AAC/D,QAAI,EAAE,KAAK,WAAW,CAAC,MAAM,EAAE,KAAK,WAAW,CAAC,GAAG;AACjD,aAAO,EAAE,KAAK,WAAW,CAAC,IAAI,EAAE,KAAK,WAAW,CAAC;AAAA,IACnD;AAAA,EACF;AACA,SAAO,EAAE,KAAK,SAAS,EAAE,KAAK;AAChC;",
|
|
4
|
+
"sourcesContent": ["// Disable our restriction on `throw` because these aren't developer-facing\n// error messages.\n/* eslint-disable no-restricted-imports */\n/* eslint-disable no-restricted-syntax */\nimport { chalkStderr } from \"chalk\";\nimport stdFs, { Dirent, Mode, ReadStream, Stats } from \"fs\";\nimport * as fsPromises from \"fs/promises\";\nimport os from \"os\";\nimport path from \"path\";\nimport crypto from \"crypto\";\nimport { Readable } from \"stream\";\n\nexport type NormalizedPath = string;\n\nconst tmpDirOverrideVar = \"CONVEX_TMPDIR\";\nfunction tmpDirPath() {\n // Allow users to override the temporary directory path with an environment variable.\n // This override needs to (1) be project-specific, since the user may have projects\n // on different filesystems, but also (2) be device-specific and not checked in, since\n // it's dependent on where the user has checked out their project. So, we don't want\n // this state in the project-specific `convex.json`, which is shared across all\n // devices, or in the top-level `~/.convex` directory, which is shared across all\n // projects on the local machine.\n //\n // Therefore, just let advanced users configure this behavior with an environment\n // variable that they're responsible for managing themselves for now.\n const envTmpDir = process.env[tmpDirOverrideVar];\n return envTmpDir ?? os.tmpdir();\n}\nconst tmpDirRoot = tmpDirPath();\n\nlet warned = false;\nfunction warnCrossFilesystem(dstPath: string) {\n const dstDir = path.dirname(dstPath);\n if (!warned) {\n // It's hard for these to use `logMessage` without creating a circular dependency, so just log directly.\n // eslint-disable-next-line no-console\n console.warn(\n chalkStderr.yellow(\n `Temporary directory '${tmpDirRoot}' and project directory '${dstDir}' are on different filesystems.`,\n ),\n );\n // eslint-disable-next-line no-console\n console.warn(\n chalkStderr.gray(\n ` If you're running into errors with other tools watching the project directory, override the temporary directory location with the ${chalkStderr.bold(\n tmpDirOverrideVar,\n )} environment variable.`,\n ),\n );\n // eslint-disable-next-line no-console\n console.warn(\n chalkStderr.gray(\n ` Be sure to pick a temporary directory that's on the same filesystem as your project.`,\n ),\n );\n warned = true;\n }\n}\n\nexport interface Filesystem {\n listDir(dirPath: string): Dirent[];\n\n exists(path: string): boolean;\n stat(path: string): Stats;\n lstat(path: string): Stats;\n readUtf8File(path: string): string;\n // createReadStream returns a stream for which [Symbol.asyncIterator]\n // yields chunks of size highWaterMark (until the last one), or 64KB if\n // highWaterMark isn't specified.\n // https://nodejs.org/api/stream.html#readablesymbolasynciterator\n createReadStream(\n path: string,\n options: { highWaterMark?: number },\n ): ReadStream;\n access(path: string): void;\n\n writeUtf8File(path: string, contents: string, mode?: Mode): void;\n mkdir(\n dirPath: string,\n options?: { allowExisting?: boolean; recursive?: boolean },\n ): void;\n rmdir(path: string): void;\n unlink(path: string): void;\n swapTmpFile(fromPath: TempPath, toPath: string): void;\n\n registerPath(path: string, st: Stats | null): void;\n invalidate(): void;\n}\n\nexport type TempPath = string & { __tempPath: \"tempPath\" };\n\nexport interface TempDir {\n writeUtf8File(contents: string): TempPath;\n writeFileStream(\n path: TempPath,\n stream: Readable,\n onData?: (chunk: any) => void,\n ): Promise<void>;\n registerTempPath(st: Stats | null): TempPath;\n path: TempPath;\n}\n\nexport async function withTmpDir(\n callback: (tmpDir: TempDir) => Promise<void>,\n): Promise<void> {\n // Create temporary directories inside `tmpDirRoot` of the form `convex-<random>`.\n const tmpPath = stdFs.mkdtempSync(path.join(tmpDirRoot, \"convex\"));\n const tmpDir = {\n writeUtf8File(contents: string): TempPath {\n const filePath = path.join(tmpPath, crypto.randomUUID());\n nodeFs.writeUtf8File(filePath, contents);\n return filePath as TempPath;\n },\n registerTempPath(st: Stats | null): TempPath {\n const filePath = path.join(tmpPath, crypto.randomUUID());\n nodeFs.registerPath(filePath, st);\n return filePath as TempPath;\n },\n writeFileStream(\n path: TempPath,\n stream: Readable,\n onData?: (chunk: any) => void,\n ): Promise<void> {\n return nodeFs.writeFileStream(path, stream, onData);\n },\n path: tmpPath as TempPath,\n };\n try {\n await callback(tmpDir);\n } finally {\n stdFs.rmSync(tmpPath, { force: true, recursive: true });\n }\n}\n\n// Use `nodeFs` when you just want to read and write to the local filesystem\n// and don't care about collecting the paths touched. One-off commands\n// should use the singleton `nodeFs`.\nexport class NodeFs implements Filesystem {\n listDir(dirPath: string) {\n return stdFs.readdirSync(dirPath, { withFileTypes: true });\n }\n exists(path: string) {\n try {\n stdFs.statSync(path);\n return true;\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n return false;\n }\n throw e;\n }\n }\n stat(path: string) {\n return stdFs.statSync(path);\n }\n lstat(path: string) {\n return stdFs.lstatSync(path);\n }\n readUtf8File(path: string) {\n return stdFs.readFileSync(path, { encoding: \"utf-8\" });\n }\n createReadStream(\n path: string,\n options: { highWaterMark?: number },\n ): ReadStream {\n return stdFs.createReadStream(path, options);\n }\n // To avoid issues with filesystem events triggering for our own streamed file\n // writes, writeFileStream is intentionally not on the Filesystem interface\n // and not implemented by RecordingFs.\n async writeFileStream(\n path: string,\n stream: Readable,\n onData?: (chunk: any) => void,\n ): Promise<void> {\n // 'wx' means O_CREAT | O_EXCL | O_WRONLY\n // 0o644 means owner has readwrite access, everyone else has read access.\n const fileHandle = await fsPromises.open(path, \"wx\", 0o644);\n try {\n for await (const chunk of stream) {\n // For some reason, adding `stream.on(\"data\", onData)` causes issues with\n // the stream, but calling a callback here works.\n if (onData) {\n onData(chunk);\n }\n await fileHandle.write(chunk);\n }\n } finally {\n await fileHandle.close();\n }\n }\n access(path: string) {\n return stdFs.accessSync(path);\n }\n writeUtf8File(path: string, contents: string, mode?: Mode) {\n const fd = stdFs.openSync(path, \"w\", mode);\n try {\n stdFs.writeFileSync(fd, contents, { encoding: \"utf-8\" });\n try {\n stdFs.fsyncSync(fd);\n } catch (e: any) {\n // fsync(2) returns EINVAL on file descriptors that don't support\n // synchronization, e.g. FIFOs/pipes. Some integrations (such as\n // 1Password's Local Environment File) expose `.env.local` as a\n // FIFO so secrets can be streamed on demand; the write itself\n // succeeded, so treat the missing sync as best-effort.\n if (e?.code !== \"EINVAL\") {\n throw e;\n }\n }\n } finally {\n stdFs.closeSync(fd);\n }\n }\n mkdir(\n dirPath: string,\n options?: { allowExisting?: boolean; recursive?: boolean },\n ): void {\n try {\n stdFs.mkdirSync(dirPath, { recursive: options?.recursive });\n } catch (e: any) {\n if (options?.allowExisting && e.code === \"EEXIST\") {\n return;\n }\n throw e;\n }\n }\n rmdir(path: string) {\n stdFs.rmdirSync(path);\n }\n unlink(path: string) {\n return stdFs.unlinkSync(path);\n }\n swapTmpFile(fromPath: TempPath, toPath: string) {\n try {\n return stdFs.renameSync(fromPath, toPath);\n } catch (e: any) {\n // Fallback to copying the file if we're on different volumes.\n if (e.code === \"EXDEV\") {\n warnCrossFilesystem(toPath);\n stdFs.copyFileSync(fromPath, toPath);\n return;\n }\n throw e;\n }\n }\n registerPath(_path: string, _st: Stats | null) {\n // The node filesystem doesn't track reads, so we don't need to do anything here.\n }\n invalidate() {\n // We don't track invalidations for the node filesystem either.\n }\n}\nexport const nodeFs = new NodeFs();\n\n// Filesystem implementation that records all paths observed. This is useful\n// for implementing continuous watch commands that need to manage a filesystem\n// watcher and know when a command's inputs were invalidated.\nexport class RecordingFs implements Filesystem {\n // Absolute path -> Set of observed child names\n private observedDirectories: Map<string, Set<string>> = new Map();\n\n // Absolute path -> observed stat (or null if observed nonexistent)\n private observedFiles: Map<string, Stats | null> = new Map();\n\n // lstat observes the link itself, while stat observes its target.\n private observedLstats: Map<string, Stats | null> = new Map();\n\n // Have we noticed that files have changed while recording?\n private invalidated = false;\n\n private traceEvents: boolean;\n\n constructor(traceEvents: boolean) {\n this.traceEvents = traceEvents;\n }\n\n listDir(dirPath: string): Dirent[] {\n const absDirPath = path.resolve(dirPath);\n\n // Register observing the directory itself.\n const dirSt = nodeFs.stat(absDirPath);\n this.registerNormalized(absDirPath, dirSt);\n\n // List the directory and register observing all of its children.\n const entries = nodeFs.listDir(dirPath);\n for (const entry of entries) {\n const childPath = path.join(absDirPath, entry.name);\n const childSt = nodeFs.stat(childPath);\n this.registerPath(childPath, childSt);\n }\n\n // Register observing the directory's children.\n const observedNames = new Set(entries.map((e) => e.name));\n const existingNames = this.observedDirectories.get(absDirPath);\n if (existingNames) {\n if (!setsEqual(observedNames, existingNames)) {\n if (this.traceEvents) {\n // eslint-disable-next-line no-console\n console.log(\n \"Invalidating due to directory children mismatch\",\n observedNames,\n existingNames,\n );\n }\n this.invalidated = true;\n }\n }\n this.observedDirectories.set(absDirPath, observedNames);\n\n return entries;\n }\n\n lstat(filePath: string): Stats {\n const absPath = path.resolve(filePath);\n try {\n const st = nodeFs.lstat(filePath);\n this.registerNormalized(absPath, st, this.observedLstats);\n return st;\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n this.registerNormalized(absPath, null, this.observedLstats);\n }\n throw err;\n }\n }\n\n exists(path: string): boolean {\n try {\n const st = nodeFs.stat(path);\n this.registerPath(path, st);\n return true;\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n this.registerPath(path, null);\n return false;\n }\n throw err;\n }\n }\n stat(path: string): Stats {\n try {\n const st = nodeFs.stat(path);\n this.registerPath(path, st);\n return st;\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n this.registerPath(path, null);\n }\n throw err;\n }\n }\n readUtf8File(path: string): string {\n try {\n const st = nodeFs.stat(path);\n this.registerPath(path, st);\n return nodeFs.readUtf8File(path);\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n this.registerPath(path, null);\n }\n throw err;\n }\n }\n createReadStream(\n path: string,\n options: { highWaterMark?: number },\n ): ReadStream {\n try {\n const st = nodeFs.stat(path);\n this.registerPath(path, st);\n return nodeFs.createReadStream(path, options);\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n this.registerPath(path, null);\n }\n throw err;\n }\n }\n access(path: string) {\n try {\n const st = nodeFs.stat(path);\n this.registerPath(path, st);\n return nodeFs.access(path);\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n this.registerPath(path, null);\n }\n throw err;\n }\n }\n\n writeUtf8File(filePath: string, contents: string, mode?: Mode) {\n const absPath = path.resolve(filePath);\n\n nodeFs.writeUtf8File(filePath, contents, mode);\n\n this.updateOnWrite(absPath);\n }\n\n mkdir(\n dirPath: string,\n options?: { allowExisting?: boolean; recursive?: boolean },\n ): void {\n const absPath = path.resolve(dirPath);\n try {\n stdFs.mkdirSync(absPath, { recursive: options?.recursive });\n } catch (e: any) {\n if (options?.allowExisting && e.code === \"EEXIST\") {\n const st = nodeFs.stat(absPath);\n this.registerNormalized(absPath, st);\n return;\n }\n throw e;\n }\n this.updateOnWrite(absPath);\n }\n\n rmdir(dirPath: string) {\n const absPath = path.resolve(dirPath);\n stdFs.rmdirSync(absPath);\n this.updateOnDelete(absPath);\n }\n unlink(filePath: string) {\n const absPath = path.resolve(filePath);\n stdFs.unlinkSync(absPath);\n this.updateOnDelete(absPath);\n }\n swapTmpFile(fromPath: TempPath, toPath: string) {\n const absToPath = path.resolve(toPath);\n nodeFs.swapTmpFile(fromPath, absToPath);\n this.updateOnWrite(absToPath);\n }\n\n private updateOnWrite(absPath: string) {\n // Stat the file or dir after writing and make it our expected observation. If we read the file after\n // writing it and it doesn't match this stat (implying a subsequent write), we'll invalidate\n // the current reader.\n const newSt = nodeFs.stat(absPath);\n // Skip invalidation checking since we don't want to conflict if we previously read this file.\n this.observedFiles.set(absPath, newSt);\n if (this.observedLstats.has(absPath))\n this.observedLstats.set(absPath, nodeFs.lstat(absPath));\n\n // If we observed the parent, add our newly created file.\n const parentPath = path.resolve(path.dirname(absPath));\n const observedParent = this.observedDirectories.get(parentPath);\n if (observedParent !== undefined) {\n observedParent.add(path.basename(absPath));\n }\n }\n private updateOnDelete(absPath: string) {\n // Expect this file to be gone.\n this.observedFiles.set(absPath, null);\n if (this.observedLstats.has(absPath))\n this.observedLstats.set(absPath, null);\n\n // Unlink it from our parent if observed.\n const parentPath = path.resolve(path.dirname(absPath));\n const observedParent = this.observedDirectories.get(parentPath);\n if (observedParent !== undefined) {\n observedParent.delete(path.basename(absPath));\n }\n }\n\n registerPath(p: string, st: Stats | null) {\n const absPath = path.resolve(p);\n this.registerNormalized(absPath, st);\n }\n\n invalidate() {\n this.invalidated = true;\n }\n\n registerNormalized(\n absPath: string,\n observed: Stats | null,\n observations = this.observedFiles,\n ): void {\n const existing = observations.get(absPath);\n if (existing !== undefined) {\n const stMatch = stMatches(observed, existing);\n if (!stMatch.matches) {\n if (this.traceEvents) {\n // eslint-disable-next-line no-console\n console.log(\n \"Invalidating due to st mismatch\",\n absPath,\n observed,\n existing,\n stMatch.reason,\n );\n }\n this.invalidated = true;\n }\n }\n observations.set(absPath, observed);\n }\n\n finalize(): Observations | \"invalidated\" {\n if (this.invalidated) {\n return \"invalidated\";\n }\n return new Observations(\n this.observedDirectories,\n this.observedFiles,\n this.observedLstats,\n );\n }\n}\n\nexport type WatchEvent = {\n name: \"add\" | \"addDir\" | \"change\" | \"unlink\" | \"unlinkDir\";\n absPath: string;\n};\n\nexport class Observations {\n directories: Map<string, Set<string>>;\n files: Map<string, Stats | null>;\n\n constructor(\n directories: Map<string, Set<string>>,\n files: Map<string, Stats | null>,\n private lstats: Map<string, Stats | null> = new Map(),\n ) {\n this.directories = directories;\n this.files = files;\n }\n\n paths(): string[] {\n const out = [];\n for (const path of this.directories.keys()) {\n out.push(path);\n }\n for (const path of this.files.keys()) {\n out.push(path);\n }\n for (const path of this.lstats.keys()) out.push(path);\n return [...new Set(out)];\n }\n\n overlaps({\n absPath,\n }: WatchEvent): { overlaps: false } | { overlaps: true; reason: string } {\n let currentSt: null | Stats;\n try {\n currentSt = nodeFs.stat(absPath);\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n currentSt = null;\n } else {\n throw e;\n }\n }\n\n // First, check to see if we observed `absPath` as a file.\n const observedSt = this.files.get(absPath);\n if (observedSt !== undefined) {\n const stMatch = stMatches(observedSt, currentSt);\n if (!stMatch.matches) {\n const reason = `modified (${stMatch.reason})`;\n return { overlaps: true, reason };\n }\n }\n\n const observedLstat = this.lstats.get(absPath);\n if (observedLstat !== undefined) {\n let currentLstat: Stats | null;\n try {\n currentLstat = nodeFs.lstat(absPath);\n } catch (err: any) {\n if (err.code !== \"ENOENT\") throw err;\n currentLstat = null;\n }\n const match = stMatches(observedLstat, currentLstat);\n if (!match.matches)\n return { overlaps: true, reason: `modified (${match.reason})` };\n }\n\n // Second, check if we listed the directory this file is in.\n const parentPath = path.resolve(path.dirname(absPath));\n const observedParent = this.directories.get(parentPath);\n if (observedParent !== undefined) {\n const filename = path.basename(absPath);\n\n // If the file is gone now, but we observed it in its directory, then\n // it was deleted.\n if (currentSt === null && observedParent.has(filename)) {\n return { overlaps: true, reason: \"deleted\" };\n }\n\n // If the file exists now, but we didn't see it when listing its directory,\n // then it was added.\n if (currentSt !== null && !observedParent.has(filename)) {\n return { overlaps: true, reason: \"added\" };\n }\n }\n\n return { overlaps: false };\n }\n}\n\nfunction setsEqual<T>(a: Set<T>, b: Set<T>): boolean {\n if (a.size !== b.size) {\n return false;\n }\n for (const elem of a.keys()) {\n if (!b.has(elem)) {\n return false;\n }\n }\n return true;\n}\n\nexport function stMatches(\n a: Stats | null,\n b: Stats | null,\n): { matches: true } | { matches: false; reason: string } {\n if (a === null && b === null) {\n return { matches: true };\n }\n if (a !== null && b !== null) {\n if (a.dev !== b.dev) {\n return { matches: false, reason: \"device boundary\" };\n }\n if (a.isFile() || b.isFile()) {\n if (!a.isFile() || !b.isFile()) {\n return { matches: false, reason: \"file type\" };\n }\n if (a.ino !== b.ino) {\n return {\n matches: false,\n reason: `file inode (${a.ino} vs. ${b.ino})`,\n };\n }\n if (a.size !== b.size) {\n return {\n matches: false,\n reason: `file size (${a.size} vs. ${b.size})`,\n };\n }\n if (a.mtimeMs !== b.mtimeMs) {\n return {\n matches: false,\n reason: `file mtime (${a.mtimeMs} vs. ${b.mtimeMs})`,\n };\n }\n return { matches: true };\n }\n if (a.isDirectory() || b.isDirectory()) {\n if (!b.isDirectory() || !b.isDirectory()) {\n return { matches: false, reason: \"dir file type\" };\n }\n if (a.ino !== b.ino) {\n return {\n matches: false,\n reason: `dir inode (${a.ino} vs. ${b.ino})`,\n };\n }\n return { matches: true };\n }\n // If we have something other than a file or directory, just compare inodes.\n if (a.ino !== b.ino) {\n return {\n matches: false,\n reason: `special inode (${a.ino} vs. ${b.ino})`,\n };\n }\n return { matches: true };\n }\n return { matches: false, reason: \"deleted mismatch\" };\n}\n\n// Sort consistent with unix directory listings.\nexport function consistentPathSort(a: Dirent, b: Dirent) {\n for (let i = 0; i < Math.min(a.name.length, b.name.length); i++) {\n if (a.name.charCodeAt(i) !== b.name.charCodeAt(i)) {\n return a.name.charCodeAt(i) - b.name.charCodeAt(i);\n }\n }\n return a.name.length - b.name.length;\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAIA,SAAS,mBAAmB;AAC5B,OAAO,WAAgD;AACvD,YAAY,gBAAgB;AAC5B,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,YAAY;AAKnB,MAAM,oBAAoB;AAC1B,SAAS,aAAa;AAWpB,QAAM,YAAY,QAAQ,IAAI,iBAAiB;AAC/C,SAAO,aAAa,GAAG,OAAO;AAChC;AACA,MAAM,aAAa,WAAW;AAE9B,IAAI,SAAS;AACb,SAAS,oBAAoB,SAAiB;AAC5C,QAAM,SAAS,KAAK,QA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kB,EAAE,GAAG,QAAQ,EAAE,GAAG;AAAA,MAC9C;AAAA,IACF;AACA,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB;AACA,SAAO,EAAE,SAAS,OAAO,QAAQ,mBAAmB;AACtD;AAGO,gBAAS,mBAAmB,GAAW,GAAW;AACvD,WAAS,IAAI,GAAG,IAAI,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,GAAG,KAAK;AAC/D,QAAI,EAAE,KAAK,WAAW,CAAC,MAAM,EAAE,KAAK,WAAW,CAAC,GAAG;AACjD,aAAO,EAAE,KAAK,WAAW,CAAC,IAAI,EAAE,KAAK,WAAW,CAAC;AAAA,IACnD;AAAA,EACF;AACA,SAAO,EAAE,KAAK,SAAS,EAAE,KAAK;AAChC;",
|
|
6
6
|
"names": ["path"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { Command } from "@commander-js/extra-typings";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { createLoginCommand } from "./login.js";
|
|
5
|
+
import { createLogoutCommand } from "./logout.js";
|
|
6
|
+
import { oneoffContext } from "../bundler/context.js";
|
|
7
|
+
import {
|
|
8
|
+
logFinishedStep,
|
|
9
|
+
logMessage,
|
|
10
|
+
logOutput,
|
|
11
|
+
logWarning
|
|
12
|
+
} from "../bundler/log.js";
|
|
13
|
+
import { loadProjectEnvironmentVariables } from "./lib/envvars.js";
|
|
14
|
+
import { isAuthorizedHeader, performLogin } from "./lib/login.js";
|
|
15
|
+
import {
|
|
16
|
+
getAccountSelection,
|
|
17
|
+
initializeDefaultAccount,
|
|
18
|
+
readAccountAuth,
|
|
19
|
+
readAccountCredentials,
|
|
20
|
+
readAccountSettings,
|
|
21
|
+
savedAccountNames,
|
|
22
|
+
validateAccountName,
|
|
23
|
+
updateAccountSettings
|
|
24
|
+
} from "./lib/accounts.js";
|
|
25
|
+
import {
|
|
26
|
+
bindAccountToDirectory,
|
|
27
|
+
projectAccess
|
|
28
|
+
} from "./lib/accountManagement.js";
|
|
29
|
+
import { warnIfDeployKeyOverridesLogin } from "./lib/deployKeyWarning.js";
|
|
30
|
+
import { promptOptions, promptString } from "./lib/utils/prompts.js";
|
|
31
|
+
async function accountContext() {
|
|
32
|
+
const ctx = await oneoffContext({ skipAuth: true });
|
|
33
|
+
loadProjectEnvironmentVariables();
|
|
34
|
+
return ctx;
|
|
35
|
+
}
|
|
36
|
+
const accountList = new Command("list").description(
|
|
37
|
+
"List saved accounts, credential status, and directory selections"
|
|
38
|
+
).allowExcessArguments(false).action(async () => {
|
|
39
|
+
const ctx = await accountContext();
|
|
40
|
+
const settings = await readAccountSettings(ctx);
|
|
41
|
+
const selected = await getAccountSelection(ctx);
|
|
42
|
+
const names = /* @__PURE__ */ new Set([
|
|
43
|
+
...savedAccountNames(ctx),
|
|
44
|
+
...Object.values(settings.directories ?? {}),
|
|
45
|
+
...settings.defaultAccount === void 0 ? [] : [settings.defaultAccount],
|
|
46
|
+
...selected === null ? [] : [selected.name]
|
|
47
|
+
]);
|
|
48
|
+
warnIfDeployKeyOverridesLogin(
|
|
49
|
+
ctx,
|
|
50
|
+
typeof settings.accessToken === "string" || savedAccountNames(ctx).length > 0
|
|
51
|
+
);
|
|
52
|
+
if (names.size === 0) {
|
|
53
|
+
logMessage(
|
|
54
|
+
typeof settings.accessToken === "string" ? await isAuthorizedHeader(ctx, `Bearer ${settings.accessToken}`) ? "Logged in without a named account. Name this login with `npx convex login --account personal --select`." : "Your saved login is no longer valid. Run `npx convex login --account <name>`." : "No saved accounts. Run `npx convex login --account <name>`."
|
|
55
|
+
);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (selected !== null)
|
|
59
|
+
logMessage(`Selected account: ${selected.name} (${selected.source})`);
|
|
60
|
+
if (settings.defaultAccount !== void 0)
|
|
61
|
+
logMessage(`Default account: ${settings.defaultAccount}`);
|
|
62
|
+
for (const name of [...names].sort()) {
|
|
63
|
+
const credentials = await readAccountCredentials(
|
|
64
|
+
ctx,
|
|
65
|
+
{ name, source: "saved accounts" },
|
|
66
|
+
true
|
|
67
|
+
);
|
|
68
|
+
const valid = credentials !== null && await isAuthorizedHeader(ctx, `Bearer ${credentials.accessToken}`);
|
|
69
|
+
const label = `${name}${credentials?.email ? ` (${credentials.email})` : ""}`;
|
|
70
|
+
const status = credentials === null ? " \u26A0\uFE0F Not logged in" : valid ? "" : " \u26A0\uFE0F Invalid credentials";
|
|
71
|
+
logOutput(`${label}${status}`);
|
|
72
|
+
for (const [directory, account2] of Object.entries(
|
|
73
|
+
settings.directories ?? {}
|
|
74
|
+
)) {
|
|
75
|
+
if (account2 === name) logOutput(` ${directory}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const accountSelect = new Command("select").description("Use a saved account in this directory and its subdirectories").argument("<account>", "Account name, such as work or personal").option(
|
|
80
|
+
"--force",
|
|
81
|
+
"Select this account even if deployment access cannot be verified"
|
|
82
|
+
).allowExcessArguments(false).action(async (name, options) => {
|
|
83
|
+
const ctx = await accountContext();
|
|
84
|
+
if (!await bindAccountToDirectory(ctx, name, options.force)) {
|
|
85
|
+
await ctx.crash({
|
|
86
|
+
exitCode: 1,
|
|
87
|
+
errorType: "fatal",
|
|
88
|
+
printedMessage: null
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const accountDefault = new Command("default").description(
|
|
93
|
+
"Show or set the default account for directories without a directory selection"
|
|
94
|
+
).argument("[account]", "Account name").allowExcessArguments(false).action(async (name) => {
|
|
95
|
+
const ctx = await accountContext();
|
|
96
|
+
if (name === void 0) {
|
|
97
|
+
const settings = await readAccountSettings(ctx);
|
|
98
|
+
logOutput(
|
|
99
|
+
settings.defaultAccount === void 0 ? "No default account is set." : `Default account: ${settings.defaultAccount}`
|
|
100
|
+
);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
await updateAccountSettings(ctx, async (settings) => {
|
|
104
|
+
const credentials = await readAccountCredentials(ctx, {
|
|
105
|
+
name,
|
|
106
|
+
source: "account default"
|
|
107
|
+
});
|
|
108
|
+
settings.defaultAccount = name;
|
|
109
|
+
settings.accessToken = credentials.accessToken;
|
|
110
|
+
});
|
|
111
|
+
logFinishedStep(`Default account: ${name}`);
|
|
112
|
+
});
|
|
113
|
+
const accountDeselect = new Command("deselect").description(
|
|
114
|
+
"Clear this directory's account selection, inheriting its parent's selection or the default"
|
|
115
|
+
).allowExcessArguments(false).action(async () => {
|
|
116
|
+
const ctx = await accountContext();
|
|
117
|
+
const directory = path.resolve(process.cwd());
|
|
118
|
+
const removed = await updateAccountSettings(ctx, (settings) => {
|
|
119
|
+
if (settings.directories && Object.hasOwn(settings.directories, directory)) {
|
|
120
|
+
delete settings.directories[directory];
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
});
|
|
125
|
+
if (removed)
|
|
126
|
+
logFinishedStep(`Removed the directory selection for ${directory}.`);
|
|
127
|
+
else logMessage(`No directory selection is saved for ${directory}.`);
|
|
128
|
+
const selected = await getAccountSelection(ctx);
|
|
129
|
+
if (selected !== null)
|
|
130
|
+
logMessage(`Selected account: ${selected.name} (${selected.source})`);
|
|
131
|
+
});
|
|
132
|
+
const accountSettings = new Command("settings").summary("Show or change account settings").description(
|
|
133
|
+
"Show or change account settings.\n\nRenewing an account login revokes its replaced personal access token unless another saved login uses it. To keep replaced tokens active, run:\n\n `npx convex@latest account settings revoke-replaced-tokens false`"
|
|
134
|
+
).argument("[name]", "revoke-replaced-tokens").argument("[value]", "true or false").allowExcessArguments(false).action(async (name, value, _options, cmd) => {
|
|
135
|
+
const ctx = await accountContext();
|
|
136
|
+
const settings = await readAccountSettings(ctx);
|
|
137
|
+
if (name === void 0 && value === void 0) {
|
|
138
|
+
logOutput(
|
|
139
|
+
`revoke-replaced-tokens: ${settings.revokeReplacedTokens ?? true}`
|
|
140
|
+
);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (name !== "revoke-replaced-tokens" || value !== "true" && value !== "false") {
|
|
144
|
+
cmd.error(
|
|
145
|
+
"Usage: npx convex account settings revoke-replaced-tokens <true|false>"
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
await updateAccountSettings(ctx, (settings2) => {
|
|
149
|
+
settings2.revokeReplacedTokens = value === "true";
|
|
150
|
+
});
|
|
151
|
+
logFinishedStep(`Set revoke-replaced-tokens to ${value}.`);
|
|
152
|
+
});
|
|
153
|
+
export const account = new Command("account").summary("Manage saved accounts and their directory selections").description(
|
|
154
|
+
"Manage saved accounts and their directory selections.\n\nSave logins for multiple Convex accounts under names such as work and personal. `npx convex@latest account login` and `npx convex@latest account logout` are aliases for the top-level login and logout commands, with the same options. Select the appropriate account for each personal, work, or client project.\n\nIn your personal project directory, save an account:\n\n `npx convex@latest login --account personal --select`\n\nIn your work project directory, log in with your work account and check its teams:\n\n `npx convex@latest login --account work --select`\n `npx convex@latest login status`\n\nChoose the appropriate account in the browser; sign out of the dashboard first if it is using another account. Upgrade each project's `convex` dependency to a version that supports saved accounts, then run `npx convex dev` to develop with its selected account.\n\n`login --account` saves credentials without changing directory selections. Add `--select` to select the account for this directory and its subdirectories after checking deployment access. The first saved account becomes the default if no other account is saved. To select a saved account in another directory, run `npx convex@latest account select work`. Run `npx convex@latest account deselect` to remove this directory's selection and inherit its parent or default. Run `npx convex@latest account default` to show the default, or `npx convex@latest account default work` to change it. The closest directory selection wins. Selections use absolute paths, so select the account again after moving a project.\n\nThe first account name is assigned to your existing login if you are already logged in, and becomes the default for directories without a selection. Use `--force` to authenticate another account instead, keeping the existing login as the default. Names start with a lowercase letter or number and contain only lowercase letters, numbers, hyphens, and underscores.\n\n`CONVEX_ACCOUNT` in the shell or project env file overrides directory selections and the default account. Deployment and project keys take priority over saved accounts.\n\nUse `npx convex@latest logout --account work` to remove one account's credentials, or `npx convex@latest logout --all` to remove all saved credentials. Logout preserves directory selections; a logged-out account requires login before use.\n\nAfter saving accounts, use `npx convex@latest` for login, logout, and account commands in every project directory on this machine. Plain `npx convex` can run the older version installed in that project. Specifying `@latest` runs the latest published CLI without updating the project's dependency.\n\nOlder CLIs ignore directory selections and `CONVEX_ACCOUNT`, using the shared login instead (normally the default account). Upgrade the project's `convex` dependency to use saved accounts with project commands such as `npx convex dev` and `npx convex deploy`.\n\nLogging in with an older CLI can change the shared login independently of your saved accounts, or discard account settings if the shared login has been removed. Logging out with an older CLI deletes directory selections and the default selection but leaves named account credentials behind. Recreate any lost selections with `npx convex@latest account select <name>` and `npx convex@latest account default <name>`.\n\nRenewing an account login can revoke its previous token and interrupt running CLI processes of any version that still use it. Restart those commands after renewing the login, or keep replaced tokens active with `npx convex@latest account settings revoke-replaced-tokens false`."
|
|
155
|
+
).addCommand(accountList).addCommand(accountSelect).addCommand(accountDefault).addCommand(accountDeselect).addCommand(accountSettings).addCommand(createLoginCommand()).addCommand(createLogoutCommand()).addHelpCommand(false);
|
|
156
|
+
export async function handleNoAccessToConfiguredProject(ctx, target, envFile) {
|
|
157
|
+
const auth = ctx.bigBrainAuth();
|
|
158
|
+
const current = auth?.kind === "accessToken" ? auth.account?.name : void 0;
|
|
159
|
+
const project = target.kind === "deploymentName" ? `deployment "${target.deploymentName}"` : target.kind === "teamAndProjectSlugs" ? `project "${target.teamSlug}/${target.projectSlug}"` : "the configured project";
|
|
160
|
+
logWarning(
|
|
161
|
+
`${current ? `Account "${current}"` : "Your account"} cannot access ${project}. It may belong to another account.`
|
|
162
|
+
);
|
|
163
|
+
const alternatives = [];
|
|
164
|
+
if (target.kind !== "projectDeployKey") {
|
|
165
|
+
for (const name2 of savedAccountNames(ctx)) {
|
|
166
|
+
if (name2 === current) continue;
|
|
167
|
+
const credentials = await readAccountCredentials(ctx, {
|
|
168
|
+
name: name2,
|
|
169
|
+
source: "saved accounts"
|
|
170
|
+
});
|
|
171
|
+
if (await projectAccess(credentials.accessToken, target) === "yes")
|
|
172
|
+
alternatives.push(name2);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (!process.stdin.isTTY) {
|
|
176
|
+
const selection2 = await getAccountSelection(ctx, { envFile });
|
|
177
|
+
const overrideHint = selection2?.source.startsWith("CONVEX_ACCOUNT") ? ` Update or unset CONVEX_ACCOUNT (${selection2.source}) before retrying.` : "";
|
|
178
|
+
return await ctx.crash({
|
|
179
|
+
exitCode: 1,
|
|
180
|
+
errorType: "fatal",
|
|
181
|
+
printedMessage: `${alternatives.length > 0 ? `A saved account can access it: ${alternatives.map((name2) => `\`npx convex account select ${name2}\``).join(" or ")}.` : "Log in to its account with `npx convex login --account <name> --select`."}${overrideHint} To select a different project, run \`npx convex dev --configure\` (this changes CONVEX_DEPLOYMENT).`
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const choice = await promptOptions(ctx, {
|
|
185
|
+
message: "Which account should this project use?",
|
|
186
|
+
choices: [
|
|
187
|
+
...alternatives.map((name2) => ({
|
|
188
|
+
name: `Use account "${name2}"`,
|
|
189
|
+
value: { kind: "use", name: name2 }
|
|
190
|
+
})),
|
|
191
|
+
{ name: "Log in to another account", value: { kind: "login" } },
|
|
192
|
+
{
|
|
193
|
+
name: "Configure a different project (changes CONVEX_DEPLOYMENT)",
|
|
194
|
+
value: { kind: "chooseProject" }
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
});
|
|
198
|
+
if (choice.kind === "chooseProject") return "chooseProject";
|
|
199
|
+
const name = choice.kind === "use" ? choice.name : await promptString(ctx, {
|
|
200
|
+
message: "Account name (for example, work):"
|
|
201
|
+
});
|
|
202
|
+
await validateAccountName(ctx, name);
|
|
203
|
+
if (choice.kind === "login") {
|
|
204
|
+
const selection2 = { name, source: "account recovery" };
|
|
205
|
+
await performLogin(ctx, { account: selection2 });
|
|
206
|
+
await initializeDefaultAccount(ctx, selection2, false);
|
|
207
|
+
}
|
|
208
|
+
if (!await bindAccountToDirectory(ctx, name, false, target))
|
|
209
|
+
return "chooseProject";
|
|
210
|
+
const selection = await getAccountSelection(ctx, { envFile });
|
|
211
|
+
if (selection?.name !== name) {
|
|
212
|
+
return await ctx.crash({
|
|
213
|
+
exitCode: 1,
|
|
214
|
+
errorType: "invalid filesystem or env vars",
|
|
215
|
+
printedMessage: `Remove the account override from ${selection?.source} before retrying.`
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
ctx._updateBigBrainAuth(await readAccountAuth(ctx, selection));
|
|
219
|
+
return "retry";
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/cli/account.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from \"@commander-js/extra-typings\";\nimport path from \"path\";\nimport { createLoginCommand } from \"./login.js\";\nimport { createLogoutCommand } from \"./logout.js\";\nimport { Context, oneoffContext } from \"../bundler/context.js\";\nimport {\n logFinishedStep,\n logMessage,\n logOutput,\n logWarning,\n} from \"../bundler/log.js\";\nimport { loadProjectEnvironmentVariables } from \"./lib/envvars.js\";\nimport { isAuthorizedHeader, performLogin } from \"./lib/login.js\";\nimport {\n getAccountSelection,\n initializeDefaultAccount,\n readAccountAuth,\n readAccountCredentials,\n readAccountSettings,\n savedAccountNames,\n validateAccountName,\n updateAccountSettings,\n} from \"./lib/accounts.js\";\nimport {\n bindAccountToDirectory,\n projectAccess,\n} from \"./lib/accountManagement.js\";\nimport { warnIfDeployKeyOverridesLogin } from \"./lib/deployKeyWarning.js\";\nimport { ProjectSelection } from \"./lib/deploymentSelection.js\";\nimport { promptOptions, promptString } from \"./lib/utils/prompts.js\";\n\nasync function accountContext() {\n const ctx = await oneoffContext({ skipAuth: true });\n loadProjectEnvironmentVariables();\n return ctx;\n}\n\nconst accountList = new Command(\"list\")\n .description(\n \"List saved accounts, credential status, and directory selections\",\n )\n .allowExcessArguments(false)\n .action(async () => {\n const ctx = await accountContext();\n const settings = await readAccountSettings(ctx);\n const selected = await getAccountSelection(ctx);\n const names = new Set([\n ...savedAccountNames(ctx),\n ...Object.values(settings.directories ?? {}),\n ...(settings.defaultAccount === undefined\n ? []\n : [settings.defaultAccount]),\n ...(selected === null ? [] : [selected.name]),\n ]);\n warnIfDeployKeyOverridesLogin(\n ctx,\n typeof settings.accessToken === \"string\" ||\n savedAccountNames(ctx).length > 0,\n );\n if (names.size === 0) {\n logMessage(\n typeof settings.accessToken === \"string\"\n ? (await isAuthorizedHeader(ctx, `Bearer ${settings.accessToken}`))\n ? \"Logged in without a named account. Name this login with `npx convex login --account personal --select`.\"\n : \"Your saved login is no longer valid. Run `npx convex login --account <name>`.\"\n : \"No saved accounts. Run `npx convex login --account <name>`.\",\n );\n return;\n }\n if (selected !== null)\n logMessage(`Selected account: ${selected.name} (${selected.source})`);\n if (settings.defaultAccount !== undefined)\n logMessage(`Default account: ${settings.defaultAccount}`);\n for (const name of [...names].sort()) {\n const credentials = await readAccountCredentials(\n ctx,\n { name, source: \"saved accounts\" },\n true,\n );\n const valid =\n credentials !== null &&\n (await isAuthorizedHeader(ctx, `Bearer ${credentials.accessToken}`));\n const label = `${name}${credentials?.email ? ` (${credentials.email})` : \"\"}`;\n const status =\n credentials === null\n ? \" \u26A0\uFE0F Not logged in\"\n : valid\n ? \"\"\n : \" \u26A0\uFE0F Invalid credentials\";\n logOutput(`${label}${status}`);\n for (const [directory, account] of Object.entries(\n settings.directories ?? {},\n )) {\n if (account === name) logOutput(` ${directory}`);\n }\n }\n });\n\nconst accountSelect = new Command(\"select\")\n .description(\"Use a saved account in this directory and its subdirectories\")\n .argument(\"<account>\", \"Account name, such as work or personal\")\n .option(\n \"--force\",\n \"Select this account even if deployment access cannot be verified\",\n )\n .allowExcessArguments(false)\n .action(async (name, options) => {\n const ctx = await accountContext();\n if (!(await bindAccountToDirectory(ctx, name, options.force))) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: null,\n });\n }\n });\n\nconst accountDefault = new Command(\"default\")\n .description(\n \"Show or set the default account for directories without a directory selection\",\n )\n .argument(\"[account]\", \"Account name\")\n .allowExcessArguments(false)\n .action(async (name) => {\n const ctx = await accountContext();\n if (name === undefined) {\n const settings = await readAccountSettings(ctx);\n logOutput(\n settings.defaultAccount === undefined\n ? \"No default account is set.\"\n : `Default account: ${settings.defaultAccount}`,\n );\n return;\n }\n await updateAccountSettings(ctx, async (settings) => {\n const credentials = await readAccountCredentials(ctx, {\n name,\n source: \"account default\",\n });\n settings.defaultAccount = name;\n settings.accessToken = credentials!.accessToken;\n });\n logFinishedStep(`Default account: ${name}`);\n });\n\nconst accountDeselect = new Command(\"deselect\")\n .description(\n \"Clear this directory's account selection, inheriting its parent's selection or the default\",\n )\n .allowExcessArguments(false)\n .action(async () => {\n const ctx = await accountContext();\n const directory = path.resolve(process.cwd());\n const removed = await updateAccountSettings(ctx, (settings) => {\n if (\n settings.directories &&\n Object.hasOwn(settings.directories, directory)\n ) {\n delete settings.directories[directory];\n return true;\n }\n return false;\n });\n if (removed)\n logFinishedStep(`Removed the directory selection for ${directory}.`);\n else logMessage(`No directory selection is saved for ${directory}.`);\n const selected = await getAccountSelection(ctx);\n if (selected !== null)\n logMessage(`Selected account: ${selected.name} (${selected.source})`);\n });\n\nconst accountSettings = new Command(\"settings\")\n .summary(\"Show or change account settings\")\n .description(\n \"Show or change account settings.\\n\\n\" +\n \"Renewing an account login revokes its replaced personal access token unless another saved login uses it. To keep replaced tokens active, run:\\n\\n\" +\n \" `npx convex@latest account settings revoke-replaced-tokens false`\",\n )\n .argument(\"[name]\", \"revoke-replaced-tokens\")\n .argument(\"[value]\", \"true or false\")\n .allowExcessArguments(false)\n .action(async (name, value, _options, cmd) => {\n const ctx = await accountContext();\n const settings = await readAccountSettings(ctx);\n if (name === undefined && value === undefined) {\n logOutput(\n `revoke-replaced-tokens: ${settings.revokeReplacedTokens ?? true}`,\n );\n return;\n }\n if (\n name !== \"revoke-replaced-tokens\" ||\n (value !== \"true\" && value !== \"false\")\n ) {\n cmd.error(\n \"Usage: npx convex account settings revoke-replaced-tokens <true|false>\",\n );\n }\n await updateAccountSettings(ctx, (settings) => {\n settings.revokeReplacedTokens = value === \"true\";\n });\n logFinishedStep(`Set revoke-replaced-tokens to ${value}.`);\n });\n\nexport const account = new Command(\"account\")\n .summary(\"Manage saved accounts and their directory selections\")\n .description(\n \"Manage saved accounts and their directory selections.\\n\\n\" +\n \"Save logins for multiple Convex accounts under names such as work and personal. `npx convex@latest account login` and `npx convex@latest account logout` are aliases for the top-level login and logout commands, with the same options. Select the appropriate account for each personal, work, or client project.\\n\\n\" +\n \"In your personal project directory, save an account:\\n\\n\" +\n \" `npx convex@latest login --account personal --select`\\n\\n\" +\n \"In your work project directory, log in with your work account and check its teams:\\n\\n\" +\n \" `npx convex@latest login --account work --select`\\n\" +\n \" `npx convex@latest login status`\\n\\n\" +\n \"Choose the appropriate account in the browser; sign out of the dashboard first if it is using another account. Upgrade each project's `convex` dependency to a version that supports saved accounts, then run `npx convex dev` to develop with its selected account.\\n\\n\" +\n \"`login --account` saves credentials without changing directory selections. Add `--select` to select the account for this directory and its subdirectories after checking deployment access. The first saved account becomes the default if no other account is saved. To select a saved account in another directory, run `npx convex@latest account select work`. Run `npx convex@latest account deselect` to remove this directory's selection and inherit its parent or default. Run `npx convex@latest account default` to show the default, or `npx convex@latest account default work` to change it. The closest directory selection wins. Selections use absolute paths, so select the account again after moving a project.\\n\\n\" +\n \"The first account name is assigned to your existing login if you are already logged in, and becomes the default for directories without a selection. Use `--force` to authenticate another account instead, keeping the existing login as the default. Names start with a lowercase letter or number and contain only lowercase letters, numbers, hyphens, and underscores.\\n\\n\" +\n \"`CONVEX_ACCOUNT` in the shell or project env file overrides directory selections and the default account. Deployment and project keys take priority over saved accounts.\\n\\n\" +\n \"Use `npx convex@latest logout --account work` to remove one account's credentials, or `npx convex@latest logout --all` to remove all saved credentials. Logout preserves directory selections; a logged-out account requires login before use.\\n\\n\" +\n \"After saving accounts, use `npx convex@latest` for login, logout, and account commands in every project directory on this machine. Plain `npx convex` can run the older version installed in that project. Specifying `@latest` runs the latest published CLI without updating the project's dependency.\\n\\n\" +\n \"Older CLIs ignore directory selections and `CONVEX_ACCOUNT`, using the shared login instead (normally the default account). Upgrade the project's `convex` dependency to use saved accounts with project commands such as `npx convex dev` and `npx convex deploy`.\\n\\n\" +\n \"Logging in with an older CLI can change the shared login independently of your saved accounts, or discard account settings if the shared login has been removed. Logging out with an older CLI deletes directory selections and the default selection but leaves named account credentials behind. Recreate any lost selections with `npx convex@latest account select <name>` and `npx convex@latest account default <name>`.\\n\\n\" +\n \"Renewing an account login can revoke its previous token and interrupt running CLI processes of any version that still use it. Restart those commands after renewing the login, or keep replaced tokens active with `npx convex@latest account settings revoke-replaced-tokens false`.\",\n )\n .addCommand(accountList)\n .addCommand(accountSelect)\n .addCommand(accountDefault)\n .addCommand(accountDeselect)\n .addCommand(accountSettings)\n .addCommand(createLoginCommand())\n .addCommand(createLogoutCommand())\n .addHelpCommand(false);\n\nexport async function handleNoAccessToConfiguredProject(\n ctx: Context,\n target: ProjectSelection,\n envFile?: string,\n): Promise<\"retry\" | \"chooseProject\"> {\n const auth = ctx.bigBrainAuth();\n const current = auth?.kind === \"accessToken\" ? auth.account?.name : undefined;\n const project =\n target.kind === \"deploymentName\"\n ? `deployment \"${target.deploymentName}\"`\n : target.kind === \"teamAndProjectSlugs\"\n ? `project \"${target.teamSlug}/${target.projectSlug}\"`\n : \"the configured project\";\n logWarning(\n `${current ? `Account \"${current}\"` : \"Your account\"} cannot access ${project}. It may belong to another account.`,\n );\n const alternatives: string[] = [];\n if (target.kind !== \"projectDeployKey\") {\n for (const name of savedAccountNames(ctx)) {\n if (name === current) continue;\n const credentials = await readAccountCredentials(ctx, {\n name,\n source: \"saved accounts\",\n });\n if ((await projectAccess(credentials!.accessToken, target)) === \"yes\")\n alternatives.push(name);\n }\n }\n if (!process.stdin.isTTY) {\n const selection = await getAccountSelection(ctx, { envFile });\n const overrideHint = selection?.source.startsWith(\"CONVEX_ACCOUNT\")\n ? ` Update or unset CONVEX_ACCOUNT (${selection.source}) before retrying.`\n : \"\";\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: `${\n alternatives.length > 0\n ? `A saved account can access it: ${alternatives.map((name) => `\\`npx convex account select ${name}\\``).join(\" or \")}.`\n : \"Log in to its account with `npx convex login --account <name> --select`.\"\n }${overrideHint} To select a different project, run \\`npx convex dev --configure\\` (this changes CONVEX_DEPLOYMENT).`,\n });\n }\n type Choice =\n | { kind: \"use\"; name: string }\n | { kind: \"login\" }\n | { kind: \"chooseProject\" };\n const choice = await promptOptions<Choice>(ctx, {\n message: \"Which account should this project use?\",\n choices: [\n ...alternatives.map((name) => ({\n name: `Use account \"${name}\"`,\n value: { kind: \"use\", name } as const,\n })),\n { name: \"Log in to another account\", value: { kind: \"login\" } as const },\n {\n name: \"Configure a different project (changes CONVEX_DEPLOYMENT)\",\n value: { kind: \"chooseProject\" } as const,\n },\n ],\n });\n if (choice.kind === \"chooseProject\") return \"chooseProject\";\n const name =\n choice.kind === \"use\"\n ? choice.name\n : await promptString(ctx, {\n message: \"Account name (for example, work):\",\n });\n await validateAccountName(ctx, name);\n if (choice.kind === \"login\") {\n const selection = { name, source: \"account recovery\" };\n await performLogin(ctx, { account: selection });\n await initializeDefaultAccount(ctx, selection, false);\n }\n if (!(await bindAccountToDirectory(ctx, name, false, target)))\n return \"chooseProject\";\n const selection = await getAccountSelection(ctx, { envFile });\n if (selection?.name !== name) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem or env vars\",\n printedMessage: `Remove the account override from ${selection?.source} before retrying.`,\n });\n }\n ctx._updateBigBrainAuth(await readAccountAuth(ctx, selection));\n return \"retry\";\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,eAAe;AACxB,OAAO,UAAU;AACjB,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC,SAAkB,qBAAqB;AACvC;AA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