@ahqstore/cli 0.3.4 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +24 -16
- package/bundle +4 -0
- package/bundle.ps1 +4 -0
- package/index.js +82 -159
- package/latest.md +3 -0
- package/package.json +11 -13
- package/src/app/build/macros.rs +95 -0
- package/src/app/build/mod.rs +64 -60
- package/src/app/create/inquire.rs +30 -77
- package/src/app/create/mod.rs +7 -1
- package/src/app/create/readme.es.md +80 -0
- package/src/app/create/readme.hi.md +80 -0
- package/src/app/create/readme.md +30 -21
- package/src/app/shared/file_sorter.rs +14 -6
- package/src/app/shared/mod.rs +5 -1
- package/src/app/shared/platforms.rs +26 -50
- package/cli-rs/Cargo.toml +0 -45
- package/cli-rs/README.md +0 -41
- package/cli-rs/build.rs +0 -4
- package/cli-rs/finalize.js +0 -25
- package/cli-rs/rust-toolchain.toml +0 -2
- package/cli-rs/src/app/build/config.rs +0 -54
- package/cli-rs/src/app/build/icon.rs +0 -48
- package/cli-rs/src/app/build/mod.rs +0 -217
- package/cli-rs/src/app/build/release.rs +0 -50
- package/cli-rs/src/app/create/icon.png +0 -0
- package/cli-rs/src/app/create/inquire.rs +0 -189
- package/cli-rs/src/app/create/mod.rs +0 -74
- package/cli-rs/src/app/create/readme.md +0 -71
- package/cli-rs/src/app/help.rs +0 -77
- package/cli-rs/src/app/mod.rs +0 -39
- package/cli-rs/src/app/shared/file_sorter.rs +0 -34
- package/cli-rs/src/app/shared/mod.rs +0 -62
- package/cli-rs/src/app/shared/platforms.rs +0 -69
- package/cli-rs/src/lib.rs +0 -13
- package/cli-rs/src/main.rs +0 -10
- package/cli-rs/tslink.toml +0 -2
|
@@ -1,69 +1,45 @@
|
|
|
1
|
-
use ahqstore_types::
|
|
1
|
+
use ahqstore_types::InstallerFormat;
|
|
2
2
|
use serde::{Deserialize, Serialize};
|
|
3
3
|
|
|
4
4
|
#[derive(Debug, Serialize, Deserialize)]
|
|
5
5
|
#[allow(non_snake_case)]
|
|
6
6
|
pub struct IPlatform<'a> {
|
|
7
|
-
pub
|
|
8
|
-
pub
|
|
9
|
-
pub
|
|
7
|
+
pub winAmd64Platform: Option<InstallerFormat>,
|
|
8
|
+
pub winArm64Platform: Option<InstallerFormat>,
|
|
9
|
+
pub linuxAmd64Platform: Option<InstallerFormat>,
|
|
10
|
+
pub linuxArm64Platform: Option<InstallerFormat>,
|
|
11
|
+
pub linuxArm32Platform: Option<InstallerFormat>,
|
|
12
|
+
pub androidUniversal: Option<InstallerFormat>,
|
|
10
13
|
#[serde(borrow)]
|
|
11
|
-
pub
|
|
12
|
-
|
|
14
|
+
pub winAmd64Options: Option<IOWin<'a>>,
|
|
15
|
+
#[serde(borrow)]
|
|
16
|
+
pub winArm64Options: Option<IOWin<'a>>,
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
#[derive(Debug, Serialize, Deserialize)]
|
|
16
|
-
pub struct
|
|
17
|
-
pub deps: Vec<Win32Deps>,
|
|
19
|
+
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
20
|
+
pub struct IOWin<'a> {
|
|
18
21
|
#[serde(borrow)]
|
|
19
22
|
pub zip_file_exec: Option<&'a str>,
|
|
20
23
|
#[serde(borrow)]
|
|
21
24
|
pub exe_installer_args: Option<Vec<&'a str>>,
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
#[derive(Debug, Serialize, Deserialize)]
|
|
25
|
-
pub struct IOLinux {
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
27
|
impl<'a> IPlatform<'a> {
|
|
30
|
-
pub fn new(
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
let linux = own(
|
|
38
|
-
platforms
|
|
39
|
-
.iter()
|
|
40
|
-
.find(|p| matches!(&p, &&&InstallerFormat::LinuxAppImage)),
|
|
41
|
-
);
|
|
28
|
+
pub fn new() -> Self {
|
|
29
|
+
let io_win = IOWin {
|
|
30
|
+
exe_installer_args: Some(vec![]),
|
|
31
|
+
zip_file_exec: None,
|
|
32
|
+
};
|
|
42
33
|
|
|
43
34
|
Self {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
linuxOptions: Some(IOLinux { }),
|
|
35
|
+
winAmd64Platform: None,
|
|
36
|
+
winArm64Platform: None,
|
|
37
|
+
linuxAmd64Platform: None,
|
|
38
|
+
linuxArm32Platform: None,
|
|
39
|
+
linuxArm64Platform: None,
|
|
40
|
+
androidUniversal: None,
|
|
41
|
+
winAmd64Options: Some(io_win.clone()),
|
|
42
|
+
winArm64Options: Some(io_win)
|
|
53
43
|
}
|
|
54
44
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
fn own(val: Option<&InstallerFormat>) -> Option<InstallerFormat> {
|
|
58
|
-
if let Some(v) = val {
|
|
59
|
-
Some(match &v {
|
|
60
|
-
&&InstallerFormat::LinuxAppImage => InstallerFormat::LinuxAppImage,
|
|
61
|
-
&&InstallerFormat::WindowsInstallerExe => InstallerFormat::WindowsInstallerExe,
|
|
62
|
-
&&InstallerFormat::WindowsZip => InstallerFormat::WindowsZip,
|
|
63
|
-
&&InstallerFormat::WindowsInstallerMsi => InstallerFormat::WindowsInstallerMsi,
|
|
64
|
-
&&InstallerFormat::WindowsUWPMsix => InstallerFormat::WindowsUWPMsix,
|
|
65
|
-
})
|
|
66
|
-
} else {
|
|
67
|
-
None
|
|
68
|
-
}
|
|
69
|
-
}
|
|
45
|
+
}
|
package/cli-rs/Cargo.toml
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
name = "ahqstore_cli_rs"
|
|
3
|
-
version = "0.2.8"
|
|
4
|
-
edition = "2021"
|
|
5
|
-
description = "AHQ Store CLI"
|
|
6
|
-
repository = "https://github.com/ahqstore/cli"
|
|
7
|
-
homepage = "https://github.com/ahqstore/cli"
|
|
8
|
-
license = "MIT"
|
|
9
|
-
exclude = ["dist/**", ".ahqstore/**", "finalize.js", "tslink.toml"]
|
|
10
|
-
readme = "README.md"
|
|
11
|
-
|
|
12
|
-
[lib]
|
|
13
|
-
name = "ahqstore_cli_rs"
|
|
14
|
-
crate-type = ["cdylib"]
|
|
15
|
-
path = "src/lib.rs"
|
|
16
|
-
|
|
17
|
-
[[bin]]
|
|
18
|
-
name = "ahqstore"
|
|
19
|
-
path = "src/main.rs"
|
|
20
|
-
|
|
21
|
-
[dependencies]
|
|
22
|
-
node-bindgen = { version = "6.0.1", optional = true }
|
|
23
|
-
tslink = { version = "0.1.3", optional = true }
|
|
24
|
-
inquire = { version = "0.7.5", features = ["editor"] }
|
|
25
|
-
chalk_rs = "1.0.1"
|
|
26
|
-
lazy_static = "1.4.0"
|
|
27
|
-
serde = { version = "1.0.203", features = ["derive"] }
|
|
28
|
-
serde_json = "1.0.117"
|
|
29
|
-
ahqstore-types = "2.0.0"
|
|
30
|
-
reqwest = { version = "0.12", features = ["json", "blocking"] }
|
|
31
|
-
sha2 = "0.10.8"
|
|
32
|
-
base64 = "0.22.1"
|
|
33
|
-
image = "0.25"
|
|
34
|
-
rand = "0.8.5"
|
|
35
|
-
|
|
36
|
-
[target.aarch64-unknown-linux-gnu.dependencies]
|
|
37
|
-
openssl = { version = "0.10.64", features = ["vendored"] }
|
|
38
|
-
|
|
39
|
-
[build-dependencies]
|
|
40
|
-
node-bindgen = { version = "6.0.1", default-features = false, features = [
|
|
41
|
-
"build",
|
|
42
|
-
], optional = true }
|
|
43
|
-
|
|
44
|
-
[features]
|
|
45
|
-
node = ["dep:node-bindgen", "dep:tslink"]
|
package/cli-rs/README.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# AHQ Store CLI
|
|
2
|
-
|
|
3
|
-
The CLI for devs making AHQ Store Apps
|
|
4
|
-
|
|
5
|
-
This version: CARGO
|
|
6
|
-
|
|
7
|
-
Install
|
|
8
|
-
|
|
9
|
-
```sh
|
|
10
|
-
$ cargo install ahqstore_cli_rs
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Help Command
|
|
14
|
-
|
|
15
|
-
The help command shows all available commands
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
$ ahqstore --help
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Create .ahqstore config
|
|
22
|
-
|
|
23
|
-
Creates the .ahqstore/\* config files to make your app ready to be built
|
|
24
|
-
|
|
25
|
-
```sh
|
|
26
|
-
$ ahqstore --create {--force}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Build a project
|
|
30
|
-
|
|
31
|
-
Builds your app based on the config files and environment variables
|
|
32
|
-
ENV:
|
|
33
|
-
|
|
34
|
-
> `APP_ID` (Optional) Application Id (only required if your config has more than 1 appIds)
|
|
35
|
-
> `RELEASE_ID` GitHub Release Id
|
|
36
|
-
> `GH_TOKEN` GitHub Personal Access Token / GitHub Actions Token
|
|
37
|
-
> `GITHUB_REPOSITORY` GitHub owner & repo name, eg ahqstore/app
|
|
38
|
-
|
|
39
|
-
```sh
|
|
40
|
-
$ ahqstore build
|
|
41
|
-
```
|
package/cli-rs/build.rs
DELETED
package/cli-rs/finalize.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const { writeFileSync, readFileSync } = require("fs");
|
|
2
|
-
const { join } = require("path");
|
|
3
|
-
let arch = process.env.arch || require("process").arch;
|
|
4
|
-
|
|
5
|
-
if (arch == "arm64" && process.platform == "win32") {
|
|
6
|
-
arch = "ia32";
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const packageJson = join(__dirname, "dist", "package.json");
|
|
10
|
-
|
|
11
|
-
let json = JSON.parse(readFileSync(packageJson));
|
|
12
|
-
|
|
13
|
-
json.name = `@ahqstore/cli-rs-${process.platform}-${arch}`;
|
|
14
|
-
|
|
15
|
-
json.description = `AHQ Store CLI Binaries for ${process.platform}-${arch}`;
|
|
16
|
-
json.repository = {
|
|
17
|
-
type: "git",
|
|
18
|
-
url: "git+https://github.com/ahqstore/cli.git",
|
|
19
|
-
};
|
|
20
|
-
json.bugs = {
|
|
21
|
-
url: "https://github.com/ahqstore/cli/issues",
|
|
22
|
-
};
|
|
23
|
-
json.homepage = "https://github.com/ahqstore/cli#readme";
|
|
24
|
-
|
|
25
|
-
writeFileSync(packageJson, JSON.stringify(json, null, 2));
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
use std::{env, fs, process};
|
|
2
|
-
|
|
3
|
-
use serde_json::from_str;
|
|
4
|
-
|
|
5
|
-
use crate::app::{
|
|
6
|
-
shared::{Config, Finder, IMetadata},
|
|
7
|
-
ERR,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
use super::{GHAsset, GHRelease};
|
|
11
|
-
|
|
12
|
-
pub fn get_config<'a>() -> IMetadata<'a> {
|
|
13
|
-
let Ok(config) = fs::read_to_string("./.ahqstore/config.json") else {
|
|
14
|
-
ERR.println(&"Unable to read config file!");
|
|
15
|
-
process::exit(1);
|
|
16
|
-
};
|
|
17
|
-
let config = config.leak();
|
|
18
|
-
let Ok(mut config) = from_str::<'a, Config>(config) else {
|
|
19
|
-
ERR.println(&"Unable to read config file!");
|
|
20
|
-
process::exit(1);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
if let Ok(app_id) = env::var("APP_ID") {
|
|
24
|
-
config.remove(&app_id).expect("Key not present in JSON")
|
|
25
|
-
} else {
|
|
26
|
-
config.into_values().nth(0).expect("No Key present in JSON")
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
pub fn find_assets<'a>(gh_r: &'a GHRelease, finder: &'a Finder) -> Vec<&'a GHAsset> {
|
|
31
|
-
gh_r
|
|
32
|
-
.assets
|
|
33
|
-
.iter()
|
|
34
|
-
.filter(|a| {
|
|
35
|
-
if let Some(x) = finder.startsWith {
|
|
36
|
-
if !a.name.starts_with(&x) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if let Some(x) = finder.contains {
|
|
41
|
-
if !a.name.contains(&x) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if let Some(x) = finder.endsWith {
|
|
46
|
-
if !a.name.ends_with(&x) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
true
|
|
52
|
-
})
|
|
53
|
-
.collect::<Vec<_>>()
|
|
54
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
use crate::app::ERR;
|
|
2
|
-
use base64::engine::{general_purpose::STANDARD, Engine};
|
|
3
|
-
use image::{load_from_memory_with_format as load_img, ImageFormat};
|
|
4
|
-
use std::fs;
|
|
5
|
-
use std::process;
|
|
6
|
-
|
|
7
|
-
pub fn get_icon(uid: &str) -> String {
|
|
8
|
-
let base_img = format!("./.ahqstore/images/{uid}/icon.png");
|
|
9
|
-
|
|
10
|
-
let Ok(icon) = fs::read(&base_img) else {
|
|
11
|
-
ERR.println(&"Unable to read icon file!");
|
|
12
|
-
process::exit(1);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
validate_png(&icon);
|
|
16
|
-
|
|
17
|
-
STANDARD.encode(&icon)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
pub fn get_images(uid: &str) -> Vec<String> {
|
|
21
|
-
let base_img = format!("./.ahqstore/images/{uid}");
|
|
22
|
-
|
|
23
|
-
let Ok(image_dir) = fs::read_dir(&base_img) else {
|
|
24
|
-
ERR.println(&"Unable to read image dir!");
|
|
25
|
-
process::exit(1);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
let mut entries = image_dir
|
|
29
|
-
.map(|res| res.expect("Unable to unwrap dir entry").path())
|
|
30
|
-
.filter(|f| !f.ends_with("icon.png"))
|
|
31
|
-
.map(|res| fs::read(res).expect("Unable to read bytes"))
|
|
32
|
-
.map(|img| {
|
|
33
|
-
validate_png(&img);
|
|
34
|
-
return STANDARD.encode(&img);
|
|
35
|
-
})
|
|
36
|
-
.collect::<Vec<_>>();
|
|
37
|
-
|
|
38
|
-
entries.truncate(10);
|
|
39
|
-
|
|
40
|
-
entries
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
pub fn validate_png(data: &Vec<u8>) {
|
|
44
|
-
let Ok(_) = load_img(&data, ImageFormat::Png) else {
|
|
45
|
-
ERR.println(&"Invalid PNG");
|
|
46
|
-
process::exit(1);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
use ahqstore_types::{
|
|
2
|
-
AHQStoreApplication, DownloadUrl, InstallType, InstallerFormat, InstallerOptions,
|
|
3
|
-
InstallerOptionsLinux, InstallerOptionsWin32, Str,
|
|
4
|
-
};
|
|
5
|
-
use lazy_static::lazy_static;
|
|
6
|
-
use reqwest::blocking::{Client, ClientBuilder};
|
|
7
|
-
use serde::{Deserialize, Serialize};
|
|
8
|
-
use serde_json::{from_str, to_string, to_string_pretty};
|
|
9
|
-
use std::{collections::HashMap, env, fs, process};
|
|
10
|
-
|
|
11
|
-
use crate::app::{ERR, WARN};
|
|
12
|
-
|
|
13
|
-
use super::INFO;
|
|
14
|
-
|
|
15
|
-
mod config;
|
|
16
|
-
mod icon;
|
|
17
|
-
mod release;
|
|
18
|
-
use config::*;
|
|
19
|
-
use icon::*;
|
|
20
|
-
use release::*;
|
|
21
|
-
|
|
22
|
-
lazy_static! {
|
|
23
|
-
pub static ref CLIENT: Client = ClientBuilder::new()
|
|
24
|
-
.user_agent("AHQ Store / App Builder")
|
|
25
|
-
.build()
|
|
26
|
-
.unwrap();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
#[derive(Debug, Deserialize, Serialize)]
|
|
30
|
-
struct GHRelease {
|
|
31
|
-
pub upload_url: String,
|
|
32
|
-
pub assets: Vec<GHAsset>,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
#[derive(Debug, Deserialize, Serialize)]
|
|
36
|
-
struct GHAsset {
|
|
37
|
-
pub name: String,
|
|
38
|
-
pub browser_download_url: String,
|
|
39
|
-
}
|
|
40
|
-
pub fn build_config(upload: bool, gh_action: bool) {
|
|
41
|
-
let Some(_) = fs::read_dir("./.ahqstore").ok() else {
|
|
42
|
-
ERR.println(&".ahqstore dir couldn't be accessed!");
|
|
43
|
-
process::exit(1);
|
|
44
|
-
};
|
|
45
|
-
if !gh_action {
|
|
46
|
-
INFO.print(&"INFO ");
|
|
47
|
-
println!("Checking .ahqstore");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let config = get_config();
|
|
51
|
-
|
|
52
|
-
let repo = env::var("GITHUB_REPOSITORY").unwrap_or("%NUL".into());
|
|
53
|
-
|
|
54
|
-
if &repo == "%NUL" {
|
|
55
|
-
ERR.println(&"GITHUB_REPOSITORY not set");
|
|
56
|
-
process::exit(1);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let r_id = env::var("RELEASE_ID").unwrap_or("latest".into());
|
|
60
|
-
|
|
61
|
-
if &r_id == "latest" && upload {
|
|
62
|
-
ERR.println(&"RELEASE_ID variable not present");
|
|
63
|
-
process::exit(1);
|
|
64
|
-
};
|
|
65
|
-
if &r_id == "latest" {
|
|
66
|
-
INFO.print(&"INFO ");
|
|
67
|
-
println!("Getting latest release");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
let gh_token = env::var("GH_TOKEN").unwrap_or("".into());
|
|
71
|
-
|
|
72
|
-
if &gh_token == "" && upload {
|
|
73
|
-
ERR.println(&"GH_TOKEN variable not present");
|
|
74
|
-
process::exit(1);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
let (version, gh_r) = fetch_release(&repo, &r_id, &gh_token);
|
|
78
|
-
|
|
79
|
-
let icon = get_icon(&config.appId);
|
|
80
|
-
#[allow(non_snake_case)]
|
|
81
|
-
let displayImages = get_images(&config.appId);
|
|
82
|
-
|
|
83
|
-
let app_id = config.appId.clone();
|
|
84
|
-
|
|
85
|
-
let mut final_config: AHQStoreApplication = AHQStoreApplication {
|
|
86
|
-
appDisplayName: config.appDisplayName,
|
|
87
|
-
appId: config.appId,
|
|
88
|
-
appShortcutName: config.appShortcutName,
|
|
89
|
-
authorId: config.authorId,
|
|
90
|
-
description: config.description,
|
|
91
|
-
downloadUrls: HashMap::default(),
|
|
92
|
-
icon,
|
|
93
|
-
displayImages,
|
|
94
|
-
install: InstallerOptions {
|
|
95
|
-
installType: config.platform.installType,
|
|
96
|
-
linux: None,
|
|
97
|
-
win32: None,
|
|
98
|
-
},
|
|
99
|
-
repo: config.repo,
|
|
100
|
-
version,
|
|
101
|
-
site: None,
|
|
102
|
-
source: None
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
if let Some(platform) = config.platform.win32Platform {
|
|
106
|
-
match (&platform, &final_config.install.installType) {
|
|
107
|
-
(&InstallerFormat::WindowsZip, _) => {}
|
|
108
|
-
(_, &InstallType::PerUser | &InstallType::Computer) => {
|
|
109
|
-
WARN.println(
|
|
110
|
-
&"Setting PerUser or Computer in a non WindowsZip install type does not have any effect",
|
|
111
|
-
);
|
|
112
|
-
process::exit(1);
|
|
113
|
-
}
|
|
114
|
-
_ => {}
|
|
115
|
-
};
|
|
116
|
-
let Some(options) = config.platform.win32Options else {
|
|
117
|
-
ERR.println(&"Win32 Options not found!");
|
|
118
|
-
process::exit(1);
|
|
119
|
-
};
|
|
120
|
-
let Some(finder) = config.finder.windowsFinder else {
|
|
121
|
-
ERR.println(&"Win32 Finder Config not found!");
|
|
122
|
-
process::exit(1);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
let assets = find_assets(&gh_r, &finder);
|
|
126
|
-
|
|
127
|
-
if assets.len() > 1 {
|
|
128
|
-
ERR.println(&"Multiple assets found");
|
|
129
|
-
process::exit(1);
|
|
130
|
-
}
|
|
131
|
-
if assets.len() == 0 {
|
|
132
|
-
ERR.println(&"No assets found");
|
|
133
|
-
process::exit(1);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
final_config.downloadUrls.insert(
|
|
137
|
-
1,
|
|
138
|
-
DownloadUrl {
|
|
139
|
-
installerType: platform,
|
|
140
|
-
url: assets[0].browser_download_url.clone(),
|
|
141
|
-
},
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
final_config.install.win32 = Some(InstallerOptionsWin32 {
|
|
145
|
-
assetId: 1,
|
|
146
|
-
deps: Some(options.deps),
|
|
147
|
-
exec: options.zip_file_exec.map_or(None, |a| Some(a.to_string())),
|
|
148
|
-
installerArgs: options
|
|
149
|
-
.exe_installer_args
|
|
150
|
-
.map_or(None, |a| Some(a.iter().map(|x| x.to_string()).collect())),
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if let Some(platform) = config.platform.linuxPlatform {
|
|
155
|
-
let Some(finder) = config.finder.linuxFinder else {
|
|
156
|
-
ERR.println(&"Linux Finder Config not found!");
|
|
157
|
-
process::exit(1);
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
let assets = find_assets(&gh_r, &finder);
|
|
161
|
-
|
|
162
|
-
if assets.len() > 1 {
|
|
163
|
-
ERR.println(&"Multiple assets found");
|
|
164
|
-
process::exit(1);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
final_config.downloadUrls.insert(
|
|
168
|
-
2,
|
|
169
|
-
DownloadUrl {
|
|
170
|
-
installerType: platform,
|
|
171
|
-
url: assets[0].browser_download_url.clone(),
|
|
172
|
-
},
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
final_config.install.linux = Some(InstallerOptionsLinux {
|
|
176
|
-
assetId: 2
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
final_config.site = config.site;
|
|
181
|
-
final_config.source = config.redistributed;
|
|
182
|
-
|
|
183
|
-
let config_file = to_string_pretty(&final_config).unwrap();
|
|
184
|
-
let config_file = to_string(config_file.as_bytes()).unwrap();
|
|
185
|
-
|
|
186
|
-
if !gh_action {
|
|
187
|
-
println!("Bytes: ahqstore.json");
|
|
188
|
-
println!("{}", &config_file);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if upload {
|
|
192
|
-
let uup = gh_r
|
|
193
|
-
.upload_url
|
|
194
|
-
.replace("{?name,label}", &format!("?name={app_id}.txt"));
|
|
195
|
-
|
|
196
|
-
let resp = CLIENT
|
|
197
|
-
.post(uup)
|
|
198
|
-
.header("Content-Length", config_file.len())
|
|
199
|
-
.header("Content-Type", "text/plain")
|
|
200
|
-
.header("Accept", "application/json")
|
|
201
|
-
.body(config_file)
|
|
202
|
-
.bearer_auth(&gh_token)
|
|
203
|
-
.send()
|
|
204
|
-
.unwrap()
|
|
205
|
-
.text()
|
|
206
|
-
.unwrap();
|
|
207
|
-
|
|
208
|
-
if gh_action {
|
|
209
|
-
let val: GHAsset = from_str(&resp).unwrap();
|
|
210
|
-
|
|
211
|
-
println!("AHQ_STORE_FILE_URL={}", &val.browser_download_url);
|
|
212
|
-
} else {
|
|
213
|
-
INFO.println(&"GitHub Response");
|
|
214
|
-
println!("{resp}");
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
use std::process;
|
|
2
|
-
|
|
3
|
-
use serde_json::{from_str, to_string};
|
|
4
|
-
use sha2::{Digest, Sha256};
|
|
5
|
-
|
|
6
|
-
use crate::app::{
|
|
7
|
-
build::{GHRelease, Str},
|
|
8
|
-
ERR, WARN,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
use super::CLIENT;
|
|
12
|
-
|
|
13
|
-
pub fn fetch_release(repo: &str, r_id: &str, gh_token: &str) -> (Str, GHRelease) {
|
|
14
|
-
let Ok(resp) = ({
|
|
15
|
-
let mut resp = CLIENT.get(format!(
|
|
16
|
-
"https://api.github.com/repos/{repo}/releases/{r_id}"
|
|
17
|
-
));
|
|
18
|
-
|
|
19
|
-
if gh_token != "" {
|
|
20
|
-
resp = resp.bearer_auth(gh_token);
|
|
21
|
-
} else {
|
|
22
|
-
WARN.println(&"You may set GH_TOKEN environment variable to load private repos");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
resp.send()
|
|
26
|
-
}) else {
|
|
27
|
-
ERR.println(&"Unable to fetch release");
|
|
28
|
-
process::exit(1)
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
let Ok(release) = resp.text() else {
|
|
32
|
-
ERR.println(&"Unable to read release");
|
|
33
|
-
process::exit(1);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
let Ok(resp) = from_str::<GHRelease>(&release) else {
|
|
37
|
-
ERR.println(&"Unable to parse release");
|
|
38
|
-
process::exit(1);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
let mut hasher = Sha256::new();
|
|
42
|
-
|
|
43
|
-
hasher.update(release.as_bytes());
|
|
44
|
-
|
|
45
|
-
let hashed = hasher.finalize();
|
|
46
|
-
let hashed = hashed.to_vec();
|
|
47
|
-
let version = to_string(&hashed).unwrap_or("**UNKNOWN**".to_string());
|
|
48
|
-
|
|
49
|
-
(version, resp)
|
|
50
|
-
}
|
|
Binary file
|