Skip to content

Commit 28c0878

Browse files
committed
fix module package id retreive/store/register (step 1)
1 parent c6b82fa commit 28c0878

9 files changed

Lines changed: 59 additions & 26 deletions

File tree

OrbitalShell-CLI/OrbitalShell-CLI.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<Product>Orbital Shell</Product>
1919
<Description>This is the Orbital Shell CLI binaries for any plateform (having dotnet) and also self-contained apps for common runtimes environments (win-x64,linux-x64,linux-musl-x64,linux-arm,linux-arm64). Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# .Net Core.</Description>
2020
<Copyright>(c) 2020 Licence MIT</Copyright>
21-
<Version>1.0.5</Version>
22-
<InformationalVersion>1.0.5</InformationalVersion>
21+
<Version>1.0.6</Version>
22+
<InformationalVersion>1.0.6</InformationalVersion>
2323

2424
<PackageReleaseNotes>initial stable release (milestone 1)</PackageReleaseNotes>
2525
<ApplicationIcon>assets\robotazteque.ico</ApplicationIcon>

OrbitalShell-CLI/Scripts/publish-binaries.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!porbsh
22
# build/publish orbital shell binaries
33

4-
set version 1.0.5
4+
set version 1.0.6
55
set nugetext .nupkg
66

77
cls

OrbitalShell-ConsoleApp/OrbitalShell-ConsoleApp.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<Product>Orbital Shell - ConsoleApp</Product>
1616
<Description>Orbital Shell console application library</Description>
1717
<Copyright>(c) 2020 Licence MIT</Copyright>
18-
<Version>1.0.5</Version>
19-
<InformationalVersion>1.0.5</InformationalVersion>
18+
<Version>1.0.6</Version>
19+
<InformationalVersion>1.0.6</InformationalVersion>
2020

2121
<PackageReleaseNotes>milestone 1</PackageReleaseNotes>
2222
<PackageLicenseExpression>MIT</PackageLicenseExpression>

