@sevenvip666/rop 0.0.2 → 0.0.5

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