@platforma-sdk/block-tools 2.20.5 → 2.21.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 +10 -7
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +580 -569
- package/dist/cli.mjs.map +1 -1
- package/dist/structure/engine/api.d.ts +3 -0
- package/dist/structure/engine/ctx.d.ts +1 -0
- package/dist/structure/engine/version.d.ts +6 -1
- package/package.json +2 -2
- package/src/structure/__tests__/root-ci-workflows.test.ts +51 -0
- package/src/structure/engine/api.ts +3 -0
- package/src/structure/engine/ctx.ts +2 -0
- package/src/structure/engine/discovery-fs.ts +1 -0
- package/src/structure/engine/runner.ts +2 -2
- package/src/structure/engine/version.ts +17 -4
- package/src/structure/rules/root-ci.ts +10 -0
- package/src/structure/templates/text/workflows/build.tpl.yaml +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
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
|
|
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 p, vt as te, wt as ne } from "./config-BusBoNIz.mjs";
|
|
2
|
+
import { Command as m, Option as h } from "commander";
|
|
3
|
+
import g from "node:path";
|
|
4
|
+
import _, { globSync as re, statSync as ie } from "node:fs";
|
|
5
|
+
import { BlockPackManifest as ae, StableChannel as oe, overrideDescriptionVersion as se, overrideManifestVersion as ce } from "@milaboratories/pl-model-middle-layer";
|
|
6
|
+
import { assertDockerPushIntent as le, createBuilder as ue, defaults as de, envs as v, util as y } from "@platforma-sdk/package-builder-lib";
|
|
7
|
+
import { ConsoleLoggerAdapter as b } from "@milaboratories/ts-helpers";
|
|
8
|
+
import fe, { isMap as pe, isSeq as me, parse as he, parseDocument as ge, stringify as _e } from "yaml";
|
|
9
|
+
import { setTimeout as ve } from "node:timers/promises";
|
|
10
|
+
import * as ye from "node:os";
|
|
11
|
+
import { confirm as be, input as xe, select as Se } from "@inquirer/prompts";
|
|
12
|
+
import { spawnSync as Ce } from "node:child_process";
|
|
13
|
+
import { ECRPUBLICClient as we, GetAuthorizationTokenCommand as Te } from "@aws-sdk/client-ecr-public";
|
|
14
14
|
// src/cmd/build-meta.ts
|
|
15
|
-
function
|
|
16
|
-
let e = new
|
|
15
|
+
function Ee() {
|
|
16
|
+
let e = new m("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 = g.resolve(e.modulePath), n = await d(t), i = await a(await r(n.meta, t));
|
|
19
|
+
await _.promises.writeFile(g.resolve(e.destination), JSON.stringify(i));
|
|
20
20
|
}), e;
|
|
21
21
|
}
|
|
22
22
|
// src/cmd/build-model.ts
|
|
23
|
-
async function
|
|
23
|
+
async function De(e) {
|
|
24
24
|
try {
|
|
25
|
-
return await
|
|
25
|
+
return await _.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 Oe() {
|
|
32
|
+
let e = new m("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 = g.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 De(e.sourceBundle);
|
|
40
40
|
a !== void 0 && (i.code = {
|
|
41
41
|
type: "plain",
|
|
42
42
|
content: a
|
|
43
|
-
}), await
|
|
43
|
+
}), await _.promises.writeFile(g.resolve(e.destination), JSON.stringify(i));
|
|
44
44
|
}), e;
|
|
45
45
|
}
|
|
46
46
|
// src/cmd/build-kind-manifest.ts
|
|
47
|
-
function
|
|
48
|
-
let e = new
|
|
47
|
+
function ke() {
|
|
48
|
+
let e = new m("build-kind-manifest").description("Writes the block-kind dist manifest (identity + src source-hash) from a pre-built kind bundle");
|
|
49
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
|
|
50
|
+
await ne({
|
|
51
51
|
modulePath: e.modulePath,
|
|
52
52
|
srcDir: e.srcDir,
|
|
53
53
|
dst: e.dst
|
|
@@ -55,80 +55,80 @@ function Ae() {
|
|
|
55
55
|
}), e;
|
|
56
56
|
}
|
|
57
57
|
// src/cmd/pack.ts
|
|
58
|
-
function
|
|
59
|
-
let e = new
|
|
58
|
+
function Ae() {
|
|
59
|
+
let e = new m("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 c(t,
|
|
61
|
+
let t = await te(g.resolve(e.modulePath));
|
|
62
|
+
await c(t, g.resolve(e.destinationPath));
|
|
63
63
|
}), e;
|
|
64
64
|
}
|
|
65
65
|
// src/cmd/publish.ts
|
|
66
|
-
function
|
|
66
|
+
function je(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]) ? je(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 n = new
|
|
75
|
-
a =
|
|
76
|
-
let o =
|
|
77
|
-
n.info(`Manifest root = ${o}`), n.info(`Facade root = ${c}`), e.versionOverride && (a =
|
|
78
|
-
let d =
|
|
79
|
-
await u(f, a, c, async (e) => Buffer.from(await
|
|
71
|
+
function Me() {
|
|
72
|
+
let e = new m("publish").description("Publishes the block package and refreshes the registry (for v2 block-pack schema)");
|
|
73
|
+
return e.addOption(new h("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new h("--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 h("--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 h("--unstable", "do not add the published package to stable channel").default(!1).env("PL_PUBLISH_UNSTABLE")), e.action(async (e) => {
|
|
74
|
+
let n = new b(), r = g.resolve(e.manifest), i = JSON.parse(await _.promises.readFile(r, { encoding: "utf-8" })), a = ae.parse(i);
|
|
75
|
+
a = je(i, a);
|
|
76
|
+
let o = g.dirname(r), c = g.dirname(o);
|
|
77
|
+
n.info(`Manifest root = ${o}`), n.info(`Facade root = ${c}`), e.versionOverride && (a = ce(a, e.versionOverride));
|
|
78
|
+
let d = p(e.registry), f = new s(d, n);
|
|
79
|
+
await u(f, a, c, async (e) => Buffer.from(await _.promises.readFile(g.resolve(o, e)))), e.unstable || (n.info(`Adding package to ${oe} channel...`), await f.addPackageToChannel(a.description.id, oe));
|
|
80
80
|
let ee = t({
|
|
81
81
|
registryUrl: e.registryServeUrl,
|
|
82
82
|
id: a.description.id
|
|
83
83
|
});
|
|
84
|
-
await l(o, ee), n.info(`Wrote published coordinates to ${
|
|
84
|
+
await l(o, ee), n.info(`Wrote published coordinates to ${g.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 Ne() {
|
|
89
|
+
let e = new m("refresh-registry").description("Refresh overview files based on published but not proecessed artefacts");
|
|
90
|
+
return e.addOption(new h("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new h("-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 s(t, new
|
|
95
|
+
let t = p(e.registry);
|
|
96
|
+
await new s(t, new b()).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 d(
|
|
104
|
-
e.versionOverride && (t =
|
|
105
|
-
let n =
|
|
100
|
+
function Pe() {
|
|
101
|
+
let e = new m("mark-stable").description("Mark target block stable");
|
|
102
|
+
return e.option("-i, --modulePath <path>", "input module path", "."), e.addOption(new h("-c, --channel <channel name>", "custom channel").default(oe).hideHelp()), e.option("-v, --version-override <path>", "override package version"), e.addOption(new h("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new h("--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(g.resolve(e.modulePath));
|
|
104
|
+
e.versionOverride && (t = se(t, e.versionOverride));
|
|
105
|
+
let n = p(e.registry), r = new s(n, new b());
|
|
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 Fe = class {
|
|
111
111
|
root;
|
|
112
112
|
constructor(e) {
|
|
113
113
|
this.root = e;
|
|
114
114
|
}
|
|
115
115
|
abs(e) {
|
|
116
|
-
return
|
|
116
|
+
return g.resolve(this.root, e);
|
|
117
117
|
}
|
|
118
118
|
read(e) {
|
|
119
|
-
return
|
|
119
|
+
return _.readFileSync(this.abs(e), "utf-8");
|
|
120
120
|
}
|
|
121
121
|
write(e, t) {
|
|
122
122
|
let n = this.abs(e);
|
|
123
|
-
|
|
123
|
+
_.mkdirSync(g.dirname(n), { recursive: !0 }), _.writeFileSync(n, t, "utf-8");
|
|
124
124
|
}
|
|
125
125
|
writeBinary(e, t) {
|
|
126
126
|
let n = this.abs(e);
|
|
127
|
-
|
|
127
|
+
_.mkdirSync(g.dirname(n), { recursive: !0 }), _.writeFileSync(n, t);
|
|
128
128
|
}
|
|
129
129
|
exists(e) {
|
|
130
130
|
try {
|
|
131
|
-
return
|
|
131
|
+
return _.statSync(this.abs(e)), !0;
|
|
132
132
|
} catch {
|
|
133
133
|
return !1;
|
|
134
134
|
}
|
|
@@ -136,15 +136,15 @@ var Ie = class {
|
|
|
136
136
|
list(e) {
|
|
137
137
|
let t = this.abs(e);
|
|
138
138
|
try {
|
|
139
|
-
if (!
|
|
139
|
+
if (!_.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 = _.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 = g.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 Ie = class {
|
|
|
153
153
|
listDir(e) {
|
|
154
154
|
let t = this.abs(e), n;
|
|
155
155
|
try {
|
|
156
|
-
n =
|
|
156
|
+
n = _.readdirSync(t, { withFileTypes: !0 });
|
|
157
157
|
} catch {
|
|
158
158
|
return [];
|
|
159
159
|
}
|
|
@@ -164,77 +164,77 @@ var Ie = class {
|
|
|
164
164
|
}
|
|
165
165
|
move(e, t) {
|
|
166
166
|
let n = this.abs(e), r = this.abs(t);
|
|
167
|
-
|
|
167
|
+
_.mkdirSync(g.dirname(r), { recursive: !0 }), _.renameSync(n, r);
|
|
168
168
|
}
|
|
169
169
|
delete(e) {
|
|
170
|
-
|
|
170
|
+
_.rmSync(this.abs(e), {
|
|
171
171
|
recursive: !0,
|
|
172
172
|
force: !0
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
-
},
|
|
175
|
+
}, Ie = class {
|
|
176
176
|
root;
|
|
177
177
|
constructor(e) {
|
|
178
178
|
this.root = e;
|
|
179
179
|
}
|
|
180
180
|
staticRead(e) {
|
|
181
|
-
return
|
|
181
|
+
return _.readFileSync(g.resolve(this.root, "static", e), "utf-8");
|
|
182
182
|
}
|
|
183
183
|
staticReadBinary(e) {
|
|
184
|
-
return
|
|
184
|
+
return _.readFileSync(g.resolve(this.root, "static", e));
|
|
185
185
|
}
|
|
186
186
|
textRead(e) {
|
|
187
|
-
return
|
|
187
|
+
return _.readFileSync(g.resolve(this.root, "text", e), "utf-8");
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
|
-
function
|
|
190
|
+
function Le(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 Re = ["default", "init"];
|
|
195
|
+
function ze(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 Be(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 Ve(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 = Be(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 '${Ue(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: ze(a, e.from),
|
|
221
|
+
resolvedTo: ze(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: ze(a, He(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, [], Re);
|
|
235
235
|
return n;
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function He(e) {
|
|
238
238
|
switch (e.kind) {
|
|
239
239
|
case "fixed":
|
|
240
240
|
case "managed":
|
|
@@ -244,61 +244,61 @@ function Ue(e) {
|
|
|
244
244
|
case "rename": return e.from;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function Ue(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 We = /[.+^${}()|[\]\\]/g;
|
|
252
|
+
function Ge(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(We, "\\$&");
|
|
257
257
|
}
|
|
258
258
|
return RegExp(`^${t}$`);
|
|
259
259
|
}
|
|
260
|
-
function
|
|
261
|
-
return
|
|
260
|
+
function Ke(e, t) {
|
|
261
|
+
return Ge(e).test(t);
|
|
262
262
|
}
|
|
263
263
|
// src/structure/engine/builders.ts
|
|
264
|
-
var
|
|
265
|
-
function
|
|
266
|
-
if (!
|
|
267
|
-
return
|
|
264
|
+
var x, qe;
|
|
265
|
+
function Je(e) {
|
|
266
|
+
if (!x) throw Error(`${e}() called outside defineStructure(). Builders must run inside the lambda passed to defineStructure(...).`);
|
|
267
|
+
return x;
|
|
268
268
|
}
|
|
269
|
-
function
|
|
270
|
-
let n =
|
|
269
|
+
function Ye(e, t) {
|
|
270
|
+
let n = Je(e);
|
|
271
271
|
n.stack[n.stack.length - 1].push(t);
|
|
272
272
|
}
|
|
273
|
-
function
|
|
274
|
-
let n =
|
|
275
|
-
|
|
273
|
+
function Xe(e, t) {
|
|
274
|
+
let n = qe;
|
|
275
|
+
qe = e;
|
|
276
276
|
try {
|
|
277
277
|
return t();
|
|
278
278
|
} finally {
|
|
279
|
-
|
|
279
|
+
qe = n;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
return
|
|
282
|
+
function Ze() {
|
|
283
|
+
return qe;
|
|
284
284
|
}
|
|
285
|
-
function
|
|
286
|
-
if (
|
|
285
|
+
function Qe(e) {
|
|
286
|
+
if (x) 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
|
+
x = 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 $e(r), r;
|
|
297
297
|
} finally {
|
|
298
|
-
|
|
298
|
+
x = void 0;
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
function
|
|
301
|
+
function $e(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 et(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 S(e, t) {
|
|
325
|
+
let n = Je("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 x(e, t) {
|
|
|
336
336
|
n.stack.pop(), n.inScope = !1;
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
var
|
|
340
|
-
function
|
|
341
|
-
|
|
339
|
+
var et;
|
|
340
|
+
function tt(e) {
|
|
341
|
+
et = e;
|
|
342
342
|
}
|
|
343
|
-
function
|
|
344
|
-
|
|
343
|
+
function C(e, t, n) {
|
|
344
|
+
nt(e, t), n && nt((t) => !e(t), n);
|
|
345
345
|
}
|
|
346
|
-
function
|
|
347
|
-
if (
|
|
348
|
-
else if (!(
|
|
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.");
|
|
349
349
|
}
|
|
350
|
-
function
|
|
351
|
-
let n =
|
|
350
|
+
function rt(e, t) {
|
|
351
|
+
let n = x, r = {
|
|
352
352
|
kind: "when",
|
|
353
353
|
trigger: e,
|
|
354
354
|
children: []
|
|
@@ -360,11 +360,11 @@ function it(e, t) {
|
|
|
360
360
|
n.stack.pop();
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function w(e) {
|
|
364
364
|
return (t) => t.filesMatch(e);
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
let r =
|
|
366
|
+
function it(e, t, n) {
|
|
367
|
+
let r = Je(e), i = {
|
|
368
368
|
kind: "mode",
|
|
369
369
|
modes: t,
|
|
370
370
|
children: []
|
|
@@ -376,140 +376,140 @@ function at(e, t, n) {
|
|
|
376
376
|
r.stack.pop();
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
function
|
|
380
|
-
|
|
379
|
+
function at(e) {
|
|
380
|
+
it("onInitOrUpdate", ["init", "updateDeps"], e);
|
|
381
381
|
}
|
|
382
|
-
function
|
|
383
|
-
|
|
382
|
+
function T(e, t) {
|
|
383
|
+
Ye("fixed", {
|
|
384
384
|
kind: "fixed",
|
|
385
385
|
path: e,
|
|
386
386
|
content: t
|
|
387
387
|
});
|
|
388
388
|
}
|
|
389
|
-
function
|
|
390
|
-
|
|
389
|
+
function E(e, t, n) {
|
|
390
|
+
Ye("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 D(e, t) {
|
|
398
|
+
Ye("scaffold", {
|
|
399
399
|
kind: "scaffold",
|
|
400
400
|
path: e,
|
|
401
401
|
initial: t
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
|
-
function
|
|
405
|
-
|
|
404
|
+
function O(e, t) {
|
|
405
|
+
Ye("seed", {
|
|
406
406
|
kind: "seed",
|
|
407
407
|
path: e,
|
|
408
408
|
initial: t
|
|
409
409
|
});
|
|
410
410
|
}
|
|
411
|
-
function
|
|
412
|
-
|
|
411
|
+
function k(e) {
|
|
412
|
+
Ye("remove", {
|
|
413
413
|
kind: "remove",
|
|
414
414
|
path: e
|
|
415
415
|
});
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function A(e) {
|
|
418
418
|
return {
|
|
419
419
|
kind: "file",
|
|
420
420
|
path: e
|
|
421
421
|
};
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function ot(e) {
|
|
424
424
|
return {
|
|
425
425
|
kind: "binary",
|
|
426
426
|
path: e
|
|
427
427
|
};
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function st(e) {
|
|
430
430
|
return {
|
|
431
431
|
kind: "text",
|
|
432
432
|
value: e
|
|
433
433
|
};
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function j(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 M(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 ct = /* @__PURE__ */ e(n());
|
|
450
|
+
function lt(e) {
|
|
451
451
|
return JSON.parse(e);
|
|
452
452
|
}
|
|
453
|
-
var
|
|
454
|
-
function
|
|
455
|
-
return e.length === 0 ? "[]" : "[" + e.map(
|
|
453
|
+
var ut = 100, dt = 2;
|
|
454
|
+
function ft(e) {
|
|
455
|
+
return e.length === 0 ? "[]" : "[" + e.map(pt).join(", ") + "]";
|
|
456
456
|
}
|
|
457
|
-
function
|
|
458
|
-
if (Array.isArray(e)) return
|
|
459
|
-
if (
|
|
457
|
+
function pt(e) {
|
|
458
|
+
if (Array.isArray(e)) return ft(e);
|
|
459
|
+
if (N(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)}: ${pt(t)}`).join(", ") + " }";
|
|
462
462
|
}
|
|
463
463
|
return JSON.stringify(e);
|
|
464
464
|
}
|
|
465
|
-
function
|
|
466
|
-
let i = t +
|
|
465
|
+
function mt(e, t, n, r) {
|
|
466
|
+
let i = t + dt, a = " ".repeat(i);
|
|
467
467
|
if (Array.isArray(e)) {
|
|
468
|
-
let o =
|
|
469
|
-
if (n + o.length + r <=
|
|
468
|
+
let o = ft(e);
|
|
469
|
+
if (n + o.length + r <= ut) 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 + mt(e, i, i, t === s ? 0 : 1)).join(",\n") + "\n" + " ".repeat(t) + "]";
|
|
472
472
|
}
|
|
473
|
-
if (
|
|
473
|
+
if (N(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 + mt(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 ht(e, t) {
|
|
485
|
+
return t?.collapse ? mt(JSON.parse(JSON.stringify(e ?? null)), 0, 0, 0) + "\n" : JSON.stringify(e, null, 2) + "\n";
|
|
486
486
|
}
|
|
487
|
-
function
|
|
487
|
+
function gt(e) {
|
|
488
488
|
return e === "" || e === void 0 ? [] : e.split(".");
|
|
489
489
|
}
|
|
490
|
-
function
|
|
490
|
+
function N(e) {
|
|
491
491
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
492
492
|
}
|
|
493
|
-
function
|
|
494
|
-
let n =
|
|
493
|
+
function _t(e, t) {
|
|
494
|
+
let n = gt(t), r = e;
|
|
495
495
|
for (let e of n) {
|
|
496
|
-
if (!
|
|
496
|
+
if (!N(r)) return;
|
|
497
497
|
r = r[e];
|
|
498
498
|
}
|
|
499
499
|
return r;
|
|
500
500
|
}
|
|
501
|
-
function
|
|
502
|
-
let n =
|
|
501
|
+
function vt(e, t) {
|
|
502
|
+
let n = gt(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 (!N(r)) return !1;
|
|
507
507
|
r = r[n[e]];
|
|
508
508
|
}
|
|
509
|
-
return
|
|
509
|
+
return N(r) ? n[n.length - 1] in r : !1;
|
|
510
510
|
}
|
|
511
|
-
function
|
|
512
|
-
let r =
|
|
511
|
+
function yt(e, t, n) {
|
|
512
|
+
let r = gt(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 bt(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 (N(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 bt(e, t) {
|
|
526
|
+
let n = gt(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 (!N(r)) return;
|
|
531
531
|
r = r[n[e]];
|
|
532
532
|
}
|
|
533
|
-
|
|
533
|
+
N(r) && delete r[n[n.length - 1]];
|
|
534
534
|
}
|
|
535
|
-
function
|
|
535
|
+
function xt(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 St(e, t) {
|
|
|
546
546
|
return o;
|
|
547
547
|
}
|
|
548
548
|
// src/structure/engine/parsers/lines.ts
|
|
549
|
-
function
|
|
549
|
+
function St(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 Ct(e) {
|
|
554
554
|
return e.join("\n") + "\n";
|
|
555
555
|
}
|
|
556
|
-
function
|
|
556
|
+
function wt(e) {
|
|
557
557
|
return e.replace(/(^|\s)#.*$/, "$1").trim();
|
|
558
558
|
}
|
|
559
|
-
function
|
|
560
|
-
let n =
|
|
559
|
+
function Tt(e, t) {
|
|
560
|
+
let n = wt(e);
|
|
561
561
|
return n !== "" && n === t.trim();
|
|
562
562
|
}
|
|
563
|
-
function
|
|
564
|
-
for (let n of e) if (
|
|
563
|
+
function Et(e, t) {
|
|
564
|
+
for (let n of e) if (Tt(n, t)) return !0;
|
|
565
565
|
return !1;
|
|
566
566
|
}
|
|
567
567
|
// src/structure/engine/content-rules.ts
|
|
568
|
-
function
|
|
568
|
+
function Dt(e, t) {
|
|
569
569
|
return e === "sdk:" ? t ? "workspace:*" : "catalog:" : e;
|
|
570
570
|
}
|
|
571
|
-
var
|
|
571
|
+
var Ot = [
|
|
572
572
|
"dependencies",
|
|
573
573
|
"devDependencies",
|
|
574
574
|
"peerDependencies",
|
|
575
575
|
"optionalDependencies"
|
|
576
576
|
];
|
|
577
|
-
function
|
|
578
|
-
if (
|
|
577
|
+
function kt(e, t) {
|
|
578
|
+
if (L(e)) for (let n of Ot) {
|
|
579
579
|
let r = e[n];
|
|
580
|
-
if (
|
|
580
|
+
if (L(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 P;
|
|
584
|
+
function At(e) {
|
|
585
|
+
if (!P) throw Error(`${e}() only valid inside a managed(...) body. Move this call inside managed(path, initial, () => {...}).`);
|
|
586
|
+
return P;
|
|
587
587
|
}
|
|
588
|
-
function
|
|
589
|
-
let t =
|
|
588
|
+
function F(e) {
|
|
589
|
+
let t = At(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 I(e) {
|
|
594
|
+
let t = At(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 jt(e) {
|
|
599
|
+
let t = At(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 Mt(e, t) {
|
|
604
|
+
let n = e.ctx ?? Ze();
|
|
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 L(e) {
|
|
609
609
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
610
610
|
}
|
|
611
|
-
function
|
|
612
|
-
if (
|
|
613
|
-
|
|
611
|
+
function Nt(e, t, n = {}) {
|
|
612
|
+
if (P) throw Error("Nested managed(...) body — engine bug.");
|
|
613
|
+
P = {
|
|
614
614
|
kind: "json",
|
|
615
615
|
obj: e,
|
|
616
616
|
ctx: n.ctx,
|
|
@@ -619,12 +619,12 @@ function Pt(e, t, n = {}) {
|
|
|
619
619
|
try {
|
|
620
620
|
return t(n.ctx ?? n.triggerContext?.ctx), e;
|
|
621
621
|
} finally {
|
|
622
|
-
|
|
622
|
+
P = void 0;
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
|
-
function
|
|
626
|
-
if (
|
|
627
|
-
|
|
625
|
+
function Pt(e, t, n = {}) {
|
|
626
|
+
if (P) throw Error("Nested managed(...) body — engine bug.");
|
|
627
|
+
P = {
|
|
628
628
|
kind: "yaml",
|
|
629
629
|
doc: e,
|
|
630
630
|
ctx: n.ctx,
|
|
@@ -635,12 +635,12 @@ function Ft(e, t, n = {}) {
|
|
|
635
635
|
try {
|
|
636
636
|
return t(n.ctx ?? n.triggerContext?.ctx), e;
|
|
637
637
|
} finally {
|
|
638
|
-
|
|
638
|
+
P = void 0;
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
|
-
function
|
|
642
|
-
if (
|
|
643
|
-
|
|
641
|
+
function Ft(e, t, n = {}) {
|
|
642
|
+
if (P) throw Error("Nested managed(...) body — engine bug.");
|
|
643
|
+
P = {
|
|
644
644
|
kind: "lines",
|
|
645
645
|
lines: e,
|
|
646
646
|
ctx: n.ctx,
|
|
@@ -649,81 +649,81 @@ function It(e, t, n = {}) {
|
|
|
649
649
|
try {
|
|
650
650
|
return t(n.ctx ?? n.triggerContext?.ctx), e;
|
|
651
651
|
} finally {
|
|
652
|
-
|
|
652
|
+
P = void 0;
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
|
-
|
|
656
|
-
if (!
|
|
657
|
-
let n =
|
|
655
|
+
tt((e, t) => {
|
|
656
|
+
if (!P) return !1;
|
|
657
|
+
let n = P.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 L(e, t) {
|
|
662
|
-
bt(P("ensureField").obj, e, t);
|
|
663
|
-
}
|
|
664
661
|
function R(e, t) {
|
|
665
|
-
|
|
666
|
-
|
|
662
|
+
yt(F("ensureField").obj, e, t);
|
|
663
|
+
}
|
|
664
|
+
function z(e, t) {
|
|
665
|
+
let n = F("removeField").obj;
|
|
666
|
+
vt(n, e) && (!t || t(_t(n, e))) && bt(n, e);
|
|
667
|
+
}
|
|
668
|
+
function It(e, t) {
|
|
669
|
+
let n = F("requireField").obj;
|
|
670
|
+
if (!vt(n, e)) throw Error(t ?? `requireField: missing field '${e}'`);
|
|
667
671
|
}
|
|
668
672
|
function Lt(e, t) {
|
|
669
|
-
|
|
670
|
-
if (!yt(n, e)) throw Error(t ?? `requireField: missing field '${e}'`);
|
|
673
|
+
if (vt(F("forbidField").obj, e)) throw Error(t);
|
|
671
674
|
}
|
|
672
675
|
function Rt(e, t) {
|
|
673
|
-
|
|
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 : {};
|
|
676
|
+
let n = F("ensureFieldEntries").obj, r = vt(n, e) ? _t(n, e) : void 0, i = L(r) ? r : {};
|
|
677
677
|
for (let [e, n] of Object.entries(t)) i[e] = n;
|
|
678
|
-
|
|
678
|
+
L(r) || yt(n, e, i);
|
|
679
679
|
}
|
|
680
|
-
function
|
|
681
|
-
|
|
680
|
+
function B(e, t) {
|
|
681
|
+
R(`scripts.${e}`, t);
|
|
682
682
|
}
|
|
683
|
-
function
|
|
684
|
-
|
|
683
|
+
function V(e) {
|
|
684
|
+
z(`scripts.${e}`);
|
|
685
685
|
}
|
|
686
|
-
var
|
|
686
|
+
var zt = [
|
|
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 Bt(e, t, n, r) {
|
|
693
|
+
let i = F(e), a = i.obj, o = n === "sdk:" ? Dt(n, Mt(i, e).isSdkInternal) : n;
|
|
694
|
+
for (let e of zt) {
|
|
695
695
|
if (e === r) continue;
|
|
696
696
|
let n = a[e];
|
|
697
|
-
|
|
697
|
+
L(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 = L(s) ? s : {};
|
|
700
|
+
c[t] = o, L(s) || (a[r] = c);
|
|
701
701
|
}
|
|
702
|
-
function
|
|
703
|
-
|
|
702
|
+
function Vt(e, t) {
|
|
703
|
+
Bt("ensureDep", e, t, "dependencies");
|
|
704
704
|
}
|
|
705
|
-
function
|
|
706
|
-
|
|
705
|
+
function H(e, t) {
|
|
706
|
+
Bt("ensureDevDep", e, t, "devDependencies");
|
|
707
707
|
}
|
|
708
|
-
function
|
|
709
|
-
|
|
708
|
+
function Ht(e, t) {
|
|
709
|
+
Bt("ensurePeerDep", e, t, "peerDependencies");
|
|
710
710
|
}
|
|
711
|
-
function
|
|
712
|
-
let t =
|
|
713
|
-
for (let n of
|
|
711
|
+
function U(e) {
|
|
712
|
+
let t = F("removeDep").obj;
|
|
713
|
+
for (let n of zt) {
|
|
714
714
|
let r = t[n];
|
|
715
|
-
|
|
715
|
+
L(r) && e in r && delete r[e];
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
-
function U(e) {
|
|
719
|
-
for (let [t, n] of Object.entries(e)) V(t, n);
|
|
720
|
-
}
|
|
721
718
|
function W(e) {
|
|
722
|
-
for (let [t, n] of Object.entries(e))
|
|
719
|
+
for (let [t, n] of Object.entries(e)) H(t, n);
|
|
720
|
+
}
|
|
721
|
+
function Ut(e) {
|
|
722
|
+
for (let [t, n] of Object.entries(e)) Ht(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 = Mt(F(e), e);
|
|
726
|
+
for (let i of r.modules) i.scope === t && Bt(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 = F("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 = xt(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(F("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 && L(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 = F("enforceAlphabeticalOrder").obj;
|
|
756
756
|
if (e === "") {
|
|
757
757
|
Yt(r, !0);
|
|
758
758
|
return;
|
|
759
759
|
}
|
|
760
|
-
let i =
|
|
761
|
-
|
|
760
|
+
let i = _t(r, e);
|
|
761
|
+
L(i) && Yt(i, n);
|
|
762
762
|
}
|
|
763
763
|
function Xt(e, t) {
|
|
764
|
-
let n =
|
|
765
|
-
|
|
764
|
+
let n = F("transformAt").obj;
|
|
765
|
+
yt(n, e, t(_t(n, e)));
|
|
766
766
|
}
|
|
767
767
|
function Zt() {
|
|
768
|
-
let e =
|
|
768
|
+
let e = I("ensureWorkspaceModulePaths"), t = Mt(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 = I("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 = I("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 = I("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 = I("ensureCatalogAtLeast"), r = Qt(n, e), i = (0, ct.minVersion)(t), a = r !== void 0 && (0, ct.validRange)(r) !== null ? (0, ct.minVersion)(r) : null;
|
|
793
|
+
(r === void 0 || i !== null && a !== null && !(0, ct.gte)(a, i)) && n.doc.setIn(["catalog", e], t);
|
|
794
794
|
}
|
|
795
795
|
function rn(e) {
|
|
796
|
-
let t =
|
|
796
|
+
let t = I("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 = I("ensureWorkspaceMapEntries");
|
|
801
|
+
pe(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 = I("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 (!me(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 = jt("ensureGitignoreEntries");
|
|
814
|
+
for (let n of e) Et(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 ge(e);
|
|
819
819
|
}
|
|
820
820
|
function ln(e) {
|
|
821
821
|
return e.toString();
|
|
@@ -824,8 +824,8 @@ var un = ".structure";
|
|
|
824
824
|
function dn(e) {
|
|
825
825
|
if (!e.exists(".structure")) return { version: 0 };
|
|
826
826
|
try {
|
|
827
|
-
let t = JSON.parse(e.read(un));
|
|
828
|
-
return
|
|
827
|
+
let t = JSON.parse(e.read(un)), n = { version: typeof t?.version == "number" ? t.version : 0 };
|
|
828
|
+
return t?.ownNpmRegistry === !0 && (n.ownNpmRegistry = !0), n;
|
|
829
829
|
} catch {
|
|
830
830
|
return { version: 0 };
|
|
831
831
|
}
|
|
@@ -841,7 +841,8 @@ var pn = class extends Error {
|
|
|
841
841
|
}
|
|
842
842
|
};
|
|
843
843
|
function mn(e, t) {
|
|
844
|
-
|
|
844
|
+
let n = { version: t.version };
|
|
845
|
+
t.ownNpmRegistry === !0 && (n.ownNpmRegistry = !0), e.write(un, JSON.stringify(n));
|
|
845
846
|
}
|
|
846
847
|
// src/structure/engine/runner.ts
|
|
847
848
|
var hn = class extends Error {
|
|
@@ -858,11 +859,11 @@ function gn(e, t, n, r) {
|
|
|
858
859
|
return n.staticRead(e.path);
|
|
859
860
|
case "tpl":
|
|
860
861
|
if (!n) throw Error(`tpl('${e.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);
|
|
861
|
-
return
|
|
862
|
+
return Le(n.textRead(e.path), typeof e.vars == "function" ? e.vars(r) : e.vars);
|
|
862
863
|
case "generate": {
|
|
863
864
|
let n = e.fn(r);
|
|
864
|
-
if (t.endsWith(".json")) return
|
|
865
|
-
if (t.endsWith(".yaml") || t.endsWith(".yml")) return
|
|
865
|
+
if (t.endsWith(".json")) return kt(n, r.isSdkInternal), ht(n, { collapse: !t.endsWith("package.json") });
|
|
866
|
+
if (t.endsWith(".yaml") || t.endsWith(".yml")) return _e(n);
|
|
866
867
|
if (typeof n != "string") throw Error(`generate() for '${t}' must return a string for non-JSON/YAML files; got ${typeof n}`);
|
|
867
868
|
return n;
|
|
868
869
|
}
|
|
@@ -878,21 +879,21 @@ function _n(e, t, n, r, i) {
|
|
|
878
879
|
function vn(e, t, n, r, i, a) {
|
|
879
880
|
let o = e.split("/").pop() ?? e;
|
|
880
881
|
if (e.endsWith(".json")) {
|
|
881
|
-
let i =
|
|
882
|
+
let i = lt(t);
|
|
882
883
|
if (typeof i != "object" || !i || Array.isArray(i)) throw Error(`managed: parsed value at '${e}' is not a JSON object`);
|
|
883
|
-
return
|
|
884
|
+
return Nt(i, n, { triggerContext: r }), ht(i, { collapse: o !== "package.json" });
|
|
884
885
|
}
|
|
885
886
|
if (e.endsWith(".yaml") || e.endsWith(".yml")) {
|
|
886
887
|
let e = cn(t);
|
|
887
|
-
return
|
|
888
|
+
return Pt(e, n, {
|
|
888
889
|
triggerContext: r,
|
|
889
890
|
getLatestVersion: i,
|
|
890
891
|
getDerivedDependencyPin: a
|
|
891
892
|
}), ln(e);
|
|
892
893
|
}
|
|
893
894
|
if (o === ".gitignore" || o.endsWith(".gitignore")) {
|
|
894
|
-
let e =
|
|
895
|
-
return
|
|
895
|
+
let e = St(t);
|
|
896
|
+
return Ft(e, n, { triggerContext: r }), Ct(e);
|
|
896
897
|
}
|
|
897
898
|
throw Error(`managed('${e}'): unsupported file kind. Only .json, .yaml, .yml, .gitignore are dispatched.`);
|
|
898
899
|
}
|
|
@@ -917,7 +918,7 @@ function xn(e, t, n) {
|
|
|
917
918
|
pathMissing: (t) => !bn(e, t),
|
|
918
919
|
filesMatch: (t) => {
|
|
919
920
|
let r = n ? `${n}/${t}` : t;
|
|
920
|
-
for (let t of e) if (
|
|
921
|
+
for (let t of e) if (Ke(r, t)) return !0;
|
|
921
922
|
return !1;
|
|
922
923
|
}
|
|
923
924
|
};
|
|
@@ -1013,17 +1014,23 @@ function Dn(e, t, n, r, i, a, o, s) {
|
|
|
1013
1014
|
return l;
|
|
1014
1015
|
}
|
|
1015
1016
|
function On(e, t, n, r = {}) {
|
|
1016
|
-
return
|
|
1017
|
-
let i =
|
|
1017
|
+
return Xe(n, () => {
|
|
1018
|
+
let i = Ve(e, n), a = !!r.initMode, o = Dn(i, t, n, n.dryRun, r.templates, a, r.registryLookup, r.derivedPinLookup);
|
|
1018
1019
|
if (!n.dryRun && !n.updateDepsOnly && !a) {
|
|
1019
|
-
mn(t, {
|
|
1020
|
+
mn(t, {
|
|
1021
|
+
version: 3,
|
|
1022
|
+
ownNpmRegistry: n.ownNpmRegistry
|
|
1023
|
+
});
|
|
1020
1024
|
let i = {
|
|
1021
1025
|
...r.rediscover ? r.rediscover(t) : n,
|
|
1022
1026
|
dryRun: !0
|
|
1023
|
-
}, a = Dn(
|
|
1027
|
+
}, a = Dn(Ve(e, i), t, i, !0, r.templates, !1, r.registryLookup, r.derivedPinLookup).filter((e) => e.path !== un);
|
|
1024
1028
|
if (a.length > 0) throw new hn(a[0]);
|
|
1025
1029
|
}
|
|
1026
|
-
return a && !n.dryRun && mn(t, {
|
|
1030
|
+
return a && !n.dryRun && mn(t, {
|
|
1031
|
+
version: 3,
|
|
1032
|
+
ownNpmRegistry: n.ownNpmRegistry
|
|
1033
|
+
}), { changes: o };
|
|
1027
1034
|
});
|
|
1028
1035
|
}
|
|
1029
1036
|
// src/structure/engine/discovery.ts
|
|
@@ -1156,7 +1163,8 @@ function Rn(e) {
|
|
|
1156
1163
|
modules: e.modules,
|
|
1157
1164
|
blockVars: e.blockVars,
|
|
1158
1165
|
version: e.version ?? 0,
|
|
1159
|
-
dryRun: e.dryRun ?? !1
|
|
1166
|
+
dryRun: e.dryRun ?? !1,
|
|
1167
|
+
ownNpmRegistry: e.ownNpmRegistry ?? !1
|
|
1160
1168
|
};
|
|
1161
1169
|
}
|
|
1162
1170
|
// src/structure/engine/discovery-fs.ts
|
|
@@ -1187,7 +1195,7 @@ function Hn(e) {
|
|
|
1187
1195
|
} catch {
|
|
1188
1196
|
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
1197
|
}
|
|
1190
|
-
let n =
|
|
1198
|
+
let n = he(t) ?? {}, r = Array.isArray(n.packages) ? n.packages : [], i = /* @__PURE__ */ new Set([""]);
|
|
1191
1199
|
for (let t of r) {
|
|
1192
1200
|
let n = Vn(t);
|
|
1193
1201
|
(n === "" || e.exists(n)) && i.add(n);
|
|
@@ -1254,7 +1262,8 @@ function Gn(e) {
|
|
|
1254
1262
|
modules: i,
|
|
1255
1263
|
blockVars: c,
|
|
1256
1264
|
version: a.version,
|
|
1257
|
-
dryRun: e.dryRun ?? !1
|
|
1265
|
+
dryRun: e.dryRun ?? !1,
|
|
1266
|
+
ownNpmRegistry: a.ownNpmRegistry === !0
|
|
1258
1267
|
});
|
|
1259
1268
|
}
|
|
1260
1269
|
// src/structure/rules/shared/key-order.ts
|
|
@@ -1340,20 +1349,20 @@ function tr() {
|
|
|
1340
1349
|
};
|
|
1341
1350
|
}
|
|
1342
1351
|
function nr() {
|
|
1343
|
-
|
|
1352
|
+
R("packageManager", Jn), R("devEngines.runtime", qn), z("pnpm", (e) => e === null || typeof e == "object" && Object.values(e).every((e) => typeof e == "object" && !!e && Object.keys(e).length === 0)), Lt("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.");
|
|
1344
1353
|
}
|
|
1345
1354
|
function rr() {
|
|
1346
|
-
nr(),
|
|
1347
|
-
for (let [e, t] of Object.entries($n))
|
|
1348
|
-
for (let [e, t] of Object.entries(er))
|
|
1349
|
-
|
|
1355
|
+
nr(), z("name"), B("fmt", "turbo run fmt"), B("check", "turbo run check");
|
|
1356
|
+
for (let [e, t] of Object.entries($n)) B(e, t);
|
|
1357
|
+
for (let [e, t] of Object.entries(er)) B(e, t);
|
|
1358
|
+
V("build"), V("build:dev"), B("mark-stable", "turbo run mark-stable"), B("do-pack", "turbo run do-pack"), B("watch", "turbo watch build"), B("changeset", "changeset"), B("version-packages", "changeset version"), B("update-sdk", "block-tools structure refresh --update-deps-only"), V("update"), B("upgrade-sdk", "block-tools structure refresh --update-deps-only && pnpm i && block-tools structure refresh && pnpm i && pnpm fmt"), W({
|
|
1350
1359
|
"@changesets/cli": "catalog:",
|
|
1351
1360
|
"@milaboratories/ts-builder": "sdk:",
|
|
1352
1361
|
"@platforma-sdk/block-tools": "sdk:",
|
|
1353
1362
|
"cross-env": "catalog:",
|
|
1354
1363
|
shx: "catalog:",
|
|
1355
1364
|
turbo: "catalog:"
|
|
1356
|
-
}),
|
|
1365
|
+
}), Ut({
|
|
1357
1366
|
oxlint: "*",
|
|
1358
1367
|
oxfmt: "*"
|
|
1359
1368
|
}), qt((e, t) => {
|
|
@@ -1420,7 +1429,7 @@ function sr() {
|
|
|
1420
1429
|
};
|
|
1421
1430
|
}
|
|
1422
1431
|
function cr() {
|
|
1423
|
-
|
|
1432
|
+
R("$schema", ir), R("globalDependencies", ar), Rt("tasks", or), z("tasks.build:dev"), G([
|
|
1424
1433
|
"$schema",
|
|
1425
1434
|
"globalDependencies",
|
|
1426
1435
|
"tasks"
|
|
@@ -1443,18 +1452,18 @@ async function pr(e) {
|
|
|
1443
1452
|
} catch (e) {
|
|
1444
1453
|
if (t > lr) throw e;
|
|
1445
1454
|
let n = ur * 2 ** (t - 1) * (.8 + .4 * Math.random());
|
|
1446
|
-
await
|
|
1455
|
+
await ve(n);
|
|
1447
1456
|
continue;
|
|
1448
1457
|
}
|
|
1449
1458
|
if (n.ok) return n;
|
|
1450
1459
|
if (!(n.status === 429 || n.status >= 500) || t > lr) throw Error(`registry returned HTTP ${n.status}`);
|
|
1451
1460
|
let r = fr(n.headers.get("retry-after"));
|
|
1452
1461
|
if (r != null) {
|
|
1453
|
-
await
|
|
1462
|
+
await ve(r);
|
|
1454
1463
|
continue;
|
|
1455
1464
|
}
|
|
1456
1465
|
let i = ur * 2 ** (t - 1) * (.8 + .4 * Math.random());
|
|
1457
|
-
await
|
|
1466
|
+
await ve(i);
|
|
1458
1467
|
}
|
|
1459
1468
|
}
|
|
1460
1469
|
function mr() {
|
|
@@ -1508,7 +1517,7 @@ var Sr = [
|
|
|
1508
1517
|
"@platforma-sdk/eslint-config"
|
|
1509
1518
|
];
|
|
1510
1519
|
function Cr() {
|
|
1511
|
-
for (let e of Sr)
|
|
1520
|
+
for (let e of Sr) U(e);
|
|
1512
1521
|
}
|
|
1513
1522
|
// src/structure/rules/root-pnpm-workspace.ts
|
|
1514
1523
|
var wr = [
|
|
@@ -1591,7 +1600,7 @@ function Ir(e) {
|
|
|
1591
1600
|
};
|
|
1592
1601
|
}
|
|
1593
1602
|
function Lr(e) {
|
|
1594
|
-
|
|
1603
|
+
R("changelog", Rr), R("commit", !1), R("access", zr), R("baseBranch", Br), R("updateInternalDependencies", Vr);
|
|
1595
1604
|
let t = Wr(e);
|
|
1596
1605
|
Xt("fixed", (e) => Gr(e, t)), G(Hr);
|
|
1597
1606
|
}
|
|
@@ -1626,19 +1635,19 @@ function Kr(e) {
|
|
|
1626
1635
|
}
|
|
1627
1636
|
// src/structure/rules/root.ts
|
|
1628
1637
|
function qr() {
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1638
|
+
S("root", () => {
|
|
1639
|
+
C(({ ctx: e }) => !e.isSdkInternal, () => {
|
|
1640
|
+
E("turbo.json", M(() => sr()), () => {
|
|
1632
1641
|
cr();
|
|
1633
|
-
}),
|
|
1642
|
+
}), T(".vscode/settings.json", A("root/.vscode/settings.json")), E("package.json", M(() => tr()), () => {
|
|
1634
1643
|
rr();
|
|
1635
|
-
}),
|
|
1644
|
+
}), E("pnpm-workspace.yaml", M((e) => Ar(e)), () => {
|
|
1636
1645
|
Mr();
|
|
1637
|
-
}),
|
|
1646
|
+
}), E(".gitignore", A("root/gitignore"), () => {
|
|
1638
1647
|
Pr();
|
|
1639
|
-
}),
|
|
1648
|
+
}), E(".changeset/config.json", M((e) => Ir(e)), (e) => {
|
|
1640
1649
|
Lr(e);
|
|
1641
|
-
}),
|
|
1650
|
+
}), O(".changeset/scaffold.md", st(Fr));
|
|
1642
1651
|
});
|
|
1643
1652
|
});
|
|
1644
1653
|
}
|
|
@@ -1646,17 +1655,19 @@ function qr() {
|
|
|
1646
1655
|
function Jr(e) {
|
|
1647
1656
|
return e.split(/[-_]+/).filter((e) => e.length > 0).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
1648
1657
|
}
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1658
|
+
var Yr = "\n\n # .structure \"ownNpmRegistry\": publish @platforma-open to npm.platforma.bio.\n npm-own-registry-scopes: '@platforma-open'";
|
|
1659
|
+
function Xr() {
|
|
1660
|
+
S("root", () => {
|
|
1661
|
+
C(({ ctx: e }) => !e.isSdkInternal, () => {
|
|
1662
|
+
T(".github/workflows/build.yaml", j("workflows/build.tpl.yaml", (e) => {
|
|
1653
1663
|
let t = e.blockVars.shortName;
|
|
1654
1664
|
return {
|
|
1655
1665
|
appName: `Block: ${Jr(t)}`,
|
|
1656
1666
|
appNameSlug: `block-${t}`,
|
|
1657
|
-
nodeVersion: Kn
|
|
1667
|
+
nodeVersion: Kn,
|
|
1668
|
+
ownNpmRegistry: e.ownNpmRegistry ? Yr : ""
|
|
1658
1669
|
};
|
|
1659
|
-
})),
|
|
1670
|
+
})), T(".github/workflows/mark-stable.yaml", j("workflows/mark-stable.tpl.yaml", (e) => ({
|
|
1660
1671
|
appName: `Block: ${Jr(e.blockVars.shortName)} - Mark Stable`,
|
|
1661
1672
|
nodeVersion: Kn
|
|
1662
1673
|
})));
|
|
@@ -1664,7 +1675,7 @@ function Yr() {
|
|
|
1664
1675
|
});
|
|
1665
1676
|
}
|
|
1666
1677
|
// src/structure/rules/block-package-json.ts
|
|
1667
|
-
var
|
|
1678
|
+
var Zr = {
|
|
1668
1679
|
"@platforma-open": {
|
|
1669
1680
|
s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
|
|
1670
1681
|
serveUrl: "https://blocks.pl-open.science"
|
|
@@ -1673,45 +1684,45 @@ var Xr = {
|
|
|
1673
1684
|
s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
|
|
1674
1685
|
serveUrl: "https://block.registry.platforma.bio/releases"
|
|
1675
1686
|
}
|
|
1676
|
-
},
|
|
1687
|
+
}, Qr = {
|
|
1677
1688
|
s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
|
|
1678
1689
|
serveUrl: "https://blocks.pl-open.science"
|
|
1679
|
-
},
|
|
1690
|
+
}, $r = {
|
|
1680
1691
|
s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/aux/dev/?region=eu-central-1",
|
|
1681
1692
|
serveUrl: "https://aux-blocks.pl-open.science"
|
|
1682
1693
|
};
|
|
1683
|
-
function
|
|
1684
|
-
let n = t ?
|
|
1694
|
+
function ei(e, t) {
|
|
1695
|
+
let n = t ? $r : Zr[e] ?? Qr;
|
|
1685
1696
|
return `block-tools publish -r ${n.s3} --registry-serve-url ${n.serveUrl}`;
|
|
1686
1697
|
}
|
|
1687
|
-
function
|
|
1698
|
+
function ti(e) {
|
|
1688
1699
|
let t = {};
|
|
1689
1700
|
for (let n of q(e, "workflow")) t.workflow = `${n.name}/dist/tengo/tpl/main.plj.gz`;
|
|
1690
1701
|
for (let n of q(e, "model")) t.model = `${n.name}/dist/model.json`;
|
|
1691
1702
|
for (let n of q(e, "ui")) t.ui = `${n.name}/dist`;
|
|
1692
1703
|
return t;
|
|
1693
1704
|
}
|
|
1694
|
-
function
|
|
1705
|
+
function ni(e, t) {
|
|
1695
1706
|
return {
|
|
1696
1707
|
build: "ts-builder build --target block-facade && block-tools pack",
|
|
1697
1708
|
check: "ts-builder type-check --target block-facade",
|
|
1698
|
-
prepublishOnly:
|
|
1709
|
+
prepublishOnly: ei(e, t),
|
|
1699
1710
|
"do-pack": "shx rm -f package.tgz && pnpm pack && shx mv *.tgz package.tgz"
|
|
1700
1711
|
};
|
|
1701
1712
|
}
|
|
1702
|
-
var
|
|
1713
|
+
var ri = {
|
|
1703
1714
|
"@milaboratories/ts-builder": "sdk:",
|
|
1704
1715
|
"@milaboratories/ts-configs": "sdk:",
|
|
1705
1716
|
"@platforma-sdk/block-tools": "sdk:",
|
|
1706
1717
|
"@platforma-sdk/model": "sdk:",
|
|
1707
1718
|
shx: "catalog:",
|
|
1708
1719
|
typescript: "catalog:"
|
|
1709
|
-
},
|
|
1720
|
+
}, ii = { ".": {
|
|
1710
1721
|
sources: "./src/index.ts",
|
|
1711
1722
|
types: "./dist/index.d.ts",
|
|
1712
1723
|
default: "./dist/index.js"
|
|
1713
|
-
} },
|
|
1714
|
-
function
|
|
1724
|
+
} }, ai = "file:CHANGELOG.md";
|
|
1725
|
+
function oi(e) {
|
|
1715
1726
|
if (Object.keys(e.components).length === 0) throw Error("block.components is empty — no workflow/model/ui module was discovered");
|
|
1716
1727
|
let t = e.meta, n = [
|
|
1717
1728
|
["block.meta.title", t.title],
|
|
@@ -1723,20 +1734,20 @@ function ai(e) {
|
|
|
1723
1734
|
];
|
|
1724
1735
|
for (let [e, t] of n) if (typeof t != "string" || t === "") throw Error(`required block field '${e}' is empty`);
|
|
1725
1736
|
}
|
|
1726
|
-
function
|
|
1737
|
+
function si(e) {
|
|
1727
1738
|
let t = e.blockVars, n = {
|
|
1728
|
-
...
|
|
1739
|
+
...ri,
|
|
1729
1740
|
...J(e, "model"),
|
|
1730
1741
|
...J(e, "ui"),
|
|
1731
1742
|
...J(e, "workflow"),
|
|
1732
1743
|
...J(e, "kind")
|
|
1733
1744
|
}, r = {
|
|
1734
|
-
components:
|
|
1745
|
+
components: ti(e),
|
|
1735
1746
|
meta: {
|
|
1736
1747
|
title: t.shortName,
|
|
1737
1748
|
description: `${t.shortName} block`,
|
|
1738
1749
|
logo: "file:logos/block-logo.png",
|
|
1739
|
-
changelog:
|
|
1750
|
+
changelog: ai,
|
|
1740
1751
|
organization: {
|
|
1741
1752
|
name: t.orgScope,
|
|
1742
1753
|
url: "https://example.com",
|
|
@@ -1744,7 +1755,7 @@ function oi(e) {
|
|
|
1744
1755
|
}
|
|
1745
1756
|
}
|
|
1746
1757
|
};
|
|
1747
|
-
return
|
|
1758
|
+
return oi(r), {
|
|
1748
1759
|
name: `${t.facadeName}.block`,
|
|
1749
1760
|
version: Z,
|
|
1750
1761
|
type: "module",
|
|
@@ -1752,41 +1763,41 @@ function oi(e) {
|
|
|
1752
1763
|
main: "./dist/index.js",
|
|
1753
1764
|
module: "./dist/index.js",
|
|
1754
1765
|
types: "./dist/index.d.ts",
|
|
1755
|
-
exports:
|
|
1756
|
-
scripts:
|
|
1766
|
+
exports: ii,
|
|
1767
|
+
scripts: ni(t.npmOrg, e.isSdkInternal),
|
|
1757
1768
|
dependencies: {},
|
|
1758
1769
|
devDependencies: n,
|
|
1759
1770
|
block: r
|
|
1760
1771
|
};
|
|
1761
1772
|
}
|
|
1762
|
-
function
|
|
1773
|
+
function ci(e) {
|
|
1763
1774
|
let t = e.blockVars, n = q(e, "kind");
|
|
1764
1775
|
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`);
|
|
1765
|
-
|
|
1766
|
-
let r =
|
|
1767
|
-
for (let [e, t] of Object.entries(r))
|
|
1768
|
-
Kt("model"), Kt("ui"), Kt("workflow"), Kt("kind"),
|
|
1776
|
+
R("type", "module"), R("files", ["dist", "block-pack"]), R("main", "./dist/index.js"), R("module", "./dist/index.js"), R("types", "./dist/index.d.ts"), R("exports", ii);
|
|
1777
|
+
let r = ni(t.npmOrg, e.isSdkInternal);
|
|
1778
|
+
for (let [e, t] of Object.entries(r)) B(e, t);
|
|
1779
|
+
Kt("model"), Kt("ui"), Kt("workflow"), Kt("kind"), H("@milaboratories/ts-builder", "sdk:"), H("@milaboratories/ts-configs", "sdk:"), H("@platforma-sdk/block-tools", "sdk:"), H("@platforma-sdk/model", "sdk:"), H("shx", "catalog:"), H("typescript", "catalog:"), R("block.components", ti(e)), R("block.meta.changelog", ai), It("version", "facade package.json must carry a 'version' (the facade publishes)"), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
1769
1780
|
}
|
|
1770
1781
|
// src/structure/rules/shared/pascal-case.ts
|
|
1771
|
-
function
|
|
1782
|
+
function li(e) {
|
|
1772
1783
|
let t = e.split(/[^A-Za-z0-9]+/).filter((e) => e.length > 0).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("");
|
|
1773
1784
|
return /^[0-9]/.test(t) ? `_${t}` : t;
|
|
1774
1785
|
}
|
|
1775
1786
|
// src/structure/rules/block.ts
|
|
1776
|
-
function
|
|
1777
|
-
|
|
1778
|
-
|
|
1787
|
+
function ui() {
|
|
1788
|
+
S("block", () => {
|
|
1789
|
+
k("index.js"), k("index.d.ts"), T("src/index.ts", j("block/src/index.tpl.ts", (e) => ({
|
|
1779
1790
|
facadeName: e.blockVars.facadeName,
|
|
1780
|
-
pascalName:
|
|
1781
|
-
}))),
|
|
1782
|
-
|
|
1791
|
+
pascalName: li(e.blockVars.shortName)
|
|
1792
|
+
}))), T("src/AGENTS.ts", A("block/src/AGENTS.ts")), D("src/block-extra.ts", A("block/src/block-extra.ts")), D("src/agents-extra.ts", A("block/src/agents-extra.ts")), T("tsconfig.json", A("block/tsconfig.json")), O("logos/block-logo.png", ot("block/logos/block-logo.png")), O("logos/organization-logo.png", ot("block/logos/organization-logo.png")), D("CHANGELOG.md", M((e) => `# ${e.blockVars.facadeName}\n`)), E("package.json", M((e) => si(e)), (e) => {
|
|
1793
|
+
ci(e);
|
|
1783
1794
|
});
|
|
1784
1795
|
});
|
|
1785
1796
|
}
|
|
1786
1797
|
// src/structure/rules/shared/colocated-tests.ts
|
|
1787
|
-
var $ = "src/**/*.test.ts",
|
|
1798
|
+
var $ = "src/**/*.test.ts", di = "src/**/*.test.tengo";
|
|
1788
1799
|
// src/structure/rules/model-package-json.ts
|
|
1789
|
-
function
|
|
1800
|
+
function fi(e) {
|
|
1790
1801
|
return {
|
|
1791
1802
|
name: `${e.blockVars.facadeName}.model`,
|
|
1792
1803
|
version: Z,
|
|
@@ -1824,42 +1835,42 @@ function di(e) {
|
|
|
1824
1835
|
}
|
|
1825
1836
|
};
|
|
1826
1837
|
}
|
|
1827
|
-
function
|
|
1828
|
-
Q(),
|
|
1838
|
+
function pi() {
|
|
1839
|
+
Q(), R("private", !0), R("type", "module"), R("main", "dist/index.cjs"), R("module", "dist/index.js"), R("types", "dist/index.d.ts"), R("exports", {
|
|
1829
1840
|
".": {
|
|
1830
1841
|
types: "./dist/index.d.ts",
|
|
1831
1842
|
sources: "./src/index.ts",
|
|
1832
1843
|
import: "./dist/index.js"
|
|
1833
1844
|
},
|
|
1834
1845
|
"./dist/*": "./dist/*"
|
|
1835
|
-
}),
|
|
1846
|
+
}), B("fmt", "ts-builder format"), B("watch", "ts-builder build --target block-model --watch"), B("build", "ts-builder build --target block-model && block-tools build-model"), B("check", "ts-builder check --target block-model"), Vt("@platforma-sdk/model", "sdk:"), Gt("kind"), W({
|
|
1836
1847
|
"@milaboratories/ts-builder": "sdk:",
|
|
1837
1848
|
"@milaboratories/ts-configs": "sdk:",
|
|
1838
1849
|
"@platforma-sdk/block-tools": "sdk:"
|
|
1839
|
-
}),
|
|
1850
|
+
}), Ut({
|
|
1840
1851
|
"@types/node": "*",
|
|
1841
1852
|
typescript: "*"
|
|
1842
|
-
}),
|
|
1843
|
-
|
|
1844
|
-
}, () =>
|
|
1853
|
+
}), C(({ ctx: e }) => !e.isSdkInternal, () => C(w($), () => {
|
|
1854
|
+
B("test", "vitest run --passWithNoTests"), H("vitest", "catalog:"), H("@types/node", "*");
|
|
1855
|
+
}, () => U("vitest"))), Cr(), z("tsup"), V("lint"), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
1845
1856
|
}
|
|
1846
1857
|
// src/structure/rules/model.ts
|
|
1847
|
-
function
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1858
|
+
function mi() {
|
|
1859
|
+
S("model", () => {
|
|
1860
|
+
C(w($), () => T("tsconfig.json", A("model/tsconfig.node.json")), () => T("tsconfig.json", A("model/tsconfig.json"))), T(".oxlintrc.json", A("model/.oxlintrc.json")), T(".oxfmtrc.json", A("model/.oxfmtrc.json")), O("src/index.ts", j("model/src/index.tpl.ts", (e) => ({ kindPkg: `${e.blockVars.facadeName}.kind` }))), E("package.json", M((e) => fi(e)), () => {
|
|
1861
|
+
pi();
|
|
1851
1862
|
});
|
|
1852
1863
|
});
|
|
1853
1864
|
}
|
|
1854
1865
|
// src/structure/rules/kind-package-json.ts
|
|
1855
|
-
var
|
|
1866
|
+
var hi = { ".": {
|
|
1856
1867
|
types: "./dist/index.d.ts",
|
|
1857
1868
|
sources: "./src/index.ts",
|
|
1858
1869
|
import: "./dist/index.js",
|
|
1859
1870
|
require: "./dist/index.cjs",
|
|
1860
1871
|
default: "./dist/index.js"
|
|
1861
1872
|
} };
|
|
1862
|
-
function
|
|
1873
|
+
function gi(e) {
|
|
1863
1874
|
return {
|
|
1864
1875
|
name: `${e.blockVars.facadeName}.kind`,
|
|
1865
1876
|
version: Z,
|
|
@@ -1868,7 +1879,7 @@ function hi(e) {
|
|
|
1868
1879
|
main: "./dist/index.cjs",
|
|
1869
1880
|
module: "./dist/index.js",
|
|
1870
1881
|
types: "./dist/index.d.ts",
|
|
1871
|
-
exports:
|
|
1882
|
+
exports: hi,
|
|
1872
1883
|
scripts: {
|
|
1873
1884
|
fmt: "ts-builder format",
|
|
1874
1885
|
watch: "ts-builder build --target block-kind --watch",
|
|
@@ -1887,26 +1898,26 @@ function hi(e) {
|
|
|
1887
1898
|
}
|
|
1888
1899
|
};
|
|
1889
1900
|
}
|
|
1890
|
-
function
|
|
1891
|
-
Q(),
|
|
1901
|
+
function _i() {
|
|
1902
|
+
Q(), R("private", !0), R("type", "module"), R("main", "./dist/index.cjs"), R("module", "./dist/index.js"), R("types", "./dist/index.d.ts"), R("exports", hi), B("fmt", "ts-builder format"), B("watch", "ts-builder build --target block-kind --watch"), B("build", "ts-builder build --target block-kind && block-tools build-kind-manifest"), B("check", "ts-builder check --target block-kind"), V("lint"), Vt("@platforma-sdk/block-kind", "sdk:"), W({
|
|
1892
1903
|
"@milaboratories/ts-builder": "sdk:",
|
|
1893
1904
|
"@milaboratories/ts-configs": "sdk:",
|
|
1894
1905
|
"@platforma-sdk/block-tools": "sdk:"
|
|
1895
|
-
}),
|
|
1906
|
+
}), Ut({
|
|
1896
1907
|
"@types/node": "*",
|
|
1897
1908
|
typescript: "*"
|
|
1898
1909
|
}), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
1899
1910
|
}
|
|
1900
1911
|
// src/structure/rules/kind.ts
|
|
1901
|
-
function
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1912
|
+
function vi() {
|
|
1913
|
+
S("kind", () => {
|
|
1914
|
+
T("tsconfig.json", A("kind/tsconfig.json")), T(".oxlintrc.json", A("kind/.oxlintrc.json")), T(".oxfmtrc.json", A("kind/.oxfmtrc.json")), D("src/index.ts", A("kind/src/index.ts")), E("package.json", M((e) => gi(e)), () => {
|
|
1915
|
+
_i();
|
|
1905
1916
|
});
|
|
1906
1917
|
});
|
|
1907
1918
|
}
|
|
1908
1919
|
// src/structure/rules/ui-package-json.ts
|
|
1909
|
-
function
|
|
1920
|
+
function yi(e) {
|
|
1910
1921
|
return {
|
|
1911
1922
|
name: `${e.blockVars.facadeName}.ui`,
|
|
1912
1923
|
version: Z,
|
|
@@ -1934,27 +1945,27 @@ function vi(e) {
|
|
|
1934
1945
|
}
|
|
1935
1946
|
};
|
|
1936
1947
|
}
|
|
1937
|
-
function
|
|
1938
|
-
Q(),
|
|
1948
|
+
function bi() {
|
|
1949
|
+
Q(), R("private", !0), R("type", "module"), B("fmt", "ts-builder format"), B("dev", "ts-builder serve --target block-ui"), B("watch", "ts-builder build --target block-ui --watch"), B("build", "ts-builder build --target block-ui"), B("check", "ts-builder check --target block-ui"), Vt("@platforma-sdk/ui-vue", "sdk:"), Vt("vue", "catalog:"), Gt("model"), W({
|
|
1939
1950
|
"@milaboratories/ts-builder": "sdk:",
|
|
1940
1951
|
"@milaboratories/ts-configs": "sdk:"
|
|
1941
|
-
}), Cr(),
|
|
1952
|
+
}), Cr(), V("preview"), V("lint"), Ut({
|
|
1942
1953
|
"@types/node": "*",
|
|
1943
1954
|
typescript: "*"
|
|
1944
|
-
}),
|
|
1945
|
-
|
|
1946
|
-
}, () =>
|
|
1955
|
+
}), C(({ ctx: e }) => !e.isSdkInternal, () => C(w($), () => {
|
|
1956
|
+
B("test", "vitest run --passWithNoTests"), H("vitest", "catalog:"), H("@types/node", "*");
|
|
1957
|
+
}, () => U("vitest"))), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
1947
1958
|
}
|
|
1948
1959
|
// src/structure/rules/ui.ts
|
|
1949
|
-
function
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1960
|
+
function xi() {
|
|
1961
|
+
S("ui", () => {
|
|
1962
|
+
C(w($), () => T("tsconfig.json", A("ui/tsconfig.node.json")), () => T("tsconfig.json", A("ui/tsconfig.json"))), T(".oxlintrc.json", A("ui/.oxlintrc.json")), T(".oxfmtrc.json", A("ui/.oxfmtrc.json")), D("index.html", A("ui/index.html")), O("src/main.ts", A("ui/src/main.ts")), O("src/app.ts", j("ui/src/app.tpl.ts", (e) => ({ modelPkg: `${e.blockVars.facadeName}.model` }))), O("src/MainPage.vue", j("ui/src/MainPage.tpl.vue", (e) => ({ shortName: e.blockVars.shortName }))), E("package.json", M((e) => yi(e)), () => {
|
|
1963
|
+
bi();
|
|
1953
1964
|
});
|
|
1954
1965
|
});
|
|
1955
1966
|
}
|
|
1956
1967
|
// src/structure/rules/workflow-package-json.ts
|
|
1957
|
-
function
|
|
1968
|
+
function Si(e) {
|
|
1958
1969
|
return {
|
|
1959
1970
|
name: `${e.blockVars.facadeName}.workflow`,
|
|
1960
1971
|
version: Z,
|
|
@@ -1976,31 +1987,31 @@ function xi(e) {
|
|
|
1976
1987
|
}
|
|
1977
1988
|
};
|
|
1978
1989
|
}
|
|
1979
|
-
function
|
|
1980
|
-
Q(),
|
|
1981
|
-
|
|
1990
|
+
function Ci() {
|
|
1991
|
+
Q(), R("private", !0), R("type", "module"), B("build", "shx rm -rf dist && pl-tengo build"), B("check", "pl-tengo imports && pl-tengo check"), B("format", "/usr/bin/env emacs --script ./format.el || echo 'No emacs.'"), C(({ ctx: e }) => !e.isSdkInternal, () => C(w($), () => {
|
|
1992
|
+
C(w(di), () => B("test", "pl-tengo test && vitest run --passWithNoTests"), () => B("test", "vitest run --passWithNoTests")), W({ vitest: "catalog:" });
|
|
1982
1993
|
}, () => {
|
|
1983
|
-
|
|
1984
|
-
})),
|
|
1994
|
+
C(w(di), () => B("test", "pl-tengo test")), U("vitest");
|
|
1995
|
+
})), Vt("@platforma-sdk/workflow-tengo", "sdk:"), Gt("software"), W({
|
|
1985
1996
|
"@platforma-sdk/tengo-builder": "sdk:",
|
|
1986
1997
|
"@platforma-sdk/test": "sdk:",
|
|
1987
1998
|
shx: "catalog:"
|
|
1988
1999
|
}), Cr(), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
1989
2000
|
}
|
|
1990
2001
|
// src/structure/rules/workflow.ts
|
|
1991
|
-
function
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
2002
|
+
function wi() {
|
|
2003
|
+
S("workflow", () => {
|
|
2004
|
+
T("format.el", A("workflow/format.el")), C(({ ctx: e }) => !e.isSdkInternal, () => C(w($), () => {
|
|
2005
|
+
T("tsconfig.json", A("workflow/tsconfig.json")), D("vitest.config.mts", A("workflow/vitest.config.mts"));
|
|
1995
2006
|
}, () => {
|
|
1996
|
-
|
|
1997
|
-
})),
|
|
1998
|
-
|
|
2007
|
+
k("tsconfig.json"), k("vitest.config.mts");
|
|
2008
|
+
})), k("index.js"), k("index.d.ts"), O("src/main.tpl.tengo", j("workflow/src/main.tpl.tengo", (e) => ({ shortName: e.blockVars.shortName }))), E("package.json", M((e) => Si(e)), () => {
|
|
2009
|
+
Ci();
|
|
1999
2010
|
});
|
|
2000
2011
|
});
|
|
2001
2012
|
}
|
|
2002
2013
|
// src/structure/rules/test-package-json.ts
|
|
2003
|
-
function
|
|
2014
|
+
function Ti(e) {
|
|
2004
2015
|
return {
|
|
2005
2016
|
name: `${e.blockVars.facadeName}.test`,
|
|
2006
2017
|
version: Z,
|
|
@@ -2020,25 +2031,25 @@ function wi(e) {
|
|
|
2020
2031
|
}
|
|
2021
2032
|
};
|
|
2022
2033
|
}
|
|
2023
|
-
function
|
|
2024
|
-
Q(),
|
|
2034
|
+
function Ei() {
|
|
2035
|
+
Q(), R("private", !0), R("type", "module"), B("fmt", "ts-builder format"), B("check", "ts-builder check --target block-test"), B("test", "vitest run --passWithNoTests"), V("lint"), W({
|
|
2025
2036
|
"@platforma-sdk/test": "sdk:",
|
|
2026
2037
|
"@milaboratories/ts-builder": "sdk:",
|
|
2027
2038
|
"@milaboratories/ts-configs": "sdk:",
|
|
2028
2039
|
vitest: "catalog:"
|
|
2029
|
-
}),
|
|
2040
|
+
}), Ut({ typescript: "*" }), U("@types/node"), Cr(), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
2030
2041
|
}
|
|
2031
2042
|
// src/structure/rules/test.ts
|
|
2032
|
-
function
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2043
|
+
function Di() {
|
|
2044
|
+
S("test", () => {
|
|
2045
|
+
T("tsconfig.json", A("test/tsconfig.json")), T(".oxlintrc.json", A("test/.oxlintrc.json")), T(".oxfmtrc.json", A("test/.oxfmtrc.json")), D("vitest.config.mts", A("test/vitest.config.mts")), O("src/demo.test.ts", st("import { expect, test } from \"vitest\";\n\ntest(\"scaffolded block sanity check\", () => {\n expect(true).toBe(true);\n});\n")), E("package.json", M((e) => Ti(e)), () => {
|
|
2046
|
+
Ei();
|
|
2036
2047
|
});
|
|
2037
2048
|
});
|
|
2038
2049
|
}
|
|
2039
2050
|
// src/structure/rules/software-package-json.ts
|
|
2040
|
-
var
|
|
2041
|
-
function
|
|
2051
|
+
var Oi = "block-tools software build", ki = "shx rm -f *.tgz && block-tools software build && pnpm pack && shx mv platforma-open*.tgz package.tgz";
|
|
2052
|
+
function Ai() {
|
|
2042
2053
|
return { entrypoints: { main: { binary: {
|
|
2043
2054
|
artifact: {
|
|
2044
2055
|
type: "python",
|
|
@@ -2053,7 +2064,7 @@ function ki() {
|
|
|
2053
2064
|
cmd: ["python", "{pkg}/main.py"]
|
|
2054
2065
|
} } } };
|
|
2055
2066
|
}
|
|
2056
|
-
function
|
|
2067
|
+
function ji(e) {
|
|
2057
2068
|
return {
|
|
2058
2069
|
name: `${e.blockVars.facadeName}.software`,
|
|
2059
2070
|
version: Z,
|
|
@@ -2061,51 +2072,51 @@ function Ai(e) {
|
|
|
2061
2072
|
description: "Block Software",
|
|
2062
2073
|
files: ["./dist/**/*"],
|
|
2063
2074
|
scripts: {
|
|
2064
|
-
build:
|
|
2065
|
-
"do-pack":
|
|
2075
|
+
build: Oi,
|
|
2076
|
+
"do-pack": ki,
|
|
2066
2077
|
changeset: "changeset",
|
|
2067
2078
|
"version-packages": "changeset version"
|
|
2068
2079
|
},
|
|
2069
|
-
"block-software":
|
|
2080
|
+
"block-software": Ai(),
|
|
2070
2081
|
devDependencies: {
|
|
2071
2082
|
"@platforma-open/milaboratories.runenv-python-3": "catalog:",
|
|
2072
2083
|
"@platforma-sdk/block-tools": "sdk:"
|
|
2073
2084
|
}
|
|
2074
2085
|
};
|
|
2075
2086
|
}
|
|
2076
|
-
function
|
|
2077
|
-
|
|
2087
|
+
function Mi() {
|
|
2088
|
+
z("private"), Q(), R("type", "module"), R("files", ["./dist/**/*"]), B("build", Oi), B("do-pack", ki), V("prepublishOnly"), B("changeset", "changeset"), B("version-packages", "changeset version"), H("@platforma-open/milaboratories.runenv-python-3", "catalog:"), H("@platforma-sdk/block-tools", "sdk:"), U("@platforma-sdk/package-builder"), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...X]);
|
|
2078
2089
|
}
|
|
2079
2090
|
// src/structure/rules/software.ts
|
|
2080
|
-
var
|
|
2081
|
-
function
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2091
|
+
var Ni = "import sys\n\nprint(\"Hello from Python, \" + sys.argv[1] + \"!\")\n", Pi = "# No dependencies specified for this script\n";
|
|
2092
|
+
function Fi() {
|
|
2093
|
+
S("software", () => {
|
|
2094
|
+
O("src/main.py", st(Ni)), O("src/requirements.txt", st(Pi)), E("package.json", M((e) => ji(e)), () => {
|
|
2095
|
+
Mi();
|
|
2085
2096
|
});
|
|
2086
2097
|
});
|
|
2087
2098
|
}
|
|
2088
|
-
function
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
}),
|
|
2092
|
-
|
|
2093
|
-
}),
|
|
2094
|
-
|
|
2095
|
-
}),
|
|
2096
|
-
|
|
2097
|
-
|
|
2099
|
+
function Ii() {
|
|
2100
|
+
S("model", () => {
|
|
2101
|
+
k("eslint.config.mjs"), k("vite.config.mts");
|
|
2102
|
+
}), S("ui", () => {
|
|
2103
|
+
k("eslint.config.mjs"), k("vite.config.ts"), k("tsconfig.app.json"), k("tsconfig.node.json");
|
|
2104
|
+
}), S("test", () => {
|
|
2105
|
+
k("eslint.config.mjs");
|
|
2106
|
+
}), S("root", () => {
|
|
2107
|
+
k(".prettierrc"), E("package.json", M(() => tr()), () => {
|
|
2108
|
+
V("pretty"), U("@platforma-sdk/blocks-deps-updater");
|
|
2098
2109
|
});
|
|
2099
2110
|
});
|
|
2100
2111
|
}
|
|
2101
2112
|
// src/structure/rules/root-catalog-bump.ts
|
|
2102
|
-
function
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2113
|
+
function Li() {
|
|
2114
|
+
at(() => {
|
|
2115
|
+
S("root", () => {
|
|
2116
|
+
C(({ ctx: e }) => !e.isSdkInternal, () => {
|
|
2117
|
+
E("package.json", M(() => tr()), () => {
|
|
2107
2118
|
nr(), G([...X]);
|
|
2108
|
-
}),
|
|
2119
|
+
}), E("pnpm-workspace.yaml", M((e) => Ar(e)), (e) => {
|
|
2109
2120
|
for (let e of wr) en(e);
|
|
2110
2121
|
for (let e of Dr) tn(e.entry, {
|
|
2111
2122
|
of: e.of,
|
|
@@ -2118,22 +2129,22 @@ function Ii() {
|
|
|
2118
2129
|
});
|
|
2119
2130
|
}
|
|
2120
2131
|
// src/structure/structure-definition.ts
|
|
2121
|
-
var
|
|
2122
|
-
qr(),
|
|
2132
|
+
var Ri = Qe(() => {
|
|
2133
|
+
qr(), Xr(), ui(), mi(), vi(), xi(), wi(), Di(), Fi(), Ii(), Li();
|
|
2123
2134
|
});
|
|
2124
2135
|
// src/structure/cli/run-structure.ts
|
|
2125
|
-
async function
|
|
2136
|
+
async function zi() {
|
|
2126
2137
|
return yr(wr.filter(vr));
|
|
2127
2138
|
}
|
|
2128
|
-
async function
|
|
2129
|
-
let t =
|
|
2139
|
+
async function Bi(e) {
|
|
2140
|
+
let t = g.resolve(e.blockPath), n = e.mode === "check", r = new Fe(t), i = new Ie(e.templatesRoot), a = On(Ri, r, Gn({
|
|
2130
2141
|
fs: r,
|
|
2131
2142
|
isSdkInternal: e.isSdkInternal,
|
|
2132
2143
|
updateDepsOnly: e.updateDepsOnly,
|
|
2133
2144
|
dryRun: n
|
|
2134
2145
|
}), {
|
|
2135
2146
|
templates: i,
|
|
2136
|
-
registryLookup: e.updateDepsOnly ? await
|
|
2147
|
+
registryLookup: e.updateDepsOnly ? await zi() : void 0,
|
|
2137
2148
|
derivedPinLookup: e.updateDepsOnly ? await xr(Dr) : void 0,
|
|
2138
2149
|
rediscover: () => Gn({
|
|
2139
2150
|
fs: r,
|
|
@@ -2147,19 +2158,19 @@ async function zi(e) {
|
|
|
2147
2158
|
changes: a.changes
|
|
2148
2159
|
};
|
|
2149
2160
|
}
|
|
2150
|
-
function
|
|
2151
|
-
let t = e.flatMap((e) => /[*?[]/.test(e) ?
|
|
2161
|
+
function Vi(e) {
|
|
2162
|
+
let t = e.flatMap((e) => /[*?[]/.test(e) ? re(e).filter((e) => ie(e, { throwIfNoEntry: !1 })?.isDirectory() === !0).map((e) => e.split(g.sep).join("/")).sort() : [e]);
|
|
2152
2163
|
return [...new Set(t)];
|
|
2153
2164
|
}
|
|
2154
|
-
function
|
|
2165
|
+
function Hi(e, t) {
|
|
2155
2166
|
if (t.length === 0) return ` ${e}: up to date (0 changes)`;
|
|
2156
2167
|
let n = t.map((e) => ` ${e.action.padEnd(6)} ${e.primitive.padEnd(8)} ${e.path} [${e.scope}]`);
|
|
2157
2168
|
return ` ${e}: ${t.length} change(s)\n${n.join("\n")}`;
|
|
2158
2169
|
}
|
|
2159
2170
|
// src/cmd/structure/refresh.ts
|
|
2160
|
-
async function
|
|
2171
|
+
async function Ui(e) {
|
|
2161
2172
|
for (let t of e.paths) {
|
|
2162
|
-
let n = await
|
|
2173
|
+
let n = await Bi({
|
|
2163
2174
|
blockPath: t,
|
|
2164
2175
|
isSdkInternal: e.isSdkInternal,
|
|
2165
2176
|
updateDepsOnly: e.updateDepsOnly,
|
|
@@ -2167,41 +2178,41 @@ async function Hi(e) {
|
|
|
2167
2178
|
templatesRoot: e.templatesRoot,
|
|
2168
2179
|
log: (t) => e.logger.info(t)
|
|
2169
2180
|
});
|
|
2170
|
-
e.logger.info(
|
|
2181
|
+
e.logger.info(Hi(t, n.changes));
|
|
2171
2182
|
}
|
|
2172
2183
|
}
|
|
2173
|
-
function
|
|
2174
|
-
let t = new
|
|
2184
|
+
function Wi(e) {
|
|
2185
|
+
let t = new m("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).");
|
|
2175
2186
|
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) => {
|
|
2176
|
-
let r = t.length > 0 ?
|
|
2177
|
-
await
|
|
2187
|
+
let r = t.length > 0 ? Vi(t) : ["."], i = g.join(e, "src", "structure", "templates");
|
|
2188
|
+
await Ui({
|
|
2178
2189
|
paths: r,
|
|
2179
2190
|
isSdkInternal: !!n.sdkInternal,
|
|
2180
2191
|
updateDepsOnly: !!n.updateDepsOnly,
|
|
2181
2192
|
templatesRoot: i,
|
|
2182
|
-
logger: new
|
|
2193
|
+
logger: new b()
|
|
2183
2194
|
});
|
|
2184
2195
|
}), t;
|
|
2185
2196
|
}
|
|
2186
2197
|
// src/cmd/update-deps.ts
|
|
2187
|
-
function
|
|
2188
|
-
let t = new
|
|
2198
|
+
function Gi(e) {
|
|
2199
|
+
let t = new m("update-deps").description("[DEPRECATED] Use `block-tools structure refresh --update-deps-only`. This alias delegates to it.");
|
|
2189
2200
|
return t.action(async () => {
|
|
2190
|
-
let t = new
|
|
2191
|
-
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
|
|
2201
|
+
let t = new b();
|
|
2202
|
+
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 Ui({
|
|
2192
2203
|
paths: ["."],
|
|
2193
2204
|
isSdkInternal: !1,
|
|
2194
2205
|
updateDepsOnly: !0,
|
|
2195
|
-
templatesRoot:
|
|
2206
|
+
templatesRoot: g.join(e, "src", "structure", "templates"),
|
|
2196
2207
|
logger: t
|
|
2197
2208
|
});
|
|
2198
2209
|
}), t;
|
|
2199
2210
|
}
|
|
2200
2211
|
// src/cmd/list-overview-snapshots.ts
|
|
2201
|
-
function
|
|
2202
|
-
let e = new
|
|
2203
|
-
return e.addOption(new
|
|
2204
|
-
let t = new
|
|
2212
|
+
function Ki() {
|
|
2213
|
+
let e = new m("list-overview-snapshots").description("List all available global overview snapshots in the registry");
|
|
2214
|
+
return e.addOption(new h("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.option("--json", "output in JSON format", !1), e.action(async (e) => {
|
|
2215
|
+
let t = new b(), n = p(e.registry), r = await new s(n, t).listGlobalOverviewSnapshots();
|
|
2205
2216
|
if (e.json) t.info(JSON.stringify(r, null, 2));
|
|
2206
2217
|
else if (r.length === 0) t.info("No snapshots found.");
|
|
2207
2218
|
else {
|
|
@@ -2211,10 +2222,10 @@ function Gi() {
|
|
|
2211
2222
|
}), e;
|
|
2212
2223
|
}
|
|
2213
2224
|
// src/cmd/restore-overview-from-snapshot.ts
|
|
2214
|
-
function
|
|
2215
|
-
let e = new
|
|
2216
|
-
return e.addOption(new
|
|
2217
|
-
let t = new
|
|
2225
|
+
function qi() {
|
|
2226
|
+
let e = new m("restore-overview-from-snapshot").description("Restore global overview from a snapshot");
|
|
2227
|
+
return e.addOption(new h("-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) => {
|
|
2228
|
+
let t = new b(), n = p(e.registry), r = new s(n, t), i = await r.listGlobalOverviewSnapshots();
|
|
2218
2229
|
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)"}`);
|
|
2219
2230
|
if (!e.skipConfirmation) {
|
|
2220
2231
|
let n = (await import("node:readline")).createInterface({
|
|
@@ -2236,7 +2247,7 @@ function Ki() {
|
|
|
2236
2247
|
}), e;
|
|
2237
2248
|
}
|
|
2238
2249
|
// src/registry_v1/flags.ts
|
|
2239
|
-
function
|
|
2250
|
+
function Ji(e) {
|
|
2240
2251
|
let t = e.match(/(?<destName>[^/\\]+)=(?<src>.*)/);
|
|
2241
2252
|
if (t) {
|
|
2242
2253
|
let { src: e, destName: n } = t.groups;
|
|
@@ -2247,44 +2258,44 @@ function qi(e) {
|
|
|
2247
2258
|
}
|
|
2248
2259
|
return {
|
|
2249
2260
|
src: e,
|
|
2250
|
-
destName:
|
|
2261
|
+
destName: g.basename(e)
|
|
2251
2262
|
};
|
|
2252
2263
|
}
|
|
2253
|
-
function
|
|
2254
|
-
return new
|
|
2264
|
+
function Yi(e, t) {
|
|
2265
|
+
return new h(e, t).argParser((e, t) => [...t ?? [], Ji(e)]).default([]);
|
|
2255
2266
|
}
|
|
2256
2267
|
// src/cmd/upload-package-v1.ts
|
|
2257
|
-
var
|
|
2268
|
+
var Xi = [
|
|
2258
2269
|
"registry",
|
|
2259
2270
|
"organization",
|
|
2260
2271
|
"package",
|
|
2261
2272
|
"version"
|
|
2262
2273
|
];
|
|
2263
|
-
function
|
|
2264
|
-
let e = new
|
|
2265
|
-
return e.addOption(new
|
|
2266
|
-
let t = new
|
|
2267
|
-
for (let t of
|
|
2268
|
-
e.meta && (e.meta.endsWith(".json") ? n.meta = JSON.parse(await
|
|
2274
|
+
function Zi() {
|
|
2275
|
+
let e = new m("upload-package-v1").description("Uploads V1 package and refreshes the registry");
|
|
2276
|
+
return e.addOption(new h("-r, --registry <address|alias>", "full address of the registry or alias from .pl.reg").env("PL_REGISTRY")), e.addOption(new h("-o, --organization <organization>", "target organisation").env("PL_PACKAGE_ORGANIZATION")), e.addOption(new h("-p, --package <package>", "target package").env("PL_PACKAGE_NAME")), e.addOption(new h("-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(Yi("-f, --file <file>", "package files")), e.addOption(new h("--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) => {
|
|
2277
|
+
let t = new b(), n = ee.parse({});
|
|
2278
|
+
for (let t of Xi) e[t] && (n[t] = e[t]);
|
|
2279
|
+
e.meta && (e.meta.endsWith(".json") ? n.meta = JSON.parse(await _.promises.readFile(e.meta, { encoding: "utf-8" })) : e.meta.endsWith(".yaml") && (n.meta = fe.parse(await _.promises.readFile(e.meta, { encoding: "utf-8" }))));
|
|
2269
2280
|
for (let t of e.file) n.files[t.destName] = t.src;
|
|
2270
2281
|
let r = await f(n);
|
|
2271
|
-
t.info(
|
|
2282
|
+
t.info(fe.stringify(r.conf));
|
|
2272
2283
|
let i = r.createRegistry(t), a = r.fullPackageName, o = i.constructNewPackage(a);
|
|
2273
2284
|
for (let [e, n] of Object.entries(r.conf.files)) {
|
|
2274
2285
|
t.info(`Uploading ${n} -> ${e} ...`);
|
|
2275
|
-
let r = await
|
|
2286
|
+
let r = await _.promises.readFile(n);
|
|
2276
2287
|
await o.addFile(e, r);
|
|
2277
2288
|
}
|
|
2278
2289
|
t.info("Uploading meta information..."), await o.writeMeta(r.conf.meta), await o.finish(), e.refresh && await i.updateIfNeeded();
|
|
2279
2290
|
}), e;
|
|
2280
2291
|
}
|
|
2281
2292
|
// src/cmd/structure/check.ts
|
|
2282
|
-
function
|
|
2283
|
-
let t = new
|
|
2293
|
+
function Qi(e) {
|
|
2294
|
+
let t = new m("check").description("Check block(s) against the canonical structure (read-only). Exits non-zero if any diff would land — used as the CI gate.");
|
|
2284
2295
|
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) => {
|
|
2285
|
-
let r = new
|
|
2296
|
+
let r = new b(), i = t.length > 0 ? Vi(t) : ["."], a = g.join(e, "src", "structure", "templates"), o = !1;
|
|
2286
2297
|
for (let e of i) {
|
|
2287
|
-
let t = await
|
|
2298
|
+
let t = await Bi({
|
|
2288
2299
|
blockPath: e,
|
|
2289
2300
|
isSdkInternal: !!n.sdkInternal,
|
|
2290
2301
|
updateDepsOnly: !1,
|
|
@@ -2292,40 +2303,40 @@ function Zi(e) {
|
|
|
2292
2303
|
templatesRoot: a,
|
|
2293
2304
|
log: (e) => r.info(e)
|
|
2294
2305
|
});
|
|
2295
|
-
r.info(
|
|
2306
|
+
r.info(Hi(e, t.changes)), t.changes.length > 0 && (o = !0);
|
|
2296
2307
|
}
|
|
2297
2308
|
if (o) throw Error("Structure check failed: one or more blocks are out of date. Run `structure refresh`.");
|
|
2298
2309
|
}), t;
|
|
2299
2310
|
}
|
|
2300
2311
|
// src/structure/init-block-constructor.ts
|
|
2301
|
-
var
|
|
2312
|
+
var $i = ["python"], ea = class extends Error {
|
|
2302
2313
|
constructor(e) {
|
|
2303
2314
|
super(`Missing required flag --${e} in --non-interactive mode. Supply every BlockVars flag, or drop --non-interactive to be prompted.`), this.name = "InitFlagError";
|
|
2304
2315
|
}
|
|
2305
2316
|
};
|
|
2306
|
-
async function
|
|
2317
|
+
async function ta(e, t, n, r) {
|
|
2307
2318
|
if (e !== void 0 && e !== "") return e;
|
|
2308
|
-
if (n) throw new
|
|
2319
|
+
if (n) throw new ea(t);
|
|
2309
2320
|
return r();
|
|
2310
2321
|
}
|
|
2311
|
-
async function
|
|
2312
|
-
let t = await
|
|
2322
|
+
async function na(e) {
|
|
2323
|
+
let t = await ta(e.npmOrg, "npm-org", e.nonInteractive, () => xe({
|
|
2313
2324
|
message: "npm org (e.g. @platforma-open):",
|
|
2314
2325
|
default: "@platforma-open"
|
|
2315
|
-
})), n = await
|
|
2316
|
-
i = e.withSoftware === void 0 ? !e.nonInteractive && await
|
|
2326
|
+
})), n = await ta(e.orgScope, "org-scope", e.nonInteractive, () => xe({ message: "org scope (e.g. my-org):" })), r = await ta(e.shortName, "short-name", e.nonInteractive, () => xe({ message: "block short name (e.g. mixcr-clonotyping):" })), i;
|
|
2327
|
+
i = e.withSoftware === void 0 ? !e.nonInteractive && await be({
|
|
2317
2328
|
message: "Include a software module?",
|
|
2318
2329
|
default: !1
|
|
2319
2330
|
}) : e.withSoftware;
|
|
2320
2331
|
let a;
|
|
2321
2332
|
if (i) {
|
|
2322
|
-
if (a = await
|
|
2333
|
+
if (a = await ta(e.platform, "platform", e.nonInteractive, () => Se({
|
|
2323
2334
|
message: "Software platform:",
|
|
2324
|
-
choices:
|
|
2335
|
+
choices: $i.map((e) => ({
|
|
2325
2336
|
name: e,
|
|
2326
2337
|
value: e
|
|
2327
2338
|
}))
|
|
2328
|
-
})),
|
|
2339
|
+
})), !$i.includes(a)) throw Error(`Unsupported --platform '${a}'. Only ${$i.join(", ")} ${$i.length === 1 ? "is" : "are"} supported at v1.`);
|
|
2329
2340
|
} else if (e.platform) throw Error("--platform was given but software is disabled (--no-software).");
|
|
2330
2341
|
return {
|
|
2331
2342
|
facadeName: `${t}/${n}.${r}`,
|
|
@@ -2336,8 +2347,8 @@ async function ta(e) {
|
|
|
2336
2347
|
softwarePlatform: a
|
|
2337
2348
|
};
|
|
2338
2349
|
}
|
|
2339
|
-
async function
|
|
2340
|
-
let t = e.vars, n = Ln(t), r = new
|
|
2350
|
+
async function ra(e) {
|
|
2351
|
+
let t = e.vars, n = Ln(t), r = new Fe(e.blockPath), i = new Ie(e.templatesRoot), a = Rn({
|
|
2341
2352
|
blockVars: t,
|
|
2342
2353
|
modules: n,
|
|
2343
2354
|
isSdkInternal: !1,
|
|
@@ -2349,7 +2360,7 @@ async function na(e) {
|
|
|
2349
2360
|
} catch (e) {
|
|
2350
2361
|
throw Error(`init requires network access to resolve SDK catalog versions from npm, but the registry lookup failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
2351
2362
|
}
|
|
2352
|
-
return On(
|
|
2363
|
+
return On(Ri, r, a, {
|
|
2353
2364
|
templates: i,
|
|
2354
2365
|
initMode: !0,
|
|
2355
2366
|
registryLookup: s,
|
|
@@ -2357,12 +2368,12 @@ async function na(e) {
|
|
|
2357
2368
|
}), e.log(`Initialised block '${t.facadeName}'${t.softwarePlatform ? ` (software: ${t.softwarePlatform})` : " (no software)"} at ${e.blockPath}`), t;
|
|
2358
2369
|
}
|
|
2359
2370
|
// src/cmd/structure/init.ts
|
|
2360
|
-
function
|
|
2361
|
-
let t = new
|
|
2362
|
-
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
|
|
2363
|
-
let r = new
|
|
2371
|
+
function ia(e) {
|
|
2372
|
+
let t = new m("init").description("Scaffold a fresh Platforma block from the canonical structure. Missing flags are prompted unless --non-interactive.");
|
|
2373
|
+
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 h("--platform <platform>", "software platform (single-valued)").choices([...$i])), t.option("--non-interactive", "error on any missing flag instead of prompting"), t.action(async (t, n) => {
|
|
2374
|
+
let r = new b(), i = n.withSoftware === !0, a = n.software === !1;
|
|
2364
2375
|
if (i && a) throw Error("--with-software and --no-software are mutually exclusive.");
|
|
2365
|
-
let o = i ? !0 : !a && void 0, s = await
|
|
2376
|
+
let o = i ? !0 : !a && void 0, s = await na({
|
|
2366
2377
|
npmOrg: n.npmOrg,
|
|
2367
2378
|
orgScope: n.orgScope,
|
|
2368
2379
|
shortName: n.shortName,
|
|
@@ -2370,24 +2381,24 @@ function ra(e) {
|
|
|
2370
2381
|
platform: n.platform,
|
|
2371
2382
|
nonInteractive: n.nonInteractive
|
|
2372
2383
|
});
|
|
2373
|
-
await
|
|
2384
|
+
await ra({
|
|
2374
2385
|
vars: s,
|
|
2375
|
-
blockPath: t ?
|
|
2376
|
-
templatesRoot:
|
|
2386
|
+
blockPath: t ? g.resolve(t) : g.resolve(process.cwd(), s.shortName),
|
|
2387
|
+
templatesRoot: g.join(e, "src", "structure", "templates"),
|
|
2377
2388
|
log: (e) => r.info(e)
|
|
2378
2389
|
});
|
|
2379
2390
|
}), t;
|
|
2380
2391
|
}
|
|
2381
2392
|
// src/cmd/software/knobs.ts
|
|
2382
|
-
var
|
|
2393
|
+
var aa = ["dev", "release"], oa = [
|
|
2383
2394
|
"docker",
|
|
2384
2395
|
"binary",
|
|
2385
2396
|
"all",
|
|
2386
2397
|
"none"
|
|
2387
|
-
],
|
|
2388
|
-
function
|
|
2398
|
+
], sa = ["local", "remote"];
|
|
2399
|
+
function ca(e) {
|
|
2389
2400
|
if (e.usePublished) {
|
|
2390
|
-
if (e.variant === "docker" || e.variant === "all") throw
|
|
2401
|
+
if (e.variant === "docker" || e.variant === "all") throw y.CLIError(`--use-published is binary-only and cannot be combined with --variant ${e.variant}`);
|
|
2391
2402
|
return { kind: "binary-existing" };
|
|
2392
2403
|
}
|
|
2393
2404
|
return e.variant === "none" ? { kind: "no-software" } : e.location === void 0 ? { kind: "bare" } : {
|
|
@@ -2398,33 +2409,33 @@ function sa(e) {
|
|
|
2398
2409
|
};
|
|
2399
2410
|
}
|
|
2400
2411
|
// src/cmd/software/ecr-login.ts
|
|
2401
|
-
var
|
|
2402
|
-
function
|
|
2412
|
+
var la = "public.ecr.aws", ua = "us-east-1";
|
|
2413
|
+
function da(e) {
|
|
2403
2414
|
if (process.env.AWS_ACCESS_KEY_ID || process.env.AWS_PROFILE) return;
|
|
2404
|
-
let t = process.env.PL_AWS_PROFILE ??
|
|
2415
|
+
let t = process.env.PL_AWS_PROFILE ?? de.AWS_DEV_PROFILE;
|
|
2405
2416
|
process.env.AWS_PROFILE = t, e?.debug(`Using AWS profile '${t}' for dev push credentials`);
|
|
2406
2417
|
}
|
|
2407
|
-
function
|
|
2418
|
+
function fa(e) {
|
|
2408
2419
|
return new URL(`https://${e}`).hostname;
|
|
2409
2420
|
}
|
|
2410
|
-
function
|
|
2411
|
-
return ` aws sso login --profile ${process.env.AWS_PROFILE ?? process.env.PL_AWS_PROFILE ??
|
|
2421
|
+
function pa() {
|
|
2422
|
+
return ` aws sso login --profile ${process.env.AWS_PROFILE ?? process.env.PL_AWS_PROFILE ?? de.AWS_DEV_PROFILE}`;
|
|
2412
2423
|
}
|
|
2413
|
-
async function
|
|
2414
|
-
let n =
|
|
2415
|
-
if (n !==
|
|
2424
|
+
async function ma(e, t) {
|
|
2425
|
+
let n = fa(e);
|
|
2426
|
+
if (n !== la) throw y.CLIError(`automatic docker login is only supported for '${la}', not '${n}'.\nLog in manually, or drop the ecr:// scheme from the push target to opt out.`);
|
|
2416
2427
|
t?.info(`Logging in to ECR registry '${n}'...`);
|
|
2417
2428
|
let r, i;
|
|
2418
2429
|
try {
|
|
2419
|
-
let e = (await new
|
|
2430
|
+
let e = (await new we({ region: ua }).send(new Te({}))).authorizationData?.authorizationToken;
|
|
2420
2431
|
if (!e) throw Error("empty authorization token");
|
|
2421
2432
|
let t = Buffer.from(e, "base64").toString("utf8"), n = t.indexOf(":");
|
|
2422
2433
|
if (n < 0) throw Error("malformed authorization token (no ':' separator)");
|
|
2423
2434
|
r = t.slice(0, n), i = t.slice(n + 1);
|
|
2424
2435
|
} catch (e) {
|
|
2425
|
-
throw
|
|
2436
|
+
throw y.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` + pa());
|
|
2426
2437
|
}
|
|
2427
|
-
let a =
|
|
2438
|
+
let a = Ce("docker", [
|
|
2428
2439
|
"login",
|
|
2429
2440
|
"--username",
|
|
2430
2441
|
r,
|
|
@@ -2439,15 +2450,15 @@ async function pa(e, t) {
|
|
|
2439
2450
|
],
|
|
2440
2451
|
env: {
|
|
2441
2452
|
...process.env,
|
|
2442
|
-
HOME: process.env.HOME ||
|
|
2453
|
+
HOME: process.env.HOME || ye.homedir()
|
|
2443
2454
|
}
|
|
2444
2455
|
});
|
|
2445
|
-
if (a.error || a.status !== 0) throw
|
|
2456
|
+
if (a.error || a.status !== 0) throw y.CLIError(`'docker login ${n}' failed`);
|
|
2446
2457
|
}
|
|
2447
2458
|
// src/cmd/software/run-build.ts
|
|
2448
|
-
async function
|
|
2459
|
+
async function ha(e) {
|
|
2449
2460
|
let { core: t, scenario: n, options: r = {}, logger: i } = e, a = r.ids;
|
|
2450
|
-
t.buildMode =
|
|
2461
|
+
t.buildMode = _a(n), ga(n) || t.assertDockerCoverage();
|
|
2451
2462
|
let o = () => t.buildSoftwareArchives({
|
|
2452
2463
|
ids: a,
|
|
2453
2464
|
forceBuild: !!r.force,
|
|
@@ -2464,101 +2475,101 @@ async function ma(e) {
|
|
|
2464
2475
|
r.buildDocker && t.buildDockerImages({
|
|
2465
2476
|
ids: a,
|
|
2466
2477
|
registry: r.dockerRegistry,
|
|
2467
|
-
strictPlatformMatching:
|
|
2478
|
+
strictPlatformMatching: v.isCI()
|
|
2468
2479
|
}), await o(), r.pushDocker && t.publishDockerImages({
|
|
2469
2480
|
ids: a,
|
|
2470
2481
|
pushTo: r.dockerPushTo,
|
|
2471
|
-
strictPlatformMatching:
|
|
2482
|
+
strictPlatformMatching: v.isCI()
|
|
2472
2483
|
});
|
|
2473
2484
|
break;
|
|
2474
2485
|
case "target": {
|
|
2475
|
-
let { channel: e, variant: s, location: c } = n, l = s !== "binary", u = s !== "docker", d = c === "remote", f =
|
|
2486
|
+
let { channel: e, variant: s, location: c } = n, l = s !== "binary", u = s !== "docker", d = c === "remote", f = ba(e, r);
|
|
2476
2487
|
l && t.buildDockerImages({
|
|
2477
2488
|
ids: a,
|
|
2478
2489
|
registry: f.pull,
|
|
2479
|
-
strictPlatformMatching:
|
|
2480
|
-
}), u && await o(), d && e === "dev" && (l || u) &&
|
|
2490
|
+
strictPlatformMatching: v.isCI()
|
|
2491
|
+
}), u && await o(), d && e === "dev" && (l || u) && da(i), l && d && (f.autoLogin && f.push && await ma(f.push, i), t.publishDockerImages({
|
|
2481
2492
|
ids: a,
|
|
2482
2493
|
pushTo: f.push,
|
|
2483
|
-
strictPlatformMatching:
|
|
2494
|
+
strictPlatformMatching: v.isCI()
|
|
2484
2495
|
})), u && d && await t.publishPackages({
|
|
2485
2496
|
ids: a,
|
|
2486
2497
|
storageURL: r.storageUrl
|
|
2487
2498
|
});
|
|
2488
2499
|
break;
|
|
2489
2500
|
}
|
|
2490
|
-
default:
|
|
2501
|
+
default: y.assertNever(n);
|
|
2491
2502
|
}
|
|
2492
2503
|
t.buildSwJsonFiles({
|
|
2493
2504
|
packageIds: a,
|
|
2494
2505
|
noSoftware: n.kind === "no-software",
|
|
2495
|
-
skipDockerCoverage:
|
|
2506
|
+
skipDockerCoverage: ga(n)
|
|
2496
2507
|
});
|
|
2497
2508
|
}
|
|
2498
|
-
function
|
|
2509
|
+
function ga(e) {
|
|
2499
2510
|
return e.kind === "no-software" || e.kind === "binary-existing";
|
|
2500
2511
|
}
|
|
2501
|
-
function
|
|
2512
|
+
function _a(e) {
|
|
2502
2513
|
return e.kind !== "target" || e.channel === "release" ? "release" : e.variant !== "docker" && e.location === "remote" ? "dev-remote" : "dev-local";
|
|
2503
2514
|
}
|
|
2504
|
-
function
|
|
2515
|
+
function va(e) {
|
|
2505
2516
|
if (!e.includes("://")) return e;
|
|
2506
2517
|
let t = new URL(e);
|
|
2507
2518
|
return t.host + t.pathname;
|
|
2508
2519
|
}
|
|
2509
|
-
function
|
|
2520
|
+
function ya(e) {
|
|
2510
2521
|
return {
|
|
2511
|
-
registry:
|
|
2522
|
+
registry: va(e),
|
|
2512
2523
|
autoLogin: e.startsWith("ecr://")
|
|
2513
2524
|
};
|
|
2514
2525
|
}
|
|
2515
|
-
function
|
|
2516
|
-
let n = e === "dev", r = process.env[n ?
|
|
2526
|
+
function ba(e, t) {
|
|
2527
|
+
let n = e === "dev", r = process.env[n ? v.PL_DEV_DOCKER_PUSH_URL : v.PL_RELEASE_DOCKER_PUSH_URL], i = process.env[n ? v.PL_DEV_DOCKER_PULL_URL : v.PL_RELEASE_DOCKER_PULL_URL], a = t.dockerPushTo ?? r ?? (n ? de.DEV_DOCKER_PUSH_TARGET : void 0), o = a ? ya(a) : {
|
|
2517
2528
|
registry: void 0,
|
|
2518
2529
|
autoLogin: !1
|
|
2519
|
-
}, s = t.dockerRegistry ?? i ?? (n ? a :
|
|
2530
|
+
}, s = t.dockerRegistry ?? i ?? (n ? a : de.DOCKER_REGISTRY);
|
|
2520
2531
|
return {
|
|
2521
|
-
pull: s ?
|
|
2532
|
+
pull: s ? va(s) : void 0,
|
|
2522
2533
|
push: o.registry,
|
|
2523
2534
|
autoLogin: o.autoLogin
|
|
2524
2535
|
};
|
|
2525
2536
|
}
|
|
2526
2537
|
// src/cmd/software/env.ts
|
|
2527
|
-
var
|
|
2528
|
-
|
|
2538
|
+
var xa = "PL_BUILD_CHANNEL", Sa = "PL_BUILD_VARIANT", Ca = "PL_BUILD_LOCATION", wa = "PL_BUILD_USE_PUBLISHED";
|
|
2539
|
+
v.PL_DOCKER_REGISTRY_PUSH_TO, v.PL_DEV_DOCKER_PUSH_URL, v.PL_DEV_DOCKER_PULL_URL, v.PL_DEV_BINARY_UPLOAD_URL, v.PL_RELEASE_DOCKER_PUSH_URL, v.PL_RELEASE_DOCKER_PULL_URL, v.PL_RELEASE_BINARY_UPLOAD_URL;
|
|
2529
2540
|
// src/cmd/software/build.ts
|
|
2530
|
-
function
|
|
2531
|
-
let e = new
|
|
2532
|
-
return e.addOption(new
|
|
2541
|
+
function Ta() {
|
|
2542
|
+
let e = new m("build").description("Build a software module for a target and write its .sw.json descriptor (build + push in one pass)");
|
|
2543
|
+
return e.addOption(new h("--channel <channel>", "registry channel to build for").choices([...aa]).env(xa)), e.addOption(new h("--variant <variant>", "artifact kind to build (default: all declared)").choices([...oa]).env(Sa)), e.addOption(new h("--location <location>", "where the artifact lands (local = no push)").choices([...sa]).env(Ca)), e.addOption(new h("--use-published", "do not build or push; emit a descriptor pointing at the already-published release artifact").env(wa)), e.addOption(new h("--log-level <level>", "logging level").choices([
|
|
2533
2544
|
"error",
|
|
2534
2545
|
"warn",
|
|
2535
2546
|
"info",
|
|
2536
2547
|
"debug"
|
|
2537
|
-
]).default("info")), e.addOption(new
|
|
2538
|
-
let t =
|
|
2548
|
+
]).default("info")), e.addOption(new h("--package-root <path>", "path to directory with package.json file")), e.addOption(new h("--force", "force action, ignoring automatic safety checks").default(!1)), e.addOption(new h("--version <value>", "override package version (ignore package.json)")), e.addOption(new h("--platform <os-arch>", "{os}-{arch} pair; no effect on cross-platform packages").choices([...y.AllPlatforms]).env(v.PL_PKG_OS)), e.addOption(new h("--all-platforms", "build for all supported platforms").default(!1)), e.addOption(new h("--full-dir-hash", "hash file contents (not metadata) for the dev content hash").env(v.PL_PKG_FULL_HASH).default(!1)), e.addOption(new h("--package-id <id...>", "act only on selected packages")), e.addOption(new h("--content-root <path>", "override software content root").env(v.PL_PKG_CONTENT_ROOT)), e.addOption(new h("--storage-url <url>", "override binary upload registry URL").env(v.PL_PKG_STORAGE_URL)), e.addOption(new h("--docker-registry <registry>", "docker pull registry embedded in the descriptor").env(v.PL_DOCKER_REGISTRY)), e.addOption(new h("--docker-push-to <registry>", "alternative registry for docker push").env(v.PL_DOCKER_REGISTRY_PUSH_TO)), e.addOption(new h("--docker-build", "build docker images").env(v.PL_DOCKER_BUILD).default(!1)), e.addOption(new h("--docker-no-build", "do not build docker images").env(v.PL_DOCKER_NO_BUILD).default(!1)), e.addOption(new h("--docker-autopush", "push docker images after build").env(v.PL_DOCKER_AUTOPUSH).default(!1)), e.addOption(new h("--docker-no-autopush", "do not push docker images").env(v.PL_DOCKER_NO_AUTOPUSH).default(!1)), e.addOption(new h("--conda-build", "build conda environment before packing").env(v.PL_CONDA_BUILD).default(!1)), e.addOption(new h("--conda-no-build", "do not build conda environment").env(v.PL_CONDA_NO_BUILD).default(!1)), e.action(async (e) => {
|
|
2549
|
+
let t = y.createLogger(e.logLevel);
|
|
2539
2550
|
try {
|
|
2540
|
-
let n =
|
|
2551
|
+
let n = ca({
|
|
2541
2552
|
channel: e.channel,
|
|
2542
2553
|
variant: e.variant,
|
|
2543
2554
|
location: e.location,
|
|
2544
2555
|
usePublished: !!e.usePublished
|
|
2545
|
-
}), r =
|
|
2556
|
+
}), r = ue(t, { packageRoot: e.packageRoot });
|
|
2546
2557
|
r.version = e.version, r.targetPlatform = e.platform, r.allPlatforms = !!e.allPlatforms, r.fullDirHash = !!e.fullDirHash;
|
|
2547
|
-
let i =
|
|
2548
|
-
default:
|
|
2558
|
+
let i = y.shouldDoAction({
|
|
2559
|
+
default: v.isCI(),
|
|
2549
2560
|
enable: e.dockerBuild,
|
|
2550
2561
|
disable: e.dockerNoBuild
|
|
2551
|
-
}), a = i &&
|
|
2552
|
-
default:
|
|
2562
|
+
}), a = i && y.shouldDoAction({
|
|
2563
|
+
default: v.isCI() && !r.isPrivate,
|
|
2553
2564
|
enable: e.dockerAutopush,
|
|
2554
2565
|
disable: e.dockerNoAutopush
|
|
2555
2566
|
});
|
|
2556
|
-
n.kind === "bare" &&
|
|
2567
|
+
n.kind === "bare" && le({
|
|
2557
2568
|
buildDocker: i,
|
|
2558
2569
|
pushDocker: a,
|
|
2559
2570
|
pushDisabledExplicitly: !!e.dockerNoAutopush,
|
|
2560
2571
|
dockerPackageCount: r.selectedDockerPackages(e.packageId).length
|
|
2561
|
-
}), await
|
|
2572
|
+
}), await ha({
|
|
2562
2573
|
core: r,
|
|
2563
2574
|
scenario: n,
|
|
2564
2575
|
logger: t,
|
|
@@ -2571,7 +2582,7 @@ function wa() {
|
|
|
2571
2582
|
dockerPushTo: e.dockerPushTo,
|
|
2572
2583
|
buildDocker: i,
|
|
2573
2584
|
pushDocker: a,
|
|
2574
|
-
condaBuild:
|
|
2585
|
+
condaBuild: y.shouldDoAction({
|
|
2575
2586
|
default: !0,
|
|
2576
2587
|
enable: e.condaBuild,
|
|
2577
2588
|
disable: e.condaNoBuild
|
|
@@ -2584,20 +2595,20 @@ function wa() {
|
|
|
2584
2595
|
}), e;
|
|
2585
2596
|
}
|
|
2586
2597
|
// src/cmd/software/index.ts
|
|
2587
|
-
function
|
|
2588
|
-
let e = new
|
|
2589
|
-
return e.addCommand(
|
|
2598
|
+
function Ea() {
|
|
2599
|
+
let e = new m("software").description("Build and publish a block's software modules");
|
|
2600
|
+
return e.addCommand(Ta()), e;
|
|
2590
2601
|
}
|
|
2591
2602
|
// src/cli.ts
|
|
2592
|
-
function
|
|
2593
|
-
let t = new
|
|
2594
|
-
t.name("block-tools").description("Utility to manipulate Platforma Blocks and Block Registry"), t.addCommand(
|
|
2595
|
-
let n = new
|
|
2596
|
-
return n.addCommand(
|
|
2603
|
+
function Da(e = process.cwd()) {
|
|
2604
|
+
let t = new m();
|
|
2605
|
+
t.name("block-tools").description("Utility to manipulate Platforma Blocks and Block Registry"), t.addCommand(Ee()), t.addCommand(Oe()), t.addCommand(ke()), t.addCommand(Ae()), t.addCommand(Me()), t.addCommand(Ne()), t.addCommand(Pe()), t.addCommand(Gi(e)), t.addCommand(Ki()), t.addCommand(qi()), t.addCommand(Zi()), t.addCommand(Ea());
|
|
2606
|
+
let n = new m("structure").description("Manage block scaffolding against the canonical structure (check / init / refresh)");
|
|
2607
|
+
return n.addCommand(Qi(e)), n.addCommand(ia(e)), n.addCommand(Wi(e)), t.addCommand(n), t;
|
|
2597
2608
|
}
|
|
2598
|
-
async function
|
|
2599
|
-
await
|
|
2609
|
+
async function Oa(e, t) {
|
|
2610
|
+
await Da(t).parseAsync(e);
|
|
2600
2611
|
}
|
|
2601
|
-
export {
|
|
2612
|
+
export { Da as buildProgram, Oa as run };
|
|
2602
2613
|
|
|
2603
2614
|
//# sourceMappingURL=cli.mjs.map
|