@cancia/astro 0.5.0 → 0.5.1
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.
|
@@ -166,10 +166,20 @@ function setBakedConfig(config) {
|
|
|
166
166
|
function setCanciaRuntime(runtime) {
|
|
167
167
|
_runtime = runtime;
|
|
168
168
|
}
|
|
169
|
+
function __resetRuntimeForTests() {
|
|
170
|
+
_runtime = null;
|
|
171
|
+
_bakedConfig = null;
|
|
172
|
+
}
|
|
169
173
|
function buildRuntimeFromBaked(baked) {
|
|
170
174
|
const projectRoot = baked.projectRoot || process.cwd();
|
|
171
175
|
const token = process.env.CANCIA_TOKEN?.trim() || "";
|
|
172
|
-
const
|
|
176
|
+
const isPublic = baked.public === true;
|
|
177
|
+
if (!isPublic && !token) {
|
|
178
|
+
throw new Error(
|
|
179
|
+
"[cancia] CANCIA_TOKEN is not set but this site is not public \u2014 refusing to start to avoid serving an open, unauthenticated mutation API. Set CANCIA_TOKEN in the deployed process, or set public:true if anonymous editing is intended."
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
const secret = isPublic ? void 0 : token;
|
|
173
183
|
const redeployHook = baked.redeployHook || void 0;
|
|
174
184
|
const deployHook = redeployHook || process.env.CANCIA_DEPLOY_HOOK || void 0;
|
|
175
185
|
const deployHookToken = process.env.CANCIA_DEPLOY_HOOK_TOKEN || void 0;
|
|
@@ -261,5 +271,6 @@ export {
|
|
|
261
271
|
makeR2UploadHandler,
|
|
262
272
|
setBakedConfig,
|
|
263
273
|
setCanciaRuntime,
|
|
274
|
+
__resetRuntimeForTests,
|
|
264
275
|
getCanciaRuntime
|
|
265
276
|
};
|
package/dist/index.js
CHANGED
package/dist/runtime.d.ts
CHANGED
|
@@ -146,6 +146,14 @@ declare function setBakedConfig(config: BakedConfig): void;
|
|
|
146
146
|
* to lazy init instead.
|
|
147
147
|
*/
|
|
148
148
|
declare function setCanciaRuntime(runtime: CanciaRuntime): void;
|
|
149
|
+
/**
|
|
150
|
+
* TEST-ONLY: clear both module singletons so the next getCanciaRuntime() rebuilds
|
|
151
|
+
* from scratch. Production never calls this — the virtual module supplies baked
|
|
152
|
+
* config exactly once and endpoints share the built runtime for the process
|
|
153
|
+
* lifetime. Needed only because a mocked virtual:cancia/runtime module survives
|
|
154
|
+
* vitest's vi.resetModules() (its singletons would otherwise leak across cases).
|
|
155
|
+
*/
|
|
156
|
+
declare function __resetRuntimeForTests(): void;
|
|
149
157
|
declare function getCanciaRuntime(): CanciaRuntime;
|
|
150
158
|
|
|
151
|
-
export { type BakedConfig, type BakedR2Config, type BakedStorageDescriptor, type CanciaRuntime, type PublishMode, getCanciaRuntime, setBakedConfig, setCanciaRuntime };
|
|
159
|
+
export { type BakedConfig, type BakedR2Config, type BakedStorageDescriptor, type CanciaRuntime, type PublishMode, __resetRuntimeForTests, getCanciaRuntime, setBakedConfig, setCanciaRuntime };
|
package/dist/runtime.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
__resetRuntimeForTests,
|
|
2
3
|
getCanciaRuntime,
|
|
3
4
|
setBakedConfig,
|
|
4
5
|
setCanciaRuntime
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AGNPUTKS.js";
|
|
6
7
|
import "./chunk-5IPHDIC6.js";
|
|
7
8
|
import "./chunk-GNWD7EL2.js";
|
|
8
9
|
import "./chunk-U7V53JX7.js";
|
|
9
10
|
import "./chunk-L2VKQJPY.js";
|
|
10
11
|
import "./chunk-7IA5B5CF.js";
|
|
11
12
|
export {
|
|
13
|
+
__resetRuntimeForTests,
|
|
12
14
|
getCanciaRuntime,
|
|
13
15
|
setBakedConfig,
|
|
14
16
|
setCanciaRuntime
|