@deessejs/cli 0.5.0 → 0.5.1
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.
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
* not file paths.
|
|
7
7
|
*/
|
|
8
8
|
import * as path from 'node:path';
|
|
9
|
-
import
|
|
9
|
+
import { createRequire } from 'node:module';
|
|
10
10
|
const SCHEMA_PATH = './src/db/schema.ts';
|
|
11
11
|
export { SCHEMA_PATH };
|
|
12
12
|
export async function loadSchema() {
|
|
13
13
|
const schemaPath = path.resolve(process.cwd(), SCHEMA_PATH);
|
|
14
|
-
//
|
|
15
|
-
// This
|
|
16
|
-
|
|
17
|
-
const schemaModule =
|
|
14
|
+
// Use createRequire to load the schema file
|
|
15
|
+
// This handles both ESM and CJS modules correctly
|
|
16
|
+
const require = createRequire(import.meta.url);
|
|
17
|
+
const schemaModule = require(schemaPath);
|
|
18
18
|
// Extract all exports that are schema objects (tables, etc.)
|
|
19
19
|
const schema = {};
|
|
20
20
|
for (const [key, value] of Object.entries(schemaModule)) {
|
|
@@ -26,7 +26,7 @@ export async function loadSchema() {
|
|
|
26
26
|
schema[key] = value;
|
|
27
27
|
}
|
|
28
28
|
if (Object.keys(schema).length === 0) {
|
|
29
|
-
throw new Error(`No schema objects found in ${SCHEMA_PATH}
|
|
29
|
+
throw new Error(`No schema objects found in ${SCHEMA_PATH}.\n` +
|
|
30
30
|
`Please export your Drizzle tables from this file.`);
|
|
31
31
|
}
|
|
32
32
|
return { schema, schemaPath };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-loader.js","sourceRoot":"","sources":["../../src/utils/schema-loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"schema-loader.js","sourceRoot":"","sources":["../../src/utils/schema-loader.ts"],"names":[],"mappings":"AAAA;;;;;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