@strifeapp/astro 1.0.11 → 1.0.13

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.
Files changed (2) hide show
  1. package/dist/index.js +55 -45
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { loadEnv as h } from "vite";
2
- import r from "serialize-javascript";
3
- const T = `/**
1
+ import { loadEnv as f } from "vite";
2
+ import d from "serialize-javascript";
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
6
6
  * @param {any} value - Value to index and store
@@ -261,29 +261,29 @@ function storeAs(name, value) {
261
261
  });
262
262
 
263
263
  return result;
264
- }`, u = "strife:store", i = "\0" + u;
265
- function R(e) {
264
+ }`, p = "strife:store", u = "\0" + p;
265
+ function h(n) {
266
266
  return {
267
267
  name: "strife:store",
268
- resolveId(o) {
269
- if (o === u)
270
- return i;
268
+ resolveId(a) {
269
+ if (a === p)
270
+ return u;
271
271
  },
272
- load(o) {
273
- var s;
274
- if (o === i)
272
+ load(a) {
273
+ var o;
274
+ if (a === u)
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(${r(e.certificate)}, 'base64'),
281
- password: ${r(e.password)},
280
+ certificate: Buffer.from(${d(n.certificate)}, 'base64'),
281
+ password: ${d(n.password)},
282
282
  };
283
283
 
284
284
  const store = new DocumentStore(
285
- ${r(e.urls ? e.urls : [])},
286
- ${r(e.database || "")},
285
+ ${d(n.urls ? n.urls : [])},
286
+ ${d(n.database || "")},
287
287
  authOptions
288
288
  ).initialize()
289
289
 
@@ -291,9 +291,9 @@ function R(e) {
291
291
  constructor() {
292
292
  super();
293
293
 
294
- this.additionalSources = {"Helper": ${r(T)}}
294
+ this.additionalSources = {"Helper": ${d(y)}}
295
295
 
296
- ${(e.collections || ["Posts"]).map((t) => `this.map("${typeof t == "string" ? t : t.name}", (doc) => { return mapDocument(doc) });`).join(`
296
+ ${(n.collections || ["Posts"]).map((e) => `this.map("${typeof e == "string" ? e : e.name}", (doc) => { return mapDocument(doc) });`).join(`
297
297
  `)}
298
298
 
299
299
  this.deploymentMode = 'Rolling';
@@ -307,8 +307,8 @@ function R(e) {
307
307
 
308
308
  const bulkInsert = store.bulkInsert();
309
309
 
310
- ${(s = e.collections) == null ? void 0 : s.map((t) => `
311
- await bulkInsert.store(${JSON.stringify(t)}, 'templates/${t.name}', { '@collection': 'Templates' });
310
+ ${(o = n.collections) == null ? void 0 : o.map((e) => `
311
+ await bulkInsert.store(${JSON.stringify(e)}, 'templates/${e.name}', { '@collection': 'Templates' });
312
312
  `).join(`
313
313
  `)}
314
314
 
@@ -319,38 +319,48 @@ function R(e) {
319
319
  }
320
320
  };
321
321
  }
322
- const A = {
322
+ const T = {
323
323
  type: "pfx"
324
324
  };
325
- function E(e) {
325
+ function R(n, a) {
326
+ let o = process.env.STRIFE_DATABASE_URLS, e = process.env.STRIFE_DATABASE, r = process.env.STRIFE_CERTIFICATE, s = process.env.STRIFE_CERTIFICATE_PASSWORD;
327
+ if (!o || !e || !r || !s) {
328
+ const t = f(n, a ?? "", "");
329
+ o = o || t.STRIFE_DATABASE_URLS, e = e || t.STRIFE_DATABASE, r = r || t.STRIFE_CERTIFICATE, s = s || t.STRIFE_CERTIFICATE_PASSWORD;
330
+ }
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: ${s ? "[SET]" : "[NOT SET]"}`), {
332
+ urls: o ? o.split(",").map((t) => t.trim()).filter(Boolean) : void 0,
333
+ database: e || void 0,
334
+ certificate: r || void 0,
335
+ password: s || void 0
336
+ };
337
+ }
338
+ function I(n) {
326
339
  return {
327
340
  name: "@strife/astro",
328
341
  hooks: {
329
- "astro:config:setup": ({ command: o, config: s, updateConfig: t }) => {
330
- let n = process.env.STRIFE_DATABASE_URLS, d = process.env.STRIFE_DATABASE, l = process.env.STRIFE_CERTIFICATE, c = process.env.STRIFE_CERTIFICATE_PASSWORD;
331
- if (!n || !d || !l || !c) {
332
- const a = h(o, s.vite.envDir ?? "", "");
333
- n = n || a.STRIFE_DATABASE_URLS, d = d || a.STRIFE_DATABASE, l = l || a.STRIFE_CERTIFICATE, c = c || a.STRIFE_CERTIFICATE_PASSWORD;
334
- }
335
- const p = {
336
- urls: n == null ? void 0 : n.split(","),
337
- database: d,
338
- certificate: l,
339
- password: c
340
- }, m = Object.fromEntries(
341
- Object.entries(p).filter(([a, y]) => y !== void 0)
342
- ), f = {
343
- ...A,
344
- // Base defaults
345
- ...m,
346
- // Environment variables override defaults
347
- ...e
348
- // Explicit options override everything
349
- };
350
- t({
342
+ "astro:config:setup": ({ command: a, config: o, updateConfig: e }) => {
343
+ const r = o.vite.envDir || process.cwd(), s = R(a, r), t = {
344
+ ...T,
345
+ ...Object.fromEntries(
346
+ Object.entries(s).filter(([l, m]) => !!m)
347
+ ),
348
+ ...n
349
+ }, i = ["urls", "database", "certificate", "password"], c = i.filter(
350
+ (l) => !t[l] || Array.isArray(t[l]) && t[l].length === 0
351
+ );
352
+ if (c.length > 0)
353
+ throw new Error(
354
+ `[strifeIntegration] Missing required environment variables: ${c.join(", ")}.
355
+ Set them in your .env file (for local) or Vercel project settings (for deployment).
356
+ Current values:
357
+ ` + i.map((l) => ` ${l}: ${JSON.stringify(t[l])}`).join(`
358
+ `)
359
+ );
360
+ e({
351
361
  vite: {
352
362
  plugins: [
353
- R(f)
363
+ h(t)
354
364
  ]
355
365
  }
356
366
  });
@@ -359,5 +369,5 @@ function E(e) {
359
369
  };
360
370
  }
361
371
  export {
362
- E as default
372
+ I as default
363
373
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strifeapp/astro",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Official Strife Astro integration",
5
5
  "keywords": [
6
6
  "astro-integration",