Skip to content

Commit

Permalink
0.3.10
Browse files Browse the repository at this point in the history
- Make --clear-log known
- Use .AppImage extension by default
  • Loading branch information
phil-harmoniq authored Nov 27, 2017
2 parents c55e6a9 + 4b47f55 commit c37477b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 23 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ before_script:

script:
- "git clone https://github.com/phil-harmoniq/Hello $TRAVIS_BUILD_DIR/Hello"
- "$HOME/netpkg-tool $TRAVIS_BUILD_DIR/Hello $HOME -v -n Hello.AppImage"
- "$HOME/netpkg-tool $TRAVIS_BUILD_DIR/Hello $HOME -v"
- "$HOME/Hello.AppImage one two thr33 --npk-v four"
- "$HOME/netpkg-tool $TRAVIS_BUILD_DIR/Hello $HOME --scd --keep -c"
- "$HOME/netpkg-tool $TRAVIS_BUILD_DIR/Hello $HOME -c --scd --keep --noext"
- "$HOME/Hello one two thr33 --npk-v four"
- "$HOME/netpkg-tool $TRAVIS_BUILD_DIR/Hello $HOME -c --scd --keep -n HelloApp"
- "$HOME/HelloApp one two thr33 --npk-v four"

deploy:
provider: releases
Expand Down
55 changes: 41 additions & 14 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Program
static bool CustomAppName = false;
static bool SelfContainedDeployment = false;
static bool KeepTempFiles = false;
static string Extension = ".AppImage";

static void Main(string[] args)
{
Expand All @@ -49,11 +50,19 @@ static void Main(string[] args)
static void CheckPaths(string[] args)
{
if (args.Length < 2 || !Directory.Exists(args[0]) && !Directory.Exists(args[1]))
{
ExitWithError("You must specify a valid .NET project AND Destination folder.", 6);
}
if (Directory.Exists(args[0]) && !Directory.Exists(args[1]))
ExitWithError($"{args[1]} is not a valid folder", 7);
{
if (Bash.Command($"mkdir -p {args[1]}").ExitCode != 0)
ExitWithError($"{args[1]} is not a valid folder", 7);
}
if (!Directory.Exists(args[0]) && Directory.Exists(args[1]))
ExitWithError($"{args[0]} is not a valid folder", 8);
{
if (Bash.Command($"mkdir -p {args[0]}").ExitCode != 0)
ExitWithError($"{args[0]} is not a valid folder", 8);
}

ProjectDir = GetRelativePath(args[0]);
Destination = GetRelativePath(args[1]);
Expand Down Expand Up @@ -96,6 +105,10 @@ static void ParseArgs(string[] args)
{
HelpMenu();
}
else if (args[i] == "--noext")
{
Extension = "";
}
}
}

Expand All @@ -116,13 +129,13 @@ static void FindCsproj(string project)
DllName = string.Join('.', nameSplit.Take(nameSplit.Length - 1));

if (!CustomAppName)
AppName = DllName;
AppName = $"{DllName}{Extension}";

if (SingleRuntimeIdentifier() && !SelfContainedDeployment)
{
SelfContainedDeployment = true;
Printer.WriteLine(
$"{Clr.Yellow}Caution: runtime identifier detected. Making self-contained app.{Clr.Default}");
$"{Clr.Yellow}Caution: Single runtime identifier detected. Using --scd{Clr.Default}");
}
}

Expand Down Expand Up @@ -253,7 +266,8 @@ static void HelpMenu()
+ @" --name or -n: Set ouput file to a custom name\n"
+ @" --scd or -s: Self-Contained Deployment (SCD)\n"
+ @" --keep or -k: Keep /tmp/{AppName}.temp directory\n"
+ @" --help or -h: Help menu (this page)\n\n"
+ @" --help or -h: Help menu (this page)\n"
+ @" --clear-log: Delete error log at ~/.netpkg-tool\n\n"
+ @" More information & source code available on github:\n"
+ @" https://github.com/phil-harmoniq/netpkg-tool\n"
+ @" Copyright (c) 2017 - MIT License\n"
Expand All @@ -264,9 +278,19 @@ static void HelpMenu()

