@ahqstore/cli 0.5.2 → 0.6.0
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 +3 -3
- package/README.md +14 -0
- package/build.rs +8 -8
- package/index.js +182 -182
- package/latest.md +1 -1
- package/package.json +10 -10
- package/src/app/build/config.rs +54 -54
- package/src/app/build/icon.rs +47 -47
- package/src/app/build/macros.rs +2 -1
- package/src/app/build/mod.rs +219 -233
- package/src/app/build/release.rs +50 -50
- package/src/app/create/inquire.rs +114 -142
- package/src/app/create/mod.rs +73 -79
- package/src/app/create/readme.md +13 -80
- package/src/app/help.rs +77 -77
- package/src/app/mod.rs +39 -39
- package/src/app/shared/file_sorter.rs +42 -42
- package/src/app/shared/mod.rs +66 -66
- package/src/app/shared/platforms.rs +44 -44
- package/src/lib.rs +12 -12
- package/src/main.rs +10 -10
- package/src/app/create/readme.es.md +0 -80
- package/src/app/create/readme.hi.md +0 -80
package/Cargo.toml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
edition = "2021"
|
|
3
3
|
name = "ahqstore_cli_rs"
|
|
4
|
-
version = "0.
|
|
4
|
+
version = "0.6.0"
|
|
5
5
|
description = "AHQ Store CLI"
|
|
6
6
|
repository = "https://github.com/ahqstore/cli"
|
|
7
7
|
homepage = "https://github.com/ahqstore/cli"
|
|
@@ -32,7 +32,7 @@ chalk_rs = "1"
|
|
|
32
32
|
lazy_static = "1"
|
|
33
33
|
serde = { version = "1", features = ["derive"] }
|
|
34
34
|
serde_json = "1"
|
|
35
|
-
ahqstore-types = "3
|
|
35
|
+
ahqstore-types = { version = "3", features = ["apps_repo"] }
|
|
36
36
|
reqwest = { version = "0.12", features = ["json", "blocking"] }
|
|
37
37
|
sha2 = "0.10"
|
|
38
38
|
image = { version = "0.25", default-features = false, features = [
|
|
@@ -42,7 +42,7 @@ image = { version = "0.25", default-features = false, features = [
|
|
|
42
42
|
rand = "0.8"
|
|
43
43
|
|
|
44
44
|
[target.'cfg(unix)'.dependencies]
|
|
45
|
-
openssl-sys = { version = "0.9
|
|
45
|
+
openssl-sys = { version = "0.9", features = ["vendored"] }
|
|
46
46
|
|
|
47
47
|
[build-dependencies]
|
|
48
48
|
napi-build = { version = "2", optional = true }
|
package/README.md
CHANGED
|
@@ -4,6 +4,20 @@ Read more about it [here](https://ahqstore.github.io)
|
|
|
4
4
|
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
+
## 0.6.0 **(m)** 05-Sep-2024 10:37PM IST
|
|
8
|
+
|
|
9
|
+
- Introduced ahqstore-types apps validation
|
|
10
|
+
- Now you can view schemas in [docs.rs](https://docs.rs/ahqstore_cli_rs)
|
|
11
|
+
- Update Dependencies
|
|
12
|
+
|
|
13
|
+
## 0.5.5 03-Sep-2024 10:20PM IST
|
|
14
|
+
|
|
15
|
+
- update ahqstore-types
|
|
16
|
+
|
|
17
|
+
## 0.5.4 01-Sep-2024 10:07PM IST
|
|
18
|
+
|
|
19
|
+
- **[CRITICAL]** Fixes invalid config files being generated
|
|
20
|
+
|
|
7
21
|
## 0.5.1 23-Aug-2024 10:09PM IST
|
|
8
22
|
|
|
9
23
|
- Fix NPM Publish error
|
package/build.rs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#[cfg(feature = "node")]
|
|
2
|
-
extern crate napi_build;
|
|
3
|
-
|
|
4
|
-
fn main() {
|
|
5
|
-
// Ensures that users can download it too
|
|
6
|
-
#[cfg(feature = "node")]
|
|
7
|
-
napi_build::setup();
|
|
8
|
-
}
|
|
1
|
+
#[cfg(feature = "node")]
|
|
2
|
+
extern crate napi_build;
|
|
3
|
+
|
|
4
|
+
fn main() {
|
|
5
|
+
// Ensures that users can download it too
|
|
6
|
+
#[cfg(feature = "node")]
|
|
7
|
+
napi_build::setup();
|
|
8
|
+
}
|
package/index.js
CHANGED
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/* tslint:disable */
|
|
4
|
-
/* eslint-disable */
|
|
5
|
-
/* prettier-ignore */
|
|
6
|
-
|
|
7
|
-
/* auto-generated by NAPI-RS */
|
|
8
|
-
/* and modified by @ahqsoftwares */
|
|
9
|
-
|
|
10
|
-
const { existsSync, readFileSync } = require('fs')
|
|
11
|
-
const { join } = require("path");
|
|
12
|
-
|
|
13
|
-
const { platform, arch } = process;
|
|
14
|
-
|
|
15
|
-
let nativeBinding = null;
|
|
16
|
-
let localFileExisted = false;
|
|
17
|
-
let loadError = null;
|
|
18
|
-
|
|
19
|
-
function isMusl() {
|
|
20
|
-
// For Node 10
|
|
21
|
-
if (!process.report || typeof process.report.getReport !== "function") {
|
|
22
|
-
try {
|
|
23
|
-
const lddPath = require("child_process")
|
|
24
|
-
.execSync("which ldd")
|
|
25
|
-
.toString()
|
|
26
|
-
.trim();
|
|
27
|
-
return readFileSync(lddPath, "utf8").includes("musl");
|
|
28
|
-
} catch (e) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
const { glibcVersionRuntime } = process.report.getReport().header;
|
|
33
|
-
return !glibcVersionRuntime;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
switch (platform) {
|
|
38
|
-
case "win32":
|
|
39
|
-
switch (arch) {
|
|
40
|
-
case "x64":
|
|
41
|
-
localFileExisted = existsSync(
|
|
42
|
-
join(__dirname, "cli.win32-x64-msvc.node")
|
|
43
|
-
);
|
|
44
|
-
try {
|
|
45
|
-
if (localFileExisted) {
|
|
46
|
-
nativeBinding = require("./cli.win32-x64-msvc.node");
|
|
47
|
-
} else {
|
|
48
|
-
nativeBinding = require("@ahqstore/cli-win32-x64-msvc");
|
|
49
|
-
}
|
|
50
|
-
} catch (e) {
|
|
51
|
-
loadError = e;
|
|
52
|
-
}
|
|
53
|
-
break;
|
|
54
|
-
case "ia32":
|
|
55
|
-
localFileExisted = existsSync(
|
|
56
|
-
join(__dirname, "cli.win32-ia32-msvc.node")
|
|
57
|
-
);
|
|
58
|
-
try {
|
|
59
|
-
if (localFileExisted) {
|
|
60
|
-
nativeBinding = require("./cli.win32-ia32-msvc.node");
|
|
61
|
-
} else {
|
|
62
|
-
nativeBinding = require("@ahqstore/cli-win32-ia32-msvc");
|
|
63
|
-
}
|
|
64
|
-
} catch (e) {
|
|
65
|
-
loadError = e;
|
|
66
|
-
}
|
|
67
|
-
break;
|
|
68
|
-
case "arm64":
|
|
69
|
-
localFileExisted = existsSync(
|
|
70
|
-
join(__dirname, "cli.win32-arm64-msvc.node")
|
|
71
|
-
);
|
|
72
|
-
try {
|
|
73
|
-
if (localFileExisted) {
|
|
74
|
-
nativeBinding = require("./cli.win32-arm64-msvc.node");
|
|
75
|
-
} else {
|
|
76
|
-
nativeBinding = require("@ahqstore/cli-win32-arm64-msvc");
|
|
77
|
-
}
|
|
78
|
-
} catch (e) {
|
|
79
|
-
loadError = e;
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
throw new Error(`Unsupported architecture on Windows: ${arch}`);
|
|
84
|
-
}
|
|
85
|
-
break;
|
|
86
|
-
case "darwin":
|
|
87
|
-
localFileExisted = existsSync(join(__dirname, "cli.darwin-universal.node"));
|
|
88
|
-
try {
|
|
89
|
-
if (localFileExisted) {
|
|
90
|
-
nativeBinding = require("./cli.darwin-universal.node");
|
|
91
|
-
} else {
|
|
92
|
-
nativeBinding = require("@ahqstore/cli-darwin-universal");
|
|
93
|
-
}
|
|
94
|
-
break;
|
|
95
|
-
} catch {}
|
|
96
|
-
switch (arch) {
|
|
97
|
-
case "x64":
|
|
98
|
-
localFileExisted = existsSync(join(__dirname, "cli.darwin-x64.node"));
|
|
99
|
-
try {
|
|
100
|
-
if (localFileExisted) {
|
|
101
|
-
nativeBinding = require("./cli.darwin-x64.node");
|
|
102
|
-
} else {
|
|
103
|
-
nativeBinding = require("@ahqstore/cli-darwin-x64");
|
|
104
|
-
}
|
|
105
|
-
} catch (e) {
|
|
106
|
-
loadError = e;
|
|
107
|
-
}
|
|
108
|
-
break;
|
|
109
|
-
case "arm64":
|
|
110
|
-
localFileExisted = existsSync(join(__dirname, "cli.darwin-arm64.node"));
|
|
111
|
-
try {
|
|
112
|
-
if (localFileExisted) {
|
|
113
|
-
nativeBinding = require("./cli.darwin-arm64.node");
|
|
114
|
-
} else {
|
|
115
|
-
nativeBinding = require("@ahqstore/cli-darwin-arm64");
|
|
116
|
-
}
|
|
117
|
-
} catch (e) {
|
|
118
|
-
loadError = e;
|
|
119
|
-
}
|
|
120
|
-
break;
|
|
121
|
-
default:
|
|
122
|
-
throw new Error(`Unsupported architecture on macOS: ${arch}`);
|
|
123
|
-
}
|
|
124
|
-
break;
|
|
125
|
-
case "linux":
|
|
126
|
-
switch (arch) {
|
|
127
|
-
case "x64":
|
|
128
|
-
if (isMusl()) {
|
|
129
|
-
throw new Error("MUSL Bindings are not supported!");
|
|
130
|
-
} else {
|
|
131
|
-
localFileExisted = existsSync(
|
|
132
|
-
join(__dirname, "cli.linux-x64-gnu.node")
|
|
133
|
-
);
|
|
134
|
-
try {
|
|
135
|
-
if (localFileExisted) {
|
|
136
|
-
nativeBinding = require("./cli.linux-x64-gnu.node");
|
|
137
|
-
} else {
|
|
138
|
-
nativeBinding = require("@ahqstore/cli-linux-x64-gnu");
|
|
139
|
-
}
|
|
140
|
-
} catch (e) {
|
|
141
|
-
loadError = e;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
break;
|
|
145
|
-
case "arm64":
|
|
146
|
-
if (isMusl()) {
|
|
147
|
-
throw new Error("MUSL Bindings are not supported!");
|
|
148
|
-
} else {
|
|
149
|
-
localFileExisted = existsSync(
|
|
150
|
-
join(__dirname, "cli.linux-arm64-gnu.node")
|
|
151
|
-
);
|
|
152
|
-
try {
|
|
153
|
-
if (localFileExisted) {
|
|
154
|
-
nativeBinding = require("./cli.linux-arm64-gnu.node");
|
|
155
|
-
} else {
|
|
156
|
-
nativeBinding = require("@ahqstore/cli-linux-arm64-gnu");
|
|
157
|
-
}
|
|
158
|
-
} catch (e) {
|
|
159
|
-
loadError = e;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
|
-
default:
|
|
164
|
-
throw new Error(`Unsupported architecture on Linux: ${arch}`);
|
|
165
|
-
}
|
|
166
|
-
break;
|
|
167
|
-
default:
|
|
168
|
-
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (!nativeBinding) {
|
|
172
|
-
if (loadError) {
|
|
173
|
-
throw loadError;
|
|
174
|
-
}
|
|
175
|
-
throw new Error(`Failed to load native binding`);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const { nodeEntrypoint } = nativeBinding;
|
|
179
|
-
|
|
180
|
-
const args = process.argv.slice(2) || [];
|
|
181
|
-
|
|
182
|
-
nodeEntrypoint(args, process.env["GH_ACTION"] != null);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
/* prettier-ignore */
|
|
6
|
+
|
|
7
|
+
/* auto-generated by NAPI-RS */
|
|
8
|
+
/* and modified by @ahqsoftwares */
|
|
9
|
+
|
|
10
|
+
const { existsSync, readFileSync } = require('fs')
|
|
11
|
+
const { join } = require("path");
|
|
12
|
+
|
|
13
|
+
const { platform, arch } = process;
|
|
14
|
+
|
|
15
|
+
let nativeBinding = null;
|
|
16
|
+
let localFileExisted = false;
|
|
17
|
+
let loadError = null;
|
|
18
|
+
|
|
19
|
+
function isMusl() {
|
|
20
|
+
// For Node 10
|
|
21
|
+
if (!process.report || typeof process.report.getReport !== "function") {
|
|
22
|
+
try {
|
|
23
|
+
const lddPath = require("child_process")
|
|
24
|
+
.execSync("which ldd")
|
|
25
|
+
.toString()
|
|
26
|
+
.trim();
|
|
27
|
+
return readFileSync(lddPath, "utf8").includes("musl");
|
|
28
|
+
} catch (e) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
const { glibcVersionRuntime } = process.report.getReport().header;
|
|
33
|
+
return !glibcVersionRuntime;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
switch (platform) {
|
|
38
|
+
case "win32":
|
|
39
|
+
switch (arch) {
|
|
40
|
+
case "x64":
|
|
41
|
+
localFileExisted = existsSync(
|
|
42
|
+
join(__dirname, "cli.win32-x64-msvc.node")
|
|
43
|
+
);
|
|
44
|
+
try {
|
|
45
|
+
if (localFileExisted) {
|
|
46
|
+
nativeBinding = require("./cli.win32-x64-msvc.node");
|
|
47
|
+
} else {
|
|
48
|
+
nativeBinding = require("@ahqstore/cli-win32-x64-msvc");
|
|
49
|
+
}
|
|
50
|
+
} catch (e) {
|
|
51
|
+
loadError = e;
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
case "ia32":
|
|
55
|
+
localFileExisted = existsSync(
|
|
56
|
+
join(__dirname, "cli.win32-ia32-msvc.node")
|
|
57
|
+
);
|
|
58
|
+
try {
|
|
59
|
+
if (localFileExisted) {
|
|
60
|
+
nativeBinding = require("./cli.win32-ia32-msvc.node");
|
|
61
|
+
} else {
|
|
62
|
+
nativeBinding = require("@ahqstore/cli-win32-ia32-msvc");
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
loadError = e;
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case "arm64":
|
|
69
|
+
localFileExisted = existsSync(
|
|
70
|
+
join(__dirname, "cli.win32-arm64-msvc.node")
|
|
71
|
+
);
|
|
72
|
+
try {
|
|
73
|
+
if (localFileExisted) {
|
|
74
|
+
nativeBinding = require("./cli.win32-arm64-msvc.node");
|
|
75
|
+
} else {
|
|
76
|
+
nativeBinding = require("@ahqstore/cli-win32-arm64-msvc");
|
|
77
|
+
}
|
|
78
|
+
} catch (e) {
|
|
79
|
+
loadError = e;
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`);
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case "darwin":
|
|
87
|
+
localFileExisted = existsSync(join(__dirname, "cli.darwin-universal.node"));
|
|
88
|
+
try {
|
|
89
|
+
if (localFileExisted) {
|
|
90
|
+
nativeBinding = require("./cli.darwin-universal.node");
|
|
91
|
+
} else {
|
|
92
|
+
nativeBinding = require("@ahqstore/cli-darwin-universal");
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
} catch {}
|
|
96
|
+
switch (arch) {
|
|
97
|
+
case "x64":
|
|
98
|
+
localFileExisted = existsSync(join(__dirname, "cli.darwin-x64.node"));
|
|
99
|
+
try {
|
|
100
|
+
if (localFileExisted) {
|
|
101
|
+
nativeBinding = require("./cli.darwin-x64.node");
|
|
102
|
+
} else {
|
|
103
|
+
nativeBinding = require("@ahqstore/cli-darwin-x64");
|
|
104
|
+
}
|
|
105
|
+
} catch (e) {
|
|
106
|
+
loadError = e;
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
case "arm64":
|
|
110
|
+
localFileExisted = existsSync(join(__dirname, "cli.darwin-arm64.node"));
|
|
111
|
+
try {
|
|
112
|
+
if (localFileExisted) {
|
|
113
|
+
nativeBinding = require("./cli.darwin-arm64.node");
|
|
114
|
+
} else {
|
|
115
|
+
nativeBinding = require("@ahqstore/cli-darwin-arm64");
|
|
116
|
+
}
|
|
117
|
+
} catch (e) {
|
|
118
|
+
loadError = e;
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
default:
|
|
122
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`);
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
case "linux":
|
|
126
|
+
switch (arch) {
|
|
127
|
+
case "x64":
|
|
128
|
+
if (isMusl()) {
|
|
129
|
+
throw new Error("MUSL Bindings are not supported!");
|
|
130
|
+
} else {
|
|
131
|
+
localFileExisted = existsSync(
|
|
132
|
+
join(__dirname, "cli.linux-x64-gnu.node")
|
|
133
|
+
);
|
|
134
|
+
try {
|
|
135
|
+
if (localFileExisted) {
|
|
136
|
+
nativeBinding = require("./cli.linux-x64-gnu.node");
|
|
137
|
+
} else {
|
|
138
|
+
nativeBinding = require("@ahqstore/cli-linux-x64-gnu");
|
|
139
|
+
}
|
|
140
|
+
} catch (e) {
|
|
141
|
+
loadError = e;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
case "arm64":
|
|
146
|
+
if (isMusl()) {
|
|
147
|
+
throw new Error("MUSL Bindings are not supported!");
|
|
148
|
+
} else {
|
|
149
|
+
localFileExisted = existsSync(
|
|
150
|
+
join(__dirname, "cli.linux-arm64-gnu.node")
|
|
151
|
+
);
|
|
152
|
+
try {
|
|
153
|
+
if (localFileExisted) {
|
|
154
|
+
nativeBinding = require("./cli.linux-arm64-gnu.node");
|
|
155
|
+
} else {
|
|
156
|
+
nativeBinding = require("@ahqstore/cli-linux-arm64-gnu");
|
|
157
|
+
}
|
|
158
|
+
} catch (e) {
|
|
159
|
+
loadError = e;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
default:
|
|
164
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`);
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
default:
|
|
168
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!nativeBinding) {
|
|
172
|
+
if (loadError) {
|
|
173
|
+
throw loadError;
|
|
174
|
+
}
|
|
175
|
+
throw new Error(`Failed to load native binding`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const { nodeEntrypoint } = nativeBinding;
|
|
179
|
+
|
|
180
|
+
const args = process.argv.slice(2) || [];
|
|
181
|
+
|
|
182
|
+
nodeEntrypoint(args, process.env["GH_ACTION"] != null);
|
package/latest.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Binaries for the release
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahqstore/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"readme": "./README.md",
|
|
5
5
|
"napi": {
|
|
6
6
|
"name": "cli",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"version": "napi version"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
-
"@ahqstore/cli-win32-x64-msvc": "0.
|
|
44
|
-
"@ahqstore/cli-darwin-x64": "0.
|
|
45
|
-
"@ahqstore/cli-linux-x64-gnu": "0.
|
|
46
|
-
"@ahqstore/cli-darwin-arm64": "0.
|
|
47
|
-
"@ahqstore/cli-linux-arm64-gnu": "0.
|
|
48
|
-
"@ahqstore/cli-win32-arm64-msvc": "0.
|
|
49
|
-
"@ahqstore/cli-win32-ia32-msvc": "0.
|
|
50
|
-
"@ahqstore/cli-darwin-universal": "0.
|
|
51
|
-
"@ahqstore/cli-linux-riscv64-gnu": "0.
|
|
43
|
+
"@ahqstore/cli-win32-x64-msvc": "0.6.0",
|
|
44
|
+
"@ahqstore/cli-darwin-x64": "0.6.0",
|
|
45
|
+
"@ahqstore/cli-linux-x64-gnu": "0.6.0",
|
|
46
|
+
"@ahqstore/cli-darwin-arm64": "0.6.0",
|
|
47
|
+
"@ahqstore/cli-linux-arm64-gnu": "0.6.0",
|
|
48
|
+
"@ahqstore/cli-win32-arm64-msvc": "0.6.0",
|
|
49
|
+
"@ahqstore/cli-win32-ia32-msvc": "0.6.0",
|
|
50
|
+
"@ahqstore/cli-darwin-universal": "0.6.0",
|
|
51
|
+
"@ahqstore/cli-linux-riscv64-gnu": "0.6.0"
|
|
52
52
|
}
|
|
53
53
|
}
|
package/src/app/build/config.rs
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
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
|
+
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
|
+
}
|
package/src/app/build/icon.rs
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
use crate::app::ERR;
|
|
2
|
-
use image::{load_from_memory_with_format as load_img, ImageFormat};
|
|
3
|
-
use std::fs;
|
|
4
|
-
use std::process;
|
|
5
|
-
|
|
6
|
-
pub fn get_icon(uid: &str) -> Vec<u8> {
|
|
7
|
-
let base_img = format!("./.ahqstore/images/{uid}/icon.png");
|
|
8
|
-
|
|
9
|
-
let Ok(icon) = fs::read(&base_img) else {
|
|
10
|
-
ERR.println(&"Unable to read icon file!");
|
|
11
|
-
process::exit(1);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
validate_png(&icon);
|
|
15
|
-
|
|
16
|
-
icon
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
pub fn get_images(uid: &str) -> Vec<Vec<u8>> {
|
|
20
|
-
let base_img = format!("./.ahqstore/images/{uid}");
|
|
21
|
-
|
|
22
|
-
let Ok(image_dir) = fs::read_dir(&base_img) else {
|
|
23
|
-
ERR.println(&"Unable to read image dir!");
|
|
24
|
-
process::exit(1);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
let mut entries = image_dir
|
|
28
|
-
.map(|res| res.expect("Unable to unwrap dir entry").path())
|
|
29
|
-
.filter(|f| !f.ends_with("icon.png"))
|
|
30
|
-
.map(|res| fs::read(res).expect("Unable to read bytes"))
|
|
31
|
-
.map(|img| {
|
|
32
|
-
validate_png(&img);
|
|
33
|
-
return img;
|
|
34
|
-
})
|
|
35
|
-
.collect::<Vec<_>>();
|
|
36
|
-
|
|
37
|
-
entries.truncate(10);
|
|
38
|
-
|
|
39
|
-
entries
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
pub fn validate_png(data: &Vec<u8>) {
|
|
43
|
-
let Ok(_) = load_img(&data, ImageFormat::Png) else {
|
|
44
|
-
ERR.println(&"Invalid PNG");
|
|
45
|
-
process::exit(1);
|
|
46
|
-
};
|
|
47
|
-
}
|
|
1
|
+
use crate::app::ERR;
|
|
2
|
+
use image::{load_from_memory_with_format as load_img, ImageFormat};
|
|
3
|
+
use std::fs;
|
|
4
|
+
use std::process;
|
|
5
|
+
|
|
6
|
+
pub fn get_icon(uid: &str) -> Vec<u8> {
|
|
7
|
+
let base_img = format!("./.ahqstore/images/{uid}/icon.png");
|
|
8
|
+
|
|
9
|
+
let Ok(icon) = fs::read(&base_img) else {
|
|
10
|
+
ERR.println(&"Unable to read icon file!");
|
|
11
|
+
process::exit(1);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
validate_png(&icon);
|
|
15
|
+
|
|
16
|
+
icon
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
pub fn get_images(uid: &str) -> Vec<Vec<u8>> {
|
|
20
|
+
let base_img = format!("./.ahqstore/images/{uid}");
|
|
21
|
+
|
|
22
|
+
let Ok(image_dir) = fs::read_dir(&base_img) else {
|
|
23
|
+
ERR.println(&"Unable to read image dir!");
|
|
24
|
+
process::exit(1);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let mut entries = image_dir
|
|
28
|
+
.map(|res| res.expect("Unable to unwrap dir entry").path())
|
|
29
|
+
.filter(|f| !f.ends_with("icon.png"))
|
|
30
|
+
.map(|res| fs::read(res).expect("Unable to read bytes"))
|
|
31
|
+
.map(|img| {
|
|
32
|
+
validate_png(&img);
|
|
33
|
+
return img;
|
|
34
|
+
})
|
|
35
|
+
.collect::<Vec<_>>();
|
|
36
|
+
|
|
37
|
+
entries.truncate(10);
|
|
38
|
+
|
|
39
|
+
entries
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
pub fn validate_png(data: &Vec<u8>) {
|
|
43
|
+
let Ok(_) = load_img(&data, ImageFormat::Png) else {
|
|
44
|
+
ERR.println(&"Invalid PNG");
|
|
45
|
+
process::exit(1);
|
|
46
|
+
};
|
|
47
|
+
}
|