@analogjs/language-server 0.2.1 → 0.2.2
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/out/routeScanner.d.ts +1 -1
- package/out/routeScanner.js +41 -3
- package/package.json +1 -1
package/out/routeScanner.d.ts
CHANGED
package/out/routeScanner.js
CHANGED
|
@@ -88,6 +88,41 @@ function collectFiles(dir, test) {
|
|
|
88
88
|
}
|
|
89
89
|
return results;
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Find all `pages` directories under a root by looking for the
|
|
93
|
+
* `src/app/pages` convention at any nesting depth.
|
|
94
|
+
* Handles both standalone projects (src/app/pages) and monorepos
|
|
95
|
+
* (apps/my-app/src/app/pages, projects/foo/src/app/pages).
|
|
96
|
+
*/
|
|
97
|
+
function findPagesDirs(root) {
|
|
98
|
+
const results = [];
|
|
99
|
+
// Direct project: root/src/app/pages
|
|
100
|
+
const direct = path.join(root, 'src', 'app', 'pages');
|
|
101
|
+
if (fs.existsSync(direct)) {
|
|
102
|
+
results.push(direct);
|
|
103
|
+
}
|
|
104
|
+
// Monorepo: scan common app directories
|
|
105
|
+
const monorepoParents = ['apps', 'projects', 'packages'];
|
|
106
|
+
for (const parent of monorepoParents) {
|
|
107
|
+
const parentDir = path.join(root, parent);
|
|
108
|
+
let entries;
|
|
109
|
+
try {
|
|
110
|
+
entries = fs.readdirSync(parentDir, { withFileTypes: true });
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
for (const entry of entries) {
|
|
116
|
+
if (!entry.isDirectory())
|
|
117
|
+
continue;
|
|
118
|
+
const candidate = path.join(parentDir, entry.name, 'src', 'app', 'pages');
|
|
119
|
+
if (fs.existsSync(candidate)) {
|
|
120
|
+
results.push(candidate);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return results;
|
|
125
|
+
}
|
|
91
126
|
/**
|
|
92
127
|
* Scans the workspace for Analog page files and builds a route map.
|
|
93
128
|
*/
|
|
@@ -97,11 +132,14 @@ class RouteScanner {
|
|
|
97
132
|
this.workspaceRoot = workspaceRoot;
|
|
98
133
|
}
|
|
99
134
|
/**
|
|
100
|
-
* Perform initial scan of
|
|
135
|
+
* Perform initial scan of all pages directories in the workspace.
|
|
101
136
|
*/
|
|
102
137
|
scan() {
|
|
103
|
-
const
|
|
104
|
-
const pageFiles =
|
|
138
|
+
const pagesDirs = findPagesDirs(this.workspaceRoot);
|
|
139
|
+
const pageFiles = [];
|
|
140
|
+
for (const dir of pagesDirs) {
|
|
141
|
+
pageFiles.push(...collectFiles(dir, (name) => name.endsWith('.page.ts')));
|
|
142
|
+
}
|
|
105
143
|
this.routes = pageFiles.map((filePath) => {
|
|
106
144
|
const urlPath = fileToUrlPath(filePath);
|
|
107
145
|
const serverFilePath = filePath.replace(/\.page\.ts$/, '.server.ts');
|