qarpeo 0.3.2 → 0.3.4

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.
@@ -11,7 +11,7 @@ import { useRuntimeConfig } from 'nuxt/server';
11
11
  import { mkdir, writeFile, readFile } from 'node:fs/promises';
12
12
  import { defu } from 'defu';
13
13
 
14
- const version = "0.3.2";
14
+ const version = "0.3.4";
15
15
 
16
16
  function resolveBindingName(service, override, defaultName) {
17
17
  if (override && typeof override === "string") {
package/dist/module.mjs CHANGED
@@ -6,8 +6,8 @@ import { x as resolveTableName, y as resolveIndexName, z as buildDevWranglerConf
6
6
  export { A as ALL_CMS_TABLE_NAMES, d as ALL_COMMENTS_TABLE_NAMES, c as ALL_STORE_TABLE_NAMES, M as cmsBookmarks, N as cmsCategories, O as cmsCollections, P as cmsEntries, Q as cmsRevisions, R as cmsSubscribers, S as cmsTags, b as getActiveAuthTableNames, T as getActiveCmsTableNames, U as getActiveCommentsTableNames, V as getActiveStoreTableNames, W as hasDatabaseSchema, r as resolveDatabaseTarget, k as resolveProjectName } from './chunks/tools.mjs';
7
7
  import { createHash } from 'node:crypto';
8
8
  import { readdir, readFile } from 'node:fs/promises';
9
- import { downloadTemplate } from 'giget';
10
9
  import { createRequire } from 'node:module';
10
+ import { downloadTemplate } from 'giget';
11
11
  import { fileURLToPath } from 'node:url';
12
12
  import 'node:child_process';
13
13
  import 'drizzle-orm/node-sqlite';
@@ -462,10 +462,14 @@ async function resolveAllCmsSources(options) {
462
462
  return resolvedList;
463
463
  }
464
464
 
465
+ let _yamlMod = null;
465
466
  function _requireYamlSync() {
467
+ if (_yamlMod) return _yamlMod;
466
468
  try {
467
- const m = require("yaml");
468
- return { parse: m.parse };
469
+ const req = createRequire(import.meta.url);
470
+ const m = req("yaml");
471
+ _yamlMod = { parse: m.parse };
472
+ return _yamlMod;
469
473
  } catch {
470
474
  throw new Error(
471
475
  `[qarpeo] CMS content scanning requires the \`yaml\` package.
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  import { useRuntimeConfig } from "nuxt/server";
2
3
  import { getQarpeoConfig } from "../config.mjs";
3
4
  function _requireComark() {
@@ -14,10 +15,14 @@ Install it with: pnpm add comark`
14
15
  );
15
16
  });
16
17
  }
18
+ let _yamlMod = null;
17
19
  function _requireYamlSync() {
20
+ if (_yamlMod) return _yamlMod;
18
21
  try {
19
- const m = require("yaml");
20
- return { parse: m.parse, stringify: m.stringify };
22
+ const req = typeof require !== "undefined" ? require : createRequire(import.meta.url);
23
+ const m = req("yaml");
24
+ _yamlMod = { parse: m.parse, stringify: m.stringify };
25
+ return _yamlMod;
21
26
  } catch {
22
27
  throw new Error(
23
28
  `[qarpeo] CMS frontmatter parsing requires the \`yaml\` package.
@@ -1,4 +1,13 @@
1
- const _yaml = () => require("yaml");
1
+ async function _requireYaml() {
2
+ try {
3
+ return await import("yaml");
4
+ } catch {
5
+ throw new Error(
6
+ `[qarpeo] CMS sync requires the \`yaml\` package.
7
+ Install it with: pnpm add yaml`
8
+ );
9
+ }
10
+ }
2
11
  import { getKVBinding } from "../../../kv.mjs";
3
12
  import { resolveIndexName } from "../table-names.mjs";
4
13
  import {
@@ -430,7 +439,7 @@ export async function syncLocalContentFiles(event, contentDir, collectionsConfig
430
439
  if (existsSync(navYmlPath)) {
431
440
  try {
432
441
  const raw = await readFile(navYmlPath);
433
- return _yaml().parse(raw) || {};
442
+ return (await _requireYaml()).parse(raw) || {};
434
443
  } catch {
435
444
  }
436
445
  }
@@ -778,7 +787,7 @@ export async function syncLocalContentFiles(event, contentDir, collectionsConfig
778
787
  }
779
788
  } else {
780
789
  try {
781
- parsed = _yaml().parse(rawContent) || {};
790
+ parsed = (await _requireYaml()).parse(rawContent) || {};
782
791
  } catch {
783
792
  }
784
793
  }
@@ -1,6 +1,5 @@
1
1
  import { defineRelations } from "drizzle-orm";
2
2
  import { drizzle as drizzleD1 } from "drizzle-orm/d1";
3
- import { drizzle as drizzlePostgres } from "drizzle-orm/postgres-js";
4
3
  import * as _schema from "#qarpeo/schema";
5
4
  import { getD1Binding, getDatabaseInfo } from "../../index.mjs";
6
5
  import { createReplicaRoutedD1 } from "../../replica.mjs";
@@ -41,15 +40,18 @@ export function useDrizzle(bindingNameOrOptions, eventOrOptions) {
41
40
  const dbInfo = getDatabaseInfo(bindingName, event);
42
41
  if (dbInfo.isPostgres && dbInfo.url) {
43
42
  let postgresLib;
43
+ let drizzlePostgres;
44
44
  try {
45
45
  const req = globalThis.require || (typeof globalThis.process !== "undefined" && typeof require !== "undefined" ? require : void 0);
46
46
  if (req) {
47
47
  const pgMod = req("postgres");
48
48
  postgresLib = pgMod?.default || pgMod;
49
+ const pgDrizzleMod = req("drizzle-orm/postgres-js");
50
+ drizzlePostgres = pgDrizzleMod?.drizzle || pgDrizzleMod?.default?.drizzle;
49
51
  }
50
52
  } catch {
51
53
  }
52
- if (!postgresLib) {
54
+ if (!postgresLib || !drizzlePostgres) {
53
55
  throw new Error(
54
56
  `[qarpeo] PostgreSQL runtime client requires the \`postgres\` package.
55
57
  Install it with: pnpm add postgres`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qarpeo",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Zero-config Cloudflare Edge Platform for Nuxt",
5
5
  "keywords": [
6
6
  "analytics-engine",