@astrojs/db 0.1.4 → 0.1.5

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/consts.d.ts CHANGED
@@ -3,4 +3,5 @@ export declare const INTERNAL_MOD_IMPORT: string;
3
3
  export declare const DRIZZLE_MOD_IMPORT: string;
4
4
  export declare const DB_TYPES_FILE = "db-types.d.ts";
5
5
  export declare const VIRTUAL_MODULE_ID = "astro:db";
6
+ export declare const DB_PATH = ".astro/content.db";
6
7
  export declare function getLocalDbUrl(root: URL): URL;
package/dist/consts.js CHANGED
@@ -6,10 +6,12 @@ const INTERNAL_MOD_IMPORT = JSON.stringify(`${PACKAGE_NAME}/internal`);
6
6
  const DRIZZLE_MOD_IMPORT = JSON.stringify(`${PACKAGE_NAME}/internal-drizzle`);
7
7
  const DB_TYPES_FILE = "db-types.d.ts";
8
8
  const VIRTUAL_MODULE_ID = "astro:db";
9
+ const DB_PATH = ".astro/content.db";
9
10
  function getLocalDbUrl(root) {
10
- return new URL(".astro/content.db", root);
11
+ return new URL(DB_PATH, root);
11
12
  }
12
13
  export {
14
+ DB_PATH,
13
15
  DB_TYPES_FILE,
14
16
  DRIZZLE_MOD_IMPORT,
15
17
  INTERNAL_MOD_IMPORT,
@@ -36,7 +36,11 @@ function integration() {
36
36
  logger.error(appTokenError);
37
37
  process.exit(0);
38
38
  }
39
- dbPlugin = vitePluginDb({ connectToStudio: true, collections, appToken });
39
+ dbPlugin = vitePluginDb({
40
+ connectToStudio: true,
41
+ collections,
42
+ appToken
43
+ });
40
44
  } else {
41
45
  const dbUrl = getLocalDbUrl(config.root);
42
46
  if (existsSync(dbUrl)) {
@@ -1,4 +1,4 @@
1
- import { DRIZZLE_MOD_IMPORT, INTERNAL_MOD_IMPORT, VIRTUAL_MODULE_ID } from "./consts.js";
1
+ import { DRIZZLE_MOD_IMPORT, INTERNAL_MOD_IMPORT, VIRTUAL_MODULE_ID, DB_PATH } from "./consts.js";
2
2
  const resolvedVirtualModuleId = "\0" + VIRTUAL_MODULE_ID;
3
3
  function vitePluginDb(params) {
4
4
  return {
@@ -26,11 +26,13 @@ function getVirtualModContents({
26
26
  return `
27
27
  import { collectionToTable, createLocalDatabaseClient } from ${INTERNAL_MOD_IMPORT};
28
28
 
29
- export const db = await createLocalDatabaseClient(${JSON.stringify({
29
+ const params = ${JSON.stringify({
30
30
  collections,
31
- dbUrl,
32
31
  seeding: false
33
- })});
32
+ })};
33
+
34
+ params.dbUrl = new URL(${JSON.stringify(DB_PATH)}, 'file://' + process.cwd() + '/');
35
+ export const db = await createLocalDatabaseClient(params);
34
36
 
35
37
  export * from ${DRIZZLE_MOD_IMPORT};
36
38
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/db",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -61,8 +61,8 @@
61
61
  "mocha": "^10.2.0",
62
62
  "typescript": "^5.2.2",
63
63
  "vite": "^4.4.11",
64
- "astro": "4.2.4",
65
- "astro-scripts": "0.0.14"
64
+ "astro-scripts": "0.0.14",
65
+ "astro": "4.2.4"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "astro-scripts build \"src/**/*.ts\" && tsc",