@strifeapp/astro 1.0.20 → 1.0.22
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 +39 -52
- 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 d 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
|
|
@@ -262,42 +262,38 @@ function storeAs(name, value) {
|
|
|
262
262
|
|
|
263
263
|
return result;
|
|
264
264
|
}`, m = "strife:store", p = "\0" + m;
|
|
265
|
-
function h(
|
|
266
|
-
return
|
|
265
|
+
function h(t) {
|
|
266
|
+
return {
|
|
267
267
|
name: "strife:store",
|
|
268
|
-
resolveId(
|
|
269
|
-
if (
|
|
268
|
+
resolveId(l) {
|
|
269
|
+
if (l === m)
|
|
270
270
|
return p;
|
|
271
271
|
},
|
|
272
|
-
load(
|
|
273
|
-
var o
|
|
274
|
-
if (
|
|
272
|
+
load(l) {
|
|
273
|
+
var o;
|
|
274
|
+
if (l === p)
|
|
275
275
|
return `
|
|
276
276
|
import { DocumentStore, AbstractJavaScriptMultiMapIndexCreationTask, IndexCreation } from "ravendb";
|
|
277
277
|
|
|
278
278
|
const authOptions = {
|
|
279
279
|
type: 'pfx',
|
|
280
|
-
certificate: Buffer.from(${
|
|
281
|
-
password: ${
|
|
280
|
+
certificate: Buffer.from(${d(t.certificate)}, 'base64'),
|
|
281
|
+
password: ${d(t.password)},
|
|
282
282
|
};
|
|
283
283
|
|
|
284
|
-
console.log('[vitePluginStrifeStore] Will attempt to connect to URLs:', ${s(e.urls)});
|
|
285
|
-
console.log('[vitePluginStrifeStore] Using database:', ${s(e.database)});
|
|
286
|
-
console.log('[vitePluginStrifeStore] Certificate length:', ${e.certificate ? e.certificate.length : 0});
|
|
287
|
-
|
|
288
284
|
const store = new DocumentStore(
|
|
289
|
-
${
|
|
290
|
-
${
|
|
285
|
+
${d(t.urls ? t.urls : [])},
|
|
286
|
+
${d(t.database || "")},
|
|
291
287
|
authOptions
|
|
292
|
-
).initialize()
|
|
288
|
+
).initialize()
|
|
293
289
|
|
|
294
290
|
class Content_ByUrl extends AbstractJavaScriptMultiMapIndexCreationTask {
|
|
295
291
|
constructor() {
|
|
296
292
|
super();
|
|
297
293
|
|
|
298
|
-
this.additionalSources = {"Helper": ${
|
|
294
|
+
this.additionalSources = {"Helper": ${d(y)}}
|
|
299
295
|
|
|
300
|
-
${(
|
|
296
|
+
${(t.collections || ["Posts"]).map((e) => `this.map("${typeof e == "string" ? e : e.name}", (doc) => { return mapDocument(doc) });`).join(`
|
|
301
297
|
`)}
|
|
302
298
|
|
|
303
299
|
this.deploymentMode = 'Rolling';
|
|
@@ -306,22 +302,13 @@ function h(e) {
|
|
|
306
302
|
}
|
|
307
303
|
|
|
308
304
|
console.log('Deploying index...');
|
|
309
|
-
console.log('[vitePluginStrifeStore] Generating virtual module code with config:', ${JSON.stringify(e, null, 2)});
|
|
310
|
-
console.log('Test SSR fetch to RavenDB:', ${s(((o = e.urls) == null ? void 0 : o[0]) || "")});
|
|
311
|
-
console.log('Pinging RavenDB server before connecting...');
|
|
312
|
-
try {
|
|
313
|
-
const res = await fetch(${s((r = e.urls) == null ? void 0 : r[0])}, { method: 'GET' });
|
|
314
|
-
console.log('Ping result status:', res.status);
|
|
315
|
-
} catch (err) {
|
|
316
|
-
console.error('Ping failed:', err);
|
|
317
|
-
}
|
|
318
305
|
|
|
319
|
-
await
|
|
306
|
+
//await store.executeIndex(new Content_ByUrl());
|
|
320
307
|
|
|
321
308
|
const bulkInsert = store.bulkInsert();
|
|
322
309
|
|
|
323
|
-
${(
|
|
324
|
-
await bulkInsert.store(${JSON.stringify(
|
|
310
|
+
${(o = t.collections) == null ? void 0 : o.map((e) => `
|
|
311
|
+
await bulkInsert.store(${JSON.stringify(e)}, 'templates/${e.name}', { '@collection': 'Templates' });
|
|
325
312
|
`).join(`
|
|
326
313
|
`)}
|
|
327
314
|
|
|
@@ -332,51 +319,51 @@ function h(e) {
|
|
|
332
319
|
}
|
|
333
320
|
};
|
|
334
321
|
}
|
|
335
|
-
const
|
|
322
|
+
const T = {
|
|
336
323
|
type: "pfx"
|
|
337
324
|
};
|
|
338
|
-
function
|
|
339
|
-
let o = process.env.STRIFE_DATABASE_URLS,
|
|
340
|
-
if (!o || !
|
|
341
|
-
const n = f(
|
|
342
|
-
o = o || n.STRIFE_DATABASE_URLS,
|
|
325
|
+
function g(t, l) {
|
|
326
|
+
let o = process.env.STRIFE_DATABASE_URLS, e = process.env.STRIFE_DATABASE, r = process.env.STRIFE_CERTIFICATE, a = process.env.STRIFE_CERTIFICATE_PASSWORD;
|
|
327
|
+
if (!o || !e || !r || !a) {
|
|
328
|
+
const n = f(t, l ?? "", "");
|
|
329
|
+
o = o || n.STRIFE_DATABASE_URLS, e = e || n.STRIFE_DATABASE, r = r || n.STRIFE_CERTIFICATE, a = a || n.STRIFE_CERTIFICATE_PASSWORD;
|
|
343
330
|
}
|
|
344
|
-
return console.log("[strifeIntegration] Loaded environment variables:"), console.log(` STRIFE_DATABASE_URLS: ${o ? "[SET]" : "[NOT SET]"}`), console.log(` STRIFE_DATABASE: ${
|
|
331
|
+
return console.log("[strifeIntegration] Loaded environment variables:"), console.log(` STRIFE_DATABASE_URLS: ${o ? "[SET]" : "[NOT SET]"}`), console.log(` STRIFE_DATABASE: ${e || "[NOT SET]"}`), console.log(` STRIFE_CERTIFICATE: ${r ? `[SET, length=${r.length}]` : "[NOT SET]"}`), console.log(` STRIFE_CERTIFICATE_PASSWORD: ${a ? "[SET]" : "[NOT SET]"}`), {
|
|
345
332
|
urls: o ? o.split(",").map((n) => n.trim()).filter(Boolean) : void 0,
|
|
346
|
-
database:
|
|
347
|
-
certificate:
|
|
348
|
-
password:
|
|
333
|
+
database: e || void 0,
|
|
334
|
+
certificate: r || void 0,
|
|
335
|
+
password: a || void 0
|
|
349
336
|
};
|
|
350
337
|
}
|
|
351
|
-
function E(
|
|
338
|
+
function E(t) {
|
|
352
339
|
return {
|
|
353
340
|
name: "@strife/astro",
|
|
354
341
|
hooks: {
|
|
355
|
-
"astro:config:setup": ({ command:
|
|
356
|
-
const
|
|
357
|
-
console.log("[strifeIntegration] envOptions:", JSON.stringify(
|
|
342
|
+
"astro:config:setup": ({ command: l, config: o, updateConfig: e }) => {
|
|
343
|
+
const r = o.vite.envDir || process.cwd(), a = g(l, r);
|
|
344
|
+
console.log("[strifeIntegration] envOptions:", JSON.stringify(a, null, 2)), t ? console.log("[strifeIntegration] options passed by user:", JSON.stringify(t, null, 2)) : console.log("[strifeIntegration] No options explicitly passed.");
|
|
358
345
|
const n = {
|
|
359
|
-
...
|
|
346
|
+
...T,
|
|
360
347
|
...Object.fromEntries(
|
|
361
|
-
Object.entries(
|
|
348
|
+
Object.entries(a).filter(([s, i]) => !!i)
|
|
362
349
|
),
|
|
363
|
-
...
|
|
364
|
-
Object.entries(
|
|
350
|
+
...t ? Object.fromEntries(
|
|
351
|
+
Object.entries(t).filter(([s, i]) => !!i)
|
|
365
352
|
) : {}
|
|
366
353
|
};
|
|
367
354
|
console.log("[strifeIntegration] Final mergedOptions:", JSON.stringify(n, null, 2));
|
|
368
355
|
const c = ["urls", "database", "certificate", "password"], u = c.filter(
|
|
369
|
-
(
|
|
356
|
+
(s) => !n[s] || Array.isArray(n[s]) && n[s].length === 0
|
|
370
357
|
);
|
|
371
358
|
if (u.length > 0)
|
|
372
359
|
throw new Error(
|
|
373
360
|
`[strifeIntegration] Missing required environment variables: ${u.join(", ")}.
|
|
374
361
|
Set them in your .env file (for local) or Vercel project settings (for deployment).
|
|
375
362
|
Current values:
|
|
376
|
-
` + c.map((
|
|
363
|
+
` + c.map((s) => ` ${s}: ${JSON.stringify(n[s])}`).join(`
|
|
377
364
|
`)
|
|
378
365
|
);
|
|
379
|
-
|
|
366
|
+
e({
|
|
380
367
|
vite: {
|
|
381
368
|
plugins: [
|
|
382
369
|
h(n)
|