Make "dub.json" the primary choice for a package description and handle "package.json" as a fallback.
1 parent efc0edc commit 9450b46e0983aede623735d949a139654256baf8
@Sönke Ludwig Sönke Ludwig authored on 21 Nov 2013
Showing 5 changed files
View
15
source/dub/dub.d
{
if( !path.absolute() ) path = m_rootPath ~ path;
path.normalize();
 
//Check to see if a target directory needs to be created
if( !path.empty ){
if( !existsFile(path) )
createDirectory(path);
}
 
//Make sure we do not overwrite anything accidentally
if( existsFile(path ~ PackageJsonFilename) ||
existsFile(path ~ "source") ||
existsFile(path ~ "views") ||
existsFile(path ~ "public") )
{
throw new Exception("The current directory is not empty.\n");
}
 
if (m_dryRun) return;
 
initPackage(path, type);
 
View
16
source/dub/init.d
module dub.init;
 
import dub.internal.vibecompat.core.file;
import dub.internal.vibecompat.core.log;
import dub.package_ : PackageJsonFilename;
import dub.package_ : packageInfoFilenames;
 
import std.datetime;
import std.exception;
import std.file;
import std.format;
import std.process;
import std.string;
 
 
void initPackage(Path root_path, string type)
{
//Check to see if a target directory needs to be created
if( !root_path.empty ){
if( !existsFile(root_path) )
createDirectory(root_path);
}
 
//Make sure we do not overwrite anything accidentally
auto files = packageInfoFilenames ~ ["source/", "views/", "public/"];
foreach (fil; files)
enforce(!existsFile(root_path ~ fil), "The target directory already contains a '"~fil~"' file. Aborting.");
 
switch (type) {
default: throw new Exception("Unknown package init type: "~type);
case "minimal": initMinimalPackage(root_path); break;
case "vibe.d": initVibeDPackage(root_path); break;
string username;
version (Windows) username = environment.get("USERNAME", "Peter Parker");
else username = environment.get("USER", "Peter Parker");
 
auto fil = openFile(root_path ~ PackageJsonFilename, FileMode.Append);
auto fil = openFile(root_path ~ "dub.json", FileMode.Append);
scope(exit) fil.close();
 
fil.formattedWrite("{\n\t\"name\": \"%s\",\n", root_path.head.toString().toLower());
fil.formattedWrite("\t\"description\": \"%s\",\n", description);
View
source/dub/package_.d
View
source/dub/packagemanager.d
View
source/dub/project.d