primitive-app 3.1.1 → 3.1.3
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/dist/dev-tools/blob-explorer/blobExplorerTypes.d.ts +9 -1
- package/dist/dev-tools/document-explorer/composables/useOptimisticList.d.ts +3 -3
- package/dist/dev-tools/document-explorer/utils.d.ts +1 -0
- package/dist/dev-tools/vite-plugin/generated-env-resolver-core.d.ts +89 -18
- package/dist/dev-tools/vite-plugin/index.cjs +3 -3
- package/dist/dev-tools/vite-plugin/index.js +110 -92
- package/dist/dev-tools/vite-plugin/primitive-env.d.ts +1 -3
- package/dist/index.cjs +4 -4
- package/dist/index.js +2601 -2598
- package/dist/lib-DcwHR2qs.cjs +1 -0
- package/dist/{lib-B7ZH2Pdd.js → lib-_MJ36YT6.js} +4 -4
- package/dist/primitive-app.css +1 -1
- package/dist/services/JsBaoClientService.d.ts +4 -2
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.js +1 -1
- package/package.json +2 -2
- package/dist/lib-CFnieS8T.cjs +0 -1
|
@@ -63,14 +63,21 @@ export const keyboardShortcut = ${JSON.stringify(s)};
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
var h = "
|
|
66
|
+
var h = "primitive", g = ".primitive", _ = "config.json", v = "local.json", y = "primitive/config.json", b = ".primitive/local.json";
|
|
67
|
+
function x(e, t) {
|
|
68
|
+
return `Found ${e} but no ${t}: this project still uses the retired layout under ${g}/, which is never read.`;
|
|
69
|
+
}
|
|
70
|
+
function S(e) {
|
|
71
|
+
return `No ${y} found in ${e} or any parent directory. Primitive commands run inside a Primitive project: it is where the CLI reads the environment, the app that environment names, and the configuration tree from. Run 'primitive init' to create one.`;
|
|
72
|
+
}
|
|
73
|
+
var C = class extends Error {
|
|
67
74
|
kind;
|
|
68
75
|
path;
|
|
69
76
|
constructor(e, t, n) {
|
|
70
77
|
super(t), this.name = "PrimitiveEnvError", this.kind = e, this.path = n;
|
|
71
78
|
}
|
|
72
79
|
};
|
|
73
|
-
function
|
|
80
|
+
function w(e) {
|
|
74
81
|
if (typeof e != "string") return;
|
|
75
82
|
let t = e.trim();
|
|
76
83
|
if (!t) return;
|
|
@@ -82,87 +89,101 @@ function x(e) {
|
|
|
82
89
|
}
|
|
83
90
|
if (!(n.protocol !== "https:" && n.protocol !== "http:") && !(n.protocol === "http:" && n.hostname !== "localhost" && n.hostname !== "127.0.0.1") && !(n.username || n.password) && !(n.pathname !== "/" && n.pathname !== "") && !(n.search || n.hash)) return n.origin;
|
|
84
91
|
}
|
|
85
|
-
function
|
|
92
|
+
function T(e, t) {
|
|
93
|
+
return `Environment "${e}" in ${t ? `${y} (${t})` : y} has no "appId". Every environment names exactly one app — add "appId": "<app-id>" to that environment in ${y}. Find the app id in the Primitive admin UI, with 'primitive apps list' run from another Primitive project, or as the residual "currentAppId" in .primitive/credentials.json if this environment was ever pointed at an app by the retired per-machine app selection.`;
|
|
94
|
+
}
|
|
95
|
+
function E(e) {
|
|
96
|
+
if (typeof e == "string") return e.trim() || void 0;
|
|
97
|
+
}
|
|
98
|
+
function D(e) {
|
|
86
99
|
return e.startsWith("https://") ? "wss://" + e.slice(8) : e.startsWith("http://") ? "ws://" + e.slice(7) : e;
|
|
87
100
|
}
|
|
88
|
-
function
|
|
101
|
+
function O(t = {}) {
|
|
89
102
|
let n = (t.env ?? process.env).PRIMITIVE_PROJECT_CONFIG;
|
|
90
103
|
if (n) {
|
|
91
104
|
let t = c(n);
|
|
105
|
+
if (a(o(t)) === ".primitive") throw new C("stale-layout", x(t, s(o(o(t)), h, _)), t);
|
|
92
106
|
return e(t) ? t : null;
|
|
93
107
|
}
|
|
94
108
|
let r = c(t.cwd ?? process.cwd());
|
|
95
109
|
for (;;) {
|
|
96
|
-
let t = s(r, h,
|
|
110
|
+
let t = s(r, h, _);
|
|
97
111
|
if (e(t)) return t;
|
|
98
|
-
let n =
|
|
99
|
-
if (n
|
|
100
|
-
|
|
112
|
+
let n = s(r, g, _);
|
|
113
|
+
if (e(n)) throw new C("stale-layout", x(n, t), n);
|
|
114
|
+
let i = o(r);
|
|
115
|
+
if (i === r) return null;
|
|
116
|
+
r = i;
|
|
101
117
|
}
|
|
102
118
|
}
|
|
103
|
-
function
|
|
119
|
+
function k(e) {
|
|
104
120
|
let t = o(e);
|
|
105
|
-
return a(t) === "
|
|
121
|
+
return a(t) === "primitive" ? o(t) : t;
|
|
122
|
+
}
|
|
123
|
+
function A(e) {
|
|
124
|
+
return s(k(e), g, v);
|
|
106
125
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
126
|
+
function j(e) {
|
|
127
|
+
return e instanceof Error ? e.message : String(e);
|
|
109
128
|
}
|
|
110
|
-
function
|
|
111
|
-
if (!e(n)) throw new
|
|
129
|
+
function M(n) {
|
|
130
|
+
if (!e(n)) throw new C("missing-config", S(o(n)), n);
|
|
112
131
|
let r;
|
|
113
132
|
try {
|
|
114
133
|
r = t(n, "utf-8");
|
|
115
134
|
} catch (e) {
|
|
116
|
-
throw new
|
|
135
|
+
throw new C("malformed-config", `Failed to read ${y} (${n}): ${j(e)}`, n);
|
|
117
136
|
}
|
|
118
137
|
let i;
|
|
119
138
|
try {
|
|
120
139
|
i = JSON.parse(r);
|
|
121
140
|
} catch (e) {
|
|
122
|
-
throw new
|
|
141
|
+
throw new C("malformed-config", `Failed to parse ${y} (${n}): ${j(e)}`, n);
|
|
123
142
|
}
|
|
124
|
-
if (!i || typeof i != "object" || Array.isArray(i)) throw new
|
|
143
|
+
if (!i || typeof i != "object" || Array.isArray(i)) throw new C("malformed-config", `${y} (${n}) must contain a JSON object at the top level.`, n);
|
|
125
144
|
let a = i;
|
|
126
|
-
if (typeof a.version != "number" || !Number.isInteger(a.version)) throw new
|
|
127
|
-
if (a.version !== 1) throw new
|
|
128
|
-
if (!a.environments || typeof a.environments != "object" || Array.isArray(a.environments)) throw new
|
|
129
|
-
let
|
|
145
|
+
if (typeof a.version != "number" || !Number.isInteger(a.version)) throw new C("malformed-config", `${y} (${n}) is missing required integer field "version".`, n);
|
|
146
|
+
if (a.version !== 1) throw new C("unsupported-version", `${y} (${n}) has version ${a.version}, but this tool understands version 1.`, n);
|
|
147
|
+
if (!a.environments || typeof a.environments != "object" || Array.isArray(a.environments)) throw new C("malformed-config", `${y} (${n}) is missing required "environments" object.`, n);
|
|
148
|
+
let s = {};
|
|
130
149
|
for (let [e, t] of Object.entries(a.environments)) {
|
|
131
|
-
if (!t || typeof t != "object" || Array.isArray(t)) throw new
|
|
150
|
+
if (!t || typeof t != "object" || Array.isArray(t)) throw new C("malformed-config", `Environment "${e}" must be an object in ${y} (${n}).`, n);
|
|
132
151
|
let r = t;
|
|
133
|
-
if (typeof r.apiUrl != "string" || !r.apiUrl) throw new
|
|
134
|
-
|
|
152
|
+
if (typeof r.apiUrl != "string" || !r.apiUrl) throw new C("malformed-config", `Environment "${e}" must have a non-empty "apiUrl" string in ${y} (${n}).`, n);
|
|
153
|
+
let i = E(r.appId);
|
|
154
|
+
if (!i) throw new C("missing-app-id", T(e, n), n);
|
|
155
|
+
s[e] = {
|
|
135
156
|
apiUrl: r.apiUrl.replace(/\/$/, ""),
|
|
136
|
-
appId:
|
|
157
|
+
appId: i,
|
|
137
158
|
appName: typeof r.appName == "string" ? r.appName : void 0,
|
|
138
|
-
webUrl:
|
|
159
|
+
webUrl: w(r.webUrl),
|
|
139
160
|
description: typeof r.description == "string" ? r.description : void 0
|
|
140
161
|
};
|
|
141
162
|
}
|
|
142
163
|
return {
|
|
143
164
|
version: a.version,
|
|
144
165
|
defaultEnvironment: typeof a.defaultEnvironment == "string" && a.defaultEnvironment ? a.defaultEnvironment : void 0,
|
|
145
|
-
environments:
|
|
166
|
+
environments: s
|
|
146
167
|
};
|
|
147
168
|
}
|
|
148
|
-
function
|
|
149
|
-
let r =
|
|
169
|
+
function N(n) {
|
|
170
|
+
let r = A(n);
|
|
150
171
|
if (!e(r)) return null;
|
|
151
172
|
let i = (e) => {
|
|
152
|
-
throw new
|
|
173
|
+
throw new C("corrupt-local-state", `${b} (${r}) is unreadable: ${e}. Delete the file or re-run 'primitive env use <name>'.`, r);
|
|
153
174
|
}, a;
|
|
154
175
|
try {
|
|
155
176
|
a = JSON.parse(t(r, "utf-8"));
|
|
156
177
|
} catch (e) {
|
|
157
|
-
return i(e
|
|
178
|
+
return i(j(e));
|
|
158
179
|
}
|
|
159
180
|
if (!a || typeof a != "object" || Array.isArray(a)) return i("expected a JSON object");
|
|
160
181
|
let o = a.selectedEnvironment;
|
|
161
182
|
return o == null || o === "" ? null : typeof o == "string" ? o : i("\"selectedEnvironment\" must be a string");
|
|
162
183
|
}
|
|
163
|
-
function
|
|
164
|
-
let n = Object.keys(e.environments), r = n.join(", ") || "(none)", i = t.configPath ? `${
|
|
165
|
-
if (!e.environments[n]) throw new
|
|
184
|
+
function P(e, t) {
|
|
185
|
+
let n = Object.keys(e.environments), r = n.join(", ") || "(none)", i = t.configPath ? `${y} (${t.configPath})` : y, a = (n, a, o) => {
|
|
186
|
+
if (!e.environments[n]) throw new C("unknown-environment", `Environment "${n}" is not defined in ${i} (selected ${o}). Available: ${r}`, t.configPath);
|
|
166
187
|
return {
|
|
167
188
|
name: n,
|
|
168
189
|
source: a
|
|
@@ -170,62 +191,60 @@ function O(e, t) {
|
|
|
170
191
|
};
|
|
171
192
|
if (t.explicitEnvName) return a(t.explicitEnvName, "explicit", "explicitly");
|
|
172
193
|
if (t.envVarName) return a(t.envVarName, "env-var", "via PRIMITIVE_ENV");
|
|
173
|
-
if (t.localSelection) return a(t.localSelection, "local", `in ${
|
|
194
|
+
if (t.localSelection) return a(t.localSelection, "local", `in ${b}`);
|
|
174
195
|
if (e.defaultEnvironment) return a(e.defaultEnvironment, "default", "as \"defaultEnvironment\"");
|
|
175
196
|
if (n.length === 1) return {
|
|
176
197
|
name: n[0],
|
|
177
198
|
source: "sole"
|
|
178
199
|
};
|
|
179
|
-
throw n.length === 0 ? new
|
|
200
|
+
throw n.length === 0 ? new C("no-selection", `${i} has no environments defined. Run 'primitive env add <name>' or 'primitive init'.`, t.configPath) : new C("no-selection", `No environment selected. Run 'primitive env use <name>', set "defaultEnvironment" in ${i}, or export PRIMITIVE_ENV. Available: ${r}`, t.configPath);
|
|
180
201
|
}
|
|
181
|
-
function
|
|
182
|
-
let t = e.env ?? process.env, n = e.configPath ??
|
|
202
|
+
function F(e = {}) {
|
|
203
|
+
let t = e.env ?? process.env, n = e.configPath ?? O({
|
|
183
204
|
cwd: e.cwd,
|
|
184
205
|
env: t
|
|
185
206
|
});
|
|
186
|
-
if (!n) throw new
|
|
187
|
-
let r =
|
|
207
|
+
if (!n) throw new C("missing-config", S(e.cwd ?? process.cwd()));
|
|
208
|
+
let r = k(n), i = M(n), { name: a, source: o } = P(i, {
|
|
188
209
|
explicitEnvName: e.explicitEnvName || null,
|
|
189
210
|
envVarName: t.PRIMITIVE_ENV || null,
|
|
190
|
-
localSelection:
|
|
211
|
+
localSelection: N(n),
|
|
191
212
|
configPath: n
|
|
192
|
-
}),
|
|
193
|
-
if (e.requireAppId && !o.appId) throw new b("missing-app-id", `Environment "${i}" in ${v} (${n}) has no "appId", which this build needs. Add one with 'primitive env add ${i} --api-url ${o.apiUrl} --app-id <id>' or edit the config.`, n);
|
|
213
|
+
}), s = i.environments[a];
|
|
194
214
|
return {
|
|
195
|
-
name:
|
|
196
|
-
apiUrl:
|
|
197
|
-
wsUrl:
|
|
198
|
-
appId:
|
|
199
|
-
appName:
|
|
200
|
-
webUrl:
|
|
201
|
-
description:
|
|
202
|
-
source:
|
|
215
|
+
name: a,
|
|
216
|
+
apiUrl: s.apiUrl,
|
|
217
|
+
wsUrl: D(s.apiUrl),
|
|
218
|
+
appId: s.appId,
|
|
219
|
+
appName: s.appName,
|
|
220
|
+
webUrl: s.webUrl,
|
|
221
|
+
description: s.description,
|
|
222
|
+
source: o,
|
|
203
223
|
configPath: n,
|
|
204
|
-
localStatePath:
|
|
205
|
-
projectRoot:
|
|
224
|
+
localStatePath: A(n),
|
|
225
|
+
projectRoot: r
|
|
206
226
|
};
|
|
207
227
|
}
|
|
208
228
|
//#endregion
|
|
209
229
|
//#region src/dev-tools/vite-plugin/primitive-env.ts
|
|
210
|
-
var
|
|
230
|
+
var I = [
|
|
211
231
|
"VITE_APP_ID",
|
|
212
232
|
"VITE_API_URL",
|
|
213
233
|
"VITE_WS_URL",
|
|
214
234
|
"VITE_APP_NAME"
|
|
215
|
-
],
|
|
216
|
-
function
|
|
235
|
+
], L = "VITE_EXPECTED_PRIMITIVE_ENV", R = /* @__PURE__ */ new Map();
|
|
236
|
+
function z(e, t) {
|
|
217
237
|
let n = process.env[e];
|
|
218
|
-
n !== void 0 && n !== "" &&
|
|
238
|
+
n !== void 0 && n !== "" && R.get(e) !== n || (process.env[e] = t, R.set(e, t));
|
|
219
239
|
}
|
|
220
|
-
function
|
|
221
|
-
return
|
|
240
|
+
function B(e = {}) {
|
|
241
|
+
return F({
|
|
222
242
|
cwd: e.root,
|
|
223
243
|
env: e.env,
|
|
224
|
-
explicitEnvName: e.primitiveEnv ?? null
|
|
225
|
-
requireAppId: e.requireAppId
|
|
244
|
+
explicitEnvName: e.primitiveEnv ?? null
|
|
226
245
|
});
|
|
227
246
|
}
|
|
228
|
-
function
|
|
247
|
+
function V(e, t, n) {
|
|
229
248
|
let r = (e) => n.includes(e) ? " (overridden)" : "", i = [
|
|
230
249
|
`[primitive-env] Primitive environment: ${e.name} (selected: ${e.source})`,
|
|
231
250
|
`[primitive-env] apiUrl: ${t.apiUrl}${r("VITE_API_URL")}`,
|
|
@@ -236,12 +255,12 @@ function F(e, t, n) {
|
|
|
236
255
|
];
|
|
237
256
|
return n.length > 0 && i.push(`[primitive-env] overridden by the environment: ${n.join(", ")}`), i.join("\n");
|
|
238
257
|
}
|
|
239
|
-
function
|
|
258
|
+
function H(e, t) {
|
|
240
259
|
let n = e?.envDir;
|
|
241
260
|
return n === !1 ? null : typeof n == "string" && n !== "" ? c(t, n) : t;
|
|
242
261
|
}
|
|
243
|
-
function
|
|
244
|
-
let n = process.env[
|
|
262
|
+
function U(e, t) {
|
|
263
|
+
let n = process.env[L];
|
|
245
264
|
if (n !== void 0 && n !== "") return {
|
|
246
265
|
value: n,
|
|
247
266
|
where: "the process environment"
|
|
@@ -253,7 +272,7 @@ function L(e, t) {
|
|
|
253
272
|
".env.local",
|
|
254
273
|
".env"
|
|
255
274
|
]) {
|
|
256
|
-
let e =
|
|
275
|
+
let e = J(s(t, n))[L];
|
|
257
276
|
if (e !== void 0) return {
|
|
258
277
|
value: e,
|
|
259
278
|
where: n
|
|
@@ -261,48 +280,47 @@ function L(e, t) {
|
|
|
261
280
|
}
|
|
262
281
|
return null;
|
|
263
282
|
}
|
|
264
|
-
function
|
|
283
|
+
function W(e, t, n) {
|
|
265
284
|
return [
|
|
266
285
|
`[primitive-env] Wrong pair: vite mode "${e}" is declared to run against Primitive environment "${t.value}", but "${n.name}" resolved.`,
|
|
267
|
-
`[primitive-env] expected: ${t.value} (${
|
|
286
|
+
`[primitive-env] expected: ${t.value} (${L} in ${t.where})`,
|
|
268
287
|
`[primitive-env] resolved: ${n.name} (selected: ${n.source})`,
|
|
269
288
|
`[primitive-env] config: ${n.configPath}`,
|
|
270
289
|
"",
|
|
271
|
-
`Run the pair you meant — PRIMITIVE_ENV=${t.value} <command> --mode ${e}, or 'primitive env use ${t.value}' — or change/remove ${
|
|
290
|
+
`Run the pair you meant — PRIMITIVE_ENV=${t.value} <command> --mode ${e}, or 'primitive env use ${t.value}' — or change/remove ${L} in ${t.where}.`,
|
|
272
291
|
"",
|
|
273
292
|
`A mode declares this when its .env.${e} carries values coupled to one backend, so continuing would run this environment's identity with another's configuration.`
|
|
274
293
|
].join("\n");
|
|
275
294
|
}
|
|
276
|
-
function
|
|
277
|
-
let r =
|
|
278
|
-
if (r && r.value !== "" && r.value !== n.name) throw Error(
|
|
295
|
+
function G(e, t, n) {
|
|
296
|
+
let r = U(e, t);
|
|
297
|
+
if (r && r.value !== "" && r.value !== n.name) throw Error(W(e, r, n));
|
|
279
298
|
}
|
|
280
|
-
function
|
|
299
|
+
function K(e = {}) {
|
|
281
300
|
let t = null, n = null, r, i = [], a = !1, o = null;
|
|
282
301
|
return {
|
|
283
302
|
name: "primitive-env",
|
|
284
303
|
enforce: "pre",
|
|
285
304
|
config(s, c) {
|
|
286
305
|
a = c?.command === "serve", o = null;
|
|
287
|
-
let l = s?.root ?? process.cwd(), u = c?.mode ?? "development", d =
|
|
288
|
-
for (let e of
|
|
289
|
-
let t = process.env[e], n = t !== void 0 &&
|
|
306
|
+
let l = s?.root ?? process.cwd(), u = c?.mode ?? "development", d = q(u, l), f = {};
|
|
307
|
+
for (let e of I) {
|
|
308
|
+
let t = process.env[e], n = t !== void 0 && R.get(e) !== t ? t : d[e];
|
|
290
309
|
n !== void 0 && n !== "" && (f[e] = n);
|
|
291
310
|
}
|
|
292
311
|
let p;
|
|
293
312
|
try {
|
|
294
|
-
p =
|
|
313
|
+
p = F({
|
|
295
314
|
cwd: l,
|
|
296
|
-
explicitEnvName: e.primitiveEnv ?? null
|
|
297
|
-
requireAppId: !f.VITE_APP_ID
|
|
315
|
+
explicitEnvName: e.primitiveEnv ?? null
|
|
298
316
|
});
|
|
299
317
|
} catch (e) {
|
|
300
|
-
if (e instanceof
|
|
318
|
+
if (e instanceof C && e.kind === "missing-config" && f.VITE_APP_ID && f.VITE_API_URL) return console.warn("[primitive-env] No primitive/config.json found; using VITE_APP_ID / VITE_API_URL from the environment. Run 'primitive init' to make the project the source of truth."), r = f.VITE_APP_NAME, {};
|
|
301
319
|
throw e;
|
|
302
320
|
}
|
|
303
321
|
if (!(f.VITE_APP_ID && f.VITE_API_URL)) {
|
|
304
|
-
let e =
|
|
305
|
-
|
|
322
|
+
let e = H(s, l);
|
|
323
|
+
G(u, e, p), o = {
|
|
306
324
|
root: l,
|
|
307
325
|
mode: u,
|
|
308
326
|
dir: e
|
|
@@ -315,25 +333,25 @@ function B(e = {}) {
|
|
|
315
333
|
VITE_WS_URL: p.wsUrl,
|
|
316
334
|
VITE_APP_NAME: p.appName
|
|
317
335
|
}, h = { "import.meta.env.VITE_PRIMITIVE_ENV": JSON.stringify(p.name) }, g = [];
|
|
318
|
-
for (let e of
|
|
336
|
+
for (let e of I) {
|
|
319
337
|
if (f[e] !== void 0) {
|
|
320
338
|
g.push(e);
|
|
321
339
|
continue;
|
|
322
340
|
}
|
|
323
341
|
let t = m[e];
|
|
324
|
-
t !== void 0 && (h[`import.meta.env.${e}`] = JSON.stringify(t),
|
|
342
|
+
t !== void 0 && (h[`import.meta.env.${e}`] = JSON.stringify(t), z(e, t));
|
|
325
343
|
}
|
|
326
|
-
return
|
|
344
|
+
return z("VITE_PRIMITIVE_ENV", p.name), i = g, n = {
|
|
327
345
|
apiUrl: f.VITE_API_URL ?? p.apiUrl,
|
|
328
346
|
wsUrl: f.VITE_WS_URL ?? p.wsUrl,
|
|
329
347
|
appId: f.VITE_APP_ID ?? p.appId,
|
|
330
348
|
appName: r
|
|
331
|
-
}, e.logResolved !== !1 && console.log(
|
|
349
|
+
}, e.logResolved !== !1 && console.log(V(p, n, g)), g.length > 0 && console.warn(`[primitive-env] Overridden by an explicit value in .env or the shell: ${g.join(", ")}. Remove it to use primitive/config.json (deploys reject these outright).`), { define: h };
|
|
332
350
|
},
|
|
333
351
|
configResolved(e) {
|
|
334
352
|
if (!o || !t) return;
|
|
335
|
-
let n =
|
|
336
|
-
n === o.dir && r === o.mode || (
|
|
353
|
+
let n = H(e, o.root), r = e?.mode ?? o.mode;
|
|
354
|
+
n === o.dir && r === o.mode || (G(r, n, t), o = {
|
|
337
355
|
root: o.root,
|
|
338
356
|
mode: r,
|
|
339
357
|
dir: n
|
|
@@ -356,17 +374,17 @@ function B(e = {}) {
|
|
|
356
374
|
}
|
|
357
375
|
};
|
|
358
376
|
}
|
|
359
|
-
function
|
|
377
|
+
function q(e, t) {
|
|
360
378
|
let n = [
|
|
361
379
|
".env",
|
|
362
380
|
".env.local",
|
|
363
381
|
`.env.${e}`,
|
|
364
382
|
`.env.${e}.local`
|
|
365
383
|
], r = {};
|
|
366
|
-
for (let e of n) Object.assign(r,
|
|
384
|
+
for (let e of n) Object.assign(r, J(s(t, e)));
|
|
367
385
|
return r;
|
|
368
386
|
}
|
|
369
|
-
function
|
|
387
|
+
function J(n) {
|
|
370
388
|
if (!e(n)) return {};
|
|
371
389
|
let r = {};
|
|
372
390
|
for (let e of t(n, "utf-8").split(/\r?\n/)) {
|
|
@@ -380,4 +398,4 @@ function H(n) {
|
|
|
380
398
|
return r;
|
|
381
399
|
}
|
|
382
400
|
//#endregion
|
|
383
|
-
export {
|
|
401
|
+
export { C as PrimitiveEnvError, m as primitiveDevTools, K as primitiveEnv, B as resolvePrimitiveEnv };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `primitiveEnv()` — Primitive environment configuration for a Vite app (#2873).
|
|
3
3
|
*
|
|
4
4
|
* A scaffolded app used to type its backend URL and app ID twice: once in
|
|
5
|
-
*
|
|
5
|
+
* `primitive/config.json` (which every `primitive` command reads) and again in
|
|
6
6
|
* `.env` / `.env.production`. This plugin removes the second copy. It resolves
|
|
7
7
|
* the selected Primitive environment at config time and `define`s the keys the
|
|
8
8
|
* app already reads:
|
|
@@ -45,8 +45,6 @@ export interface ResolvePrimitiveEnvOptions {
|
|
|
45
45
|
env?: Record<string, string | undefined>;
|
|
46
46
|
/** An explicit environment name (e.g. from `--primitive-env`). */
|
|
47
47
|
primitiveEnv?: string | null;
|
|
48
|
-
/** Fail when the resolved environment has no `appId`. */
|
|
49
|
-
requireAppId?: boolean;
|
|
50
48
|
}
|
|
51
49
|
/**
|
|
52
50
|
* Resolves the Primitive environment for a project. A thin wrapper over the
|