OrbitalShell-Kernel-Commands/Commands/Shell/ShellCommands_Mod.cs

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ public CommandResult<List<ModuleSpecification>> Module(
5151
bool fetchInfo = fetchInfoName != null;
5252
var clog = context.ShellEnv.Colors.Log;
5353
var o = context.Out;
54+
string n;
5455

5556
if (loadModulePath == null && unloadModuleName == null && updateModuleName == null && installModuleName == null && uninstallModuleName == null
5657
&& !fetchList && !fetchInfo)
5758
{
5859
// output reports on loaded modules
5960

6061
var col1length = context.CommandLineProcessor.ModuleManager.Modules.Values.Select(x => x.Name.Length).Max() + 1;
61-
int n = 1;
62+
int i = 1;
6263
foreach (var kvp in context.CommandLineProcessor.ModuleManager.Modules)
6364
{
6465
var ver = kvp.Value.Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
@@ -92,22 +93,46 @@ public CommandResult<List<ModuleSpecification>> Module(
9293
{
9394
o.Echoln($"{"".PadRight(col1length, ' ')}{context.ShellEnv.Colors.Label}version : {context.ShellEnv.Colors.HalfDark}{ver} (target {((target == null) ? "" : target + ", ")}created {dat}) {context.ShellEnv.Colors.Label}Company : (rdc){comp} ({aut}) ");
9495
}
95-
if (n < context.CommandLineProcessor.ModuleManager.Modules.Count) o.Echoln();
96-
n++;
96+
if (i < context.CommandLineProcessor.ModuleManager.Modules.Count) o.Echoln();
97+
i++;
9798
}
9899
return new CommandResult<List<ModuleSpecification>>(context.CommandLineProcessor.ModuleManager.Modules.Values.ToList());
99100
}
100101

101102
if (!fetchList && !fetchInfo)
102103
{
104+
// update module name
105+
106+
if (updateModuleName!=null)
107+
{
108+
n = updateModuleName;
109+
if (ModuleUtil.IsModuleInstalled(context, n))
110+
{
111+
var modSpec = context.CommandLineProcessor.ModuleManager.GetModule(context, n);
112+
if (modSpec == null)
113+
return _ModuleErr(context, $"module specification not found for module name '{n}'");
114+
115+
var getVersMethod = typeof(NuGetServerApiCommands).GetMethod("NugetVer");
116+
var r = context.CommandLineProcessor.Eval(context, getVersMethod, $"{n}", 0);
117+
if (r.EvalResultCode == (int)ReturnCode.OK)
118+
{
119+
var vers = (PackageVersions)r.Result;
120+
}
121+
else
122+
return _ModuleErr(context, $"module id '{n}' not found at NuGet");
123+
} else
124+
return _ModuleErr(context, $"module '{n}' is not installed");
125+
}
126+
103127
// uninstall module
104128

105129
if (uninstallModuleName!=null)
106130
{
107-
var folderName = uninstallModuleName.ToLower();
131+
n = uninstallModuleName;
132+
var folderName = n.ToLower();
108133
if (!ModuleUtil.IsModuleInstalled( context, folderName ))
109134
// error not installed
110-
return _ModuleErr(context, $"module '{uninstallModuleName}' is not installed");
135+
return _ModuleErr(context, $"module '{n}' is not installed");
111136

112137
o.Echoln(clog + "removing potentially registered dlls:");
113138
var modInit = ModuleUtil.LoadModuleInitConfiguration(context);
@@ -133,12 +158,13 @@ public CommandResult<List<ModuleSpecification>> Module(
133158

134159
if (installModuleName != null)
135160
{
161+
n = installModuleName;
136162
var lastVer = string.IsNullOrWhiteSpace(version);
137163

138164
#region fetch module info
139165

140166
var queryMethod = typeof(NuGetServerApiCommands).GetMethod("NugetQuery");
141-
var r0 = context.CommandLineProcessor.Eval(context, queryMethod, $"{installModuleName} -t 1",0);
167+
var r0 = context.CommandLineProcessor.Eval(context, queryMethod, $"{n} -t 1",0);
142168
if (r0.EvalResultCode!=(int)ReturnCode.OK) return _ModuleErr(context, r0.ErrorReason);
143169
var queryRes = r0.Result as QueryResultRoot;
144170
if (queryRes==null) return _ModuleErr(context, "nuget query return a null result");
@@ -150,7 +176,7 @@ public CommandResult<List<ModuleSpecification>> Module(
150176
o.Echoln();
151177

152178
var getVersMethod = typeof(NuGetServerApiCommands).GetMethod("NugetVer");
153-
var r = context.CommandLineProcessor.Eval(context, getVersMethod, $"{installModuleName}", 0);
179+
var r = context.CommandLineProcessor.Eval(context, getVersMethod, $"{n}", 0);
154180
if (r.EvalResultCode==(int)ReturnCode.OK)
155181
{
156182
var vers = (PackageVersions)r.Result;
@@ -179,7 +205,7 @@ public CommandResult<List<ModuleSpecification>> Module(
179205
if (!Directory.Exists(moduleFolder)) Directory.CreateDirectory(moduleFolder);
180206

181207
moduleFolder = FileSystemPath.UnescapePathSeparators(moduleFolder);
182-
var rd = context.CommandLineProcessor.Eval(context, dwnMethod, $"{installModuleName} {version} -o {moduleFolder}", 0);
208+
var rd = context.CommandLineProcessor.Eval(context, dwnMethod, $"{n} {version} -o {moduleFolder}", 0);
183209
if (rd.EvalResultCode==(int)ReturnCode.OK)
184210
{
185211
o.Echo(clog + "extracting package... ");
@@ -265,17 +291,18 @@ public CommandResult<List<ModuleSpecification>> Module(
265291
return _ModuleErr(null,null);
266292
}
267293

268-
// unload module
294+
// unload module (unregistered in session)
269295

270296
if (unloadModuleName != null)
271297
{
272-
if (context.CommandLineProcessor.ModuleManager.Modules.Values.Any(x => x.Name == unloadModuleName))
298+
n = unloadModuleName;
299+
if (context.CommandLineProcessor.ModuleManager.Modules.Values.Any(x => x.Name == n))
273300
{
274-
moduleSpecification = context.CommandLineProcessor.ModuleManager.UnregisterModule(context, unloadModuleName);
301+
moduleSpecification = context.CommandLineProcessor.ModuleManager.UnregisterModule(context, n);
275302
if (moduleSpecification != null && moduleSpecification.Info != null) o.Echoln($"unloaded: {moduleSpecification.Info.GetDescriptor(context)}");
276303
}
277304
else
278-
return _ModuleErr(context, $"module '{unloadModuleName}' is not registered");
305+
return _ModuleErr(context, $"module '{n}' is not registered");
279306
}
280307
}
281308
else

OrbitalShell-Kernel-Commands/ModuleInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
/// <summary>
55
/// declare a shell module
66
/// </summary>
7-
[assembly: ShellModule()]
7+
[assembly: ShellModule("OrbitalShell-Kernel-Commands")]
88
[assembly: ModuleTargetPlateform(TargetPlatform.Any)]
9-
[assembly: ModuleShellMinVersion("1.0.1-beta4")]
9+
[assembly: ModuleShellMinVersion("1.0.6")]
1010
[assembly: ModuleAuthors("Orbital Shell team")]
1111
namespace OrbitalShell.Kernel.Commands
1212
{

OrbitalShell-Kernel-Commands/OrbitalShell-Kernel-Commands.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<Product>Orbital Shell - Kernel commands module</Product>
1616
<Description>Orbital Shell kernel commands module. Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# .Net Core</Description>
1717
<Copyright>(c) Orbital Shell 2020</Copyright>
18-
<Version>1.0.2</Version>
19-
<InformationalVersion>1.0.2</InformationalVersion>
18+
<Version>1.0.6</Version>
19+
<InformationalVersion>1.0.6</InformationalVersion>
2020

2121
<PackageReleaseNotes>milestone 1</PackageReleaseNotes>
2222
<PackageLicenseExpression>MIT</PackageLicenseExpression>

OrbitalShell-Kernel/Component/Shell/Module/ShellModuleAttribute.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ namespace OrbitalShell.Component.Shell.Module
88
[AttributeUsage(AttributeTargets.Assembly)]
99
public class ShellModuleAttribute : Attribute
1010
{
11-
public ShellModuleAttribute() { }
11+
public readonly string PackageId;
12+
13+
/// <summary>
14+
/// declare the assembly beeing a shell module having the specified package ID (must match PackageID in .csproj)
15+
/// </summary>
16+
/// <param name="packageId"></param>
17+
public ShellModuleAttribute(string packageId) { PackageId = packageId; }
1218
}
1319
}

OrbitalShell-Kernel/ModuleInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
/// <summary>
55
/// declare a shell module
66
/// </summary>
7-
[assembly: ShellModule()]
7+
[assembly: ShellModule("OrbitalShell-Kernel")]
88
[assembly: ModuleTargetPlateform(TargetPlatform.Any)]
9-
[assembly: ModuleShellMinVersion("1.0.1-beta4")]
9+
[assembly: ModuleShellMinVersion("1.0.6")]
1010
[assembly: ModuleAuthors("Orbital Shell team")]
1111
namespace OrbitalShell.Kernel
1212
{

OrbitalShell-Kernel/OrbitalShell-Kernel.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<Product>Orbital Shell - Kernel</Product>
1616
<Description>Orbital Shell kernel - Orbital Shell is a command shell based inspired by bash and POSIX recommendations, coded in C# .Net Core</Description>
1717
<Copyright>(c) 2020 Licence MIT</Copyright>
18-
<Version>1.0.2</Version>
19-
<InformationalVersion>1.0.2</InformationalVersion>
18+
<Version>1.0.6</Version>
19+
<InformationalVersion>1.0.6</InformationalVersion>
2020

2121
<PackageReleaseNotes>milestone 1</PackageReleaseNotes>
2222
<PackageLicenseExpression>MIT</PackageLicenseExpression>

0 commit comments

Comments
 (0)