Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/2.0 #40

Merged
merged 7 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/dotnet-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Restore
env:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/dotnet-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Restore
env:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Atlassian Downloader - Changelog

## 2.x

* `2.0.0.0` - migrated to `dotnet8` and updated libs. code optimized by [@kasthack](https://github.com/kasthack). reworked build scripts via `cli` and `vs`. added translations to `ru` and `en`. added new dists - `osx-arm64`, `linux-bionic-x64`.

## 1.x
* `1.1.0.0` - added automatic compare of local and remote file sizes. If they differ - the file will be re-downloaded.
* `1.0.1.1` - minor update: added `UserAgent` to HTTP headers and added mirrors of json files.
* `1.0.1.0` - added support of `Atlassian Bitbucket (Mesh)` product, updated deps, fixed `Chocolatey` support and start logic.
* `1.0.0.9` - updated deps.
Expand Down
58 changes: 38 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,44 @@

# Atlassian Downloader

Console app written with `c#` and `dotnet6` for downloading all avalible products from `Atlassian`. Why not?
Console app written with `c#` and `dotnet8` for downloading all avalible products from `Atlassian`. Why not?

![Atlassian Downloader](https://rawcdn.githack.com/EpicMorg/atlassian-downloader/87f1d7fd4e3f22b29b4be87d02d80dd0b3e0280e/.github/media/screenshot-01.png)
![Atlassian Downloader](https://rawcdn.githack.com/EpicMorg/atlassian-downloader/87f1d7fd4e3f22b29b4be87d02d80dd0b3e0280e/.github/media/screenshot-03.png)

## Requirements
1. Preinstalled`*` `dotnet6`. Download [here](https://dotnet.microsoft.com/download/dotnet/6.0).
2. Supported OS: `win32/win64`, `linux`, `macosx`, `arm/arm64`
# Supported OS:
`win-x86`, `win-x64`, `win-arm64`, `linux-x86`, `linux-x64`, `linux-musl-x64`, `linux-arm`, `linux-arm64`, `linux-bionic-x64`, `osx-x64`, `osx-arm64`

`*` since version `1.0.0.4` application build asstandalone package and do not requre preinstalled `dotnet6`.
-------------------

# How to...
## ..bootstrap from scratch

## ..develop
1. preinstall `dotnet8`. Download [here](https://dotnet.microsoft.com/download/dotnet/8.0).
2. preinstall `VS2022`. Download [here](https://visualstudio.microsoft.com/vs/).
3. `git clone` this repo.
4. `cd` to `<repo>/src`.
5. open `*.sln` file
6. ...
7. profit!

## ..build from scratch
1. `git clone` this repo.
2. `cd` to `<repo>/src`.
3.1 execute `dotnet run` in `src` folder.
or
3.2 execute `build.bat(sh)` in `src` folder.
4. by default all data will be downloaded to `src/atlassian` folder and subfolders.
3. execute `build.bat(sh)` in `src` folder.
4. by default all data will be downloaded to `src/Atlassian` folder and subfolders.

## ..install
1. download latest [![Downloads](https://img.shields.io/github/downloads/EpicMorg/atlassian-downloader/total.svg?style=flat-square)](https://github.com/EpicMorg/atlassian-downloader/releases) [![Release](https://img.shields.io/github/v/release/EpicMorg/atlassian-downloader?style=flat-square)](https://github.com/EpicMorg/atlassian-downloader/releases)
## ..use binary versions
1. just download latest [![Downloads](https://img.shields.io/github/downloads/EpicMorg/atlassian-downloader/total.svg?style=flat-square)](https://github.com/EpicMorg/atlassian-downloader/releases) [![Release](https://img.shields.io/github/v/release/EpicMorg/atlassian-downloader?style=flat-square)](https://github.com/EpicMorg/atlassian-downloader/releases)
2. ...
3. profit!

# Intall via Chocolatey
## ..intall via Chocolatey
| CLI | Version | Downloads
| ------ | ------ | ------
| :computer: `choco install atlassian-downloader` | [![Version](https://img.shields.io/chocolatey/v/atlassian-downloader?label=version&style=for-the-badge)](https://chocolatey.org/packages/atlassian-downloader/) | [![Version](https://img.shields.io/chocolatey/dt/atlassian-downloader?style=for-the-badge)](https://chocolatey.org/packages/atlassian-downloader/)

-------------------

# Usage and settings
## CLI args
Expand All @@ -46,12 +54,20 @@ Usage:
atlassian-downloader [options]

Options:
--output-dir <output-dir> Override output directory to download [default: atlassian]
--custom-feed <custom-feed> Override URIs to import [default: ]
--action <Download|ListURLs|ListVersions|ShowRawJson> Action to perform [default: Download]
--version Show credits banner [default: False]
--product-version <product-version> Override target version to download some product. Advice: Use it with "customFeed". [default: ]
-?, -h, --help Show help and usage information
--output-dir <output-dir> Override output directory to download
--custom-feed <custom-feed> Override URIs to import []
--action <Download|ListURLs|ListVersions|ShowRawJson> Action to perform [default: Download]
--about Show credits banner [default: False]
--product-version <product-version> Override target version to download some product. Advice: Use
it with "customFeed". []
--skip-file-check Skip compare of file sizes if a local file already exists.
Existing file will be skipped to check and redownload.
[default: False]
--user-agent <user-agent> Set custom user agent via this feature flag. [default:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:101.0)
Gecko/20100101 Firefox/101.0]
--version Show version information
-?, -h, --help Show help and usage information
```

## Example of usage:
Expand Down Expand Up @@ -106,6 +122,8 @@ The following built-in themes are available, provided by `Serilog.Sinks.Console`
* `AnsiConsoleTheme.Grayscale` - an ANSI 256-color version of the "grayscale" theme
* `AnsiConsoleTheme.Code` - an ANSI 256-color Visual Studio Code-inspired theme

-------------------

# Supported products:

| Product | Current | Archive | EAP |
Expand All @@ -125,7 +143,7 @@ The following built-in themes are available, provided by `Serilog.Sinks.Console`

* Archive of `Atlassian` jsons available [here](https://github.com/EpicMorg/atlassian-json).

------
-------------------

## Authors
* [@kasthack](https://github.com/kasthack) - code
Expand Down
116 changes: 116 additions & 0 deletions src/Core/BellsAndWhistles.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
namespace EpicMorg.Atlassian.Downloader.Models;

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using Microsoft.Extensions.Logging;

internal class BellsAndWhistles
{
private static readonly string assemblyEnvironment = string.Format("[{1}, {0}]", RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(), RuntimeInformation.FrameworkDescription);

private static readonly Assembly entryAssembly = Assembly.GetEntryAssembly();

private static readonly string assemblyVersion = entryAssembly.GetName().Version.ToString();

private static readonly string fileVersion = entryAssembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;

private static readonly string assemblyName = entryAssembly.GetCustomAttribute<AssemblyProductAttribute>().Product;
const string assemblyBuildType =
#if DEBUG
"[Debug]"
#else

"[Release]"
#endif
;

private const ConsoleColor DEFAULT = ConsoleColor.Blue;

public static void ShowVersionInfo(ILogger logger)
{
logger.LogInformation($"{assemblyName} {assemblyVersion} {assemblyEnvironment} {assemblyBuildType}");
Console.BackgroundColor = ConsoleColor.Black;
WriteColorLine("%╔═╦═══════════════════════════════════════════════════════════════════════════════════════╦═╗");
WriteColorLine("%╠═╝ .''. %╚═%╣");
WriteColorLine("%║ .:cc;. %║");
WriteColorLine("%║ .;cccc;. %║");
WriteColorLine("%║ .;cccccc;. !╔══════════════════════════════════════════════╗ %║");
WriteColorLine($"%║ .:ccccccc;. !║ {assemblyName} !║ %║");
WriteColorLine("%║ 'ccccccccc;. !╠══════════════════════════════════════════════╣ %║");
WriteColorLine("%║ ,cccccccccc;. !║ &Code: @kasthack !║ %║");
WriteColorLine("%║ ,ccccccccccc;. !║ &GFX: @stam !║ %║");
WriteColorLine("%║ .... .:ccccccccccc;. !╠══════════════════════════════════════════════╣ %║");
WriteColorLine($"%║ .',,'..;cccccccccccc;. !║ &Version: {fileVersion} !║ %║");
WriteColorLine("%║ .,,,,,'.';cccccccccccc;. !║ &GitHub: $EpicMorg/atlassian-downloader !║ %║");
WriteColorLine("%║ .,;;;;;,'.':cccccccccccc;. !╚══════════════════════════════════════════════╝ %║");
WriteColorLine("%║ .;:;;;;;;,...:cccccccccccc;. %║");
WriteColorLine("%║ .;:::::;;;;'. .;:ccccccccccc;. %║");
WriteColorLine("%║ .:cc::::::::,. ..:ccccccccccc;. %║");
WriteColorLine("%║ .:cccccc:::::' .:ccccccccccc;. %║");
WriteColorLine("%║ .;:::::::::::,. .;:::::::::::,. %║");
WriteColorLine("%╠═╗ ............ ............ %╔═╣");
WriteColorLine("%╚═╩═══════════════════════════════════════════════════════════════════════════════════════╩═╝");
Console.ResetColor();
}
public static void SetConsoleTitle() => Console.Title = $@"{assemblyName} {assemblyVersion} {assemblyEnvironment} - {assemblyBuildType}";

private static void WriteColorLine(string text, params object[] args)
{
Dictionary<char, ConsoleColor> colors = new()
{
{ '!', ConsoleColor.Red },
{ '@', ConsoleColor.Green },
{ '#', ConsoleColor.Blue },
{ '$', ConsoleColor.Magenta },
{ '&', ConsoleColor.Yellow },
{ '%', ConsoleColor.Cyan }
};
// TODO: word wrap, backslash escapes
text = string.Format(text, args);
var chunk = "";
var paren = false;
for (var i = 0; i < text.Length; i++)
{
var c = text[i];
if (colors.ContainsKey(c) && StringNext(text, i) != ' ')
{
Console.Write(chunk);
chunk = "";
if (StringNext(text, i) == '(')
{
i++; // skip past the paren
paren = true;
}

Console.ForegroundColor = colors[c];
}
else if (paren && c == ')')
{
paren = false;
Console.ForegroundColor = DEFAULT;
}
else if (Console.ForegroundColor != DEFAULT)
{
Console.Write(c);
if (c == ' ' && !paren)
{
Console.ForegroundColor = DEFAULT;
}
}
else
{
chunk += c;
}
}

Console.WriteLine(chunk);
Console.ForegroundColor = DEFAULT;
}

private static char StringNext(string text, int index) => index < text.Length ? text[index + 1] : '\0';

}

Loading
Loading