@ontrails/config 0.2.2 → 0.2.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ontrails/config
2
2
 
3
+ ## 0.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`807ebda`](https://github.com/outfitter-dev/trails/commit/807ebdaeabfee0cd06539dc9b86e3ba9a817ab40): Keep Warden scoped to the nearest fresh Trails app when a parent has another Trails source marker, and pass the operator's resolved project root to the shared Warden command.
8
+
3
9
  ## 0.2.2
4
10
 
5
11
  No changes in this release.
package/README.md CHANGED
@@ -99,6 +99,8 @@ Each layer overrides the previous. Environment variables always win.
99
99
  - `trails.lock`
100
100
  - source-shaped projects with `src/trails/` or `trails/` when no committed marker exists above them
101
101
 
102
+ A nested `trails/` directory inside another project's `src/` does not take over source-only root discovery unless its parent has its own `package.json`, `src/app.ts`, or `.git` marker. Use an explicit root for a nested project without one of those markers.
103
+
102
104
  `trails.config.local.*` is a per-developer override and does not mark a project root by itself. A bare `.trails/` directory also does not mark a root; it is the committed-control home for project-local sections after a project root is known.
103
105
 
104
106
  ## Workspace app identity
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ontrails/config",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/outfitter-dev/trails.git",
@@ -27,11 +27,11 @@
27
27
  "clean": "rm -rf dist *.tsbuildinfo"
28
28
  },
29
29
  "dependencies": {
30
- "@ontrails/source": "^0.2.2",
30
+ "@ontrails/source": "^0.2.3",
31
31
  "yaml": "^2.8.3"
32
32
  },
33
33
  "peerDependencies": {
34
- "@ontrails/core": "^0.2.2",
34
+ "@ontrails/core": "^0.2.3",
35
35
  "zod": "^4.3.5"
36
36
  }
37
37
  }
@@ -159,6 +159,39 @@ const findSourceRootMarkerIn = (
159
159
  return undefined;
160
160
  };
161
161
 
162
+ const isIncidentalNestedSourceRoot = (
163
+ fallback: TrailsProjectRootResolution,
164
+ ancestorRoot: string,
165
+ ancestorMarkerPath: string
166
+ ): boolean => {
167
+ if (
168
+ (ancestorMarkerPath !== join(ancestorRoot, 'src', 'trails') &&
169
+ ancestorMarkerPath !== join(ancestorRoot, 'trails')) ||
170
+ fallback.markerPath !== join(fallback.rootDir, 'trails') ||
171
+ !isWithinBoundary(join(ancestorRoot, 'src'), fallback.rootDir)
172
+ ) {
173
+ return false;
174
+ }
175
+
176
+ return (
177
+ !isFile(join(fallback.rootDir, 'package.json')) &&
178
+ !isFile(join(fallback.rootDir, trailsAppEntryRelativePath)) &&
179
+ !isFile(join(fallback.rootDir, '.git')) &&
180
+ !isDirectory(join(fallback.rootDir, '.git'))
181
+ );
182
+ };
183
+
184
+ const shouldPreferSourceRoot = (
185
+ fallback: TrailsProjectRootResolution | undefined,
186
+ marker: Omit<TrailsProjectRootResolution, 'rootDir'> | undefined,
187
+ rootDir: string
188
+ ): boolean =>
189
+ marker !== undefined &&
190
+ (fallback === undefined ||
191
+ fallback.markerPath === marker.markerPath ||
192
+ (marker.markerPath !== undefined &&
193
+ isIncidentalNestedSourceRoot(fallback, rootDir, marker.markerPath)));
194
+
162
195
  export const findTrailsProjectRoot = ({
163
196
  boundaryDir,
164
197
  startDir = process.cwd(),
@@ -195,7 +228,12 @@ export const findTrailsProjectRoot = ({
195
228
  }
196
229
 
197
230
  const sourceMarker = findSourceRootMarkerIn(current);
198
- if (sourceMarker !== undefined) {
231
+ if (
232
+ sourceMarker !== undefined &&
233
+ shouldPreferSourceRoot(sourceFallback, sourceMarker, current)
234
+ ) {
235
+ // src/trails also looks like a trails root from src; keep the outer owner
236
+ // when both markers point there or the inner marker is incidental.
199
237
  sourceFallback = { ...sourceMarker, rootDir: current };
200
238
  }
201
239