@strifeapp/astro 1.0.18 → 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 +28 -29
- 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
|
|
@@ -270,32 +270,25 @@ function h(e) {
|
|
|
270
270
|
return p;
|
|
271
271
|
},
|
|
272
272
|
load(i) {
|
|
273
|
-
var o, r;
|
|
273
|
+
var o, r, a;
|
|
274
274
|
if (i === p)
|
|
275
275
|
return `
|
|
276
276
|
import { DocumentStore, AbstractJavaScriptMultiMapIndexCreationTask, IndexCreation } from "ravendb";
|
|
277
277
|
import https from 'https';
|
|
278
278
|
|
|
279
|
-
https.get(${l(((o = e.urls) == null ? void 0 : o[0]) || "")}, (res) => {
|
|
280
|
-
console.log('Test SSR fetch to RavenDB:', res.statusCode);
|
|
281
|
-
}).on('error', (e) => {
|
|
282
|
-
console.error('SSR network error to RavenDB:', e);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
|
|
286
279
|
const authOptions = {
|
|
287
280
|
type: 'pfx',
|
|
288
|
-
certificate: Buffer.from(${
|
|
289
|
-
password: ${
|
|
281
|
+
certificate: Buffer.from(${s(e.certificate)}, 'base64'),
|
|
282
|
+
password: ${s(e.password)},
|
|
290
283
|
};
|
|
291
284
|
|
|
292
|
-
console.log('[vitePluginStrifeStore] Will attempt to connect to URLs:', ${
|
|
293
|
-
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)});
|
|
294
287
|
console.log('[vitePluginStrifeStore] Certificate length:', ${e.certificate ? e.certificate.length : 0});
|
|
295
288
|
|
|
296
289
|
const store = new DocumentStore(
|
|
297
|
-
${
|
|
298
|
-
${
|
|
290
|
+
${s(e.urls ? e.urls : [])},
|
|
291
|
+
${s(e.database || "")},
|
|
299
292
|
authOptions
|
|
300
293
|
).initialize();
|
|
301
294
|
|
|
@@ -303,7 +296,7 @@ function h(e) {
|
|
|
303
296
|
constructor() {
|
|
304
297
|
super();
|
|
305
298
|
|
|
306
|
-
this.additionalSources = {"Helper": ${
|
|
299
|
+
this.additionalSources = {"Helper": ${s(y)}}
|
|
307
300
|
|
|
308
301
|
${(e.collections || ["Posts"]).map((t) => `this.map("${typeof t == "string" ? t : t.name}", (doc) => { return mapDocument(doc) });`).join(`
|
|
309
302
|
`)}
|
|
@@ -315,12 +308,18 @@ function h(e) {
|
|
|
315
308
|
|
|
316
309
|
console.log('Deploying index...');
|
|
317
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
|
+
});
|
|
318
317
|
|
|
319
318
|
await IndexCreation.createIndexes([new Content_ByUrl()], store);
|
|
320
319
|
|
|
321
320
|
const bulkInsert = store.bulkInsert();
|
|
322
321
|
|
|
323
|
-
${(
|
|
322
|
+
${(a = e.collections) == null ? void 0 : a.map((t) => `
|
|
324
323
|
await bulkInsert.store(${JSON.stringify(t)}, 'templates/${t.name}', { '@collection': 'Templates' });
|
|
325
324
|
`).join(`
|
|
326
325
|
`)}
|
|
@@ -336,16 +335,16 @@ const T = {
|
|
|
336
335
|
type: "pfx"
|
|
337
336
|
};
|
|
338
337
|
function g(e, i) {
|
|
339
|
-
let o = process.env.STRIFE_DATABASE_URLS, r = process.env.STRIFE_DATABASE,
|
|
340
|
-
if (!o || !r || !
|
|
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) {
|
|
341
340
|
const n = f(e, i ?? "", "");
|
|
342
|
-
o = o || n.STRIFE_DATABASE_URLS, r = r || n.STRIFE_DATABASE,
|
|
341
|
+
o = o || n.STRIFE_DATABASE_URLS, r = r || n.STRIFE_DATABASE, a = a || n.STRIFE_CERTIFICATE, t = t || n.STRIFE_CERTIFICATE_PASSWORD;
|
|
343
342
|
}
|
|
344
|
-
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: ${
|
|
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]"}`), {
|
|
345
344
|
urls: o ? o.split(",").map((n) => n.trim()).filter(Boolean) : void 0,
|
|
346
345
|
database: r || void 0,
|
|
347
|
-
certificate:
|
|
348
|
-
password:
|
|
346
|
+
certificate: a || void 0,
|
|
347
|
+
password: t || void 0
|
|
349
348
|
};
|
|
350
349
|
}
|
|
351
350
|
function v(e) {
|
|
@@ -353,27 +352,27 @@ function v(e) {
|
|
|
353
352
|
name: "@strife/astro",
|
|
354
353
|
hooks: {
|
|
355
354
|
"astro:config:setup": ({ command: i, config: o, updateConfig: r }) => {
|
|
356
|
-
const
|
|
357
|
-
console.log("[strifeIntegration] envOptions:", JSON.stringify(
|
|
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.");
|
|
358
357
|
const n = {
|
|
359
358
|
...T,
|
|
360
359
|
...Object.fromEntries(
|
|
361
|
-
Object.entries(
|
|
360
|
+
Object.entries(t).filter(([l, d]) => !!d)
|
|
362
361
|
),
|
|
363
362
|
...e ? Object.fromEntries(
|
|
364
|
-
Object.entries(e).filter(([
|
|
363
|
+
Object.entries(e).filter(([l, d]) => !!d)
|
|
365
364
|
) : {}
|
|
366
365
|
};
|
|
367
366
|
console.log("[strifeIntegration] Final mergedOptions:", JSON.stringify(n, null, 2));
|
|
368
367
|
const c = ["urls", "database", "certificate", "password"], u = c.filter(
|
|
369
|
-
(
|
|
368
|
+
(l) => !n[l] || Array.isArray(n[l]) && n[l].length === 0
|
|
370
369
|
);
|
|
371
370
|
if (u.length > 0)
|
|
372
371
|
throw new Error(
|
|
373
372
|
`[strifeIntegration] Missing required environment variables: ${u.join(", ")}.
|
|
374
373
|
Set them in your .env file (for local) or Vercel project settings (for deployment).
|
|
375
374
|
Current values:
|
|
376
|
-
` + c.map((
|
|
375
|
+
` + c.map((l) => ` ${l}: ${JSON.stringify(n[l])}`).join(`
|
|
377
376
|
`)
|
|
378
377
|
);
|
|
379
378
|
r({
|