@strifeapp/astro 1.0.17 → 1.0.19
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/index.js +49 -47
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { loadEnv as f } from "vite";
|
|
2
|
-
import
|
|
2
|
+
import s from "serialize-javascript";
|
|
3
3
|
const y = `/**
|
|
4
4
|
* Creates an indexed item that will be stored in the index.
|
|
5
5
|
* @param {string} name - Name of property to index
|
|
@@ -261,38 +261,34 @@ function storeAs(name, value) {
|
|
|
261
261
|
});
|
|
262
262
|
|
|
263
263
|
return result;
|
|
264
|
-
}`,
|
|
265
|
-
function
|
|
266
|
-
|
|
267
|
-
return console.log("[vitePluginStrifeStore] Config received:", JSON.stringify(e, null, 2)), h.get(((i = e.urls) == null ? void 0 : i[0]) || "", (t) => {
|
|
268
|
-
console.log("Test SSR fetch to RavenDB:", t.statusCode);
|
|
269
|
-
}).on("error", (t) => {
|
|
270
|
-
console.error("SSR network error to RavenDB:", t);
|
|
271
|
-
}), {
|
|
264
|
+
}`, m = "strife:store", p = "\0" + m;
|
|
265
|
+
function h(e) {
|
|
266
|
+
return console.log("[vitePluginStrifeStore] Config received:", JSON.stringify(e, null, 2)), {
|
|
272
267
|
name: "strife:store",
|
|
273
|
-
resolveId(
|
|
274
|
-
if (
|
|
268
|
+
resolveId(i) {
|
|
269
|
+
if (i === m)
|
|
275
270
|
return p;
|
|
276
271
|
},
|
|
277
|
-
load(
|
|
278
|
-
var r;
|
|
279
|
-
if (
|
|
272
|
+
load(i) {
|
|
273
|
+
var o, r, a;
|
|
274
|
+
if (i === p)
|
|
280
275
|
return `
|
|
281
276
|
import { DocumentStore, AbstractJavaScriptMultiMapIndexCreationTask, IndexCreation } from "ravendb";
|
|
277
|
+
import https from 'https';
|
|
282
278
|
|
|
283
279
|
const authOptions = {
|
|
284
280
|
type: 'pfx',
|
|
285
|
-
certificate: Buffer.from(${
|
|
286
|
-
password: ${
|
|
281
|
+
certificate: Buffer.from(${s(e.certificate)}, 'base64'),
|
|
282
|
+
password: ${s(e.password)},
|
|
287
283
|
};
|
|
288
284
|
|
|
289
|
-
console.log('[vitePluginStrifeStore] Will attempt to connect to URLs:', ${
|
|
290
|
-
console.log('[vitePluginStrifeStore] Using database:', ${
|
|
285
|
+
console.log('[vitePluginStrifeStore] Will attempt to connect to URLs:', ${s(e.urls)});
|
|
286
|
+
console.log('[vitePluginStrifeStore] Using database:', ${s(e.database)});
|
|
291
287
|
console.log('[vitePluginStrifeStore] Certificate length:', ${e.certificate ? e.certificate.length : 0});
|
|
292
288
|
|
|
293
289
|
const store = new DocumentStore(
|
|
294
|
-
${
|
|
295
|
-
${
|
|
290
|
+
${s(e.urls ? e.urls : [])},
|
|
291
|
+
${s(e.database || "")},
|
|
296
292
|
authOptions
|
|
297
293
|
).initialize();
|
|
298
294
|
|
|
@@ -300,9 +296,9 @@ function T(e) {
|
|
|
300
296
|
constructor() {
|
|
301
297
|
super();
|
|
302
298
|
|
|
303
|
-
this.additionalSources = {"Helper": ${
|
|
299
|
+
this.additionalSources = {"Helper": ${s(y)}}
|
|
304
300
|
|
|
305
|
-
${(e.collections || ["Posts"]).map((
|
|
301
|
+
${(e.collections || ["Posts"]).map((t) => `this.map("${typeof t == "string" ? t : t.name}", (doc) => { return mapDocument(doc) });`).join(`
|
|
306
302
|
`)}
|
|
307
303
|
|
|
308
304
|
this.deploymentMode = 'Rolling';
|
|
@@ -312,13 +308,19 @@ function T(e) {
|
|
|
312
308
|
|
|
313
309
|
console.log('Deploying index...');
|
|
314
310
|
console.log('[vitePluginStrifeStore] Generating virtual module code with config:', ${JSON.stringify(e, null, 2)});
|
|
311
|
+
console.log('Test SSR fetch to RavenDB:', ${s(((o = e.urls) == null ? void 0 : o[0]) || "")});
|
|
312
|
+
https.get(${s(((r = e.urls) == null ? void 0 : r[0]) || "")}, (res) => {
|
|
313
|
+
console.log('Test SSR fetch to RavenDB:', res.statusCode);
|
|
314
|
+
}).on('error', (e) => {
|
|
315
|
+
console.error('SSR network error to RavenDB:', e);
|
|
316
|
+
});
|
|
315
317
|
|
|
316
318
|
await IndexCreation.createIndexes([new Content_ByUrl()], store);
|
|
317
319
|
|
|
318
320
|
const bulkInsert = store.bulkInsert();
|
|
319
321
|
|
|
320
|
-
${(
|
|
321
|
-
await bulkInsert.store(${JSON.stringify(
|
|
322
|
+
${(a = e.collections) == null ? void 0 : a.map((t) => `
|
|
323
|
+
await bulkInsert.store(${JSON.stringify(t)}, 'templates/${t.name}', { '@collection': 'Templates' });
|
|
322
324
|
`).join(`
|
|
323
325
|
`)}
|
|
324
326
|
|
|
@@ -329,54 +331,54 @@ function T(e) {
|
|
|
329
331
|
}
|
|
330
332
|
};
|
|
331
333
|
}
|
|
332
|
-
const
|
|
334
|
+
const T = {
|
|
333
335
|
type: "pfx"
|
|
334
336
|
};
|
|
335
|
-
function
|
|
336
|
-
let
|
|
337
|
-
if (!
|
|
338
|
-
const
|
|
339
|
-
|
|
337
|
+
function g(e, i) {
|
|
338
|
+
let o = process.env.STRIFE_DATABASE_URLS, r = process.env.STRIFE_DATABASE, a = process.env.STRIFE_CERTIFICATE, t = process.env.STRIFE_CERTIFICATE_PASSWORD;
|
|
339
|
+
if (!o || !r || !a || !t) {
|
|
340
|
+
const n = f(e, i ?? "", "");
|
|
341
|
+
o = o || n.STRIFE_DATABASE_URLS, r = r || n.STRIFE_DATABASE, a = a || n.STRIFE_CERTIFICATE, t = t || n.STRIFE_CERTIFICATE_PASSWORD;
|
|
340
342
|
}
|
|
341
|
-
return console.log("[strifeIntegration] Loaded environment variables:"), console.log(` STRIFE_DATABASE_URLS: ${
|
|
342
|
-
urls:
|
|
343
|
+
return console.log("[strifeIntegration] Loaded environment variables:"), console.log(` STRIFE_DATABASE_URLS: ${o ? "[SET]" : "[NOT SET]"}`), console.log(` STRIFE_DATABASE: ${r || "[NOT SET]"}`), console.log(` STRIFE_CERTIFICATE: ${a ? `[SET, length=${a.length}]` : "[NOT SET]"}`), console.log(` STRIFE_CERTIFICATE_PASSWORD: ${t ? "[SET]" : "[NOT SET]"}`), {
|
|
344
|
+
urls: o ? o.split(",").map((n) => n.trim()).filter(Boolean) : void 0,
|
|
343
345
|
database: r || void 0,
|
|
344
|
-
certificate:
|
|
345
|
-
password:
|
|
346
|
+
certificate: a || void 0,
|
|
347
|
+
password: t || void 0
|
|
346
348
|
};
|
|
347
349
|
}
|
|
348
|
-
function
|
|
350
|
+
function v(e) {
|
|
349
351
|
return {
|
|
350
352
|
name: "@strife/astro",
|
|
351
353
|
hooks: {
|
|
352
|
-
"astro:config:setup": ({ command: i, config:
|
|
353
|
-
const
|
|
354
|
-
console.log("[strifeIntegration] envOptions:", JSON.stringify(
|
|
355
|
-
const
|
|
356
|
-
...
|
|
354
|
+
"astro:config:setup": ({ command: i, config: o, updateConfig: r }) => {
|
|
355
|
+
const a = o.vite.envDir || process.cwd(), t = g(i, a);
|
|
356
|
+
console.log("[strifeIntegration] envOptions:", JSON.stringify(t, null, 2)), e ? console.log("[strifeIntegration] options passed by user:", JSON.stringify(e, null, 2)) : console.log("[strifeIntegration] No options explicitly passed.");
|
|
357
|
+
const n = {
|
|
358
|
+
...T,
|
|
357
359
|
...Object.fromEntries(
|
|
358
|
-
Object.entries(
|
|
360
|
+
Object.entries(t).filter(([l, d]) => !!d)
|
|
359
361
|
),
|
|
360
362
|
...e ? Object.fromEntries(
|
|
361
|
-
Object.entries(e).filter(([
|
|
363
|
+
Object.entries(e).filter(([l, d]) => !!d)
|
|
362
364
|
) : {}
|
|
363
365
|
};
|
|
364
|
-
console.log("[strifeIntegration] Final mergedOptions:", JSON.stringify(
|
|
366
|
+
console.log("[strifeIntegration] Final mergedOptions:", JSON.stringify(n, null, 2));
|
|
365
367
|
const c = ["urls", "database", "certificate", "password"], u = c.filter(
|
|
366
|
-
(
|
|
368
|
+
(l) => !n[l] || Array.isArray(n[l]) && n[l].length === 0
|
|
367
369
|
);
|
|
368
370
|
if (u.length > 0)
|
|
369
371
|
throw new Error(
|
|
370
372
|
`[strifeIntegration] Missing required environment variables: ${u.join(", ")}.
|
|
371
373
|
Set them in your .env file (for local) or Vercel project settings (for deployment).
|
|
372
374
|
Current values:
|
|
373
|
-
` + c.map((
|
|
375
|
+
` + c.map((l) => ` ${l}: ${JSON.stringify(n[l])}`).join(`
|
|
374
376
|
`)
|
|
375
377
|
);
|
|
376
378
|
r({
|
|
377
379
|
vite: {
|
|
378
380
|
plugins: [
|
|
379
|
-
|
|
381
|
+
h(n)
|
|
380
382
|
]
|
|
381
383
|
}
|
|
382
384
|
});
|
|
@@ -385,5 +387,5 @@ Current values:
|
|
|
385
387
|
};
|
|
386
388
|
}
|
|
387
389
|
export {
|
|
388
|
-
|
|
390
|
+
v as default
|
|
389
391
|
};
|