presentation & tools

This commit is contained in:
Paul Schneider 2019-06-22 19:34:39 +01:00
commit 4c496e08d1
76 changed files with 3973 additions and 254 deletions

View file

@ -1,16 +1,20 @@
{
"tools": {
"env": [],
"build" :{
},
"prepare": {
"make": {}
},
"projects": {
"post_build": {
"yavsc": {
"type": "make",
"source" : {
"github": "pazof/yavsc",
"branch": "vnext"
},
"env": [],
"args": []
}
}
},
"emails": []
}

View file

@ -7,7 +7,6 @@ namespace cli
{
public partial class Program
{
public static void Main(string[] args)
{
CommandOption rootCommandHelpOption = null;

View file

@ -1,32 +1,10 @@
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
public class CiBuildSettings
{
/// <summary>
/// A command specification (a system command),
/// in order to reference some trusted server-side process
/// </summary>
public class Command
{
[Required]
[JsonPropertyAttribute("path")]
public string Path { get; set; }
[JsonPropertyAttribute("args")]
public string[] Args { get; set; }
/// <summary>
/// Specific variables to this process
/// </summary>
/// <value></value>
///
[JsonPropertyAttribute("env")]
public string[] Environment { get; set; }
[JsonPropertyAttribute("working_dir")]
public string WorkingDir { get; set; }
}
/// <summary>
/// The global process environment variables
/// </summary>
@ -40,7 +18,7 @@ public class CiBuildSettings
/// <value></value>
[Required]
[JsonPropertyAttribute("build")]
public Command Build { get; set; }
public CommandPipe Build { get; set; }
/// <summary>
/// A preparing command.
@ -49,7 +27,7 @@ public class CiBuildSettings
/// </summary>
/// <value></value>
[JsonPropertyAttribute("prepare")]
public Command Prepare { get; set; }
public CommandPipe Prepare { get; set; }
/// <summary>
/// A post-production command,
@ -59,7 +37,7 @@ public class CiBuildSettings
/// </summary>
/// <value></value>
[JsonPropertyAttribute("post_build")]
public Command PostBuild { get; set; }
public CommandPipe PostBuild { get; set; }
/// <summary>
/// Additional emails, as dest of notifications

View file

@ -0,0 +1,36 @@
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using Newtonsoft.Json;
/// <summary>
/// A command specification (a system command),
/// in order to reference some trusted server-side process
/// </summary>
public class Command
{
[Required]
[JsonPropertyAttribute("path")]
public string Path { get; set; }
[JsonPropertyAttribute("args")]
public string[] Args { get; set; }
/// <summary>
/// Specific variables for this process
/// </summary>
/// <value></value>
[JsonPropertyAttribute("env")]
public string[] Environment { get; set; }
public virtual Process Start(string workingDir=null, bool redirectInput=false, bool redirectOutput=false)
{
var procStart = new ProcessStartInfo(Path, string.Join(" ",Args));
procStart.WorkingDirectory = workingDir;
procStart.UseShellExecute = false;
procStart.RedirectStandardInput = true;
procStart.RedirectStandardOutput = true;
procStart.RedirectStandardError = false;
return Process.Start(procStart);
}
}

View file

@ -0,0 +1,64 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class CommandPipe
{
[JsonPropertyAttribute("pipe")]
public Command[] Pipe { get; set; }
[JsonPropertyAttribute("working_dir")]
public string WorkingDir { get; set; }
public virtual int Run()
{
Process latest = null;
Queue<Process> runQueue = new Queue<Process>();
Queue<Task> joints = new Queue<Task>();
if (Pipe.Length == 0) return -1;
if (Pipe.Length == 1)
{
latest = Pipe[0].Start();
latest.WaitForExit();
return latest.ExitCode;
}
for (int i = 0; i < Pipe.Length; i++)
{
Process newProcess = null;
var cmd = Pipe[i];
bool isNotLast = (i + 1) >= Pipe.Length;
if (latest != null) // i.e. isNotFirst
{
newProcess = cmd.Start(WorkingDir, true, isNotLast);
var jt = Task.Run(async () =>
{
while (!latest.HasExited && !newProcess.HasExited)
{
string line = await latest.StandardOutput.ReadLineAsync();
if (line != null)
await newProcess.StandardInput.WriteLineAsync(line);
}
});
joints.Enqueue(jt);
}
else
{
newProcess = cmd.Start(WorkingDir, false, isNotLast);
Task ending = Task.Run(() => { latest.WaitForExit(); });
joints.Enqueue(ending);
}
latest = newProcess;
runQueue.Enqueue(latest);
}
while (runQueue.Count > 0)
(latest = runQueue.Dequeue()).WaitForExit();
return latest.ExitCode;
}
}

View file

@ -6,19 +6,15 @@
<version>$version$</version>
<authors>Paul Schneider</authors>
<owners>Paul Schneider</owners>
<licenseUrl>https://github.com/pazof/yavsc/blob/vnext/Yavsc/License.md</licenseUrl>
<projectUrl>https://github.com/pazof/yavsc/README.md</projectUrl>
<iconUrl>https://github.com/pazof/yavsc/blob/vnext/Yavsc/wwwroot/images/yavsc.png</iconUrl>
<License>https://github.com/pazof/yavsc/blob/vnext/LICENSE</License>
<projectUrl>https://github.com/pazof/yavsc/blob/vnext/README.md</projectUrl>
<iconUrl>http://yavsc.pschneider.fr/images/yavsc.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>
A command line interface to Yavsc server runtime
</description>
<summary>
</summary>
<tags>Blog, POS, Web API</tags>
<description>A command line interface to Yavsc server API's</description>
<tags></tags>
<dependencies>
<dependency id="Yavsc.Server" version="$version$"></dependency>
</dependencies>
</dependencies>
</metadata>
<files>
<file src="bin/$config$/dnx451/cli.dll" target="lib/portable-net45+win8+wp8+wpa81+Xamarin.Mac+MonoAndroid10+MonoTouch10+Xamarin.iOS10" />

96
src/cli/jsonSchema Normal file
View file

@ -0,0 +1,96 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "CiBuildSettings",
"type": "object",
"additionalProperties": false,
"required": [
"build"
],
"properties": {
"env": {
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"build": {
"minLength": 1,
"oneOf": [
{
"$ref": "#/definitions/Command"
}
]
},
"prepare": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/definitions/Command"
}
]
},
"post_build": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/definitions/Command"
}
]
},
"emails": {
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
}
},
"definitions": {
"Command": {
"type": "object",
"additionalProperties": false,
"required": [
"path"
],
"properties": {
"path": {
"type": "string",
"minLength": 1
},
"args": {
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"env": {
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"working_dir": {
"type": [
"null",
"string"
]
}
}
}
}
}

View file

@ -0,0 +1,96 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "CiBuildSettings",
"type": "object",
"additionalProperties": false,
"required": [
"build"
],
"properties": {
"env": {
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"build": {
"minLength": 1,
"oneOf": [
{
"$ref": "#/definitions/Command"
}
]
},
"prepare": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/definitions/Command"
}
]
},
"post_build": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/definitions/Command"
}
]
},
"emails": {
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
}
},
"definitions": {
"Command": {
"type": "object",
"additionalProperties": false,
"required": [
"path"
],
"properties": {
"path": {
"type": "string",
"minLength": 1
},
"args": {
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"env": {
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"working_dir": {
"type": [
"null",
"string"
]
}
}
}
}
}

View file

@ -65,8 +65,8 @@
},
"frameworks": {
"dnx451": {
"System.Net": "4.0.0.0",
"System.Xml": "4.0.0.0"
"System.Net": {},
"System.Xml": {}
}
}
}