@platforma-sdk/block-tools 2.6.63 → 2.6.64

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/cli.mjs CHANGED
@@ -1,426 +1,381 @@
1
- var D = Object.defineProperty;
2
- var M = (o, e, t) => e in o ? D(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var i = (o, e, t) => M(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { Command as m, Flags as s } from "@oclif/core";
5
- import d from "node:path";
6
- import p from "node:fs";
7
- import "zod";
8
- import "mime-types";
9
- import "tar";
10
- import "@milaboratories/resolve-helper";
11
- import { l as Y, B, a as J, s as R, b as N, c as H, d as U, M as K, P as z, g as W } from "./config-Cc8_zV3b.mjs";
12
- import { StableChannel as F, overrideDescriptionVersion as _, BlockPackManifest as Z, overrideManifestVersion as Q } from "@milaboratories/pl-model-middle-layer";
13
- import "@milaboratories/pl-model-common";
14
- import "@milaboratories/ts-helpers";
15
- import "canonicalize";
16
- import "lru-cache";
17
- import { OclifLoggerAdapter as u } from "@milaboratories/ts-helpers-oclif";
18
- import "undici";
19
- import "@milaboratories/pl-http";
20
- import q from "yaml";
21
- import { execFileSync as X } from "node:child_process";
22
- import { createRequire as ee } from "node:module";
23
- const h = class h extends m {
24
- async run() {
25
- const { flags: e } = await this.parse(h), t = d.resolve(e.modulePath), a = await Y(t), r = await B.parseAsync(
26
- J(t).parse(a.meta)
27
- );
28
- await p.promises.writeFile(d.resolve(e.destination), JSON.stringify(r));
29
- }
1
+ import { Ct as e, F as t, J as n, Q as r, Y as i, _ as a, b as o, n as s, ot as c, p as l, st as u } from "./config-CZZ2gdZH.mjs";
2
+ import { Command as d, Flags as f } from "@oclif/core";
3
+ import p from "node:path";
4
+ import m from "node:fs";
5
+ import { BlockPackManifest as h, StableChannel as g, overrideDescriptionVersion as _, overrideManifestVersion as v } from "@milaboratories/pl-model-middle-layer";
6
+ import { OclifLoggerAdapter as y } from "@milaboratories/ts-helpers-oclif";
7
+ import b from "yaml";
8
+ import { execFileSync as x } from "node:child_process";
9
+ import { createRequire as S } from "node:module";
10
+ var C = class e extends d {
11
+ static description = "Extracts meta information from blocks package.json and outputs meta.json with embedded binary and textual information linked from the meta section.";
12
+ static flags = {
13
+ modulePath: f.string({
14
+ char: "i",
15
+ summary: "input module path",
16
+ helpValue: "<path>",
17
+ default: "."
18
+ }),
19
+ destination: f.string({
20
+ char: "o",
21
+ summary: "output meta.json file",
22
+ helpValue: "<path>",
23
+ required: !0
24
+ })
25
+ };
26
+ async run() {
27
+ let { flags: t } = await this.parse(e), n = p.resolve(t.modulePath), r = await i(n), a = await u.parseAsync(c(n).parse(r.meta));
28
+ await m.promises.writeFile(p.resolve(t.destination), JSON.stringify(a));
29
+ }
30
30
  };
31
- i(h, "description", "Extracts meta information from blocks package.json and outputs meta.json with embedded binary and textual information linked from the meta section."), i(h, "flags", {
32
- modulePath: s.string({
33
- char: "i",
34
- summary: "input module path",
35
- helpValue: "<path>",
36
- default: "."
37
- }),
38
- destination: s.string({
39
- char: "o",
40
- summary: "output meta.json file",
41
- helpValue: "<path>",
42
- required: !0
43
- })
44
- });
45
- let x = h;
46
- async function te(o) {
47
- try {
48
- return await p.promises.readFile(o, "utf8");
49
- } catch (e) {
50
- if (e instanceof Error && "code" in e && e.code === "ENOENT")
51
- return;
52
- throw e;
53
- }
31
+ async function w(e) {
32
+ try {
33
+ return await m.promises.readFile(e, "utf8");
34
+ } catch (e) {
35
+ if (e instanceof Error && "code" in e && e.code === "ENOENT") return;
36
+ throw e;
37
+ }
54
38
  }
55
- const g = class g extends m {
56
- async run() {
57
- const { flags: e } = await this.parse(g), t = d.resolve(e.modulePath);
58
- let { model: a, platforma: r } = require(t);
59
- if (a || (a = r), !a) throw new Error('"model" export not found');
60
- const { config: c } = a;
61
- if (!c)
62
- throw new Error(
63
- 'Malformed "model" object, check it is created with "BlockModel" and ".done()" is executed as the call in the chain.'
64
- );
65
- if (!("outputs" in c) || !("sections" in c))
66
- throw new Error('"config" has unexpected structure');
67
- const l = await te(e.sourceBundle);
68
- l !== void 0 && (c.code = {
69
- type: "plain",
70
- content: l
71
- }), await p.promises.writeFile(d.resolve(e.destination), JSON.stringify(c));
72
- }
73
- };
74
- i(g, "description", "Extracts and outputs block model JSON from pre-built block model module"), i(g, "flags", {
75
- modulePath: s.string({
76
- char: "i",
77
- summary: "input module path",
78
- helpValue: "<path>",
79
- default: "."
80
- }),
81
- sourceBundle: s.string({
82
- char: "b",
83
- summary: "bundled model code to embed into the model for callback-based rendering to work",
84
- helpValue: "<path>",
85
- default: "./dist/bundle.js"
86
- }),
87
- destination: s.string({
88
- char: "o",
89
- summary: "output model file",
90
- helpValue: "<path>",
91
- default: "./dist/model.json"
92
- })
93
- });
94
- let A = g;
95
- const y = class y extends m {
96
- async run() {
97
- const { flags: e } = await this.parse(y), t = R(e.registry), r = await new N(t, new u(this)).listGlobalOverviewSnapshots();
98
- if (e.json)
99
- this.log(JSON.stringify(r, null, 2));
100
- else if (r.length === 0)
101
- this.log("No snapshots found.");
102
- else {
103
- this.log(`Found ${r.length} snapshot(s):
104
- `);
105
- for (const c of r)
106
- this.log(` ${c.timestamp}`), this.log(` Path: ${c.path}`), this.log("");
107
- }
108
- }
109
- };
110
- i(y, "description", "List all available global overview snapshots in the registry"), i(y, "flags", {
111
- registry: s.string({
112
- char: "r",
113
- summary: "full address of the registry",
114
- helpValue: "<address>",
115
- env: "PL_REGISTRY",
116
- required: !0
117
- }),
118
- json: s.boolean({
119
- summary: "output in JSON format",
120
- default: !1
121
- })
122
- });
123
- let I = y;
124
- const w = class w extends m {
125
- async run() {
126
- const { flags: e } = await this.parse(w);
127
- let t = await Y(d.resolve(e.modulePath));
128
- e["version-override"] && (t = _(t, e["version-override"]));
129
- const a = R(e.registry), r = new N(a, new u(this));
130
- e.unmark ? await r.removePackageFromChannel(t.id, e.channel) : await r.addPackageToChannel(t.id, e.channel), e.refresh && await r.updateIfNeeded();
131
- }
132
- };
133
- i(w, "description", "Mark target block stable"), i(w, "flags", {
134
- modulePath: s.string({
135
- char: "i",
136
- summary: "input module path",
137
- helpValue: "<path>",
138
- default: "."
139
- }),
140
- channel: s.string({
141
- char: "c",
142
- hidden: !0,
143
- summary: "custom channel",
144
- helpValue: "<channel name>",
145
- default: F
146
- }),
147
- "version-override": s.file({
148
- char: "v",
149
- summary: "override package version"
150
- }),
151
- registry: s.string({
152
- char: "r",
153
- summary: "full address of the registry",
154
- helpValue: "<address>",
155
- env: "PL_REGISTRY",
156
- required: !0
157
- }),
158
- refresh: s.boolean({
159
- summary: "refresh repository after adding the package",
160
- default: !0,
161
- allowNo: !0,
162
- env: "PL_REGISTRY_REFRESH"
163
- }),
164
- unmark: s.boolean({
165
- summary: 'reverses meaning of this command, flag can be used to remove "stable" flag from the package',
166
- default: !1
167
- })
168
- });
169
- let V = w;
170
- const v = class v extends m {
171
- async run() {
172
- const { flags: e } = await this.parse(v), t = await H(d.resolve(e.modulePath));
173
- await U(t, d.resolve(e.destinationPath));
174
- }
39
+ var T = class t extends d {
40
+ static description = "Extracts and outputs block model JSON from pre-built block model module";
41
+ static flags = {
42
+ modulePath: f.string({
43
+ char: "i",
44
+ summary: "input module path",
45
+ helpValue: "<path>",
46
+ default: "."
47
+ }),
48
+ sourceBundle: f.string({
49
+ char: "b",
50
+ summary: "bundled model code to embed into the model for callback-based rendering to work",
51
+ helpValue: "<path>",
52
+ default: "./dist/bundle.js"
53
+ }),
54
+ destination: f.string({
55
+ char: "o",
56
+ summary: "output model file",
57
+ helpValue: "<path>",
58
+ default: "./dist/model.json"
59
+ })
60
+ };
61
+ async run() {
62
+ let { flags: n } = await this.parse(t), { model: r, platforma: i } = e(p.resolve(n.modulePath));
63
+ if (r ||= i, !r) throw Error("\"model\" export not found");
64
+ let { config: a } = r;
65
+ if (!a) throw Error("Malformed \"model\" object, check it is created with \"BlockModel\" and \".done()\" is executed as the call in the chain.");
66
+ if (!("outputs" in a) || !("sections" in a)) throw Error("\"config\" has unexpected structure");
67
+ let o = await w(n.sourceBundle);
68
+ o !== void 0 && (a.code = {
69
+ type: "plain",
70
+ content: o
71
+ }), await m.promises.writeFile(p.resolve(n.destination), JSON.stringify(a));
72
+ }
73
+ }, E = class e extends d {
74
+ static description = "List all available global overview snapshots in the registry";
75
+ static flags = {
76
+ registry: f.string({
77
+ char: "r",
78
+ summary: "full address of the registry",
79
+ helpValue: "<address>",
80
+ env: "PL_REGISTRY",
81
+ required: !0
82
+ }),
83
+ json: f.boolean({
84
+ summary: "output in JSON format",
85
+ default: !1
86
+ })
87
+ };
88
+ async run() {
89
+ let { flags: t } = await this.parse(e), n = await new o(a(t.registry), new y(this)).listGlobalOverviewSnapshots();
90
+ if (t.json) this.log(JSON.stringify(n, null, 2));
91
+ else if (n.length === 0) this.log("No snapshots found.");
92
+ else {
93
+ this.log(`Found ${n.length} snapshot(s):\n`);
94
+ for (let e of n) this.log(` ${e.timestamp}`), this.log(` Path: ${e.path}`), this.log("");
95
+ }
96
+ }
97
+ }, D = class e extends d {
98
+ static description = "Mark target block stable";
99
+ static flags = {
100
+ modulePath: f.string({
101
+ char: "i",
102
+ summary: "input module path",
103
+ helpValue: "<path>",
104
+ default: "."
105
+ }),
106
+ channel: f.string({
107
+ char: "c",
108
+ hidden: !0,
109
+ summary: "custom channel",
110
+ helpValue: "<channel name>",
111
+ default: g
112
+ }),
113
+ "version-override": f.file({
114
+ char: "v",
115
+ summary: "override package version"
116
+ }),
117
+ registry: f.string({
118
+ char: "r",
119
+ summary: "full address of the registry",
120
+ helpValue: "<address>",
121
+ env: "PL_REGISTRY",
122
+ required: !0
123
+ }),
124
+ refresh: f.boolean({
125
+ summary: "refresh repository after adding the package",
126
+ default: !0,
127
+ allowNo: !0,
128
+ env: "PL_REGISTRY_REFRESH"
129
+ }),
130
+ unmark: f.boolean({
131
+ summary: "reverses meaning of this command, flag can be used to remove \"stable\" flag from the package",
132
+ default: !1
133
+ })
134
+ };
135
+ async run() {
136
+ let { flags: t } = await this.parse(e), n = await i(p.resolve(t.modulePath));
137
+ t["version-override"] && (n = _(n, t["version-override"]));
138
+ let r = new o(a(t.registry), new y(this));
139
+ t.unmark ? await r.removePackageFromChannel(n.id, t.channel) : await r.addPackageToChannel(n.id, t.channel), t.refresh && await r.updateIfNeeded();
140
+ }
141
+ }, O = class e extends d {
142
+ static description = "Builds block pack and outputs a block pack manifest consolidating all references assets into a single folder";
143
+ static flags = {
144
+ modulePath: f.string({
145
+ char: "i",
146
+ summary: "input module path",
147
+ helpValue: "<path>",
148
+ default: "."
149
+ }),
150
+ destinationPath: f.string({
151
+ char: "o",
152
+ summary: "output folder",
153
+ helpValue: "<path>",
154
+ default: "./block-pack"
155
+ })
156
+ };
157
+ async run() {
158
+ let { flags: t } = await this.parse(e);
159
+ await r(await n(p.resolve(t.modulePath)), p.resolve(t.destinationPath));
160
+ }
175
161
  };
176
- i(v, "description", "Builds block pack and outputs a block pack manifest consolidating all references assets into a single folder"), i(v, "flags", {
177
- modulePath: s.string({
178
- char: "i",
179
- summary: "input module path",
180
- helpValue: "<path>",
181
- default: "."
182
- }),
183
- destinationPath: s.string({
184
- char: "o",
185
- summary: "output folder",
186
- helpValue: "<path>",
187
- default: "./block-pack"
188
- })
189
- });
190
- let L = v;
191
- function O(o, e) {
192
- const t = { ...o };
193
- for (const a in e)
194
- e[a] && typeof e[a] == "object" && !Array.isArray(e[a]) && t[a] && typeof t[a] == "object" && !Array.isArray(t[a]) ? t[a] = O(
195
- t[a],
196
- e[a]
197
- ) : t[a] = e[a];
198
- return t;
162
+ function k(e, t) {
163
+ let n = { ...e };
164
+ for (let e in t) t[e] && typeof t[e] == "object" && !Array.isArray(t[e]) && n[e] && typeof n[e] == "object" && !Array.isArray(n[e]) ? n[e] = k(n[e], t[e]) : n[e] = t[e];
165
+ return n;
199
166
  }
200
- const b = class b extends m {
201
- async run() {
202
- const { flags: e } = await this.parse(b), t = d.resolve(e.manifest), a = JSON.parse(
203
- await p.promises.readFile(t, { encoding: "utf-8" })
204
- );
205
- let r = Z.parse(a);
206
- r = O(
207
- a,
208
- r
209
- );
210
- const c = d.dirname(t);
211
- this.log(`Manifest root = ${c}`), e["version-override"] && (r = Q(r, e["version-override"]));
212
- const l = R(e.registry), n = new N(l, new u(this));
213
- await n.publishPackage(
214
- r,
215
- async (f) => Buffer.from(await p.promises.readFile(d.resolve(c, f)))
216
- ), e.unstable || (this.log(`Adding package to ${F} channel...`), await n.addPackageToChannel(r.description.id, F)), e.refresh && await n.updateIfNeeded();
217
- }
167
+ var A = class e extends d {
168
+ static description = "Publishes the block package and refreshes the registry (for v2 block-pack schema)";
169
+ static flags = {
170
+ registry: f.string({
171
+ char: "r",
172
+ summary: "full address of the registry",
173
+ helpValue: "<address>",
174
+ env: "PL_REGISTRY",
175
+ required: !0
176
+ }),
177
+ manifest: f.file({
178
+ char: "m",
179
+ summary: "manifest file path",
180
+ exists: !0,
181
+ default: `./block-pack/${t}`
182
+ }),
183
+ "version-override": f.file({
184
+ char: "v",
185
+ summary: "override package version"
186
+ }),
187
+ refresh: f.boolean({
188
+ summary: "refresh repository after adding the package",
189
+ default: !0,
190
+ allowNo: !0,
191
+ env: "PL_REGISTRY_REFRESH"
192
+ }),
193
+ unstable: f.boolean({
194
+ summary: "do not add the published package to stable channel",
195
+ default: !1,
196
+ env: "PL_PUBLISH_UNSTABLE"
197
+ })
198
+ };
199
+ async run() {
200
+ let { flags: t } = await this.parse(e), n = p.resolve(t.manifest), r = JSON.parse(await m.promises.readFile(n, { encoding: "utf-8" })), i = h.parse(r);
201
+ i = k(r, i);
202
+ let s = p.dirname(n);
203
+ this.log(`Manifest root = ${s}`), t["version-override"] && (i = v(i, t["version-override"]));
204
+ let c = new o(a(t.registry), new y(this));
205
+ await c.publishPackage(i, async (e) => Buffer.from(await m.promises.readFile(p.resolve(s, e)))), t.unstable || (this.log(`Adding package to ${g} channel...`), await c.addPackageToChannel(i.description.id, g)), t.refresh && await c.updateIfNeeded();
206
+ }
207
+ }, j = class e extends d {
208
+ static description = "Refresh overview files based on published but not proecessed artefacts";
209
+ static flags = {
210
+ registry: f.string({
211
+ char: "r",
212
+ summary: "full address of the registry",
213
+ helpValue: "<address>",
214
+ env: "PL_REGISTRY",
215
+ required: !0
216
+ }),
217
+ mode: f.string({
218
+ char: "m",
219
+ summary: "refresh mode (allowed valiues: \"force\", \"normal\", \"dry-run\")",
220
+ helpValue: "<mode>",
221
+ options: [
222
+ "force",
223
+ "normal",
224
+ "dry-run"
225
+ ],
226
+ env: "PL_REGISTRY_REFRESH_DRY_RUN",
227
+ default: "normal"
228
+ })
229
+ };
230
+ async run() {
231
+ let { flags: t } = await this.parse(e);
232
+ await new o(a(t.registry), new y(this)).updateIfNeeded(t.mode);
233
+ }
234
+ }, M = class e extends d {
235
+ static description = "Restore global overview from a snapshot";
236
+ static flags = {
237
+ registry: f.string({
238
+ char: "r",
239
+ summary: "full address of the registry",
240
+ helpValue: "<address>",
241
+ env: "PL_REGISTRY",
242
+ required: !0
243
+ }),
244
+ snapshot: f.string({
245
+ char: "s",
246
+ summary: "snapshot timestamp ID to restore from",
247
+ helpValue: "<timestamp>",
248
+ required: !0
249
+ }),
250
+ "skip-confirmation": f.boolean({
251
+ summary: "skip confirmation prompt (use with caution)",
252
+ default: !1
253
+ })
254
+ };
255
+ async run() {
256
+ let { flags: t } = await this.parse(e), n = new o(a(t.registry), new y(this)), r = await n.listGlobalOverviewSnapshots();
257
+ if (r.find((e) => e.timestamp === t.snapshot) || this.error(`Snapshot '${t.snapshot}' not found. Available snapshots:\n${r.map((e) => ` - ${e.timestamp}`).join("\n") || " (none)"}`), !t["skip-confirmation"]) {
258
+ let e = (await import("node:readline")).createInterface({
259
+ input: process.stdin,
260
+ output: process.stdout
261
+ }), n = await new Promise((n) => {
262
+ e.question(`⚠️ This will overwrite the current global overview with snapshot '${t.snapshot}'.\nAre you sure you want to continue? (y/N): `, n);
263
+ });
264
+ if (e.close(), n.toLowerCase() !== "y" && n.toLowerCase() !== "yes") {
265
+ this.log("Restore cancelled.");
266
+ return;
267
+ }
268
+ }
269
+ try {
270
+ await n.restoreGlobalOverviewFromSnapshot(t.snapshot), this.log(`✅ Successfully restored global overview from snapshot '${t.snapshot}'`);
271
+ } catch (e) {
272
+ this.error(`Failed to restore from snapshot: ${String(e)}`);
273
+ }
274
+ }
218
275
  };
219
- i(b, "description", "Publishes the block package and refreshes the registry (for v2 block-pack schema)"), i(b, "flags", {
220
- registry: s.string({
221
- char: "r",
222
- summary: "full address of the registry",
223
- helpValue: "<address>",
224
- env: "PL_REGISTRY",
225
- required: !0
226
- }),
227
- manifest: s.file({
228
- char: "m",
229
- summary: "manifest file path",
230
- exists: !0,
231
- default: `./block-pack/${K}`
232
- }),
233
- "version-override": s.file({
234
- char: "v",
235
- summary: "override package version"
236
- }),
237
- refresh: s.boolean({
238
- summary: "refresh repository after adding the package",
239
- default: !0,
240
- allowNo: !0,
241
- env: "PL_REGISTRY_REFRESH"
242
- }),
243
- unstable: s.boolean({
244
- summary: "do not add the published package to stable channel",
245
- default: !1,
246
- env: "PL_PUBLISH_UNSTABLE"
247
- })
248
- });
249
- let G = b;
250
- const k = class k extends m {
251
- async run() {
252
- const { flags: e } = await this.parse(k), t = R(e.registry);
253
- await new N(t, new u(this)).updateIfNeeded(e.mode);
254
- }
255
- };
256
- i(k, "description", "Refresh overview files based on published but not proecessed artefacts"), i(k, "flags", {
257
- registry: s.string({
258
- char: "r",
259
- summary: "full address of the registry",
260
- helpValue: "<address>",
261
- env: "PL_REGISTRY",
262
- required: !0
263
- }),
264
- mode: s.string({
265
- char: "m",
266
- summary: 'refresh mode (allowed valiues: "force", "normal", "dry-run")',
267
- helpValue: "<mode>",
268
- options: ["force", "normal", "dry-run"],
269
- env: "PL_REGISTRY_REFRESH_DRY_RUN",
270
- default: "normal"
271
- })
272
- });
273
- let T = k;
274
- const P = class P extends m {
275
- async run() {
276
- const { flags: e } = await this.parse(P), t = R(e.registry), a = new N(t, new u(this)), r = await a.listGlobalOverviewSnapshots();
277
- if (r.find((l) => l.timestamp === e.snapshot) || this.error(
278
- `Snapshot '${e.snapshot}' not found. Available snapshots:
279
- ${r.map((l) => ` - ${l.timestamp}`).join(`
280
- `) || " (none)"}`
281
- ), !e["skip-confirmation"]) {
282
- const n = (await import("node:readline")).createInterface({
283
- input: process.stdin,
284
- output: process.stdout
285
- }), f = await new Promise((S) => {
286
- n.question(
287
- `⚠️ This will overwrite the current global overview with snapshot '${e.snapshot}'.
288
- Are you sure you want to continue? (y/N): `,
289
- S
290
- );
291
- });
292
- if (n.close(), f.toLowerCase() !== "y" && f.toLowerCase() !== "yes") {
293
- this.log("Restore cancelled.");
294
- return;
295
- }
296
- }
297
- try {
298
- await a.restoreGlobalOverviewFromSnapshot(e.snapshot), this.log(`✅ Successfully restored global overview from snapshot '${e.snapshot}'`);
299
- } catch (l) {
300
- this.error(`Failed to restore from snapshot: ${String(l)}`);
301
- }
302
- }
303
- };
304
- i(P, "description", "Restore global overview from a snapshot"), i(P, "flags", {
305
- registry: s.string({
306
- char: "r",
307
- summary: "full address of the registry",
308
- helpValue: "<address>",
309
- env: "PL_REGISTRY",
310
- required: !0
311
- }),
312
- snapshot: s.string({
313
- char: "s",
314
- summary: "snapshot timestamp ID to restore from",
315
- helpValue: "<timestamp>",
316
- required: !0
317
- }),
318
- "skip-confirmation": s.boolean({
319
- summary: "skip confirmation prompt (use with caution)",
320
- default: !1
321
- })
322
- });
323
- let j = P;
324
- function ae(o) {
325
- const e = o.match(/(?<destName>[^/\\]+)=(?<src>.*)/);
326
- if (e) {
327
- const { src: t, destName: a } = e.groups;
328
- return { src: t, destName: a };
329
- } else
330
- return { src: o, destName: d.basename(o) };
276
+ function N(e) {
277
+ let t = e.match(/(?<destName>[^/\\]+)=(?<src>.*)/);
278
+ if (t) {
279
+ let { src: e, destName: n } = t.groups;
280
+ return {
281
+ src: e,
282
+ destName: n
283
+ };
284
+ } else return {
285
+ src: e,
286
+ destName: p.basename(e)
287
+ };
331
288
  }
332
- const se = s.custom({
333
- summary: "target files to upload",
334
- helpValue: "file_path | package_name=file_path",
335
- // eslint-disable-next-line @typescript-eslint/require-await -- oclif requires async but parsing is sync
336
- parse: async (o) => ae(o)
337
- }), re = ["registry", "organization", "package", "version"], E = class E extends m {
338
- async run() {
339
- const { flags: e } = await this.parse(E), t = z.parse({});
340
- for (const n of re) e[n] && (t[n] = e[n]);
341
- e.meta && (e.meta.endsWith(".json") ? t.meta = JSON.parse(
342
- await p.promises.readFile(e.meta, { encoding: "utf-8" })
343
- ) : e.meta.endsWith(".yaml") && (t.meta = q.parse(
344
- await p.promises.readFile(e.meta, { encoding: "utf-8" })
345
- )));
346
- for (const n of e.file)
347
- t.files[n.destName] = n.src;
348
- const a = await W(t);
349
- this.log(q.stringify(a.conf));
350
- const r = a.createRegistry(new u(this)), c = a.fullPackageName, l = r.constructNewPackage(c);
351
- for (const [n, f] of Object.entries(a.conf.files)) {
352
- this.log(`Uploading ${f} -> ${n} ...`);
353
- const S = await p.promises.readFile(f);
354
- await l.addFile(n, S);
355
- }
356
- this.log("Uploading meta information..."), await l.writeMeta(a.conf.meta), await l.finish(), e.refresh && await r.updateIfNeeded();
357
- }
358
- };
359
- i(E, "description", "Uploads V1 package and refreshes the registry"), i(E, "flags", {
360
- registry: s.string({
361
- char: "r",
362
- summary: "full address of the registry or alias from .pl.reg",
363
- helpValue: "<address|alias>",
364
- env: "PL_REGISTRY"
365
- }),
366
- organization: s.string({
367
- char: "o",
368
- summary: "target organisation",
369
- env: "PL_PACKAGE_ORGANIZATION"
370
- }),
371
- package: s.string({
372
- char: "p",
373
- summary: "target package",
374
- env: "PL_PACKAGE_NAME"
375
- }),
376
- version: s.string({
377
- char: "v",
378
- summary: "target version",
379
- env: "PL_PACKAGE_VERSION"
380
- }),
381
- meta: s.file({
382
- char: "m",
383
- summary: "json file containing meta information to associate with tha package",
384
- exists: !0
385
- }),
386
- file: se({
387
- char: "f",
388
- summary: "package files",
389
- multiple: !0,
390
- default: []
391
- }),
392
- refresh: s.boolean({
393
- summary: "refresh repository after adding the package",
394
- default: !0,
395
- allowNo: !0,
396
- env: "PL_REGISTRY_REFRESH"
397
- })
289
+ const P = f.custom({
290
+ summary: "target files to upload",
291
+ helpValue: "file_path | package_name=file_path",
292
+ parse: async (e) => N(e)
398
293
  });
399
- let C = E;
400
- class $ extends m {
401
- // eslint-disable-next-line @typescript-eslint/require-await -- oclif requires async but implementation is sync
402
- async run() {
403
- const t = ee(import.meta.url).resolve("@platforma-sdk/blocks-deps-updater/scripts/updater.js");
404
- X(process.execPath, [t], {
405
- stdio: "inherit",
406
- cwd: process.cwd()
407
- });
408
- }
409
- }
410
- i($, "description", "Updates @platforma-sdk and @milaboratories packages in pnpm-workspace.yaml catalog to their latest versions from npm registry."), i($, "examples", ["<%= config.bin %> <%= command.id %>"]);
411
- const Ne = {
412
- "build-meta": x,
413
- "build-model": A,
414
- "list-overview-snapshots": I,
415
- "mark-stable": V,
416
- pack: L,
417
- publish: G,
418
- "refresh-registry": T,
419
- "restore-overview-from-snapshot": j,
420
- "upload-package-v1": C,
421
- "update-deps": $
294
+ var F = [
295
+ "registry",
296
+ "organization",
297
+ "package",
298
+ "version"
299
+ ], I = class e extends d {
300
+ static description = "Uploads V1 package and refreshes the registry";
301
+ static flags = {
302
+ registry: f.string({
303
+ char: "r",
304
+ summary: "full address of the registry or alias from .pl.reg",
305
+ helpValue: "<address|alias>",
306
+ env: "PL_REGISTRY"
307
+ }),
308
+ organization: f.string({
309
+ char: "o",
310
+ summary: "target organisation",
311
+ env: "PL_PACKAGE_ORGANIZATION"
312
+ }),
313
+ package: f.string({
314
+ char: "p",
315
+ summary: "target package",
316
+ env: "PL_PACKAGE_NAME"
317
+ }),
318
+ version: f.string({
319
+ char: "v",
320
+ summary: "target version",
321
+ env: "PL_PACKAGE_VERSION"
322
+ }),
323
+ meta: f.file({
324
+ char: "m",
325
+ summary: "json file containing meta information to associate with tha package",
326
+ exists: !0
327
+ }),
328
+ file: P({
329
+ char: "f",
330
+ summary: "package files",
331
+ multiple: !0,
332
+ default: []
333
+ }),
334
+ refresh: f.boolean({
335
+ summary: "refresh repository after adding the package",
336
+ default: !0,
337
+ allowNo: !0,
338
+ env: "PL_REGISTRY_REFRESH"
339
+ })
340
+ };
341
+ async run() {
342
+ let { flags: t } = await this.parse(e), n = l.parse({});
343
+ for (let e of F) t[e] && (n[e] = t[e]);
344
+ t.meta && (t.meta.endsWith(".json") ? n.meta = JSON.parse(await m.promises.readFile(t.meta, { encoding: "utf-8" })) : t.meta.endsWith(".yaml") && (n.meta = b.parse(await m.promises.readFile(t.meta, { encoding: "utf-8" }))));
345
+ for (let e of t.file) n.files[e.destName] = e.src;
346
+ let r = await s(n);
347
+ this.log(b.stringify(r.conf));
348
+ let i = r.createRegistry(new y(this)), a = r.fullPackageName, o = i.constructNewPackage(a);
349
+ for (let [e, t] of Object.entries(r.conf.files)) {
350
+ this.log(`Uploading ${t} -> ${e} ...`);
351
+ let n = await m.promises.readFile(t);
352
+ await o.addFile(e, n);
353
+ }
354
+ this.log("Uploading meta information..."), await o.writeMeta(r.conf.meta), await o.finish(), t.refresh && await i.updateIfNeeded();
355
+ }
356
+ }, L = class extends d {
357
+ static description = "Updates @platforma-sdk and @milaboratories packages in pnpm-workspace.yaml catalog to their latest versions from npm registry.";
358
+ static examples = ["<%= config.bin %> <%= command.id %>"];
359
+ async run() {
360
+ let e = S(import.meta.url).resolve("@platforma-sdk/blocks-deps-updater/scripts/updater.js");
361
+ x(process.execPath, [e], {
362
+ stdio: "inherit",
363
+ cwd: process.cwd()
364
+ });
365
+ }
422
366
  };
423
- export {
424
- Ne as COMMANDS
367
+ const R = {
368
+ "build-meta": C,
369
+ "build-model": T,
370
+ "list-overview-snapshots": E,
371
+ "mark-stable": D,
372
+ pack: O,
373
+ publish: A,
374
+ "refresh-registry": j,
375
+ "restore-overview-from-snapshot": M,
376
+ "upload-package-v1": I,
377
+ "update-deps": L
425
378
  };
426
- //# sourceMappingURL=cli.mjs.map
379
+ export { R as COMMANDS };
380
+
381
+ //# sourceMappingURL=cli.mjs.map