...
parent
df55836c58
commit
1befc2e053
@ -0,0 +1 @@
|
||||
select * from ApiKLeys;
|
@ -0,0 +1,13 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isn.Abstract
|
||||
{
|
||||
public class ApiIndexViewModel
|
||||
{
|
||||
[JsonProperty("version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
[JsonProperty("resources")]
|
||||
public Resource[] Resources { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace isn.abst
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public const string PublishCommandId = "PackagePublish/2.0.0";
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Controllers
|
||||
namespace isn.Abstract
|
||||
{
|
||||
public class Resource
|
||||
{
|
@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net4.7.2</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,9 @@
|
||||
namespace isn
|
||||
{
|
||||
public class IsnSourceSettings
|
||||
{
|
||||
internal string Source { get; set; }
|
||||
|
||||
internal string[] Keys { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace isn
|
||||
{
|
||||
public class IsndErrorMessage
|
||||
{
|
||||
public int ecode { get; set; }
|
||||
public string msg { get; set; }
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Mono.Options;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isn
|
||||
{
|
||||
|
||||
partial class Program
|
||||
{
|
||||
private static void SourceList(IEnumerable<string> sargs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static object SourceAdd(IEnumerable<string> str)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static object Add(IEnumerable<string> str)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static async Task<List<PushReport>> PushPkgAsync(IEnumerable<string> pkgs)
|
||||
{
|
||||
List<PushReport> pushReports = new List<PushReport>();
|
||||
|
||||
foreach (string pkg in pkgs)
|
||||
{
|
||||
var report = await PushCommand.RunAsync(pkg, source, apiKey);
|
||||
|
||||
pushReports.Add(report);
|
||||
}
|
||||
if (storApiKey)
|
||||
{
|
||||
EnsureKeyStored();
|
||||
}
|
||||
return pushReports;
|
||||
}
|
||||
static OptionSet storeoptions = new OptionSet {
|
||||
{ "s|source=", "use source", val => source = source ?? val },
|
||||
{ "h|help", "show this message and exit", h => shouldShowPushHelp = h != null },
|
||||
};
|
||||
private static string _configFileName =
|
||||
Path.Combine(
|
||||
Path.Combine(Environment.GetFolderPath(
|
||||
Environment.SpecialFolder.UserProfile), ".isn"),
|
||||
"config.json")
|
||||
;
|
||||
|
||||
public class IsnSourceSettings
|
||||
{
|
||||
internal string Source { get; set; }
|
||||
|
||||
internal string[] Keys { get; set; }
|
||||
}
|
||||
public static IEnumerable<IsnSourceSettings> Sources { get; protected set; }
|
||||
|
||||
private static void StoreApiKey(IEnumerable<string> storeArgs)
|
||||
{
|
||||
var args = storeoptions.Parse(storeArgs);
|
||||
if (shouldShowPushHelp)
|
||||
{
|
||||
// output the options
|
||||
Console.Error.WriteLine("Push Options:");
|
||||
storeoptions.WriteOptionDescriptions(Console.Out);
|
||||
}
|
||||
else
|
||||
{
|
||||
apiKey = args[0];
|
||||
EnsureKeyStored();
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnsureKeyStored()
|
||||
{
|
||||
if (source == null) return;
|
||||
|
||||
if (Settings.Sources.ContainsKey(source))
|
||||
{
|
||||
if (apiKey == null)
|
||||
{
|
||||
// Une suppression
|
||||
Settings.Sources.Remove(source);
|
||||
if (Settings.DefaultSource == source) Settings.DefaultSource = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Une mise À jour
|
||||
string ptd = Protector.Protect(apiKey);
|
||||
Settings.Sources[source].ApiKey = ptd;
|
||||
if (Settings.DefaultSource == null) Settings.DefaultSource = source;
|
||||
}
|
||||
}
|
||||
else if (apiKey != null)
|
||||
{
|
||||
// une addition
|
||||
string ptd = Protector.Protect(apiKey);
|
||||
Settings.Sources.Add(source, new SourceSettings { ApiKey = ptd });
|
||||
}
|
||||
else return;
|
||||
FileInfo cfgSettingIf = new FileInfo(_configFileName);
|
||||
if (!cfgSettingIf.Directory.Exists) cfgSettingIf.Directory.Create();
|
||||
File.WriteAllText(
|
||||
cfgSettingIf.FullName,
|
||||
JsonConvert.SerializeObject(
|
||||
Settings,
|
||||
Formatting.Indented
|
||||
));
|
||||
}
|
||||
|
||||
public static void LoadConfig()
|
||||
{
|
||||
FileInfo cfgSettingIf = new FileInfo(_configFileName);
|
||||
if (cfgSettingIf.Exists)
|
||||
{
|
||||
var json = File.ReadAllText(cfgSettingIf.FullName);
|
||||
settings = JsonConvert.DeserializeObject<Settings>(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using isn.Abstract;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isn
|
||||
{
|
||||
public static class SourceHelpers
|
||||
{
|
||||
public static async Task<ApiIndexViewModel> GetServerResourcesAsync(string url)
|
||||
{
|
||||
HttpClient client = new HttpClient();
|
||||
client.DefaultRequestHeaders.Add("content-type","application/json; utf-8");
|
||||
using (var indexResponse = await client.GetAsync(url))
|
||||
{
|
||||
var json = await indexResponse.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<ApiIndexViewModel>(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace isn
|
||||
{
|
||||
|
||||
partial class Program
|
||||
{
|
||||
private static async Task<List<PushReport>> PushPkgAsync(IEnumerable<string> pkgs)
|
||||
{
|
||||
List<PushReport> pushReports = new List<PushReport>();
|
||||
|
||||
foreach (string pkg in pkgs)
|
||||
{
|
||||
var report = await PushCommand.RunAsync(pkg, source, apiKey);
|
||||
|
||||
pushReports.Add(report);
|
||||
}
|
||||
if (storApiKey)
|
||||
{
|
||||
EnsureKeyStored();
|
||||
}
|
||||
return pushReports;
|
||||
}
|
||||
|
||||
private static object Add(IEnumerable<string> str)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace isn
|
||||
{
|
||||
|
||||
partial class Program
|
||||
{
|
||||
|
||||
private static void StoreApiKey(IEnumerable<string> storeArgs)
|
||||
{
|
||||
var args = storeoptions.Parse(storeArgs);
|
||||
if (shouldShowPushHelp)
|
||||
{
|
||||
// output the options
|
||||
Console.Error.WriteLine("Push Options:");
|
||||
storeoptions.WriteOptionDescriptions(Console.Out);
|
||||
}
|
||||
else
|
||||
{
|
||||
apiKey = args[0];
|
||||
EnsureKeyStored();
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnsureKeyStored()
|
||||
{
|
||||
if (source == null) return;
|
||||
|
||||
if (Settings.Sources.ContainsKey(source))
|
||||
{
|
||||
if (apiKey == null)
|
||||
{
|
||||
// Une suppression
|
||||
Settings.Sources.Remove(source);
|
||||
if (Settings.DefaultSource == source) Settings.DefaultSource = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Une mise À jour
|
||||
string ptd = Protector.Protect(apiKey);
|
||||
Settings.Sources[source].ApiKey = ptd;
|
||||
if (Settings.DefaultSource == null) Settings.DefaultSource = source;
|
||||
}
|
||||
}
|
||||
else if (apiKey != null)
|
||||
{
|
||||
// une addition
|
||||
string ptd = Protector.Protect(apiKey);
|
||||
Settings.Sources.Add(source, new SourceSettings { ApiKey = ptd });
|
||||
}
|
||||
else return;
|
||||
FileInfo cfgSettingIf = new FileInfo(_configFileName);
|
||||
if (!cfgSettingIf.Directory.Exists) cfgSettingIf.Directory.Create();
|
||||
File.WriteAllText(
|
||||
cfgSettingIf.FullName,
|
||||
JsonConvert.SerializeObject(
|
||||
Settings,
|
||||
Formatting.Indented
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace isn
|
||||
{
|
||||
|
||||
partial class Program
|
||||
{
|
||||
|
||||
private static void ShowConfig()
|
||||
{
|
||||
Console.WriteLine(JsonConvert.SerializeObject(Settings));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isn
|
||||
{
|
||||
|
||||
partial class Program
|
||||
{
|
||||
private static void SourceAdd(IEnumerable<string> str)
|
||||
{
|
||||
foreach (string arg in str)
|
||||
{
|
||||
if (Settings.Sources.ContainsKey(arg))
|
||||
{
|
||||
SourceSettings setting = Settings.Sources[arg];
|
||||
throw new InvalidOperationException
|
||||
(setting.Alias);
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace isn
|
||||
{
|
||||
|
||||
partial class Program
|
||||
{
|
||||
private static void SourceList(IEnumerable<string> sargs)
|
||||
{
|
||||
IEnumerable<string> spec = sargs.Count()>0 ? sargs : Settings.Sources.Keys;
|
||||
foreach (string arg in spec)
|
||||
{
|
||||
SourceSettings setting = Settings.Sources[arg];
|
||||
Console.WriteLine(JsonConvert.SerializeObject(setting));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1,17 +0,0 @@
|
||||
using static isn.tests.Tests;
|
||||
|
||||
namespace isn.tests
|
||||
{
|
||||
internal class Engine : INeedEngine
|
||||
{
|
||||
public Engine()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public object Parse(string code)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
namespace isn.tests
|
||||
{
|
||||
internal interface IBody
|
||||
{
|
||||
/// <summary>
|
||||
/// The mult
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
T Action<T>(T v);
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
namespace isn.tests
|
||||
{
|
||||
internal interface IRing : IBody
|
||||
{
|
||||
|
||||
|
||||
IRing Add(IRing other);
|
||||
IRing Mult<TBody>(TBody v);
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
namespace isn.tests
|
||||
{
|
||||
internal class Body : IBody
|
||||
{
|
||||
static public Ring One { get ;}
|
||||
|
||||
public T Action<T>(T v)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
internal class Ring : Body, IRing
|
||||
{
|
||||
public static IRing Zero => throw new System.NotImplementedException();
|
||||
|
||||
|
||||
public IRing Add(IRing unity)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public IRing Mult<TBody>(TBody v)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue