mirror of https://gitlab.com/basile.b/dexed.git
fix #118 - add support for the new DUB package naming scheme
This commit is contained in:
parent
63fff3f001
commit
bd2a5d16df
|
@ -30,6 +30,7 @@ type
|
|||
strict private
|
||||
fName : string;
|
||||
fVersions: TSemVerList;
|
||||
fNewNamingScheme: boolean;
|
||||
public
|
||||
constructor create;
|
||||
destructor destroy; override;
|
||||
|
@ -38,6 +39,7 @@ type
|
|||
function highestInInterval(constref lo, hi: TSemVer): PSemVer;
|
||||
function highest: PSemVer;
|
||||
property name: string read fName write fName;
|
||||
property newNamingScheme: boolean read fNewNamingScheme write fNewNamingScheme;
|
||||
end;
|
||||
|
||||
TDubLocalPackages = class
|
||||
|
@ -359,10 +361,12 @@ begin
|
|||
begin
|
||||
v := fVersions[i]^;
|
||||
if v < lo then
|
||||
continue;
|
||||
if v < hi then
|
||||
result := fVersions[i];
|
||||
if v > hi then
|
||||
continue
|
||||
else if (v > lo) or (v = lo) then
|
||||
result := fVersions[i]
|
||||
else if (v < hi) and ((assigned(result) and (v > result^)) or (not assigned(result))) then
|
||||
result := fVersions[i]
|
||||
else if v > hi then
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
|
@ -395,6 +399,23 @@ begin
|
|||
end;
|
||||
|
||||
class procedure TDubLocalPackages.update;
|
||||
|
||||
procedure addPackageOrVersion(name, semVer: string; newNamingScheme: Boolean);
|
||||
var
|
||||
d: PDubLocalPackage = nil;
|
||||
begin
|
||||
if not find(name, d) then
|
||||
begin
|
||||
setLength(fLocalPackages, length(fLocalPackages) + 1);
|
||||
fLocalPackages[high(fLocalPackages)] := TDubLocalPackage.create;
|
||||
d := @fLocalPackages[high(fLocalPackages)];
|
||||
d^.name := name;
|
||||
d^.newNamingScheme := newNamingScheme;
|
||||
end;
|
||||
d^.addVersion(semVer);
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
p: TStringList;
|
||||
r: TStringList;
|
||||
|
@ -404,9 +425,10 @@ var
|
|||
i: integer;
|
||||
j: integer = 0;
|
||||
k: integer;
|
||||
d: PDubLocalPackage = nil;
|
||||
h: TStringRange = (ptr: nil; pos: 0; len: 0);
|
||||
x: string;
|
||||
u: TStringList;
|
||||
g: string;
|
||||
|
||||
begin
|
||||
|
||||
|
@ -441,6 +463,23 @@ begin
|
|||
j := 0;
|
||||
s := p[i];
|
||||
h.init(s);
|
||||
// after 2.104 <cachePath>/<package>/<version>/<package>
|
||||
// new naming scheme can be distinguished because '.' is not a legal char in a package name
|
||||
v := s.extractFileName;
|
||||
if (Pos('.', v) < 1) and (Pos('master', v) < 1) then
|
||||
begin
|
||||
u := TStringList.Create;
|
||||
try
|
||||
listFolders(u, s + DirectorySeparator);
|
||||
for g in u do
|
||||
addPackageOrVersion(v, 'v' + g.extractFileName, true);
|
||||
finally
|
||||
u.free;
|
||||
end;
|
||||
end
|
||||
// before 2.104 <cachePath>/<package>-<version>/<package>
|
||||
else
|
||||
begin
|
||||
while true do
|
||||
begin
|
||||
h.popUntil('-');
|
||||
|
@ -453,21 +492,13 @@ begin
|
|||
break;
|
||||
end;
|
||||
end;
|
||||
if j.equals(0) then
|
||||
continue;
|
||||
|
||||
if not j.equals(0) then
|
||||
begin
|
||||
n := s[1..j-1];
|
||||
n := n.extractFileName;
|
||||
if not find(n, d) then
|
||||
begin
|
||||
setLength(fLocalPackages, length(fLocalPackages) + 1);
|
||||
fLocalPackages[high(fLocalPackages)] := TDubLocalPackage.create;
|
||||
d := @fLocalPackages[high(fLocalPackages)];
|
||||
d^.name := n;
|
||||
addPackageOrVersion(n, 'v' + s[j+1 .. length(s)], false);
|
||||
end;
|
||||
end;
|
||||
v := 'v' + s[j+1 .. length(s)];
|
||||
d^.addVersion(v);
|
||||
|
||||
end;
|
||||
finally
|
||||
p.Free;
|
||||
|
@ -509,7 +540,6 @@ begin
|
|||
hi.patch := 0;
|
||||
hi.additional :='';
|
||||
result := package^.highestInInterval(opVer, hi);
|
||||
result := result;
|
||||
end;
|
||||
end
|
||||
else if op = '=' then
|
||||
|
@ -1743,14 +1773,18 @@ procedure TDubProject.updateImportPathsFromJson;
|
|||
begin
|
||||
s := b[k] + n;
|
||||
p := s + '-' + u^.asString + DirectorySeparator + n + DirectorySeparator;
|
||||
// e.g vibe-d:http -> <registrypath>/vibed-<sember>/http
|
||||
// new naming scheme
|
||||
if not p.dirExists then
|
||||
p := s + DirectorySeparator + u^.asString + DirectorySeparator + n + DirectorySeparator;
|
||||
// e.g vibe-d:http -> <registrypath>/vibed/<semver>/vibed/http
|
||||
// e.g ae:sys-wininet -> <registrypath>/ae/<semver>/ae/sys/wininet
|
||||
if length(w) <> 0 then
|
||||
p += w;
|
||||
p += strutils.ReplaceText(w, '-', DirectorySeparator);
|
||||
if not p.dirExists then
|
||||
continue;
|
||||
if (p + 'source').dirExists then
|
||||
begin
|
||||
fImportPaths.Add(p + 'source') ;
|
||||
fImportPaths.Add(p + 'source');
|
||||
break;
|
||||
end
|
||||
else if (p + 'src').dirExists then
|
||||
|
|
Loading…
Reference in New Issue