Skip to content

Commit e39d977

Browse files
authored
Merge pull request #1849 from wheels-dev/cli-fixes-and-fw-fixes
Cli fixes and fw fixes
2 parents ce9b6e3 + 044dbd7 commit e39d977

File tree

4 files changed

+95
-5
lines changed

4 files changed

+95
-5
lines changed

cli/src/commands/wheels/reload.cfc

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,100 @@ component aliases='wheels r' extends="base" {
2424
requireWheelsApp(getCWD());
2525
arguments=reconstructArgs(arguments);
2626
var serverDetails = $getServerInfo();
27+
var appSettings = $getAppSettings(mode);
2728

29+
var reloadPassword = StructKeyExists(appSettings, "reloadPassword") ? appSettings.reloadPassword : "";
30+
getURL = serverDetails.serverURL & "/index.cfm?reload=#mode#";
31+
32+
// Handle password logic
33+
if (len(reloadPassword)) {
34+
// Password is configured
35+
if (len(password)) {
36+
// User provided a password, validate it against configured one
37+
if (password != reloadPassword) {
38+
detailOutput.error("Invalid password. The configured reload password does not match the provided password.");
39+
return;
40+
}
41+
getURL &= "&password=#password#";
42+
} else {
43+
detailOutput.error("Reload password is configured but not provided!");
44+
return;
45+
}
46+
} else {
47+
// No password configured - check if user provided one unnecessarily
48+
if (len(password)) {
49+
detailOutput.statusWarning("No reload password is configured in settings, but you provided one. Proceeding without password.");
50+
}
51+
}
2852
getURL = serverDetails.serverURL &
2953
"/index.cfm?reload=#mode#&password=#password#";
3054
var loc = new Http( url=getURL ).send().getPrefix();
3155
detailOutput.statusSuccess("Reload Request sent");
3256
}
3357

58+
private struct function $getAppSettings(required string mode="development") {
59+
try {
60+
local.appPath = getCWD();
61+
local.settingsFile = local.appPath & "/config/settings.cfm";
62+
local.envSettingsFile = local.appPath & "/config/" & arguments.mode & "/settings.cfm";
63+
local.settings = {};
64+
65+
// Override with app settings if file exists
66+
if (FileExists(local.settingsFile)) {
67+
local.settingsContent = FileRead(local.settingsFile);
68+
parseSettings(local.settingsContent, local.settings);
69+
}
70+
71+
// Override with environment-specific settings
72+
if (FileExists(local.envSettingsFile)) {
73+
local.envSettingsContent = FileRead(local.envSettingsFile);
74+
parseSettings(local.envSettingsContent, local.settings);
75+
}
76+
77+
return local.settings;
78+
} catch (any e) {
79+
detailOutput.error("Error reading settings: #e.message#");
80+
if (StructKeyExists(e, "detail") && Len(e.detail)) {
81+
detailOutput.output("Details: #e.detail#");
82+
}
83+
}
84+
}
85+
86+
private void function parseSettings(required string content, required struct settings) {
87+
local.pattern = '(?i)set\s*\(\s*([^)]+)\)';
88+
local.matches = REMatch(local.pattern, arguments.content);
89+
90+
for (local.match in local.matches) {
91+
try {
92+
// extract the inside of set(...)
93+
local.inner = REReplace(local.match, '(?i)^set\s*\(|\);?$', '', 'all');
94+
95+
// split only on FIRST =
96+
local.eqPos = Find("=", local.inner);
97+
if (!local.eqPos) continue;
98+
99+
local.key = Trim(Left(local.inner, local.eqPos - 1));
100+
local.value = Trim(Mid(local.inner, local.eqPos + 1));
101+
102+
// strip quotes
103+
local.value = REReplace(local.value, "^['""]|['""]$", "", "all");
104+
105+
// coerce types
106+
if (local.value == "true") {
107+
local.value = true;
108+
} else if (local.value == "false") {
109+
local.value = false;
110+
} else if (IsNumeric(local.value)) {
111+
local.value = Val(local.value);
112+
}
113+
114+
arguments.settings[local.key] = local.value;
115+
} catch (any e) {
116+
detailOutput.error("Error reading settings: #e.message#");
117+
if (StructKeyExists(e, "detail") && Len(e.detail)) {
118+
detailOutput.output("Details: #e.detail#");
119+
}
120+
}
121+
}
122+
}
34123
}

core/src/wheels/model/create.cfc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ component {
2727
$args(name = "create", args = arguments);
2828
$setProperties(
2929
argumentCollection = arguments,
30-
filterList = "properties,parameterize,reload,validate,transaction,callbacks,allowExplicitTimestamps"
30+
filterList = "properties,parameterize,reload,validate,transaction,callbacks"
3131
);
3232
local.rv = new (argumentCollection = arguments);
3333
local.rv.save(
@@ -172,6 +172,7 @@ component {
172172
if (!Len(key())) {
173173
local.rollback = true;
174174
}
175+
175176
$create(parameterize = arguments.parameterize, reload = arguments.reload);
176177
if (
177178
$saveAssociations(argumentCollection = arguments)
@@ -226,6 +227,7 @@ component {
226227
public boolean function $create(required any parameterize, required boolean reload) {
227228
// Allow explicit assignment of the createdAt/updatedAt properties if allowExplicitTimestamps is true
228229
local.allowExplicitTimestamps = StructKeyExists(this, "allowExplicitTimestamps") && this.allowExplicitTimestamps;
230+
229231
if (
230232
local.allowExplicitTimestamps
231233
&& StructKeyExists(this, $get("timeStampOnCreateProperty"))

core/src/wheels/model/update.cfc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,14 @@ component {
244244
$args(name = "update", args = arguments);
245245
$setProperties(
246246
argumentCollection = arguments,
247-
filterList = "properties,parameterize,reload,validate,transaction,callbacks,allowExplicitTimestamps"
247+
filterList = "properties,parameterize,reload,validate,transaction,callbacks"
248248
);
249249
return save(
250250
callbacks = arguments.callbacks,
251251
parameterize = arguments.parameterize,
252252
reload = arguments.reload,
253253
transaction = arguments.transaction,
254-
validate = arguments.validate,
255-
allowExplicitTimestamps = arguments.allowExplicitTimestamps
254+
validate = arguments.validate
256255
);
257256
}
258257

docs/api/v3.0.0.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)