@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.
@@ -18,7 +18,7 @@ export declare class RouteScanner {
18
18
  private workspaceRoot;
19
19
  constructor(workspaceRoot: string);
20
20
  /**
21
- * Perform initial scan of the pages directory.
21
+ * Perform initial scan of all pages directories in the workspace.
22
22
  */
23
23
  scan(): void;
24
24
  /**
@@ -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 the pages directory.
135
+ * Perform initial scan of all pages directories in the workspace.
101
136
  */
102
137
  scan() {
103
- const pagesDir = path.join(this.workspaceRoot, 'src', 'app', 'pages');
104
- const pageFiles = collectFiles(pagesDir, (name) => name.endsWith('.page.ts'));
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');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@analogjs/language-server",
3
3
  "description": "LSP server for AnalogJS Language Service",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "main": "out/index.js",
6
6
  "license": "MIT",
7
7
  "scripts": {