Skip to content

Commit d84c681

Browse files
bpamiriclaude
andauthored
fix(config): walk up two levels for monorepo box.json in $readFrameworkVersion (closes #2291) (#2293)
The default rootBoxJsonPath resolved "../box.json" from Global.cfc's directory (vendor/wheels/), pointing at vendor/box.json which does not exist. At runtime boot via onapplicationstart.cfc — where the helper is called with no arguments — this silently fell through to "0.0.0-dev" even inside a wheels-dev/wheels checkout. Walking up two levels reaches <repo-root>/box.json so application.wheels.version now resolves to "<rootversion>-dev" as intended. Adds a regression spec that asserts application.wheels.version at boot (rather than invoking the helper directly), because WheelsTest.cfc binds methods into each spec's scope which shifts GetCurrentTemplatePath() and bypasses the code path we need to cover. The existing specs all passed explicit path arguments, leaving the default-args computation uncovered. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6dda45e commit d84c681

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎vendor/wheels/Global.cfc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2788,7 +2788,7 @@ return local.$wheels;
27882788
// homepage shows the upcoming version rather than a blank placeholder.
27892789
local.rootPath = Len(arguments.rootBoxJsonPath)
27902790
? arguments.rootBoxJsonPath
2791-
: GetDirectoryFromPath(GetCurrentTemplatePath()) & "../box.json";
2791+
: GetDirectoryFromPath(GetCurrentTemplatePath()) & "../../box.json";
27922792
try {
27932793
if (FileExists(local.rootPath)) {
27942794
local.rootBox = DeserializeJSON(FileRead(local.rootPath));

‎vendor/wheels/tests/specs/events/frameworkVersionSpec.cfc‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,41 @@ component extends="wheels.WheelsTest" {
8585
}
8686
});
8787

88+
it("application.wheels.version resolves to <rootversion>-dev at boot in a monorepo dev checkout (regression for ##2291)", () => {
89+
// Regression for ##2291. Asserts the *runtime boot* result — not a direct
90+
// call — because $readFrameworkVersion is bound into the spec's scope by
91+
// WheelsTest.cfc, which shifts GetCurrentTemplatePath() to this file and
92+
// bypasses the code path we want to cover. application.wheels.version is
93+
// populated by onapplicationstart.cfc calling $readFrameworkVersion() with
94+
// no arguments, so whatever it resolved to is the answer we need to check.
95+
//
96+
// With the bug (one-level "../box.json"): default rootBoxJsonPath points at
97+
// vendor/box.json, which does not exist, so the helper falls through to
98+
// "0.0.0-dev" even in a monorepo checkout.
99+
// With the fix (two-level "../../box.json"): default rootBoxJsonPath points
100+
// at <repo-root>/box.json and yields "<rootversion>-dev".
101+
var wheelsDir = ExpandPath("/wheels/");
102+
var fwBoxPath = wheelsDir & "box.json";
103+
var rootBoxPath = wheelsDir & "../../box.json";
104+
if (!FileExists(fwBoxPath) || !FileExists(rootBoxPath)) {
105+
return;
106+
}
107+
var fwBox = DeserializeJSON(FileRead(fwBoxPath));
108+
var rootBox = DeserializeJSON(FileRead(rootBoxPath));
109+
if (!IsStruct(fwBox) || (fwBox.version ?: "") != "@build.version@") {
110+
return;
111+
}
112+
var isWheelsRepo = IsStruct(rootBox)
113+
&& (
114+
((rootBox.slug ?: "") == "wheels")
115+
|| ((rootBox.name ?: "") == "Wheels.fw")
116+
);
117+
if (!isWheelsRepo || (rootBox.version ?: "") == "" || rootBox.version == "@build.version@") {
118+
return;
119+
}
120+
expect(application.wheels.version).toBe(rootBox.version & "-dev");
121+
});
122+
88123
it("$readFrameworkVersion throws Wheels.VersionReadFailed when the file is missing", () => {
89124
var missing = getTempDirectory() & "wheels-version-missing-#CreateUUID()#.json";
90125
var threw = false;

0 commit comments

Comments
 (0)