small fixes in translators and resolving

This commit is contained in:
DavHau 2022-02-27 15:37:09 +07:00
parent d8d0856c96
commit ed9bdd2fa2
3 changed files with 19 additions and 14 deletions

View File

@ -428,7 +428,7 @@ let
discoveredProjects = dlib.discoverers.discoverProjects { inherit tree; };
getTranslator = subsystem: translatorName:
translators.translators."${subsystem}".all."${translatorName}";
translators.translatorsV2."${subsystem}".all."${translatorName}";
isImpure = project: translatorName:
(getTranslator project.subsystem translatorName).type == "impure";

View File

@ -21,7 +21,7 @@ let
let
nodes = l.readDir path;
in
l.optionals (nodes ? "package-lock.json") [ "package-lock2" ]
l.optionals (nodes ? "package-lock.json") [ "package-lock" ]
++ l.optionals (nodes ? "yarn.lock") [ "yarn-lock" ]
++ [ "package-json" ];
@ -57,7 +57,9 @@ let
makeWorkspaceProjectInfo = tree: wsRelPath: parentInfo:
{
inherit subsystem;
name = (getPackageJson "${tree.fullPath}/${wsRelPath}").name or null;
name =
(getPackageJson "${tree.fullPath}/${wsRelPath}").name
or "${parentInfo.name}/${wsRelPath}";
relPath = dlib.sanitizeRelativePath "${tree.relPath}/${wsRelPath}";
translators =
l.unique
@ -90,7 +92,7 @@ let
{
inherit subsystem;
inherit (tree) relPath;
name = tree.files."package.json".jsonContent.name or null;
name = tree.files."package.json".jsonContent.name or tree.relPath;
translators = getTranslatorNames tree.fullPath;
subsystemInfo =
l.optionalAttrs (workspaces != []) {
@ -120,6 +122,7 @@ let
(l.map (p: p.relPath) foundProjects)
(relPath: null));
in
# l.trace tree.directories
# the current directory
foundProjects

View File

@ -32,7 +32,8 @@ let
(proj:
translator.translate
((cleanedArgs args) // {
source = "${args.source}${proj.relPath}";
source = "${args.source}/${proj.relPath}";
name = proj.name;
}))
args.projects;
};
@ -50,15 +51,16 @@ let
downgradeTranslator =
translator // {
translate = args:
translator.translate (args // {
inherit (args) source;
tree = dlib.prepareSourceTree { inherit (args) source; };
projects = [{
name = translator.projectName { inherit (args) source; };
relPath = "";
subsystem = translator.subsystem;
}];
});
l.head
(translator.translate (args // {
inherit (args) source;
tree = dlib.prepareSourceTree { inherit (args) source; };
projects = [{
name = translator.projectName { inherit (args) source; };
relPath = "";
subsystem = translator.subsystem;
}];
}));
};
in
if version == 1 then