@vitnode/core 1.2.0-canary.42 → 1.2.0-canary.44
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drizzle.config.d.ts","sourceRoot":"","sources":["../../src/drizzle.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,eAAO,MAAM,0BAA0B,GAAI,+BAGxC,MAAM,GAAG;IACV,gBAAgB,EAAE,gBAAgB,CAAC;CACpC,
|
|
1
|
+
{"version":3,"file":"drizzle.config.d.ts","sourceRoot":"","sources":["../../src/drizzle.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,eAAO,MAAM,0BAA0B,GAAI,+BAGxC,MAAM,GAAG;IACV,gBAAgB,EAAE,gBAAgB,CAAC;CACpC,WA6EA,CAAC"}
|
|
@@ -3,16 +3,24 @@ import { existsSync, readdirSync } from "fs";
|
|
|
3
3
|
import { join, resolve } from "path";
|
|
4
4
|
export const defineVitNodeDrizzleConfig = ({ vitNodeApiConfig, ...args })=>{
|
|
5
5
|
const pluginId = vitNodeApiConfig.plugins.map((plugin)=>plugin.pluginId);
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const findMonorepoRoot = (startPath)=>{
|
|
7
|
+
let currentPath = startPath;
|
|
8
|
+
while(currentPath !== resolve(currentPath, '..')){
|
|
9
|
+
const turboConfigPath = join(currentPath, 'turbo.json');
|
|
10
|
+
if (existsSync(turboConfigPath)) {
|
|
11
|
+
return currentPath;
|
|
12
|
+
}
|
|
13
|
+
currentPath = resolve(currentPath, '..');
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
const checkPluginPath = (basePath, itemId)=>{
|
|
18
|
+
const pluginPath = resolve(basePath, 'node_modules', itemId, 'dist', 'src', 'database');
|
|
11
19
|
// Check if the plugin path exists
|
|
12
20
|
if (!existsSync(pluginPath)) {
|
|
13
21
|
return null;
|
|
14
22
|
}
|
|
15
|
-
// Check if there are any .
|
|
23
|
+
// Check if there are any .js files in the directory
|
|
16
24
|
try {
|
|
17
25
|
const files = readdirSync(pluginPath);
|
|
18
26
|
const hasSchemaFiles = files.some((file)=>file.endsWith('.js'));
|
|
@@ -22,6 +30,23 @@ export const defineVitNodeDrizzleConfig = ({ vitNodeApiConfig, ...args })=>{
|
|
|
22
30
|
} catch {
|
|
23
31
|
return null;
|
|
24
32
|
}
|
|
33
|
+
};
|
|
34
|
+
const cwd = process.cwd();
|
|
35
|
+
const monorepoRoot = findMonorepoRoot(cwd);
|
|
36
|
+
const pluginPaths = [
|
|
37
|
+
'@vitnode/core',
|
|
38
|
+
...pluginId
|
|
39
|
+
].flatMap((itemId)=>{
|
|
40
|
+
const paths = [];
|
|
41
|
+
// Check in current working directory
|
|
42
|
+
const cwdPath = checkPluginPath(cwd, itemId);
|
|
43
|
+
if (cwdPath) paths.push(cwdPath);
|
|
44
|
+
// Check in monorepo root if it exists and is different from cwd
|
|
45
|
+
if (monorepoRoot && monorepoRoot !== cwd) {
|
|
46
|
+
const rootPath = checkPluginPath(monorepoRoot, itemId);
|
|
47
|
+
if (rootPath) paths.push(rootPath);
|
|
48
|
+
}
|
|
49
|
+
return paths;
|
|
25
50
|
}).filter((pluginPath)=>pluginPath !== null);
|
|
26
51
|
return defineConfig({
|
|
27
52
|
...args,
|