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