Skip to content

Commit

Permalink
[FEATURE] Install with dotnet tool - nuget pack (#1)
Browse files Browse the repository at this point in the history
* log version
* manifest json
* conf
* add new nice options
* add readme
* Description add
* add icon
* Changelog
* add install readme
* remove auto releaser (it will be done in another PR)
* add badge for NuGet
* Target Frameworks - 6,7,8 dotnet
* new icon for readme + move local development section
* remove extra line
* better version log
  • Loading branch information
jurczewski committed Jun 15, 2024
1 parent 0739f8a commit d70a14d
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": "1.0.0",
"isRoot": true,
"tools": {}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ bld/
msbuild.log
msbuild.err
msbuild.wrn

/nupkg/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 🔑🔒 Changelog

## 1.0.0 - 2024.06.24

Initial release
53 changes: 34 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![100 - Commitów](https://img.shields.io/badge/100-Commitów-2ea44f)](https://100commitow.pl/)
[![Build](https://github.com/jurczewski/private-pdf-converter/actions/workflows/build.yaml/badge.svg)](https://github.com/jurczewski/private-pdf-converter/actions/workflows/build.yaml)
[![NuGet version (PrivatePdfConverter)](https://img.shields.io/nuget/v/PrivatePdfConverter.svg?style=flat-square)](https://www.nuget.org/packages/PrivatePdfConverter/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Linkedin](https://img.shields.io/badge/Linkedin-0882bd?logo=linkedin)](https://www.linkedin.com/in/jurczewski/)

Expand All @@ -11,9 +12,7 @@

---

<div align="center">
<img src="assets/logo.jpeg" width="200" height="200" alt="Logo">
</div>
![Logo](./assets/logo-200x200.jpeg)

## ✒️ Description

Expand All @@ -30,6 +29,26 @@ In three words:

### **Small, offline, and convenient!**

## ⚡ Install

Just type to install:

```ps1
dotnet tool install --global PrivatePdfConverter
```

and then just run it!

```ps1
ppc dir --path "D:\dir-with-images"
```

Example of logo command:

```ps1
ppc logo --path "D:\1.pdf" --logo-path "D:\logo.png" --position "bottom-left" --scale 25 --opacity 50 --output "newpdf"
```

## 📐 Arguments

| Argument | Description | Options | Optional options |
Expand All @@ -49,22 +68,6 @@ In three words:

For all commends, default export .pdf file name is `output.pdf`.

Example of usage - build and run using [.NET 8.0](https://dotnet.microsoft.com/en-us/download):

```ps1
dotnet build
```

```ps1
.\PrivatePdfConverter.exe dir --path "D:\dir-with-images"
```

Example of logo command:

```ps1
logo --path "D:\1.pdf" --logo-path "D:\logo.png" --position "bottom-left" --scale 25 --opacity 50 --output "newpdf"
```

### 📌 Supported file extensions

Type `ext` argument to list all of valid image extensions:
Expand Down Expand Up @@ -117,6 +120,18 @@ If you want to contribute, please take a look at the [Roadmap](#️-features-roa

Please create a **Pull Request** with a solution if you are eager to help. Keep in mind the structure of a solution. If you are going to create a new command, make sure to do it in the [Commands](./src/PrivatePdfConverter/Commands/) directory.

### Local

Build and run using [.NET 8.0](https://dotnet.microsoft.com/en-us/download):

```ps1
dotnet build
```

```ps1
.\PrivatePdfConverter.exe dir --path "D:\dir-with-images"
```

### 🔗 Dependencies

Based on micro-framework [Cocona](https://github.com/mayuki/Cocona).
Expand Down
Binary file added assets/logo-200x200.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion src/PrivatePdfConverter/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,15 @@ public static void Initialize()
=> Log.Logger = new LoggerConfiguration()
.WriteTo.Console(theme: AnsiConsoleTheme.Code)
.CreateLogger();
}

public static void LogStart(string fullVersionString)
{
// Split the version string by '+' to get the version and the commit ID
var versionParts = fullVersionString.Split('+');
var shortVersion = versionParts[0];
var commitId = versionParts.Length > 1 ? versionParts[1] : "0.0.0";

// Log the message
Log.Logger.Information("--- PrivatePdfConverter v{VersionString} (commit: {CommitId}) ---", shortVersion, commitId);
}
}
63 changes: 46 additions & 17 deletions src/PrivatePdfConverter/PrivatePdfConverter.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;</TargetFrameworks>
<TargetFrameworks Condition="'$(LibraryFrameworks)'!=''">$(LibraryFrameworks)</TargetFrameworks>
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cocona.Lite" Version="2.2.0" />
<PackageReference Include="itext7" Version="8.0.4" />
<PackageReference Include="itext7.bouncy-castle-adapter" Version="8.0.4" />
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.9.1" />
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
</ItemGroup>
<PropertyGroup>
<PackageId>PrivatePdfConverter</PackageId>
<Title>PrivatePdfConverter</Title>
<Authors>Bartosz Jurczewski</Authors>
<PackageProjectUrl>https://github.com/jurczewski/private-pdf-converter</PackageProjectUrl>
<RepositoryUrl>https://github.com/jurczewski/private-pdf-converter</RepositoryUrl>
<RepositoryType>GIT</RepositoryType>
<Version>1.0.0</Version>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>logo.jpeg</PackageIcon>
<Description>Private PDF Converter is a secure offline tool designed to effortlessly convert PNG files stored locally into a comprehensive PDF document.</Description>
<Copyright>MIT</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>pdf, privacy, dotnet, pdf-converter, private, split-pdf, merge-pdf, merge-pdf-images, 100commits, 100commitow, cli, tool, dotnet-tool</PackageTags>
<PackageReleaseNotes>See https://github.com/jurczewski/private-pdf-converter/blob/master/CHANGELOG.md</PackageReleaseNotes>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

<ItemGroup>
<InternalsVisibleTo Include="PrivatePdfConverter.Tests" />
</ItemGroup>
<PackAsTool>true</PackAsTool>
<ToolCommandName>ppc</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cocona.Lite" Version="2.2.0"/>
<PackageReference Include="itext7" Version="8.0.4"/>
<PackageReference Include="itext7.bouncy-castle-adapter" Version="8.0.4"/>
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.9.1"/>
<PackageReference Include="Serilog" Version="4.0.0"/>
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0"/>
</ItemGroup>

<ItemGroup>
<None Include=".\..\..\README.md" Pack="true" PackagePath="\"/>
<None Include=".\..\..\CHANGELOG.md" Pack="true" PackagePath="\"/>
<None Include=".\..\..\assets\logo.jpeg" Pack="true" PackagePath="\"/>
<InternalsVisibleTo Include="PrivatePdfConverter.Tests"/>
</ItemGroup>

</Project>
10 changes: 7 additions & 3 deletions src/PrivatePdfConverter/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
using Cocona;
using System.Reflection;
using Cocona;
using PrivatePdfConverter;
using PrivatePdfConverter.Commands;

var versionString = Assembly.GetEntryAssembly()?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "0.0.0";

Logger.Initialize();
Logger.LogStart(versionString);

var app = CoconaLiteApp.Create();

app.AddCommand("dir", DirToPdf.ConvertDirectoryToOnePdf).WithDescription("Convert all images inside directory to single pdf file.");
Expand All @@ -11,6 +17,4 @@
app.AddCommand("encrypt", EncryptPdf.EncryptPdfWithPassword).WithDescription("Encrypt pdf file with a password.");
app.AddCommand("logo", AddLogoToPdf.Run).WithDescription("Add an image/logo/watermark to a every page of pdf file.");

Logger.Initialize();

await app.RunAsync();

0 comments on commit d70a14d

Please sign in to comment.