@platforma-sdk/block-tools 2.11.9 → 2.12.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 +13 -13
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +845 -625
- package/dist/cli.mjs.map +1 -1
- package/dist/cmd/software/build.d.ts +2 -0
- package/dist/cmd/software/ecr-login.d.ts +3 -0
- package/dist/cmd/software/env.d.ts +5 -0
- package/dist/cmd/software/index.d.ts +2 -0
- package/dist/cmd/software/knobs.d.ts +26 -0
- package/dist/cmd/software/run-build.d.ts +19 -0
- package/dist/structure/engine/version.d.ts +5 -4
- package/dist/structure/rules/root-package-json.d.ts +1 -2
- package/dist/structure/rules/root-pnpm-workspace.d.ts +7 -1
- package/package.json +11 -9
- package/src/cli.test.ts +20 -1
- package/src/cli.ts +2 -0
- package/src/cmd/software/build.ts +175 -0
- package/src/cmd/software/ecr-login.test.ts +92 -0
- package/src/cmd/software/ecr-login.ts +75 -0
- package/src/cmd/software/env.test.ts +17 -0
- package/src/cmd/software/env.ts +22 -0
- package/src/cmd/software/index.ts +9 -0
- package/src/cmd/software/knobs.test.ts +52 -0
- package/src/cmd/software/knobs.ts +61 -0
- package/src/cmd/software/run-build.test.ts +291 -0
- package/src/cmd/software/run-build.ts +156 -0
- package/src/structure/__tests__/floor-version.test.ts +2 -2
- package/src/structure/engine/__tests__/version.test.ts +14 -17
- package/src/structure/engine/discovery-fs.ts +4 -13
- package/src/structure/engine/runner.ts +4 -4
- package/src/structure/engine/version.ts +11 -13
- package/src/structure/rules/migrations.ts +1 -1
- package/src/structure/rules/root-package-json.ts +38 -14
- package/src/structure/rules/root-pnpm-workspace.ts +8 -1
- package/src/structure/rules/root.ts +1 -1
- package/src/structure/rules/software-package-json.ts +23 -10
- package/src/structure/templates/static/root/turbo.json +15 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,120 +1,124 @@
|
|
|
1
|
-
import { H as e, O as t, Q as n, Tt as r, W as i, Y as a, _ as o, b as s, n as c, p as l, q as u, st as d, ut as
|
|
2
|
-
import { Command as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { BlockPackManifest as
|
|
6
|
-
import { ConsoleLoggerAdapter as
|
|
7
|
-
import
|
|
8
|
-
import { setTimeout as
|
|
1
|
+
import { H as e, O as t, Q as n, Tt as r, W as i, Y as a, _ as o, b as s, n as c, p as l, q as u, st as d, ut as f } from "./config-CiC347sB.mjs";
|
|
2
|
+
import { Command as p, Option as m } from "commander";
|
|
3
|
+
import h from "node:path";
|
|
4
|
+
import g from "node:fs";
|
|
5
|
+
import { BlockPackManifest as ee, StableChannel as te, overrideDescriptionVersion as ne, overrideManifestVersion as re } from "@milaboratories/pl-model-middle-layer";
|
|
6
|
+
import { ConsoleLoggerAdapter as _ } from "@milaboratories/ts-helpers";
|
|
7
|
+
import ie, { parse as ae, parseDocument as oe, stringify as se } from "yaml";
|
|
8
|
+
import { setTimeout as ce } from "node:timers/promises";
|
|
9
|
+
import * as le from "node:os";
|
|
9
10
|
import { confirm as ue, input as de, select as fe } from "@inquirer/prompts";
|
|
11
|
+
import { createBuilder as pe, defaults as me, envs as v, util as y } from "@platforma-sdk/package-builder-lib";
|
|
12
|
+
import { spawnSync as he } from "node:child_process";
|
|
13
|
+
import { ECRPUBLICClient as ge, GetAuthorizationTokenCommand as _e } from "@aws-sdk/client-ecr-public";
|
|
10
14
|
//#region src/cmd/build-meta.ts
|
|
11
|
-
function
|
|
12
|
-
let e = new
|
|
15
|
+
function ve() {
|
|
16
|
+
let e = new p("build-meta").description("Extracts meta information from blocks package.json and outputs meta.json with embedded binary and textual information linked from the meta section.");
|
|
13
17
|
return e.option("-i, --modulePath <path>", "input module path", "."), e.requiredOption("-o, --destination <path>", "output meta.json file"), e.action(async (e) => {
|
|
14
|
-
let t =
|
|
15
|
-
await
|
|
18
|
+
let t = h.resolve(e.modulePath), n = await d(await f((await a(t)).meta, t));
|
|
19
|
+
await g.promises.writeFile(h.resolve(e.destination), JSON.stringify(n));
|
|
16
20
|
}), e;
|
|
17
21
|
}
|
|
18
22
|
//#endregion
|
|
19
23
|
//#region src/cmd/build-model.ts
|
|
20
|
-
async function
|
|
24
|
+
async function ye(e) {
|
|
21
25
|
try {
|
|
22
|
-
return await
|
|
26
|
+
return await g.promises.readFile(e, "utf8");
|
|
23
27
|
} catch (e) {
|
|
24
28
|
if (e instanceof Error && "code" in e && e.code === "ENOENT") return;
|
|
25
29
|
throw e;
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
|
-
function
|
|
29
|
-
let e = new
|
|
32
|
+
function be() {
|
|
33
|
+
let e = new p("build-model").description("Extracts and outputs block model JSON from pre-built block model module");
|
|
30
34
|
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) => {
|
|
31
|
-
let { model: t, platforma: n } = r(
|
|
35
|
+
let { model: t, platforma: n } = r(h.resolve(e.modulePath));
|
|
32
36
|
if (t ||= n, !t) throw Error("\"model\" export not found");
|
|
33
37
|
let { config: i } = t;
|
|
34
38
|
if (!i) throw Error("Malformed \"model\" object, check it is created with \"BlockModel\" and \".done()\" is executed as the call in the chain.");
|
|
35
39
|
if (!("outputs" in i) || !("sections" in i)) throw Error("\"config\" has unexpected structure");
|
|
36
|
-
let a = await
|
|
40
|
+
let a = await ye(e.sourceBundle);
|
|
37
41
|
a !== void 0 && (i.code = {
|
|
38
42
|
type: "plain",
|
|
39
43
|
content: a
|
|
40
|
-
}), await
|
|
44
|
+
}), await g.promises.writeFile(h.resolve(e.destination), JSON.stringify(i));
|
|
41
45
|
}), e;
|
|
42
46
|
}
|
|
43
47
|
//#endregion
|
|
44
48
|
//#region src/cmd/pack.ts
|
|
45
|
-
function
|
|
46
|
-
let e = new
|
|
49
|
+
function xe() {
|
|
50
|
+
let e = new p("pack").description("Builds block pack and outputs a block pack manifest consolidating all references assets into a single folder");
|
|
47
51
|
return e.option("-i, --modulePath <path>", "input module path", "."), e.option("-o, --destinationPath <path>", "output folder", "./block-pack"), e.action(async (e) => {
|
|
48
|
-
await n(await u(
|
|
52
|
+
await n(await u(h.resolve(e.modulePath)), h.resolve(e.destinationPath));
|
|
49
53
|
}), e;
|
|
50
54
|
}
|
|
51
55
|
//#endregion
|
|
52
56
|
//#region src/cmd/publish.ts
|
|
53
|
-
function
|
|
57
|
+
function Se(e, t) {
|
|
54
58
|
let n = { ...e };
|
|
55
|
-
for (let e in t) t[e] && typeof t[e] == "object" && !Array.isArray(t[e]) && n[e] && typeof n[e] == "object" && !Array.isArray(n[e]) ? n[e] =
|
|
59
|
+
for (let e in t) t[e] && typeof t[e] == "object" && !Array.isArray(t[e]) && n[e] && typeof n[e] == "object" && !Array.isArray(n[e]) ? n[e] = Se(n[e], t[e]) : n[e] = t[e];
|
|
56
60
|
return n;
|
|
57
61
|
}
|
|
58
|
-
function
|
|
59
|
-
let n = new
|
|
60
|
-
return n.addOption(new
|
|
61
|
-
let n = new
|
|
62
|
-
c =
|
|
63
|
-
let l =
|
|
64
|
-
n.info(`Manifest root = ${l}`), t.versionOverride && (c =
|
|
62
|
+
function Ce() {
|
|
63
|
+
let n = new p("publish").description("Publishes the block package and refreshes the registry (for v2 block-pack schema)");
|
|
64
|
+
return n.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), n.addOption(new m("--registry-serve-url <url>", "CDN serve URL written into block-pack/published.json (npm-consumed blocks)").env("PL_REGISTRY_SERVE_URL").makeOptionMandatory()), n.option("-m, --manifest <path>", "manifest file path", `./block-pack/${t}`), n.option("-v, --version-override <path>", "override package version"), n.addOption(new m("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), n.option("--no-refresh", "do not refresh repository after adding the package"), n.addOption(new m("--unstable", "do not add the published package to stable channel").default(!1).env("PL_PUBLISH_UNSTABLE")), n.action(async (t) => {
|
|
65
|
+
let n = new _(), r = h.resolve(t.manifest), a = JSON.parse(await g.promises.readFile(r, { encoding: "utf-8" })), c = ee.parse(a);
|
|
66
|
+
c = Se(a, c);
|
|
67
|
+
let l = h.dirname(r);
|
|
68
|
+
n.info(`Manifest root = ${l}`), t.versionOverride && (c = re(c, t.versionOverride));
|
|
65
69
|
let u = new s(o(t.registry), n);
|
|
66
|
-
await u.publishPackage(c, async (e) => Buffer.from(await
|
|
70
|
+
await u.publishPackage(c, async (e) => Buffer.from(await g.promises.readFile(h.resolve(l, e)))), t.unstable || (n.info(`Adding package to ${te} channel...`), await u.addPackageToChannel(c.description.id, te)), await i(l, e({
|
|
67
71
|
registryUrl: t.registryServeUrl,
|
|
68
72
|
id: c.description.id
|
|
69
|
-
})), n.info(`Wrote published coordinates to ${
|
|
73
|
+
})), n.info(`Wrote published coordinates to ${h.resolve(l, "published.json")}`), t.refresh && await u.updateIfNeeded();
|
|
70
74
|
}), n;
|
|
71
75
|
}
|
|
72
76
|
//#endregion
|
|
73
77
|
//#region src/cmd/refresh-registry.ts
|
|
74
|
-
function
|
|
75
|
-
let e = new
|
|
76
|
-
return e.addOption(new
|
|
78
|
+
function we() {
|
|
79
|
+
let e = new p("refresh-registry").description("Refresh overview files based on published but not proecessed artefacts");
|
|
80
|
+
return e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new m("-m, --mode <mode>", "refresh mode (allowed valiues: \"force\", \"normal\", \"dry-run\")").choices([
|
|
77
81
|
"force",
|
|
78
82
|
"normal",
|
|
79
83
|
"dry-run"
|
|
80
84
|
]).env("PL_REGISTRY_REFRESH_DRY_RUN").default("normal")), e.action(async (e) => {
|
|
81
|
-
await new s(o(e.registry), new
|
|
85
|
+
await new s(o(e.registry), new _()).updateIfNeeded(e.mode);
|
|
82
86
|
}), e;
|
|
83
87
|
}
|
|
84
88
|
//#endregion
|
|
85
89
|
//#region src/cmd/mark-stable.ts
|
|
86
|
-
function
|
|
87
|
-
let e = new
|
|
88
|
-
return e.option("-i, --modulePath <path>", "input module path", "."), e.addOption(new
|
|
89
|
-
let t = await a(
|
|
90
|
-
e.versionOverride && (t =
|
|
91
|
-
let n = new s(o(e.registry), new
|
|
90
|
+
function Te() {
|
|
91
|
+
let e = new p("mark-stable").description("Mark target block stable");
|
|
92
|
+
return e.option("-i, --modulePath <path>", "input module path", "."), e.addOption(new m("-c, --channel <channel name>", "custom channel").default(te).hideHelp()), e.option("-v, --version-override <path>", "override package version"), e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new m("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), e.option("--no-refresh", "do not refresh repository after adding the package"), e.option("--unmark", "reverses meaning of this command, flag can be used to remove \"stable\" flag from the package", !1), e.action(async (e) => {
|
|
93
|
+
let t = await a(h.resolve(e.modulePath));
|
|
94
|
+
e.versionOverride && (t = ne(t, e.versionOverride));
|
|
95
|
+
let n = new s(o(e.registry), new _());
|
|
92
96
|
e.unmark ? await n.removePackageFromChannel(t.id, e.channel) : await n.addPackageToChannel(t.id, e.channel), e.refresh && await n.updateIfNeeded();
|
|
93
97
|
}), e;
|
|
94
98
|
}
|
|
95
99
|
//#endregion
|
|
96
100
|
//#region src/structure/engine/fs/node.ts
|
|
97
|
-
var
|
|
101
|
+
var Ee = class {
|
|
98
102
|
constructor(e) {
|
|
99
103
|
this.root = e;
|
|
100
104
|
}
|
|
101
105
|
abs(e) {
|
|
102
|
-
return
|
|
106
|
+
return h.resolve(this.root, e);
|
|
103
107
|
}
|
|
104
108
|
read(e) {
|
|
105
|
-
return
|
|
109
|
+
return g.readFileSync(this.abs(e), "utf-8");
|
|
106
110
|
}
|
|
107
111
|
write(e, t) {
|
|
108
112
|
let n = this.abs(e);
|
|
109
|
-
|
|
113
|
+
g.mkdirSync(h.dirname(n), { recursive: !0 }), g.writeFileSync(n, t, "utf-8");
|
|
110
114
|
}
|
|
111
115
|
writeBinary(e, t) {
|
|
112
116
|
let n = this.abs(e);
|
|
113
|
-
|
|
117
|
+
g.mkdirSync(h.dirname(n), { recursive: !0 }), g.writeFileSync(n, t);
|
|
114
118
|
}
|
|
115
119
|
exists(e) {
|
|
116
120
|
try {
|
|
117
|
-
return
|
|
121
|
+
return g.statSync(this.abs(e)), !0;
|
|
118
122
|
} catch {
|
|
119
123
|
return !1;
|
|
120
124
|
}
|
|
@@ -122,15 +126,15 @@ var xe = class {
|
|
|
122
126
|
list(e) {
|
|
123
127
|
let t = this.abs(e);
|
|
124
128
|
try {
|
|
125
|
-
if (!
|
|
129
|
+
if (!g.statSync(t).isDirectory()) return [];
|
|
126
130
|
} catch {
|
|
127
131
|
return [];
|
|
128
132
|
}
|
|
129
133
|
let n = [];
|
|
130
134
|
function r(e, t) {
|
|
131
|
-
let i =
|
|
135
|
+
let i = g.readdirSync(t, { withFileTypes: !0 });
|
|
132
136
|
for (let a of i) {
|
|
133
|
-
let i = e ? `${e}/${a.name}` : a.name, o =
|
|
137
|
+
let i = e ? `${e}/${a.name}` : a.name, o = h.join(t, a.name);
|
|
134
138
|
a.isDirectory() ? r(i, o) : a.isFile() && n.push(i);
|
|
135
139
|
}
|
|
136
140
|
}
|
|
@@ -139,7 +143,7 @@ var xe = class {
|
|
|
139
143
|
listDir(e) {
|
|
140
144
|
let t = this.abs(e), n;
|
|
141
145
|
try {
|
|
142
|
-
n =
|
|
146
|
+
n = g.readdirSync(t, { withFileTypes: !0 });
|
|
143
147
|
} catch {
|
|
144
148
|
return [];
|
|
145
149
|
}
|
|
@@ -150,48 +154,48 @@ var xe = class {
|
|
|
150
154
|
}
|
|
151
155
|
move(e, t) {
|
|
152
156
|
let n = this.abs(e), r = this.abs(t);
|
|
153
|
-
|
|
157
|
+
g.mkdirSync(h.dirname(r), { recursive: !0 }), g.renameSync(n, r);
|
|
154
158
|
}
|
|
155
159
|
delete(e) {
|
|
156
|
-
|
|
160
|
+
g.rmSync(this.abs(e), {
|
|
157
161
|
recursive: !0,
|
|
158
162
|
force: !0
|
|
159
163
|
});
|
|
160
164
|
}
|
|
161
|
-
},
|
|
165
|
+
}, De = class {
|
|
162
166
|
constructor(e) {
|
|
163
167
|
this.root = e;
|
|
164
168
|
}
|
|
165
169
|
staticRead(e) {
|
|
166
|
-
return
|
|
170
|
+
return g.readFileSync(h.resolve(this.root, "static", e), "utf-8");
|
|
167
171
|
}
|
|
168
172
|
staticReadBinary(e) {
|
|
169
|
-
return
|
|
173
|
+
return g.readFileSync(h.resolve(this.root, "static", e));
|
|
170
174
|
}
|
|
171
175
|
textRead(e) {
|
|
172
|
-
return
|
|
176
|
+
return g.readFileSync(h.resolve(this.root, "text", e), "utf-8");
|
|
173
177
|
}
|
|
174
178
|
};
|
|
175
|
-
function
|
|
179
|
+
function Oe(e, t) {
|
|
176
180
|
return e.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (e, n) => t[n] ?? `\${${n}}`);
|
|
177
181
|
}
|
|
178
182
|
//#endregion
|
|
179
183
|
//#region src/structure/engine/flatten.ts
|
|
180
|
-
var
|
|
181
|
-
function
|
|
184
|
+
var ke = ["default", "init"];
|
|
185
|
+
function Ae(e, t) {
|
|
182
186
|
if (!e) return t;
|
|
183
187
|
if (!t) return e;
|
|
184
188
|
let n = e.endsWith("/") ? e.slice(0, -1) : e, r = t.startsWith("/") ? t.slice(1) : t;
|
|
185
189
|
return r ? `${n}/${r}` : n;
|
|
186
190
|
}
|
|
187
|
-
function
|
|
191
|
+
function je(e, t) {
|
|
188
192
|
return e.filter((e) => e.scope === t).slice().sort((e, t) => e.path.localeCompare(t.path));
|
|
189
193
|
}
|
|
190
|
-
function
|
|
194
|
+
function Me(e, t) {
|
|
191
195
|
let n = [];
|
|
192
196
|
function r(e, i, a, o, s) {
|
|
193
197
|
if (e.kind === "scope") {
|
|
194
|
-
let n =
|
|
198
|
+
let n = je(t.modules, e.scope);
|
|
195
199
|
for (let t of n) for (let n of e.children) r(n, e.scope, t.path, o, s);
|
|
196
200
|
return;
|
|
197
201
|
}
|
|
@@ -204,14 +208,14 @@ function De(e, t) {
|
|
|
204
208
|
for (let t of e.children) r(t, i, a, o, e.modes);
|
|
205
209
|
return;
|
|
206
210
|
}
|
|
207
|
-
if (i === void 0 || a === void 0) throw Error(`flatten: leaf '${
|
|
211
|
+
if (i === void 0 || a === void 0) throw Error(`flatten: leaf '${Pe(e)}' is not inside a scope() frame`);
|
|
208
212
|
if (e.kind === "rename") {
|
|
209
213
|
n.push({
|
|
210
214
|
leaf: e,
|
|
211
215
|
scope: i,
|
|
212
216
|
modulePath: a,
|
|
213
|
-
resolvedPath:
|
|
214
|
-
resolvedTo:
|
|
217
|
+
resolvedPath: Ae(a, e.from),
|
|
218
|
+
resolvedTo: Ae(a, e.to),
|
|
215
219
|
triggers: o,
|
|
216
220
|
modes: s
|
|
217
221
|
});
|
|
@@ -221,15 +225,15 @@ function De(e, t) {
|
|
|
221
225
|
leaf: e,
|
|
222
226
|
scope: i,
|
|
223
227
|
modulePath: a,
|
|
224
|
-
resolvedPath:
|
|
228
|
+
resolvedPath: Ae(a, Ne(e)),
|
|
225
229
|
triggers: o,
|
|
226
230
|
modes: s
|
|
227
231
|
});
|
|
228
232
|
}
|
|
229
|
-
for (let t of e.children) r(t, void 0, void 0, [],
|
|
233
|
+
for (let t of e.children) r(t, void 0, void 0, [], ke);
|
|
230
234
|
return n;
|
|
231
235
|
}
|
|
232
|
-
function
|
|
236
|
+
function Ne(e) {
|
|
233
237
|
switch (e.kind) {
|
|
234
238
|
case "fixed":
|
|
235
239
|
case "managed":
|
|
@@ -239,63 +243,63 @@ function Oe(e) {
|
|
|
239
243
|
case "rename": return e.from;
|
|
240
244
|
}
|
|
241
245
|
}
|
|
242
|
-
function
|
|
246
|
+
function Pe(e) {
|
|
243
247
|
return e.kind === "rename" ? `rename ${e.from} -> ${e.to}` : `${e.kind} ${e.path}`;
|
|
244
248
|
}
|
|
245
249
|
//#endregion
|
|
246
250
|
//#region src/structure/engine/glob.ts
|
|
247
|
-
var
|
|
248
|
-
function
|
|
251
|
+
var Fe = /[.+^${}()|[\]\\]/g;
|
|
252
|
+
function Ie(e) {
|
|
249
253
|
let t = "";
|
|
250
254
|
for (let n = 0; n < e.length; n++) {
|
|
251
255
|
let r = e[n];
|
|
252
|
-
r === "*" ? e[n + 1] === "*" ? (n++, e[n + 1] === "/" ? (n++, t += "(?:.*/)?") : t += ".*") : t += "[^/]*" : r === "?" ? t += "[^/]" : t += r.replace(
|
|
256
|
+
r === "*" ? e[n + 1] === "*" ? (n++, e[n + 1] === "/" ? (n++, t += "(?:.*/)?") : t += ".*") : t += "[^/]*" : r === "?" ? t += "[^/]" : t += r.replace(Fe, "\\$&");
|
|
253
257
|
}
|
|
254
258
|
return RegExp(`^${t}$`);
|
|
255
259
|
}
|
|
256
|
-
function
|
|
257
|
-
return
|
|
260
|
+
function Le(e, t) {
|
|
261
|
+
return Ie(e).test(t);
|
|
258
262
|
}
|
|
259
263
|
//#endregion
|
|
260
264
|
//#region src/structure/engine/builders.ts
|
|
261
|
-
var
|
|
262
|
-
function
|
|
263
|
-
if (!
|
|
264
|
-
return
|
|
265
|
+
var b, Re;
|
|
266
|
+
function ze(e) {
|
|
267
|
+
if (!b) throw Error(`${e}() called outside defineStructure(). Builders must run inside the lambda passed to defineStructure(...).`);
|
|
268
|
+
return b;
|
|
265
269
|
}
|
|
266
|
-
function
|
|
267
|
-
let n =
|
|
270
|
+
function x(e, t) {
|
|
271
|
+
let n = ze(e);
|
|
268
272
|
n.stack[n.stack.length - 1].push(t);
|
|
269
273
|
}
|
|
270
|
-
function
|
|
271
|
-
let n =
|
|
272
|
-
|
|
274
|
+
function Be(e, t) {
|
|
275
|
+
let n = Re;
|
|
276
|
+
Re = e;
|
|
273
277
|
try {
|
|
274
278
|
return t();
|
|
275
279
|
} finally {
|
|
276
|
-
|
|
280
|
+
Re = n;
|
|
277
281
|
}
|
|
278
282
|
}
|
|
279
|
-
function
|
|
280
|
-
return
|
|
283
|
+
function Ve() {
|
|
284
|
+
return Re;
|
|
281
285
|
}
|
|
282
|
-
function
|
|
283
|
-
if (
|
|
286
|
+
function He(e) {
|
|
287
|
+
if (b) throw Error("defineStructure() cannot be called from inside another defineStructure().");
|
|
284
288
|
let t = [], n = {
|
|
285
289
|
root: t,
|
|
286
290
|
stack: [t],
|
|
287
291
|
inScope: !1
|
|
288
292
|
};
|
|
289
|
-
|
|
293
|
+
b = n;
|
|
290
294
|
try {
|
|
291
295
|
if (e(), n.stack.length !== 1) throw Error(`defineStructure: builder body left ${n.stack.length - 1} unclosed group frame(s)`);
|
|
292
296
|
let r = { children: t };
|
|
293
|
-
return
|
|
297
|
+
return Ue(r), r;
|
|
294
298
|
} finally {
|
|
295
|
-
|
|
299
|
+
b = void 0;
|
|
296
300
|
}
|
|
297
301
|
}
|
|
298
|
-
function
|
|
302
|
+
function Ue(e) {
|
|
299
303
|
let t = /* @__PURE__ */ new Map();
|
|
300
304
|
function n(e, r) {
|
|
301
305
|
if (e.kind === "scope") {
|
|
@@ -318,8 +322,8 @@ function Le(e) {
|
|
|
318
322
|
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.`);
|
|
319
323
|
}
|
|
320
324
|
}
|
|
321
|
-
function
|
|
322
|
-
let n =
|
|
325
|
+
function S(e, t) {
|
|
326
|
+
let n = ze("scope");
|
|
323
327
|
if (n.inScope) throw Error("scope() cannot nest. Already inside a scope.");
|
|
324
328
|
let r = {
|
|
325
329
|
kind: "scope",
|
|
@@ -333,22 +337,22 @@ function b(e, t) {
|
|
|
333
337
|
n.stack.pop(), n.inScope = !1;
|
|
334
338
|
}
|
|
335
339
|
}
|
|
336
|
-
var
|
|
337
|
-
function
|
|
338
|
-
|
|
340
|
+
var We;
|
|
341
|
+
function Ge(e) {
|
|
342
|
+
We = e;
|
|
339
343
|
}
|
|
340
|
-
function
|
|
341
|
-
|
|
344
|
+
function C(e, t, n) {
|
|
345
|
+
Ke(e, t), n && Ke((t) => !e(t), n);
|
|
342
346
|
}
|
|
343
|
-
function
|
|
344
|
-
if (
|
|
345
|
-
|
|
347
|
+
function Ke(e, t) {
|
|
348
|
+
if (b) {
|
|
349
|
+
qe(e, t);
|
|
346
350
|
return;
|
|
347
351
|
}
|
|
348
|
-
if (!(
|
|
352
|
+
if (!(We?.(e, t) ?? !1)) throw Error("when() called outside defineStructure() and outside any managed(...) body. Place this call inside one of the two.");
|
|
349
353
|
}
|
|
350
|
-
function
|
|
351
|
-
let n =
|
|
354
|
+
function qe(e, t) {
|
|
355
|
+
let n = b, r = {
|
|
352
356
|
kind: "when",
|
|
353
357
|
trigger: e,
|
|
354
358
|
children: []
|
|
@@ -360,11 +364,11 @@ function Ve(e, t) {
|
|
|
360
364
|
n.stack.pop();
|
|
361
365
|
}
|
|
362
366
|
}
|
|
363
|
-
function
|
|
367
|
+
function w(e) {
|
|
364
368
|
return (t) => t.filesMatch(e);
|
|
365
369
|
}
|
|
366
|
-
function
|
|
367
|
-
let r =
|
|
370
|
+
function Je(e, t, n) {
|
|
371
|
+
let r = ze(e), i = {
|
|
368
372
|
kind: "mode",
|
|
369
373
|
modes: t,
|
|
370
374
|
children: []
|
|
@@ -376,70 +380,70 @@ function He(e, t, n) {
|
|
|
376
380
|
r.stack.pop();
|
|
377
381
|
}
|
|
378
382
|
}
|
|
379
|
-
function
|
|
380
|
-
|
|
383
|
+
function Ye(e) {
|
|
384
|
+
Je("onInitOrUpdate", ["init", "updateDeps"], e);
|
|
381
385
|
}
|
|
382
|
-
function
|
|
383
|
-
|
|
386
|
+
function T(e, t) {
|
|
387
|
+
x("fixed", {
|
|
384
388
|
kind: "fixed",
|
|
385
389
|
path: e,
|
|
386
390
|
content: t
|
|
387
391
|
});
|
|
388
392
|
}
|
|
389
|
-
function
|
|
390
|
-
|
|
393
|
+
function E(e, t, n) {
|
|
394
|
+
x("managed", {
|
|
391
395
|
kind: "managed",
|
|
392
396
|
path: e,
|
|
393
397
|
initial: t,
|
|
394
398
|
body: n
|
|
395
399
|
});
|
|
396
400
|
}
|
|
397
|
-
function
|
|
398
|
-
|
|
401
|
+
function D(e, t) {
|
|
402
|
+
x("scaffold", {
|
|
399
403
|
kind: "scaffold",
|
|
400
404
|
path: e,
|
|
401
405
|
initial: t
|
|
402
406
|
});
|
|
403
407
|
}
|
|
404
|
-
function
|
|
405
|
-
|
|
408
|
+
function O(e, t) {
|
|
409
|
+
x("seed", {
|
|
406
410
|
kind: "seed",
|
|
407
411
|
path: e,
|
|
408
412
|
initial: t
|
|
409
413
|
});
|
|
410
414
|
}
|
|
411
|
-
function
|
|
412
|
-
|
|
415
|
+
function k(e) {
|
|
416
|
+
x("remove", {
|
|
413
417
|
kind: "remove",
|
|
414
418
|
path: e
|
|
415
419
|
});
|
|
416
420
|
}
|
|
417
|
-
function
|
|
421
|
+
function A(e) {
|
|
418
422
|
return {
|
|
419
423
|
kind: "file",
|
|
420
424
|
path: e
|
|
421
425
|
};
|
|
422
426
|
}
|
|
423
|
-
function
|
|
427
|
+
function Xe(e) {
|
|
424
428
|
return {
|
|
425
429
|
kind: "binary",
|
|
426
430
|
path: e
|
|
427
431
|
};
|
|
428
432
|
}
|
|
429
|
-
function
|
|
433
|
+
function Ze(e) {
|
|
430
434
|
return {
|
|
431
435
|
kind: "text",
|
|
432
436
|
value: e
|
|
433
437
|
};
|
|
434
438
|
}
|
|
435
|
-
function
|
|
439
|
+
function j(e, t) {
|
|
436
440
|
return {
|
|
437
441
|
kind: "tpl",
|
|
438
442
|
path: e,
|
|
439
443
|
vars: t
|
|
440
444
|
};
|
|
441
445
|
}
|
|
442
|
-
function
|
|
446
|
+
function M(e) {
|
|
443
447
|
return {
|
|
444
448
|
kind: "generate",
|
|
445
449
|
fn: e
|
|
@@ -447,69 +451,69 @@ function A(e) {
|
|
|
447
451
|
}
|
|
448
452
|
//#endregion
|
|
449
453
|
//#region src/structure/engine/parsers/json.ts
|
|
450
|
-
function
|
|
454
|
+
function Qe(e) {
|
|
451
455
|
return JSON.parse(e);
|
|
452
456
|
}
|
|
453
|
-
var
|
|
454
|
-
function
|
|
455
|
-
return e.length === 0 ? "[]" : "[" + e.map(
|
|
457
|
+
var $e = 100, et = 2;
|
|
458
|
+
function tt(e) {
|
|
459
|
+
return e.length === 0 ? "[]" : "[" + e.map(nt).join(", ") + "]";
|
|
456
460
|
}
|
|
457
|
-
function
|
|
458
|
-
if (Array.isArray(e)) return
|
|
459
|
-
if (
|
|
461
|
+
function nt(e) {
|
|
462
|
+
if (Array.isArray(e)) return tt(e);
|
|
463
|
+
if (N(e)) {
|
|
460
464
|
let t = Object.entries(e);
|
|
461
|
-
return t.length === 0 ? "{}" : "{ " + t.map(([e, t]) => `${JSON.stringify(e)}: ${
|
|
465
|
+
return t.length === 0 ? "{}" : "{ " + t.map(([e, t]) => `${JSON.stringify(e)}: ${nt(t)}`).join(", ") + " }";
|
|
462
466
|
}
|
|
463
467
|
return JSON.stringify(e);
|
|
464
468
|
}
|
|
465
|
-
function
|
|
466
|
-
let i = t +
|
|
469
|
+
function rt(e, t, n, r) {
|
|
470
|
+
let i = t + et, a = " ".repeat(i);
|
|
467
471
|
if (Array.isArray(e)) {
|
|
468
|
-
let o =
|
|
469
|
-
if (n + o.length + r <=
|
|
472
|
+
let o = tt(e);
|
|
473
|
+
if (n + o.length + r <= $e) return o;
|
|
470
474
|
let s = e.length - 1;
|
|
471
|
-
return "[\n" + e.map((e, t) => a +
|
|
475
|
+
return "[\n" + e.map((e, t) => a + rt(e, i, i, t === s ? 0 : 1)).join(",\n") + "\n" + " ".repeat(t) + "]";
|
|
472
476
|
}
|
|
473
|
-
if (
|
|
477
|
+
if (N(e)) {
|
|
474
478
|
let n = Object.entries(e);
|
|
475
479
|
if (n.length === 0) return "{}";
|
|
476
480
|
let r = n.length - 1;
|
|
477
481
|
return "{\n" + n.map(([e, t], n) => {
|
|
478
482
|
let o = `${a}${JSON.stringify(e)}: `;
|
|
479
|
-
return o +
|
|
483
|
+
return o + rt(t, i, o.length, n === r ? 0 : 1);
|
|
480
484
|
}).join(",\n") + "\n" + " ".repeat(t) + "}";
|
|
481
485
|
}
|
|
482
486
|
return JSON.stringify(e);
|
|
483
487
|
}
|
|
484
|
-
function
|
|
485
|
-
return t?.collapse ?
|
|
488
|
+
function it(e, t) {
|
|
489
|
+
return t?.collapse ? rt(JSON.parse(JSON.stringify(e ?? null)), 0, 0, 0) + "\n" : JSON.stringify(e, null, 2) + "\n";
|
|
486
490
|
}
|
|
487
|
-
function
|
|
491
|
+
function at(e) {
|
|
488
492
|
return e === "" || e === void 0 ? [] : e.split(".");
|
|
489
493
|
}
|
|
490
|
-
function
|
|
494
|
+
function N(e) {
|
|
491
495
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
492
496
|
}
|
|
493
|
-
function
|
|
494
|
-
let n =
|
|
497
|
+
function ot(e, t) {
|
|
498
|
+
let n = at(t), r = e;
|
|
495
499
|
for (let e of n) {
|
|
496
|
-
if (!
|
|
500
|
+
if (!N(r)) return;
|
|
497
501
|
r = r[e];
|
|
498
502
|
}
|
|
499
503
|
return r;
|
|
500
504
|
}
|
|
501
|
-
function
|
|
502
|
-
let n =
|
|
505
|
+
function st(e, t) {
|
|
506
|
+
let n = at(t);
|
|
503
507
|
if (n.length === 0) return !0;
|
|
504
508
|
let r = e;
|
|
505
509
|
for (let e = 0; e < n.length - 1; e++) {
|
|
506
|
-
if (!
|
|
510
|
+
if (!N(r)) return !1;
|
|
507
511
|
r = r[n[e]];
|
|
508
512
|
}
|
|
509
|
-
return
|
|
513
|
+
return N(r) ? n[n.length - 1] in r : !1;
|
|
510
514
|
}
|
|
511
|
-
function
|
|
512
|
-
let r =
|
|
515
|
+
function ct(e, t, n) {
|
|
516
|
+
let r = at(t);
|
|
513
517
|
if (r.length === 0) throw Error("setAtPath: jsonPath must be non-empty");
|
|
514
518
|
let i = e;
|
|
515
519
|
for (let e = 0; e < r.length - 1; e++) {
|
|
@@ -517,22 +521,22 @@ function tt(e, t, n) {
|
|
|
517
521
|
if (n === void 0) {
|
|
518
522
|
let e = {};
|
|
519
523
|
i[t] = e, i = e;
|
|
520
|
-
} else if (
|
|
524
|
+
} else if (N(n)) i = n;
|
|
521
525
|
else throw Error(`setAtPath: cannot descend into non-object at '${r.slice(0, e + 1).join(".")}'`);
|
|
522
526
|
}
|
|
523
527
|
i[r[r.length - 1]] = n;
|
|
524
528
|
}
|
|
525
|
-
function
|
|
526
|
-
let n =
|
|
529
|
+
function lt(e, t) {
|
|
530
|
+
let n = at(t);
|
|
527
531
|
if (n.length === 0) throw Error("deleteAtPath: jsonPath must be non-empty");
|
|
528
532
|
let r = e;
|
|
529
533
|
for (let e = 0; e < n.length - 1; e++) {
|
|
530
|
-
if (!
|
|
534
|
+
if (!N(r)) return;
|
|
531
535
|
r = r[n[e]];
|
|
532
536
|
}
|
|
533
|
-
|
|
537
|
+
N(r) && delete r[n[n.length - 1]];
|
|
534
538
|
}
|
|
535
|
-
function
|
|
539
|
+
function ut(e, t) {
|
|
536
540
|
let n = new Set(t), r = Object.keys(e), i = /* @__PURE__ */ new Map();
|
|
537
541
|
i.set("", []);
|
|
538
542
|
let a = "";
|
|
@@ -547,72 +551,72 @@ function rt(e, t) {
|
|
|
547
551
|
}
|
|
548
552
|
//#endregion
|
|
549
553
|
//#region src/structure/engine/parsers/lines.ts
|
|
550
|
-
function
|
|
554
|
+
function dt(e) {
|
|
551
555
|
let t = e.split("\n");
|
|
552
556
|
return t.length > 0 && t[t.length - 1] === "" && t.pop(), t;
|
|
553
557
|
}
|
|
554
|
-
function
|
|
558
|
+
function ft(e) {
|
|
555
559
|
return e.join("\n") + "\n";
|
|
556
560
|
}
|
|
557
|
-
function
|
|
561
|
+
function pt(e) {
|
|
558
562
|
return e.replace(/(^|\s)#.*$/, "$1").trim();
|
|
559
563
|
}
|
|
560
|
-
function
|
|
561
|
-
let n =
|
|
564
|
+
function mt(e, t) {
|
|
565
|
+
let n = pt(e);
|
|
562
566
|
return n === "" ? !1 : n === t.trim();
|
|
563
567
|
}
|
|
564
|
-
function
|
|
565
|
-
for (let n of e) if (
|
|
568
|
+
function ht(e, t) {
|
|
569
|
+
for (let n of e) if (mt(n, t)) return !0;
|
|
566
570
|
return !1;
|
|
567
571
|
}
|
|
568
572
|
//#endregion
|
|
569
573
|
//#region src/structure/engine/content-rules.ts
|
|
570
|
-
function
|
|
574
|
+
function gt(e, t) {
|
|
571
575
|
return e === "sdk:" ? t ? "workspace:*" : "catalog:" : e;
|
|
572
576
|
}
|
|
573
|
-
var
|
|
577
|
+
var _t = [
|
|
574
578
|
"dependencies",
|
|
575
579
|
"devDependencies",
|
|
576
580
|
"peerDependencies",
|
|
577
581
|
"optionalDependencies"
|
|
578
582
|
];
|
|
579
|
-
function
|
|
580
|
-
if (
|
|
583
|
+
function vt(e, t) {
|
|
584
|
+
if (L(e)) for (let n of _t) {
|
|
581
585
|
let r = e[n];
|
|
582
|
-
if (
|
|
586
|
+
if (L(r)) for (let e of Object.keys(r)) r[e] === "sdk:" && (r[e] = t ? "workspace:*" : "catalog:");
|
|
583
587
|
}
|
|
584
588
|
}
|
|
585
|
-
var
|
|
586
|
-
function
|
|
587
|
-
if (!
|
|
588
|
-
return
|
|
589
|
+
var P;
|
|
590
|
+
function yt(e) {
|
|
591
|
+
if (!P) throw Error(`${e}() only valid inside a managed(...) body. Move this call inside managed(path, initial, () => {...}).`);
|
|
592
|
+
return P;
|
|
589
593
|
}
|
|
590
|
-
function
|
|
591
|
-
let t =
|
|
594
|
+
function F(e) {
|
|
595
|
+
let t = yt(e);
|
|
592
596
|
if (t.kind !== "json") throw Error(`${e}() requires a JSON-managed body; got '${t.kind}'.`);
|
|
593
597
|
return t;
|
|
594
598
|
}
|
|
595
|
-
function
|
|
596
|
-
let t =
|
|
599
|
+
function I(e) {
|
|
600
|
+
let t = yt(e);
|
|
597
601
|
if (t.kind !== "yaml") throw Error(`${e}() requires a YAML-managed body; got '${t.kind}'.`);
|
|
598
602
|
return t;
|
|
599
603
|
}
|
|
600
|
-
function
|
|
601
|
-
let t =
|
|
604
|
+
function bt(e) {
|
|
605
|
+
let t = yt(e);
|
|
602
606
|
if (t.kind !== "lines") throw Error(`${e}() requires a lines-managed body; got '${t.kind}'.`);
|
|
603
607
|
return t;
|
|
604
608
|
}
|
|
605
|
-
function
|
|
606
|
-
let n = e.ctx ??
|
|
609
|
+
function xt(e, t) {
|
|
610
|
+
let n = e.ctx ?? Ve();
|
|
607
611
|
if (!n) throw Error(`${t}() needs a RunContext but none is active. Pass { ctx } via the with-managed-* helper or run inside engine.run(...).`);
|
|
608
612
|
return n;
|
|
609
613
|
}
|
|
610
|
-
function
|
|
614
|
+
function L(e) {
|
|
611
615
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
612
616
|
}
|
|
613
|
-
function
|
|
614
|
-
if (
|
|
615
|
-
|
|
617
|
+
function St(e, t, n = {}) {
|
|
618
|
+
if (P) throw Error("Nested managed(...) body — engine bug.");
|
|
619
|
+
P = {
|
|
616
620
|
kind: "json",
|
|
617
621
|
obj: e,
|
|
618
622
|
ctx: n.ctx,
|
|
@@ -621,12 +625,12 @@ function ht(e, t, n = {}) {
|
|
|
621
625
|
try {
|
|
622
626
|
return t(n.ctx ?? n.triggerContext?.ctx), e;
|
|
623
627
|
} finally {
|
|
624
|
-
|
|
628
|
+
P = void 0;
|
|
625
629
|
}
|
|
626
630
|
}
|
|
627
|
-
function
|
|
628
|
-
if (
|
|
629
|
-
|
|
631
|
+
function Ct(e, t, n = {}) {
|
|
632
|
+
if (P) throw Error("Nested managed(...) body — engine bug.");
|
|
633
|
+
P = {
|
|
630
634
|
kind: "yaml",
|
|
631
635
|
doc: e,
|
|
632
636
|
ctx: n.ctx,
|
|
@@ -637,12 +641,12 @@ function gt(e, t, n = {}) {
|
|
|
637
641
|
try {
|
|
638
642
|
return t(n.ctx ?? n.triggerContext?.ctx), e;
|
|
639
643
|
} finally {
|
|
640
|
-
|
|
644
|
+
P = void 0;
|
|
641
645
|
}
|
|
642
646
|
}
|
|
643
|
-
function
|
|
644
|
-
if (
|
|
645
|
-
|
|
647
|
+
function wt(e, t, n = {}) {
|
|
648
|
+
if (P) throw Error("Nested managed(...) body — engine bug.");
|
|
649
|
+
P = {
|
|
646
650
|
kind: "lines",
|
|
647
651
|
lines: e,
|
|
648
652
|
ctx: n.ctx,
|
|
@@ -651,170 +655,178 @@ function _t(e, t, n = {}) {
|
|
|
651
655
|
try {
|
|
652
656
|
return t(n.ctx ?? n.triggerContext?.ctx), e;
|
|
653
657
|
} finally {
|
|
654
|
-
|
|
658
|
+
P = void 0;
|
|
655
659
|
}
|
|
656
660
|
}
|
|
657
|
-
|
|
658
|
-
if (!
|
|
659
|
-
let n =
|
|
661
|
+
Ge((e, t) => {
|
|
662
|
+
if (!P) return !1;
|
|
663
|
+
let n = P.triggerContext;
|
|
660
664
|
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.");
|
|
661
665
|
return e(n) && t(), !0;
|
|
662
666
|
});
|
|
663
|
-
function L(e, t) {
|
|
664
|
-
tt(P("ensureField").obj, e, t);
|
|
665
|
-
}
|
|
666
667
|
function R(e, t) {
|
|
667
|
-
|
|
668
|
-
et(n, e) && (t && !t($e(n, e)) || nt(n, e));
|
|
669
|
-
}
|
|
670
|
-
function vt(e, t) {
|
|
671
|
-
let n = P("requireField").obj;
|
|
672
|
-
if (!et(n, e)) throw Error(t ?? `requireField: missing field '${e}'`);
|
|
668
|
+
ct(F("ensureField").obj, e, t);
|
|
673
669
|
}
|
|
674
670
|
function z(e, t) {
|
|
675
|
-
|
|
671
|
+
let n = F("removeField").obj;
|
|
672
|
+
st(n, e) && (t && !t(ot(n, e)) || lt(n, e));
|
|
676
673
|
}
|
|
677
|
-
function
|
|
678
|
-
|
|
674
|
+
function Tt(e, t) {
|
|
675
|
+
let n = F("requireField").obj;
|
|
676
|
+
if (!st(n, e)) throw Error(t ?? `requireField: missing field '${e}'`);
|
|
679
677
|
}
|
|
680
|
-
|
|
678
|
+
function B(e, t) {
|
|
679
|
+
R(`scripts.${e}`, t);
|
|
680
|
+
}
|
|
681
|
+
function V(e) {
|
|
682
|
+
z(`scripts.${e}`);
|
|
683
|
+
}
|
|
684
|
+
var Et = [
|
|
681
685
|
"dependencies",
|
|
682
686
|
"devDependencies",
|
|
683
687
|
"peerDependencies",
|
|
684
688
|
"optionalDependencies"
|
|
685
689
|
];
|
|
686
|
-
function
|
|
687
|
-
let i =
|
|
688
|
-
for (let e of
|
|
690
|
+
function Dt(e, t, n, r) {
|
|
691
|
+
let i = F(e), a = i.obj, o = n === "sdk:" ? gt(n, xt(i, e).isSdkInternal) : n;
|
|
692
|
+
for (let e of Et) {
|
|
689
693
|
if (e === r) continue;
|
|
690
694
|
let n = a[e];
|
|
691
|
-
|
|
695
|
+
L(n) && t in n && delete n[t];
|
|
692
696
|
}
|
|
693
|
-
let s = a[r], c =
|
|
694
|
-
c[t] = o,
|
|
697
|
+
let s = a[r], c = L(s) ? s : {};
|
|
698
|
+
c[t] = o, L(s) || (a[r] = c);
|
|
695
699
|
}
|
|
696
700
|
function H(e, t) {
|
|
697
|
-
|
|
701
|
+
Dt("ensureDep", e, t, "dependencies");
|
|
698
702
|
}
|
|
699
703
|
function U(e, t) {
|
|
700
|
-
|
|
704
|
+
Dt("ensureDevDep", e, t, "devDependencies");
|
|
701
705
|
}
|
|
702
|
-
function
|
|
703
|
-
|
|
706
|
+
function Ot(e, t) {
|
|
707
|
+
Dt("ensurePeerDep", e, t, "peerDependencies");
|
|
704
708
|
}
|
|
705
709
|
function W(e) {
|
|
706
|
-
let t =
|
|
707
|
-
for (let n of
|
|
710
|
+
let t = F("removeDep").obj;
|
|
711
|
+
for (let n of Et) {
|
|
708
712
|
let r = t[n];
|
|
709
|
-
|
|
713
|
+
L(r) && e in r && delete r[e];
|
|
710
714
|
}
|
|
711
715
|
}
|
|
712
716
|
function G(e) {
|
|
713
717
|
for (let [t, n] of Object.entries(e)) U(t, n);
|
|
714
718
|
}
|
|
715
|
-
function
|
|
716
|
-
for (let [t, n] of Object.entries(e))
|
|
719
|
+
function kt(e) {
|
|
720
|
+
for (let [t, n] of Object.entries(e)) Ot(t, n);
|
|
717
721
|
}
|
|
718
|
-
function
|
|
719
|
-
let r =
|
|
720
|
-
for (let i of r.modules) i.scope === t &&
|
|
722
|
+
function At(e, t, n) {
|
|
723
|
+
let r = xt(F(e), e);
|
|
724
|
+
for (let i of r.modules) i.scope === t && Dt(e, i.name, "workspace:*", n);
|
|
721
725
|
}
|
|
722
|
-
function
|
|
723
|
-
|
|
726
|
+
function jt(e) {
|
|
727
|
+
At("ensureWorkspaceScopeDeps", e, "dependencies");
|
|
724
728
|
}
|
|
725
|
-
function
|
|
726
|
-
|
|
729
|
+
function Mt(e) {
|
|
730
|
+
At("ensureWorkspaceScopeDevDeps", e, "devDependencies");
|
|
727
731
|
}
|
|
728
|
-
function
|
|
729
|
-
let t =
|
|
732
|
+
function Nt(e) {
|
|
733
|
+
let t = F("pruneKeysMatching").obj;
|
|
730
734
|
for (let n of Object.keys(t)) e(n, t[n]) && delete t[n];
|
|
731
735
|
}
|
|
732
|
-
function
|
|
733
|
-
let n =
|
|
736
|
+
function Pt(e, t) {
|
|
737
|
+
let n = ut(e, t);
|
|
734
738
|
for (let t of Object.keys(e)) delete e[t];
|
|
735
739
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
736
740
|
}
|
|
737
741
|
function K(e) {
|
|
738
|
-
|
|
742
|
+
Pt(F("enforceFieldOrder").obj, e);
|
|
739
743
|
}
|
|
740
|
-
function
|
|
744
|
+
function Ft(e, t) {
|
|
741
745
|
let n = Object.keys(e).sort(), r = {};
|
|
742
746
|
for (let t of n) r[t] = e[t];
|
|
743
747
|
for (let t of Object.keys(e)) delete e[t];
|
|
744
|
-
for (let i of n) e[i] = r[i], t &&
|
|
748
|
+
for (let i of n) e[i] = r[i], t && L(e[i]) && Ft(e[i], !0);
|
|
745
749
|
}
|
|
746
750
|
function q(e = "", t = {}) {
|
|
747
751
|
let n = t.recursive ?? !1;
|
|
748
752
|
if (e === "" && !n) return;
|
|
749
|
-
let r =
|
|
753
|
+
let r = F("enforceAlphabeticalOrder").obj;
|
|
750
754
|
if (e === "") {
|
|
751
|
-
|
|
755
|
+
Ft(r, !0);
|
|
752
756
|
return;
|
|
753
757
|
}
|
|
754
|
-
let i =
|
|
755
|
-
|
|
758
|
+
let i = ot(r, e);
|
|
759
|
+
L(i) && Ft(i, n);
|
|
756
760
|
}
|
|
757
|
-
function
|
|
758
|
-
let e =
|
|
761
|
+
function It() {
|
|
762
|
+
let e = I("ensureWorkspaceModulePaths"), t = xt(e, "ensureWorkspaceModulePaths").modules.filter((e) => e.path !== "").map((e) => e.path).sort(), n = e.doc.toJSON()?.packages;
|
|
759
763
|
Array.isArray(n) && n.length === t.length && n.every((e, n) => e === t[n]) || e.doc.setIn(["packages"], t);
|
|
760
764
|
}
|
|
761
|
-
function
|
|
765
|
+
function Lt(e, t) {
|
|
762
766
|
let n = e.doc.getIn(["catalog", t]);
|
|
763
767
|
return typeof n == "string" ? n : void 0;
|
|
764
768
|
}
|
|
765
|
-
function
|
|
766
|
-
let n =
|
|
767
|
-
|
|
769
|
+
function Rt(e, t) {
|
|
770
|
+
let n = I("ensureCatalogVersion");
|
|
771
|
+
Lt(n, e) === void 0 && n.doc.setIn(["catalog", e], t);
|
|
768
772
|
}
|
|
769
|
-
function
|
|
770
|
-
let t =
|
|
773
|
+
function zt(e) {
|
|
774
|
+
let t = I("ensureCatalogLatest");
|
|
771
775
|
if (!t.getLatestVersion) return;
|
|
772
776
|
let n = t.getLatestVersion(e);
|
|
773
|
-
n !== void 0 &&
|
|
777
|
+
n !== void 0 && Lt(t, e) !== n && t.doc.setIn(["catalog", e], n);
|
|
774
778
|
}
|
|
775
|
-
function
|
|
776
|
-
let n =
|
|
779
|
+
function Bt(e, t) {
|
|
780
|
+
let n = I("pinCatalogToDependencyOf");
|
|
777
781
|
if (!n.getDerivedDependencyPin) return;
|
|
778
782
|
let r = n.getDerivedDependencyPin(e);
|
|
779
|
-
r !== void 0 &&
|
|
783
|
+
r !== void 0 && Lt(n, e) !== r && n.doc.setIn(["catalog", e], r);
|
|
780
784
|
}
|
|
781
|
-
function
|
|
782
|
-
let t =
|
|
785
|
+
function Vt(e) {
|
|
786
|
+
let t = I("ensureCatalogAbsent");
|
|
783
787
|
t.doc.hasIn(["catalog", e]) && t.doc.deleteIn(["catalog", e]);
|
|
784
788
|
}
|
|
785
|
-
function
|
|
786
|
-
let t =
|
|
787
|
-
for (let n of e)
|
|
789
|
+
function Ht(e) {
|
|
790
|
+
let t = bt("ensureGitignoreEntries");
|
|
791
|
+
for (let n of e) ht(t.lines, n) || t.lines.push(n);
|
|
788
792
|
}
|
|
789
793
|
//#endregion
|
|
790
794
|
//#region src/structure/engine/parsers/yaml.ts
|
|
791
|
-
function
|
|
792
|
-
return
|
|
795
|
+
function Ut(e) {
|
|
796
|
+
return oe(e);
|
|
793
797
|
}
|
|
794
|
-
function
|
|
798
|
+
function Wt(e) {
|
|
795
799
|
return e.toString();
|
|
796
800
|
}
|
|
797
|
-
var
|
|
798
|
-
function
|
|
799
|
-
if (e
|
|
801
|
+
var Gt = ".structure";
|
|
802
|
+
function Kt(e) {
|
|
803
|
+
if (!e.exists(".structure")) return { version: 0 };
|
|
804
|
+
try {
|
|
805
|
+
let t = JSON.parse(e.read(Gt));
|
|
806
|
+
return { version: typeof t?.version == "number" ? t.version : 0 };
|
|
807
|
+
} catch {
|
|
808
|
+
return { version: 0 };
|
|
809
|
+
}
|
|
800
810
|
}
|
|
801
|
-
|
|
811
|
+
function qt(e, t = 0) {
|
|
812
|
+
if (e < t) throw new Jt(e, t);
|
|
813
|
+
}
|
|
814
|
+
var Jt = class extends Error {
|
|
802
815
|
constructor(e, t) {
|
|
803
816
|
super(`Block .structure version is ${e}, below floor ${t}. Bootstrap via the legacy-migration skill, then re-run.`), this.version = e, this.floor = t, this.name = "StructureVersionFloorError";
|
|
804
817
|
}
|
|
805
818
|
};
|
|
806
|
-
function
|
|
807
|
-
|
|
808
|
-
e.write(Lt, JSON.stringify(n));
|
|
819
|
+
function Yt(e, t) {
|
|
820
|
+
e.write(Gt, JSON.stringify(t));
|
|
809
821
|
}
|
|
810
822
|
//#endregion
|
|
811
823
|
//#region src/structure/engine/runner.ts
|
|
812
|
-
var
|
|
824
|
+
var Xt = class extends Error {
|
|
813
825
|
constructor(e) {
|
|
814
826
|
super(`Post-run recheck: rule set not idempotent. Failing item: ${e.primitive} '${e.path}' (scope=${e.scope}, action=${e.action}). Engine bug.`), this.failing = e, this.name = "RecheckError";
|
|
815
827
|
}
|
|
816
828
|
};
|
|
817
|
-
function
|
|
829
|
+
function Zt(e, t, n, r) {
|
|
818
830
|
switch (e.kind) {
|
|
819
831
|
case "text": return e.value;
|
|
820
832
|
case "file":
|
|
@@ -822,47 +834,47 @@ function Ht(e, t, n, r) {
|
|
|
822
834
|
return n.staticRead(e.path);
|
|
823
835
|
case "tpl":
|
|
824
836
|
if (!n) throw Error(`tpl('${e.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);
|
|
825
|
-
return
|
|
837
|
+
return Oe(n.textRead(e.path), typeof e.vars == "function" ? e.vars(r) : e.vars);
|
|
826
838
|
case "generate": {
|
|
827
839
|
let n = e.fn(r);
|
|
828
|
-
if (t.endsWith(".json")) return
|
|
829
|
-
if (t.endsWith(".yaml") || t.endsWith(".yml")) return
|
|
840
|
+
if (t.endsWith(".json")) return vt(n, r.isSdkInternal), it(n, { collapse: !t.endsWith("package.json") });
|
|
841
|
+
if (t.endsWith(".yaml") || t.endsWith(".yml")) return se(n);
|
|
830
842
|
if (typeof n != "string") throw Error(`generate() for '${t}' must return a string for non-JSON/YAML files; got ${typeof n}`);
|
|
831
843
|
return n;
|
|
832
844
|
}
|
|
833
845
|
case "binary": throw Error(`binary('${e.path}') cannot be resolved to a string; it is only valid inside seed()/scaffold(), which copy it verbatim via fs.writeBinary.`);
|
|
834
846
|
}
|
|
835
847
|
}
|
|
836
|
-
function
|
|
848
|
+
function Qt(e, t, n, r, i) {
|
|
837
849
|
if (n.kind === "binary") {
|
|
838
850
|
if (!r) throw Error(`binary('${n.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);
|
|
839
851
|
e.writeBinary(t, r.staticReadBinary(n.path));
|
|
840
852
|
return;
|
|
841
853
|
}
|
|
842
|
-
e.write(t,
|
|
854
|
+
e.write(t, Zt(n, t, r, i));
|
|
843
855
|
}
|
|
844
|
-
function
|
|
856
|
+
function $t(e, t, n, r, i, a) {
|
|
845
857
|
let o = e.split("/").pop() ?? e;
|
|
846
858
|
if (e.endsWith(".json")) {
|
|
847
|
-
let i =
|
|
859
|
+
let i = Qe(t);
|
|
848
860
|
if (typeof i != "object" || !i || Array.isArray(i)) throw Error(`managed: parsed value at '${e}' is not a JSON object`);
|
|
849
|
-
return
|
|
861
|
+
return St(i, n, { triggerContext: r }), it(i, { collapse: o !== "package.json" });
|
|
850
862
|
}
|
|
851
863
|
if (e.endsWith(".yaml") || e.endsWith(".yml")) {
|
|
852
|
-
let e =
|
|
853
|
-
return
|
|
864
|
+
let e = Ut(t);
|
|
865
|
+
return Ct(e, n, {
|
|
854
866
|
triggerContext: r,
|
|
855
867
|
getLatestVersion: i,
|
|
856
868
|
getDerivedDependencyPin: a
|
|
857
|
-
}),
|
|
869
|
+
}), Wt(e);
|
|
858
870
|
}
|
|
859
871
|
if (o === ".gitignore" || o.endsWith(".gitignore")) {
|
|
860
|
-
let e =
|
|
861
|
-
return
|
|
872
|
+
let e = dt(t);
|
|
873
|
+
return wt(e, n, { triggerContext: r }), ft(e);
|
|
862
874
|
}
|
|
863
875
|
throw Error(`managed('${e}'): unsupported file kind. Only .json, .yaml, .yml, .gitignore are dispatched.`);
|
|
864
876
|
}
|
|
865
|
-
function
|
|
877
|
+
function en(e) {
|
|
866
878
|
let t = e.list(""), n = /* @__PURE__ */ new Set();
|
|
867
879
|
for (let e of t) {
|
|
868
880
|
n.add(e);
|
|
@@ -871,37 +883,37 @@ function Gt(e) {
|
|
|
871
883
|
}
|
|
872
884
|
return n;
|
|
873
885
|
}
|
|
874
|
-
function
|
|
886
|
+
function tn(e, t) {
|
|
875
887
|
let n = t === "" ? t : t.endsWith("/") ? t.slice(0, -1) : t;
|
|
876
888
|
return e.has(n);
|
|
877
889
|
}
|
|
878
|
-
function
|
|
890
|
+
function nn(e, t, n) {
|
|
879
891
|
return {
|
|
880
892
|
ctx: t,
|
|
881
893
|
version: t.version,
|
|
882
|
-
pathExists: (t) =>
|
|
883
|
-
pathMissing: (t) => !
|
|
894
|
+
pathExists: (t) => tn(e, t),
|
|
895
|
+
pathMissing: (t) => !tn(e, t),
|
|
884
896
|
filesMatch: (t) => {
|
|
885
897
|
let r = n ? `${n}/${t}` : t;
|
|
886
|
-
for (let t of e) if (
|
|
898
|
+
for (let t of e) if (Le(r, t)) return !0;
|
|
887
899
|
return !1;
|
|
888
900
|
}
|
|
889
901
|
};
|
|
890
902
|
}
|
|
891
|
-
function
|
|
903
|
+
function rn(e, t) {
|
|
892
904
|
for (let n of e.triggers) if (!n(t)) return !1;
|
|
893
905
|
return !0;
|
|
894
906
|
}
|
|
895
|
-
function
|
|
907
|
+
function an(e, t) {
|
|
896
908
|
return t ? "init" : e.updateDepsOnly ? "updateDeps" : "default";
|
|
897
909
|
}
|
|
898
|
-
function
|
|
910
|
+
function on(e, t) {
|
|
899
911
|
return e.filter((e) => e.modes.includes(t));
|
|
900
912
|
}
|
|
901
|
-
function
|
|
913
|
+
function sn(e, t, n, r, i, a) {
|
|
902
914
|
let o = e.leaf;
|
|
903
915
|
if (o.kind === "fixed") {
|
|
904
|
-
let i =
|
|
916
|
+
let i = Zt(o.content, e.resolvedPath, r, a);
|
|
905
917
|
return t.exists(e.resolvedPath) ? t.read(e.resolvedPath) === i ? void 0 : (n || t.write(e.resolvedPath, i), {
|
|
906
918
|
scope: e.scope,
|
|
907
919
|
path: e.resolvedPath,
|
|
@@ -914,13 +926,13 @@ function Zt(e, t, n, r, i, a) {
|
|
|
914
926
|
action: "create"
|
|
915
927
|
});
|
|
916
928
|
}
|
|
917
|
-
if (o.kind === "scaffold") return t.exists(e.resolvedPath) ? void 0 : (n ||
|
|
929
|
+
if (o.kind === "scaffold") return t.exists(e.resolvedPath) ? void 0 : (n || Qt(t, e.resolvedPath, o.initial, r, a), {
|
|
918
930
|
scope: e.scope,
|
|
919
931
|
path: e.resolvedPath,
|
|
920
932
|
primitive: "scaffold",
|
|
921
933
|
action: "create"
|
|
922
934
|
});
|
|
923
|
-
if (o.kind === "seed") return !i || t.exists(e.resolvedPath) ? void 0 : (n ||
|
|
935
|
+
if (o.kind === "seed") return !i || t.exists(e.resolvedPath) ? void 0 : (n || Qt(t, e.resolvedPath, o.initial, r, a), {
|
|
924
936
|
scope: e.scope,
|
|
925
937
|
path: e.resolvedPath,
|
|
926
938
|
primitive: "seed",
|
|
@@ -943,58 +955,58 @@ function Zt(e, t, n, r, i, a) {
|
|
|
943
955
|
});
|
|
944
956
|
}
|
|
945
957
|
}
|
|
946
|
-
function
|
|
958
|
+
function cn(e, t, n, r, i, a, o, s) {
|
|
947
959
|
if (e.leaf.kind !== "managed") return;
|
|
948
|
-
let c = e.leaf, l = e.resolvedPath, u = t.exists(l), d,
|
|
949
|
-
u ? d = t.read(l) : (d =
|
|
950
|
-
let
|
|
951
|
-
if (
|
|
960
|
+
let c = e.leaf, l = e.resolvedPath, u = t.exists(l), d, f = !1;
|
|
961
|
+
u ? d = t.read(l) : (d = Zt(c.initial, l, i, s), f = !0);
|
|
962
|
+
let p = $t(l, d, c.body, r, a, o);
|
|
963
|
+
if (f) return n || t.write(l, p), {
|
|
952
964
|
scope: e.scope,
|
|
953
965
|
path: l,
|
|
954
966
|
primitive: "managed",
|
|
955
967
|
action: "create"
|
|
956
968
|
};
|
|
957
|
-
if (
|
|
969
|
+
if (p !== d) return n || t.write(l, p), {
|
|
958
970
|
scope: e.scope,
|
|
959
971
|
path: l,
|
|
960
972
|
primitive: "managed",
|
|
961
973
|
action: "update"
|
|
962
974
|
};
|
|
963
975
|
}
|
|
964
|
-
function
|
|
965
|
-
let c =
|
|
976
|
+
function ln(e, t, n, r, i, a, o, s) {
|
|
977
|
+
let c = on(e, an(n, a)), l = [], u = en(t);
|
|
966
978
|
for (let e of c) {
|
|
967
|
-
if (e.leaf.kind === "managed" || !
|
|
968
|
-
let o =
|
|
979
|
+
if (e.leaf.kind === "managed" || !rn(e, nn(u, n, e.modulePath))) continue;
|
|
980
|
+
let o = sn(e, t, r, i, a, n);
|
|
969
981
|
o && l.push(o);
|
|
970
982
|
}
|
|
971
|
-
let d =
|
|
983
|
+
let d = en(t);
|
|
972
984
|
for (let e of c) {
|
|
973
985
|
if (e.leaf.kind !== "managed") continue;
|
|
974
|
-
let a =
|
|
975
|
-
if (!
|
|
976
|
-
let c =
|
|
986
|
+
let a = nn(d, n, e.modulePath);
|
|
987
|
+
if (!rn(e, a)) continue;
|
|
988
|
+
let c = cn(e, t, r, a, i, o, s, n);
|
|
977
989
|
c && l.push(c);
|
|
978
990
|
}
|
|
979
991
|
return l;
|
|
980
992
|
}
|
|
981
|
-
function
|
|
982
|
-
return
|
|
983
|
-
let i =
|
|
993
|
+
function un(e, t, n, r = {}) {
|
|
994
|
+
return Be(n, () => {
|
|
995
|
+
let i = Me(e, n), a = !!r.initMode, o = ln(i, t, n, n.dryRun, r.templates, a, r.registryLookup, r.derivedPinLookup);
|
|
984
996
|
if (!n.dryRun && !n.updateDepsOnly && !a) {
|
|
985
|
-
|
|
997
|
+
Yt(t, { version: 2 });
|
|
986
998
|
let i = {
|
|
987
999
|
...r.rediscover ? r.rediscover(t) : n,
|
|
988
1000
|
dryRun: !0
|
|
989
|
-
}, a =
|
|
990
|
-
if (a.length > 0) throw new
|
|
1001
|
+
}, a = ln(Me(e, i), t, i, !0, r.templates, !1, r.registryLookup, r.derivedPinLookup).filter((e) => e.path !== Gt);
|
|
1002
|
+
if (a.length > 0) throw new Xt(a[0]);
|
|
991
1003
|
}
|
|
992
|
-
return a && !n.dryRun &&
|
|
1004
|
+
return a && !n.dryRun && Yt(t, { version: 2 }), { changes: o };
|
|
993
1005
|
});
|
|
994
1006
|
}
|
|
995
1007
|
//#endregion
|
|
996
1008
|
//#region src/structure/engine/discovery.ts
|
|
997
|
-
var
|
|
1009
|
+
var dn = [
|
|
998
1010
|
"root",
|
|
999
1011
|
"block",
|
|
1000
1012
|
"model",
|
|
@@ -1002,12 +1014,12 @@ var tn = [
|
|
|
1002
1014
|
"workflow",
|
|
1003
1015
|
"test",
|
|
1004
1016
|
"software"
|
|
1005
|
-
],
|
|
1017
|
+
], fn = class extends Error {
|
|
1006
1018
|
constructor(e, t) {
|
|
1007
1019
|
super(e), this.path = t, this.name = "DiscoveryError";
|
|
1008
1020
|
}
|
|
1009
1021
|
};
|
|
1010
|
-
function
|
|
1022
|
+
function pn(e) {
|
|
1011
1023
|
let t = /* @__PURE__ */ new Set();
|
|
1012
1024
|
for (let n of [
|
|
1013
1025
|
e.dependencies,
|
|
@@ -1017,18 +1029,18 @@ function rn(e) {
|
|
|
1017
1029
|
]) if (n) for (let e of Object.keys(n)) t.add(e);
|
|
1018
1030
|
return t;
|
|
1019
1031
|
}
|
|
1020
|
-
function
|
|
1032
|
+
function mn(e) {
|
|
1021
1033
|
return e === "" || e === ".";
|
|
1022
1034
|
}
|
|
1023
|
-
function
|
|
1035
|
+
function hn(e) {
|
|
1024
1036
|
let t = e.pkg["block-scope"];
|
|
1025
1037
|
if (typeof t == "string") {
|
|
1026
|
-
if (!
|
|
1038
|
+
if (!dn.includes(t)) throw new fn(`package.json "block-scope" must be one of ${dn.join(", ")}, got '${t}'`, e.path);
|
|
1027
1039
|
return t;
|
|
1028
1040
|
}
|
|
1029
|
-
if (
|
|
1041
|
+
if (mn(e.path)) return "root";
|
|
1030
1042
|
if (e.pkg.block !== void 0) return "block";
|
|
1031
|
-
let n =
|
|
1043
|
+
let n = pn(e.pkg);
|
|
1032
1044
|
if (e.pkg["block-software"] !== void 0) return "software";
|
|
1033
1045
|
if (n.has("@platforma-sdk/package-builder")) {
|
|
1034
1046
|
for (let e of n) if (/^@platforma-open\/.*runenv/.test(e)) return "software";
|
|
@@ -1038,15 +1050,15 @@ function on(e) {
|
|
|
1038
1050
|
if (n.has("@platforma-sdk/model") && e.pkg.main) return "model";
|
|
1039
1051
|
if (n.has("@platforma-sdk/test")) return "test";
|
|
1040
1052
|
}
|
|
1041
|
-
function
|
|
1053
|
+
function gn(e) {
|
|
1042
1054
|
let t = [];
|
|
1043
1055
|
for (let n of e) {
|
|
1044
|
-
let e =
|
|
1045
|
-
if (!e) throw new
|
|
1056
|
+
let e = hn(n);
|
|
1057
|
+
if (!e) throw new fn(`Unclassified workspace package at '${n.path}'. Add a top-level "block-scope" string to its package.json.`, n.path);
|
|
1046
1058
|
t.push({
|
|
1047
1059
|
scope: e,
|
|
1048
1060
|
name: n.pkg.name ?? n.path,
|
|
1049
|
-
path:
|
|
1061
|
+
path: mn(n.path) ? "" : n.path
|
|
1050
1062
|
});
|
|
1051
1063
|
}
|
|
1052
1064
|
return t;
|
|
@@ -1056,21 +1068,21 @@ function sn(e) {
|
|
|
1056
1068
|
function J(e, t) {
|
|
1057
1069
|
return e.modules.filter((e) => e.scope === t);
|
|
1058
1070
|
}
|
|
1059
|
-
function
|
|
1071
|
+
function _n(e, t) {
|
|
1060
1072
|
let n = J(e, t);
|
|
1061
1073
|
if (n.length === 0) throw Error(`findModule: expected one '${t}' module, found none`);
|
|
1062
1074
|
if (n.length > 1) throw Error(`findModule: expected exactly one '${t}' module, found ${n.length}`);
|
|
1063
1075
|
return n[0];
|
|
1064
1076
|
}
|
|
1065
|
-
function
|
|
1066
|
-
return { [
|
|
1077
|
+
function vn(e, t) {
|
|
1078
|
+
return { [_n(e, t).name]: "workspace:*" };
|
|
1067
1079
|
}
|
|
1068
|
-
function
|
|
1080
|
+
function yn(e, t) {
|
|
1069
1081
|
let n = {};
|
|
1070
1082
|
for (let r of J(e, t)) n[r.name] = "workspace:*";
|
|
1071
1083
|
return n;
|
|
1072
1084
|
}
|
|
1073
|
-
function
|
|
1085
|
+
function bn(e) {
|
|
1074
1086
|
let t = e.facadeName, n = [
|
|
1075
1087
|
{
|
|
1076
1088
|
scope: "root",
|
|
@@ -1109,7 +1121,7 @@ function dn(e) {
|
|
|
1109
1121
|
path: "software"
|
|
1110
1122
|
}), n;
|
|
1111
1123
|
}
|
|
1112
|
-
function
|
|
1124
|
+
function xn(e) {
|
|
1113
1125
|
return {
|
|
1114
1126
|
isSdkInternal: e.isSdkInternal ?? !1,
|
|
1115
1127
|
updateDepsOnly: e.updateDepsOnly ?? !1,
|
|
@@ -1126,36 +1138,36 @@ var Y = class extends Error {
|
|
|
1126
1138
|
super(e), this.name = "StructureCliError";
|
|
1127
1139
|
}
|
|
1128
1140
|
};
|
|
1129
|
-
function
|
|
1141
|
+
function Sn(e, t) {
|
|
1130
1142
|
return e === "" ? t : `${e}/${t}`;
|
|
1131
1143
|
}
|
|
1132
|
-
function
|
|
1144
|
+
function Cn(e, t) {
|
|
1133
1145
|
try {
|
|
1134
1146
|
return JSON.parse(e.read(t));
|
|
1135
1147
|
} catch {
|
|
1136
1148
|
return;
|
|
1137
1149
|
}
|
|
1138
1150
|
}
|
|
1139
|
-
function
|
|
1151
|
+
function wn(e) {
|
|
1140
1152
|
if (e.includes("*")) throw new Y(`pnpm-workspace.yaml 'packages:' entry '${e}' contains a glob. The structurer requires literal package paths — replace the glob with one entry per package directory.`);
|
|
1141
1153
|
let t = e.replace(/^\.\//, "").replace(/\/$/, "");
|
|
1142
1154
|
return t === "." ? "" : t;
|
|
1143
1155
|
}
|
|
1144
|
-
function
|
|
1156
|
+
function Tn(e) {
|
|
1145
1157
|
let t;
|
|
1146
1158
|
try {
|
|
1147
1159
|
t = e.read("pnpm-workspace.yaml");
|
|
1148
1160
|
} catch {
|
|
1149
1161
|
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.");
|
|
1150
1162
|
}
|
|
1151
|
-
let n =
|
|
1163
|
+
let n = ae(t) ?? {}, r = Array.isArray(n.packages) ? n.packages : [], i = new Set([""]);
|
|
1152
1164
|
for (let t of r) {
|
|
1153
|
-
let n =
|
|
1165
|
+
let n = wn(t);
|
|
1154
1166
|
(n === "" || e.exists(n)) && i.add(n);
|
|
1155
1167
|
}
|
|
1156
1168
|
let a = [];
|
|
1157
1169
|
for (let t of i) {
|
|
1158
|
-
let n =
|
|
1170
|
+
let n = Cn(e, Sn(t, "package.json"));
|
|
1159
1171
|
n && a.push({
|
|
1160
1172
|
path: t,
|
|
1161
1173
|
pkg: n
|
|
@@ -1163,7 +1175,7 @@ function gn(e) {
|
|
|
1163
1175
|
}
|
|
1164
1176
|
return a;
|
|
1165
1177
|
}
|
|
1166
|
-
function
|
|
1178
|
+
function En(e) {
|
|
1167
1179
|
let t = [], n = new Set([
|
|
1168
1180
|
"node_modules",
|
|
1169
1181
|
".turbo",
|
|
@@ -1175,7 +1187,7 @@ function _n(e) {
|
|
|
1175
1187
|
let o = e.listDir(i);
|
|
1176
1188
|
for (let s of o) {
|
|
1177
1189
|
if (!s.isDirectory || n.has(s.name)) continue;
|
|
1178
|
-
let o =
|
|
1190
|
+
let o = Sn(i, s.name), c = Cn(e, Sn(o, "package.json"));
|
|
1179
1191
|
c && t.push({
|
|
1180
1192
|
path: o,
|
|
1181
1193
|
pkg: c
|
|
@@ -1184,7 +1196,7 @@ function _n(e) {
|
|
|
1184
1196
|
}
|
|
1185
1197
|
return r("", 1), t;
|
|
1186
1198
|
}
|
|
1187
|
-
function
|
|
1199
|
+
function Dn(e) {
|
|
1188
1200
|
let t = e.indexOf("/");
|
|
1189
1201
|
if (!e.startsWith("@") || t < 0) throw new Y(`Cannot parse block name '${e}': expected '@npm-org/org-scope.short-name'.`);
|
|
1190
1202
|
let n = e.slice(0, t), r = e.slice(t + 1), i = r.indexOf(".");
|
|
@@ -1197,28 +1209,20 @@ function vn(e) {
|
|
|
1197
1209
|
shortName: r.slice(i + 1)
|
|
1198
1210
|
};
|
|
1199
1211
|
}
|
|
1200
|
-
function
|
|
1201
|
-
|
|
1202
|
-
let t = JSON.parse(e.read(Lt));
|
|
1203
|
-
return typeof t.version == "number" ? t.version : 0;
|
|
1204
|
-
} catch {
|
|
1205
|
-
return 0;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
function bn(e) {
|
|
1209
|
-
let { fs: t, isSdkInternal: n } = e, r = n ? _n(t) : gn(t);
|
|
1212
|
+
function On(e) {
|
|
1213
|
+
let { fs: t, isSdkInternal: n } = e, r = n ? En(t) : Tn(t);
|
|
1210
1214
|
if (r.length === 0) throw new Y("No workspace packages found. Run 'block-tools structure init' to scaffold a block.");
|
|
1211
|
-
let i =
|
|
1212
|
-
|
|
1215
|
+
let i = gn(r), a = Kt(t);
|
|
1216
|
+
qt(a.version, 0);
|
|
1213
1217
|
let o = i.find((e) => e.scope === "block") ?? i.find((e) => e.scope === "root");
|
|
1214
1218
|
if (!o) throw new Y("Could not find a 'block' (or root-as-block) package to derive BlockVars from.");
|
|
1215
|
-
let s =
|
|
1216
|
-
return
|
|
1219
|
+
let s = Dn(o.name.replace(/\.block$/, ""));
|
|
1220
|
+
return xn({
|
|
1217
1221
|
isSdkInternal: n,
|
|
1218
1222
|
updateDepsOnly: e.updateDepsOnly ?? !1,
|
|
1219
1223
|
modules: i,
|
|
1220
1224
|
blockVars: s,
|
|
1221
|
-
version: a,
|
|
1225
|
+
version: a.version,
|
|
1222
1226
|
dryRun: e.dryRun ?? !1
|
|
1223
1227
|
});
|
|
1224
1228
|
}
|
|
@@ -1245,20 +1249,25 @@ var X = [
|
|
|
1245
1249
|
"pnpm",
|
|
1246
1250
|
"block",
|
|
1247
1251
|
"block-software"
|
|
1248
|
-
]
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
+
], kn = {
|
|
1253
|
+
"build:dev-local": "env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=all PL_BUILD_LOCATION=local turbo run build",
|
|
1254
|
+
"build:dev-remote": "env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=all PL_BUILD_LOCATION=remote turbo run build",
|
|
1255
|
+
"build:dev-no-software": "env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=none turbo run build",
|
|
1256
|
+
"build:dev-binary-existing": "env PL_BUILD_CHANNEL=dev PL_BUILD_USE_PUBLISHED=true turbo run build",
|
|
1257
|
+
"build:release": "env PL_BUILD_CHANNEL=release PL_BUILD_VARIANT=all PL_BUILD_LOCATION=remote turbo run build"
|
|
1258
|
+
}, An = {
|
|
1259
|
+
test: "env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=binary PL_BUILD_LOCATION=local turbo run test --concurrency 1",
|
|
1260
|
+
"test:dry-run": "env PL_BUILD_CHANNEL=dev PL_BUILD_VARIANT=binary PL_BUILD_LOCATION=local turbo run test --dry-run=json"
|
|
1261
|
+
};
|
|
1262
|
+
function jn() {
|
|
1252
1263
|
return {
|
|
1253
1264
|
version: "1.0.0",
|
|
1254
1265
|
private: !0,
|
|
1255
1266
|
scripts: {
|
|
1256
1267
|
fmt: "turbo run fmt",
|
|
1257
1268
|
check: "turbo run check",
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
test: "env PL_PKG_DEV=local turbo run test --concurrency 1",
|
|
1261
|
-
"test:dry-run": "env PL_PKG_DEV=local turbo run test --dry-run=json",
|
|
1269
|
+
...kn,
|
|
1270
|
+
...An,
|
|
1262
1271
|
"mark-stable": "turbo run mark-stable",
|
|
1263
1272
|
"do-pack": "turbo run do-pack",
|
|
1264
1273
|
watch: "turbo watch build",
|
|
@@ -1281,17 +1290,20 @@ function xn(e) {
|
|
|
1281
1290
|
packageManager: "pnpm@9.12.0"
|
|
1282
1291
|
};
|
|
1283
1292
|
}
|
|
1284
|
-
function
|
|
1285
|
-
|
|
1293
|
+
function Mn() {
|
|
1294
|
+
R("packageManager", "pnpm@9.12.0"), z("name"), B("fmt", "turbo run fmt"), B("check", "turbo run check");
|
|
1295
|
+
for (let [e, t] of Object.entries(kn)) B(e, t);
|
|
1296
|
+
for (let [e, t] of Object.entries(An)) B(e, t);
|
|
1297
|
+
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"), G({
|
|
1286
1298
|
"@changesets/cli": "catalog:",
|
|
1287
1299
|
"@milaboratories/ts-builder": "sdk:",
|
|
1288
1300
|
"@platforma-sdk/block-tools": "sdk:",
|
|
1289
1301
|
shx: "catalog:",
|
|
1290
1302
|
turbo: "catalog:"
|
|
1291
|
-
}),
|
|
1303
|
+
}), kt({
|
|
1292
1304
|
oxlint: "*",
|
|
1293
1305
|
oxfmt: "*"
|
|
1294
|
-
}),
|
|
1306
|
+
}), Nt((e, t) => {
|
|
1295
1307
|
if (!/^(\/\/|--)/.test(e) || typeof t != "object" || !t) return !1;
|
|
1296
1308
|
let n = t;
|
|
1297
1309
|
return n.pnpm !== void 0 || n.overrides !== void 0;
|
|
@@ -1299,70 +1311,70 @@ function Sn() {
|
|
|
1299
1311
|
}
|
|
1300
1312
|
//#endregion
|
|
1301
1313
|
//#region src/structure/engine/registry-client.ts
|
|
1302
|
-
var
|
|
1303
|
-
function
|
|
1314
|
+
var Nn = 2, Pn = 500, Fn = 3e4;
|
|
1315
|
+
function In(e) {
|
|
1304
1316
|
if (!e) return null;
|
|
1305
1317
|
let t = Number(e);
|
|
1306
1318
|
if (Number.isFinite(t) && t > 0) return t * 1e3;
|
|
1307
1319
|
let n = Date.parse(e);
|
|
1308
1320
|
return Number.isNaN(n) ? null : Math.max(0, n - Date.now());
|
|
1309
1321
|
}
|
|
1310
|
-
async function
|
|
1322
|
+
async function Ln(e) {
|
|
1311
1323
|
for (let t = 1;; t++) {
|
|
1312
1324
|
let n;
|
|
1313
1325
|
try {
|
|
1314
|
-
n = await fetch(e, { signal: AbortSignal.timeout(
|
|
1326
|
+
n = await fetch(e, { signal: AbortSignal.timeout(Fn) });
|
|
1315
1327
|
} catch (e) {
|
|
1316
|
-
if (t >
|
|
1317
|
-
await
|
|
1328
|
+
if (t > Nn) throw e;
|
|
1329
|
+
await ce(Pn * 2 ** (t - 1) * (.8 + .4 * Math.random()));
|
|
1318
1330
|
continue;
|
|
1319
1331
|
}
|
|
1320
1332
|
if (n.ok) return n;
|
|
1321
|
-
if (!(n.status === 429 || n.status >= 500) || t >
|
|
1322
|
-
let r =
|
|
1333
|
+
if (!(n.status === 429 || n.status >= 500) || t > Nn) throw Error(`registry returned HTTP ${n.status}`);
|
|
1334
|
+
let r = In(n.headers.get("retry-after"));
|
|
1323
1335
|
if (r != null) {
|
|
1324
|
-
await
|
|
1336
|
+
await ce(r);
|
|
1325
1337
|
continue;
|
|
1326
1338
|
}
|
|
1327
|
-
await
|
|
1339
|
+
await ce(Pn * 2 ** (t - 1) * (.8 + .4 * Math.random()));
|
|
1328
1340
|
}
|
|
1329
1341
|
}
|
|
1330
|
-
function
|
|
1342
|
+
function Rn() {
|
|
1331
1343
|
return {
|
|
1332
1344
|
async getLatestVersion(e) {
|
|
1333
|
-
let t = (await (await
|
|
1345
|
+
let t = (await (await Ln(`https://registry.npmjs.org/-/package/${e}/dist-tags`)).json()).latest;
|
|
1334
1346
|
if (!t) throw Error("no 'latest' dist-tag in registry response");
|
|
1335
1347
|
return t;
|
|
1336
1348
|
},
|
|
1337
1349
|
async getDeclaredDependency(e, t, n) {
|
|
1338
|
-
let r = await (await
|
|
1350
|
+
let r = await (await Ln(`https://registry.npmjs.org/${e}/${t}`)).json();
|
|
1339
1351
|
return r.dependencies?.[n] ?? r.peerDependencies?.[n];
|
|
1340
1352
|
}
|
|
1341
1353
|
};
|
|
1342
1354
|
}
|
|
1343
|
-
async function
|
|
1355
|
+
async function zn(e, t) {
|
|
1344
1356
|
let n = await Promise.all(t.map(async (t) => [t, await e.getLatestVersion(t)]));
|
|
1345
1357
|
return new Map(n);
|
|
1346
1358
|
}
|
|
1347
|
-
function
|
|
1359
|
+
function Bn(e) {
|
|
1348
1360
|
return (t) => e.get(t);
|
|
1349
1361
|
}
|
|
1350
|
-
var
|
|
1351
|
-
function
|
|
1352
|
-
return
|
|
1362
|
+
var Vn = [/^@platforma-sdk\//, /^@milaboratories\//];
|
|
1363
|
+
function Hn(e) {
|
|
1364
|
+
return Vn.some((t) => t.test(e));
|
|
1353
1365
|
}
|
|
1354
|
-
async function
|
|
1355
|
-
return e.length === 0 ? () => void 0 :
|
|
1366
|
+
async function Un(e, t = Rn()) {
|
|
1367
|
+
return e.length === 0 ? () => void 0 : Bn(await zn(t, e));
|
|
1356
1368
|
}
|
|
1357
|
-
function
|
|
1369
|
+
function Wn(e) {
|
|
1358
1370
|
return /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(e);
|
|
1359
1371
|
}
|
|
1360
|
-
async function
|
|
1372
|
+
async function Gn(e, t = Rn()) {
|
|
1361
1373
|
if (e.length === 0) return () => void 0;
|
|
1362
1374
|
let n = await Promise.all(e.map(async (e) => {
|
|
1363
1375
|
let n = await t.getDeclaredDependency(e.of, e.ofVersion ?? "latest", e.entry);
|
|
1364
1376
|
if (n === void 0) throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion ? `@${e.ofVersion}` : " (latest)"} declares no dependency '${e.entry}'. A derived pin requires the source to declare the dep as an exact version.`);
|
|
1365
|
-
if (!
|
|
1377
|
+
if (!Wn(n)) throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion ? `@${e.ofVersion}` : " (latest)"} declares '${e.entry}: ${n}', which is not an exact version. A derived pin requires an exact ('x.y.z') source dependency so the catalog can pin to it precisely.`);
|
|
1366
1378
|
return [e.entry, n];
|
|
1367
1379
|
})), r = new Map(n);
|
|
1368
1380
|
return (e) => r.get(e);
|
|
@@ -1370,7 +1382,7 @@ async function Fn(e, t = On()) {
|
|
|
1370
1382
|
//#endregion
|
|
1371
1383
|
//#region src/structure/rules/shared/retired-deps.ts
|
|
1372
1384
|
// @vitejs/plugin-vue — bundled by ts-builder's internal vite config.
|
|
1373
|
-
var
|
|
1385
|
+
var Kn = [
|
|
1374
1386
|
"vite",
|
|
1375
1387
|
"tsup",
|
|
1376
1388
|
"vue-tsc",
|
|
@@ -1378,8 +1390,8 @@ var In = [
|
|
|
1378
1390
|
"vite-plugin-dts",
|
|
1379
1391
|
"@platforma-sdk/eslint-config"
|
|
1380
1392
|
];
|
|
1381
|
-
function
|
|
1382
|
-
for (let e of
|
|
1393
|
+
function qn() {
|
|
1394
|
+
for (let e of Kn) W(e);
|
|
1383
1395
|
}
|
|
1384
1396
|
//#endregion
|
|
1385
1397
|
//#region src/structure/rules/root-pnpm-workspace.ts
|
|
@@ -1393,32 +1405,35 @@ var Z = [
|
|
|
1393
1405
|
"@platforma-sdk/package-builder",
|
|
1394
1406
|
"@milaboratories/ts-builder",
|
|
1395
1407
|
"@milaboratories/ts-configs"
|
|
1396
|
-
],
|
|
1397
|
-
for (let e of Z) if (!
|
|
1398
|
-
var
|
|
1408
|
+
], Jn = "0.0.0-init-must-fetch";
|
|
1409
|
+
for (let e of Z) if (!Hn(e)) throw Error(`SDK_CATALOG_PACKAGES entry '${e}' matches no catalog bump pattern; its placeholder would never be resolved to npm latest on init. Add it to CATALOG_BUMP_PATTERNS or move it to the infra floor.`);
|
|
1410
|
+
var Yn = {
|
|
1399
1411
|
turbo: "~2.8.11",
|
|
1400
1412
|
shx: "~0.4.0",
|
|
1401
1413
|
"@changesets/cli": "~2.29.8",
|
|
1402
1414
|
vitest: "~4.0.18"
|
|
1403
|
-
},
|
|
1415
|
+
}, Xn = [{
|
|
1404
1416
|
entry: "vue",
|
|
1405
1417
|
of: "@platforma-sdk/ui-vue"
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1418
|
+
}, {
|
|
1419
|
+
entry: "@milaboratories/helpers",
|
|
1420
|
+
of: "@platforma-sdk/model"
|
|
1421
|
+
}], Zn = "@platforma-open/milaboratories.runenv-python-3", Qn = "1.8.2";
|
|
1422
|
+
function $n(e) {
|
|
1408
1423
|
let t = e.modules.filter((e) => e.path !== "").map((e) => e.path).sort(), n = {};
|
|
1409
|
-
for (let e of Z) n[e] =
|
|
1410
|
-
return Object.assign(n,
|
|
1424
|
+
for (let e of Z) n[e] = Jn;
|
|
1425
|
+
return Object.assign(n, Yn), e.modules.some((e) => e.scope === "software") && (n[Zn] = Qn), {
|
|
1411
1426
|
packages: t,
|
|
1412
1427
|
catalog: n
|
|
1413
1428
|
};
|
|
1414
1429
|
}
|
|
1415
|
-
function
|
|
1416
|
-
|
|
1417
|
-
for (let e of
|
|
1430
|
+
function er() {
|
|
1431
|
+
It();
|
|
1432
|
+
for (let e of Kn) Vt(e);
|
|
1418
1433
|
}
|
|
1419
1434
|
//#endregion
|
|
1420
1435
|
//#region src/structure/rules/root-gitignore.ts
|
|
1421
|
-
var
|
|
1436
|
+
var tr = [
|
|
1422
1437
|
".test_auth.json",
|
|
1423
1438
|
"node_modules/",
|
|
1424
1439
|
"dist/",
|
|
@@ -1433,45 +1448,45 @@ var Gn = [
|
|
|
1433
1448
|
".vscode/sftp.json",
|
|
1434
1449
|
"test-dry-run.json"
|
|
1435
1450
|
];
|
|
1436
|
-
function
|
|
1437
|
-
|
|
1451
|
+
function nr() {
|
|
1452
|
+
Ht(tr);
|
|
1438
1453
|
}
|
|
1439
1454
|
//#endregion
|
|
1440
1455
|
//#region src/structure/rules/root.ts
|
|
1441
|
-
function
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
}),
|
|
1447
|
-
|
|
1448
|
-
}),
|
|
1449
|
-
|
|
1456
|
+
function rr() {
|
|
1457
|
+
S("root", () => {
|
|
1458
|
+
C(({ ctx: e }) => !e.isSdkInternal, () => {
|
|
1459
|
+
T("turbo.json", A("root/turbo.json")), T(".vscode/settings.json", A("root/.vscode/settings.json")), E("package.json", M(() => jn()), () => {
|
|
1460
|
+
Mn();
|
|
1461
|
+
}), E("pnpm-workspace.yaml", M((e) => $n(e)), () => {
|
|
1462
|
+
er();
|
|
1463
|
+
}), E(".gitignore", A("root/.gitignore"), () => {
|
|
1464
|
+
nr();
|
|
1450
1465
|
});
|
|
1451
1466
|
});
|
|
1452
1467
|
});
|
|
1453
1468
|
}
|
|
1454
1469
|
//#endregion
|
|
1455
1470
|
//#region src/structure/rules/root-ci.ts
|
|
1456
|
-
function
|
|
1471
|
+
function ir(e) {
|
|
1457
1472
|
return e.split(/[-_]+/).filter((e) => e.length > 0).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
1458
1473
|
}
|
|
1459
|
-
function
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1474
|
+
function ar() {
|
|
1475
|
+
S("root", () => {
|
|
1476
|
+
C(({ ctx: e }) => !e.isSdkInternal, () => {
|
|
1477
|
+
T(".github/workflows/build.yaml", j("workflows/build.tpl.yaml", (e) => {
|
|
1463
1478
|
let t = e.blockVars.shortName;
|
|
1464
1479
|
return {
|
|
1465
|
-
appName: `Block: ${
|
|
1480
|
+
appName: `Block: ${ir(t)}`,
|
|
1466
1481
|
appNameSlug: `block-${t}`
|
|
1467
1482
|
};
|
|
1468
|
-
})),
|
|
1483
|
+
})), T(".github/workflows/mark-stable.yaml", j("workflows/mark-stable.tpl.yaml", (e) => ({ appName: `Block: ${ir(e.blockVars.shortName)} - Mark Stable` })));
|
|
1469
1484
|
});
|
|
1470
1485
|
});
|
|
1471
1486
|
}
|
|
1472
1487
|
//#endregion
|
|
1473
1488
|
//#region src/structure/rules/block-package-json.ts
|
|
1474
|
-
var
|
|
1489
|
+
var or = {
|
|
1475
1490
|
"@platforma-open": {
|
|
1476
1491
|
s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
|
|
1477
1492
|
serveUrl: "https://blocks.pl-open.science"
|
|
@@ -1480,45 +1495,45 @@ var Xn = {
|
|
|
1480
1495
|
s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
|
|
1481
1496
|
serveUrl: "https://block.registry.platforma.bio/releases"
|
|
1482
1497
|
}
|
|
1483
|
-
},
|
|
1498
|
+
}, sr = {
|
|
1484
1499
|
s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
|
|
1485
1500
|
serveUrl: "https://blocks.pl-open.science"
|
|
1486
|
-
},
|
|
1501
|
+
}, cr = {
|
|
1487
1502
|
s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/aux/dev/?region=eu-central-1",
|
|
1488
1503
|
serveUrl: "https://aux-blocks.pl-open.science"
|
|
1489
1504
|
};
|
|
1490
|
-
function
|
|
1491
|
-
let n = t ?
|
|
1505
|
+
function lr(e, t) {
|
|
1506
|
+
let n = t ? cr : or[e] ?? sr;
|
|
1492
1507
|
return `block-tools publish -r ${n.s3} --registry-serve-url ${n.serveUrl}`;
|
|
1493
1508
|
}
|
|
1494
|
-
function
|
|
1509
|
+
function ur(e) {
|
|
1495
1510
|
let t = {};
|
|
1496
1511
|
for (let n of J(e, "workflow")) t.workflow = `${n.name}/dist/tengo/tpl/main.plj.gz`;
|
|
1497
1512
|
for (let n of J(e, "model")) t.model = `${n.name}/dist/model.json`;
|
|
1498
1513
|
for (let n of J(e, "ui")) t.ui = `${n.name}/dist`;
|
|
1499
1514
|
return t;
|
|
1500
1515
|
}
|
|
1501
|
-
function
|
|
1516
|
+
function dr(e, t) {
|
|
1502
1517
|
return {
|
|
1503
1518
|
build: "ts-builder build --target block-facade && block-tools pack",
|
|
1504
1519
|
check: "ts-builder type-check --target block-facade",
|
|
1505
|
-
prepublishOnly:
|
|
1520
|
+
prepublishOnly: lr(e, t),
|
|
1506
1521
|
"do-pack": "shx rm -f package.tgz && pnpm pack && shx mv *.tgz package.tgz"
|
|
1507
1522
|
};
|
|
1508
1523
|
}
|
|
1509
|
-
var
|
|
1524
|
+
var fr = {
|
|
1510
1525
|
"@milaboratories/ts-builder": "sdk:",
|
|
1511
1526
|
"@milaboratories/ts-configs": "sdk:",
|
|
1512
1527
|
"@platforma-sdk/block-tools": "sdk:",
|
|
1513
1528
|
"@platforma-sdk/model": "sdk:",
|
|
1514
1529
|
shx: "catalog:",
|
|
1515
1530
|
typescript: "catalog:"
|
|
1516
|
-
},
|
|
1531
|
+
}, pr = { ".": {
|
|
1517
1532
|
sources: "./src/index.ts",
|
|
1518
1533
|
types: "./dist/index.d.ts",
|
|
1519
1534
|
default: "./dist/index.js"
|
|
1520
1535
|
} };
|
|
1521
|
-
function
|
|
1536
|
+
function mr(e) {
|
|
1522
1537
|
if (Object.keys(e.components).length === 0) throw Error("block.components is empty — no workflow/model/ui module was discovered");
|
|
1523
1538
|
let t = e.meta, n = [
|
|
1524
1539
|
["block.meta.title", t.title],
|
|
@@ -1530,14 +1545,14 @@ function ir(e) {
|
|
|
1530
1545
|
];
|
|
1531
1546
|
for (let [e, t] of n) if (typeof t != "string" || t === "") throw Error(`required block field '${e}' is empty`);
|
|
1532
1547
|
}
|
|
1533
|
-
function
|
|
1548
|
+
function hr(e) {
|
|
1534
1549
|
let t = e.blockVars, n = {
|
|
1535
|
-
...
|
|
1536
|
-
...
|
|
1537
|
-
...
|
|
1538
|
-
...
|
|
1550
|
+
...fr,
|
|
1551
|
+
...yn(e, "model"),
|
|
1552
|
+
...yn(e, "ui"),
|
|
1553
|
+
...yn(e, "workflow")
|
|
1539
1554
|
}, r = {
|
|
1540
|
-
components:
|
|
1555
|
+
components: ur(e),
|
|
1541
1556
|
meta: {
|
|
1542
1557
|
title: t.shortName,
|
|
1543
1558
|
description: `${t.shortName} block`,
|
|
@@ -1549,7 +1564,7 @@ function ar(e) {
|
|
|
1549
1564
|
}
|
|
1550
1565
|
}
|
|
1551
1566
|
};
|
|
1552
|
-
return
|
|
1567
|
+
return mr(r), {
|
|
1553
1568
|
name: `${t.facadeName}.block`,
|
|
1554
1569
|
version: "1.0.0",
|
|
1555
1570
|
type: "module",
|
|
@@ -1557,35 +1572,35 @@ function ar(e) {
|
|
|
1557
1572
|
main: "./dist/index.js",
|
|
1558
1573
|
module: "./dist/index.js",
|
|
1559
1574
|
types: "./dist/index.d.ts",
|
|
1560
|
-
exports:
|
|
1561
|
-
scripts:
|
|
1575
|
+
exports: pr,
|
|
1576
|
+
scripts: dr(t.npmOrg, e.isSdkInternal),
|
|
1562
1577
|
dependencies: {},
|
|
1563
1578
|
devDependencies: n,
|
|
1564
1579
|
block: r
|
|
1565
1580
|
};
|
|
1566
1581
|
}
|
|
1567
|
-
function
|
|
1582
|
+
function gr(e) {
|
|
1568
1583
|
let t = e.blockVars;
|
|
1569
|
-
|
|
1570
|
-
let n =
|
|
1571
|
-
for (let [e, t] of Object.entries(n))
|
|
1572
|
-
|
|
1584
|
+
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", pr);
|
|
1585
|
+
let n = dr(t.npmOrg, e.isSdkInternal);
|
|
1586
|
+
for (let [e, t] of Object.entries(n)) B(e, t);
|
|
1587
|
+
V("mark-stable"), Mt("model"), Mt("ui"), Mt("workflow"), U("@milaboratories/ts-builder", "sdk:"), U("@milaboratories/ts-configs", "sdk:"), U("@platforma-sdk/block-tools", "sdk:"), U("@platforma-sdk/model", "sdk:"), U("shx", "catalog:"), U("typescript", "catalog:"), R("block.components", ur(e)), Tt("version", "facade package.json must carry a 'version' (the facade publishes)"), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
|
|
1573
1588
|
}
|
|
1574
1589
|
//#endregion
|
|
1575
1590
|
//#region src/structure/rules/shared/pascal-case.ts
|
|
1576
|
-
function
|
|
1591
|
+
function _r(e) {
|
|
1577
1592
|
let t = e.split(/[^A-Za-z0-9]+/).filter((e) => e.length > 0).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("");
|
|
1578
1593
|
return /^[0-9]/.test(t) ? `_${t}` : t;
|
|
1579
1594
|
}
|
|
1580
1595
|
//#endregion
|
|
1581
1596
|
//#region src/structure/rules/block.ts
|
|
1582
|
-
function
|
|
1583
|
-
|
|
1584
|
-
|
|
1597
|
+
function vr() {
|
|
1598
|
+
S("block", () => {
|
|
1599
|
+
k("index.js"), k("index.d.ts"), T("src/index.ts", j("block/src/index.tpl.ts", (e) => ({
|
|
1585
1600
|
facadeName: e.blockVars.facadeName,
|
|
1586
|
-
pascalName:
|
|
1587
|
-
}))),
|
|
1588
|
-
|
|
1601
|
+
pascalName: _r(e.blockVars.shortName)
|
|
1602
|
+
}))), 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", Xe("block/logos/block-logo.png")), O("logos/organization-logo.png", Xe("block/logos/organization-logo.png")), E("package.json", M((e) => hr(e)), (e) => {
|
|
1603
|
+
gr(e);
|
|
1589
1604
|
});
|
|
1590
1605
|
});
|
|
1591
1606
|
}
|
|
@@ -1594,7 +1609,7 @@ function cr() {
|
|
|
1594
1609
|
var Q = "src/**/*.test.ts";
|
|
1595
1610
|
//#endregion
|
|
1596
1611
|
//#region src/structure/rules/model-package-json.ts
|
|
1597
|
-
function
|
|
1612
|
+
function yr(e) {
|
|
1598
1613
|
return {
|
|
1599
1614
|
name: `${e.blockVars.facadeName}.model`,
|
|
1600
1615
|
private: !0,
|
|
@@ -1628,37 +1643,37 @@ function lr(e) {
|
|
|
1628
1643
|
}
|
|
1629
1644
|
};
|
|
1630
1645
|
}
|
|
1631
|
-
function
|
|
1632
|
-
|
|
1646
|
+
function br() {
|
|
1647
|
+
R("private", !0), R("type", "module"), R("main", "dist/index.cjs"), R("module", "dist/index.js"), R("types", "dist/index.d.ts"), R("exports", {
|
|
1633
1648
|
".": {
|
|
1634
1649
|
types: "./dist/index.d.ts",
|
|
1635
1650
|
sources: "./src/index.ts",
|
|
1636
1651
|
import: "./dist/index.js"
|
|
1637
1652
|
},
|
|
1638
1653
|
"./dist/*": "./dist/*"
|
|
1639
|
-
}),
|
|
1654
|
+
}), 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"), H("@platforma-sdk/model", "sdk:"), G({
|
|
1640
1655
|
"@milaboratories/ts-builder": "sdk:",
|
|
1641
1656
|
"@milaboratories/ts-configs": "sdk:",
|
|
1642
1657
|
"@platforma-sdk/block-tools": "sdk:"
|
|
1643
|
-
}),
|
|
1658
|
+
}), kt({
|
|
1644
1659
|
"@types/node": "*",
|
|
1645
1660
|
typescript: "*"
|
|
1646
|
-
}),
|
|
1647
|
-
|
|
1648
|
-
}, () => W("vitest"))),
|
|
1661
|
+
}), C(({ ctx: e }) => !e.isSdkInternal, () => C(w(Q), () => {
|
|
1662
|
+
B("test", "vitest run --passWithNoTests"), U("vitest", "catalog:"), U("@types/node", "*");
|
|
1663
|
+
}, () => W("vitest"))), qn(), z("tsup"), V("lint"), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
|
|
1649
1664
|
}
|
|
1650
1665
|
//#endregion
|
|
1651
1666
|
//#region src/structure/rules/model.ts
|
|
1652
|
-
function
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1667
|
+
function xr() {
|
|
1668
|
+
S("model", () => {
|
|
1669
|
+
C(w(Q), () => 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", A("model/src/index.ts")), E("package.json", M((e) => yr(e)), () => {
|
|
1670
|
+
br();
|
|
1656
1671
|
});
|
|
1657
1672
|
});
|
|
1658
1673
|
}
|
|
1659
1674
|
//#endregion
|
|
1660
1675
|
//#region src/structure/rules/ui-package-json.ts
|
|
1661
|
-
function
|
|
1676
|
+
function Sr(e) {
|
|
1662
1677
|
return {
|
|
1663
1678
|
name: `${e.blockVars.facadeName}.ui`,
|
|
1664
1679
|
private: !0,
|
|
@@ -1673,7 +1688,7 @@ function fr(e) {
|
|
|
1673
1688
|
dependencies: {
|
|
1674
1689
|
"@platforma-sdk/ui-vue": "sdk:",
|
|
1675
1690
|
vue: "catalog:",
|
|
1676
|
-
...
|
|
1691
|
+
...vn(e, "model")
|
|
1677
1692
|
},
|
|
1678
1693
|
devDependencies: {
|
|
1679
1694
|
"@milaboratories/ts-builder": "sdk:",
|
|
@@ -1685,29 +1700,29 @@ function fr(e) {
|
|
|
1685
1700
|
}
|
|
1686
1701
|
};
|
|
1687
1702
|
}
|
|
1688
|
-
function
|
|
1689
|
-
|
|
1703
|
+
function Cr() {
|
|
1704
|
+
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"), H("@platforma-sdk/ui-vue", "sdk:"), H("vue", "catalog:"), jt("model"), G({
|
|
1690
1705
|
"@milaboratories/ts-builder": "sdk:",
|
|
1691
1706
|
"@milaboratories/ts-configs": "sdk:"
|
|
1692
|
-
}),
|
|
1707
|
+
}), qn(), V("preview"), V("lint"), kt({
|
|
1693
1708
|
"@types/node": "*",
|
|
1694
1709
|
typescript: "*"
|
|
1695
|
-
}),
|
|
1696
|
-
|
|
1710
|
+
}), C(({ ctx: e }) => !e.isSdkInternal, () => C(w(Q), () => {
|
|
1711
|
+
B("test", "vitest run --passWithNoTests"), U("vitest", "catalog:"), U("@types/node", "*");
|
|
1697
1712
|
}, () => W("vitest"))), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
|
|
1698
1713
|
}
|
|
1699
1714
|
//#endregion
|
|
1700
1715
|
//#region src/structure/rules/ui.ts
|
|
1701
|
-
function
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1716
|
+
function wr() {
|
|
1717
|
+
S("ui", () => {
|
|
1718
|
+
C(w(Q), () => 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) => Sr(e)), () => {
|
|
1719
|
+
Cr();
|
|
1705
1720
|
});
|
|
1706
1721
|
});
|
|
1707
1722
|
}
|
|
1708
1723
|
//#endregion
|
|
1709
1724
|
//#region src/structure/rules/workflow-package-json.ts
|
|
1710
|
-
function
|
|
1725
|
+
function Tr(e) {
|
|
1711
1726
|
return {
|
|
1712
1727
|
name: `${e.blockVars.facadeName}.workflow`,
|
|
1713
1728
|
private: !0,
|
|
@@ -1719,7 +1734,7 @@ function hr(e) {
|
|
|
1719
1734
|
},
|
|
1720
1735
|
dependencies: {
|
|
1721
1736
|
"@platforma-sdk/workflow-tengo": "sdk:",
|
|
1722
|
-
...
|
|
1737
|
+
...yn(e, "software")
|
|
1723
1738
|
},
|
|
1724
1739
|
devDependencies: {
|
|
1725
1740
|
"@platforma-sdk/tengo-builder": "sdk:",
|
|
@@ -1728,31 +1743,31 @@ function hr(e) {
|
|
|
1728
1743
|
}
|
|
1729
1744
|
};
|
|
1730
1745
|
}
|
|
1731
|
-
function
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
}, () => W("vitest"))), H("@platforma-sdk/workflow-tengo", "sdk:"),
|
|
1746
|
+
function Er() {
|
|
1747
|
+
R("private", !0), R("type", "module"), B("build", "shx rm -rf dist && pl-tengo build"), B("check", "pl-tengo check"), B("format", "/usr/bin/env emacs --script ./format.el || echo 'No emacs.'"), C(({ ctx: e }) => !e.isSdkInternal, () => C(w(Q), () => {
|
|
1748
|
+
B("test", "vitest run --passWithNoTests"), G({ vitest: "catalog:" });
|
|
1749
|
+
}, () => W("vitest"))), H("@platforma-sdk/workflow-tengo", "sdk:"), jt("software"), G({
|
|
1735
1750
|
"@platforma-sdk/tengo-builder": "sdk:",
|
|
1736
1751
|
"@platforma-sdk/test": "sdk:",
|
|
1737
1752
|
shx: "catalog:"
|
|
1738
|
-
}),
|
|
1753
|
+
}), qn(), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
|
|
1739
1754
|
}
|
|
1740
1755
|
//#endregion
|
|
1741
1756
|
//#region src/structure/rules/workflow.ts
|
|
1742
|
-
function
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1757
|
+
function Dr() {
|
|
1758
|
+
S("workflow", () => {
|
|
1759
|
+
T("format.el", A("workflow/format.el")), C(({ ctx: e }) => !e.isSdkInternal, () => C(w(Q), () => {
|
|
1760
|
+
T("tsconfig.json", A("workflow/tsconfig.json")), D("vitest.config.mts", A("workflow/vitest.config.mts"));
|
|
1746
1761
|
}, () => {
|
|
1747
|
-
|
|
1748
|
-
})),
|
|
1749
|
-
|
|
1762
|
+
k("tsconfig.json"), k("vitest.config.mts");
|
|
1763
|
+
})), 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) => Tr(e)), () => {
|
|
1764
|
+
Er();
|
|
1750
1765
|
});
|
|
1751
1766
|
});
|
|
1752
1767
|
}
|
|
1753
1768
|
//#endregion
|
|
1754
1769
|
//#region src/structure/rules/test-package-json.ts
|
|
1755
|
-
function
|
|
1770
|
+
function Or(e) {
|
|
1756
1771
|
return {
|
|
1757
1772
|
name: `${e.blockVars.facadeName}.test`,
|
|
1758
1773
|
private: !0,
|
|
@@ -1771,26 +1786,27 @@ function vr(e) {
|
|
|
1771
1786
|
}
|
|
1772
1787
|
};
|
|
1773
1788
|
}
|
|
1774
|
-
function
|
|
1775
|
-
|
|
1789
|
+
function kr() {
|
|
1790
|
+
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"), G({
|
|
1776
1791
|
"@platforma-sdk/test": "sdk:",
|
|
1777
1792
|
"@milaboratories/ts-builder": "sdk:",
|
|
1778
1793
|
"@milaboratories/ts-configs": "sdk:",
|
|
1779
1794
|
vitest: "catalog:"
|
|
1780
|
-
}),
|
|
1795
|
+
}), kt({ typescript: "*" }), W("@types/node"), qn(), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
|
|
1781
1796
|
}
|
|
1782
1797
|
//#endregion
|
|
1783
1798
|
//#region src/structure/rules/test.ts
|
|
1784
|
-
function
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1799
|
+
function Ar() {
|
|
1800
|
+
S("test", () => {
|
|
1801
|
+
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", Ze("import { expect, test } from \"vitest\";\n\ntest(\"scaffolded block sanity check\", () => {\n expect(true).toBe(true);\n});\n")), E("package.json", M((e) => Or(e)), () => {
|
|
1802
|
+
kr();
|
|
1788
1803
|
});
|
|
1789
1804
|
});
|
|
1790
1805
|
}
|
|
1791
1806
|
//#endregion
|
|
1792
1807
|
//#region src/structure/rules/software-package-json.ts
|
|
1793
|
-
|
|
1808
|
+
var jr = "block-tools software build", Mr = "shx rm -f *.tgz && block-tools software build && pnpm pack && shx mv platforma-open*.tgz package.tgz";
|
|
1809
|
+
function Nr() {
|
|
1794
1810
|
return { entrypoints: { main: { binary: {
|
|
1795
1811
|
artifact: {
|
|
1796
1812
|
type: "python",
|
|
@@ -1805,68 +1821,65 @@ function xr() {
|
|
|
1805
1821
|
cmd: ["python", "{pkg}/main.py"]
|
|
1806
1822
|
} } } };
|
|
1807
1823
|
}
|
|
1808
|
-
function
|
|
1824
|
+
function Pr(e) {
|
|
1809
1825
|
return {
|
|
1810
1826
|
name: `${e.blockVars.facadeName}.software`,
|
|
1811
1827
|
type: "module",
|
|
1812
1828
|
description: "Block Software",
|
|
1813
1829
|
files: ["./dist/**/*"],
|
|
1814
1830
|
scripts: {
|
|
1815
|
-
build:
|
|
1816
|
-
|
|
1831
|
+
build: jr,
|
|
1832
|
+
"do-pack": Mr,
|
|
1817
1833
|
changeset: "changeset",
|
|
1818
1834
|
"version-packages": "changeset version"
|
|
1819
1835
|
},
|
|
1820
|
-
"block-software":
|
|
1836
|
+
"block-software": Nr(),
|
|
1821
1837
|
devDependencies: {
|
|
1822
1838
|
"@platforma-open/milaboratories.runenv-python-3": "catalog:",
|
|
1823
|
-
"@platforma-sdk/
|
|
1839
|
+
"@platforma-sdk/block-tools": "sdk:"
|
|
1824
1840
|
}
|
|
1825
1841
|
};
|
|
1826
1842
|
}
|
|
1827
|
-
function
|
|
1828
|
-
|
|
1829
|
-
"@platforma-open/milaboratories.runenv-python-3": "catalog:",
|
|
1830
|
-
"@platforma-sdk/package-builder": "sdk:"
|
|
1831
|
-
}), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
|
|
1843
|
+
function Fr() {
|
|
1844
|
+
z("private"), R("type", "module"), R("files", ["./dist/**/*"]), B("build", jr), B("do-pack", Mr), V("prepublishOnly"), B("changeset", "changeset"), B("version-packages", "changeset version"), U("@platforma-open/milaboratories.runenv-python-3", "catalog:"), U("@platforma-sdk/block-tools", "sdk:"), W("@platforma-sdk/package-builder"), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
|
|
1832
1845
|
}
|
|
1833
1846
|
//#endregion
|
|
1834
1847
|
//#region src/structure/rules/software.ts
|
|
1835
|
-
var
|
|
1836
|
-
function
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1848
|
+
var Ir = "import sys\n\nprint(\"Hello from Python, \" + sys.argv[1] + \"!\")\n", Lr = "# No dependencies specified for this script\n";
|
|
1849
|
+
function Rr() {
|
|
1850
|
+
S("software", () => {
|
|
1851
|
+
O("src/main.py", Ze(Ir)), O("src/requirements.txt", Ze(Lr)), E("package.json", M((e) => Pr(e)), () => {
|
|
1852
|
+
Fr();
|
|
1840
1853
|
});
|
|
1841
1854
|
});
|
|
1842
1855
|
}
|
|
1843
|
-
function
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
}),
|
|
1847
|
-
|
|
1848
|
-
}),
|
|
1849
|
-
|
|
1850
|
-
}),
|
|
1851
|
-
|
|
1852
|
-
|
|
1856
|
+
function zr() {
|
|
1857
|
+
S("model", () => {
|
|
1858
|
+
k("eslint.config.mjs"), k("vite.config.mts");
|
|
1859
|
+
}), S("ui", () => {
|
|
1860
|
+
k("eslint.config.mjs"), k("vite.config.ts"), k("tsconfig.app.json"), k("tsconfig.node.json");
|
|
1861
|
+
}), S("test", () => {
|
|
1862
|
+
k("eslint.config.mjs");
|
|
1863
|
+
}), S("root", () => {
|
|
1864
|
+
k(".prettierrc"), E("package.json", M(() => jn()), () => {
|
|
1865
|
+
V("pretty"), W("@platforma-sdk/blocks-deps-updater");
|
|
1853
1866
|
});
|
|
1854
1867
|
});
|
|
1855
1868
|
}
|
|
1856
1869
|
//#endregion
|
|
1857
1870
|
//#region src/structure/rules/root-catalog-bump.ts
|
|
1858
|
-
function
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
for (let e of Z)
|
|
1864
|
-
for (let e of
|
|
1871
|
+
function Br() {
|
|
1872
|
+
Ye(() => {
|
|
1873
|
+
S("root", () => {
|
|
1874
|
+
C(({ ctx: e }) => !e.isSdkInternal, () => {
|
|
1875
|
+
E("pnpm-workspace.yaml", M((e) => $n(e)), (e) => {
|
|
1876
|
+
for (let e of Z) zt(e);
|
|
1877
|
+
for (let e of Xn) Bt(e.entry, {
|
|
1865
1878
|
of: e.of,
|
|
1866
1879
|
ofVersion: e.ofVersion
|
|
1867
1880
|
});
|
|
1868
|
-
for (let [e, t] of Object.entries(
|
|
1869
|
-
e.modules.some((e) => e.scope === "software") &&
|
|
1881
|
+
for (let [e, t] of Object.entries(Yn)) Rt(e, t);
|
|
1882
|
+
e.modules.some((e) => e.scope === "software") && Rt(Zn, Qn);
|
|
1870
1883
|
});
|
|
1871
1884
|
});
|
|
1872
1885
|
});
|
|
@@ -1874,25 +1887,25 @@ function Or() {
|
|
|
1874
1887
|
}
|
|
1875
1888
|
//#endregion
|
|
1876
1889
|
//#region src/structure/structure-definition.ts
|
|
1877
|
-
var
|
|
1878
|
-
|
|
1890
|
+
var Vr = He(() => {
|
|
1891
|
+
rr(), ar(), vr(), xr(), wr(), Dr(), Ar(), Rr(), zr(), Br();
|
|
1879
1892
|
});
|
|
1880
1893
|
//#endregion
|
|
1881
1894
|
//#region src/structure/cli/run-structure.ts
|
|
1882
|
-
async function
|
|
1883
|
-
return
|
|
1895
|
+
async function Hr() {
|
|
1896
|
+
return Un(Z.filter(Hn));
|
|
1884
1897
|
}
|
|
1885
|
-
async function
|
|
1886
|
-
let t =
|
|
1898
|
+
async function Ur(e) {
|
|
1899
|
+
let t = h.resolve(e.blockPath), n = e.mode === "check", r = new Ee(t), i = new De(e.templatesRoot), a = un(Vr, r, On({
|
|
1887
1900
|
fs: r,
|
|
1888
1901
|
isSdkInternal: e.isSdkInternal,
|
|
1889
1902
|
updateDepsOnly: e.updateDepsOnly,
|
|
1890
1903
|
dryRun: n
|
|
1891
1904
|
}), {
|
|
1892
1905
|
templates: i,
|
|
1893
|
-
registryLookup: e.updateDepsOnly ? await
|
|
1894
|
-
derivedPinLookup: e.updateDepsOnly ? await
|
|
1895
|
-
rediscover: () =>
|
|
1906
|
+
registryLookup: e.updateDepsOnly ? await Hr() : void 0,
|
|
1907
|
+
derivedPinLookup: e.updateDepsOnly ? await Gn(Xn) : void 0,
|
|
1908
|
+
rediscover: () => On({
|
|
1896
1909
|
fs: r,
|
|
1897
1910
|
isSdkInternal: e.isSdkInternal,
|
|
1898
1911
|
updateDepsOnly: !1,
|
|
@@ -1904,16 +1917,16 @@ async function jr(e) {
|
|
|
1904
1917
|
changes: a.changes
|
|
1905
1918
|
};
|
|
1906
1919
|
}
|
|
1907
|
-
function
|
|
1920
|
+
function Wr(e, t) {
|
|
1908
1921
|
if (t.length === 0) return ` ${e}: up to date (0 changes)`;
|
|
1909
1922
|
let n = t.map((e) => ` ${e.action.padEnd(6)} ${e.primitive.padEnd(8)} ${e.path} [${e.scope}]`);
|
|
1910
1923
|
return ` ${e}: ${t.length} change(s)\n${n.join("\n")}`;
|
|
1911
1924
|
}
|
|
1912
1925
|
//#endregion
|
|
1913
1926
|
//#region src/cmd/structure/refresh.ts
|
|
1914
|
-
async function
|
|
1927
|
+
async function Gr(e) {
|
|
1915
1928
|
for (let t of e.paths) {
|
|
1916
|
-
let n = await
|
|
1929
|
+
let n = await Ur({
|
|
1917
1930
|
blockPath: t,
|
|
1918
1931
|
isSdkInternal: e.isSdkInternal,
|
|
1919
1932
|
updateDepsOnly: e.updateDepsOnly,
|
|
@@ -1921,43 +1934,43 @@ async function Nr(e) {
|
|
|
1921
1934
|
templatesRoot: e.templatesRoot,
|
|
1922
1935
|
log: (t) => e.logger.info(t)
|
|
1923
1936
|
});
|
|
1924
|
-
e.logger.info(
|
|
1937
|
+
e.logger.info(Wr(t, n.changes));
|
|
1925
1938
|
}
|
|
1926
1939
|
}
|
|
1927
|
-
function
|
|
1928
|
-
let t = new
|
|
1940
|
+
function Kr(e) {
|
|
1941
|
+
let t = new p("refresh").description("Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only fires only catalog-bump rules (network).");
|
|
1929
1942
|
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", "fire ONLY catalog-bump rules (npm network). Follow with `pnpm install` then a plain refresh."), t.action(async (t, n) => {
|
|
1930
|
-
let r = t.length > 0 ? t : ["."], i =
|
|
1931
|
-
await
|
|
1943
|
+
let r = t.length > 0 ? t : ["."], i = h.join(e, "src", "structure", "templates");
|
|
1944
|
+
await Gr({
|
|
1932
1945
|
paths: r,
|
|
1933
1946
|
isSdkInternal: !!n.sdkInternal,
|
|
1934
1947
|
updateDepsOnly: !!n.updateDepsOnly,
|
|
1935
1948
|
templatesRoot: i,
|
|
1936
|
-
logger: new
|
|
1949
|
+
logger: new _()
|
|
1937
1950
|
});
|
|
1938
1951
|
}), t;
|
|
1939
1952
|
}
|
|
1940
1953
|
//#endregion
|
|
1941
1954
|
//#region src/cmd/update-deps.ts
|
|
1942
|
-
function
|
|
1943
|
-
let t = new
|
|
1955
|
+
function qr(e) {
|
|
1956
|
+
let t = new p("update-deps").description("[DEPRECATED] Use `block-tools structure refresh --update-deps-only`. This alias delegates to it.");
|
|
1944
1957
|
return t.action(async () => {
|
|
1945
|
-
let t = new
|
|
1946
|
-
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
|
|
1958
|
+
let t = new _();
|
|
1959
|
+
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 Gr({
|
|
1947
1960
|
paths: ["."],
|
|
1948
1961
|
isSdkInternal: !1,
|
|
1949
1962
|
updateDepsOnly: !0,
|
|
1950
|
-
templatesRoot:
|
|
1963
|
+
templatesRoot: h.join(e, "src", "structure", "templates"),
|
|
1951
1964
|
logger: t
|
|
1952
1965
|
});
|
|
1953
1966
|
}), t;
|
|
1954
1967
|
}
|
|
1955
1968
|
//#endregion
|
|
1956
1969
|
//#region src/cmd/list-overview-snapshots.ts
|
|
1957
|
-
function
|
|
1958
|
-
let e = new
|
|
1959
|
-
return e.addOption(new
|
|
1960
|
-
let t = new
|
|
1970
|
+
function Jr() {
|
|
1971
|
+
let e = new p("list-overview-snapshots").description("List all available global overview snapshots in the registry");
|
|
1972
|
+
return e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.option("--json", "output in JSON format", !1), e.action(async (e) => {
|
|
1973
|
+
let t = new _(), n = await new s(o(e.registry), t).listGlobalOverviewSnapshots();
|
|
1961
1974
|
if (e.json) t.info(JSON.stringify(n, null, 2));
|
|
1962
1975
|
else if (n.length === 0) t.info("No snapshots found.");
|
|
1963
1976
|
else {
|
|
@@ -1968,10 +1981,10 @@ function Ir() {
|
|
|
1968
1981
|
}
|
|
1969
1982
|
//#endregion
|
|
1970
1983
|
//#region src/cmd/restore-overview-from-snapshot.ts
|
|
1971
|
-
function
|
|
1972
|
-
let e = new
|
|
1973
|
-
return e.addOption(new
|
|
1974
|
-
let t = new
|
|
1984
|
+
function Yr() {
|
|
1985
|
+
let e = new p("restore-overview-from-snapshot").description("Restore global overview from a snapshot");
|
|
1986
|
+
return e.addOption(new m("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.requiredOption("-s, --snapshot <timestamp>", "snapshot timestamp ID to restore from"), e.option("--skip-confirmation", "skip confirmation prompt (use with caution)", !1), e.action(async (e) => {
|
|
1987
|
+
let t = new _(), n = new s(o(e.registry), t), r = await n.listGlobalOverviewSnapshots();
|
|
1975
1988
|
if (!r.find((t) => t.timestamp === e.snapshot)) throw Error(`Snapshot '${e.snapshot}' not found. Available snapshots:\n${r.map((e) => ` - ${e.timestamp}`).join("\n") || " (none)"}`);
|
|
1976
1989
|
if (!e.skipConfirmation) {
|
|
1977
1990
|
let n = (await import("node:readline")).createInterface({
|
|
@@ -1994,7 +2007,7 @@ function Lr() {
|
|
|
1994
2007
|
}
|
|
1995
2008
|
//#endregion
|
|
1996
2009
|
//#region src/registry_v1/flags.ts
|
|
1997
|
-
function
|
|
2010
|
+
function Xr(e) {
|
|
1998
2011
|
let t = e.match(/(?<destName>[^/\\]+)=(?<src>.*)/);
|
|
1999
2012
|
if (t) {
|
|
2000
2013
|
let { src: e, destName: n } = t.groups;
|
|
@@ -2004,33 +2017,33 @@ function Rr(e) {
|
|
|
2004
2017
|
};
|
|
2005
2018
|
} else return {
|
|
2006
2019
|
src: e,
|
|
2007
|
-
destName:
|
|
2020
|
+
destName: h.basename(e)
|
|
2008
2021
|
};
|
|
2009
2022
|
}
|
|
2010
|
-
function
|
|
2011
|
-
return new
|
|
2023
|
+
function Zr(e, t) {
|
|
2024
|
+
return new m(e, t).argParser((e, t) => [...t ?? [], Xr(e)]).default([]);
|
|
2012
2025
|
}
|
|
2013
2026
|
//#endregion
|
|
2014
2027
|
//#region src/cmd/upload-package-v1.ts
|
|
2015
|
-
var
|
|
2028
|
+
var Qr = [
|
|
2016
2029
|
"registry",
|
|
2017
2030
|
"organization",
|
|
2018
2031
|
"package",
|
|
2019
2032
|
"version"
|
|
2020
2033
|
];
|
|
2021
|
-
function
|
|
2022
|
-
let e = new
|
|
2023
|
-
return e.addOption(new
|
|
2024
|
-
let t = new
|
|
2025
|
-
for (let t of
|
|
2026
|
-
e.meta && (e.meta.endsWith(".json") ? n.meta = JSON.parse(await
|
|
2034
|
+
function $r() {
|
|
2035
|
+
let e = new p("upload-package-v1").description("Uploads V1 package and refreshes the registry");
|
|
2036
|
+
return e.addOption(new m("-r, --registry <address|alias>", "full address of the registry or alias from .pl.reg").env("PL_REGISTRY")), e.addOption(new m("-o, --organization <organization>", "target organisation").env("PL_PACKAGE_ORGANIZATION")), e.addOption(new m("-p, --package <package>", "target package").env("PL_PACKAGE_NAME")), e.addOption(new m("-v, --version <version>", "target version").env("PL_PACKAGE_VERSION")), e.option("-m, --meta <path>", "json file containing meta information to associate with tha package"), e.addOption(Zr("-f, --file <file>", "package files")), e.addOption(new m("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), e.option("--no-refresh", "do not refresh repository after adding the package"), e.action(async (e) => {
|
|
2037
|
+
let t = new _(), n = l.parse({});
|
|
2038
|
+
for (let t of Qr) e[t] && (n[t] = e[t]);
|
|
2039
|
+
e.meta && (e.meta.endsWith(".json") ? n.meta = JSON.parse(await g.promises.readFile(e.meta, { encoding: "utf-8" })) : e.meta.endsWith(".yaml") && (n.meta = ie.parse(await g.promises.readFile(e.meta, { encoding: "utf-8" }))));
|
|
2027
2040
|
for (let t of e.file) n.files[t.destName] = t.src;
|
|
2028
2041
|
let r = await c(n);
|
|
2029
|
-
t.info(
|
|
2042
|
+
t.info(ie.stringify(r.conf));
|
|
2030
2043
|
let i = r.createRegistry(t), a = r.fullPackageName, o = i.constructNewPackage(a);
|
|
2031
2044
|
for (let [e, n] of Object.entries(r.conf.files)) {
|
|
2032
2045
|
t.info(`Uploading ${n} -> ${e} ...`);
|
|
2033
|
-
let r = await
|
|
2046
|
+
let r = await g.promises.readFile(n);
|
|
2034
2047
|
await o.addFile(e, r);
|
|
2035
2048
|
}
|
|
2036
2049
|
t.info("Uploading meta information..."), await o.writeMeta(r.conf.meta), await o.finish(), e.refresh && await i.updateIfNeeded();
|
|
@@ -2038,12 +2051,12 @@ function Vr() {
|
|
|
2038
2051
|
}
|
|
2039
2052
|
//#endregion
|
|
2040
2053
|
//#region src/cmd/structure/check.ts
|
|
2041
|
-
function
|
|
2042
|
-
let t = new
|
|
2054
|
+
function ei(e) {
|
|
2055
|
+
let t = new p("check").description("Check block(s) against the canonical structure (read-only). Exits non-zero if any diff would land — used as the CI gate.");
|
|
2043
2056
|
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) => {
|
|
2044
|
-
let r = new
|
|
2057
|
+
let r = new _(), i = t.length > 0 ? t : ["."], a = h.join(e, "src", "structure", "templates"), o = !1;
|
|
2045
2058
|
for (let e of i) {
|
|
2046
|
-
let t = await
|
|
2059
|
+
let t = await Ur({
|
|
2047
2060
|
blockPath: e,
|
|
2048
2061
|
isSdkInternal: !!n.sdkInternal,
|
|
2049
2062
|
updateDepsOnly: !1,
|
|
@@ -2051,35 +2064,35 @@ function Hr(e) {
|
|
|
2051
2064
|
templatesRoot: a,
|
|
2052
2065
|
log: (e) => r.info(e)
|
|
2053
2066
|
});
|
|
2054
|
-
r.info(
|
|
2067
|
+
r.info(Wr(e, t.changes)), t.changes.length > 0 && (o = !0);
|
|
2055
2068
|
}
|
|
2056
2069
|
if (o) throw Error("Structure check failed: one or more blocks are out of date. Run `structure refresh`.");
|
|
2057
2070
|
}), t;
|
|
2058
2071
|
}
|
|
2059
2072
|
//#endregion
|
|
2060
2073
|
//#region src/structure/init-block-constructor.ts
|
|
2061
|
-
var $ = ["python"],
|
|
2074
|
+
var $ = ["python"], ti = class extends Error {
|
|
2062
2075
|
constructor(e) {
|
|
2063
2076
|
super(`Missing required flag --${e} in --non-interactive mode. Supply every BlockVars flag, or drop --non-interactive to be prompted.`), this.name = "InitFlagError";
|
|
2064
2077
|
}
|
|
2065
2078
|
};
|
|
2066
|
-
async function
|
|
2079
|
+
async function ni(e, t, n, r) {
|
|
2067
2080
|
if (e !== void 0 && e !== "") return e;
|
|
2068
|
-
if (n) throw new
|
|
2081
|
+
if (n) throw new ti(t);
|
|
2069
2082
|
return r();
|
|
2070
2083
|
}
|
|
2071
|
-
async function
|
|
2072
|
-
let t = await
|
|
2084
|
+
async function ri(e) {
|
|
2085
|
+
let t = await ni(e.npmOrg, "npm-org", e.nonInteractive, () => de({
|
|
2073
2086
|
message: "npm org (e.g. @platforma-open):",
|
|
2074
2087
|
default: "@platforma-open"
|
|
2075
|
-
})), n = await
|
|
2088
|
+
})), n = await ni(e.orgScope, "org-scope", e.nonInteractive, () => de({ message: "org scope (e.g. my-org):" })), r = await ni(e.shortName, "short-name", e.nonInteractive, () => de({ message: "block short name (e.g. mixcr-clonotyping):" })), i;
|
|
2076
2089
|
i = e.withSoftware === void 0 ? e.nonInteractive ? !1 : await ue({
|
|
2077
2090
|
message: "Include a software module?",
|
|
2078
2091
|
default: !1
|
|
2079
2092
|
}) : e.withSoftware;
|
|
2080
2093
|
let a;
|
|
2081
2094
|
if (i) {
|
|
2082
|
-
if (a = await
|
|
2095
|
+
if (a = await ni(e.platform, "platform", e.nonInteractive, () => fe({
|
|
2083
2096
|
message: "Software platform:",
|
|
2084
2097
|
choices: $.map((e) => ({
|
|
2085
2098
|
name: e,
|
|
@@ -2096,20 +2109,20 @@ async function Gr(e) {
|
|
|
2096
2109
|
softwarePlatform: a
|
|
2097
2110
|
};
|
|
2098
2111
|
}
|
|
2099
|
-
async function
|
|
2100
|
-
let t = e.vars, n =
|
|
2112
|
+
async function ii(e) {
|
|
2113
|
+
let t = e.vars, n = bn(t), r = new Ee(e.blockPath), i = new De(e.templatesRoot), a = xn({
|
|
2101
2114
|
blockVars: t,
|
|
2102
2115
|
modules: n,
|
|
2103
2116
|
isSdkInternal: !1,
|
|
2104
|
-
version:
|
|
2117
|
+
version: 2,
|
|
2105
2118
|
dryRun: !1
|
|
2106
|
-
}), o = Z.filter(
|
|
2119
|
+
}), o = Z.filter(Hn), s, c;
|
|
2107
2120
|
try {
|
|
2108
|
-
s = await
|
|
2121
|
+
s = await Un(o), c = await Gn(Xn);
|
|
2109
2122
|
} catch (e) {
|
|
2110
2123
|
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)}`);
|
|
2111
2124
|
}
|
|
2112
|
-
return
|
|
2125
|
+
return un(Vr, r, a, {
|
|
2113
2126
|
templates: i,
|
|
2114
2127
|
initMode: !0,
|
|
2115
2128
|
registryLookup: s,
|
|
@@ -2118,12 +2131,12 @@ async function Kr(e) {
|
|
|
2118
2131
|
}
|
|
2119
2132
|
//#endregion
|
|
2120
2133
|
//#region src/cmd/structure/init.ts
|
|
2121
|
-
function
|
|
2122
|
-
let t = new
|
|
2123
|
-
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
|
|
2124
|
-
let r = new
|
|
2134
|
+
function ai(e) {
|
|
2135
|
+
let t = new p("init").description("Scaffold a fresh Platforma block from the canonical structure. Missing flags are prompted unless --non-interactive.");
|
|
2136
|
+
return t.argument("[path]", "target directory (default: <short-name> under the current directory)"), t.option("--npm-org <org>", "npm org, e.g. @platforma-open"), t.option("--org-scope <scope>", "org scope, e.g. my-org"), t.option("--short-name <name>", "block short name, e.g. mixcr-clonotyping"), t.option("--with-software", "include a software module"), t.option("--no-software", "omit the software module"), t.addOption(new m("--platform <platform>", "software platform (single-valued)").choices([...$])), t.option("--non-interactive", "error on any missing flag instead of prompting"), t.action(async (t, n) => {
|
|
2137
|
+
let r = new _(), i = n.withSoftware === !0, a = n.software === !1;
|
|
2125
2138
|
if (i && a) throw Error("--with-software and --no-software are mutually exclusive.");
|
|
2126
|
-
let o = i ? !0 : a ? !1 : void 0, s = await
|
|
2139
|
+
let o = i ? !0 : a ? !1 : void 0, s = await ri({
|
|
2127
2140
|
npmOrg: n.npmOrg,
|
|
2128
2141
|
orgScope: n.orgScope,
|
|
2129
2142
|
shortName: n.shortName,
|
|
@@ -2131,26 +2144,233 @@ function qr(e) {
|
|
|
2131
2144
|
platform: n.platform,
|
|
2132
2145
|
nonInteractive: n.nonInteractive
|
|
2133
2146
|
});
|
|
2134
|
-
await
|
|
2147
|
+
await ii({
|
|
2135
2148
|
vars: s,
|
|
2136
|
-
blockPath: t ?
|
|
2137
|
-
templatesRoot:
|
|
2149
|
+
blockPath: t ? h.resolve(t) : h.resolve(process.cwd(), s.shortName),
|
|
2150
|
+
templatesRoot: h.join(e, "src", "structure", "templates"),
|
|
2138
2151
|
log: (e) => r.info(e)
|
|
2139
2152
|
});
|
|
2140
2153
|
}), t;
|
|
2141
2154
|
}
|
|
2142
2155
|
//#endregion
|
|
2156
|
+
//#region src/cmd/software/knobs.ts
|
|
2157
|
+
var oi = ["dev", "release"], si = [
|
|
2158
|
+
"docker",
|
|
2159
|
+
"binary",
|
|
2160
|
+
"all",
|
|
2161
|
+
"none"
|
|
2162
|
+
], ci = ["local", "remote"];
|
|
2163
|
+
function li(e) {
|
|
2164
|
+
if (e.usePublished) {
|
|
2165
|
+
if (e.variant === "docker" || e.variant === "all") throw y.CLIError(`--use-published is binary-only and cannot be combined with --variant ${e.variant}`);
|
|
2166
|
+
return { kind: "binary-existing" };
|
|
2167
|
+
}
|
|
2168
|
+
return e.variant === "none" ? { kind: "no-software" } : e.location === void 0 ? { kind: "bare" } : {
|
|
2169
|
+
kind: "target",
|
|
2170
|
+
channel: e.channel ?? "release",
|
|
2171
|
+
variant: e.variant ?? "all",
|
|
2172
|
+
location: e.location
|
|
2173
|
+
};
|
|
2174
|
+
}
|
|
2175
|
+
//#endregion
|
|
2176
|
+
//#region src/cmd/software/ecr-login.ts
|
|
2177
|
+
var ui = "public.ecr.aws", di = "us-east-1";
|
|
2178
|
+
function fi(e) {
|
|
2179
|
+
if (process.env.AWS_ACCESS_KEY_ID || process.env.AWS_PROFILE) return;
|
|
2180
|
+
let t = process.env.PL_AWS_PROFILE ?? me.AWS_DEV_PROFILE;
|
|
2181
|
+
process.env.AWS_PROFILE = t, e?.debug(`Using AWS profile '${t}' for dev push credentials`);
|
|
2182
|
+
}
|
|
2183
|
+
function pi(e) {
|
|
2184
|
+
return new URL(`https://${e}`).hostname;
|
|
2185
|
+
}
|
|
2186
|
+
function mi() {
|
|
2187
|
+
return ` aws sso login --profile ${process.env.AWS_PROFILE ?? process.env.PL_AWS_PROFILE ?? me.AWS_DEV_PROFILE}`;
|
|
2188
|
+
}
|
|
2189
|
+
async function hi(e, t) {
|
|
2190
|
+
let n = pi(e);
|
|
2191
|
+
if (n !== ui) throw y.CLIError(`automatic docker login is only supported for '${ui}', not '${n}'.\nLog in manually, or drop the ecr:// scheme from the push target to opt out.`);
|
|
2192
|
+
t?.info(`Logging in to ECR registry '${n}'...`);
|
|
2193
|
+
let r, i;
|
|
2194
|
+
try {
|
|
2195
|
+
let e = (await new ge({ region: di }).send(new _e({}))).authorizationData?.authorizationToken;
|
|
2196
|
+
if (!e) throw Error("empty authorization token");
|
|
2197
|
+
let t = Buffer.from(e, "base64").toString("utf8"), n = t.indexOf(":");
|
|
2198
|
+
if (n < 0) throw Error("malformed authorization token (no ':' separator)");
|
|
2199
|
+
r = t.slice(0, n), i = t.slice(n + 1);
|
|
2200
|
+
} catch (e) {
|
|
2201
|
+
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` + mi());
|
|
2202
|
+
}
|
|
2203
|
+
let a = he("docker", [
|
|
2204
|
+
"login",
|
|
2205
|
+
"--username",
|
|
2206
|
+
r,
|
|
2207
|
+
"--password-stdin",
|
|
2208
|
+
n
|
|
2209
|
+
], {
|
|
2210
|
+
input: i,
|
|
2211
|
+
stdio: [
|
|
2212
|
+
"pipe",
|
|
2213
|
+
"inherit",
|
|
2214
|
+
"inherit"
|
|
2215
|
+
],
|
|
2216
|
+
env: {
|
|
2217
|
+
...process.env,
|
|
2218
|
+
HOME: process.env.HOME || le.homedir()
|
|
2219
|
+
}
|
|
2220
|
+
});
|
|
2221
|
+
if (a.error || a.status !== 0) throw y.CLIError(`'docker login ${n}' failed`);
|
|
2222
|
+
}
|
|
2223
|
+
//#endregion
|
|
2224
|
+
//#region src/cmd/software/run-build.ts
|
|
2225
|
+
async function gi(e) {
|
|
2226
|
+
let { core: t, scenario: n, options: r = {}, logger: i } = e, a = r.ids;
|
|
2227
|
+
t.buildMode = _i(n);
|
|
2228
|
+
let o = () => t.buildSoftwareArchives({
|
|
2229
|
+
ids: a,
|
|
2230
|
+
forceBuild: !!r.force,
|
|
2231
|
+
contentRoot: r.contentRoot,
|
|
2232
|
+
skipIfEmpty: !a,
|
|
2233
|
+
condaBuild: r.condaBuild
|
|
2234
|
+
});
|
|
2235
|
+
switch (n.kind) {
|
|
2236
|
+
case "binary-existing":
|
|
2237
|
+
t.writePublishedArtifactInfo({ ids: a });
|
|
2238
|
+
break;
|
|
2239
|
+
case "no-software": break;
|
|
2240
|
+
case "bare":
|
|
2241
|
+
r.buildDocker && t.buildDockerImages({
|
|
2242
|
+
ids: a,
|
|
2243
|
+
registry: r.dockerRegistry,
|
|
2244
|
+
strictPlatformMatching: v.isCI()
|
|
2245
|
+
}), await o(), r.pushDocker && t.publishDockerImages({
|
|
2246
|
+
ids: a,
|
|
2247
|
+
pushTo: r.dockerPushTo,
|
|
2248
|
+
strictPlatformMatching: v.isCI()
|
|
2249
|
+
});
|
|
2250
|
+
break;
|
|
2251
|
+
case "target": {
|
|
2252
|
+
let { channel: e, variant: s, location: c } = n, l = s !== "binary", u = s !== "docker", d = c === "remote", f = bi(e, r);
|
|
2253
|
+
l && t.buildDockerImages({
|
|
2254
|
+
ids: a,
|
|
2255
|
+
registry: f.pull,
|
|
2256
|
+
strictPlatformMatching: v.isCI()
|
|
2257
|
+
}), u && await o(), d && e === "dev" && (l || u) && fi(i), l && d && (f.autoLogin && f.push && await hi(f.push, i), t.publishDockerImages({
|
|
2258
|
+
ids: a,
|
|
2259
|
+
pushTo: f.push,
|
|
2260
|
+
strictPlatformMatching: v.isCI()
|
|
2261
|
+
})), u && d && await t.publishPackages({
|
|
2262
|
+
ids: a,
|
|
2263
|
+
storageURL: r.storageUrl
|
|
2264
|
+
});
|
|
2265
|
+
break;
|
|
2266
|
+
}
|
|
2267
|
+
default: y.assertNever(n);
|
|
2268
|
+
}
|
|
2269
|
+
t.buildSwJsonFiles({
|
|
2270
|
+
packageIds: a,
|
|
2271
|
+
noSoftware: n.kind === "no-software"
|
|
2272
|
+
});
|
|
2273
|
+
}
|
|
2274
|
+
function _i(e) {
|
|
2275
|
+
return e.kind !== "target" || e.channel === "release" ? "release" : e.variant !== "docker" && e.location === "remote" ? "dev-remote" : "dev-local";
|
|
2276
|
+
}
|
|
2277
|
+
function vi(e) {
|
|
2278
|
+
if (!e.includes("://")) return e;
|
|
2279
|
+
let t = new URL(e);
|
|
2280
|
+
return t.host + t.pathname;
|
|
2281
|
+
}
|
|
2282
|
+
function yi(e) {
|
|
2283
|
+
return {
|
|
2284
|
+
registry: vi(e),
|
|
2285
|
+
autoLogin: e.startsWith("ecr://")
|
|
2286
|
+
};
|
|
2287
|
+
}
|
|
2288
|
+
function bi(e, t) {
|
|
2289
|
+
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 ? me.DEV_DOCKER_PUSH_TARGET : void 0), o = a ? yi(a) : {
|
|
2290
|
+
registry: void 0,
|
|
2291
|
+
autoLogin: !1
|
|
2292
|
+
}, s = t.dockerRegistry ?? i ?? a;
|
|
2293
|
+
return {
|
|
2294
|
+
pull: s ? vi(s) : void 0,
|
|
2295
|
+
push: o.registry,
|
|
2296
|
+
autoLogin: o.autoLogin
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
//#endregion
|
|
2300
|
+
//#region src/cmd/software/env.ts
|
|
2301
|
+
var xi = "PL_BUILD_CHANNEL", Si = "PL_BUILD_VARIANT", Ci = "PL_BUILD_LOCATION", wi = "PL_BUILD_USE_PUBLISHED";
|
|
2302
|
+
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;
|
|
2303
|
+
//#endregion
|
|
2304
|
+
//#region src/cmd/software/build.ts
|
|
2305
|
+
function Ti() {
|
|
2306
|
+
let e = new p("build").description("Build a software module for a target and write its .sw.json descriptor (build + push in one pass)");
|
|
2307
|
+
return e.addOption(new m("--channel <channel>", "registry channel to build for").choices([...oi]).env(xi)), e.addOption(new m("--variant <variant>", "artifact kind to build (default: all declared)").choices([...si]).env(Si)), e.addOption(new m("--location <location>", "where the artifact lands (local = no push)").choices([...ci]).env(Ci)), e.addOption(new m("--use-published", "do not build or push; emit a descriptor pointing at the already-published release artifact").env(wi)), e.addOption(new m("--log-level <level>", "logging level").choices([
|
|
2308
|
+
"error",
|
|
2309
|
+
"warn",
|
|
2310
|
+
"info",
|
|
2311
|
+
"debug"
|
|
2312
|
+
]).default("info")), e.addOption(new m("--package-root <path>", "path to directory with package.json file")), e.addOption(new m("--force", "force action, ignoring automatic safety checks").default(!1)), e.addOption(new m("--version <value>", "override package version (ignore package.json)")), e.addOption(new m("--platform <os-arch>", "{os}-{arch} pair; no effect on cross-platform packages").choices([...y.AllPlatforms]).env(v.PL_PKG_OS)), e.addOption(new m("--all-platforms", "build for all supported platforms").default(!1)), e.addOption(new m("--full-dir-hash", "hash file contents (not metadata) for the dev content hash").env(v.PL_PKG_FULL_HASH).default(!1)), e.addOption(new m("--package-id <id...>", "act only on selected packages")), e.addOption(new m("--content-root <path>", "override software content root").env(v.PL_PKG_CONTENT_ROOT)), e.addOption(new m("--storage-url <url>", "override binary upload registry URL").env(v.PL_PKG_STORAGE_URL)), e.addOption(new m("--docker-registry <registry>", "docker pull registry embedded in the descriptor").env(v.PL_DOCKER_REGISTRY)), e.addOption(new m("--docker-push-to <registry>", "alternative registry for docker push").env(v.PL_DOCKER_REGISTRY_PUSH_TO)), e.addOption(new m("--docker-build", "build docker images").env(v.PL_DOCKER_BUILD).default(!1)), e.addOption(new m("--docker-no-build", "do not build docker images").env(v.PL_DOCKER_NO_BUILD).default(!1)), e.addOption(new m("--docker-autopush", "push docker images after build").env(v.PL_DOCKER_AUTOPUSH).default(!1)), e.addOption(new m("--docker-no-autopush", "do not push docker images").env(v.PL_DOCKER_NO_AUTOPUSH).default(!1)), e.addOption(new m("--conda-build", "build conda environment before packing").env(v.PL_CONDA_BUILD).default(!1)), e.addOption(new m("--conda-no-build", "do not build conda environment").env(v.PL_CONDA_NO_BUILD).default(!1)), e.action(async (e) => {
|
|
2313
|
+
let t = y.createLogger(e.logLevel);
|
|
2314
|
+
try {
|
|
2315
|
+
let n = li({
|
|
2316
|
+
channel: e.channel,
|
|
2317
|
+
variant: e.variant,
|
|
2318
|
+
location: e.location,
|
|
2319
|
+
usePublished: !!e.usePublished
|
|
2320
|
+
}), r = pe(t, { packageRoot: e.packageRoot });
|
|
2321
|
+
r.version = e.version, r.targetPlatform = e.platform, r.allPlatforms = !!e.allPlatforms, r.fullDirHash = !!e.fullDirHash;
|
|
2322
|
+
let i = y.shouldDoAction({
|
|
2323
|
+
default: v.isCI(),
|
|
2324
|
+
enable: e.dockerBuild,
|
|
2325
|
+
disable: e.dockerNoBuild
|
|
2326
|
+
}), a = i && y.shouldDoAction({
|
|
2327
|
+
default: v.isCI() && !r.isPrivate,
|
|
2328
|
+
enable: e.dockerAutopush,
|
|
2329
|
+
disable: e.dockerNoAutopush
|
|
2330
|
+
});
|
|
2331
|
+
await gi({
|
|
2332
|
+
core: r,
|
|
2333
|
+
scenario: n,
|
|
2334
|
+
logger: t,
|
|
2335
|
+
options: {
|
|
2336
|
+
ids: e.packageId,
|
|
2337
|
+
force: e.force,
|
|
2338
|
+
contentRoot: e.contentRoot,
|
|
2339
|
+
storageUrl: e.storageUrl,
|
|
2340
|
+
dockerRegistry: e.dockerRegistry,
|
|
2341
|
+
dockerPushTo: e.dockerPushTo,
|
|
2342
|
+
buildDocker: i,
|
|
2343
|
+
pushDocker: a,
|
|
2344
|
+
condaBuild: y.shouldDoAction({
|
|
2345
|
+
default: !0,
|
|
2346
|
+
enable: e.condaBuild,
|
|
2347
|
+
disable: e.condaNoBuild
|
|
2348
|
+
})
|
|
2349
|
+
}
|
|
2350
|
+
});
|
|
2351
|
+
} catch (e) {
|
|
2352
|
+
throw t.debug(e), e instanceof Error && t.debug(e.stack), e;
|
|
2353
|
+
}
|
|
2354
|
+
}), e;
|
|
2355
|
+
}
|
|
2356
|
+
//#endregion
|
|
2357
|
+
//#region src/cmd/software/index.ts
|
|
2358
|
+
function Ei() {
|
|
2359
|
+
let e = new p("software").description("Build and publish a block's software modules");
|
|
2360
|
+
return e.addCommand(Ti()), e;
|
|
2361
|
+
}
|
|
2362
|
+
//#endregion
|
|
2143
2363
|
//#region src/cli.ts
|
|
2144
|
-
function
|
|
2145
|
-
let t = new
|
|
2146
|
-
t.name("block-tools").description("Utility to manipulate Platforma Blocks and Block Registry"), t.addCommand(
|
|
2147
|
-
let n = new
|
|
2148
|
-
return n.addCommand(
|
|
2364
|
+
function Di(e = process.cwd()) {
|
|
2365
|
+
let t = new p();
|
|
2366
|
+
t.name("block-tools").description("Utility to manipulate Platforma Blocks and Block Registry"), t.addCommand(ve()), t.addCommand(be()), t.addCommand(xe()), t.addCommand(Ce()), t.addCommand(we()), t.addCommand(Te()), t.addCommand(qr(e)), t.addCommand(Jr()), t.addCommand(Yr()), t.addCommand($r()), t.addCommand(Ei());
|
|
2367
|
+
let n = new p("structure").description("Manage block scaffolding against the canonical structure (check / init / refresh)");
|
|
2368
|
+
return n.addCommand(ei(e)), n.addCommand(ai(e)), n.addCommand(Kr(e)), t.addCommand(n), t;
|
|
2149
2369
|
}
|
|
2150
|
-
async function
|
|
2151
|
-
await
|
|
2370
|
+
async function Oi(e, t) {
|
|
2371
|
+
await Di(t).parseAsync(e);
|
|
2152
2372
|
}
|
|
2153
2373
|
//#endregion
|
|
2154
|
-
export {
|
|
2374
|
+
export { Di as buildProgram, Oi as run };
|
|
2155
2375
|
|
|
2156
2376
|
//# sourceMappingURL=cli.mjs.map
|