Skip to content

Commit 4736850

Browse files
committed
Fixed: Now showing compiler messages for every build.
Update: Caching version information for 1 hour and now it is configurable
1 parent 3013208 commit 4736850

File tree

5 files changed

+68
-3
lines changed

5 files changed

+68
-3
lines changed

source/app.d

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ int main(string[] args)
6868
"test": &testMain,
6969
"init": &initMain,
7070
"install": &installMain,
71+
"configure": &configureMain,
7172
"use": &useMain,
7273
// "watch": &watchMain,
7374
"run": cast(int function(string[]))null
@@ -435,4 +436,32 @@ int useMain(string[] args)
435436
}
436437
saveRedubMeta(meta);
437438
return 0;
439+
}
440+
441+
int configureMain(string[] args)
442+
{
443+
import redub.cli.dub;
444+
import redub.logging;
445+
import redub.meta;
446+
import redub.misc.path;
447+
import std.getopt;
448+
setLogLevel(LogLevel.info);
449+
450+
struct ConfigArgs
451+
{
452+
@("Sets whether redub checks for update when an error happens")
453+
@("update-check")
454+
bool updateCheck = true;
455+
}
456+
ConfigArgs config;
457+
GetoptResult res = betterGetopt(args, config);
458+
if(res.helpWanted)
459+
{
460+
defaultGetoptPrinter(RedubVersionShort~" configure usage: redub configure [options]\nOptions:", res.options);
461+
return 0;
462+
}
463+
JSONValue meta = getRedubMeta();
464+
meta["updateCheck"] = JSONValue(config.updateCheck);
465+
saveRedubMeta(meta);
466+
return 0;
438467
}

source/redub/buildapi.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import redub.package_searching.api;
77

88

99
///vX.X.X
10-
enum RedubVersionOnly = "v1.26.6";
10+
enum RedubVersionOnly = "v1.26.7";
1111
///Redub vX.X.X
1212
enum RedubVersionShort = "Redub "~RedubVersionOnly;
1313
///Redub vX.X.X - Description

source/redub/building/compile.d

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,13 @@ private void buildSucceeded(ProjectNode node, CompilationResult res)
537537
{
538538
if(!node.isCopyEnough)
539539
{
540+
import std.string:stripRight;
540541
string cfg = node.requirements.targetConfiguration ? (" ["~node.requirements.targetConfiguration~"]") : null;
541542
string ver = node.requirements.version_.length ? (" "~node.requirements.version_) : null;
542543

543544
infos("Built: ", node.name, ver, cfg, " - ", res.msNeeded, "ms");
545+
if(res.message.length)
546+
info(res.message.stripRight);
544547
vlog("\n\t", res.compilationCommand, " \n");
545548
}
546549

source/redub/meta.d

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,33 @@ string getExistingRedubVersion()
8181
if(!ver)
8282
return null;
8383
return ver.str;
84+
}
85+
86+
string getLatestRedubVersion()
87+
{
88+
import redub.misc.github_tag_check;
89+
import std.datetime.systime;
90+
JSONValue meta = getRedubMeta();
91+
JSONValue* latest = "latestVersion" in meta;
92+
if(latest)
93+
{
94+
long time = latest.array[1].get!long;
95+
int currHour = Clock.currTime.hour - SysTime(time).hour;
96+
if(currHour == 0)
97+
return latest.array[0].str;
98+
}
99+
string v = redub.misc.github_tag_check.getLatestRedubVersion();
100+
JSONValue data = JSONValue([JSONValue(v), JSONValue(Clock.currStdTime)]);
101+
meta["latestVersion"] = data;
102+
saveRedubMeta(meta);
103+
return v;
104+
}
105+
106+
bool shouldShowNewerVersionMessage()
107+
{
108+
JSONValue meta = getRedubMeta();
109+
JSONValue* updateCheck = "updateCheck" in meta;
110+
if(updateCheck)
111+
return updateCheck.get!bool;
112+
return true;
84113
}

source/redub/misc/github_tag_check.d

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ private enum CreateIssueURL = "https://github.com/"~RedubUserRepository~"/issues
77

88
void showNewerVersionMessage()
99
{
10+
import redub.meta;
1011
import redub.buildapi;
1112
import redub.logging;
12-
string ver = getLatestRedubVersion();
13+
if(!shouldShowNewerVersionMessage)
14+
return;
15+
string ver = redub.meta.getLatestRedubVersion();
1316
if(ver)
1417
{
1518
if(ver != RedubVersionOnly)
1619
{
1720
warnTitle(
1821
"Redub "~ ver~ " available. \n\t",
19-
"Maybe try updating it with 'redub update 'or running dub fetch redub@"~ver[1..$]~" if you think this compilation error is a redub bug."
22+
"Maybe try updating it with 'redub update 'or running dub fetch redub@"~ver[1..$]~" if you think this compilation error is a redub bug.\n\t"~
23+
"You can disable this message by calling redub configure --update-check=false "
2024
);
2125
return;
2226
}

0 commit comments

Comments
 (0)