spec-controller 0.1.77 → 0.1.79

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 +29 -23
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -12868,17 +12868,14 @@ var init_cucumber = __esm({
12868
12868
  function wordsOf(text) {
12869
12869
  return text.trim().split(/\s+/);
12870
12870
  }
12871
- function opensWith(words, phrase) {
12872
- return words.slice(0, wordsOf(phrase).length).join(" ") === phrase;
12873
- }
12874
12871
  function commandHeads(line) {
12875
- return line.split(COMMAND_SEPARATOR).map((command) => {
12872
+ return subshellsSpaced(line).split(COMMAND_SEPARATOR).map((command) => {
12876
12873
  const words = wordsOf(command);
12877
12874
  return words.slice(words.findIndex((word) => !ASSIGNMENT.test(word)));
12878
12875
  });
12879
12876
  }
12880
12877
  function handedOn(words) {
12881
- const prefix = LAUNCHERS.find((row) => opensWithWords(words, row.words));
12878
+ const prefix = LAUNCHERS.find((row) => opensWith(words, row.words));
12882
12879
  return prefix === void 0 ? void 0 : words.slice(prefix.words.length + prefix.operands);
12883
12880
  }
12884
12881
  function launched(words) {
@@ -12892,17 +12889,16 @@ function afterSelections(head, at, invocations) {
12892
12889
  return at;
12893
12890
  return afterSelections(head, at + (option === head[at] ? 1 + valueWords : 1), invocations);
12894
12891
  }
12895
- function fromRun(words) {
12896
- const at = words.indexOf("run");
12897
- return at === -1 ? [] : words.slice(at);
12898
- }
12899
12892
  function scriptsNamedBy(head) {
12900
12893
  const invocations = SCRIPT_INVOCATIONS.get(head[0]);
12901
12894
  if (invocations === void 0)
12902
12895
  return void 0;
12903
- const command = head.slice(afterSelections(head, 1, invocations));
12904
- const foreach = invocations.optionsUpToRun !== void 0 && opensWith(command, invocations.optionsUpToRun);
12905
- const [word, next] = foreach ? fromRun(command) : command;
12896
+ const each = invocations.eachWorkspace;
12897
+ if (each !== void 0 && opensWith(head, each.words)) {
12898
+ const [word2, next2] = head.slice(pastOptions(head, each.words.length, each));
12899
+ return isOneOf(invocations.runWords, word2) ? [next2] : void 0;
12900
+ }
12901
+ const [word, next] = head.slice(afterSelections(head, 1, invocations));
12906
12902
  if (isOneOf(invocations.runWords, word))
12907
12903
  return [next];
12908
12904
  return [isOneOf(invocations.testShortcuts, word) ? "test" : void 0, invocations.runsBareName ? word : void 0];
@@ -12914,7 +12910,7 @@ function pastOptions(words, at, prefix) {
12914
12910
  return pastOptions(words, at + (prefix.valued.includes(word) ? 2 : 1), prefix);
12915
12911
  }
12916
12912
  function passedOn(words) {
12917
- const prefix = COMMAND_PREFIXES.find((row) => opensWithWords(words, row.words));
12913
+ const prefix = COMMAND_PREFIXES.find((row) => opensWith(words, row.words));
12918
12914
  return prefix === void 0 ? void 0 : words.slice(pastOptions(words, prefix.words.length, prefix) + prefix.operands);
12919
12915
  }
12920
12916
  function runsScript(head, script) {
@@ -12923,26 +12919,31 @@ function runsScript(head, script) {
12923
12919
  const next = passedOn(head);
12924
12920
  return next !== void 0 && runsScript(next, script);
12925
12921
  }
12922
+ function headsOf(command) {
12923
+ return command.split(/\r?\n/).flatMap((line) => quotedSeparatorsBlanked(line).split(BACKGROUND).flatMap(commandHeads));
12924
+ }
12926
12925
  function commandInvokesScript(command, script) {
12927
- return command.split(/\r?\n/).some((line) => line.split(BACKGROUND).some((list) => commandHeads(list).some((head) => runsScript(head, script))));
12926
+ return headsOf(command).some((head) => runsScript(head, script));
12928
12927
  }
12929
12928
  function runs(command, invocation, scripts, depth, lineRuns) {
12930
12929
  if (command.split(/\r?\n/).some((line) => lineRuns(line, invocation)))
12931
12930
  return true;
12932
- if (depth === 0)
12931
+ const entries = Object.entries(scripts);
12932
+ if (depth === 0 || entries.length === 0)
12933
12933
  return false;
12934
- return Object.entries(scripts).some(([name, body]) => commandInvokesScript(command, name) && runs(body, invocation, scripts, depth - 1, lineRuns));
12934
+ const heads = headsOf(command);
12935
+ return entries.some(([name, body]) => heads.some((head) => runsScript(head, name)) && runs(body, invocation, scripts, depth - 1, lineRuns));
12935
12936
  }
12936
12937
  function runsBy(lineRuns) {
12937
12938
  return (command, invocation, scripts) => {
12938
- const text = wordsOf(invocation).join(" ");
12939
- return text !== "" && runs(command, text, scripts, SCRIPT_CHAIN_DEPTH, lineRuns);
12939
+ const words = wordsOf(invocation);
12940
+ return words.join(" ") !== "" && runs(command, words, scripts, SCRIPT_CHAIN_DEPTH, lineRuns);
12940
12941
  };
12941
12942
  }
12942
12943
  function finalStages(command) {
12943
12944
  return command.replace(/\\\r?\n/g, " ").split(/\r?\n/).map((line) => line.replace(UP_TO_LAST_PIPE, "")).join("\n");
12944
12945
  }
12945
- var SCRIPT_CHAIN_DEPTH, UP_TO_LAST_PIPE, COMMAND_SEPARATOR, BACKGROUND, ASSIGNMENT, launcher, runsNext, SHELL_WORDS, COMMAND_PREFIXES, LAUNCHERS, SCRIPT_INVOCATIONS, opensWithWords, anywhere, isOneOf, asCommand, commandRuns, commandRunsAsCommand, shellReading;
12946
+ var SCRIPT_CHAIN_DEPTH, UP_TO_LAST_PIPE, COMMAND_SEPARATOR, BACKGROUND, ASSIGNMENT, launcher, runsNext, YARN_FOREACH, SHELL_WORDS, COMMAND_PREFIXES, LAUNCHERS, SCRIPT_INVOCATIONS, opensAt, opensWith, anywhere, subshellsSpaced, isOneOf, QUOTED, quotedSeparatorsBlanked, asCommand, commandRuns, commandRunsAsCommand, shellReading;
12946
12947
  var init_commandRuns = __esm({
12947
12948
  "../core/dist/parse/commandRuns.js"() {
12948
12949
  "use strict";
@@ -12963,6 +12964,7 @@ var init_commandRuns = __esm({
12963
12964
  operands: 0,
12964
12965
  valued
12965
12966
  });
12967
+ YARN_FOREACH = runsNext(["yarn", "workspaces", "foreach"], "--from", "--include", "--exclude", "-j", "--jobs");
12966
12968
  SHELL_WORDS = ["!", "(", "{", "if", "then", "elif", "else", "while", "until", "do"];
12967
12969
  COMMAND_PREFIXES = [
12968
12970
  { ...launcher(["timeout"], "-k", "--kill-after", "-s", "--signal"), operands: 1 },
@@ -12973,7 +12975,7 @@ var init_commandRuns = __esm({
12973
12975
  launcher(["pnpm"]),
12974
12976
  runsNext(["yarn", "exec"]),
12975
12977
  runsNext(["yarn", "dlx"], "-p", "--package"),
12976
- runsNext(["yarn", "workspaces", "foreach"], "--from", "--include", "--exclude", "-j", "--jobs"),
12978
+ YARN_FOREACH,
12977
12979
  launcher(["yarn"]),
12978
12980
  launcher(["bunx"], "-p", "--package"),
12979
12981
  launcher(["python", "-m"]),
@@ -13029,16 +13031,20 @@ var init_commandRuns = __esm({
13029
13031
  runWords: ["run"],
13030
13032
  runsBareName: true,
13031
13033
  selections: /* @__PURE__ */ new Map([["workspace", 1]]),
13032
- optionsUpToRun: "workspaces foreach"
13034
+ eachWorkspace: YARN_FOREACH
13033
13035
  }
13034
13036
  ]
13035
13037
  ]);
13036
- opensWithWords = (words, prefix) => prefix.every((word, at) => words[at] === word);
13038
+ opensAt = (words, prefix, from) => prefix.every((word, at) => words[from + at] === word);
13039
+ opensWith = (words, prefix) => opensAt(words, prefix, 0);
13037
13040
  anywhere = (line, invocation) => {
13038
13041
  const words = wordsOf(line);
13039
- return words.some((_, at) => opensWith(words.slice(at), invocation));
13042
+ return words.some((_, at) => opensAt(words, invocation, at));
13040
13043
  };
13044
+ subshellsSpaced = (line) => line.replace(/(^|\s)\(/g, "$1( ").replace(/\)(?=[\s;&|]|$)/g, " )");
13041
13045
  isOneOf = (words, word) => words?.some((each) => each === word) === true;
13046
+ QUOTED = /"[^"]*"|'[^']*'/g;
13047
+ quotedSeparatorsBlanked = (line) => line.replace(QUOTED, (quoted) => quoted.replace(/[&;|]/g, " "));
13042
13048
  asCommand = (line, invocation) => commandHeads(line).some((head) => opensWith(launched(head), invocation));
13043
13049
  commandRuns = runsBy(anywhere);
13044
13050
  commandRunsAsCommand = runsBy(asCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-controller",
3
- "version": "0.1.77",
3
+ "version": "0.1.79",
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.77"
28
+ "@3f-consulting/spec-controller-core": "0.1.79"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"