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