@sevenvip666/rop 0.0.2 → 0.0.3
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/dist/398.index.js +450 -0
- package/dist/api-types/src/index.d.ts +201 -0
- package/dist/api-types/src/index.d.ts.map +1 -0
- package/dist/index.js +34739 -0
- package/dist/package.json +3 -0
- package/dist/upload/lib/init.d.ts +6 -0
- package/dist/upload/lib/init.d.ts.map +1 -0
- package/dist/upload/lib/rop.d.ts +2 -0
- package/dist/upload/lib/rop.d.ts.map +1 -0
- package/dist/upload/lib/tauri/artifacts.d.ts +3 -0
- package/dist/upload/lib/tauri/artifacts.d.ts.map +1 -0
- package/dist/upload/lib/tauri/config.d.ts +22 -0
- package/dist/upload/lib/tauri/config.d.ts.map +1 -0
- package/dist/upload/lib/tauri/index.d.ts +20 -0
- package/dist/upload/lib/tauri/index.d.ts.map +1 -0
- package/dist/upload/lib/tauri/utils.d.ts +9 -0
- package/dist/upload/lib/tauri/utils.d.ts.map +1 -0
- package/dist/upload/lib/tauri.d.ts +11 -0
- package/dist/upload/lib/tauri.d.ts.map +1 -0
- package/dist/upload/lib/types.d.ts +18 -0
- package/dist/upload/lib/types.d.ts.map +1 -0
- package/dist/upload/lib/upload.d.ts +14 -0
- package/dist/upload/lib/upload.d.ts.map +1 -0
- package/dist/upload/lib/utils.d.ts +151 -0
- package/dist/upload/lib/utils.d.ts.map +1 -0
- package/dist/upload/src/main.d.ts +2 -0
- package/dist/upload/src/main.d.ts.map +1 -0
- package/dist/upload/test/upload.spec.d.ts +2 -0
- package/dist/upload/test/upload.spec.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/index.d.ts +0 -57
- package/dist/rop.js +0 -605
package/dist/rop.js
DELETED
|
@@ -1,605 +0,0 @@
|
|
|
1
|
-
import { Command as I } from "commander";
|
|
2
|
-
import * as b from "node:fs";
|
|
3
|
-
import p, { existsSync as y, readFileSync as w, writeFileSync as j } from "node:fs";
|
|
4
|
-
import K from "node-fetch";
|
|
5
|
-
import U from "form-data";
|
|
6
|
-
import { exec as M } from "child_process";
|
|
7
|
-
import g, { join as l, resolve as B, sep as R, normalize as S } from "node:path";
|
|
8
|
-
import * as E from "js-yaml";
|
|
9
|
-
import * as T from "node:os";
|
|
10
|
-
import $ from "vite-plugin-node-polyfills/shims/process";
|
|
11
|
-
import { parse as C } from "@iarna/toml";
|
|
12
|
-
import { globbySync as F } from "globby";
|
|
13
|
-
import z from "json5";
|
|
14
|
-
import G from "cli-progress";
|
|
15
|
-
import N from "ansi-colors";
|
|
16
|
-
import { confirm as W, input as Y } from "@inquirer/prompts";
|
|
17
|
-
var L = /* @__PURE__ */ ((r) => (r.TAURI = "TAURI", r.IONIC = "IONIC", r.FLUTTER = "FLUTTER", r))(L || {});
|
|
18
|
-
function x(r) {
|
|
19
|
-
try {
|
|
20
|
-
return JSON.parse(r);
|
|
21
|
-
} catch (t) {
|
|
22
|
-
const e = t.message;
|
|
23
|
-
return console.error(
|
|
24
|
-
`Couldn't parse --config flag as inline JSON. This is not an error if it's a file path. Source: "${e}"`
|
|
25
|
-
), null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function _(r) {
|
|
29
|
-
try {
|
|
30
|
-
return z.parse(r);
|
|
31
|
-
} catch (t) {
|
|
32
|
-
const e = t.message;
|
|
33
|
-
return console.error(
|
|
34
|
-
`Couldn't parse --config flag as inline JSON. This is not an error if it's a file path. Source: "${e}"`
|
|
35
|
-
), null;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function D(r) {
|
|
39
|
-
try {
|
|
40
|
-
return C(r);
|
|
41
|
-
} catch (t) {
|
|
42
|
-
const e = t.message;
|
|
43
|
-
return console.error(
|
|
44
|
-
`Couldn't parse --config flag as inline JSON. This is not an error if it's a file path. Source: "${e}"`
|
|
45
|
-
), null;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function H(r, t) {
|
|
49
|
-
let e = l(r, `tauri.${t}.conf.json`);
|
|
50
|
-
if (y(e)) {
|
|
51
|
-
const n = w(e).toString(), i = x(n);
|
|
52
|
-
if (i) return i;
|
|
53
|
-
}
|
|
54
|
-
if (e = l(r, `tauri.${t}.conf.json5`), y(e)) {
|
|
55
|
-
const n = w(e).toString(), i = _(n);
|
|
56
|
-
if (i) return i;
|
|
57
|
-
}
|
|
58
|
-
if (e = l(r, `Tauri.${t}.toml`), y(e)) {
|
|
59
|
-
const n = w(e).toString(), i = D(n);
|
|
60
|
-
if (i) return i;
|
|
61
|
-
}
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
function q(r) {
|
|
65
|
-
if (!y(r))
|
|
66
|
-
throw new Error(`Provided config path \`${r}\` does not exist.`);
|
|
67
|
-
const t = w(r).toString(), e = g.extname(r);
|
|
68
|
-
if (e === ".json") {
|
|
69
|
-
const n = x(t);
|
|
70
|
-
if (n) return n;
|
|
71
|
-
}
|
|
72
|
-
if (e === ".json5") {
|
|
73
|
-
const n = _(t);
|
|
74
|
-
if (n) return n;
|
|
75
|
-
}
|
|
76
|
-
if (e === ".toml") {
|
|
77
|
-
const n = D(t);
|
|
78
|
-
if (n) return n;
|
|
79
|
-
}
|
|
80
|
-
throw new Error(`Couldn't parse \`${r}\` as ${e.substring(1)}.`);
|
|
81
|
-
}
|
|
82
|
-
class P {
|
|
83
|
-
// Non tauri config properties
|
|
84
|
-
_isV2;
|
|
85
|
-
// Required values
|
|
86
|
-
identifier;
|
|
87
|
-
// Optional values
|
|
88
|
-
productName;
|
|
89
|
-
version;
|
|
90
|
-
frontendDist;
|
|
91
|
-
beforeBuildCommand;
|
|
92
|
-
rpmRelease;
|
|
93
|
-
wixLanguage;
|
|
94
|
-
constructor(t, e = !1) {
|
|
95
|
-
this.identifier = t, this._isV2 = e;
|
|
96
|
-
}
|
|
97
|
-
static fromBaseConfig(t) {
|
|
98
|
-
if (console.log(t), y(l(t, "tauri.conf.json"))) {
|
|
99
|
-
const e = w(l(t, "tauri.conf.json")).toString(), n = x(e);
|
|
100
|
-
if (n)
|
|
101
|
-
return "identifier" in n ? this.fromV2Base(n) : this.fromV1Base(n);
|
|
102
|
-
console.error("Found tauri.conf.json file but couldn't parse it as JSON.");
|
|
103
|
-
}
|
|
104
|
-
if (y(l(t, "tauri.conf.json5"))) {
|
|
105
|
-
const e = w(l(t, "tauri.conf.json5")).toString(), n = _(e);
|
|
106
|
-
if (n)
|
|
107
|
-
return "identifier" in n ? this.fromV2Base(n) : this.fromV1Base(n);
|
|
108
|
-
console.error("Found tauri.conf.json5 file but couldn't parse it as JSON5.");
|
|
109
|
-
}
|
|
110
|
-
if (y(l(t, "Tauri.toml"))) {
|
|
111
|
-
const e = w(l(t, "Tauri.toml")).toString(), n = D(e);
|
|
112
|
-
if (n)
|
|
113
|
-
return "identifier" in n ? this.fromV2Base(n) : this.fromV1Base(n);
|
|
114
|
-
console.error("Found Tauri.toml file but couldn't parse it as TOML.");
|
|
115
|
-
}
|
|
116
|
-
throw new Error("Couldn't locate or parse tauri config.");
|
|
117
|
-
}
|
|
118
|
-
static fromV1Base(t) {
|
|
119
|
-
if (!t.tauri?.bundle?.identifier)
|
|
120
|
-
throw Error("base config has no bundle identifier.");
|
|
121
|
-
const e = new P(t.tauri?.bundle?.identifier, !1);
|
|
122
|
-
return e.productName = t.package?.productName, e.version = t.package?.version, e.frontendDist = t.build?.distDir, e.beforeBuildCommand = t.build?.beforeBuildCommand, e.rpmRelease = t.tauri.bundle.rpm?.release, e.wixLanguage = t.tauri.bundle.windows?.wix?.language, e;
|
|
123
|
-
}
|
|
124
|
-
static fromV2Base(t) {
|
|
125
|
-
if (!t.identifier)
|
|
126
|
-
throw Error("base config has no bundle identifier.");
|
|
127
|
-
const e = new P(t.identifier, !0);
|
|
128
|
-
return e.productName = t.productName, e.version = t.version, e.frontendDist = t.build?.frontendDist, e.beforeBuildCommand = t.build?.beforeBuildCommand, e.rpmRelease = t.bundle?.linux?.rpm?.release, e.wixLanguage = t.bundle?.windows?.wix?.language, e;
|
|
129
|
-
}
|
|
130
|
-
mergeConfig(t) {
|
|
131
|
-
if (this._isV2) {
|
|
132
|
-
const e = t;
|
|
133
|
-
this.identifier = e.identifier ?? this.identifier, this.productName = e.productName ?? this.productName, this.version = e.version ?? this.version, this.frontendDist = e.build?.frontendDist ?? this.frontendDist, this.beforeBuildCommand = e.build?.beforeBuildCommand ?? this.beforeBuildCommand, this.rpmRelease = e.bundle?.linux?.rpm?.release ?? this.rpmRelease, this.wixLanguage = e.bundle?.windows?.wix?.language ?? this.wixLanguage;
|
|
134
|
-
} else {
|
|
135
|
-
const e = t;
|
|
136
|
-
this.identifier = e.tauri?.bundle?.identifier ?? this.identifier, this.productName = e.package?.productName ?? this.productName, this.version = e.package?.version ?? this.version, this.frontendDist = e.build?.distDir ?? this.frontendDist, this.beforeBuildCommand = e.build?.beforeBuildCommand ?? this.beforeBuildCommand, this.rpmRelease = e.tauri?.bundle?.rpm?.release ?? this.rpmRelease, this.wixLanguage = e.tauri?.bundle?.windows?.wix?.language ?? this.wixLanguage;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
mergePlatformConfig(t, e) {
|
|
140
|
-
const n = H(t, e);
|
|
141
|
-
n && this.mergeConfig(n);
|
|
142
|
-
}
|
|
143
|
-
mergeUserConfig(t, e) {
|
|
144
|
-
let n = x(e);
|
|
145
|
-
if (!n) {
|
|
146
|
-
const i = g.isAbsolute(e) ? e : g.join(t, e);
|
|
147
|
-
n = q(i);
|
|
148
|
-
}
|
|
149
|
-
n ? this.mergeConfig(n) : console.error(`Couldn't read --config: ${e}`);
|
|
150
|
-
}
|
|
151
|
-
/// Update tauri.conf.json file on disk with current values. Used solely in `initProject()`
|
|
152
|
-
/// and therefore only handles plain JSON while assuming it's a valid file straight from `tauri init`.
|
|
153
|
-
updateConfigFile(t) {
|
|
154
|
-
const e = l(t, "tauri.conf.json"), n = w(e).toString(), i = x(n);
|
|
155
|
-
if (!i)
|
|
156
|
-
throw new Error("Couldn't parse tauri.conf.json");
|
|
157
|
-
if (this._isV2) {
|
|
158
|
-
const a = i;
|
|
159
|
-
a.identifier = this.identifier, a.productName = this.productName, a.version = this.version, a.build.beforeBuildCommand = this.beforeBuildCommand, a.build.frontendDist = this.frontendDist, j(e, JSON.stringify(a, null, 2));
|
|
160
|
-
} else {
|
|
161
|
-
const a = i;
|
|
162
|
-
a.build.beforeBuildCommand = this.beforeBuildCommand, a.build.distDir = this.frontendDist, a.package.productName = this.productName, a.package.version = this.version, a.tauri.bundle.identifier = this.identifier, j(e, JSON.stringify(a, null, 2));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
function A(r) {
|
|
167
|
-
const t = r;
|
|
168
|
-
for (; r.length && r[r.length - 1] !== R; ) {
|
|
169
|
-
const e = l(r, "Cargo.toml");
|
|
170
|
-
if (y(e)) {
|
|
171
|
-
const n = C(w(e).toString());
|
|
172
|
-
if (n.workspace?.members) {
|
|
173
|
-
const i = ["**/target", "**/node_modules"];
|
|
174
|
-
if (n.workspace.exclude && i.push(...n.workspace.exclude), F(n.workspace.members, {
|
|
175
|
-
cwd: r,
|
|
176
|
-
ignore: i,
|
|
177
|
-
expandDirectories: !1,
|
|
178
|
-
onlyFiles: !1
|
|
179
|
-
}).some((o) => B(r, o) === t))
|
|
180
|
-
return r;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
r = S(l(r, ".."));
|
|
184
|
-
}
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
function Q(r) {
|
|
188
|
-
const { arch: t, platform: e } = r;
|
|
189
|
-
return e == "macos" ? `${t}-apple-darwin` : e == "windows" && (t == "aarch64" || t == "i686") ? `${t}-pc-windows-msvc` : "";
|
|
190
|
-
}
|
|
191
|
-
function X(r, t, e) {
|
|
192
|
-
const n = l(r, "target");
|
|
193
|
-
let i = t, a, o;
|
|
194
|
-
for ($.env.CARGO_TARGET_DIR && (a = $.env.CARGO_TARGET_DIR ?? n); i.length && i[i.length - 1] !== R; ) {
|
|
195
|
-
let s = l(i, ".cargo/config");
|
|
196
|
-
if (y(s) || (s = l(i, ".cargo/config.toml")), y(s)) {
|
|
197
|
-
const c = C(w(s).toString());
|
|
198
|
-
if (!a && c.build?.["target-dir"]) {
|
|
199
|
-
const f = c.build["target-dir"];
|
|
200
|
-
g.isAbsolute(f) ? a = f : a = S(l(i, f));
|
|
201
|
-
}
|
|
202
|
-
!e && !o && typeof c.build?.target == "string" && (o = c.build.target);
|
|
203
|
-
}
|
|
204
|
-
if (a && o) break;
|
|
205
|
-
i = S(l(i, ".."));
|
|
206
|
-
}
|
|
207
|
-
return a ? S(l(a, o ?? "")) : S(l(n, o ?? ""));
|
|
208
|
-
}
|
|
209
|
-
function O(r) {
|
|
210
|
-
const t = F(["**/tauri.conf.json", "**/tauri.conf.json5", "**/Tauri.toml"], {
|
|
211
|
-
gitignore: !0,
|
|
212
|
-
cwd: r,
|
|
213
|
-
// Forcefully ignore target and node_modules dirs
|
|
214
|
-
ignore: ["**/target", "**/node_modules"]
|
|
215
|
-
});
|
|
216
|
-
return t.length === 0 ? null : B(r, t[0], "..");
|
|
217
|
-
}
|
|
218
|
-
function Z(r, t) {
|
|
219
|
-
const e = O(r);
|
|
220
|
-
if (e !== null) {
|
|
221
|
-
let n, i, a = "en-US", o = "1";
|
|
222
|
-
const s = P.fromBaseConfig(e);
|
|
223
|
-
if (t && s.mergePlatformConfig(e, t.platform), n = s?.productName, s.version?.endsWith(".json")) {
|
|
224
|
-
const f = l(e, s?.version), u = w(f).toString();
|
|
225
|
-
i = JSON.parse(u).version;
|
|
226
|
-
} else
|
|
227
|
-
i = s?.version;
|
|
228
|
-
if (!(n && i)) {
|
|
229
|
-
const f = J(e);
|
|
230
|
-
n = n ?? f.package.name, i = i ?? f.package.version;
|
|
231
|
-
}
|
|
232
|
-
n && i || (console.error("Could not determine package name and version."), $.exit(1));
|
|
233
|
-
const c = i.replace(/[-+]/g, ".");
|
|
234
|
-
return s.wixLanguage && (a = s.wixLanguage), s.rpmRelease && (o = s.rpmRelease), {
|
|
235
|
-
tauriPath: e,
|
|
236
|
-
name: n,
|
|
237
|
-
version: i,
|
|
238
|
-
wixLanguage: a,
|
|
239
|
-
wixAppVersion: c,
|
|
240
|
-
rpmRelease: o
|
|
241
|
-
};
|
|
242
|
-
} else
|
|
243
|
-
throw Error("Couldn't detect Tauri dir");
|
|
244
|
-
}
|
|
245
|
-
function J(r) {
|
|
246
|
-
const t = l(r, "Cargo.toml"), e = C(w(t).toString());
|
|
247
|
-
let n = e.package.name, i = e.package.version;
|
|
248
|
-
if (typeof e.package.version == "object" || typeof e.package.name == "object") {
|
|
249
|
-
const a = A(r);
|
|
250
|
-
if (!a)
|
|
251
|
-
throw new Error(
|
|
252
|
-
"Could not find workspace directory, but version and/or name specifies to use workspace package"
|
|
253
|
-
);
|
|
254
|
-
const o = l(a, "Cargo.toml"), s = C(w(o).toString());
|
|
255
|
-
typeof n == "object" && s?.workspace?.package?.name !== void 0 && (n = s.workspace.package.name), typeof i == "object" && s?.workspace?.package?.version !== void 0 && (i = s.workspace.package.version);
|
|
256
|
-
}
|
|
257
|
-
return {
|
|
258
|
-
...e,
|
|
259
|
-
package: {
|
|
260
|
-
...e.package,
|
|
261
|
-
name: n,
|
|
262
|
-
version: i
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
async function ee(r, t, e, n, i) {
|
|
267
|
-
if (!r.tauriPath)
|
|
268
|
-
throw Error("Couldn't detect path of tauri app");
|
|
269
|
-
const a = i ?? "nsis", o = {
|
|
270
|
-
tauriPath: r.tauriPath,
|
|
271
|
-
name: r.name,
|
|
272
|
-
version: r.version,
|
|
273
|
-
wixLanguage: r.wixLanguage,
|
|
274
|
-
wixAppVersion: r.wixAppVersion
|
|
275
|
-
}, s = A(o.tauriPath) ?? o.tauriPath, c = l(
|
|
276
|
-
X(s, r.tauriPath, !!e),
|
|
277
|
-
e ?? "",
|
|
278
|
-
t ? "debug" : "release"
|
|
279
|
-
);
|
|
280
|
-
let f = [], u = n.arch;
|
|
281
|
-
if (n.platform === "macos")
|
|
282
|
-
u === "x86_64" ? u = "x64" : u === "arm64" && (u = "aarch64"), f = [
|
|
283
|
-
{ path: l(c, `bundle/dmg/${o.name}_${o.version}_${u}.dmg`), type: "target" },
|
|
284
|
-
{
|
|
285
|
-
path: l(c, `bundle/macos/${o.name}.app.tar.gz`),
|
|
286
|
-
type: "update"
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
path: l(c, `bundle/macos/${o.name}.app.tar.gz.sig`),
|
|
290
|
-
type: "updateSig"
|
|
291
|
-
}
|
|
292
|
-
].map((d) => ({ ...d, arch: u }));
|
|
293
|
-
else if (n.platform === "windows") {
|
|
294
|
-
u?.startsWith("i") ? u = "x86" : u === "aarch64" ? u = "arm64" : u = "x64";
|
|
295
|
-
const d = [];
|
|
296
|
-
if (a == "msi") {
|
|
297
|
-
let m;
|
|
298
|
-
typeof o.wixLanguage == "string" ? m = [o.wixLanguage] : Array.isArray(o.wixLanguage) ? m = o.wixLanguage : m = Object.keys(o.wixLanguage), m.forEach((h) => {
|
|
299
|
-
d.push(
|
|
300
|
-
{
|
|
301
|
-
path: l(c, `bundle/msi/${o.name}_${o.wixAppVersion}_${u}_${h}.msi`),
|
|
302
|
-
type: "target"
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
path: l(
|
|
306
|
-
c,
|
|
307
|
-
`bundle/msi/${o.name}_${o.wixAppVersion}_${u}_${h}.msi.zip`
|
|
308
|
-
),
|
|
309
|
-
type: "update"
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
path: l(
|
|
313
|
-
c,
|
|
314
|
-
`bundle/msi/${o.name}_${o.wixAppVersion}_${u}_${h}.msi.zip.sig`
|
|
315
|
-
),
|
|
316
|
-
type: "updateSig"
|
|
317
|
-
}
|
|
318
|
-
);
|
|
319
|
-
});
|
|
320
|
-
} else
|
|
321
|
-
d.push(
|
|
322
|
-
{
|
|
323
|
-
path: l(c, `bundle/nsis/${o.name}_${o.version}_${u}-setup.exe`),
|
|
324
|
-
type: "target"
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
path: l(c, `bundle/nsis/${o.name}_${o.version}_${u}-setup.nsis.zip`),
|
|
328
|
-
type: "update"
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
path: l(c, `bundle/nsis/${o.name}_${o.version}_${u}-setup.nsis.zip.sig`),
|
|
332
|
-
type: "updateSig"
|
|
333
|
-
}
|
|
334
|
-
);
|
|
335
|
-
f = d.map((m) => ({ ...m, arch: u }));
|
|
336
|
-
}
|
|
337
|
-
return console.log(`Looking for artifacts in:
|
|
338
|
-
${f.map((d) => d.path).join(`
|
|
339
|
-
`)}`), f.filter((d) => y(d.path));
|
|
340
|
-
}
|
|
341
|
-
const Se = async (r) => {
|
|
342
|
-
const { projectPath: t, debug: e, winPackage: n, arch: i, platform: a } = r, o = { arch: i, platform: a }, s = Q(o), c = Z(t ?? ".", o), f = await ee(c, e ?? !1, s, o, n);
|
|
343
|
-
if (f.length === 0)
|
|
344
|
-
throw new Error("No artifacts were found.");
|
|
345
|
-
const u = f.find((v) => v.type == "target").path, d = f.find((v) => v.type == "update")?.path, m = f.find((v) => v.type == "updateSig")?.path, h = m ? p.readFileSync(m, "utf8") : void 0;
|
|
346
|
-
return {
|
|
347
|
-
version: c.version,
|
|
348
|
-
arch: o.arch,
|
|
349
|
-
platform: o.platform,
|
|
350
|
-
targetPath: u,
|
|
351
|
-
updatePath: d,
|
|
352
|
-
signature: h
|
|
353
|
-
};
|
|
354
|
-
}, te = (r) => {
|
|
355
|
-
const t = O(r ?? ".");
|
|
356
|
-
if (t !== null) {
|
|
357
|
-
let e, n, i = "en-US", a = "1";
|
|
358
|
-
const o = P.fromBaseConfig(t);
|
|
359
|
-
if (e = o?.productName, o.version?.endsWith(".json")) {
|
|
360
|
-
const c = l(t, o?.version), f = w(c).toString();
|
|
361
|
-
n = JSON.parse(f).version;
|
|
362
|
-
} else
|
|
363
|
-
n = o?.version;
|
|
364
|
-
if (!(e && n)) {
|
|
365
|
-
const c = J(t);
|
|
366
|
-
e = e ?? c.package.name, n = n ?? c.package.version;
|
|
367
|
-
}
|
|
368
|
-
e && n || (console.error("Could not determine package name and version."), $.exit(1));
|
|
369
|
-
const s = n.replace(/[-+]/g, ".");
|
|
370
|
-
return o.wixLanguage && (i = o.wixLanguage), o.rpmRelease && (a = o.rpmRelease), {
|
|
371
|
-
basePath: t + "/target",
|
|
372
|
-
appName: e,
|
|
373
|
-
version: n,
|
|
374
|
-
wixLanguage: i,
|
|
375
|
-
wixAppVersion: s,
|
|
376
|
-
rpmRelease: a
|
|
377
|
-
};
|
|
378
|
-
} else
|
|
379
|
-
throw Error("Couldn't detect Tauri dir");
|
|
380
|
-
}, ne = async () => new Promise((r) => M("git rev-parse --abbrev-ref HEAD", (t, e, n) => {
|
|
381
|
-
if (t)
|
|
382
|
-
console.log(`getBranch Error: ${t}`);
|
|
383
|
-
else if (e) {
|
|
384
|
-
r(e.trim());
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
r(void 0);
|
|
388
|
-
}));
|
|
389
|
-
function re({
|
|
390
|
-
platform: r,
|
|
391
|
-
arch: t,
|
|
392
|
-
optionAccessKey: e
|
|
393
|
-
}) {
|
|
394
|
-
const n = g.join(".", "rop.yml"), i = p.readFileSync(n, "utf8"), a = E.load(i);
|
|
395
|
-
let o;
|
|
396
|
-
t == "x86_64" ? o = "x64" : t ? o = t : o = "x64";
|
|
397
|
-
let s = {
|
|
398
|
-
arch: o
|
|
399
|
-
};
|
|
400
|
-
if (!a.framework.name)
|
|
401
|
-
throw new Error('Missing "framework.name" property in the configuration file.');
|
|
402
|
-
const c = oe(a.framework.name, a.projectPath);
|
|
403
|
-
if (!c && !a.framework.env)
|
|
404
|
-
throw new Error(
|
|
405
|
-
`The [${a.framework.name}] framework is not supported, please specify the [framework.env] attribute.`
|
|
406
|
-
);
|
|
407
|
-
if (s = {
|
|
408
|
-
...s,
|
|
409
|
-
...c,
|
|
410
|
-
...a.framework.env ?? {}
|
|
411
|
-
}, !s.appName)
|
|
412
|
-
throw new Error('Missing "appName" property in the configuration file.');
|
|
413
|
-
if (!s.version)
|
|
414
|
-
throw new Error('Missing "version" property in the configuration file.');
|
|
415
|
-
function f(m) {
|
|
416
|
-
Object.keys(m).forEach((h) => {
|
|
417
|
-
typeof m[h] == "string" ? m[h] = m[h].replace(/\$\{(\w+)\}/g, (v, V) => s[V] || "") : typeof m[h] == "object" && m[h] !== null && f(m[h]);
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
f(a);
|
|
421
|
-
const u = a.platforms[r][o];
|
|
422
|
-
console.log("find target file:"), console.log(u);
|
|
423
|
-
const d = ie(e, a.access);
|
|
424
|
-
return { config: a, targetInfo: u, accessKey: d, version: s.version };
|
|
425
|
-
}
|
|
426
|
-
const ie = (r, t) => {
|
|
427
|
-
if (r)
|
|
428
|
-
return r;
|
|
429
|
-
if (t?.key)
|
|
430
|
-
return t?.key;
|
|
431
|
-
if (t?.name) {
|
|
432
|
-
const e = p.readFileSync(`${T.homedir()}/.rop/config`, "utf8"), n = `\\[${t.name}]\\n(.+)`, i = new RegExp(n).exec(e);
|
|
433
|
-
if (i)
|
|
434
|
-
return i[1];
|
|
435
|
-
}
|
|
436
|
-
throw new Error("missing access-key");
|
|
437
|
-
}, oe = (r, t) => {
|
|
438
|
-
switch (r.toLowerCase()) {
|
|
439
|
-
case L.TAURI.toLowerCase():
|
|
440
|
-
return te(t);
|
|
441
|
-
default:
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
class ae {
|
|
446
|
-
baseDomain;
|
|
447
|
-
constructor({ baseDomain: t }) {
|
|
448
|
-
this.baseDomain = t;
|
|
449
|
-
}
|
|
450
|
-
async upload(t) {
|
|
451
|
-
const e = await this.checkParams(t), n = new U(), i = p.createReadStream(e.targetPath), a = new G.MultiBar({
|
|
452
|
-
format: "Upload Progress |" + N.cyan("{bar}") + "| {percentage}% | {filename}",
|
|
453
|
-
barCompleteChar: "█",
|
|
454
|
-
barIncompleteChar: "░",
|
|
455
|
-
hideCursor: !0
|
|
456
|
-
}), o = a.create(p.statSync(e.targetPath).size, 0);
|
|
457
|
-
let s = 0;
|
|
458
|
-
i.on("data", (d) => {
|
|
459
|
-
s += d.length, o.update(s, { filename: g.basename(e.targetPath) });
|
|
460
|
-
}), n.append("targetFile", i, {
|
|
461
|
-
filename: e.targetName ?? g.basename(e.targetPath)
|
|
462
|
-
});
|
|
463
|
-
let c;
|
|
464
|
-
if (e.updatePath) {
|
|
465
|
-
const d = a.create(p.statSync(e.updatePath).size, 0);
|
|
466
|
-
c = p.createReadStream(e.updatePath);
|
|
467
|
-
let m = 0;
|
|
468
|
-
c.on("data", (h) => {
|
|
469
|
-
m += h.length, d.update(m, { filename: g.basename(e.updatePath) });
|
|
470
|
-
}), n.append("updateFile", c, {
|
|
471
|
-
filename: e.updateName ?? g.basename(e.updatePath)
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
n.append("accessKey", e.accessKey), n.append("branch", e.branch), n.append("version", e.version), n.append("platform", e.platform), n.append("arch", e.arch), e.signature && n.append("signature", e.signature);
|
|
475
|
-
const f = await K(`${this.baseDomain}/api/upload`, {
|
|
476
|
-
method: "POST",
|
|
477
|
-
headers: n.getHeaders(),
|
|
478
|
-
body: n
|
|
479
|
-
}), u = await f.json();
|
|
480
|
-
return f.ok || console.log(f.status, f.statusText, u), a.stop(), i.destroy(), c?.destroy(), { success: f.ok, body: u };
|
|
481
|
-
}
|
|
482
|
-
checkParams = async (t) => {
|
|
483
|
-
if (!t.accessKey)
|
|
484
|
-
throw new Error("accessKey not null");
|
|
485
|
-
const e = t.branch ?? await ne();
|
|
486
|
-
if (e)
|
|
487
|
-
t.branch = e;
|
|
488
|
-
else
|
|
489
|
-
throw new Error("branch not null");
|
|
490
|
-
if (!t.platform)
|
|
491
|
-
throw new Error("platform not null");
|
|
492
|
-
if (!t.arch)
|
|
493
|
-
throw new Error("arch not null");
|
|
494
|
-
if (!t.targetPath)
|
|
495
|
-
throw new Error("target path not null");
|
|
496
|
-
if (!p.existsSync(t.targetPath))
|
|
497
|
-
throw new Error(`target file not found, file path: ${t.targetPath}`);
|
|
498
|
-
if (t.updatePath && !p.existsSync(t.updatePath))
|
|
499
|
-
throw new Error(`update file not found, file path: ${t.updatePath}`);
|
|
500
|
-
if (!t.version)
|
|
501
|
-
throw new Error("version not null");
|
|
502
|
-
return t;
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
class se {
|
|
506
|
-
async initYaml(t) {
|
|
507
|
-
const e = g.resolve(), n = g.basename(e), i = g.join(".", "rop.yml");
|
|
508
|
-
let a = {};
|
|
509
|
-
if (p.existsSync(i)) {
|
|
510
|
-
let s = !1;
|
|
511
|
-
try {
|
|
512
|
-
s = await W({
|
|
513
|
-
message: `${N.cyan("rop.yml")} already exists, does it need to be overwritten?`
|
|
514
|
-
});
|
|
515
|
-
} catch {
|
|
516
|
-
return console.log("cancel"), !1;
|
|
517
|
-
}
|
|
518
|
-
if (!s)
|
|
519
|
-
return console.log("cancel"), !1;
|
|
520
|
-
const c = p.readFileSync(i, "utf8");
|
|
521
|
-
a = E.load(c);
|
|
522
|
-
}
|
|
523
|
-
a.access ? a.access.name = n : a.access = {
|
|
524
|
-
name: n
|
|
525
|
-
};
|
|
526
|
-
const o = E.dump(a, {
|
|
527
|
-
lineWidth: 500
|
|
528
|
-
});
|
|
529
|
-
return p.writeFileSync(i, o, "utf8"), !0;
|
|
530
|
-
}
|
|
531
|
-
async initRopConfig(t) {
|
|
532
|
-
const e = g.join(".", ".rop");
|
|
533
|
-
p.existsSync(e) || p.mkdirSync(e);
|
|
534
|
-
const n = g.join(e, "config.json");
|
|
535
|
-
let i = {};
|
|
536
|
-
p.existsSync(n) && (i = JSON.parse(p.readFileSync(n, "utf8"))), i.accessKey = t, p.writeFileSync(n, JSON.stringify(i, null, 2), "utf8");
|
|
537
|
-
}
|
|
538
|
-
async initGitignore() {
|
|
539
|
-
const t = g.join(".", ".gitignore");
|
|
540
|
-
p.existsSync(t) ? p.readFileSync(t, "utf8").includes(".rop") || p.appendFileSync(t, `
|
|
541
|
-
.rop`, "utf8") : p.writeFileSync(t, ".rop", "utf8");
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
const k = new I();
|
|
545
|
-
k.name("rop").description("CLI to some JavaScript string utilities").version("0.1.0");
|
|
546
|
-
k.command("init").description("init rop").action(async () => {
|
|
547
|
-
let r = "";
|
|
548
|
-
for (; !r; )
|
|
549
|
-
try {
|
|
550
|
-
r = await Y({ message: `Please enter ${N.cyan("access-key")}` });
|
|
551
|
-
} catch {
|
|
552
|
-
console.log("cancel");
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
const t = new se();
|
|
556
|
-
await t.initYaml(r) && (await t.initRopConfig(r), await t.initGitignore(), console.log("done"));
|
|
557
|
-
});
|
|
558
|
-
k.command("set-key").description("set access-key").argument("<string>", "projectAccessKey").action(async (r) => {
|
|
559
|
-
try {
|
|
560
|
-
const t = r.split("=");
|
|
561
|
-
if (t.length != 2)
|
|
562
|
-
throw new Error("parameter format error");
|
|
563
|
-
const [e, n] = t, a = `${T.homedir()}/.rop`;
|
|
564
|
-
b.existsSync(a) || b.mkdirSync(a);
|
|
565
|
-
const o = `${a}/config`, s = `[${e}]
|
|
566
|
-
${n}`;
|
|
567
|
-
if (!b.existsSync(o))
|
|
568
|
-
b.writeFileSync(o, s);
|
|
569
|
-
else {
|
|
570
|
-
const c = b.readFileSync(o, "utf8"), f = `\\[${e}]\\n(.+)`, u = new RegExp(f).exec(c);
|
|
571
|
-
u ? b.writeFileSync(o, c.replace(u[0], s)) : b.appendFileSync(o, `
|
|
572
|
-
` + s);
|
|
573
|
-
}
|
|
574
|
-
} catch (t) {
|
|
575
|
-
console.error("Error reading configuration file or missing required properties:", t);
|
|
576
|
-
}
|
|
577
|
-
});
|
|
578
|
-
k.command("upload").description("Upload some framework build").argument("<string>", "platform").argument("[string]", "arch").option("-a, --accessKey <string>", "accessKey path").action(async (r, t, e) => {
|
|
579
|
-
const { config: n, targetInfo: i, accessKey: a, version: o } = re({
|
|
580
|
-
platform: r,
|
|
581
|
-
arch: t,
|
|
582
|
-
optionAccessKey: e.accessKey
|
|
583
|
-
});
|
|
584
|
-
if (!n.host)
|
|
585
|
-
throw new Error('Missing "host" property in the configuration file.');
|
|
586
|
-
if (!i)
|
|
587
|
-
throw new Error('Missing "targetInfo" property in the configuration file.');
|
|
588
|
-
await new ae({ baseDomain: n.host }).upload({
|
|
589
|
-
accessKey: a,
|
|
590
|
-
arch: t,
|
|
591
|
-
platform: r,
|
|
592
|
-
version: o,
|
|
593
|
-
targetPath: i.target.path,
|
|
594
|
-
targetName: i.target?.name,
|
|
595
|
-
updatePath: i.update?.path,
|
|
596
|
-
updateName: i.update?.name,
|
|
597
|
-
signature: i.sig?.path ? b.readFileSync(i.sig.path, "utf8") : void 0
|
|
598
|
-
});
|
|
599
|
-
});
|
|
600
|
-
k.parse();
|
|
601
|
-
export {
|
|
602
|
-
ae as RopUpload,
|
|
603
|
-
Se as getTauriBody,
|
|
604
|
-
te as getTauriEnv
|
|
605
|
-
};
|