diff --git a/source/dub/dub.d b/source/dub/dub.d index bfa5980..3e48d90 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -22,18 +22,14 @@ import dub.generators.generator; import dub.init; - -// todo: cleanup imports. import std.algorithm; -import std.array; -import std.conv; -import std.datetime; -import std.exception; +import std.array : array, replace; +import std.conv : to; +import std.exception : enforce; import std.file; -import std.process; +import std.process : environment; +import std.range : empty; import std.string; -import std.typecons; -import std.zip; import std.encoding : sanitize; // Workaround for libcurl liker errors when building with LDC @@ -739,6 +735,7 @@ // import path leakage. dstpath = dstpath ~ packageId; + import std.datetime : seconds; auto lock = lockFile(dstpath.toNativeString() ~ ".lock", 30.seconds); // possibly wait for other dub instance if (dstpath.existsFile()) { @@ -959,6 +956,7 @@ */ auto searchPackages(string query) { + import std.typecons : Tuple, tuple; Tuple!(string, PackageSupplier.SearchResult[])[] results; foreach (ps; this.m_packageSuppliers) { try @@ -1098,6 +1096,8 @@ */ void runDdox(bool run, string[] generate_args = null) { + import std.process : browse; + if (m_dryRun) return; // allow to choose a custom ddox tool @@ -1168,6 +1168,7 @@ private void determineDefaultCompiler() { + import std.range : front; import std.process : environment; m_defaultCompiler = m_config.defaultCompiler; @@ -1318,6 +1319,7 @@ protected override TreeNodes[] getChildren(TreeNode node) { + import std.array : appender; auto ret = appender!(TreeNodes[]); auto pack = getPackage(node.pack, node.config); if (!pack) { diff --git a/source/dub/internal/utils.d b/source/dub/internal/utils.d index b928088..52cf55f 100644 --- a/source/dub/internal/utils.d +++ b/source/dub/internal/utils.d @@ -14,18 +14,15 @@ import dub.compilers.buildsettings : BuildSettings; import dub.version_; -// todo: cleanup imports. -import core.thread; +import core.time : Duration; import std.algorithm : canFind, startsWith; -import std.array; -import std.conv; -import std.exception; +import std.array : appender; +import std.conv : to; +import std.exception : enforce; import std.file; +import std.string : format; import std.process; -import std.string; import std.traits : isIntegral; -import std.typecons; -import std.zip; version(DubUseCurl) { import std.net.curl; @@ -64,6 +61,7 @@ */ auto lockFile(string path, Duration timeout) { + import core.thread : Thread; import std.datetime, std.stdio : File; import std.algorithm : move; @@ -127,6 +125,7 @@ } Json jsonFromZip(Path zip, string filename) { + import std.zip : ZipArchive; auto f = openFile(zip, FileMode.read); ubyte[] b = new ubyte[cast(size_t)f.size]; f.rawRead(b); @@ -308,6 +307,7 @@ string getDUBVersion() { import dub.version_; + import std.array : split, join; // convert version string to valid SemVer format auto verstr = dubVersion; if (verstr.startsWith("v")) verstr = verstr[1 .. $]; diff --git a/source/dub/project.d b/source/dub/project.d index b8f7813..23a3a96 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -20,18 +20,12 @@ import dub.packagesupplier; import dub.generators.generator; - -// todo: cleanup imports. import std.algorithm; import std.array; -import std.conv; +import std.conv : to; import std.datetime; -import std.exception; -import std.file; -import std.process; +import std.exception : enforce; import std.string; -import std.typecons; -import std.zip; import std.encoding : sanitize; /** @@ -1099,6 +1093,7 @@ } private void writeDubJson() { + import std.file : exists, mkdir; // don't bother to write an empty file if( m_packageSettings.length == 0 ) return; @@ -1218,6 +1213,7 @@ private string getVariable(string name, in Project project, in Package pack) { + import std.process : environment; if (name == "PACKAGE_DIR") return pack.path.toNativeString(); if (name == "ROOT_PACKAGE_DIR") return project.rootPackage.path.toNativeString();