@ordewell/core 0.12.2 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ModeResolver-CA2fUU9h.d.mts → ModeResolver-CkZnbIqs.d.mts} +1 -1
- package/dist/{ModeResolver-B64aUZXJ.d.ts → ModeResolver-DS-aCVOP.d.ts} +1 -1
- package/dist/{Task-CxGgN6I0.d.mts → Task-D3O49EUo.d.mts} +43 -6
- package/dist/{Task-CxGgN6I0.d.ts → Task-D3O49EUo.d.ts} +43 -6
- package/dist/{chunk-RZ23BMVR.mjs → chunk-3S5IVTZM.mjs} +80 -22
- package/dist/chunk-3S5IVTZM.mjs.map +1 -0
- package/dist/{chunk-FX33UKAD.mjs → chunk-IOYBL3E5.mjs} +3 -3
- package/dist/{chunk-UDUATSCJ.mjs → chunk-MJKCU4U7.mjs} +1 -1
- package/dist/{chunk-UDUATSCJ.mjs.map → chunk-MJKCU4U7.mjs.map} +1 -1
- package/dist/{chunk-PKJTN2PD.mjs → chunk-POD3KZQW.mjs} +7 -1
- package/dist/chunk-POD3KZQW.mjs.map +1 -0
- package/dist/{chunk-2IFKPYPO.mjs → chunk-YZDWWXCB.mjs} +58 -17
- package/dist/chunk-YZDWWXCB.mjs.map +1 -0
- package/dist/{eventStore-CTCSKS9E.d.ts → eventStore-BcoMsZtU.d.mts} +23 -7
- package/dist/{eventStore-CcB8yELZ.d.mts → eventStore-CSFKy48Y.d.ts} +23 -7
- package/dist/index.d.mts +248 -112
- package/dist/index.d.ts +248 -112
- package/dist/index.js +2576 -1104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2240 -866
- package/dist/index.mjs.map +1 -1
- package/dist/parsing.d.mts +2 -2
- package/dist/parsing.d.ts +2 -2
- package/dist/parsing.js +43 -15
- package/dist/parsing.js.map +1 -1
- package/dist/parsing.mjs +3 -3
- package/dist/plan-utils.d.mts +4 -4
- package/dist/plan-utils.d.ts +4 -4
- package/dist/plan-utils.js +65 -14
- package/dist/plan-utils.js.map +1 -1
- package/dist/plan-utils.mjs +15 -3
- package/dist/plan-utils.mjs.map +1 -1
- package/dist/{runSettingsText-DFVpe6aU.d.mts → runSettingsText-C6eto6Uv.d.ts} +550 -26
- package/dist/{runSettingsText-lKLDsyli.d.ts → runSettingsText-DnzSrB0c.d.mts} +550 -26
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +2 -2
- package/docker/task.Dockerfile +7 -4
- package/package.json +1 -1
- package/dist/chunk-2IFKPYPO.mjs.map +0 -1
- package/dist/chunk-PKJTN2PD.mjs.map +0 -1
- package/dist/chunk-RZ23BMVR.mjs.map +0 -1
- /package/dist/{chunk-FX33UKAD.mjs.map → chunk-IOYBL3E5.mjs.map} +0 -0
package/dist/parsing.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { R as RunnerModeInfo } from './ModeResolver-
|
|
1
|
+
import { b4 as RunnerId, bq as Task } from './Task-D3O49EUo.mjs';
|
|
2
|
+
import { R as RunnerModeInfo } from './ModeResolver-CkZnbIqs.mjs';
|
|
3
3
|
|
|
4
4
|
declare function parsePlanJson(raw: string, runners: RunnerId[], runnerModes?: Record<RunnerId, RunnerModeInfo[]>, autonomousDefault?: boolean): Task[];
|
|
5
5
|
|
package/dist/parsing.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { R as RunnerModeInfo } from './ModeResolver-
|
|
1
|
+
import { b4 as RunnerId, bq as Task } from './Task-D3O49EUo.js';
|
|
2
|
+
import { R as RunnerModeInfo } from './ModeResolver-DS-aCVOP.js';
|
|
3
3
|
|
|
4
4
|
declare function parsePlanJson(raw: string, runners: RunnerId[], runnerModes?: Record<RunnerId, RunnerModeInfo[]>, autonomousDefault?: boolean): Task[];
|
|
5
5
|
|
package/dist/parsing.js
CHANGED
|
@@ -322,11 +322,14 @@ var lesser = (limit) => (parent, request) => {
|
|
|
322
322
|
return { value: Math.min(parent[limit], asked ?? parent[limit]) };
|
|
323
323
|
};
|
|
324
324
|
function intersectModels(parent, asked = {}) {
|
|
325
|
-
const models = { ...
|
|
326
|
-
for (const runner of Object.
|
|
327
|
-
|
|
325
|
+
const models = { ...parent };
|
|
326
|
+
for (const [runner, wanted] of Object.entries(asked)) {
|
|
327
|
+
const held = parent[runner] ?? [];
|
|
328
|
+
const kept = held.length > 0 ? held.filter((model) => wanted.includes(model)) : wanted;
|
|
329
|
+
if (kept.length === 0) return { refused: { field: "limits.models", asked: `${runner}: ${wanted.join(", ") || "nothing"}`, there: `${runner}: ${held.join(", ") || "any"}` } };
|
|
330
|
+
models[runner] = kept;
|
|
328
331
|
}
|
|
329
|
-
return models;
|
|
332
|
+
return { value: models };
|
|
330
333
|
}
|
|
331
334
|
var LIMIT_RULES = {
|
|
332
335
|
tokens: ({ tokens }, { tokens: asked }) => {
|
|
@@ -346,8 +349,12 @@ var LIMIT_RULES = {
|
|
|
346
349
|
},
|
|
347
350
|
delegatedTasks: lesser("delegatedTasks"),
|
|
348
351
|
tasksPerPlan: lesser("tasksPerPlan"),
|
|
349
|
-
runners: ({ runners }, { runners: asked }) =>
|
|
350
|
-
|
|
352
|
+
runners: ({ runners }, { runners: asked }) => {
|
|
353
|
+
if (!asked) return { value: runners };
|
|
354
|
+
const kept = runners.filter((runner) => asked.includes(runner));
|
|
355
|
+
return kept.length > 0 ? { value: kept } : { refused: { field: "limits.runners", asked: asked.join(", ") || "nothing", there: runners.join(", ") || "nothing" } };
|
|
356
|
+
},
|
|
357
|
+
models: ({ models }, { models: asked }) => intersectModels(models, asked)
|
|
351
358
|
};
|
|
352
359
|
var COMMAND_GRANTS = {
|
|
353
360
|
run_plan: "control",
|
|
@@ -476,6 +483,11 @@ function delegationErrors(tasks, rules = {}) {
|
|
|
476
483
|
const paths = task.protectedPaths;
|
|
477
484
|
if (!task.readOnly && (!Array.isArray(paths) || paths.length === 0 || !paths.every((p) => typeof p === "string" && p.trim()))) {
|
|
478
485
|
fail(task, "protectedPaths", `${where} is a delegated task that lands, with no "protectedPaths": name the paths its child may not change, what its check runs and the configuration that runs it`);
|
|
486
|
+
} else if (!task.readOnly) {
|
|
487
|
+
for (const rule of paths ?? []) {
|
|
488
|
+
const fault = protectedPathFault(rule);
|
|
489
|
+
if (fault) fail(task, "protectedPaths", `${where} protects "${rule}", which ${fault}`);
|
|
490
|
+
}
|
|
479
491
|
}
|
|
480
492
|
if (task.scope !== void 0 && !scopeOk(task.scope)) fail(task, "scope", `${where} has a "scope" that is not lists of text: "paths", "provides" and "consumes", at most ${SCOPE_LIMITS.items} items of one line and ${SCOPE_LIMITS.item} characters each`);
|
|
481
493
|
const unknown = (task.grants ?? []).filter((grant) => !GRANTS.includes(grant));
|
|
@@ -513,20 +525,35 @@ function scopeOk(scope) {
|
|
|
513
525
|
function judges(task, delegated, runnerModes) {
|
|
514
526
|
return readsOnly(task, runnerModes) || !delegated.readOnly && task.type === "script" && task.readOnly === true;
|
|
515
527
|
}
|
|
528
|
+
function pathSteps(path) {
|
|
529
|
+
return path.trim().replace(/\\/g, "/").split("/").filter((step) => step !== "" && step !== ".");
|
|
530
|
+
}
|
|
531
|
+
function foldedPath(path) {
|
|
532
|
+
return pathSteps(path).join("/").normalize("NFC").toUpperCase().toLowerCase();
|
|
533
|
+
}
|
|
534
|
+
function protectedPathFault(rule) {
|
|
535
|
+
const path = rule.trim().replace(/\\/g, "/");
|
|
536
|
+
if (path.startsWith("/") || /^[a-z]:\//i.test(path)) return "is not relative to the repository, and a diff lists nothing else: name it from the repository's root";
|
|
537
|
+
const steps = pathSteps(path);
|
|
538
|
+
if (steps.includes("..")) return "is outside the repository: name a path inside it";
|
|
539
|
+
if (steps.every((step) => /^\*+$/.test(step))) return 'covers the whole repository, so its child could land nothing: name what it may not change, or make the task "readOnly"';
|
|
540
|
+
if (/[?{}]|^!/.test(path) || path.includes("*") && /[[\]]/.test(path)) return "reads as a wildcard, and only `*` is a wildcard here, with `**` for any depth: name each path";
|
|
541
|
+
return null;
|
|
542
|
+
}
|
|
516
543
|
function underProtectedPath(file, protectedPath) {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
return
|
|
544
|
+
if (!protectedPath.trim()) return false;
|
|
545
|
+
const rule = foldedPath(protectedPath).replace(/(?:\/\*\*)+$/, "");
|
|
546
|
+
const path = foldedPath(file);
|
|
547
|
+
if (rule.includes("*")) return globRegExp(rule).test(path);
|
|
548
|
+
return !rule || path === rule || path.startsWith(`${rule}/`);
|
|
522
549
|
}
|
|
523
550
|
function fixedStart(rule) {
|
|
524
|
-
const bare = rule
|
|
551
|
+
const bare = foldedPath(rule);
|
|
525
552
|
const star = bare.indexOf("*");
|
|
526
553
|
return star === -1 ? bare : bare.slice(0, star);
|
|
527
554
|
}
|
|
528
555
|
function pathsMeet(a, b) {
|
|
529
|
-
if (underProtectedPath(a
|
|
556
|
+
if (underProtectedPath(a, b) || underProtectedPath(b, a)) return true;
|
|
530
557
|
if (!a.includes("*") || !b.includes("*")) return false;
|
|
531
558
|
const [one, other] = [fixedStart(a), fixedStart(b)];
|
|
532
559
|
return one.startsWith(other) || other.startsWith(one);
|
|
@@ -557,9 +584,10 @@ function scopeOverlaps(tasks) {
|
|
|
557
584
|
});
|
|
558
585
|
return said;
|
|
559
586
|
}
|
|
587
|
+
var GLOB_STARS = { "*": "[^/]*", "**": ".*", "**/": "(?:.*/)?" };
|
|
560
588
|
function globRegExp(rule) {
|
|
561
|
-
const pattern = rule.replace(/[
|
|
562
|
-
return new RegExp(`^${pattern}(?:/.*)
|
|
589
|
+
const pattern = rule.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*\*\/|\*\*|\*/g, (star) => GLOB_STARS[star]);
|
|
590
|
+
return new RegExp(`^${rule.includes("/") ? "" : "(?:.*/)?"}${pattern}(?:/.*)?$`, "s");
|
|
563
591
|
}
|
|
564
592
|
|
|
565
593
|
// src/services/PlannedTask.ts
|