spec-controller 0.1.82 → 0.1.84

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 +54 -15
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -12872,24 +12872,29 @@ function pastQuote(text, from, quote) {
12872
12872
  const end = text.indexOf(quote, from);
12873
12873
  return end === -1 ? text.length : end + 1;
12874
12874
  }
12875
- function pastBalanced(text, from, open, close) {
12875
+ function pastQuoted(text, at) {
12876
+ const char = text.charAt(at);
12877
+ if (char === "\\")
12878
+ return at + 2;
12879
+ if (char === "'" || char === "`")
12880
+ return pastQuote(text, at + 1, char);
12881
+ return char === '"' ? doubleQuoted(text, at + 1)[1] : void 0;
12882
+ }
12883
+ function pastBalanced(text, from, open, close, commands = false) {
12876
12884
  let depth = 1;
12877
12885
  let at = from;
12886
+ const bodies = [];
12887
+ const pastPart = commands ? pastCommandPart : pastNoCommand;
12878
12888
  while (at < text.length && depth > 0) {
12879
12889
  const char = text[at];
12880
- if (char === "\\")
12881
- at += 2;
12882
- else if (char === "'" || char === "`")
12883
- at = pastQuote(text, at + 1, char);
12884
- else if (char === '"')
12885
- at = doubleQuoted(text, at + 1)[1];
12886
- else {
12890
+ const skipped = pastPart(text, at, bodies) ?? pastQuoted(text, at);
12891
+ if (skipped === void 0) {
12887
12892
  if (char === open)
12888
12893
  depth += 1;
12889
12894
  if (char === close)
12890
12895
  depth -= 1;
12891
- at += 1;
12892
12896
  }
12897
+ at = skipped ?? at + 1;
12893
12898
  }
12894
12899
  return Math.min(at, text.length);
12895
12900
  }
@@ -12900,7 +12905,8 @@ function expansionEnd(text, at, openers) {
12900
12905
  if (opener === void 0)
12901
12906
  return void 0;
12902
12907
  const open = opener.slice(-1);
12903
- return pastBalanced(text, at + opener.length, open, open === "{" ? "}" : ")");
12908
+ const commands = open === "(" && !text.startsWith("$((", at);
12909
+ return pastBalanced(text, at + opener.length, open, open === "{" ? "}" : ")", commands);
12904
12910
  }
12905
12911
  function doubleQuotedPart(text, at) {
12906
12912
  const char = text.charAt(at);
@@ -12934,10 +12940,42 @@ function nextToken(text, at, word) {
12934
12940
  }
12935
12941
  return plain(text, at);
12936
12942
  }
12937
- function pastBody(text, from, { delimiter, tabs }) {
12938
- const lines = text.slice(from).split("\n");
12939
- const last = lines.findIndex((line) => (tabs ? line.replace(/^\t*/, "") : line) === delimiter);
12940
- return last === -1 ? text.length : from + lines.slice(0, last + 1).join("\n").length;
12943
+ function pastBody(text, from, { delimiter, tabs }, inSubstitution = false) {
12944
+ let start = from;
12945
+ for (const line of text.slice(from).split("\n")) {
12946
+ const stripped = tabs ? line.replace(/^\t*/, "") : line;
12947
+ if (stripped === delimiter)
12948
+ return start + line.length;
12949
+ if (inSubstitution && stripped.startsWith(delimiter) && stripped.includes(")", delimiter.length)) {
12950
+ return start + line.length - stripped.length + delimiter.length;
12951
+ }
12952
+ start += line.length + 1;
12953
+ }
12954
+ return text.length;
12955
+ }
12956
+ function delimiterWord(text, from) {
12957
+ let at = from;
12958
+ while (blank(text, at, void 0) !== void 0)
12959
+ at += 1;
12960
+ let word = "";
12961
+ for (let token = nextToken(text, at, word); token.kind === "part"; token = nextToken(text, at, word)) {
12962
+ word += token.value;
12963
+ at = token.end;
12964
+ }
12965
+ return [word, at];
12966
+ }
12967
+ function pastCommandPart(text, at, bodies) {
12968
+ if (text.startsWith("$((", at))
12969
+ return pastBalanced(text, at + 2, "(", ")");
12970
+ if (text[at] === "\n" && bodies.length > 0) {
12971
+ return bodies.splice(0).reduce((from, body) => pastBody(text, from, body, true), at + 1);
12972
+ }
12973
+ const token = redirection(text, at, void 0);
12974
+ if (token?.kind !== "heredoc")
12975
+ return token?.end;
12976
+ const [delimiter, end] = delimiterWord(text, token.end);
12977
+ bodies.push({ delimiter, tabs: token.tabs, quoted: false });
12978
+ return end;
12941
12979
  }
12942
12980
  function commandList() {
12943
12981
  const commands = [];
@@ -13069,7 +13107,7 @@ function runsBy(reading) {
13069
13107
  return words.join(" ") !== "" && runs(command, words, scripts, SCRIPT_CHAIN_DEPTH, reading);
13070
13108
  };
13071
13109
  }
13072
- var SCRIPT_CHAIN_DEPTH, ASSIGNMENT, launcher, runsNext, YARN_FOREACH, SHELL_WORDS, COMMAND_PREFIXES, LAUNCHERS, SCRIPT_INVOCATIONS, opensAt, opensWith, namedOnLine, pastAssignments, JOINED_LINE, SEPARATORS, REDIRECTION, FILE_DESCRIPTOR, PLAIN, ESCAPED_IN_DOUBLE_QUOTES, EXPANSIONS, EXPANSIONS_IN_DOUBLE_QUOTES, part, blank, comment, escaped, singleQuoted, doubleQuotedWord, expansion, redirection, separator, READS, isOneOf, headsOf, lastStageHeadsOf, anywhere, asCommand, commandRuns, shellReading;
13110
+ var SCRIPT_CHAIN_DEPTH, ASSIGNMENT, launcher, runsNext, YARN_FOREACH, SHELL_WORDS, COMMAND_PREFIXES, LAUNCHERS, SCRIPT_INVOCATIONS, opensAt, opensWith, namedOnLine, pastAssignments, JOINED_LINE, SEPARATORS, REDIRECTION, FILE_DESCRIPTOR, PLAIN, ESCAPED_IN_DOUBLE_QUOTES, EXPANSIONS, EXPANSIONS_IN_DOUBLE_QUOTES, pastNoCommand, part, blank, comment, escaped, singleQuoted, doubleQuotedWord, expansion, redirection, separator, READS, isOneOf, headsOf, lastStageHeadsOf, anywhere, asCommand, commandRuns, shellReading;
13073
13111
  var init_commandRuns = __esm({
13074
13112
  "../core/dist/parse/commandRuns.js"() {
13075
13113
  "use strict";
@@ -13173,6 +13211,7 @@ var init_commandRuns = __esm({
13173
13211
  ESCAPED_IN_DOUBLE_QUOTES = '"\\$`';
13174
13212
  EXPANSIONS = ["$(", "${", "<(", ">("];
13175
13213
  EXPANSIONS_IN_DOUBLE_QUOTES = ["$(", "${"];
13214
+ pastNoCommand = () => void 0;
13176
13215
  part = (value, quoted, end) => ({ kind: "part", value, quoted, end });
13177
13216
  blank = (text, at) => {
13178
13217
  const char = text.charAt(at);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-controller",
3
- "version": "0.1.82",
3
+ "version": "0.1.84",
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.82"
28
+ "@3f-consulting/spec-controller-core": "0.1.84"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"