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