static void ClearLogs()
{
Console.Write($"Clear log at {GetRelativePath(ConfigDir)}/error.log");
Bash.Rm($"{ConfigDir}/error.log", "-f");
CheckCommandOutput(errorCode: 5);
Console.Write($"Clear error log at {GetRelativePath(ConfigDir)}/error.log...");

if (File.Exists($"{ConfigDir}/error.log"))
{
Bash.Rm($"{ConfigDir}/error.log");
CheckCommandOutput(errorCode: 5);
}
else
{
SayCaution();
Printer.WriteLine($"{Clr.Yellow}Error log file already removed.{Clr.Default}");
}

SayBye();
Environment.Exit(0);
}
Expand All @@ -291,16 +315,16 @@ static void WriteToErrorLog(string message, int code)
if (!Directory.Exists(ConfigDir))
Directory.CreateDirectory(ConfigDir);

using (var tw = new StreamWriter($"{ConfigDir}/error.log", true))
using (var log = new StreamWriter($"{ConfigDir}/error.log", true))
{
var now = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
var dir = Directory.GetCurrentDirectory();

tw.WriteLine($"{new string('-', Width)}");
tw.WriteLine($"{GetRelativePath(dir)}$ netpkg-tool {string.Join(' ', Args)}");
tw.WriteLine($"Errored with code {code} - ({now}):\n");
tw.WriteLine(message.TrimEnd('\n'));
tw.WriteLine($"{new string('-', Width)}");
log.WriteLine($"{new string('-', Width)}");
log.WriteLine($"{GetRelativePath(dir)}$ netpkg-tool {string.Join(' ', Args)}");
log.WriteLine($"Errored with code {code} - ({now}):\n");
log.WriteLine(message.TrimEnd('\n'));
log.WriteLine($"{new string('-', Width)}");
}
}

Expand Down Expand Up @@ -336,6 +360,9 @@ static void SayFinished(string message) =>
static void SayPass() =>
Printer.WriteLine($" {Frmt.Bold}[ {Clr.Green}PASS{Clr.Default} ]{Reset.Code}");

static void SayCaution() =>
Printer.WriteLine($" {Frmt.Bold}[ {Clr.Yellow}PASS{Clr.Default} ]{Reset.Code}");

static void SayFail() =>
Printer.WriteLine($" {Frmt.Bold}[ {Clr.Red}FAIL{Clr.Default} ]{Reset.Code}");
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
Pre-packaged versions of *netpkg-tool* are available from the [releases tab](https://github.com/phil-harmoniq/netpkg-tool/releases):

```bash
# Github releases are tagged with their version (ex: 0.3.9)
wget https://github.com/phil-harmoniq/netpkg-tool/releases/download/0.3.9/netpkg-tool
# Github releases are tagged with their version (ex: 0.3.10)
wget https://github.com/phil-harmoniq/netpkg-tool/releases/download/0.3.10/netpkg-tool
chmod a+x ./netpkg-tool

# Place netpkg-tool somewhere on your $PATH (Optional)
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ else
mv "$PWD/squashfs-root" "$HERE/appimagetool"
rm "$HERE/appimagetool.AppImage"
fi
dotnet run --project "$HERE" "$HERE" "$1"
dotnet run --project "$HERE" "$HERE" "$1" --noext --keep
fi
2 changes: 1 addition & 1 deletion file-transfer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fi
# Create an AppRun launcher
touch /tmp/"$APP_NAME".temp/AppRun
{
echo '#! /usr/bin/env bash'
echo '#!/usr/bin/env bash'
echo
echo 'export HERE=$(dirname "$(readlink -f "${0}")")'
echo 'export NET_PKG='\""$NET_PKG"\"
Expand Down
6 changes: 3 additions & 3 deletions netpkg-tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Authors>Phil Hawkins</Authors>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<VersionPrefix>0.3.9</VersionPrefix>
<VersionPrefix>0.3.10</VersionPrefix>
<VersionSuffix>alpha</VersionSuffix>
<Description>Bundle .NET Core applications into convenient Linux binaries using appimagetool</Description>
<Copyright>MIT</Copyright>
Expand All @@ -17,8 +17,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shell.Net" Version="0.2.0"/>
<PackageReference Include="ConsoleColors" Version="0.1.9-alpha"/>
<PackageReference Include="Shell.Net" Version="0.2.2"/>
<PackageReference Include="ConsoleColors" Version="0.1.10-alpha"/>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit c37477b

Please sign in to comment.