spec-controller 0.1.93 → 0.1.95

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.
Files changed (2) hide show
  1. package/dist/cli.js +304 -21
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -12865,6 +12865,218 @@ var init_cucumber = __esm({
12865
12865
  });
12866
12866
 
12867
12867
  // ../../node_modules/.pnpm/unbash@6.0.1/node_modules/unbash/dist/traversal.js
12868
+ function forEachChild(node, callback) {
12869
+ switch (node.type) {
12870
+ case "Script":
12871
+ case "CompoundList":
12872
+ case "AndOr":
12873
+ for (const command of node.commands)
12874
+ callback(command);
12875
+ return;
12876
+ case "Statement":
12877
+ callback(node.command);
12878
+ return;
12879
+ case "Command":
12880
+ for (const child of node.prefix)
12881
+ callback(child);
12882
+ if (node.name)
12883
+ callback(node.name);
12884
+ for (const child of node.suffix)
12885
+ callback(child);
12886
+ return;
12887
+ case "Pipeline":
12888
+ for (const prefix of node.prefixes)
12889
+ callback(prefix);
12890
+ for (const command of node.commands)
12891
+ callback(command);
12892
+ return;
12893
+ case "Redirected":
12894
+ callback(node.command);
12895
+ for (const redirect of node.redirects)
12896
+ callback(redirect);
12897
+ return;
12898
+ case "If":
12899
+ callback(node.clause);
12900
+ callback(node.then);
12901
+ for (const branch of node.elif)
12902
+ callback(branch);
12903
+ if (node.else)
12904
+ callback(node.else);
12905
+ return;
12906
+ case "Elif":
12907
+ callback(node.clause);
12908
+ callback(node.then);
12909
+ return;
12910
+ case "For":
12911
+ case "Select":
12912
+ callback(node.name);
12913
+ if (node.wordlist)
12914
+ for (const word of node.wordlist)
12915
+ callback(word);
12916
+ callback(node.body);
12917
+ return;
12918
+ case "While":
12919
+ callback(node.clause);
12920
+ callback(node.body);
12921
+ return;
12922
+ case "Function":
12923
+ case "Coproc":
12924
+ if (node.name)
12925
+ callback(node.name);
12926
+ callback(node.body);
12927
+ return;
12928
+ case "Subshell":
12929
+ case "BraceGroup":
12930
+ callback(node.body);
12931
+ return;
12932
+ case "Case":
12933
+ callback(node.word);
12934
+ for (const item of node.items)
12935
+ callback(item);
12936
+ return;
12937
+ case "CaseItem":
12938
+ for (const pattern of node.pattern)
12939
+ callback(pattern);
12940
+ callback(node.body);
12941
+ return;
12942
+ case "ArithmeticFor": {
12943
+ const initialize = node.initialize;
12944
+ if (initialize)
12945
+ callback(initialize);
12946
+ const test = node.test;
12947
+ if (test)
12948
+ callback(test);
12949
+ const update = node.update;
12950
+ if (update)
12951
+ callback(update);
12952
+ callback(node.body);
12953
+ return;
12954
+ }
12955
+ case "Word":
12956
+ case "Glob":
12957
+ case "ArithmeticWord":
12958
+ case "HereDocBody":
12959
+ case "BraceExpansion":
12960
+ case "ExtendedGlob": {
12961
+ const parts = node.parts;
12962
+ if (parts)
12963
+ for (const part of parts)
12964
+ callback(part);
12965
+ return;
12966
+ }
12967
+ case "DoubleQuoted":
12968
+ case "LocaleString":
12969
+ for (const part of node.parts)
12970
+ callback(part);
12971
+ return;
12972
+ case "ParameterExpansion":
12973
+ if (node.index)
12974
+ callback(node.index);
12975
+ if (node.operation)
12976
+ callback(node.operation);
12977
+ return;
12978
+ case "Default":
12979
+ case "Remove":
12980
+ case "Transform":
12981
+ callback(node.operand);
12982
+ return;
12983
+ case "CaseModification":
12984
+ if (node.operand)
12985
+ callback(node.operand);
12986
+ return;
12987
+ case "Replace":
12988
+ callback(node.pattern);
12989
+ callback(node.replacement);
12990
+ return;
12991
+ case "Slice":
12992
+ callback(node.offset);
12993
+ if (node.length)
12994
+ callback(node.length);
12995
+ return;
12996
+ case "Assignment": {
12997
+ const index = node.index;
12998
+ if (index)
12999
+ callback(index);
13000
+ callback(node.value);
13001
+ return;
13002
+ }
13003
+ case "ArrayValue":
13004
+ for (const element of node.elements)
13005
+ callback(element);
13006
+ return;
13007
+ case "Redirect":
13008
+ case "HereString":
13009
+ if (node.descriptor)
13010
+ callback(node.descriptor);
13011
+ if (node.target)
13012
+ callback(node.target);
13013
+ return;
13014
+ case "HereDoc":
13015
+ if (node.descriptor)
13016
+ callback(node.descriptor);
13017
+ if (node.delimiter)
13018
+ callback(node.delimiter);
13019
+ callback(node.body);
13020
+ return;
13021
+ case "CommandExpansion":
13022
+ case "ProcessSubstitution":
13023
+ case "ArithmeticCommandExpansion": {
13024
+ const script = node.script;
13025
+ if (script)
13026
+ callback(script);
13027
+ return;
13028
+ }
13029
+ case "ArithmeticExpansion":
13030
+ case "ArithmeticCommand":
13031
+ case "ArithmeticGroup":
13032
+ case "TestCommand":
13033
+ case "TestGroup": {
13034
+ const expression = node.expression;
13035
+ if (expression)
13036
+ callback(expression);
13037
+ return;
13038
+ }
13039
+ case "ArithmeticBinary":
13040
+ case "TestBinary":
13041
+ callback(node.left);
13042
+ callback(node.right);
13043
+ return;
13044
+ case "ArithmeticUnary":
13045
+ case "TestUnary":
13046
+ callback(node.operand);
13047
+ return;
13048
+ case "ArithmeticTernary":
13049
+ callback(node.test);
13050
+ callback(node.consequent);
13051
+ callback(node.alternate);
13052
+ return;
13053
+ case "TestLogical":
13054
+ for (const operand of node.operands)
13055
+ callback(operand);
13056
+ return;
13057
+ case "TestNot":
13058
+ for (const negation of node.negations)
13059
+ callback(negation);
13060
+ callback(node.operand);
13061
+ return;
13062
+ case "Literal":
13063
+ case "SingleQuoted":
13064
+ case "AnsiCQuoted":
13065
+ case "SimpleExpansion":
13066
+ case "Names":
13067
+ case "Unknown":
13068
+ case "FileDescriptor":
13069
+ case "FileDescriptorVariable":
13070
+ case "HereDocDelimiter":
13071
+ case "Time":
13072
+ case "Negation":
13073
+ return;
13074
+ default: {
13075
+ const exhaustive = node;
13076
+ throw new TypeError(`Unexpected syntax node: ${exhaustive}`);
13077
+ }
13078
+ }
13079
+ }
12868
13080
  var init_traversal = __esm({
12869
13081
  "../../node_modules/.pnpm/unbash@6.0.1/node_modules/unbash/dist/traversal.js"() {
12870
13082
  }
@@ -19636,18 +19848,21 @@ var init_parser = __esm({
19636
19848
  function wordsOf(text) {
19637
19849
  return text.trim().split(/\s+/);
19638
19850
  }
19639
- function redirectedOnce(outputs, redirection) {
19851
+ function redirectedOnce(held, redirection, opened) {
19640
19852
  const { descriptor } = redirection;
19641
19853
  if (descriptor?.type === "FileDescriptorVariable")
19642
- return outputs;
19854
+ return held;
19855
+ if (toFileWithErrors(redirection))
19856
+ return pointing(pointing(held, 1, opened), 2, opened);
19643
19857
  const number = descriptor?.value ?? (ONTO_STDOUT.has(redirection.operator) ? 1 : 0);
19644
19858
  const source = duplicates(redirection) ? Number.parseInt(redirection.target?.value ?? "", 10) : Number.NaN;
19645
- return pointing(outputs, number, outputs.get(source) ?? false);
19859
+ return pointing(held, number, held.get(source) ?? opened);
19646
19860
  }
19647
19861
  function shellScripts(command, [name, ...args], outputs) {
19648
19862
  if (!SHELLS.has(name) || !args.every((arg) => arg.startsWith("-")))
19649
19863
  return NOTHING;
19650
- return command.redirects.flatMap((redirect) => redirect.type === "HereDoc" ? walk(parse(redirect.body.text), outputs) : NOTHING);
19864
+ const script = stdinHereDocument(command.redirects);
19865
+ return script === void 0 ? NOTHING : walk(parse(script.body.text), outputs);
19651
19866
  }
19652
19867
  function simple(command, inherited) {
19653
19868
  if (command.name === void 0)
@@ -19656,6 +19871,14 @@ function simple(command, inherited) {
19656
19871
  const words = [command.name.value, ...command.suffix.filter(isWord).map((word) => word.value)];
19657
19872
  return [{ words, piped: outputs.get(1) ?? false }, ...shellScripts(command, words, outputs)];
19658
19873
  }
19874
+ function childrenOf(node) {
19875
+ const children = [];
19876
+ forEachChild(node, (child) => {
19877
+ if (ENTERED[child.type])
19878
+ children.push(child);
19879
+ });
19880
+ return children;
19881
+ }
19659
19882
  function pipeline(node, outputs) {
19660
19883
  const last = node.commands.length - 1;
19661
19884
  return node.commands.flatMap((stage, at) => walk(stage, at < last ? pointing(outputs, 1, true) : outputs));
@@ -19665,9 +19888,11 @@ function walk(node, outputs) {
19665
19888
  return simple(node, outputs);
19666
19889
  if (node.type === "Pipeline")
19667
19890
  return pipeline(node, outputs);
19891
+ if (node.type === "Coproc")
19892
+ return walk(node.body, pointing(outputs, 1, true));
19668
19893
  if (node.type === "Redirected")
19669
19894
  return walk(node.command, redirected(outputs, node.redirects));
19670
- return childrenOf(node).flatMap((child) => child === void 0 ? NOTHING : walk(child, outputs));
19895
+ return childrenOf(node).flatMap((child) => walk(child, outputs));
19671
19896
  }
19672
19897
  function simpleCommands(text) {
19673
19898
  const known = READ.get(text);
@@ -19737,7 +19962,7 @@ function runsBy(reading) {
19737
19962
  return words.join(" ") !== "" && runs(command, words, scripts, SCRIPT_CHAIN_DEPTH, reading);
19738
19963
  };
19739
19964
  }
19740
- var SCRIPT_CHAIN_DEPTH, ASSIGNMENT, launcher, runsNext, YARN_FOREACH, COMMAND_PREFIXES, LAUNCHERS, SCRIPT_INVOCATIONS, opensAt, opensWith, namedOnLine, NOTHING, SHELLS, isWord, UNPIPED, ONTO_STDOUT, duplicates, pointing, redirected, commandsOf, CHILDREN, childrenOf, READ, isOneOf, headsOf, lastStageHeadsOf, anywhere, asCommand, commandRuns, shellReading;
19965
+ var SCRIPT_CHAIN_DEPTH, ASSIGNMENT, launcher, runsNext, YARN_FOREACH, COMMAND_PREFIXES, LAUNCHERS, SCRIPT_INVOCATIONS, opensAt, opensWith, namedOnLine, NOTHING, SHELLS, isWord, UNPIPED, ONTO_STDOUT, duplicates, pointing, DESCRIPTOR_OR_CLOSE, toFileWithErrors, redirected, NO_HERE_DOCUMENTS, stdinHereDocument, ENTERED, READ, isOneOf, headsOf, lastStageHeadsOf, anywhere, asCommand, commandRuns, shellReading;
19741
19966
  var init_commandRuns = __esm({
19742
19967
  "../core/dist/parse/commandRuns.js"() {
19743
19968
  "use strict";
@@ -19837,22 +20062,79 @@ var init_commandRuns = __esm({
19837
20062
  UNPIPED = /* @__PURE__ */ new Map();
19838
20063
  ONTO_STDOUT = /* @__PURE__ */ new Set([">", ">>", ">|", ">&", "&>", "&>>"]);
19839
20064
  duplicates = (redirection) => redirection.operator === ">&" || redirection.operator === "<&";
19840
- pointing = (outputs, descriptor, piped) => new Map([...outputs, [descriptor, piped]]);
19841
- redirected = (outputs, redirections) => redirections.reduce(redirectedOnce, outputs);
19842
- commandsOf = (node) => node.commands.map((statement) => statement.command);
19843
- CHILDREN = {
19844
- Script: commandsOf,
19845
- CompoundList: commandsOf,
19846
- AndOr: (node) => node.commands,
19847
- Function: (node) => [node.body],
19848
- If: (node) => [node.clause, node.then, ...node.elif.flatMap((elif) => [elif.clause, elif.then]), node.else],
19849
- For: (node) => [node.body],
19850
- While: (node) => [node.clause, node.body],
19851
- Subshell: (node) => [node.body],
19852
- BraceGroup: (node) => [node.body],
19853
- Case: (node) => node.items.map((item) => item.body)
20065
+ pointing = (held, descriptor, value) => new Map([...held, [descriptor, value]]);
20066
+ DESCRIPTOR_OR_CLOSE = /^(\d+-?|-)$/;
20067
+ toFileWithErrors = (redirection) => redirection.operator === "&>" || redirection.operator === "&>>" || redirection.operator === ">&" && redirection.descriptor === void 0 && !DESCRIPTOR_OR_CLOSE.test(redirection.target?.value ?? "");
20068
+ redirected = (outputs, redirections) => redirections.reduce((held, redirection) => redirectedOnce(held, redirection, false), outputs);
20069
+ NO_HERE_DOCUMENTS = /* @__PURE__ */ new Map();
20070
+ stdinHereDocument = (redirections) => redirections.reduce((held, redirection) => redirectedOnce(held, redirection, redirection.type === "HereDoc" ? redirection : void 0), NO_HERE_DOCUMENTS).get(0);
20071
+ ENTERED = {
20072
+ Script: true,
20073
+ Statement: true,
20074
+ CompoundList: true,
20075
+ AndOr: true,
20076
+ Pipeline: true,
20077
+ Command: true,
20078
+ Redirected: true,
20079
+ If: true,
20080
+ Elif: true,
20081
+ For: true,
20082
+ ArithmeticFor: true,
20083
+ Select: true,
20084
+ While: true,
20085
+ Case: true,
20086
+ CaseItem: true,
20087
+ Subshell: true,
20088
+ BraceGroup: true,
20089
+ Function: true,
20090
+ Coproc: true,
20091
+ Time: false,
20092
+ Negation: false,
20093
+ Word: false,
20094
+ Literal: false,
20095
+ Glob: false,
20096
+ SingleQuoted: false,
20097
+ DoubleQuoted: false,
20098
+ AnsiCQuoted: false,
20099
+ LocaleString: false,
20100
+ SimpleExpansion: false,
20101
+ ParameterExpansion: false,
20102
+ CommandExpansion: false,
20103
+ ArithmeticExpansion: false,
20104
+ ProcessSubstitution: false,
20105
+ ExtendedGlob: false,
20106
+ BraceExpansion: false,
20107
+ Assignment: false,
20108
+ ArrayValue: false,
20109
+ Redirect: false,
20110
+ HereString: false,
20111
+ HereDoc: false,
20112
+ FileDescriptor: false,
20113
+ FileDescriptorVariable: false,
20114
+ HereDocDelimiter: false,
20115
+ HereDocBody: false,
20116
+ ArithmeticBinary: false,
20117
+ ArithmeticUnary: false,
20118
+ ArithmeticTernary: false,
20119
+ ArithmeticGroup: false,
20120
+ ArithmeticWord: false,
20121
+ ArithmeticCommandExpansion: false,
20122
+ ArithmeticCommand: false,
20123
+ TestCommand: false,
20124
+ TestUnary: false,
20125
+ TestBinary: false,
20126
+ TestLogical: false,
20127
+ TestNot: false,
20128
+ TestGroup: false,
20129
+ Default: false,
20130
+ Remove: false,
20131
+ Replace: false,
20132
+ Slice: false,
20133
+ CaseModification: false,
20134
+ Transform: false,
20135
+ Names: false,
20136
+ Unknown: false
19854
20137
  };
19855
- childrenOf = (node) => CHILDREN[node.type]?.(node) ?? [];
19856
20138
  READ = /* @__PURE__ */ new Map();
19857
20139
  isOneOf = (words, word) => words?.some((each) => each === word) === true;
19858
20140
  headsOf = (command) => simpleCommands(command).map(({ words }) => words);
@@ -29100,6 +29382,7 @@ var init_composers = __esm({
29100
29382
  // ../core/dist/index.js
29101
29383
  var init_dist3 = __esm({
29102
29384
  "../core/dist/index.js"() {
29385
+ "use strict";
29103
29386
  init_scenarios();
29104
29387
  init_corpusCounts();
29105
29388
  init_evidenceReconciliation();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-controller",
3
- "version": "0.1.93",
3
+ "version": "0.1.95",
4
4
  "description": "Reconcile the behaviour your scenarios name against the evidence that actually ran — the deterministic `balance` CLI.",
5
5
  "keywords": [
6
6
  "reconciliation",
@@ -25,7 +25,7 @@
25
25
  "esbuild": "0.28.1",
26
26
  "fast-xml-parser": "^5.11.2",
27
27
  "yaml": "^2.9.0",
28
- "@3f-consulting/spec-controller-core": "0.1.93"
28
+ "@3f-consulting/spec-controller-core": "0.1.95"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"