@iann29/synapse 1.8.3 → 1.8.4
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/lib/env-file.js +27 -12
- package/package.json +1 -1
package/lib/env-file.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Writes / reads `.env.local` for Synapse-linked projects.
|
|
2
2
|
//
|
|
3
|
-
// As of v1.8.
|
|
4
|
-
// tutorials
|
|
3
|
+
// As of v1.8.4 the file is drop-in compatible with Convex Cloud
|
|
4
|
+
// tutorials (cloud-style NEXT_PUBLIC_* vars) while keeping CONVEX_DEPLOYMENT
|
|
5
|
+
// commented so the Convex CLI's mode picker doesn't see both modes active:
|
|
5
6
|
//
|
|
6
7
|
// # Convex (Synapse self-hosted — drop-in compatible with Cloud tutorials)
|
|
7
8
|
// NEXT_PUBLIC_CONVEX_URL="https://<name>.app.synapsepanel.com"
|
|
8
9
|
// NEXT_PUBLIC_CONVEX_SITE_URL="https://<name>.app.synapsepanel.com"
|
|
9
|
-
// CONVEX_DEPLOYMENT=dev:<name> # team: <team>, project: <project>
|
|
10
|
+
// # CONVEX_DEPLOYMENT=dev:<name> # team: <team>, project: <project>
|
|
10
11
|
//
|
|
11
12
|
// # Self-hosted auth (Synapse cannot use Cloud account session)
|
|
12
13
|
// CONVEX_SELF_HOSTED_URL="https://<name>.app.synapsepanel.com"
|
|
@@ -17,10 +18,16 @@
|
|
|
17
18
|
// origins. In self-hosted both point at the same URL; the backend
|
|
18
19
|
// container routes API calls and HTTP actions on the same host.
|
|
19
20
|
//
|
|
20
|
-
// CONVEX_DEPLOYMENT
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
21
|
+
// CONVEX_DEPLOYMENT stays commented in self-hosted mode. The Convex
|
|
22
|
+
// CLI errors with "CONVEX_DEPLOYMENT must not be set when
|
|
23
|
+
// CONVEX_SELF_HOSTED_URL and CONVEX_SELF_HOSTED_ADMIN_KEY are set" if
|
|
24
|
+
// both are present at runtime. Our wrapper deletes CONVEX_DEPLOYMENT
|
|
25
|
+
// from process.env before spawning npx convex, but the convex CLI
|
|
26
|
+
// invokes dotenv.config() on its own and re-reads .env.local, which
|
|
27
|
+
// would resurrect the var. Keeping the line commented preserves the
|
|
28
|
+
// human-readable context (team/project, deployment kind) without
|
|
29
|
+
// triggering the conflict. v1.8.2-v1.8.3 wrote it active — that
|
|
30
|
+
// regression broke `synapse dev` and is fixed in v1.8.4.
|
|
24
31
|
|
|
25
32
|
const fs = require("node:fs");
|
|
26
33
|
const path = require("node:path");
|
|
@@ -115,10 +122,18 @@ function readProjectEnv(projectDir) {
|
|
|
115
122
|
return parseEnvContent(fs.readFileSync(file, "utf8"));
|
|
116
123
|
}
|
|
117
124
|
|
|
118
|
-
// Build the
|
|
119
|
-
// don't have enough info
|
|
120
|
-
//
|
|
121
|
-
//
|
|
125
|
+
// Build the (commented) CONVEX_DEPLOYMENT line. Returns null when we
|
|
126
|
+
// don't have enough info (legacy caller with no deploymentName).
|
|
127
|
+
//
|
|
128
|
+
// REGRESSION FIX v1.8.4: this line MUST be commented. Convex CLI rejects
|
|
129
|
+
// the combination of CONVEX_DEPLOYMENT + CONVEX_SELF_HOSTED_URL/ADMIN_KEY
|
|
130
|
+
// — the two modes are mutually exclusive. v1.8.2 wrote it ACTIVE, which
|
|
131
|
+
// broke `npx convex` (and therefore `synapse dev`) because Convex's
|
|
132
|
+
// internal dotenv re-loads .env.local after our wrapper deletes the
|
|
133
|
+
// var from the child env. Keeping it commented preserves the human
|
|
134
|
+
// context (team/project label) while never showing up in the parsed
|
|
135
|
+
// env. See https://github.com/Iann29/convex-synapse/issues for the
|
|
136
|
+
// real-world report from the user's session.
|
|
122
137
|
function buildDeploymentLine({ deploymentName, target, teamName, projectName, teamSlug, projectSlug }) {
|
|
123
138
|
if (!deploymentName) return null;
|
|
124
139
|
const safeTarget = target === "prod" ? "prod" : "dev";
|
|
@@ -128,7 +143,7 @@ function buildDeploymentLine({ deploymentName, target, teamName, projectName, te
|
|
|
128
143
|
if (teamLabel) parts.push(`team: ${teamLabel}`);
|
|
129
144
|
if (projectLabel) parts.push(`project: ${projectLabel}`);
|
|
130
145
|
const comment = parts.length > 0 ? ` # ${parts.join(", ")}` : "";
|
|
131
|
-
return
|
|
146
|
+
return `# ${CONVEX_DEPLOYMENT}=${safeTarget}:${deploymentName}${comment}`;
|
|
132
147
|
}
|
|
133
148
|
|
|
134
149
|
function updateEnvContent(content, opts) {
|