@nqlib/nqui 0.4.0 → 0.4.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.
package/package.json
CHANGED
|
@@ -59,11 +59,24 @@ function getWorkspacePackageDirs(workspaceRoot) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function isNquiSourceDir(dir) {
|
|
62
|
+
// Must NOT be inside node_modules (that means we're installed as a dep, not dev source)
|
|
63
|
+
if (resolve(dir).includes('node_modules')) return false;
|
|
62
64
|
return existsSync(resolve(dir, 'docs/components/README.md')) &&
|
|
63
65
|
existsSync(resolve(dir, 'package.json')) &&
|
|
64
66
|
readFileSync(resolve(dir, 'package.json'), 'utf8').includes('"name": "@nqlib/nqui"');
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
function findProjectRootFromNodeModules(startDir) {
|
|
70
|
+
let dir = resolve(startDir);
|
|
71
|
+
for (let i = 0; i < 20; i++) {
|
|
72
|
+
if (existsSync(resolve(dir, 'node_modules/@nqlib/nqui'))) return dir;
|
|
73
|
+
const parent = dirname(dir);
|
|
74
|
+
if (parent === dir) break;
|
|
75
|
+
dir = parent;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
67
80
|
/**
|
|
68
81
|
* Returns the directory where .cursor/ should be written.
|
|
69
82
|
* Prefers a dir with node_modules/@nqlib/nqui so docs path resolves.
|
|
@@ -72,7 +85,13 @@ function isNquiSourceDir(dir) {
|
|
|
72
85
|
* @returns {string} Absolute path to target directory
|
|
73
86
|
*/
|
|
74
87
|
export function resolveTargetDir(startDir) {
|
|
75
|
-
|
|
88
|
+
let cwd = resolve(startDir);
|
|
89
|
+
|
|
90
|
+
// 0. Running from node_modules (postinstall as dep) -> use host project root
|
|
91
|
+
if (cwd.includes('node_modules')) {
|
|
92
|
+
const projectRoot = findProjectRootFromNodeModules(cwd);
|
|
93
|
+
if (projectRoot) return projectRoot;
|
|
94
|
+
}
|
|
76
95
|
|
|
77
96
|
// 1. Current dir has nqui in node_modules -> use it
|
|
78
97
|
if (hasNquiInNodeModules(cwd)) return cwd;
|