resolvePkg function
- String templateLibName
Resolves a templateLibName
to a package spec.
Searches user, local, syscache, and pub.dev. Returns the highest version. Result is map with keys name, version, cache, and rootUri.
Implementation
Future<List<Map>> resolvePkg(String templateLibName) async {
// Config.debugLogger.d('resolvePkg: $templateLibName');
switch (templateLibName) {
case ':.':
case ':here':
return listHereLib();
break;
case ':d':
case ':dartrix': // Config.appName :
return [
{
'name': Config.appName,
'version': Config.appVersion,
'docstring': 'Builtin templates',
'scope': 'builtin',
'rootUri': path.canonicalize(Config.appPkgRoot)
}
];
break;
case ':h':
case ':home':
case ':u':
case ':user':
return listUserLib();
break;
case ':l':
case ':local': // return listLocalLib();
//FIXME: verify it exists
return [
{
'name': ':local', //'dartrix',
'version': null,
'docstring': 'Local template library',
'scope': 'local',
'rootUri': '/usr/local/share/dartrix'
}
];
default:
if (templateLibName.startsWith(':')) {
return await resolvePluginPkg(templateLibName.substring(1));
} else {
Config.prodLogger.e(
'Invalid library tag: ${templateLibName}. Library begin with \':\'. Did you mean \':${templateLibName}\'?');
return null;
}
}
}