@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.js +3 -6
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +372 -417
- package/dist/cli.mjs.map +1 -1
- package/dist/config-CZZ2gdZH.mjs +1696 -0
- package/dist/config-CZZ2gdZH.mjs.map +1 -0
- package/dist/config-DXWEXkqY.js +3 -0
- package/dist/config-DXWEXkqY.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -299
- package/dist/index.mjs.map +1 -1
- package/dist/util.d.ts +1 -1
- package/dist/v2/model/block_components.d.ts +88 -88
- package/dist/v2/model/block_description.d.ts +1340 -1340
- package/dist/v2/model/block_meta.d.ts +226 -226
- package/package.json +8 -8
- package/src/util.ts +5 -2
- package/src/v2/model/content_conversion.ts +2 -2
- package/dist/config-Cc8_zV3b.mjs +0 -2050
- package/dist/config-Cc8_zV3b.mjs.map +0 -1
- package/dist/config-Ycas5fbX.js +0 -3
- package/dist/config-Ycas5fbX.js.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,426 +1,381 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import "
|
|
8
|
-
import "
|
|
9
|
-
import "
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
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
|
-
|
|
424
|
-
|
|
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
|
-
|
|
379
|
+
export { R as COMMANDS };
|
|
380
|
+
|
|
381
|
+
//# sourceMappingURL=cli.mjs.map
|