diff --git a/.travis.yml b/.travis.yml index 327345e..0e408ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ - d: ldc-1.3.0 env: [FRONTEND=2.073] - stage: deploy - d: ldc + d: ldc-1.15.0 os: osx script: echo "Deploying to GitHub releases ..." && ./release.sh deploy: @@ -69,7 +69,7 @@ api_key: $GH_REPO_TOKEN on: tags: true - - d: ldc + - d: ldc-1.15.0 script: echo "Deploying to GitHub releases ..." && ./release.sh env: [ARCH=32] addons: @@ -85,7 +85,7 @@ api_key: $GH_REPO_TOKEN on: tags: true - - d: ldc + - d: ldc-1.15.0 script: echo "Deploying to GitHub releases ..." && ./release.sh deploy: - provider: releases @@ -95,7 +95,7 @@ api_key: $GH_REPO_TOKEN on: tags: true - - d: ldc + - d: ldc-1.15.0 script: echo "Deploying to GitHub releases (win32) ..." && ./release-windows.sh addons: apt: @@ -109,7 +109,7 @@ api_key: $GH_REPO_TOKEN on: tags: true - - d: ldc + - d: ldc-1.15.0 script: echo "Deploying to GitHub releases (win64) ..." && ARCH=64 ./release-windows.sh addons: apt: diff --git a/changelog/custom-dub-init-type.dd b/changelog/custom-dub-init-type.dd new file mode 100644 index 0000000..fff1b29 --- /dev/null +++ b/changelog/custom-dub-init-type.dd @@ -0,0 +1,10 @@ +Support of custom dub init type + +Command dub init now supports custom dub packages for argument `-t`. +$(CONSOLE +> dub init -n myPackage --format sdl -t custom-dub-init-dubpackage -- --foo=bar +) + +Dub init will be invoked like before. The package `custom-dub-init-dubpackage` +contains a sub package `init-exec` which will be invoked afterwards to create a custom +package skeleton. Additional arguments could be passed e.g. `-- --foo=bar`. diff --git a/changelog/dmd-mscoff-default.dd b/changelog/dmd-mscoff-default.dd new file mode 100644 index 0000000..5fc0c11 --- /dev/null +++ b/changelog/dmd-mscoff-default.dd @@ -0,0 +1,16 @@ +DUB will no longer use OPTLINK as default on Windows + +DMD's $(LINK2 https://digitalmars.com/ctg/optlink.html, OPTLINK) has many limitations. Apart from long-standing issues in the underlying DigitalMars runtime, +the maximum number of symbols is limited as well, which is why most big DUB +libraries can't be compiled with OPTLINK for years. This has been a cause of +grief and pain for many users and impacted the newcomer experience severly. + +With this release, `dub` will no longer use `OPTLINK` as default on Windows, but +use `-m32mscoff` (MSCOFF) on 32-bit Windows systems and `-m64` (MSCOFF) on 64-bit +Windows. + +Users can still manually instruct `dub` to use OPTLINK with the `--arch=x86` switch of `dub`: + +$(CONSOLE +> dub --arch=x86 +) diff --git a/changelog/dub-run.dd b/changelog/dub-run.dd new file mode 100644 index 0000000..d66cf35 --- /dev/null +++ b/changelog/dub-run.dd @@ -0,0 +1,45 @@ +`dub run` will now automatically fetch a package if it's not found locally + +Starting with this release, `dub run ` makes sure that the package is available locally. +This means that now a `dub fetch ` is no longer required and all a user of a library needs to run your dub package is `dub run`: + +$(CONSOLE +> dub run gitcompatibledubpackage +gitcompatibledubpackage wasn't found locally, but it's available online: +--- +Description: Example of a DUB package also usable as git submodule. For DUB test suite. +Version: 1.0.4 +--- +Do you want to fetch gitcompatibledubpackage? [Y/n]: +) + +An optional `--yes` (`-y`) flag is provided for non-interactive use: + +$(CONSOLE +> dub run --yes gitcompatibledubpackage +gitcompatibledubpackage wasn't found locally, but it's available online: +--- +Description: Example of a DUB package also usable as git submodule. For DUB test suite. +Version: 1.0.4 +--- +Fetching gitcompatibledubpackage 1.0.4... +Building package gitcompatibledubpackage in /home/seb/.dub/packages/gitcompatibledubpackage-1.0.4/gitcompatibledubpackage/ +Performing "debug" build using dmd for x86_64. +gitcompatibledubpackage 1.0.4: building configuration "exe"... +Linking... +Running ../../.dub/packages/gitcompatibledubpackage-1.0.4/gitcompatibledubpackage/gitcompatibledubpackage +Hello DUB +) + +If one wants to run a specific version of a package, it can be passed to `dub run` too: + +$(CONSOLE +> dub run gitcompatibledubpackage@1.0.3 +Fetching gitcompatibledubpackage 1.0.3... +Building package gitcompatibledubpackage in /home/seb/.dub/packages/gitcompatibledubpackage-1.0.3/gitcompatibledubpackage/ +Performing "debug" build using dmd for x86_64. +gitcompatibledubpackage 1.0.3: building configuration "exe"... +Linking... +Running ../../.dub/packages/gitcompatibledubpackage-1.0.3/gitcompatibledubpackage/gitcompatibledubpackage +Hello DUB +) diff --git a/changelog/remove-dub-list-installed.dd b/changelog/remove-dub-list-installed.dd new file mode 100644 index 0000000..83a1639 --- /dev/null +++ b/changelog/remove-dub-list-installed.dd @@ -0,0 +1,3 @@ +Remove `dub list-installed` command + +`dub list-installed` command was deprecated and renamed to `list` at $(LINK2 https://github.com/dlang/dub/pull/150, in 2013). diff --git a/changelog/single-api-requests.dd b/changelog/single-api-requests.dd new file mode 100644 index 0000000..a8b15a3 --- /dev/null +++ b/changelog/single-api-requests.dd @@ -0,0 +1,4 @@ +DUB uses single API requests to upgrade/resolve dependencies. + +`dub` now uses single API request to upgrade/resolve dependencies. +For more details, see $(LINK2 https://github.com/dlang/dub/pull/1366, pull #1366). diff --git a/dub.selections.json b/dub.selections.json index 486c146..5ef0425 100644 --- a/dub.selections.json +++ b/dub.selections.json @@ -1,18 +1,19 @@ { "fileVersion": 1, "versions": { - "botan": "1.12.9", + "botan": "1.12.10", "botan-math": "1.0.3", - "diet-ng": "1.4.3", - "eventcore": "0.8.27", - "libasync": "0.8.3", + "diet-ng": "1.5.0", + "eventcore": "0.8.41", + "libasync": "0.8.4", "libev": "5.0.0+4.04", "libevent": "2.0.2+2.0.16", - "memutils": "0.4.9", + "memutils": "0.4.13", + "mir-linux-kernel": "1.0.1", "openssl": "1.1.6+1.0.1g", - "stdx-allocator": "2.77.2", - "taggedalgebraic": "0.10.8", - "vibe-core": "1.4.0-alpha.1", - "vibe-d": "0.8.3-alpha.3" + "stdx-allocator": "2.77.5", + "taggedalgebraic": "0.10.13", + "vibe-core": "1.6.0", + "vibe-d": "0.8.4" } } diff --git a/source/dub/commandline.d b/source/dub/commandline.d index a420aea..c22c00d 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -67,7 +67,6 @@ new RemoveLocalCommand, new ListCommand, new SearchCommand, - new ListInstalledCommand, new AddOverrideCommand, new RemoveOverrideCommand, new ListOverridesCommand, @@ -489,6 +488,7 @@ this.helpText = [ "Initializes an empty package of the specified type in the given directory. By default, the current working directory is used." ]; + this.acceptsAppArgs = true; } override void prepare(scope CommandArgs args) @@ -499,6 +499,7 @@ "minimal - simple \"hello world\" project (default)", "vibe.d - minimal HTTP server based on vibe.d", "deimos - skeleton for C header bindings", + "custom - custom project provided by dub package", ]); args.getopt("f|format", &m_format, [ "Sets the format to use for the package description file. Possible values:", @@ -510,14 +511,13 @@ override int execute(Dub dub, string[] free_args, string[] app_args) { string dir; - enforceUsage(app_args.empty, "Unexpected application arguments."); if (free_args.length) { dir = free_args[0]; free_args = free_args[1 .. $]; } - string input(string caption, string default_value) + static string input(string caption, string default_value) { writef("%s [%s]: ", caption, default_value); auto inp = readln(); @@ -565,18 +565,11 @@ } } - //TODO: Remove this block in next version - // Checks if argument uses current method of specifying project type. - if (free_args.length) + if (!["vibe.d", "deimos", "minimal"].canFind(m_templateType)) { - if (["vibe.d", "deimos", "minimal"].canFind(free_args[0])) - { - m_templateType = free_args[0]; - free_args = free_args[1 .. $]; - logInfo("Deprecated use of init type. Use --type=[vibe.d | deimos | minimal] in future."); - } + free_args ~= m_templateType; } - dub.createEmptyPackage(NativePath(dir), free_args, m_templateType, m_format, &depCallback); + dub.createEmptyPackage(NativePath(dir), free_args, m_templateType, m_format, &depCallback, app_args); logInfo("Package successfully created in %s", dir.length ? dir : "."); return 0; @@ -829,6 +822,7 @@ } class BuildCommand : GenerateCommand { + bool m_yes; // automatic yes to prompts; this() { this.name = "build"; @@ -848,12 +842,70 @@ args.getopt("f|force", &m_force, [ "Forces a recompilation even if the target is up to date" ]); + args.getopt("y|yes", &m_yes, [ + `Automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively.` + ]); super.prepare(args); m_generator = "build"; } override int execute(Dub dub, string[] free_args, string[] app_args) { + // single package files don't need to be downloaded, they are on the disk. + if (free_args.length < 1 || m_single) + return super.execute(dub, free_args, app_args); + + const package_parts = splitPackageName(free_args[0]); + const package_name = package_parts.name; + + static bool input(string caption, bool default_value = true) { + writef("%s [%s]: ", caption, default_value ? "Y/n" : "y/N"); + auto inp = readln(); + string userInput = "y"; + if (inp.length > 1) + userInput = inp[0 .. $ - 1].toLower; + + switch (userInput) { + case "no", "n", "0": + return false; + case "yes", "y", "1": + default: + return true; + } + } + + Dependency dep; + + if (package_parts.version_.length > 0) { + // the user provided a version manually + free_args[0] = package_name; + dep = Dependency(package_parts.version_); + } else { + const pack = dub.packageManager.getFirstPackage(package_name); + if (pack) + return super.execute(dub, free_args, app_args); + + // search for the package and filter versions for exact matches + auto search = dub.searchPackages(package_name) + .map!(tup => tup[1].find!(p => p.name == package_name)) + .filter!(ps => !ps.empty); + if (search.empty) + return 2; + + const p = search.front.front; + logInfo("%s wasn't found locally, but it's available online:", package_name); + logInfo("---"); + logInfo("Description: %s", p.description); + logInfo("Version: %s", p.version_); + logInfo("---"); + + const answer = m_yes ? true : input("Do you want to fetch %s?".format(package_name)); + if (!answer) + return 0; + dep = Dependency(p.version_); + } + + dub.fetch(package_name, dep, dub.defaultPlacementLocation, FetchOptions.none); return super.execute(dub, free_args, app_args); } } @@ -1531,16 +1583,6 @@ } } -class ListInstalledCommand : ListCommand { - this() { this.name = "list-installed"; hidden = true; } - override void prepare(scope CommandArgs args) { super.prepare(args); } - override int execute(Dub dub, string[] free_args, string[] app_args) - { - warnRenamed("list-installed", "list"); - return super.execute(dub, free_args, app_args); - } -} - class SearchCommand : Command { this() { diff --git a/source/dub/compilers/dmd.d b/source/dub/compilers/dmd.d index ac0a459..a628076 100644 --- a/source/dub/compilers/dmd.d +++ b/source/dub/compilers/dmd.d @@ -22,6 +22,24 @@ import std.process; import std.typecons; +// Determines whether the specified process is running under WOW64 or an Intel64 of x64 processor. +version (Windows) +private Nullable!bool isWow64() { + // See also: https://docs.microsoft.com/de-de/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getnativesysteminfo + import core.sys.windows.windows : GetNativeSystemInfo, SYSTEM_INFO, PROCESSOR_ARCHITECTURE_AMD64; + + static Nullable!bool result; + + // A process's architecture won't change over while the process is in memory + // Return the cached result + if (!result.isNull) + return result; + + SYSTEM_INFO systemInfo; + GetNativeSystemInfo(&systemInfo); + result = systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64; + return result; +} class DMDCompiler : Compiler { private static immutable s_options = [ @@ -86,7 +104,14 @@ string[] arch_flags; switch (arch_override) { default: throw new Exception("Unsupported architecture: "~arch_override); - case "": break; + case "": + // Don't use Optlink by default on Windows + version (Windows) { + const is64bit = isWow64(); + if (!is64bit.isNull) + arch_flags = [is64bit ? "-m64" : "-m32mscoff"]; + } + break; case "x86": arch_flags = ["-m32"]; break; case "x86_64": arch_flags = ["-m64"]; break; case "x86_mscoff": arch_flags = ["-m32mscoff"]; break; diff --git a/source/dub/dub.d b/source/dub/dub.d index dff7a97..33f99cc 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -1168,7 +1168,8 @@ */ void createEmptyPackage(NativePath path, string[] deps, string type, PackageFormat format = PackageFormat.sdl, - scope void delegate(ref PackageRecipe, ref PackageFormat) recipe_callback = null) + scope void delegate(ref PackageRecipe, ref PackageFormat) recipe_callback = null, + string[] app_args = []) { if (!path.absolute) path = m_rootPath ~ path; path.normalize(); @@ -1196,10 +1197,40 @@ initPackage(path, depVers, type, format, recipe_callback); + if (!["vibe.d", "deimos", "minimal"].canFind(type)) { + runCustomInitialization(path, type, app_args); + } + //Act smug to the user. logInfo("Successfully created an empty project in '%s'.", path.toNativeString()); } + private void runCustomInitialization(NativePath path, string type, string[] runArgs) + { + string packageName = type; + auto template_pack = m_packageManager.getBestPackage(packageName, ">=0.0.0"); + if (!template_pack) template_pack = m_packageManager.getBestPackage(packageName, "~master"); + if (!template_pack) { + logInfo("%s is not present, getting and storing it user wide", packageName); + template_pack = fetch(packageName, Dependency(">=0.0.0"), defaultPlacementLocation, FetchOptions.none); + } + + Package initSubPackage = m_packageManager.getSubPackage(template_pack, "init-exec", false); + auto template_dub = new Dub(null, m_packageSuppliers); + template_dub.loadPackage(initSubPackage); + auto compiler_binary = this.defaultCompiler; + + GeneratorSettings settings; + settings.config = "application"; + settings.compiler = getCompiler(compiler_binary); + settings.platform = settings.compiler.determinePlatform(settings.buildSettings, compiler_binary, m_defaultArchitecture); + settings.buildType = "debug"; + settings.run = true; + settings.runArgs = runArgs; + initSubPackage.recipe.buildSettings.workingDirectory = path.toNativeString(); + template_dub.generateProject("build", settings); + } + /** Converts the package recipe of the loaded root package to the given format. Params: diff --git a/source/dub/init.d b/source/dub/init.d index c5e4598..98c98c4 100644 --- a/source/dub/init.d +++ b/source/dub/init.d @@ -82,7 +82,7 @@ } switch (type) { - default: throw new Exception("Unknown package init type: "~type); + default: break; case "minimal": initMinimalPackage(root_path, p, &processRecipe); break; case "vibe.d": initVibeDPackage(root_path, p, &processRecipe); break; case "deimos": initDeimosPackage(root_path, p, &processRecipe); break; diff --git a/source/dub/packagesuppliers/registry.d b/source/dub/packagesuppliers/registry.d index 3eb2c88..470f636 100644 --- a/source/dub/packagesuppliers/registry.d +++ b/source/dub/packagesuppliers/registry.d @@ -63,7 +63,7 @@ } catch(HTTPStatusException e) { if (e.status == 404) throw e; - else logDebug("Failed to download package %s from %s", packageId, url); + else logDebug("Failed to download package %s from %s", packageId, url); } catch(Exception e) { logDebug("Failed to download package %s from %s", packageId, url); @@ -86,27 +86,21 @@ m_metadataCache.remove(packageId); } - auto url = m_registryUrl ~ NativePath(PackagesPath ~ "/" ~ packageId ~ ".json"); + auto url = m_registryUrl ~ NativePath("api/packages/infos?packages=[\"" ~ + packageId ~ "\"]&include_dependencies=true&minimize=true"); logDebug("Downloading metadata for %s", packageId); string jsonData; - try - jsonData = cast(string)retryDownload(url); - catch(HTTPStatusException e) { - if (e.status == 404) { - logDebug("Package %s not found at %s (404): %s", packageId, description, e.msg); - return Json(null); - } - else throw e; - } + jsonData = cast(string)retryDownload(url); Json json = parseJsonString(jsonData, url.toString()); - // strip readme data (to save size and time) - foreach (ref v; json["versions"]) - v.remove("readme"); - m_metadataCache[packageId] = CacheEntry(json, now); - return json; + foreach (pkg, info; json.get!(Json[string])) + { + logDebug("adding %s to metadata cache", pkg); + m_metadataCache[pkg] = CacheEntry(info, now); + } + return json[packageId]; } SearchResult[] searchPackages(string query) { diff --git a/source/dub/project.d b/source/dub/project.d index 4b4e85b..48b6752 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -1194,14 +1194,9 @@ foreach (var; vars) dst.put(processVars(var, project, pack, gsettings, are_paths)); } -private string processVars(Project, Package)(string var, in Project project, in Package pack,in GeneratorSettings gsettings, bool is_path) +private string processVars(Project, Package)(string var, in Project project, in Package pack, in GeneratorSettings gsettings, bool is_path) { - import std.regex : regex, replaceAll; - - auto varRE = regex(`\$([\w_]+)|\$\{([\w_]+)\}|(\$\$[\w_]+|\$\$\{[\w_]+\})`); - var = var.replaceAll!( - m => m[3].length ? m[3][1..$] : (getVariable(m[1].length ? m[1] : m[2], project, pack, gsettings)) - )(varRE); + var = var.expandVars!(varName => getVariable(varName, project, pack, gsettings)); if (is_path) { auto p = NativePath(var); if (!p.absolute) { @@ -1210,6 +1205,91 @@ } else return var; } +/// Expand variables using `$VAR_NAME` or `${VAR_NAME}` syntax. +/// `$$` escapes itself and is expanded to a single `$`. +private string expandVars(alias expandVar)(string s) +{ + import std.functional : not; + + auto result = appender!string; + + static bool isVarChar(char c) + { + import std.ascii; + return isAlphaNum(c) || c == '_'; + } + + while (true) + { + auto pos = s.indexOf('$'); + if (pos < 0) + { + result.put(s); + return result.data; + } + result.put(s[0 .. pos]); + s = s[pos + 1 .. $]; + enforce(s.length > 0, "Variable name expected at end of string"); + switch (s[0]) + { + case '$': + result.put("$"); + s = s[1 .. $]; + break; + case '{': + pos = s.indexOf('}'); + enforce(pos >= 0, "Could not find '}' to match '${'"); + result.put(expandVar(s[1 .. pos])); + s = s[pos + 1 .. $]; + break; + default: + pos = s.representation.countUntil!(not!isVarChar); + if (pos < 0) + pos = s.length; + result.put(expandVar(s[0 .. pos])); + s = s[pos .. $]; + break; + } + } +} + +unittest +{ + string[string] vars = + [ + "A" : "a", + "B" : "b", + ]; + + string expandVar(string name) { auto p = name in vars; enforce(p, name); return *p; } + + assert(expandVars!expandVar("") == ""); + assert(expandVars!expandVar("x") == "x"); + assert(expandVars!expandVar("$$") == "$"); + assert(expandVars!expandVar("x$$") == "x$"); + assert(expandVars!expandVar("$$x") == "$x"); + assert(expandVars!expandVar("$$$$") == "$$"); + assert(expandVars!expandVar("x$A") == "xa"); + assert(expandVars!expandVar("x$$A") == "x$A"); + assert(expandVars!expandVar("$A$B") == "ab"); + assert(expandVars!expandVar("${A}$B") == "ab"); + assert(expandVars!expandVar("$A${B}") == "ab"); + assert(expandVars!expandVar("a${B}") == "ab"); + assert(expandVars!expandVar("${A}b") == "ab"); + + import std.exception : assertThrown; + assertThrown(expandVars!expandVar("$")); + assertThrown(expandVars!expandVar("${}")); + assertThrown(expandVars!expandVar("$|")); + assertThrown(expandVars!expandVar("x$")); + assertThrown(expandVars!expandVar("$X")); + assertThrown(expandVars!expandVar("${")); + assertThrown(expandVars!expandVar("${X")); + + // https://github.com/dlang/dmd/pull/9275 + assert(expandVars!expandVar("$${DUB_EXE:-dub}") == "${DUB_EXE:-dub}"); +} + // Keep the following list up-to-date if adding more build settings variables. /// List of variables that can be used in build settings package(dub) immutable buildSettingsVars = [ diff --git a/test/issue1336-registry/api/packages/infos__packages=%5B%22gitcompatibledubpackage%22%5D&include_dependencies=true&minimize=true b/test/issue1336-registry/api/packages/infos__packages=%5B%22gitcompatibledubpackage%22%5D&include_dependencies=true&minimize=true new file mode 100644 index 0000000..7258e3d --- /dev/null +++ b/test/issue1336-registry/api/packages/infos__packages=%5B%22gitcompatibledubpackage%22%5D&include_dependencies=true&minimize=true @@ -0,0 +1,3 @@ +{ + "gitcompatibledubpackage": {"versions":[{"configurations":[{"name":"exe"},{"name":"lib"}],"version":"~master","name":"gitcompatibledubpackage"},{"version":"1.0.1","name":"gitcompatibledubpackage"},{"version":"1.0.2","name":"gitcompatibledubpackage"},{"version":"1.0.3","name":"gitcompatibledubpackage"},{"configurations":[{"name":"exe"},{"name":"lib"}],"version":"1.0.4","name":"gitcompatibledubpackage"}]} +} \ No newline at end of file diff --git a/test/issue1336-registry/packages/gitcompatibledubpackage.json b/test/issue1336-registry/packages/gitcompatibledubpackage.json deleted file mode 100644 index 6f0d641..0000000 --- a/test/issue1336-registry/packages/gitcompatibledubpackage.json +++ /dev/null @@ -1 +0,0 @@ -{"repository":{"project":"gitcompatibledubpackage","owner":"dlang-community","kind":"github"},"dateAdded":"2017-02-11T21:00:16","name":"gitcompatibledubpackage","categories":[],"owner":"5148973d2179ddb20b0002fd","id":"589f6d501c18646d0ee49f12","versions":[{"packageDescriptionFile":"dub.sdl","configurations":[{"name":"exe","targetType":"executable","mainSourceFile":"hello.d"},{"excludedSourceFiles":["hello.d"],"name":"lib","targetType":"library"}],"commitID":"9e3972be4c63790c32257220f40c0af7dc41bec5","importPaths":[".."],"name":"gitcompatibledubpackage","version":"~master","license":"public domain","readmeFile":"/README.md","date":"2017-09-18T18:18:35Z","description":"Example of a DUB package also usable as git submodule. For DUB test suite.","sourcePaths":["."]},{"packageDescriptionFile":"dub.json","commitID":"b62466d32dd6bbb0d45f9a73c91142205d1048e5","importPaths":[".."],"name":"gitcompatibledubpackage","version":"1.0.1","license":"public domain","readmeFile":"/README.md","date":"2015-10-31T11:09:14Z","description":"Example of a DUB package also usable as git submodule. For DUB test suite."},{"packageDescriptionFile":"dub.json","commitID":"cef89b5513a140b1e3417809f59d1957ddaad837","importPaths":[".."],"name":"gitcompatibledubpackage","version":"1.0.2","license":"public domain","readmeFile":"/README.md","date":"2015-10-31T11:23:53Z","description":"Example of a DUB package also usable as git submodule. For DUB test suite.","sourcePaths":["."]},{"packageDescriptionFile":"dub.json","commitID":"d36e49d31b26ea76e1670e9d5cd89aaac40fde75","importPaths":[".."],"name":"gitcompatibledubpackage","version":"1.0.3","targetType":"executable","license":"public domain","readmeFile":"/README.md","date":"2017-04-05T22:12:48Z","description":"Example of a DUB package also usable as git submodule. For DUB test suite.","mainSourceFile":"hello.d","sourcePaths":["."]},{"packageDescriptionFile":"dub.sdl","configurations":[{"name":"exe","targetType":"executable","mainSourceFile":"hello.d"},{"excludedSourceFiles":["hello.d"],"name":"lib","targetType":"library"}],"commitID":"9e3972be4c63790c32257220f40c0af7dc41bec5","importPaths":[".."],"name":"gitcompatibledubpackage","version":"1.0.4","license":"public domain","readmeFile":"/README.md","date":"2017-09-18T18:18:35Z","description":"Example of a DUB package also usable as git submodule. For DUB test suite.","sourcePaths":["."]}]} \ No newline at end of file diff --git a/test/issue1651-custom-dub-init-type.sh b/test/issue1651-custom-dub-init-type.sh new file mode 100755 index 0000000..5c48313 --- /dev/null +++ b/test/issue1651-custom-dub-init-type.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +. $(dirname "${BASH_SOURCE[0]}")/common.sh +DIR=$(dirname "${BASH_SOURCE[0]}") +packname="custom-dub-init-type-sample" + +$DUB remove custom-dub-init-dubpackage --non-interactive --version=* 2>/dev/null || true +$DUB init -n $packname --format sdl -t custom-dub-init-dubpackage --skip-registry=all --registry=file://"$DIR"/issue1651-custom-dub-init-type -- --foo=bar + +function cleanup { + rm -rf $packname +} + +if [ ! -e $packname/dub.sdl ]; then # it failed + cleanup + die $LINENO 'No dub.sdl file has been generated.' +fi + +cd $packname +if ! { ${DUB} 2>&1 || true; } | grep -cF 'foo=bar'; then + cd .. + cleanup + die $LINENO 'Custom init type.' +fi +cd .. +cleanup \ No newline at end of file diff --git a/test/issue1651-custom-dub-init-type/.no_build b/test/issue1651-custom-dub-init-type/.no_build new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue1651-custom-dub-init-type/.no_build diff --git a/test/issue1651-custom-dub-init-type/.no_run b/test/issue1651-custom-dub-init-type/.no_run new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue1651-custom-dub-init-type/.no_run diff --git a/test/issue1651-custom-dub-init-type/.no_test b/test/issue1651-custom-dub-init-type/.no_test new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue1651-custom-dub-init-type/.no_test diff --git a/test/issue1651-custom-dub-init-type/custom-dub-init-dubpackage-1.0.1.zip b/test/issue1651-custom-dub-init-type/custom-dub-init-dubpackage-1.0.1.zip new file mode 100644 index 0000000..67a499b --- /dev/null +++ b/test/issue1651-custom-dub-init-type/custom-dub-init-dubpackage-1.0.1.zip Binary files differ diff --git a/test/issue877-auto-fetch-package-on-run.sh b/test/issue877-auto-fetch-package-on-run.sh new file mode 100755 index 0000000..a131426 --- /dev/null +++ b/test/issue877-auto-fetch-package-on-run.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -eu -o pipefail +set -x +$DUB remove --version="*" gitcompatibledubpackage || true + +# check whether the interactive run mode works +echo "y" | $DUB run gitcompatibledubpackage | grep "Hello DUB" +$DUB remove gitcompatibledubpackage + +! (echo "n" | $DUB run gitcompatibledubpackage | grep "Hello DUB") +! $DUB remove gitcompatibledubpackage + +# check -y +$DUB run --yes gitcompatibledubpackage | grep "Hello DUB" +$DUB remove gitcompatibledubpackage + +# check --yes +$DUB run -y gitcompatibledubpackage | grep "Hello DUB" +$DUB remove gitcompatibledubpackage + +# check supplying versions directly +dub_log="$($DUB run gitcompatibledubpackage@1.0.3)" +echo "$dub_log" | grep "Hello DUB" +echo "$dub_log" | grep "Fetching.*1.0.3" +$DUB remove gitcompatibledubpackage + +# check supplying an invalid version +(! $DUB run gitcompatibledubpackage@0.42.43) 2>&1 | \ + grep 'No package gitcompatibledubpackage was found matching the dependency 0[.]42[.]43' + +! $DUB remove gitcompatibledubpackage diff --git a/test/test_registry.d b/test/test_registry.d old mode 100644 new mode 100755 index dfeb358..f5d14c1 --- a/test/test_registry.d +++ b/test/test_registry.d @@ -1,11 +1,42 @@ +#!/usr/bin/env dub /+dub.sdl: -dependency "vibe-d" version="~>0.8.3-alpha.1" +dependency "vibe-d" version="~>0.8.5" versions "VibeNoSSL" +/ +import vibe.d; + +/* +Provide a special API File Handler as Vibe.d's builtin serveStaticFiles +doesn't deal well with query params. +This will blindly check if the requestURI payload exists on the filesystem and if so, return the file. + +It replaces `?` with `__` for Windows compatibility. + +Params: + skip = initial part of the requestURI to skip over + folder = the base directory from which to serve API requests from +*/ +auto apiFileHandler(string skip, string folder) { + import std.functional : toDelegate; + void handler(HTTPServerRequest req, HTTPServerResponse res) { + import std.algorithm : skipOver; + import std.path : buildPath; + import std.file : exists; + // ? can't be part of path names on Windows + auto requestURI = req.requestURI.replace("?", "__"); + requestURI.skipOver(skip); + const reqFile = buildPath(folder, requestURI); + if (reqFile.exists) { + return req.sendFile(res, PosixPath(reqFile)); + } + } + return toDelegate(&handler); +} + void main(string[] args) { - import std.conv, vibe.d; + import std.conv; immutable folder = readRequiredOption!string("folder", "Folder to service files from."); immutable port = readRequiredOption!uint("port", "Port to use"); auto router = new URLRouter; @@ -18,6 +49,8 @@ }); router.get("*", folder.serveStaticFiles); router.get("/fallback/*", folder.serveStaticFiles(new HTTPFileServerSettings("/fallback"))); + router.get("/api/*", apiFileHandler("/", folder)); + router.get("/fallback/api/*", apiFileHandler("/fallback/", folder)); listenHTTP(text(":", port), router); runApplication(); } diff --git a/travis-ci.sh b/travis-ci.sh index efe3203..6297a31 100755 --- a/travis-ci.sh +++ b/travis-ci.sh @@ -4,7 +4,7 @@ source ~/dlang/*/activate # activate host compiler -if [ -z "$FRONTEND" -o "$FRONTEND" \> 2.072.z ]; then +if [ -z "$FRONTEND" -o "$FRONTEND" \> 2.074.z ]; then vibe_ver=$(jq -r '.versions | .["vibe-d"]' < dub.selections.json) dub fetch vibe-d --version=$vibe_ver # get optional dependency dub test --compiler=${DC} -c library-nonet