@platforma-sdk/block-tools 2.17.9 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +11 -11
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +442 -442
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-C07cYptA.mjs → config-BusBoNIz.mjs} +495 -586
- package/dist/config-BusBoNIz.mjs.map +1 -0
- package/dist/config-DG4SQFXv.js +2 -0
- package/dist/config-DG4SQFXv.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -15
- package/dist/index.mjs.map +1 -1
- package/dist/io/storage.d.ts +1 -28
- package/package.json +2 -3
- package/src/io/folder_reader.test.ts +18 -0
- package/src/io/folder_reader.ts +6 -0
- package/src/io/storage.ts +8 -147
- package/dist/config-C07cYptA.mjs.map +0 -1
- package/dist/config-on5N57rI.js +0 -3
- package/dist/config-on5N57rI.js.map +0 -1
- package/src/io/storage.test.ts +0 -96
package/dist/cli.mjs
CHANGED
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Command as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { BlockPackManifest as
|
|
6
|
-
import { assertDockerPushIntent as
|
|
7
|
-
import { ConsoleLoggerAdapter as
|
|
8
|
-
import
|
|
9
|
-
import { setTimeout as
|
|
10
|
-
import * as
|
|
11
|
-
import { confirm as
|
|
12
|
-
import { spawnSync as
|
|
13
|
-
import { ECRPUBLICClient as
|
|
1
|
+
import { $t as e, J as t, K as n, Lt as r, N as i, Pt as a, Qt as o, T as s, Tt as c, X as l, Z as u, bt as d, n as f, p as ee, v as te, vt as ne, wt as re } from "./config-BusBoNIz.mjs";
|
|
2
|
+
import { Command as p, Option as m } from "commander";
|
|
3
|
+
import h from "node:path";
|
|
4
|
+
import g, { globSync as ie, statSync as ae } from "node:fs";
|
|
5
|
+
import { BlockPackManifest as oe, StableChannel as se, overrideDescriptionVersion as ce, overrideManifestVersion as le } from "@milaboratories/pl-model-middle-layer";
|
|
6
|
+
import { assertDockerPushIntent as ue, createBuilder as de, defaults as fe, envs as _, util as v } from "@platforma-sdk/package-builder-lib";
|
|
7
|
+
import { ConsoleLoggerAdapter as y } from "@milaboratories/ts-helpers";
|
|
8
|
+
import pe, { isMap as me, isSeq as he, parse as ge, parseDocument as _e, stringify as ve } from "yaml";
|
|
9
|
+
import { setTimeout as ye } from "node:timers/promises";
|
|
10
|
+
import * as be from "node:os";
|
|
11
|
+
import { confirm as xe, input as Se, select as Ce } from "@inquirer/prompts";
|
|
12
|
+
import { spawnSync as we } from "node:child_process";
|
|
13
|
+
import { ECRPUBLICClient as Te, GetAuthorizationTokenCommand as Ee } from "@aws-sdk/client-ecr-public";
|
|
14
14
|
// src/cmd/build-meta.ts
|
|
15
|
-
function
|
|
16
|
-
let e = new
|
|
15
|
+
function De() {
|
|
16
|
+
let e = new p("build-meta").description("Extracts meta information from blocks package.json and outputs meta.json with embedded binary and textual information linked from the meta section.");
|
|
17
17
|
return e.option("-i, --modulePath <path>", "input module path", "."), e.requiredOption("-o, --destination <path>", "output meta.json file"), e.action(async (e) => {
|
|
18
|
-
let t =
|
|
19
|
-
await
|
|
18
|
+
let t = h.resolve(e.modulePath), n = await d(t), i = await a(await r(n.meta, t));
|
|
19
|
+
await g.promises.writeFile(h.resolve(e.destination), JSON.stringify(i));
|
|
20
20
|
}), e;
|
|
21
21
|
}
|
|
22
22
|
// src/cmd/build-model.ts
|
|
23
|
-
async function
|
|
23
|
+
async function Oe(e) {
|
|
24
24
|
try {
|
|
25
|
-
return await
|
|
25
|
+
return await g.promises.readFile(e, "utf8");
|
|
26
26
|
} catch (e) {
|
|
27
27
|
if (e instanceof Error && "code" in e && e.code === "ENOENT") return;
|
|
28
28
|
throw e;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
let e = new
|
|
31
|
+
function ke() {
|
|
32
|
+
let e = new p("build-model").description("Extracts and outputs block model JSON from pre-built block model module");
|
|
33
33
|
return e.option("-i, --modulePath <path>", "input module path", "."), e.option("-b, --sourceBundle <path>", "bundled model code to embed into the model for callback-based rendering to work", "./dist/bundle.js"), e.option("-o, --destination <path>", "output model file", "./dist/model.json"), e.action(async (e) => {
|
|
34
|
-
let t =
|
|
34
|
+
let t = h.resolve(e.modulePath), { model: n, platforma: r } = o(t);
|
|
35
35
|
if (n ||= r, !n) throw Error("\"model\" export not found");
|
|
36
36
|
let { config: i } = n;
|
|
37
37
|
if (!i) throw Error("Malformed \"model\" object, check it is created with \"BlockModel\" and \".done()\" is executed as the call in the chain.");
|
|
38
38
|
if (!("outputs" in i) || !("sections" in i)) throw Error("\"config\" has unexpected structure");
|
|
39
|
-
let a = await
|
|
39
|
+
let a = await Oe(e.sourceBundle);
|
|
40
40
|
a !== void 0 && (i.code = {
|
|
41
41
|
type: "plain",
|
|
42
42
|
content: a
|
|
43
|
-
}), await
|
|
43
|
+
}), await g.promises.writeFile(h.resolve(e.destination), JSON.stringify(i));
|
|
44
44
|
}), e;
|
|
45
45
|
}
|
|
46
46
|
// src/cmd/build-kind-manifest.ts
|
|
47
|
-
function
|
|
48
|
-
let
|
|
49
|
-
return
|
|
50
|
-
await
|
|
51
|
-
modulePath:
|
|
52
|
-
srcDir:
|
|
53
|
-
dst:
|
|
47
|
+
function Ae() {
|
|
48
|
+
let e = new p("build-kind-manifest").description("Writes the block-kind dist manifest (identity + src source-hash) from a pre-built kind bundle");
|
|
49
|
+
return e.option("-i, --modulePath <path>", "kind package dir (contains package.json, src/, dist/)", "."), e.option("-s, --srcDir <path>", "source dir hashed into sourceHash, relative to modulePath", "src"), e.option("-o, --dst <path>", "output dir with the compiled bundle, relative to modulePath", "dist"), e.action(async (e) => {
|
|
50
|
+
await re({
|
|
51
|
+
modulePath: e.modulePath,
|
|
52
|
+
srcDir: e.srcDir,
|
|
53
|
+
dst: e.dst
|
|
54
54
|
});
|
|
55
|
-
}),
|
|
55
|
+
}), e;
|
|
56
56
|
}
|
|
57
57
|
// src/cmd/pack.ts
|
|
58
|
-
function
|
|
59
|
-
let e = new
|
|
58
|
+
function je() {
|
|
59
|
+
let e = new p("pack").description("Builds block pack and outputs a block pack manifest consolidating all references assets into a single folder");
|
|
60
60
|
return e.option("-i, --modulePath <path>", "input module path", "."), e.option("-o, --destinationPath <path>", "output folder", "./block-pack"), e.action(async (e) => {
|
|
61
|
-
let t = await
|
|
62
|
-
await
|
|
61
|
+
let t = await ne(h.resolve(e.modulePath));
|
|
62
|
+
await c(t, h.resolve(e.destinationPath));
|
|
63
63
|
}), e;
|
|
64
64
|
}
|
|
65
65
|
// src/cmd/publish.ts
|
|
66
|
-
function
|
|
66
|
+
function Me(e, t) {
|
|
67
67
|
let n = { ...e };
|
|
68
|
-
for (let e in t) n[e] = t[e] && typeof t[e] == "object" && !Array.isArray(t[e]) && n[e] && typeof n[e] == "object" && !Array.isArray(n[e]) ?
|
|
68
|
+
for (let e in t) n[e] = t[e] && typeof t[e] == "object" && !Array.isArray(t[e]) && n[e] && typeof n[e] == "object" && !Array.isArray(n[e]) ? Me(n[e], t[e]) : t[e];
|
|
69
69
|
return n;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
let e = new
|
|
73
|
-
return e.addOption(new
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
let
|
|
79
|
-
await
|
|
80
|
-
let
|
|
71
|
+
function Ne() {
|
|
72
|
+
let e = new p("publish").description("Publishes the block package and refreshes the registry (for v2 block-pack schema)");
|
|
73
|
+
return e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new m("--registry-serve-url <url>", "CDN serve URL written into block-pack/published.json (npm-consumed blocks)").env("PL_REGISTRY_SERVE_URL").makeOptionMandatory()), e.option("-m, --manifest <path>", "manifest file path", `./block-pack/${i}`), e.option("-v, --version-override <path>", "override package version"), e.addOption(new m("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), e.option("--no-refresh", "do not refresh repository after adding the package"), e.addOption(new m("--unstable", "do not add the published package to stable channel").default(!1).env("PL_PUBLISH_UNSTABLE")), e.action(async (e) => {
|
|
74
|
+
let n = new y(), r = h.resolve(e.manifest), i = JSON.parse(await g.promises.readFile(r, { encoding: "utf-8" })), a = oe.parse(i);
|
|
75
|
+
a = Me(i, a);
|
|
76
|
+
let o = h.dirname(r), c = h.dirname(o);
|
|
77
|
+
n.info(`Manifest root = ${o}`), n.info(`Facade root = ${c}`), e.versionOverride && (a = le(a, e.versionOverride));
|
|
78
|
+
let d = te(e.registry), f = new s(d, n);
|
|
79
|
+
await u(f, a, c, async (e) => Buffer.from(await g.promises.readFile(h.resolve(o, e)))), e.unstable || (n.info(`Adding package to ${se} channel...`), await f.addPackageToChannel(a.description.id, se));
|
|
80
|
+
let ee = t({
|
|
81
81
|
registryUrl: e.registryServeUrl,
|
|
82
|
-
id:
|
|
82
|
+
id: a.description.id
|
|
83
83
|
});
|
|
84
|
-
await
|
|
84
|
+
await l(o, ee), n.info(`Wrote published coordinates to ${h.resolve(o, "published.json")}`), e.refresh && await f.updateIfNeeded();
|
|
85
85
|
}), e;
|
|
86
86
|
}
|
|
87
87
|
// src/cmd/refresh-registry.ts
|
|
88
|
-
function
|
|
89
|
-
let e = new
|
|
90
|
-
return e.addOption(new
|
|
88
|
+
function Pe() {
|
|
89
|
+
let e = new p("refresh-registry").description("Refresh overview files based on published but not proecessed artefacts");
|
|
90
|
+
return e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new m("-m, --mode <mode>", "refresh mode (allowed valiues: \"force\", \"normal\", \"dry-run\")").choices([
|
|
91
91
|
"force",
|
|
92
92
|
"normal",
|
|
93
93
|
"dry-run"
|
|
94
94
|
]).env("PL_REGISTRY_REFRESH_DRY_RUN").default("normal")), e.action(async (e) => {
|
|
95
|
-
let t =
|
|
96
|
-
await new
|
|
95
|
+
let t = te(e.registry);
|
|
96
|
+
await new s(t, new y()).updateIfNeeded(e.mode);
|
|
97
97
|
}), e;
|
|
98
98
|
}
|
|
99
99
|
// src/cmd/mark-stable.ts
|
|
100
|
-
function
|
|
101
|
-
let e = new
|
|
102
|
-
return e.option("-i, --modulePath <path>", "input module path", "."), e.addOption(new
|
|
103
|
-
let t = await
|
|
104
|
-
e.versionOverride && (t =
|
|
105
|
-
let n =
|
|
100
|
+
function Fe() {
|
|
101
|
+
let e = new p("mark-stable").description("Mark target block stable");
|
|
102
|
+
return e.option("-i, --modulePath <path>", "input module path", "."), e.addOption(new m("-c, --channel <channel name>", "custom channel").default(se).hideHelp()), e.option("-v, --version-override <path>", "override package version"), e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new m("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), e.option("--no-refresh", "do not refresh repository after adding the package"), e.option("--unmark", "reverses meaning of this command, flag can be used to remove \"stable\" flag from the package", !1), e.action(async (e) => {
|
|
103
|
+
let t = await d(h.resolve(e.modulePath));
|
|
104
|
+
e.versionOverride && (t = ce(t, e.versionOverride));
|
|
105
|
+
let n = te(e.registry), r = new s(n, new y());
|
|
106
106
|
e.unmark ? await r.removePackageFromChannel(t.id, e.channel) : await r.addPackageToChannel(t.id, e.channel), e.refresh && await r.updateIfNeeded();
|
|
107
107
|
}), e;
|
|
108
108
|
}
|
|
109
109
|
// src/structure/engine/fs/node.ts
|
|
110
|
-
var
|
|
110
|
+
var Ie = class {
|
|
111
111
|
root;
|
|
112
112
|
constructor(e) {
|
|
113
113
|
this.root = e;
|
|
114
114
|
}
|
|
115
115
|
abs(e) {
|
|
116
|
-
return
|
|
116
|
+
return h.resolve(this.root, e);
|
|
117
117
|
}
|
|
118
118
|
read(e) {
|
|
119
|
-
return
|
|
119
|
+
return g.readFileSync(this.abs(e), "utf-8");
|
|
120
120
|
}
|
|
121
121
|
write(e, t) {
|
|
122
122
|
let n = this.abs(e);
|
|
123
|
-
|
|
123
|
+
g.mkdirSync(h.dirname(n), { recursive: !0 }), g.writeFileSync(n, t, "utf-8");
|
|
124
124
|
}
|
|
125
125
|
writeBinary(e, t) {
|
|
126
126
|
let n = this.abs(e);
|
|
127
|
-
|
|
127
|
+
g.mkdirSync(h.dirname(n), { recursive: !0 }), g.writeFileSync(n, t);
|
|
128
128
|
}
|
|
129
129
|
exists(e) {
|
|
130
130
|
try {
|
|
131
|
-
return
|
|
131
|
+
return g.statSync(this.abs(e)), !0;
|
|
132
132
|
} catch {
|
|
133
133
|
return !1;
|
|
134
134
|
}
|
|
@@ -136,15 +136,15 @@ var Fe = class {
|
|
|
136
136
|
list(e) {
|
|
137
137
|
let t = this.abs(e);
|
|
138
138
|
try {
|
|
139
|
-
if (!
|
|
139
|
+
if (!g.statSync(t).isDirectory()) return [];
|
|
140
140
|
} catch {
|
|
141
141
|
return [];
|
|
142
142
|
}
|
|
143
143
|
let n = [];
|
|
144
144
|
function r(e, t) {
|
|
145
|
-
let i =
|
|
145
|
+
let i = g.readdirSync(t, { withFileTypes: !0 });
|
|
146
146
|
for (let a of i) {
|
|
147
|
-
let i = e ? `${e}/${a.name}` : a.name, o =
|
|
147
|
+
let i = e ? `${e}/${a.name}` : a.name, o = h.join(t, a.name);
|
|
148
148
|
a.isDirectory() ? r(i, o) : a.isFile() && n.push(i);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -153,7 +153,7 @@ var Fe = class {
|
|
|
153
153
|
listDir(e) {
|
|
154
154
|
let t = this.abs(e), n;
|
|
155
155
|
try {
|
|
156
|
-
n =
|
|
156
|
+
n = g.readdirSync(t, { withFileTypes: !0 });
|
|
157
157
|
} catch {
|
|
158
158
|
return [];
|
|
159
159
|
}
|
|
@@ -164,77 +164,77 @@ var Fe = class {
|
|
|
164
164
|
}
|
|
165
165
|
move(e, t) {
|
|
166
166
|
let n = this.abs(e), r = this.abs(t);
|
|
167
|
-
|
|
167
|
+
g.mkdirSync(h.dirname(r), { recursive: !0 }), g.renameSync(n, r);
|
|
168
168
|
}
|
|
169
169
|
delete(e) {
|
|
170
|
-
|
|
170
|
+
g.rmSync(this.abs(e), {
|
|
171
171
|
recursive: !0,
|
|
172
172
|
force: !0
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
-
},
|
|
175
|
+
}, Le = class {
|
|
176
176
|
root;
|
|
177
177
|
constructor(e) {
|
|
178
178
|
this.root = e;
|
|
179
179
|
}
|
|
180
180
|
staticRead(e) {
|
|
181
|
-
return
|
|
181
|
+
return g.readFileSync(h.resolve(this.root, "static", e), "utf-8");
|
|
182
182
|
}
|
|
183
183
|
staticReadBinary(e) {
|
|
184
|
-
return
|
|
184
|
+
return g.readFileSync(h.resolve(this.root, "static", e));
|
|
185
185
|
}
|
|
186
186
|
textRead(e) {
|
|
187
|
-
return
|
|
187
|
+
return g.readFileSync(h.resolve(this.root, "text", e), "utf-8");
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
|
-
function
|
|
190
|
+
function Re(e, t) {
|
|
191
191
|
return e.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (e, n) => t[n] ?? `\${${n}}`);
|
|
192
192
|
}
|
|
193
193
|
// src/structure/engine/flatten.ts
|
|
194
|
-
var
|
|
195
|
-
function
|
|
194
|
+
var ze = ["default", "init"];
|
|
195
|
+
function Be(e, t) {
|
|
196
196
|
if (!e) return t;
|
|
197
197
|
if (!t) return e;
|
|
198
198
|
let n = e.endsWith("/") ? e.slice(0, -1) : e, r = t.startsWith("/") ? t.slice(1) : t;
|
|
199
199
|
return r ? `${n}/${r}` : n;
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function Ve(e, t) {
|
|
202
202
|
return e.filter((e) => e.scope === t).slice().sort((e, t) => e.path.localeCompare(t.path));
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function He(e, t) {
|
|
205
205
|
let n = [];
|
|
206
206
|
function r(e, i, a, o, s) {
|
|
207
207
|
if (e.kind === "scope") {
|
|
208
|
-
let n =
|
|
208
|
+
let n = Ve(t.modules, e.scope);
|
|
209
209
|
for (let t of n) for (let n of e.children) r(n, e.scope, t.path, o, s);
|
|
210
210
|
} else if (e.kind === "when") {
|
|
211
211
|
let t = o.concat(e.trigger);
|
|
212
212
|
for (let n of e.children) r(n, i, a, t, s);
|
|
213
213
|
} else if (e.kind === "mode") for (let t of e.children) r(t, i, a, o, e.modes);
|
|
214
214
|
else {
|
|
215
|
-
if (i === void 0 || a === void 0) throw Error(`flatten: leaf '${
|
|
215
|
+
if (i === void 0 || a === void 0) throw Error(`flatten: leaf '${We(e)}' is not inside a scope() frame`);
|
|
216
216
|
e.kind === "rename" ? n.push({
|
|
217
217
|
leaf: e,
|
|
218
218
|
scope: i,
|
|
219
219
|
modulePath: a,
|
|
220
|
-
resolvedPath:
|
|
221
|
-
resolvedTo:
|
|
220
|
+
resolvedPath: Be(a, e.from),
|
|
221
|
+
resolvedTo: Be(a, e.to),
|
|
222
222
|
triggers: o,
|
|
223
223
|
modes: s
|
|
224
224
|
}) : n.push({
|
|
225
225
|
leaf: e,
|
|
226
226
|
scope: i,
|
|
227
227
|
modulePath: a,
|
|
228
|
-
resolvedPath:
|
|
228
|
+
resolvedPath: Be(a, Ue(e)),
|
|
229
229
|
triggers: o,
|
|
230
230
|
modes: s
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
for (let t of e.children) r(t, void 0, void 0, [],
|
|
234
|
+
for (let t of e.children) r(t, void 0, void 0, [], ze);
|
|
235
235
|
return n;
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function Ue(e) {
|
|
238
238
|
switch (e.kind) {
|
|
239
239
|
case "fixed":
|
|
240
240
|
case "managed":
|
|
@@ -244,61 +244,61 @@ function He(e) {
|
|
|
244
244
|
case "rename": return e.from;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function We(e) {
|
|
248
248
|
return e.kind === "rename" ? `rename ${e.from} -> ${e.to}` : `${e.kind} ${e.path}`;
|
|
249
249
|
}
|
|
250
250
|
// src/structure/engine/glob.ts
|
|
251
|
-
var
|
|
252
|
-
function
|
|
251
|
+
var Ge = /[.+^${}()|[\]\\]/g;
|
|
252
|
+
function Ke(e) {
|
|
253
253
|
let t = "";
|
|
254
254
|
for (let n = 0; n < e.length; n++) {
|
|
255
255
|
let r = e[n];
|
|
256
|
-
r === "*" ? e[n + 1] === "*" ? (n++, e[n + 1] === "/" ? (n++, t += "(?:.*/)?") : t += ".*") : t += "[^/]*" : t += r === "?" ? "[^/]" : r.replace(
|
|
256
|
+
r === "*" ? e[n + 1] === "*" ? (n++, e[n + 1] === "/" ? (n++, t += "(?:.*/)?") : t += ".*") : t += "[^/]*" : t += r === "?" ? "[^/]" : r.replace(Ge, "\\$&");
|
|
257
257
|
}
|
|
258
258
|
return RegExp(`^${t}$`);
|
|
259
259
|
}
|
|
260
|
-
function
|
|
261
|
-
return
|
|
260
|
+
function qe(e, t) {
|
|
261
|
+
return Ke(e).test(t);
|
|
262
262
|
}
|
|
263
263
|
// src/structure/engine/builders.ts
|
|
264
|
-
var
|
|
265
|
-
function
|
|
266
|
-
if (!
|
|
267
|
-
return
|
|
264
|
+
var b, Je;
|
|
265
|
+
function Ye(e) {
|
|
266
|
+
if (!b) throw Error(`${e}() called outside defineStructure(). Builders must run inside the lambda passed to defineStructure(...).`);
|
|
267
|
+
return b;
|
|
268
268
|
}
|
|
269
|
-
function
|
|
270
|
-
let n =
|
|
269
|
+
function Xe(e, t) {
|
|
270
|
+
let n = Ye(e);
|
|
271
271
|
n.stack[n.stack.length - 1].push(t);
|
|
272
272
|
}
|
|
273
|
-
function
|
|
274
|
-
let n =
|
|
275
|
-
|
|
273
|
+
function Ze(e, t) {
|
|
274
|
+
let n = Je;
|
|
275
|
+
Je = e;
|
|
276
276
|
try {
|
|
277
277
|
return t();
|
|
278
278
|
} finally {
|
|
279
|
-
|
|
279
|
+
Je = n;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
return
|
|
282
|
+
function Qe() {
|
|
283
|
+
return Je;
|
|
284
284
|
}
|
|
285
|
-
function
|
|
286
|
-
if (
|
|
285
|
+
function $e(e) {
|
|
286
|
+
if (b) throw Error("defineStructure() cannot be called from inside another defineStructure().");
|
|
287
287
|
let t = [], n = {
|
|
288
288
|
root: t,
|
|
289
289
|
stack: [t],
|
|
290
290
|
inScope: !1
|
|
291
291
|
};
|
|
292
|
-
|
|
292
|
+
b = n;
|
|
293
293
|
try {
|
|
294
294
|
if (e(), n.stack.length !== 1) throw Error(`defineStructure: builder body left ${n.stack.length - 1} unclosed group frame(s)`);
|
|
295
295
|
let r = { children: t };
|
|
296
|
-
return
|
|
296
|
+
return et(r), r;
|
|
297
297
|
} finally {
|
|
298
|
-
|
|
298
|
+
b = void 0;
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
function
|
|
301
|
+
function et(e) {
|
|
302
302
|
let t = /* @__PURE__ */ new Map();
|
|
303
303
|
function n(e, r) {
|
|
304
304
|
if (e.kind === "scope") {
|
|
@@ -321,8 +321,8 @@ function $e(e) {
|
|
|
321
321
|
throw Error(`defineStructure validation: path '${t}' under scope '${e}' is declared as both seed and ${n}. Seeds are block-author territory (written once at init, untouched thereafter); engine-managed primitives (fixed/managed/scaffold) rewrite on every refresh. The two contracts cannot coexist on the same path.`);
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
-
function
|
|
325
|
-
let n =
|
|
324
|
+
function x(e, t) {
|
|
325
|
+
let n = Ye("scope");
|
|
326
326
|
if (n.inScope) throw Error("scope() cannot nest. Already inside a scope.");
|
|
327
327
|
let r = {
|
|
328
328
|
kind: "scope",
|
|
@@ -336,19 +336,19 @@ function S(e, t) {
|
|
|
336
336
|
n.stack.pop(), n.inScope = !1;
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
var
|
|
340
|
-
function
|
|
341
|
-
|
|
339
|
+
var tt;
|
|
340
|
+
function nt(e) {
|
|
341
|
+
tt = e;
|
|
342
342
|
}
|
|
343
|
-
function
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
function nt(e, t) {
|
|
347
|
-
if (x) rt(e, t);
|
|
348
|
-
else if (!(et?.(e, t) ?? !1)) throw Error("when() called outside defineStructure() and outside any managed(...) body. Place this call inside one of the two.");
|
|
343
|
+
function S(e, t, n) {
|
|
344
|
+
rt(e, t), n && rt((t) => !e(t), n);
|
|
349
345
|
}
|
|
350
346
|
function rt(e, t) {
|
|
351
|
-
|
|
347
|
+
if (b) it(e, t);
|
|
348
|
+
else if (!(tt?.(e, t) ?? !1)) throw Error("when() called outside defineStructure() and outside any managed(...) body. Place this call inside one of the two.");
|
|
349
|
+
}
|
|
350
|
+
function it(e, t) {
|
|
351
|
+
let n = b, r = {
|
|
352
352
|
kind: "when",
|
|
353
353
|
trigger: e,
|
|
354
354
|
children: []
|
|
@@ -360,11 +360,11 @@ function rt(e, t) {
|
|
|
360
360
|
n.stack.pop();
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function C(e) {
|
|
364
364
|
return (t) => t.filesMatch(e);
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
let r =
|
|
366
|
+
function at(e, t, n) {
|
|
367
|
+
let r = Ye(e), i = {
|
|
368
368
|
kind: "mode",
|
|
369
369
|
modes: t,
|
|
370
370
|
children: []
|
|
@@ -376,140 +376,140 @@ function it(e, t, n) {
|
|
|
376
376
|
r.stack.pop();
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
function
|
|
380
|
-
|
|
379
|
+
function ot(e) {
|
|
380
|
+
at("onInitOrUpdate", ["init", "updateDeps"], e);
|
|
381
381
|
}
|
|
382
|
-
function
|
|
383
|
-
|
|
382
|
+
function w(e, t) {
|
|
383
|
+
Xe("fixed", {
|
|
384
384
|
kind: "fixed",
|
|
385
385
|
path: e,
|
|
386
386
|
content: t
|
|
387
387
|
});
|
|
388
388
|
}
|
|
389
|
-
function
|
|
390
|
-
|
|
389
|
+
function T(e, t, n) {
|
|
390
|
+
Xe("managed", {
|
|
391
391
|
kind: "managed",
|
|
392
392
|
path: e,
|
|
393
393
|
initial: t,
|
|
394
394
|
body: n
|
|
395
395
|
});
|
|
396
396
|
}
|
|
397
|
-
function
|
|
398
|
-
|
|
397
|
+
function E(e, t) {
|
|
398
|
+
Xe("scaffold", {
|
|
399
399
|
kind: "scaffold",
|
|
400
400
|
path: e,
|
|
401
401
|
initial: t
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
|
-
function
|
|
405
|
-
|
|
404
|
+
function D(e, t) {
|
|
405
|
+
Xe("seed", {
|
|
406
406
|
kind: "seed",
|
|
407
407
|
path: e,
|
|
408
408
|
initial: t
|
|
409
409
|
});
|
|
410
410
|
}
|
|
411
|
-
function
|
|
412
|
-
|
|
411
|
+
function O(e) {
|
|
412
|
+
Xe("remove", {
|
|
413
413
|
kind: "remove",
|
|
414
414
|
path: e
|
|
415
415
|
});
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function k(e) {
|
|
418
418
|
return {
|
|
419
419
|
kind: "file",
|
|
420
420
|
path: e
|
|
421
421
|
};
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function st(e) {
|
|
424
424
|
return {
|
|
425
425
|
kind: "binary",
|
|
426
426
|
path: e
|
|
427
427
|
};
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function ct(e) {
|
|
430
430
|
return {
|
|
431
431
|
kind: "text",
|
|
432
432
|
value: e
|
|
433
433
|
};
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function A(e, t) {
|
|
436
436
|
return {
|
|
437
437
|
kind: "tpl",
|
|
438
438
|
path: e,
|
|
439
439
|
vars: t
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
|
-
function
|
|
442
|
+
function j(e) {
|
|
443
443
|
return {
|
|
444
444
|
kind: "generate",
|
|
445
445
|
fn: e
|
|
446
446
|
};
|
|
447
447
|
}
|
|
448
448
|
// src/structure/engine/parsers/json.ts
|
|
449
|
-
var
|
|
450
|
-
function
|
|
449
|
+
var lt = /* @__PURE__ */ e(n());
|
|
450
|
+
function ut(e) {
|
|
451
451
|
return JSON.parse(e);
|
|
452
452
|
}
|
|
453
|
-
var
|
|
454
|
-
function ft(e) {
|
|
455
|
-
return e.length === 0 ? "[]" : "[" + e.map(pt).join(", ") + "]";
|
|
456
|
-
}
|
|
453
|
+
var dt = 100, ft = 2;
|
|
457
454
|
function pt(e) {
|
|
458
|
-
|
|
459
|
-
|
|
455
|
+
return e.length === 0 ? "[]" : "[" + e.map(mt).join(", ") + "]";
|
|
456
|
+
}
|
|
457
|
+
function mt(e) {
|
|
458
|
+
if (Array.isArray(e)) return pt(e);
|
|
459
|
+
if (M(e)) {
|
|
460
460
|
let t = Object.entries(e);
|
|
461
|
-
return t.length === 0 ? "{}" : "{ " + t.map(([e, t]) => `${JSON.stringify(e)}: ${
|
|
461
|
+
return t.length === 0 ? "{}" : "{ " + t.map(([e, t]) => `${JSON.stringify(e)}: ${mt(t)}`).join(", ") + " }";
|
|
462
462
|
}
|
|
463
463
|
return JSON.stringify(e);
|
|
464
464
|
}
|
|
465
|
-
function
|
|
466
|
-
let i = t +
|
|
465
|
+
function ht(e, t, n, r) {
|
|
466
|
+
let i = t + ft, a = " ".repeat(i);
|
|
467
467
|
if (Array.isArray(e)) {
|
|
468
|
-
let o =
|
|
469
|
-
if (n + o.length + r <=
|
|
468
|
+
let o = pt(e);
|
|
469
|
+
if (n + o.length + r <= dt) return o;
|
|
470
470
|
let s = e.length - 1;
|
|
471
|
-
return "[\n" + e.map((e, t) => a +
|
|
471
|
+
return "[\n" + e.map((e, t) => a + ht(e, i, i, t === s ? 0 : 1)).join(",\n") + "\n" + " ".repeat(t) + "]";
|
|
472
472
|
}
|
|
473
|
-
if (
|
|
473
|
+
if (M(e)) {
|
|
474
474
|
let n = Object.entries(e);
|
|
475
475
|
if (n.length === 0) return "{}";
|
|
476
476
|
let r = n.length - 1;
|
|
477
477
|
return "{\n" + n.map(([e, t], n) => {
|
|
478
478
|
let o = `${a}${JSON.stringify(e)}: `;
|
|
479
|
-
return o +
|
|
479
|
+
return o + ht(t, i, o.length, n === r ? 0 : 1);
|
|
480
480
|
}).join(",\n") + "\n" + " ".repeat(t) + "}";
|
|
481
481
|
}
|
|
482
482
|
return JSON.stringify(e);
|
|
483
483
|
}
|
|
484
|
-
function
|
|
485
|
-
return t?.collapse ?
|
|
484
|
+
function gt(e, t) {
|
|
485
|
+
return t?.collapse ? ht(JSON.parse(JSON.stringify(e ?? null)), 0, 0, 0) + "\n" : JSON.stringify(e, null, 2) + "\n";
|
|
486
486
|
}
|
|
487
|
-
function
|
|
487
|
+
function _t(e) {
|
|
488
488
|
return e === "" || e === void 0 ? [] : e.split(".");
|
|
489
489
|
}
|
|
490
|
-
function
|
|
490
|
+
function M(e) {
|
|
491
491
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
492
492
|
}
|
|
493
|
-
function
|
|
494
|
-
let n =
|
|
493
|
+
function vt(e, t) {
|
|
494
|
+
let n = _t(t), r = e;
|
|
495
495
|
for (let e of n) {
|
|
496
|
-
if (!
|
|
496
|
+
if (!M(r)) return;
|
|
497
497
|
r = r[e];
|
|
498
498
|
}
|
|
499
499
|
return r;
|
|
500
500
|
}
|
|
501
|
-
function
|
|
502
|
-
let n =
|
|
501
|
+
function yt(e, t) {
|
|
502
|
+
let n = _t(t);
|
|
503
503
|
if (n.length === 0) return !0;
|
|
504
504
|
let r = e;
|
|
505
505
|
for (let e = 0; e < n.length - 1; e++) {
|
|
506
|
-
if (!
|
|
506
|
+
if (!M(r)) return !1;
|
|
507
507
|
r = r[n[e]];
|
|
508
508
|
}
|
|
509
|
-
return
|
|
509
|
+
return M(r) ? n[n.length - 1] in r : !1;
|
|
510
510
|
}
|
|
511
|
-
function
|
|
512
|
-
let r =
|
|
511
|
+
function bt(e, t, n) {
|
|
512
|
+
let r = _t(t);
|
|
513
513
|
if (r.length === 0) throw Error("setAtPath: jsonPath must be non-empty");
|
|
514
514
|
let i = e;
|
|
515
515
|
for (let e = 0; e < r.length - 1; e++) {
|
|
@@ -517,22 +517,22 @@ function yt(e, t, n) {
|
|
|
517
517
|
if (n === void 0) {
|
|
518
518
|
let e = {};
|
|
519
519
|
i[t] = e, i = e;
|
|
520
|
-
} else if (
|
|
520
|
+
} else if (M(n)) i = n;
|
|
521
521
|
else throw Error(`setAtPath: cannot descend into non-object at '${r.slice(0, e + 1).join(".")}'`);
|
|
522
522
|
}
|
|
523
523
|
i[r[r.length - 1]] = n;
|
|
524
524
|
}
|
|
525
|
-
function
|
|
526
|
-
let n =
|
|
525
|
+
function xt(e, t) {
|
|
526
|
+
let n = _t(t);
|
|
527
527
|
if (n.length === 0) throw Error("deleteAtPath: jsonPath must be non-empty");
|
|
528
528
|
let r = e;
|
|
529
529
|
for (let e = 0; e < n.length - 1; e++) {
|
|
530
|
-
if (!
|
|
530
|
+
if (!M(r)) return;
|
|
531
531
|
r = r[n[e]];
|
|
532
532
|
}
|
|
533
|
-
|
|
533
|
+
M(r) && delete r[n[n.length - 1]];
|
|
534
534
|
}
|
|
535
|
-
function
|
|
535
|
+
function St(e, t) {
|
|
536
536
|
let n = new Set(t), r = Object.keys(e), i = /* @__PURE__ */ new Map();
|
|
537
537
|
i.set("", []);
|
|
538
538
|
let a = "";
|
|
@@ -546,71 +546,71 @@ function xt(e, t) {
|
|
|
546
546
|
return o;
|
|
547
547
|
}
|
|
548
548
|
// src/structure/engine/parsers/lines.ts
|
|
549
|
-
function
|
|
549
|
+
function Ct(e) {
|
|
550
550
|
let t = e.split("\n");
|
|
551
551
|
return t.length > 0 && t[t.length - 1] === "" && t.pop(), t;
|
|
552
552
|
}
|
|
553
|
-
function
|
|
553
|
+
function wt(e) {
|
|
554
554
|
return e.join("\n") + "\n";
|
|
555
555
|
}
|
|
556
|
-
function
|
|
556
|
+
function Tt(e) {
|
|
557
557
|
return e.replace(/(^|\s)#.*$/, "$1").trim();
|
|
558
558
|
}
|
|
559
|
-
function
|
|
560
|
-
let n =
|
|
559
|
+
function Et(e, t) {
|
|
560
|
+
let n = Tt(e);
|
|
561
561
|
return n !== "" && n === t.trim();
|
|
562
562
|
}
|
|
563
|
-
function
|
|
564
|
-
for (let n of e) if (
|
|
563
|
+
function Dt(e, t) {
|
|
564
|
+
for (let n of e) if (Et(n, t)) return !0;
|
|
565
565
|
return !1;
|
|
566
566
|
}
|
|
567
567
|
// src/structure/engine/content-rules.ts
|
|
568
|
-
function
|
|
568
|
+
function Ot(e, t) {
|
|
569
569
|
return e === "sdk:" ? t ? "workspace:*" : "catalog:" : e;
|
|
570
570
|
}
|
|
571
|
-
var
|
|
571
|
+
var kt = [
|
|
572
572
|
"dependencies",
|
|
573
573
|
"devDependencies",
|
|
574
574
|
"peerDependencies",
|
|
575
575
|
"optionalDependencies"
|
|
576
576
|
];
|
|
577
|
-
function
|
|
578
|
-
if (
|
|
577
|
+
function At(e, t) {
|
|
578
|
+
if (I(e)) for (let n of kt) {
|
|
579
579
|
let r = e[n];
|
|
580
|
-
if (
|
|
580
|
+
if (I(r)) for (let e of Object.keys(r)) r[e] === "sdk:" && (r[e] = t ? "workspace:*" : "catalog:");
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
|
-
var
|
|
584
|
-
function
|
|
585
|
-
if (!
|
|
586
|
-
return
|
|
583
|
+
var N;
|
|
584
|
+
function jt(e) {
|
|
585
|
+
if (!N) throw Error(`${e}() only valid inside a managed(...) body. Move this call inside managed(path, initial, () => {...}).`);
|
|
586
|
+
return N;
|
|
587
587
|
}
|
|
588
|
-
function
|
|
589
|
-
let t =
|
|
588
|
+
function P(e) {
|
|
589
|
+
let t = jt(e);
|
|
590
590
|
if (t.kind !== "json") throw Error(`${e}() requires a JSON-managed body; got '${t.kind}'.`);
|
|
591
591
|
return t;
|
|
592
592
|
}
|
|
593
|
-
function
|
|
594
|
-
let t =
|
|
593
|
+
function F(e) {
|
|
594
|
+
let t = jt(e);
|
|
595
595
|
if (t.kind !== "yaml") throw Error(`${e}() requires a YAML-managed body; got '${t.kind}'.`);
|
|
596
596
|
return t;
|
|
597
597
|
}
|
|
598
|
-
function
|
|
599
|
-
let t =
|
|
598
|
+
function Mt(e) {
|
|
599
|
+
let t = jt(e);
|
|
600
600
|
if (t.kind !== "lines") throw Error(`${e}() requires a lines-managed body; got '${t.kind}'.`);
|
|
601
601
|
return t;
|
|
602
602
|
}
|
|
603
|
-
function
|
|
604
|
-
let n = e.ctx ??
|
|
603
|
+
function Nt(e, t) {
|
|
604
|
+
let n = e.ctx ?? Qe();
|
|
605
605
|
if (!n) throw Error(`${t}() needs a RunContext but none is active. Pass { ctx } via the with-managed-* helper or run inside engine.run(...).`);
|
|
606
606
|
return n;
|
|
607
607
|
}
|
|
608
|
-
function
|
|
608
|
+
function I(e) {
|
|
609
609
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
610
610
|
}
|
|
611
|
-
function
|
|
612
|
-
if (
|
|
613
|
-
|
|
611
|
+
function Pt(e, t, n = {}) {
|
|
612
|
+
if (N) throw Error("Nested managed(...) body — engine bug.");
|
|
613
|
+
N = {
|
|
614
614
|
kind: "json",
|
|
615
615
|
obj: e,
|
|
616
616
|
ctx: n.ctx,
|
|
@@ -619,12 +619,12 @@ function Nt(e, t, n = {}) {
|
|
|
619
619
|
try {
|
|
620
620
|
return t(n.ctx ?? n.triggerContext?.ctx), e;
|
|
621
621
|
} finally {
|
|
622
|
-
|
|
622
|
+
N = void 0;
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
|
-
function
|
|
626
|
-
if (
|
|
627
|
-
|
|
625
|
+
function Ft(e, t, n = {}) {
|
|
626
|
+
if (N) throw Error("Nested managed(...) body — engine bug.");
|
|
627
|
+
N = {
|
|
628
628
|
kind: "yaml",
|
|
629
629
|
doc: e,
|
|
630
630
|
ctx: n.ctx,
|
|
@@ -635,12 +635,12 @@ function Pt(e, t, n = {}) {
|
|
|
635
635
|
try {
|
|
636
636
|
return t(n.ctx ?? n.triggerContext?.ctx), e;
|
|
637
637
|
} finally {
|
|
638
|
-
|
|
638
|
+
N = void 0;
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
|
-
function
|
|
642
|
-
if (
|
|
643
|
-
|
|
641
|
+
function It(e, t, n = {}) {
|
|
642
|
+
if (N) throw Error("Nested managed(...) body — engine bug.");
|
|
643
|
+
N = {
|
|
644
644
|
kind: "lines",
|
|
645
645
|
lines: e,
|
|
646
646
|
ctx: n.ctx,
|
|
@@ -649,81 +649,81 @@ function Ft(e, t, n = {}) {
|
|
|
649
649
|
try {
|
|
650
650
|
return t(n.ctx ?? n.triggerContext?.ctx), e;
|
|
651
651
|
} finally {
|
|
652
|
-
|
|
652
|
+
N = void 0;
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
|
-
|
|
656
|
-
if (!
|
|
657
|
-
let n =
|
|
655
|
+
nt((e, t) => {
|
|
656
|
+
if (!N) return !1;
|
|
657
|
+
let n = N.triggerContext;
|
|
658
658
|
if (!n) throw Error("when() inside a managed(...) body requires a triggerContext. The runner supplies it via the `triggerContext` opt to with-managed-*; ensure your test/test helper passes one.");
|
|
659
659
|
return e(n) && t(), !0;
|
|
660
660
|
});
|
|
661
|
-
function
|
|
662
|
-
|
|
663
|
-
}
|
|
664
|
-
function z(e, t) {
|
|
665
|
-
let n = F("removeField").obj;
|
|
666
|
-
vt(n, e) && (!t || t(_t(n, e))) && bt(n, e);
|
|
661
|
+
function L(e, t) {
|
|
662
|
+
bt(P("ensureField").obj, e, t);
|
|
667
663
|
}
|
|
668
|
-
function
|
|
669
|
-
let n =
|
|
670
|
-
|
|
664
|
+
function R(e, t) {
|
|
665
|
+
let n = P("removeField").obj;
|
|
666
|
+
yt(n, e) && (!t || t(vt(n, e))) && xt(n, e);
|
|
671
667
|
}
|
|
672
668
|
function Lt(e, t) {
|
|
673
|
-
|
|
669
|
+
let n = P("requireField").obj;
|
|
670
|
+
if (!yt(n, e)) throw Error(t ?? `requireField: missing field '${e}'`);
|
|
674
671
|
}
|
|
675
672
|
function Rt(e, t) {
|
|
676
|
-
|
|
673
|
+
if (yt(P("forbidField").obj, e)) throw Error(t);
|
|
674
|
+
}
|
|
675
|
+
function zt(e, t) {
|
|
676
|
+
let n = P("ensureFieldEntries").obj, r = yt(n, e) ? vt(n, e) : void 0, i = I(r) ? r : {};
|
|
677
677
|
for (let [e, n] of Object.entries(t)) i[e] = n;
|
|
678
|
-
|
|
678
|
+
I(r) || bt(n, e, i);
|
|
679
679
|
}
|
|
680
|
-
function
|
|
681
|
-
|
|
680
|
+
function z(e, t) {
|
|
681
|
+
L(`scripts.${e}`, t);
|
|
682
682
|
}
|
|
683
|
-
function
|
|
684
|
-
|
|
683
|
+
function B(e) {
|
|
684
|
+
R(`scripts.${e}`);
|
|
685
685
|
}
|
|
686
|
-
var
|
|
686
|
+
var Bt = [
|
|
687
687
|
"dependencies",
|
|
688
688
|
"devDependencies",
|
|
689
689
|
"peerDependencies",
|
|
690
690
|
"optionalDependencies"
|
|
691
691
|
];
|
|
692
|
-
function
|
|
693
|
-
let i =
|
|
694
|
-
for (let e of
|
|
692
|
+
function Vt(e, t, n, r) {
|
|
693
|
+
let i = P(e), a = i.obj, o = n === "sdk:" ? Ot(n, Nt(i, e).isSdkInternal) : n;
|
|
694
|
+
for (let e of Bt) {
|
|
695
695
|
if (e === r) continue;
|
|
696
696
|
let n = a[e];
|
|
697
|
-
|
|
697
|
+
I(n) && t in n && delete n[t];
|
|
698
698
|
}
|
|
699
|
-
let s = a[r], c =
|
|
700
|
-
c[t] = o,
|
|
699
|
+
let s = a[r], c = I(s) ? s : {};
|
|
700
|
+
c[t] = o, I(s) || (a[r] = c);
|
|
701
701
|
}
|
|
702
|
-
function
|
|
703
|
-
|
|
702
|
+
function Ht(e, t) {
|
|
703
|
+
Vt("ensureDep", e, t, "dependencies");
|
|
704
704
|
}
|
|
705
|
-
function
|
|
706
|
-
|
|
705
|
+
function V(e, t) {
|
|
706
|
+
Vt("ensureDevDep", e, t, "devDependencies");
|
|
707
707
|
}
|
|
708
|
-
function
|
|
709
|
-
|
|
708
|
+
function Ut(e, t) {
|
|
709
|
+
Vt("ensurePeerDep", e, t, "peerDependencies");
|
|
710
710
|
}
|
|
711
|
-
function
|
|
712
|
-
let t =
|
|
713
|
-
for (let n of
|
|
711
|
+
function H(e) {
|
|
712
|
+
let t = P("removeDep").obj;
|
|
713
|
+
for (let n of Bt) {
|
|
714
714
|
let r = t[n];
|
|
715
|
-
|
|
715
|
+
I(r) && e in r && delete r[e];
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
-
function
|
|
719
|
-
for (let [t, n] of Object.entries(e))
|
|
718
|
+
function U(e) {
|
|
719
|
+
for (let [t, n] of Object.entries(e)) V(t, n);
|
|
720
720
|
}
|
|
721
|
-
function
|
|
722
|
-
for (let [t, n] of Object.entries(e))
|
|
721
|
+
function W(e) {
|
|
722
|
+
for (let [t, n] of Object.entries(e)) Ut(t, n);
|
|
723
723
|
}
|
|
724
724
|
function Wt(e, t, n) {
|
|
725
|
-
let r =
|
|
726
|
-
for (let i of r.modules) i.scope === t &&
|
|
725
|
+
let r = Nt(P(e), e);
|
|
726
|
+
for (let i of r.modules) i.scope === t && Vt(e, i.name, "workspace:*", n);
|
|
727
727
|
}
|
|
728
728
|
function Gt(e) {
|
|
729
729
|
Wt("ensureWorkspaceScopeDeps", e, "dependencies");
|
|
@@ -732,40 +732,40 @@ function Kt(e) {
|
|
|
732
732
|
Wt("ensureWorkspaceScopeDevDeps", e, "devDependencies");
|
|
733
733
|
}
|
|
734
734
|
function qt(e) {
|
|
735
|
-
let t =
|
|
735
|
+
let t = P("pruneKeysMatching").obj;
|
|
736
736
|
for (let n of Object.keys(t)) e(n, t[n]) && delete t[n];
|
|
737
737
|
}
|
|
738
738
|
function Jt(e, t) {
|
|
739
|
-
let n =
|
|
739
|
+
let n = St(e, t);
|
|
740
740
|
for (let t of Object.keys(e)) delete e[t];
|
|
741
741
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
742
742
|
}
|
|
743
743
|
function G(e) {
|
|
744
|
-
Jt(
|
|
744
|
+
Jt(P("enforceFieldOrder").obj, e);
|
|
745
745
|
}
|
|
746
746
|
function Yt(e, t) {
|
|
747
747
|
let n = Object.keys(e).sort(), r = {};
|
|
748
748
|
for (let t of n) r[t] = e[t];
|
|
749
749
|
for (let t of Object.keys(e)) delete e[t];
|
|
750
|
-
for (let i of n) e[i] = r[i], t &&
|
|
750
|
+
for (let i of n) e[i] = r[i], t && I(e[i]) && Yt(e[i], !0);
|
|
751
751
|
}
|
|
752
752
|
function K(e = "", t = {}) {
|
|
753
753
|
let n = t.recursive ?? !1;
|
|
754
754
|
if (e === "" && !n) return;
|
|
755
|
-
let r =
|
|
755
|
+
let r = P("enforceAlphabeticalOrder").obj;
|
|
756
756
|
if (e === "") {
|
|
757
757
|
Yt(r, !0);
|
|
758
758
|
return;
|
|
759
759
|
}
|
|
760
|
-
let i =
|
|
761
|
-
|
|
760
|
+
let i = vt(r, e);
|
|
761
|
+
I(i) && Yt(i, n);
|
|
762
762
|
}
|
|
763
763
|
function Xt(e, t) {
|
|
764
|
-
let n =
|
|
765
|
-
|
|
764
|
+
let n = P("transformAt").obj;
|
|
765
|
+
bt(n, e, t(vt(n, e)));
|
|
766
766
|
}
|
|
767
767
|
function Zt() {
|
|
768
|
-
let e =
|
|
768
|
+
let e = F("ensureWorkspaceModulePaths"), t = Nt(e, "ensureWorkspaceModulePaths").modules.filter((e) => e.path !== "").map((e) => e.path).sort(), n = e.doc.toJSON()?.packages;
|
|
769
769
|
Array.isArray(n) && n.length === t.length && n.every((e, n) => e === t[n]) || e.doc.setIn(["packages"], t);
|
|
770
770
|
}
|
|
771
771
|
function Qt(e, t) {
|
|
@@ -773,49 +773,49 @@ function Qt(e, t) {
|
|
|
773
773
|
return typeof n == "string" ? n : void 0;
|
|
774
774
|
}
|
|
775
775
|
function $t(e, t) {
|
|
776
|
-
let n =
|
|
776
|
+
let n = F("ensureCatalogVersion");
|
|
777
777
|
Qt(n, e) === void 0 && n.doc.setIn(["catalog", e], t);
|
|
778
778
|
}
|
|
779
779
|
function en(e) {
|
|
780
|
-
let t =
|
|
780
|
+
let t = F("ensureCatalogLatest");
|
|
781
781
|
if (!t.getLatestVersion) return;
|
|
782
782
|
let n = t.getLatestVersion(e);
|
|
783
783
|
n !== void 0 && Qt(t, e) !== n && t.doc.setIn(["catalog", e], n);
|
|
784
784
|
}
|
|
785
785
|
function tn(e, t) {
|
|
786
|
-
let n =
|
|
786
|
+
let n = F("pinCatalogToDependencyOf");
|
|
787
787
|
if (!n.getDerivedDependencyPin) return;
|
|
788
788
|
let r = n.getDerivedDependencyPin(e);
|
|
789
789
|
r !== void 0 && Qt(n, e) !== r && n.doc.setIn(["catalog", e], r);
|
|
790
790
|
}
|
|
791
791
|
function nn(e, t) {
|
|
792
|
-
let n =
|
|
793
|
-
(r === void 0 || i !== null && a !== null && !(0,
|
|
792
|
+
let n = F("ensureCatalogAtLeast"), r = Qt(n, e), i = (0, lt.minVersion)(t), a = r !== void 0 && (0, lt.validRange)(r) !== null ? (0, lt.minVersion)(r) : null;
|
|
793
|
+
(r === void 0 || i !== null && a !== null && !(0, lt.gte)(a, i)) && n.doc.setIn(["catalog", e], t);
|
|
794
794
|
}
|
|
795
795
|
function rn(e) {
|
|
796
|
-
let t =
|
|
796
|
+
let t = F("ensureCatalogAbsent");
|
|
797
797
|
t.doc.hasIn(["catalog", e]) && t.doc.deleteIn(["catalog", e]);
|
|
798
798
|
}
|
|
799
799
|
function an(e, t, { keepExisting: n = !1 } = {}) {
|
|
800
|
-
let r =
|
|
801
|
-
|
|
800
|
+
let r = F("ensureWorkspaceMapEntries");
|
|
801
|
+
me(r.doc.get(e)) || r.doc.delete(e);
|
|
802
802
|
let i = Object.entries(t).filter(([t, i]) => n ? !r.doc.hasIn([e, t]) : r.doc.getIn([e, t]) !== i);
|
|
803
803
|
for (let [t, n] of i) r.doc.setIn([e, t], n);
|
|
804
804
|
}
|
|
805
805
|
function on(e, t) {
|
|
806
|
-
let n =
|
|
806
|
+
let n = F("ensureWorkspaceListItems"), r = n.doc.toJSON()?.[e], i = new Set(Array.isArray(r) ? r : []), a = t.filter((e) => !i.has(e));
|
|
807
807
|
if (a.length !== 0) {
|
|
808
|
-
if (!
|
|
808
|
+
if (!he(n.doc.get(e))) n.doc.set(e, a);
|
|
809
809
|
else for (let t of a) n.doc.addIn([e], t);
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
812
|
function sn(e) {
|
|
813
|
-
let t =
|
|
814
|
-
for (let n of e)
|
|
813
|
+
let t = Mt("ensureGitignoreEntries");
|
|
814
|
+
for (let n of e) Dt(t.lines, n) || t.lines.push(n);
|
|
815
815
|
}
|
|
816
816
|
// src/structure/engine/parsers/yaml.ts
|
|
817
817
|
function cn(e) {
|
|
818
|
-
return
|
|
818
|
+
return _e(e);
|
|
819
819
|
}
|
|
820
820
|
function ln(e) {
|
|
821
821
|
return e.toString();
|
|
@@ -858,11 +858,11 @@ function gn(e, t, n, r) {
|
|
|
858
858
|
return n.staticRead(e.path);
|
|
859
859
|
case "tpl":
|
|
860
860
|
if (!n) throw Error(`tpl('${e.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);
|
|
861
|
-
return
|
|
861
|
+
return Re(n.textRead(e.path), typeof e.vars == "function" ? e.vars(r) : e.vars);
|
|
862
862
|
case "generate": {
|
|
863
863
|
let n = e.fn(r);
|
|
864
|
-
if (t.endsWith(".json")) return
|
|
865
|
-
if (t.endsWith(".yaml") || t.endsWith(".yml")) return
|
|
864
|
+
if (t.endsWith(".json")) return At(n, r.isSdkInternal), gt(n, { collapse: !t.endsWith("package.json") });
|
|
865
|
+
if (t.endsWith(".yaml") || t.endsWith(".yml")) return ve(n);
|
|
866
866
|
if (typeof n != "string") throw Error(`generate() for '${t}' must return a string for non-JSON/YAML files; got ${typeof n}`);
|
|
867
867
|
return n;
|
|
868
868
|
}
|
|
@@ -878,21 +878,21 @@ function _n(e, t, n, r, i) {
|
|
|
878
878
|
function vn(e, t, n, r, i, a) {
|
|
879
879
|
let o = e.split("/").pop() ?? e;
|
|
880
880
|
if (e.endsWith(".json")) {
|
|
881
|
-
let i =
|
|
881
|
+
let i = ut(t);
|
|
882
882
|
if (typeof i != "object" || !i || Array.isArray(i)) throw Error(`managed: parsed value at '${e}' is not a JSON object`);
|
|
883
|
-
return
|
|
883
|
+
return Pt(i, n, { triggerContext: r }), gt(i, { collapse: o !== "package.json" });
|
|
884
884
|
}
|
|
885
885
|
if (e.endsWith(".yaml") || e.endsWith(".yml")) {
|
|
886
886
|
let e = cn(t);
|
|
887
|
-
return
|
|
887
|
+
return Ft(e, n, {
|
|
888
888
|
triggerContext: r,
|
|
889
889
|
getLatestVersion: i,
|
|
890
890
|
getDerivedDependencyPin: a
|
|
891
891
|
}), ln(e);
|
|
892
892
|
}
|
|
893
893
|
if (o === ".gitignore" || o.endsWith(".gitignore")) {
|
|
894
|
-
let e =
|
|
895
|
-
return
|
|
894
|
+
let e = Ct(t);
|
|
895
|
+
return It(e, n, { triggerContext: r }), wt(e);
|
|
896
896
|
}
|
|
897
897
|
throw Error(`managed('${e}'): unsupported file kind. Only .json, .yaml, .yml, .gitignore are dispatched.`);
|
|
898
898
|
}
|
|
@@ -917,7 +917,7 @@ function xn(e, t, n) {
|
|
|
917
917
|
pathMissing: (t) => !bn(e, t),
|
|
918
918
|
filesMatch: (t) => {
|
|
919
919
|
let r = n ? `${n}/${t}` : t;
|
|
920
|
-
for (let t of e) if (
|
|
920
|
+
for (let t of e) if (qe(r, t)) return !0;
|
|
921
921
|
return !1;
|
|
922
922
|
}
|
|
923
923
|
};
|
|
@@ -1013,14 +1013,14 @@ function Dn(e, t, n, r, i, a, o, s) {
|
|
|
1013
1013
|
return l;
|
|
1014
1014
|
}
|
|
1015
1015
|
function On(e, t, n, r = {}) {
|
|
1016
|
-
return
|
|
1017
|
-
let i =
|
|
1016
|
+
return Ze(n, () => {
|
|
1017
|
+
let i = He(e, n), a = !!r.initMode, o = Dn(i, t, n, n.dryRun, r.templates, a, r.registryLookup, r.derivedPinLookup);
|
|
1018
1018
|
if (!n.dryRun && !n.updateDepsOnly && !a) {
|
|
1019
1019
|
mn(t, { version: 3 });
|
|
1020
1020
|
let i = {
|
|
1021
1021
|
...r.rediscover ? r.rediscover(t) : n,
|
|
1022
1022
|
dryRun: !0
|
|
1023
|
-
}, a = Dn(
|
|
1023
|
+
}, a = Dn(He(e, i), t, i, !0, r.templates, !1, r.registryLookup, r.derivedPinLookup).filter((e) => e.path !== un);
|
|
1024
1024
|
if (a.length > 0) throw new hn(a[0]);
|
|
1025
1025
|
}
|
|
1026
1026
|
return a && !n.dryRun && mn(t, { version: 3 }), { changes: o };
|
|
@@ -1187,7 +1187,7 @@ function Hn(e) {
|
|
|
1187
1187
|
} catch {
|
|
1188
1188
|
throw new Y("No pnpm-workspace.yaml found. This directory is empty or unrecognisable as a block — run 'block-tools structure init' instead, or pass --sdk-internal for an in-monorepo block.");
|
|
1189
1189
|
}
|
|
1190
|
-
let n =
|
|
1190
|
+
let n = ge(t) ?? {}, r = Array.isArray(n.packages) ? n.packages : [], i = /* @__PURE__ */ new Set([""]);
|
|
1191
1191
|
for (let t of r) {
|
|
1192
1192
|
let n = Vn(t);
|
|
1193
1193
|
(n === "" || e.exists(n)) && i.add(n);
|
|
@@ -1339,20 +1339,20 @@ function tr() {
|
|
|
1339
1339
|
};
|
|
1340
1340
|
}
|
|
1341
1341
|
function nr() {
|
|
1342
|
-
|
|
1342
|
+
L("packageManager", Jn), L("devEngines.runtime", qn), R("pnpm", (e) => e === null || typeof e == "object" && Object.values(e).every((e) => typeof e == "object" && !!e && Object.keys(e).length === 0)), Rt("pnpm", "pnpm 11+ ignores the \"pnpm\" field in package.json. Move its settings to pnpm-workspace.yaml: overrides as is, onlyBuiltDependencies as allowBuilds true, neverBuiltDependencies as allowBuilds false.");
|
|
1343
1343
|
}
|
|
1344
1344
|
function rr() {
|
|
1345
|
-
nr(),
|
|
1346
|
-
for (let [e, t] of Object.entries($n))
|
|
1347
|
-
for (let [e, t] of Object.entries(er))
|
|
1348
|
-
|
|
1345
|
+
nr(), R("name"), z("fmt", "turbo run fmt"), z("check", "turbo run check");
|
|
1346
|
+
for (let [e, t] of Object.entries($n)) z(e, t);
|
|
1347
|
+
for (let [e, t] of Object.entries(er)) z(e, t);
|
|
1348
|
+
B("build"), B("build:dev"), z("mark-stable", "turbo run mark-stable"), z("do-pack", "turbo run do-pack"), z("watch", "turbo watch build"), z("changeset", "changeset"), z("version-packages", "changeset version"), z("update-sdk", "block-tools structure refresh --update-deps-only"), B("update"), z("upgrade-sdk", "block-tools structure refresh --update-deps-only && pnpm i && block-tools structure refresh && pnpm i && pnpm fmt"), U({
|
|
1349
1349
|
"@changesets/cli": "catalog:",
|
|
1350
1350
|
"@milaboratories/ts-builder": "sdk:",
|
|
1351
1351
|
"@platforma-sdk/block-tools": "sdk:",
|
|
1352
1352
|
"cross-env": "catalog:",
|
|
1353
1353
|
shx: "catalog:",
|
|
1354
1354
|
turbo: "catalog:"
|
|
1355
|
-
}),
|
|
1355
|
+
}), W({
|
|
1356
1356
|
oxlint: "*",
|
|
1357
1357
|
oxfmt: "*"
|
|
1358
1358
|
}), qt((e, t) => {
|
|
@@ -1419,7 +1419,7 @@ function sr() {
|
|
|
1419
1419
|
};
|
|
1420
1420
|
}
|
|
1421
1421
|
function cr() {
|
|
1422
|
-
|
|
1422
|
+
L("$schema", ir), L("globalDependencies", ar), zt("tasks", or), R("tasks.build:dev"), G([
|
|
1423
1423
|
"$schema",
|
|
1424
1424
|
"globalDependencies",
|
|
1425
1425
|
"tasks"
|
|
@@ -1442,18 +1442,18 @@ async function pr(e) {
|
|
|
1442
1442
|
} catch (e) {
|
|
1443
1443
|
if (t > lr) throw e;
|
|
1444
1444
|
let n = ur * 2 ** (t - 1) * (.8 + .4 * Math.random());
|
|
1445
|
-
await
|
|
1445
|
+
await ye(n);
|
|
1446
1446
|
continue;
|
|
1447
1447
|
}
|
|
1448
1448
|
if (n.ok) return n;
|
|
1449
1449
|
if (!(n.status === 429 || n.status >= 500) || t > lr) throw Error(`registry returned HTTP ${n.status}`);
|
|
1450
1450
|
let r = fr(n.headers.get("retry-after"));
|
|
1451
1451
|
if (r != null) {
|
|
1452
|
-
await
|
|
1452
|
+
await ye(r);
|
|
1453
1453
|
continue;
|
|
1454
1454
|
}
|
|
1455
1455
|
let i = ur * 2 ** (t - 1) * (.8 + .4 * Math.random());
|
|
1456
|
-
await
|
|
1456
|
+
await ye(i);
|
|
1457
1457
|
}
|
|
1458
1458
|
}
|
|
1459
1459
|
function mr() {
|
|
@@ -1507,7 +1507,7 @@ var Sr = [
|
|
|
1507
1507
|
"@platforma-sdk/eslint-config"
|
|
1508
1508
|
];
|
|
1509
1509
|
function Cr() {
|
|
1510
|
-
for (let e of Sr)
|
|
1510
|
+
for (let e of Sr) H(e);
|
|
1511
1511
|
}
|
|
1512
1512
|
// src/structure/rules/root-pnpm-workspace.ts
|
|
1513
1513
|
var wr = [
|
|
@@ -1590,7 +1590,7 @@ function Ir(e) {
|
|
|
1590
1590
|
};
|
|
1591
1591
|
}
|
|
1592
1592
|
function Lr(e) {
|
|
1593
|
-
|
|
1593
|
+
L("changelog", Rr), L("commit", !1), L("access", zr), L("baseBranch", Br), L("updateInternalDependencies", Vr);
|
|
1594
1594
|
let t = Wr(e);
|
|
1595
1595
|
Xt("fixed", (e) => Gr(e, t)), G(Hr);
|
|
1596
1596
|
}
|
|
@@ -1625,19 +1625,19 @@ function Kr(e) {
|
|
|
1625
1625
|
}
|
|
1626
1626
|
// src/structure/rules/root.ts
|
|
1627
1627
|
function qr() {
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1628
|
+
x("root", () => {
|
|
1629
|
+
S(({ ctx: e }) => !e.isSdkInternal, () => {
|
|
1630
|
+
T("turbo.json", j(() => sr()), () => {
|
|
1631
1631
|
cr();
|
|
1632
|
-
}),
|
|
1632
|
+
}), w(".vscode/settings.json", k("root/.vscode/settings.json")), T("package.json", j(() => tr()), () => {
|
|
1633
1633
|
rr();
|
|
1634
|
-
}),
|
|
1634
|
+
}), T("pnpm-workspace.yaml", j((e) => Ar(e)), () => {
|
|
1635
1635
|
Mr();
|
|
1636
|
-
}),
|
|
1636
|
+
}), T(".gitignore", k("root/gitignore"), () => {
|
|
1637
1637
|
Pr();
|
|
1638
|
-
}),
|
|
1638
|
+
}), T(".changeset/config.json", j((e) => Ir(e)), (e) => {
|
|
1639
1639
|
Lr(e);
|
|
1640
|
-
}),
|
|
1640
|
+
}), D(".changeset/scaffold.md", ct(Fr));
|
|
1641
1641
|
});
|
|
1642
1642
|
});
|
|
1643
1643
|
}
|
|
@@ -1646,16 +1646,16 @@ function Jr(e) {
|
|
|
1646
1646
|
return e.split(/[-_]+/).filter((e) => e.length > 0).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
1647
1647
|
}
|
|
1648
1648
|
function Yr() {
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1649
|
+
x("root", () => {
|
|
1650
|
+
S(({ ctx: e }) => !e.isSdkInternal, () => {
|
|
1651
|
+
w(".github/workflows/build.yaml", A("workflows/build.tpl.yaml", (e) => {
|
|
1652
1652
|
let t = e.blockVars.shortName;
|
|
1653
1653
|
return {
|
|
1654
1654
|
appName: `Block: ${Jr(t)}`,
|
|
1655
1655
|
appNameSlug: `block-${t}`,
|
|
1656
1656
|
nodeVersion: Kn
|
|
1657
1657
|
};
|
|
1658
|
-
})),
|
|
1658
|
+
})), w(".github/workflows/mark-stable.yaml", A("workflows/mark-stable.tpl.yaml", (e) => ({
|
|
1659
1659
|
appName: `Block: ${Jr(e.blockVars.shortName)} - Mark Stable`,
|
|
1660
1660
|
nodeVersion: Kn
|
|
1661
1661
|
})));
|
|
@@ -1760,10 +1760,10 @@ function ai(e) {
|
|
|
1760
1760
|
function oi(e) {
|
|
1761
1761
|
let t = e.blockVars, n = q(e, "kind");
|
|
1762
1762
|
if (n.length !== 1) throw Error(n.length === 0 ? `block '${t.facadeName}' declares no kind — every block must have a sibling kind/ package` : `block '${t.facadeName}' declares ${n.length} kinds; exactly one is required`);
|
|
1763
|
-
|
|
1763
|
+
L("type", "module"), L("files", ["dist", "block-pack"]), L("main", "./dist/index.js"), L("module", "./dist/index.js"), L("types", "./dist/index.d.ts"), L("exports", ri);
|
|
1764
1764
|
let r = ti(t.npmOrg, e.isSdkInternal);
|
|
1765
|
-
for (let [e, t] of Object.entries(r))
|
|
1766
|
-
Kt("model"), Kt("ui"), Kt("workflow"), Kt("kind"),
|
|
1765
|
+
for (let [e, t] of Object.entries(r)) z(e, t);
|
|
1766
|
+
Kt("model"), Kt("ui"), Kt("workflow"), Kt("kind"), V("@milaboratories/ts-builder", "sdk:"), V("@milaboratories/ts-configs", "sdk:"), V("@platforma-sdk/block-tools", "sdk:"), V("@platforma-sdk/model", "sdk:"), V("shx", "catalog:"), V("typescript", "catalog:"), L("block.components", ei(e)), Lt("version", "facade package.json must carry a 'version' (the facade publishes)"), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
1767
1767
|
}
|
|
1768
1768
|
// src/structure/rules/shared/pascal-case.ts
|
|
1769
1769
|
function si(e) {
|
|
@@ -1772,11 +1772,11 @@ function si(e) {
|
|
|
1772
1772
|
}
|
|
1773
1773
|
// src/structure/rules/block.ts
|
|
1774
1774
|
function ci() {
|
|
1775
|
-
|
|
1776
|
-
|
|
1775
|
+
x("block", () => {
|
|
1776
|
+
O("index.js"), O("index.d.ts"), w("src/index.ts", A("block/src/index.tpl.ts", (e) => ({
|
|
1777
1777
|
facadeName: e.blockVars.facadeName,
|
|
1778
1778
|
pascalName: si(e.blockVars.shortName)
|
|
1779
|
-
}))),
|
|
1779
|
+
}))), w("src/AGENTS.ts", k("block/src/AGENTS.ts")), E("src/block-extra.ts", k("block/src/block-extra.ts")), E("src/agents-extra.ts", k("block/src/agents-extra.ts")), w("tsconfig.json", k("block/tsconfig.json")), D("logos/block-logo.png", st("block/logos/block-logo.png")), D("logos/organization-logo.png", st("block/logos/organization-logo.png")), T("package.json", j((e) => ai(e)), (e) => {
|
|
1780
1780
|
oi(e);
|
|
1781
1781
|
});
|
|
1782
1782
|
});
|
|
@@ -1823,28 +1823,28 @@ function ui(e) {
|
|
|
1823
1823
|
};
|
|
1824
1824
|
}
|
|
1825
1825
|
function di() {
|
|
1826
|
-
Q(),
|
|
1826
|
+
Q(), L("private", !0), L("type", "module"), L("main", "dist/index.cjs"), L("module", "dist/index.js"), L("types", "dist/index.d.ts"), L("exports", {
|
|
1827
1827
|
".": {
|
|
1828
1828
|
types: "./dist/index.d.ts",
|
|
1829
1829
|
sources: "./src/index.ts",
|
|
1830
1830
|
import: "./dist/index.js"
|
|
1831
1831
|
},
|
|
1832
1832
|
"./dist/*": "./dist/*"
|
|
1833
|
-
}),
|
|
1833
|
+
}), z("fmt", "ts-builder format"), z("watch", "ts-builder build --target block-model --watch"), z("build", "ts-builder build --target block-model && block-tools build-model"), z("check", "ts-builder check --target block-model"), Ht("@platforma-sdk/model", "sdk:"), Gt("kind"), U({
|
|
1834
1834
|
"@milaboratories/ts-builder": "sdk:",
|
|
1835
1835
|
"@milaboratories/ts-configs": "sdk:",
|
|
1836
1836
|
"@platforma-sdk/block-tools": "sdk:"
|
|
1837
|
-
}),
|
|
1837
|
+
}), W({
|
|
1838
1838
|
"@types/node": "*",
|
|
1839
1839
|
typescript: "*"
|
|
1840
|
-
}),
|
|
1841
|
-
|
|
1842
|
-
}, () =>
|
|
1840
|
+
}), S(({ ctx: e }) => !e.isSdkInternal, () => S(C($), () => {
|
|
1841
|
+
z("test", "vitest run --passWithNoTests"), V("vitest", "catalog:"), V("@types/node", "*");
|
|
1842
|
+
}, () => H("vitest"))), Cr(), R("tsup"), B("lint"), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
1843
1843
|
}
|
|
1844
1844
|
// src/structure/rules/model.ts
|
|
1845
1845
|
function fi() {
|
|
1846
|
-
|
|
1847
|
-
C(
|
|
1846
|
+
x("model", () => {
|
|
1847
|
+
S(C($), () => w("tsconfig.json", k("model/tsconfig.node.json")), () => w("tsconfig.json", k("model/tsconfig.json"))), w(".oxlintrc.json", k("model/.oxlintrc.json")), w(".oxfmtrc.json", k("model/.oxfmtrc.json")), D("src/index.ts", A("model/src/index.tpl.ts", (e) => ({ kindPkg: `${e.blockVars.facadeName}.kind` }))), T("package.json", j((e) => ui(e)), () => {
|
|
1848
1848
|
di();
|
|
1849
1849
|
});
|
|
1850
1850
|
});
|
|
@@ -1886,19 +1886,19 @@ function mi(e) {
|
|
|
1886
1886
|
};
|
|
1887
1887
|
}
|
|
1888
1888
|
function hi() {
|
|
1889
|
-
Q(),
|
|
1889
|
+
Q(), L("private", !0), L("type", "module"), L("main", "./dist/index.cjs"), L("module", "./dist/index.js"), L("types", "./dist/index.d.ts"), L("exports", pi), z("fmt", "ts-builder format"), z("watch", "ts-builder build --target block-kind --watch"), z("build", "ts-builder build --target block-kind && block-tools build-kind-manifest"), z("check", "ts-builder check --target block-kind"), B("lint"), Ht("@platforma-sdk/block-kind", "sdk:"), U({
|
|
1890
1890
|
"@milaboratories/ts-builder": "sdk:",
|
|
1891
1891
|
"@milaboratories/ts-configs": "sdk:",
|
|
1892
1892
|
"@platforma-sdk/block-tools": "sdk:"
|
|
1893
|
-
}),
|
|
1893
|
+
}), W({
|
|
1894
1894
|
"@types/node": "*",
|
|
1895
1895
|
typescript: "*"
|
|
1896
1896
|
}), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
1897
1897
|
}
|
|
1898
1898
|
// src/structure/rules/kind.ts
|
|
1899
1899
|
function gi() {
|
|
1900
|
-
|
|
1901
|
-
|
|
1900
|
+
x("kind", () => {
|
|
1901
|
+
w("tsconfig.json", k("kind/tsconfig.json")), w(".oxlintrc.json", k("kind/.oxlintrc.json")), w(".oxfmtrc.json", k("kind/.oxfmtrc.json")), E("src/index.ts", k("kind/src/index.ts")), T("package.json", j((e) => mi(e)), () => {
|
|
1902
1902
|
hi();
|
|
1903
1903
|
});
|
|
1904
1904
|
});
|
|
@@ -1933,20 +1933,20 @@ function _i(e) {
|
|
|
1933
1933
|
};
|
|
1934
1934
|
}
|
|
1935
1935
|
function vi() {
|
|
1936
|
-
Q(),
|
|
1936
|
+
Q(), L("private", !0), L("type", "module"), z("fmt", "ts-builder format"), z("dev", "ts-builder serve --target block-ui"), z("watch", "ts-builder build --target block-ui --watch"), z("build", "ts-builder build --target block-ui"), z("check", "ts-builder check --target block-ui"), Ht("@platforma-sdk/ui-vue", "sdk:"), Ht("vue", "catalog:"), Gt("model"), U({
|
|
1937
1937
|
"@milaboratories/ts-builder": "sdk:",
|
|
1938
1938
|
"@milaboratories/ts-configs": "sdk:"
|
|
1939
|
-
}), Cr(),
|
|
1939
|
+
}), Cr(), B("preview"), B("lint"), W({
|
|
1940
1940
|
"@types/node": "*",
|
|
1941
1941
|
typescript: "*"
|
|
1942
|
-
}),
|
|
1943
|
-
|
|
1944
|
-
}, () =>
|
|
1942
|
+
}), S(({ ctx: e }) => !e.isSdkInternal, () => S(C($), () => {
|
|
1943
|
+
z("test", "vitest run --passWithNoTests"), V("vitest", "catalog:"), V("@types/node", "*");
|
|
1944
|
+
}, () => H("vitest"))), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
1945
1945
|
}
|
|
1946
1946
|
// src/structure/rules/ui.ts
|
|
1947
1947
|
function yi() {
|
|
1948
|
-
|
|
1949
|
-
C(
|
|
1948
|
+
x("ui", () => {
|
|
1949
|
+
S(C($), () => w("tsconfig.json", k("ui/tsconfig.node.json")), () => w("tsconfig.json", k("ui/tsconfig.json"))), w(".oxlintrc.json", k("ui/.oxlintrc.json")), w(".oxfmtrc.json", k("ui/.oxfmtrc.json")), E("index.html", k("ui/index.html")), D("src/main.ts", k("ui/src/main.ts")), D("src/app.ts", A("ui/src/app.tpl.ts", (e) => ({ modelPkg: `${e.blockVars.facadeName}.model` }))), D("src/MainPage.vue", A("ui/src/MainPage.tpl.vue", (e) => ({ shortName: e.blockVars.shortName }))), T("package.json", j((e) => _i(e)), () => {
|
|
1950
1950
|
vi();
|
|
1951
1951
|
});
|
|
1952
1952
|
});
|
|
@@ -1975,11 +1975,11 @@ function bi(e) {
|
|
|
1975
1975
|
};
|
|
1976
1976
|
}
|
|
1977
1977
|
function xi() {
|
|
1978
|
-
Q(),
|
|
1979
|
-
C(
|
|
1978
|
+
Q(), L("private", !0), L("type", "module"), z("build", "shx rm -rf dist && pl-tengo build"), z("check", "pl-tengo imports && pl-tengo check"), z("format", "/usr/bin/env emacs --script ./format.el || echo 'No emacs.'"), S(({ ctx: e }) => !e.isSdkInternal, () => S(C($), () => {
|
|
1979
|
+
S(C(li), () => z("test", "pl-tengo test && vitest run --passWithNoTests"), () => z("test", "vitest run --passWithNoTests")), U({ vitest: "catalog:" });
|
|
1980
1980
|
}, () => {
|
|
1981
|
-
C(
|
|
1982
|
-
})),
|
|
1981
|
+
S(C(li), () => z("test", "pl-tengo test")), H("vitest");
|
|
1982
|
+
})), Ht("@platforma-sdk/workflow-tengo", "sdk:"), Gt("software"), U({
|
|
1983
1983
|
"@platforma-sdk/tengo-builder": "sdk:",
|
|
1984
1984
|
"@platforma-sdk/test": "sdk:",
|
|
1985
1985
|
shx: "catalog:"
|
|
@@ -1987,12 +1987,12 @@ function xi() {
|
|
|
1987
1987
|
}
|
|
1988
1988
|
// src/structure/rules/workflow.ts
|
|
1989
1989
|
function Si() {
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1990
|
+
x("workflow", () => {
|
|
1991
|
+
w("format.el", k("workflow/format.el")), S(({ ctx: e }) => !e.isSdkInternal, () => S(C($), () => {
|
|
1992
|
+
w("tsconfig.json", k("workflow/tsconfig.json")), E("vitest.config.mts", k("workflow/vitest.config.mts"));
|
|
1993
1993
|
}, () => {
|
|
1994
|
-
|
|
1995
|
-
})),
|
|
1994
|
+
O("tsconfig.json"), O("vitest.config.mts");
|
|
1995
|
+
})), O("index.js"), O("index.d.ts"), D("src/main.tpl.tengo", A("workflow/src/main.tpl.tengo", (e) => ({ shortName: e.blockVars.shortName }))), T("package.json", j((e) => bi(e)), () => {
|
|
1996
1996
|
xi();
|
|
1997
1997
|
});
|
|
1998
1998
|
});
|
|
@@ -2019,17 +2019,17 @@ function Ci(e) {
|
|
|
2019
2019
|
};
|
|
2020
2020
|
}
|
|
2021
2021
|
function wi() {
|
|
2022
|
-
Q(),
|
|
2022
|
+
Q(), L("private", !0), L("type", "module"), z("fmt", "ts-builder format"), z("check", "ts-builder check --target block-test"), z("test", "vitest run --passWithNoTests"), B("lint"), U({
|
|
2023
2023
|
"@platforma-sdk/test": "sdk:",
|
|
2024
2024
|
"@milaboratories/ts-builder": "sdk:",
|
|
2025
2025
|
"@milaboratories/ts-configs": "sdk:",
|
|
2026
2026
|
vitest: "catalog:"
|
|
2027
|
-
}),
|
|
2027
|
+
}), W({ typescript: "*" }), H("@types/node"), Cr(), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
2028
2028
|
}
|
|
2029
2029
|
// src/structure/rules/test.ts
|
|
2030
2030
|
function Ti() {
|
|
2031
|
-
|
|
2032
|
-
|
|
2031
|
+
x("test", () => {
|
|
2032
|
+
w("tsconfig.json", k("test/tsconfig.json")), w(".oxlintrc.json", k("test/.oxlintrc.json")), w(".oxfmtrc.json", k("test/.oxfmtrc.json")), E("vitest.config.mts", k("test/vitest.config.mts")), D("src/demo.test.ts", ct("import { expect, test } from \"vitest\";\n\ntest(\"scaffolded block sanity check\", () => {\n expect(true).toBe(true);\n});\n")), T("package.json", j((e) => Ci(e)), () => {
|
|
2033
2033
|
wi();
|
|
2034
2034
|
});
|
|
2035
2035
|
});
|
|
@@ -2072,38 +2072,38 @@ function ki(e) {
|
|
|
2072
2072
|
};
|
|
2073
2073
|
}
|
|
2074
2074
|
function Ai() {
|
|
2075
|
-
|
|
2075
|
+
R("private"), Q(), L("type", "module"), L("files", ["./dist/**/*"]), z("build", Ei), z("do-pack", Di), B("prepublishOnly"), z("changeset", "changeset"), z("version-packages", "changeset version"), V("@platforma-open/milaboratories.runenv-python-3", "catalog:"), V("@platforma-sdk/block-tools", "sdk:"), H("@platforma-sdk/package-builder"), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
2076
2076
|
}
|
|
2077
2077
|
// src/structure/rules/software.ts
|
|
2078
2078
|
var ji = "import sys\n\nprint(\"Hello from Python, \" + sys.argv[1] + \"!\")\n", Mi = "# No dependencies specified for this script\n";
|
|
2079
2079
|
function Ni() {
|
|
2080
|
-
|
|
2081
|
-
|
|
2080
|
+
x("software", () => {
|
|
2081
|
+
D("src/main.py", ct(ji)), D("src/requirements.txt", ct(Mi)), T("package.json", j((e) => ki(e)), () => {
|
|
2082
2082
|
Ai();
|
|
2083
2083
|
});
|
|
2084
2084
|
});
|
|
2085
2085
|
}
|
|
2086
2086
|
function Pi() {
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
}),
|
|
2090
|
-
|
|
2091
|
-
}),
|
|
2092
|
-
|
|
2093
|
-
}),
|
|
2094
|
-
|
|
2095
|
-
|
|
2087
|
+
x("model", () => {
|
|
2088
|
+
O("eslint.config.mjs"), O("vite.config.mts");
|
|
2089
|
+
}), x("ui", () => {
|
|
2090
|
+
O("eslint.config.mjs"), O("vite.config.ts"), O("tsconfig.app.json"), O("tsconfig.node.json");
|
|
2091
|
+
}), x("test", () => {
|
|
2092
|
+
O("eslint.config.mjs");
|
|
2093
|
+
}), x("root", () => {
|
|
2094
|
+
O(".prettierrc"), T("package.json", j(() => tr()), () => {
|
|
2095
|
+
B("pretty"), H("@platforma-sdk/blocks-deps-updater");
|
|
2096
2096
|
});
|
|
2097
2097
|
});
|
|
2098
2098
|
}
|
|
2099
2099
|
// src/structure/rules/root-catalog-bump.ts
|
|
2100
2100
|
function Fi() {
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2101
|
+
ot(() => {
|
|
2102
|
+
x("root", () => {
|
|
2103
|
+
S(({ ctx: e }) => !e.isSdkInternal, () => {
|
|
2104
|
+
T("package.json", j(() => tr()), () => {
|
|
2105
2105
|
nr(), G([...X]);
|
|
2106
|
-
}),
|
|
2106
|
+
}), T("pnpm-workspace.yaml", j((e) => Ar(e)), (e) => {
|
|
2107
2107
|
for (let e of wr) en(e);
|
|
2108
2108
|
for (let e of Dr) tn(e.entry, {
|
|
2109
2109
|
of: e.of,
|
|
@@ -2116,7 +2116,7 @@ function Fi() {
|
|
|
2116
2116
|
});
|
|
2117
2117
|
}
|
|
2118
2118
|
// src/structure/structure-definition.ts
|
|
2119
|
-
var Ii =
|
|
2119
|
+
var Ii = $e(() => {
|
|
2120
2120
|
qr(), Yr(), ci(), fi(), gi(), yi(), Si(), Ti(), Ni(), Pi(), Fi();
|
|
2121
2121
|
});
|
|
2122
2122
|
// src/structure/cli/run-structure.ts
|
|
@@ -2124,7 +2124,7 @@ async function Li() {
|
|
|
2124
2124
|
return yr(wr.filter(vr));
|
|
2125
2125
|
}
|
|
2126
2126
|
async function Ri(e) {
|
|
2127
|
-
let t =
|
|
2127
|
+
let t = h.resolve(e.blockPath), n = e.mode === "check", r = new Ie(t), i = new Le(e.templatesRoot), a = On(Ii, r, Gn({
|
|
2128
2128
|
fs: r,
|
|
2129
2129
|
isSdkInternal: e.isSdkInternal,
|
|
2130
2130
|
updateDepsOnly: e.updateDepsOnly,
|
|
@@ -2146,7 +2146,7 @@ async function Ri(e) {
|
|
|
2146
2146
|
};
|
|
2147
2147
|
}
|
|
2148
2148
|
function zi(e) {
|
|
2149
|
-
let t = e.flatMap((e) => /[*?[]/.test(e) ?
|
|
2149
|
+
let t = e.flatMap((e) => /[*?[]/.test(e) ? ie(e).filter((e) => ae(e, { throwIfNoEntry: !1 })?.isDirectory() === !0).map((e) => e.split(h.sep).join("/")).sort() : [e]);
|
|
2150
2150
|
return [...new Set(t)];
|
|
2151
2151
|
}
|
|
2152
2152
|
function Bi(e, t) {
|
|
@@ -2169,37 +2169,37 @@ async function Vi(e) {
|
|
|
2169
2169
|
}
|
|
2170
2170
|
}
|
|
2171
2171
|
function Hi(e) {
|
|
2172
|
-
let t = new
|
|
2172
|
+
let t = new p("refresh").description("Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only updates the catalog versions and the pnpm and Node toolchain (network).");
|
|
2173
2173
|
return t.argument("[paths...]", "block path(s); defaults to the current directory"), t.option("--sdk-internal", "block(s) live inside the SDK monorepo; skip root-scope rules"), t.option("--update-deps-only", "update ONLY the catalog versions and the pnpm and Node toolchain (npm network). Follow with `pnpm install` then a plain refresh."), t.action(async (t, n) => {
|
|
2174
|
-
let r = t.length > 0 ? zi(t) : ["."], i =
|
|
2174
|
+
let r = t.length > 0 ? zi(t) : ["."], i = h.join(e, "src", "structure", "templates");
|
|
2175
2175
|
await Vi({
|
|
2176
2176
|
paths: r,
|
|
2177
2177
|
isSdkInternal: !!n.sdkInternal,
|
|
2178
2178
|
updateDepsOnly: !!n.updateDepsOnly,
|
|
2179
2179
|
templatesRoot: i,
|
|
2180
|
-
logger: new
|
|
2180
|
+
logger: new y()
|
|
2181
2181
|
});
|
|
2182
2182
|
}), t;
|
|
2183
2183
|
}
|
|
2184
2184
|
// src/cmd/update-deps.ts
|
|
2185
2185
|
function Ui(e) {
|
|
2186
|
-
let t = new
|
|
2186
|
+
let t = new p("update-deps").description("[DEPRECATED] Use `block-tools structure refresh --update-deps-only`. This alias delegates to it.");
|
|
2187
2187
|
return t.action(async () => {
|
|
2188
|
-
let t = new
|
|
2188
|
+
let t = new y();
|
|
2189
2189
|
t.warn("`block-tools update-deps` is deprecated and will be removed in a future release. Use `block-tools structure refresh --update-deps-only` instead. Delegating now."), await Vi({
|
|
2190
2190
|
paths: ["."],
|
|
2191
2191
|
isSdkInternal: !1,
|
|
2192
2192
|
updateDepsOnly: !0,
|
|
2193
|
-
templatesRoot:
|
|
2193
|
+
templatesRoot: h.join(e, "src", "structure", "templates"),
|
|
2194
2194
|
logger: t
|
|
2195
2195
|
});
|
|
2196
2196
|
}), t;
|
|
2197
2197
|
}
|
|
2198
2198
|
// src/cmd/list-overview-snapshots.ts
|
|
2199
2199
|
function Wi() {
|
|
2200
|
-
let e = new
|
|
2201
|
-
return e.addOption(new
|
|
2202
|
-
let t = new
|
|
2200
|
+
let e = new p("list-overview-snapshots").description("List all available global overview snapshots in the registry");
|
|
2201
|
+
return e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.option("--json", "output in JSON format", !1), e.action(async (e) => {
|
|
2202
|
+
let t = new y(), n = te(e.registry), r = await new s(n, t).listGlobalOverviewSnapshots();
|
|
2203
2203
|
if (e.json) t.info(JSON.stringify(r, null, 2));
|
|
2204
2204
|
else if (r.length === 0) t.info("No snapshots found.");
|
|
2205
2205
|
else {
|
|
@@ -2210,9 +2210,9 @@ function Wi() {
|
|
|
2210
2210
|
}
|
|
2211
2211
|
// src/cmd/restore-overview-from-snapshot.ts
|
|
2212
2212
|
function Gi() {
|
|
2213
|
-
let e = new
|
|
2214
|
-
return e.addOption(new
|
|
2215
|
-
let t = new
|
|
2213
|
+
let e = new p("restore-overview-from-snapshot").description("Restore global overview from a snapshot");
|
|
2214
|
+
return e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.requiredOption("-s, --snapshot <timestamp>", "snapshot timestamp ID to restore from"), e.option("--skip-confirmation", "skip confirmation prompt (use with caution)", !1), e.action(async (e) => {
|
|
2215
|
+
let t = new y(), n = te(e.registry), r = new s(n, t), i = await r.listGlobalOverviewSnapshots();
|
|
2216
2216
|
if (!i.find((t) => t.timestamp === e.snapshot)) throw Error(`Snapshot '${e.snapshot}' not found. Available snapshots:\n${i.map((e) => ` - ${e.timestamp}`).join("\n") || " (none)"}`);
|
|
2217
2217
|
if (!e.skipConfirmation) {
|
|
2218
2218
|
let n = (await import("node:readline")).createInterface({
|
|
@@ -2245,11 +2245,11 @@ function Ki(e) {
|
|
|
2245
2245
|
}
|
|
2246
2246
|
return {
|
|
2247
2247
|
src: e,
|
|
2248
|
-
destName:
|
|
2248
|
+
destName: h.basename(e)
|
|
2249
2249
|
};
|
|
2250
2250
|
}
|
|
2251
2251
|
function qi(e, t) {
|
|
2252
|
-
return new
|
|
2252
|
+
return new m(e, t).argParser((e, t) => [...t ?? [], Ki(e)]).default([]);
|
|
2253
2253
|
}
|
|
2254
2254
|
// src/cmd/upload-package-v1.ts
|
|
2255
2255
|
var Ji = [
|
|
@@ -2259,18 +2259,18 @@ var Ji = [
|
|
|
2259
2259
|
"version"
|
|
2260
2260
|
];
|
|
2261
2261
|
function Yi() {
|
|
2262
|
-
let e = new
|
|
2263
|
-
return e.addOption(new
|
|
2264
|
-
let t = new
|
|
2262
|
+
let e = new p("upload-package-v1").description("Uploads V1 package and refreshes the registry");
|
|
2263
|
+
return e.addOption(new m("-r, --registry <address|alias>", "full address of the registry or alias from .pl.reg").env("PL_REGISTRY")), e.addOption(new m("-o, --organization <organization>", "target organisation").env("PL_PACKAGE_ORGANIZATION")), e.addOption(new m("-p, --package <package>", "target package").env("PL_PACKAGE_NAME")), e.addOption(new m("-v, --version <version>", "target version").env("PL_PACKAGE_VERSION")), e.option("-m, --meta <path>", "json file containing meta information to associate with tha package"), e.addOption(qi("-f, --file <file>", "package files")), e.addOption(new m("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), e.option("--no-refresh", "do not refresh repository after adding the package"), e.action(async (e) => {
|
|
2264
|
+
let t = new y(), n = ee.parse({});
|
|
2265
2265
|
for (let t of Ji) e[t] && (n[t] = e[t]);
|
|
2266
|
-
e.meta && (e.meta.endsWith(".json") ? n.meta = JSON.parse(await
|
|
2266
|
+
e.meta && (e.meta.endsWith(".json") ? n.meta = JSON.parse(await g.promises.readFile(e.meta, { encoding: "utf-8" })) : e.meta.endsWith(".yaml") && (n.meta = pe.parse(await g.promises.readFile(e.meta, { encoding: "utf-8" }))));
|
|
2267
2267
|
for (let t of e.file) n.files[t.destName] = t.src;
|
|
2268
|
-
let r = await
|
|
2269
|
-
t.info(
|
|
2268
|
+
let r = await f(n);
|
|
2269
|
+
t.info(pe.stringify(r.conf));
|
|
2270
2270
|
let i = r.createRegistry(t), a = r.fullPackageName, o = i.constructNewPackage(a);
|
|
2271
2271
|
for (let [e, n] of Object.entries(r.conf.files)) {
|
|
2272
2272
|
t.info(`Uploading ${n} -> ${e} ...`);
|
|
2273
|
-
let r = await
|
|
2273
|
+
let r = await g.promises.readFile(n);
|
|
2274
2274
|
await o.addFile(e, r);
|
|
2275
2275
|
}
|
|
2276
2276
|
t.info("Uploading meta information..."), await o.writeMeta(r.conf.meta), await o.finish(), e.refresh && await i.updateIfNeeded();
|
|
@@ -2278,9 +2278,9 @@ function Yi() {
|
|
|
2278
2278
|
}
|
|
2279
2279
|
// src/cmd/structure/check.ts
|
|
2280
2280
|
function Xi(e) {
|
|
2281
|
-
let t = new
|
|
2281
|
+
let t = new p("check").description("Check block(s) against the canonical structure (read-only). Exits non-zero if any diff would land — used as the CI gate.");
|
|
2282
2282
|
return t.argument("[paths...]", "block path(s); defaults to the current directory"), t.option("--sdk-internal", "block(s) live inside the SDK monorepo; skip root-scope rules"), t.action(async (t, n) => {
|
|
2283
|
-
let r = new
|
|
2283
|
+
let r = new y(), i = t.length > 0 ? zi(t) : ["."], a = h.join(e, "src", "structure", "templates"), o = !1;
|
|
2284
2284
|
for (let e of i) {
|
|
2285
2285
|
let t = await Ri({
|
|
2286
2286
|
blockPath: e,
|
|
@@ -2307,17 +2307,17 @@ async function $i(e, t, n, r) {
|
|
|
2307
2307
|
return r();
|
|
2308
2308
|
}
|
|
2309
2309
|
async function ea(e) {
|
|
2310
|
-
let t = await $i(e.npmOrg, "npm-org", e.nonInteractive, () =>
|
|
2310
|
+
let t = await $i(e.npmOrg, "npm-org", e.nonInteractive, () => Se({
|
|
2311
2311
|
message: "npm org (e.g. @platforma-open):",
|
|
2312
2312
|
default: "@platforma-open"
|
|
2313
|
-
})), n = await $i(e.orgScope, "org-scope", e.nonInteractive, () =>
|
|
2314
|
-
i = e.withSoftware === void 0 ? !e.nonInteractive && await
|
|
2313
|
+
})), n = await $i(e.orgScope, "org-scope", e.nonInteractive, () => Se({ message: "org scope (e.g. my-org):" })), r = await $i(e.shortName, "short-name", e.nonInteractive, () => Se({ message: "block short name (e.g. mixcr-clonotyping):" })), i;
|
|
2314
|
+
i = e.withSoftware === void 0 ? !e.nonInteractive && await xe({
|
|
2315
2315
|
message: "Include a software module?",
|
|
2316
2316
|
default: !1
|
|
2317
2317
|
}) : e.withSoftware;
|
|
2318
2318
|
let a;
|
|
2319
2319
|
if (i) {
|
|
2320
|
-
if (a = await $i(e.platform, "platform", e.nonInteractive, () =>
|
|
2320
|
+
if (a = await $i(e.platform, "platform", e.nonInteractive, () => Ce({
|
|
2321
2321
|
message: "Software platform:",
|
|
2322
2322
|
choices: Zi.map((e) => ({
|
|
2323
2323
|
name: e,
|
|
@@ -2335,7 +2335,7 @@ async function ea(e) {
|
|
|
2335
2335
|
};
|
|
2336
2336
|
}
|
|
2337
2337
|
async function ta(e) {
|
|
2338
|
-
let t = e.vars, n = Ln(t), r = new
|
|
2338
|
+
let t = e.vars, n = Ln(t), r = new Ie(e.blockPath), i = new Le(e.templatesRoot), a = Rn({
|
|
2339
2339
|
blockVars: t,
|
|
2340
2340
|
modules: n,
|
|
2341
2341
|
isSdkInternal: !1,
|
|
@@ -2356,9 +2356,9 @@ async function ta(e) {
|
|
|
2356
2356
|
}
|
|
2357
2357
|
// src/cmd/structure/init.ts
|
|
2358
2358
|
function na(e) {
|
|
2359
|
-
let t = new
|
|
2360
|
-
return t.argument("[path]", "target directory (default: <short-name> under the current directory)"), t.option("--npm-org <org>", "npm org, e.g. @platforma-open"), t.option("--org-scope <scope>", "org scope, e.g. my-org"), t.option("--short-name <name>", "block short name, e.g. mixcr-clonotyping"), t.option("--with-software", "include a software module"), t.option("--no-software", "omit the software module"), t.addOption(new
|
|
2361
|
-
let r = new
|
|
2359
|
+
let t = new p("init").description("Scaffold a fresh Platforma block from the canonical structure. Missing flags are prompted unless --non-interactive.");
|
|
2360
|
+
return t.argument("[path]", "target directory (default: <short-name> under the current directory)"), t.option("--npm-org <org>", "npm org, e.g. @platforma-open"), t.option("--org-scope <scope>", "org scope, e.g. my-org"), t.option("--short-name <name>", "block short name, e.g. mixcr-clonotyping"), t.option("--with-software", "include a software module"), t.option("--no-software", "omit the software module"), t.addOption(new m("--platform <platform>", "software platform (single-valued)").choices([...Zi])), t.option("--non-interactive", "error on any missing flag instead of prompting"), t.action(async (t, n) => {
|
|
2361
|
+
let r = new y(), i = n.withSoftware === !0, a = n.software === !1;
|
|
2362
2362
|
if (i && a) throw Error("--with-software and --no-software are mutually exclusive.");
|
|
2363
2363
|
let o = i ? !0 : !a && void 0, s = await ea({
|
|
2364
2364
|
npmOrg: n.npmOrg,
|
|
@@ -2370,8 +2370,8 @@ function na(e) {
|
|
|
2370
2370
|
});
|
|
2371
2371
|
await ta({
|
|
2372
2372
|
vars: s,
|
|
2373
|
-
blockPath: t ?
|
|
2374
|
-
templatesRoot:
|
|
2373
|
+
blockPath: t ? h.resolve(t) : h.resolve(process.cwd(), s.shortName),
|
|
2374
|
+
templatesRoot: h.join(e, "src", "structure", "templates"),
|
|
2375
2375
|
log: (e) => r.info(e)
|
|
2376
2376
|
});
|
|
2377
2377
|
}), t;
|
|
@@ -2385,7 +2385,7 @@ var ra = ["dev", "release"], ia = [
|
|
|
2385
2385
|
], aa = ["local", "remote"];
|
|
2386
2386
|
function oa(e) {
|
|
2387
2387
|
if (e.usePublished) {
|
|
2388
|
-
if (e.variant === "docker" || e.variant === "all") throw
|
|
2388
|
+
if (e.variant === "docker" || e.variant === "all") throw v.CLIError(`--use-published is binary-only and cannot be combined with --variant ${e.variant}`);
|
|
2389
2389
|
return { kind: "binary-existing" };
|
|
2390
2390
|
}
|
|
2391
2391
|
return e.variant === "none" ? { kind: "no-software" } : e.location === void 0 ? { kind: "bare" } : {
|
|
@@ -2399,30 +2399,30 @@ function oa(e) {
|
|
|
2399
2399
|
var sa = "public.ecr.aws", ca = "us-east-1";
|
|
2400
2400
|
function la(e) {
|
|
2401
2401
|
if (process.env.AWS_ACCESS_KEY_ID || process.env.AWS_PROFILE) return;
|
|
2402
|
-
let t = process.env.PL_AWS_PROFILE ??
|
|
2402
|
+
let t = process.env.PL_AWS_PROFILE ?? fe.AWS_DEV_PROFILE;
|
|
2403
2403
|
process.env.AWS_PROFILE = t, e?.debug(`Using AWS profile '${t}' for dev push credentials`);
|
|
2404
2404
|
}
|
|
2405
2405
|
function ua(e) {
|
|
2406
2406
|
return new URL(`https://${e}`).hostname;
|
|
2407
2407
|
}
|
|
2408
2408
|
function da() {
|
|
2409
|
-
return ` aws sso login --profile ${process.env.AWS_PROFILE ?? process.env.PL_AWS_PROFILE ??
|
|
2409
|
+
return ` aws sso login --profile ${process.env.AWS_PROFILE ?? process.env.PL_AWS_PROFILE ?? fe.AWS_DEV_PROFILE}`;
|
|
2410
2410
|
}
|
|
2411
2411
|
async function fa(e, t) {
|
|
2412
2412
|
let n = ua(e);
|
|
2413
|
-
if (n !== sa) throw
|
|
2413
|
+
if (n !== sa) throw v.CLIError(`automatic docker login is only supported for '${sa}', not '${n}'.\nLog in manually, or drop the ecr:// scheme from the push target to opt out.`);
|
|
2414
2414
|
t?.info(`Logging in to ECR registry '${n}'...`);
|
|
2415
2415
|
let r, i;
|
|
2416
2416
|
try {
|
|
2417
|
-
let e = (await new
|
|
2417
|
+
let e = (await new Te({ region: ca }).send(new Ee({}))).authorizationData?.authorizationToken;
|
|
2418
2418
|
if (!e) throw Error("empty authorization token");
|
|
2419
2419
|
let t = Buffer.from(e, "base64").toString("utf8"), n = t.indexOf(":");
|
|
2420
2420
|
if (n < 0) throw Error("malformed authorization token (no ':' separator)");
|
|
2421
2421
|
r = t.slice(0, n), i = t.slice(n + 1);
|
|
2422
2422
|
} catch (e) {
|
|
2423
|
-
throw
|
|
2423
|
+
throw v.CLIError(`failed to obtain an ECR login token for '${n}': ${e instanceof Error ? e.message : String(e)}\nYour AWS/SSO session is likely expired or absent — log in and retry:\n` + da());
|
|
2424
2424
|
}
|
|
2425
|
-
let a =
|
|
2425
|
+
let a = we("docker", [
|
|
2426
2426
|
"login",
|
|
2427
2427
|
"--username",
|
|
2428
2428
|
r,
|
|
@@ -2437,10 +2437,10 @@ async function fa(e, t) {
|
|
|
2437
2437
|
],
|
|
2438
2438
|
env: {
|
|
2439
2439
|
...process.env,
|
|
2440
|
-
HOME: process.env.HOME ||
|
|
2440
|
+
HOME: process.env.HOME || be.homedir()
|
|
2441
2441
|
}
|
|
2442
2442
|
});
|
|
2443
|
-
if (a.error || a.status !== 0) throw
|
|
2443
|
+
if (a.error || a.status !== 0) throw v.CLIError(`'docker login ${n}' failed`);
|
|
2444
2444
|
}
|
|
2445
2445
|
// src/cmd/software/run-build.ts
|
|
2446
2446
|
async function pa(e) {
|
|
@@ -2462,11 +2462,11 @@ async function pa(e) {
|
|
|
2462
2462
|
r.buildDocker && t.buildDockerImages({
|
|
2463
2463
|
ids: a,
|
|
2464
2464
|
registry: r.dockerRegistry,
|
|
2465
|
-
strictPlatformMatching:
|
|
2465
|
+
strictPlatformMatching: _.isCI()
|
|
2466
2466
|
}), await o(), r.pushDocker && t.publishDockerImages({
|
|
2467
2467
|
ids: a,
|
|
2468
2468
|
pushTo: r.dockerPushTo,
|
|
2469
|
-
strictPlatformMatching:
|
|
2469
|
+
strictPlatformMatching: _.isCI()
|
|
2470
2470
|
});
|
|
2471
2471
|
break;
|
|
2472
2472
|
case "target": {
|
|
@@ -2474,18 +2474,18 @@ async function pa(e) {
|
|
|
2474
2474
|
l && t.buildDockerImages({
|
|
2475
2475
|
ids: a,
|
|
2476
2476
|
registry: f.pull,
|
|
2477
|
-
strictPlatformMatching:
|
|
2477
|
+
strictPlatformMatching: _.isCI()
|
|
2478
2478
|
}), u && await o(), d && e === "dev" && (l || u) && la(i), l && d && (f.autoLogin && f.push && await fa(f.push, i), t.publishDockerImages({
|
|
2479
2479
|
ids: a,
|
|
2480
2480
|
pushTo: f.push,
|
|
2481
|
-
strictPlatformMatching:
|
|
2481
|
+
strictPlatformMatching: _.isCI()
|
|
2482
2482
|
})), u && d && await t.publishPackages({
|
|
2483
2483
|
ids: a,
|
|
2484
2484
|
storageURL: r.storageUrl
|
|
2485
2485
|
});
|
|
2486
2486
|
break;
|
|
2487
2487
|
}
|
|
2488
|
-
default:
|
|
2488
|
+
default: v.assertNever(n);
|
|
2489
2489
|
}
|
|
2490
2490
|
t.buildSwJsonFiles({
|
|
2491
2491
|
packageIds: a,
|
|
@@ -2511,10 +2511,10 @@ function _a(e) {
|
|
|
2511
2511
|
};
|
|
2512
2512
|
}
|
|
2513
2513
|
function va(e, t) {
|
|
2514
|
-
let n = e === "dev", r = process.env[n ?
|
|
2514
|
+
let n = e === "dev", r = process.env[n ? _.PL_DEV_DOCKER_PUSH_URL : _.PL_RELEASE_DOCKER_PUSH_URL], i = process.env[n ? _.PL_DEV_DOCKER_PULL_URL : _.PL_RELEASE_DOCKER_PULL_URL], a = t.dockerPushTo ?? r ?? (n ? fe.DEV_DOCKER_PUSH_TARGET : void 0), o = a ? _a(a) : {
|
|
2515
2515
|
registry: void 0,
|
|
2516
2516
|
autoLogin: !1
|
|
2517
|
-
}, s = t.dockerRegistry ?? i ?? (n ? a :
|
|
2517
|
+
}, s = t.dockerRegistry ?? i ?? (n ? a : fe.DOCKER_REGISTRY);
|
|
2518
2518
|
return {
|
|
2519
2519
|
pull: s ? ga(s) : void 0,
|
|
2520
2520
|
push: o.registry,
|
|
@@ -2523,35 +2523,35 @@ function va(e, t) {
|
|
|
2523
2523
|
}
|
|
2524
2524
|
// src/cmd/software/env.ts
|
|
2525
2525
|
var ya = "PL_BUILD_CHANNEL", ba = "PL_BUILD_VARIANT", xa = "PL_BUILD_LOCATION", Sa = "PL_BUILD_USE_PUBLISHED";
|
|
2526
|
-
|
|
2526
|
+
_.PL_DOCKER_REGISTRY_PUSH_TO, _.PL_DEV_DOCKER_PUSH_URL, _.PL_DEV_DOCKER_PULL_URL, _.PL_DEV_BINARY_UPLOAD_URL, _.PL_RELEASE_DOCKER_PUSH_URL, _.PL_RELEASE_DOCKER_PULL_URL, _.PL_RELEASE_BINARY_UPLOAD_URL;
|
|
2527
2527
|
// src/cmd/software/build.ts
|
|
2528
2528
|
function Ca() {
|
|
2529
|
-
let e = new
|
|
2530
|
-
return e.addOption(new
|
|
2529
|
+
let e = new p("build").description("Build a software module for a target and write its .sw.json descriptor (build + push in one pass)");
|
|
2530
|
+
return e.addOption(new m("--channel <channel>", "registry channel to build for").choices([...ra]).env(ya)), e.addOption(new m("--variant <variant>", "artifact kind to build (default: all declared)").choices([...ia]).env(ba)), e.addOption(new m("--location <location>", "where the artifact lands (local = no push)").choices([...aa]).env(xa)), e.addOption(new m("--use-published", "do not build or push; emit a descriptor pointing at the already-published release artifact").env(Sa)), e.addOption(new m("--log-level <level>", "logging level").choices([
|
|
2531
2531
|
"error",
|
|
2532
2532
|
"warn",
|
|
2533
2533
|
"info",
|
|
2534
2534
|
"debug"
|
|
2535
|
-
]).default("info")), e.addOption(new
|
|
2536
|
-
let t =
|
|
2535
|
+
]).default("info")), e.addOption(new m("--package-root <path>", "path to directory with package.json file")), e.addOption(new m("--force", "force action, ignoring automatic safety checks").default(!1)), e.addOption(new m("--version <value>", "override package version (ignore package.json)")), e.addOption(new m("--platform <os-arch>", "{os}-{arch} pair; no effect on cross-platform packages").choices([...v.AllPlatforms]).env(_.PL_PKG_OS)), e.addOption(new m("--all-platforms", "build for all supported platforms").default(!1)), e.addOption(new m("--full-dir-hash", "hash file contents (not metadata) for the dev content hash").env(_.PL_PKG_FULL_HASH).default(!1)), e.addOption(new m("--package-id <id...>", "act only on selected packages")), e.addOption(new m("--content-root <path>", "override software content root").env(_.PL_PKG_CONTENT_ROOT)), e.addOption(new m("--storage-url <url>", "override binary upload registry URL").env(_.PL_PKG_STORAGE_URL)), e.addOption(new m("--docker-registry <registry>", "docker pull registry embedded in the descriptor").env(_.PL_DOCKER_REGISTRY)), e.addOption(new m("--docker-push-to <registry>", "alternative registry for docker push").env(_.PL_DOCKER_REGISTRY_PUSH_TO)), e.addOption(new m("--docker-build", "build docker images").env(_.PL_DOCKER_BUILD).default(!1)), e.addOption(new m("--docker-no-build", "do not build docker images").env(_.PL_DOCKER_NO_BUILD).default(!1)), e.addOption(new m("--docker-autopush", "push docker images after build").env(_.PL_DOCKER_AUTOPUSH).default(!1)), e.addOption(new m("--docker-no-autopush", "do not push docker images").env(_.PL_DOCKER_NO_AUTOPUSH).default(!1)), e.addOption(new m("--conda-build", "build conda environment before packing").env(_.PL_CONDA_BUILD).default(!1)), e.addOption(new m("--conda-no-build", "do not build conda environment").env(_.PL_CONDA_NO_BUILD).default(!1)), e.action(async (e) => {
|
|
2536
|
+
let t = v.createLogger(e.logLevel);
|
|
2537
2537
|
try {
|
|
2538
2538
|
let n = oa({
|
|
2539
2539
|
channel: e.channel,
|
|
2540
2540
|
variant: e.variant,
|
|
2541
2541
|
location: e.location,
|
|
2542
2542
|
usePublished: !!e.usePublished
|
|
2543
|
-
}), r =
|
|
2543
|
+
}), r = de(t, { packageRoot: e.packageRoot });
|
|
2544
2544
|
r.version = e.version, r.targetPlatform = e.platform, r.allPlatforms = !!e.allPlatforms, r.fullDirHash = !!e.fullDirHash;
|
|
2545
|
-
let i =
|
|
2546
|
-
default:
|
|
2545
|
+
let i = v.shouldDoAction({
|
|
2546
|
+
default: _.isCI(),
|
|
2547
2547
|
enable: e.dockerBuild,
|
|
2548
2548
|
disable: e.dockerNoBuild
|
|
2549
|
-
}), a = i &&
|
|
2550
|
-
default:
|
|
2549
|
+
}), a = i && v.shouldDoAction({
|
|
2550
|
+
default: _.isCI() && !r.isPrivate,
|
|
2551
2551
|
enable: e.dockerAutopush,
|
|
2552
2552
|
disable: e.dockerNoAutopush
|
|
2553
2553
|
});
|
|
2554
|
-
n.kind === "bare" &&
|
|
2554
|
+
n.kind === "bare" && ue({
|
|
2555
2555
|
buildDocker: i,
|
|
2556
2556
|
pushDocker: a,
|
|
2557
2557
|
pushDisabledExplicitly: !!e.dockerNoAutopush,
|
|
@@ -2569,7 +2569,7 @@ function Ca() {
|
|
|
2569
2569
|
dockerPushTo: e.dockerPushTo,
|
|
2570
2570
|
buildDocker: i,
|
|
2571
2571
|
pushDocker: a,
|
|
2572
|
-
condaBuild:
|
|
2572
|
+
condaBuild: v.shouldDoAction({
|
|
2573
2573
|
default: !0,
|
|
2574
2574
|
enable: e.condaBuild,
|
|
2575
2575
|
disable: e.condaNoBuild
|
|
@@ -2583,14 +2583,14 @@ function Ca() {
|
|
|
2583
2583
|
}
|
|
2584
2584
|
// src/cmd/software/index.ts
|
|
2585
2585
|
function wa() {
|
|
2586
|
-
let e = new
|
|
2586
|
+
let e = new p("software").description("Build and publish a block's software modules");
|
|
2587
2587
|
return e.addCommand(Ca()), e;
|
|
2588
2588
|
}
|
|
2589
2589
|
// src/cli.ts
|
|
2590
2590
|
function Ta(e = process.cwd()) {
|
|
2591
|
-
let t = new
|
|
2592
|
-
t.name("block-tools").description("Utility to manipulate Platforma Blocks and Block Registry"), t.addCommand(
|
|
2593
|
-
let n = new
|
|
2591
|
+
let t = new p();
|
|
2592
|
+
t.name("block-tools").description("Utility to manipulate Platforma Blocks and Block Registry"), t.addCommand(De()), t.addCommand(ke()), t.addCommand(Ae()), t.addCommand(je()), t.addCommand(Ne()), t.addCommand(Pe()), t.addCommand(Fe()), t.addCommand(Ui(e)), t.addCommand(Wi()), t.addCommand(Gi()), t.addCommand(Yi()), t.addCommand(wa());
|
|
2593
|
+
let n = new p("structure").description("Manage block scaffolding against the canonical structure (check / init / refresh)");
|
|
2594
2594
|
return n.addCommand(Xi(e)), n.addCommand(na(e)), n.addCommand(Hi(e)), t.addCommand(n), t;
|
|
2595
2595
|
}
|
|
2596
2596
|
async function Ea(e, t) {
|