@strifeapp/astro 1.0.12 → 1.0.14
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 +48 -43
- 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
|
|
@@ -261,39 +261,39 @@ function storeAs(name, value) {
|
|
|
261
261
|
});
|
|
262
262
|
|
|
263
263
|
return result;
|
|
264
|
-
}`,
|
|
265
|
-
function h(
|
|
266
|
-
return {
|
|
264
|
+
}`, m = "strife:store", p = "\0" + m;
|
|
265
|
+
function h(e) {
|
|
266
|
+
return console.log("[vitePluginStrifeStore] Config received:", JSON.stringify(e, null, 2)), {
|
|
267
267
|
name: "strife:store",
|
|
268
|
-
resolveId(
|
|
269
|
-
if (
|
|
270
|
-
return
|
|
268
|
+
resolveId(l) {
|
|
269
|
+
if (l === m)
|
|
270
|
+
return p;
|
|
271
271
|
},
|
|
272
|
-
load(
|
|
272
|
+
load(l) {
|
|
273
273
|
var o;
|
|
274
|
-
if (
|
|
275
|
-
return `
|
|
274
|
+
if (l === p)
|
|
275
|
+
return console.log("[vitePluginStrifeStore] Generating virtual module code with config:", JSON.stringify(e, null, 2)), `
|
|
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(e.certificate)}, 'base64'),
|
|
281
|
+
password: ${d(e.password)},
|
|
282
282
|
};
|
|
283
283
|
|
|
284
284
|
const store = new DocumentStore(
|
|
285
|
-
${
|
|
286
|
-
${
|
|
285
|
+
${d(e.urls ? e.urls : [])},
|
|
286
|
+
${d(e.database || "")},
|
|
287
287
|
authOptions
|
|
288
|
-
).initialize()
|
|
288
|
+
).initialize();
|
|
289
289
|
|
|
290
290
|
class Content_ByUrl extends AbstractJavaScriptMultiMapIndexCreationTask {
|
|
291
291
|
constructor() {
|
|
292
292
|
super();
|
|
293
293
|
|
|
294
|
-
this.additionalSources = {"Helper": ${
|
|
294
|
+
this.additionalSources = {"Helper": ${d(y)}}
|
|
295
295
|
|
|
296
|
-
${(
|
|
296
|
+
${(e.collections || ["Posts"]).map((t) => `this.map("${typeof t == "string" ? t : t.name}", (doc) => { return mapDocument(doc) });`).join(`
|
|
297
297
|
`)}
|
|
298
298
|
|
|
299
299
|
this.deploymentMode = 'Rolling';
|
|
@@ -302,13 +302,12 @@ function h(n) {
|
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
console.log('Deploying index...');
|
|
305
|
-
|
|
306
305
|
await IndexCreation.createIndexes([new Content_ByUrl()], store);
|
|
307
306
|
|
|
308
307
|
const bulkInsert = store.bulkInsert();
|
|
309
308
|
|
|
310
|
-
${(o =
|
|
311
|
-
await bulkInsert.store(${JSON.stringify(
|
|
309
|
+
${(o = e.collections) == null ? void 0 : o.map((t) => `
|
|
310
|
+
await bulkInsert.store(${JSON.stringify(t)}, 'templates/${t.name}', { '@collection': 'Templates' });
|
|
312
311
|
`).join(`
|
|
313
312
|
`)}
|
|
314
313
|
|
|
@@ -322,45 +321,51 @@ function h(n) {
|
|
|
322
321
|
const T = {
|
|
323
322
|
type: "pfx"
|
|
324
323
|
};
|
|
325
|
-
function
|
|
326
|
-
let o = process.env.STRIFE_DATABASE_URLS,
|
|
327
|
-
if (!o || !
|
|
328
|
-
const
|
|
329
|
-
o = o ||
|
|
324
|
+
function g(e, l) {
|
|
325
|
+
let o = process.env.STRIFE_DATABASE_URLS, t = process.env.STRIFE_DATABASE, r = process.env.STRIFE_CERTIFICATE, a = process.env.STRIFE_CERTIFICATE_PASSWORD;
|
|
326
|
+
if (!o || !t || !r || !a) {
|
|
327
|
+
const n = f(e, l ?? "", "");
|
|
328
|
+
o = o || n.STRIFE_DATABASE_URLS, t = t || n.STRIFE_DATABASE, r = r || n.STRIFE_CERTIFICATE, a = a || n.STRIFE_CERTIFICATE_PASSWORD;
|
|
330
329
|
}
|
|
331
|
-
return {
|
|
332
|
-
urls: o ? o.split(",").map((
|
|
333
|
-
database:
|
|
334
|
-
certificate:
|
|
335
|
-
password:
|
|
330
|
+
return console.log("[strifeIntegration] Loaded environment variables:"), console.log(` STRIFE_DATABASE_URLS: ${o ? "[SET]" : "[NOT SET]"}`), console.log(` STRIFE_DATABASE: ${t || "[NOT SET]"}`), console.log(` STRIFE_CERTIFICATE: ${r ? `[SET, length=${r.length}]` : "[NOT SET]"}`), console.log(` STRIFE_CERTIFICATE_PASSWORD: ${a ? "[SET]" : "[NOT SET]"}`), {
|
|
331
|
+
urls: o ? o.split(",").map((n) => n.trim()).filter(Boolean) : void 0,
|
|
332
|
+
database: t || void 0,
|
|
333
|
+
certificate: r || void 0,
|
|
334
|
+
password: a || void 0
|
|
336
335
|
};
|
|
337
336
|
}
|
|
338
|
-
function
|
|
337
|
+
function E(e) {
|
|
339
338
|
return {
|
|
340
339
|
name: "@strife/astro",
|
|
341
340
|
hooks: {
|
|
342
|
-
"astro:config:setup": ({ command:
|
|
343
|
-
const
|
|
341
|
+
"astro:config:setup": ({ command: l, config: o, updateConfig: t }) => {
|
|
342
|
+
const r = o.vite.envDir || process.cwd(), a = g(l, r);
|
|
343
|
+
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.");
|
|
344
|
+
const n = {
|
|
344
345
|
...T,
|
|
345
346
|
...Object.fromEntries(
|
|
346
|
-
Object.entries(
|
|
347
|
+
Object.entries(a).filter(([s, i]) => !!i)
|
|
347
348
|
),
|
|
348
|
-
...
|
|
349
|
-
|
|
350
|
-
|
|
349
|
+
...e ? Object.fromEntries(
|
|
350
|
+
Object.entries(e).filter(([s, i]) => !!i)
|
|
351
|
+
) : {}
|
|
352
|
+
};
|
|
353
|
+
console.log("[strifeIntegration] Final mergedOptions:", JSON.stringify(n, null, 2));
|
|
354
|
+
const c = ["urls", "database", "certificate", "password"], u = c.filter(
|
|
355
|
+
(s) => !n[s] || Array.isArray(n[s]) && n[s].length === 0
|
|
351
356
|
);
|
|
352
|
-
if (
|
|
357
|
+
if (u.length > 0)
|
|
353
358
|
throw new Error(
|
|
354
|
-
`[strifeIntegration] Missing required environment variables: ${
|
|
359
|
+
`[strifeIntegration] Missing required environment variables: ${u.join(", ")}.
|
|
355
360
|
Set them in your .env file (for local) or Vercel project settings (for deployment).
|
|
356
361
|
Current values:
|
|
357
|
-
` +
|
|
362
|
+
` + c.map((s) => ` ${s}: ${JSON.stringify(n[s])}`).join(`
|
|
358
363
|
`)
|
|
359
364
|
);
|
|
360
|
-
|
|
365
|
+
t({
|
|
361
366
|
vite: {
|
|
362
367
|
plugins: [
|
|
363
|
-
h(
|
|
368
|
+
h(n)
|
|
364
369
|
]
|
|
365
370
|
}
|
|
366
371
|
});
|
|
@@ -369,5 +374,5 @@ Current values:
|
|
|
369
374
|
};
|
|
370
375
|
}
|
|
371
376
|
export {
|
|
372
|
-
|
|
377
|
+
E as default
|
|
373
378
|
};
|