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; }; discoveredProjects = dlib.discoverers.discoverProjects { inherit tree; };
getTranslator = subsystem: translatorName: getTranslator = subsystem: translatorName:
translators.translators."${subsystem}".all."${translatorName}"; translators.translatorsV2."${subsystem}".all."${translatorName}";
isImpure = project: translatorName: isImpure = project: translatorName:
(getTranslator project.subsystem translatorName).type == "impure"; (getTranslator project.subsystem translatorName).type == "impure";

View File

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

View File

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