@featurevisor/core 3.10.0 → 4.0.0

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 (299) hide show
  1. package/README.md +20 -2
  2. package/lib/assess-distribution/index.js +6 -2
  3. package/lib/assess-distribution/index.js.map +1 -1
  4. package/lib/benchmark/index.d.ts +1 -1
  5. package/lib/benchmark/index.js +15 -10
  6. package/lib/benchmark/index.js.map +1 -1
  7. package/lib/builder/applyContextToConditions.d.ts +5 -4
  8. package/lib/builder/applyContextToConditions.js +84 -89
  9. package/lib/builder/applyContextToConditions.js.map +1 -1
  10. package/lib/builder/applyContextToDatafile.d.ts +2 -2
  11. package/lib/builder/applyContextToDatafile.js +45 -149
  12. package/lib/builder/applyContextToDatafile.js.map +1 -1
  13. package/lib/builder/applyContextToSegments.d.ts +6 -4
  14. package/lib/builder/applyContextToSegments.js +9 -98
  15. package/lib/builder/applyContextToSegments.js.map +1 -1
  16. package/lib/builder/buildDatafile.d.ts +15 -6
  17. package/lib/builder/buildDatafile.js +320 -220
  18. package/lib/builder/buildDatafile.js.map +1 -1
  19. package/lib/builder/buildProject.d.ts +2 -1
  20. package/lib/builder/buildProject.js +36 -37
  21. package/lib/builder/buildProject.js.map +1 -1
  22. package/lib/builder/buildRuntimeDatafiles.js +2 -0
  23. package/lib/builder/buildRuntimeDatafiles.js.map +1 -1
  24. package/lib/builder/environments.d.ts +3 -0
  25. package/lib/builder/environments.js +26 -0
  26. package/lib/builder/environments.js.map +1 -0
  27. package/lib/builder/hashes.d.ts +5 -5
  28. package/lib/builder/hashes.js +82 -100
  29. package/lib/builder/hashes.js.map +1 -1
  30. package/lib/builder/inflate.d.ts +7 -0
  31. package/lib/builder/inflate.js +26 -0
  32. package/lib/builder/inflate.js.map +1 -0
  33. package/lib/builder/mutateVariables.d.ts +6 -2
  34. package/lib/builder/mutateVariables.js +26 -18
  35. package/lib/builder/mutateVariables.js.map +1 -1
  36. package/lib/builder/mutationEntries.d.ts +5 -0
  37. package/lib/builder/mutationEntries.js +23 -0
  38. package/lib/builder/mutationEntries.js.map +1 -0
  39. package/lib/builder/mutator.d.ts +4 -2
  40. package/lib/builder/mutator.js +20 -209
  41. package/lib/builder/mutator.js.map +1 -1
  42. package/lib/builder/traffic.d.ts +2 -4
  43. package/lib/builder/traffic.js +48 -19
  44. package/lib/builder/traffic.js.map +1 -1
  45. package/lib/builder/variableOverrideProgram.d.ts +9 -0
  46. package/lib/builder/variableOverrideProgram.js +147 -0
  47. package/lib/builder/variableOverrideProgram.js.map +1 -0
  48. package/lib/catalog.d.ts +23 -0
  49. package/lib/catalog.js +117 -0
  50. package/lib/catalog.js.map +1 -0
  51. package/lib/cli/cli.d.ts +2 -0
  52. package/lib/cli/cli.js +38 -13
  53. package/lib/cli/cli.js.map +1 -1
  54. package/lib/cli/options.js +78 -17
  55. package/lib/cli/options.js.map +1 -1
  56. package/lib/cli/plugins.js +13 -3
  57. package/lib/cli/plugins.js.map +1 -1
  58. package/lib/cli/suggestions.d.ts +4 -0
  59. package/lib/cli/suggestions.js +61 -0
  60. package/lib/cli/suggestions.js.map +1 -0
  61. package/lib/config/allowedConditions.d.ts +9 -0
  62. package/lib/config/allowedConditions.js +44 -0
  63. package/lib/config/allowedConditions.js.map +1 -0
  64. package/lib/config/index.d.ts +1 -0
  65. package/lib/config/index.js +1 -0
  66. package/lib/config/index.js.map +1 -1
  67. package/lib/config/projectConfig.d.ts +9 -3
  68. package/lib/config/projectConfig.js +68 -11
  69. package/lib/config/projectConfig.js.map +1 -1
  70. package/lib/config/removedGroups.d.ts +5 -0
  71. package/lib/config/removedGroups.js +62 -0
  72. package/lib/config/removedGroups.js.map +1 -0
  73. package/lib/datasource/adapter.d.ts +10 -1
  74. package/lib/datasource/adapter.js.map +1 -1
  75. package/lib/datasource/attributeNamespaces.d.ts +14 -0
  76. package/lib/datasource/attributeNamespaces.js +70 -0
  77. package/lib/datasource/attributeNamespaces.js.map +1 -0
  78. package/lib/datasource/composition.d.ts +5 -0
  79. package/lib/datasource/composition.js +19 -0
  80. package/lib/datasource/composition.js.map +1 -0
  81. package/lib/datasource/conditions.d.ts +20 -0
  82. package/lib/datasource/conditions.js +113 -0
  83. package/lib/datasource/conditions.js.map +1 -0
  84. package/lib/datasource/datasource.d.ts +18 -12
  85. package/lib/datasource/datasource.js +137 -76
  86. package/lib/datasource/datasource.js.map +1 -1
  87. package/lib/datasource/dependencies.d.ts +52 -0
  88. package/lib/datasource/dependencies.js +347 -0
  89. package/lib/datasource/dependencies.js.map +1 -0
  90. package/lib/datasource/filesystemAdapter.d.ts +31 -1
  91. package/lib/datasource/filesystemAdapter.js +581 -99
  92. package/lib/datasource/filesystemAdapter.js.map +1 -1
  93. package/lib/datasource/index.d.ts +3 -0
  94. package/lib/datasource/index.js +3 -0
  95. package/lib/datasource/index.js.map +1 -1
  96. package/lib/datasource/parseError.d.ts +5 -0
  97. package/lib/datasource/parseError.js +68 -0
  98. package/lib/datasource/parseError.js.map +1 -0
  99. package/lib/datasource/testSpecs.d.ts +4 -0
  100. package/lib/datasource/testSpecs.js +40 -0
  101. package/lib/datasource/testSpecs.js.map +1 -0
  102. package/lib/diff/compare.d.ts +9 -0
  103. package/lib/diff/compare.js +31 -0
  104. package/lib/diff/compare.js.map +1 -0
  105. package/lib/diff/details.d.ts +11 -0
  106. package/lib/diff/details.js +210 -0
  107. package/lib/diff/details.js.map +1 -0
  108. package/lib/diff/git.d.ts +28 -0
  109. package/lib/diff/git.js +195 -0
  110. package/lib/diff/git.js.map +1 -0
  111. package/lib/diff/index.d.ts +36 -0
  112. package/lib/diff/index.js +229 -0
  113. package/lib/diff/index.js.map +1 -0
  114. package/lib/error.d.ts +1 -0
  115. package/lib/error.js +6 -0
  116. package/lib/error.js.map +1 -1
  117. package/lib/evaluate/explain.d.ts +15 -2
  118. package/lib/evaluate/explain.js +273 -79
  119. package/lib/evaluate/explain.js.map +1 -1
  120. package/lib/evaluate/index.js +128 -17
  121. package/lib/evaluate/index.js.map +1 -1
  122. package/lib/evaluate/probeConditions.d.ts +30 -0
  123. package/lib/evaluate/probeConditions.js +165 -0
  124. package/lib/evaluate/probeConditions.js.map +1 -0
  125. package/lib/evaluate/validateExplanation.js +175 -16
  126. package/lib/evaluate/validateExplanation.js.map +1 -1
  127. package/lib/find-duplicate-segments/findDuplicateSegments.js +20 -1
  128. package/lib/find-duplicate-segments/findDuplicateSegments.js.map +1 -1
  129. package/lib/find-usage/index.d.ts +14 -1
  130. package/lib/find-usage/index.js +359 -155
  131. package/lib/find-usage/index.js.map +1 -1
  132. package/lib/generate-code/typescript.js +156 -60
  133. package/lib/generate-code/typescript.js.map +1 -1
  134. package/lib/info/index.js +11 -5
  135. package/lib/info/index.js.map +1 -1
  136. package/lib/init/index.js +234 -28
  137. package/lib/init/index.js.map +1 -1
  138. package/lib/linter/attributeSchema.d.ts +6 -11
  139. package/lib/linter/attributeSchema.js +59 -53
  140. package/lib/linter/attributeSchema.js.map +1 -1
  141. package/lib/linter/comparisonOperators.d.ts +18 -0
  142. package/lib/linter/comparisonOperators.js +82 -0
  143. package/lib/linter/comparisonOperators.js.map +1 -0
  144. package/lib/linter/composedOverrideSchema.d.ts +5 -0
  145. package/lib/linter/composedOverrideSchema.js +243 -0
  146. package/lib/linter/composedOverrideSchema.js.map +1 -0
  147. package/lib/linter/compositionWarnings.d.ts +8 -0
  148. package/lib/linter/compositionWarnings.js +212 -0
  149. package/lib/linter/compositionWarnings.js.map +1 -0
  150. package/lib/linter/conditionKinds.d.ts +12 -0
  151. package/lib/linter/conditionKinds.js +129 -0
  152. package/lib/linter/conditionKinds.js.map +1 -0
  153. package/lib/linter/conditionSchema.d.ts +8 -2
  154. package/lib/linter/conditionSchema.js +253 -52
  155. package/lib/linter/conditionSchema.js.map +1 -1
  156. package/lib/linter/contextWarnings.d.ts +13 -0
  157. package/lib/linter/contextWarnings.js +241 -0
  158. package/lib/linter/contextWarnings.js.map +1 -0
  159. package/lib/linter/definitionReferences.d.ts +39 -0
  160. package/lib/linter/definitionReferences.js +234 -0
  161. package/lib/linter/definitionReferences.js.map +1 -0
  162. package/lib/linter/dependencyDepth.d.ts +14 -0
  163. package/lib/linter/dependencyDepth.js +106 -0
  164. package/lib/linter/dependencyDepth.js.map +1 -0
  165. package/lib/linter/diagnostics.d.ts +129 -0
  166. package/lib/linter/diagnostics.js +84 -0
  167. package/lib/linter/diagnostics.js.map +1 -0
  168. package/lib/linter/featureSchema.d.ts +189 -72
  169. package/lib/linter/featureSchema.js +385 -210
  170. package/lib/linter/featureSchema.js.map +1 -1
  171. package/lib/linter/lintProject.d.ts +4 -1
  172. package/lib/linter/lintProject.js +449 -143
  173. package/lib/linter/lintProject.js.map +1 -1
  174. package/lib/linter/mutationNotation.d.ts +7 -1
  175. package/lib/linter/mutationNotation.js +40 -20
  176. package/lib/linter/mutationNotation.js.map +1 -1
  177. package/lib/linter/mutationOrder.d.ts +6 -0
  178. package/lib/linter/mutationOrder.js +105 -0
  179. package/lib/linter/mutationOrder.js.map +1 -0
  180. package/lib/linter/mutationResultPaths.d.ts +4 -0
  181. package/lib/linter/mutationResultPaths.js +131 -0
  182. package/lib/linter/mutationResultPaths.js.map +1 -0
  183. package/lib/linter/mutationSchema.d.ts +3 -0
  184. package/lib/linter/mutationSchema.js +32 -0
  185. package/lib/linter/mutationSchema.js.map +1 -0
  186. package/lib/linter/printError.d.ts +3 -0
  187. package/lib/linter/printError.js +38 -25
  188. package/lib/linter/printError.js.map +1 -1
  189. package/lib/linter/regexSafety.d.ts +19 -0
  190. package/lib/linter/regexSafety.js +307 -0
  191. package/lib/linter/regexSafety.js.map +1 -0
  192. package/lib/linter/removedConditionFields.d.ts +10 -0
  193. package/lib/linter/removedConditionFields.js +47 -0
  194. package/lib/linter/removedConditionFields.js.map +1 -0
  195. package/lib/linter/requiredFeaturesSchema.d.ts +2 -2
  196. package/lib/linter/requiredFeaturesSchema.js +32 -28
  197. package/lib/linter/requiredFeaturesSchema.js.map +1 -1
  198. package/lib/linter/requiredVariableCost.d.ts +5 -0
  199. package/lib/linter/requiredVariableCost.js +60 -0
  200. package/lib/linter/requiredVariableCost.js.map +1 -0
  201. package/lib/linter/requiredVariablesSchema.d.ts +13 -0
  202. package/lib/linter/requiredVariablesSchema.js +498 -0
  203. package/lib/linter/requiredVariablesSchema.js.map +1 -0
  204. package/lib/linter/reservedNames.d.ts +12 -0
  205. package/lib/linter/reservedNames.js +52 -0
  206. package/lib/linter/reservedNames.js.map +1 -0
  207. package/lib/linter/schema.d.ts +12 -15
  208. package/lib/linter/schema.js +108 -26
  209. package/lib/linter/schema.js.map +1 -1
  210. package/lib/linter/schemaFormats.d.ts +35 -0
  211. package/lib/linter/schemaFormats.js +66 -0
  212. package/lib/linter/schemaFormats.js.map +1 -0
  213. package/lib/linter/segmentSchema.d.ts +11 -1
  214. package/lib/linter/segmentSchema.js +12 -2
  215. package/lib/linter/segmentSchema.js.map +1 -1
  216. package/lib/linter/testSchema.d.ts +394 -2
  217. package/lib/linter/testSchema.js +565 -34
  218. package/lib/linter/testSchema.js.map +1 -1
  219. package/lib/linter/variableSchema.d.ts +60 -43
  220. package/lib/linter/variableSchema.js +459 -60
  221. package/lib/linter/variableSchema.js.map +1 -1
  222. package/lib/linter/zodHelpers.d.ts +8 -1
  223. package/lib/linter/zodHelpers.js +9 -1
  224. package/lib/linter/zodHelpers.js.map +1 -1
  225. package/lib/list/index.js +384 -66
  226. package/lib/list/index.js.map +1 -1
  227. package/lib/list/matrix.d.ts +2 -2
  228. package/lib/list/matrix.js +60 -39
  229. package/lib/list/matrix.js.map +1 -1
  230. package/lib/list/scenarios.d.ts +8 -0
  231. package/lib/list/scenarios.js +84 -0
  232. package/lib/list/scenarios.js.map +1 -0
  233. package/lib/promoter/index.d.ts +1 -1
  234. package/lib/promoter/index.js +469 -210
  235. package/lib/promoter/index.js.map +1 -1
  236. package/lib/sets.js +14 -5
  237. package/lib/sets.js.map +1 -1
  238. package/lib/tester/checks.d.ts +12 -0
  239. package/lib/tester/checks.js +418 -0
  240. package/lib/tester/checks.js.map +1 -0
  241. package/lib/tester/coverage.d.ts +16 -0
  242. package/lib/tester/coverage.js +64 -0
  243. package/lib/tester/coverage.js.map +1 -0
  244. package/lib/tester/datafileKey.d.ts +4 -0
  245. package/lib/tester/datafileKey.js +18 -0
  246. package/lib/tester/datafileKey.js.map +1 -0
  247. package/lib/tester/diagnostics.d.ts +5 -0
  248. package/lib/tester/diagnostics.js +32 -0
  249. package/lib/tester/diagnostics.js.map +1 -0
  250. package/lib/tester/index.d.ts +2 -0
  251. package/lib/tester/printTestResult.d.ts +3 -2
  252. package/lib/tester/printTestResult.js +53 -8
  253. package/lib/tester/printTestResult.js.map +1 -1
  254. package/lib/tester/provenance.d.ts +21 -0
  255. package/lib/tester/provenance.js +98 -0
  256. package/lib/tester/provenance.js.map +1 -0
  257. package/lib/tester/report.d.ts +78 -0
  258. package/lib/tester/report.js +246 -0
  259. package/lib/tester/report.js.map +1 -0
  260. package/lib/tester/segments.d.ts +23 -0
  261. package/lib/tester/segments.js +103 -0
  262. package/lib/tester/segments.js.map +1 -0
  263. package/lib/tester/testFeature.d.ts +2 -0
  264. package/lib/tester/testFeature.js +17 -8
  265. package/lib/tester/testFeature.js.map +1 -1
  266. package/lib/tester/testProject.d.ts +15 -3
  267. package/lib/tester/testProject.js +198 -83
  268. package/lib/tester/testProject.js.map +1 -1
  269. package/lib/tester/testSegment.d.ts +2 -4
  270. package/lib/tester/testSegment.js +89 -7
  271. package/lib/tester/testSegment.js.map +1 -1
  272. package/lib/tester/testVariable.d.ts +2 -2
  273. package/lib/tester/testVariable.js +195 -24
  274. package/lib/tester/testVariable.js.map +1 -1
  275. package/lib/utils/conditionReferences.d.ts +5 -0
  276. package/lib/utils/conditionReferences.js +30 -0
  277. package/lib/utils/conditionReferences.js.map +1 -0
  278. package/lib/utils/extractKeys.d.ts +7 -3
  279. package/lib/utils/extractKeys.js +32 -113
  280. package/lib/utils/extractKeys.js.map +1 -1
  281. package/lib/utils/git.d.ts +7 -2
  282. package/lib/utils/git.js +87 -72
  283. package/lib/utils/git.js.map +1 -1
  284. package/package.json +11 -8
  285. package/lib/builder/getFeatureRanges.d.ts +0 -11
  286. package/lib/builder/getFeatureRanges.js +0 -70
  287. package/lib/builder/getFeatureRanges.js.map +0 -1
  288. package/lib/datasource/requiredFeatures.d.ts +0 -14
  289. package/lib/datasource/requiredFeatures.js +0 -75
  290. package/lib/datasource/requiredFeatures.js.map +0 -1
  291. package/lib/linter/checkCircularDependency.d.ts +0 -3
  292. package/lib/linter/checkCircularDependency.js +0 -8
  293. package/lib/linter/checkCircularDependency.js.map +0 -1
  294. package/lib/linter/checkPercentageExceedingSlot.d.ts +0 -3
  295. package/lib/linter/checkPercentageExceedingSlot.js +0 -45
  296. package/lib/linter/checkPercentageExceedingSlot.js.map +0 -1
  297. package/lib/linter/groupSchema.d.ts +0 -11
  298. package/lib/linter/groupSchema.js +0 -31
  299. package/lib/linter/groupSchema.js.map +0 -1
package/lib/list/index.js CHANGED
@@ -1,32 +1,97 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.listPlugin = void 0;
4
37
  exports.listEntities = listEntities;
5
38
  exports.formatDatafileSize = formatDatafileSize;
6
39
  exports.listProject = listProject;
40
+ const path = __importStar(require("path"));
7
41
  const validation_1 = require("../cli/validation");
8
42
  const error_1 = require("../error");
9
43
  const matrix_1 = require("./matrix");
10
44
  const sets_1 = require("../sets");
11
45
  const targeting_1 = require("../targeting");
12
46
  const cliFormat_1 = require("../tester/cliFormat");
47
+ const checks_1 = require("../tester/checks");
48
+ const conditions_1 = require("../datasource/conditions");
49
+ const scenarios_1 = require("./scenarios");
13
50
  async function getEntitiesWithTests(deps) {
14
51
  const { datasource } = deps;
15
52
  const featuresWithTests = new Set();
16
53
  const segmentsWithTests = new Set();
17
54
  const variablesWithTests = new Set();
18
- const tests = await datasource.listTests();
19
- for (const testKey of tests) {
20
- const test = await datasource.readTest(testKey);
21
- if (test.feature) {
55
+ const tests = await (0, scenarios_1.listTestSpecs)(datasource);
56
+ for (const test of tests) {
57
+ if ("feature" in test) {
22
58
  featuresWithTests.add(test.feature);
23
59
  }
24
- if (test.segment) {
60
+ if ("segment" in test) {
25
61
  segmentsWithTests.add(test.segment);
26
62
  }
27
- if (test.variable) {
63
+ if ("variable" in test) {
28
64
  variablesWithTests.add(test.variable);
29
65
  }
66
+ if ("variable" in test || "scenario" in test) {
67
+ const owner = "variable" in test ? test.variable : undefined;
68
+ const addReference = (reference) => {
69
+ if (reference.segment) {
70
+ segmentsWithTests.add(reference.segment);
71
+ }
72
+ else if (reference.feature) {
73
+ featuresWithTests.add(reference.feature);
74
+ }
75
+ else if (reference.variable || owner) {
76
+ variablesWithTests.add(reference.variable || owner);
77
+ }
78
+ };
79
+ for (let assertionIndex = 0; assertionIndex < test.assertions.length; assertionIndex++) {
80
+ const authoredAssertion = test.assertions[assertionIndex];
81
+ if (authoredAssertion.matrix &&
82
+ (0, matrix_1.getMatrixCombinations)(authoredAssertion.matrix).length === 0) {
83
+ throw new Error("Cannot collect test coverage from an empty assertion matrix.");
84
+ }
85
+ const assertions = (0, matrix_1.getVariableAssertionsFromMatrix)(assertionIndex, authoredAssertion);
86
+ for (const assertion of assertions) {
87
+ for (const expectation of [assertion, ...(assertion.children || [])]) {
88
+ if (expectation.checks === undefined)
89
+ continue;
90
+ (0, checks_1.getCheckReferences)(expectation.checks, owner).forEach(addReference);
91
+ }
92
+ }
93
+ }
94
+ }
30
95
  }
31
96
  return {
32
97
  features: Array.from(featuresWithTests),
@@ -46,10 +111,85 @@ function getBooleanOptionValue(value, fallback = false) {
46
111
  function matchesBooleanOption(option, value, defaultOption) {
47
112
  return (getBooleanOptionValue(value, defaultOption) === getBooleanOptionValue(option, defaultOption));
48
113
  }
114
+ function getTestSource(deps, storageKey, entityType) {
115
+ const { datasource, projectConfig, rootDirectoryPath } = deps;
116
+ if (entityType === "scenario" && datasource.getScenarioSourcePath) {
117
+ return path
118
+ .relative(rootDirectoryPath, datasource.getScenarioSourcePath(storageKey))
119
+ .split(path.sep)
120
+ .join("/");
121
+ }
122
+ if (entityType !== "scenario" && datasource.getTestSourcePath) {
123
+ return path
124
+ .relative(rootDirectoryPath, datasource.getTestSourcePath(storageKey))
125
+ .split(path.sep)
126
+ .join("/");
127
+ }
128
+ const namespaceCharacter = projectConfig.namespaceCharacter;
129
+ const fallbackKey = storageKey.endsWith(".spec") ? storageKey : `${storageKey}.spec`;
130
+ const segments = namespaceCharacter ? fallbackKey.split(namespaceCharacter) : [fallbackKey];
131
+ if (segments.length > 1 &&
132
+ ["spec", "feature", "segment"].includes(segments[segments.length - 1])) {
133
+ const suffix = segments.pop();
134
+ segments[segments.length - 1] = `${segments[segments.length - 1]}.${suffix}`;
135
+ }
136
+ const parser = projectConfig.parser;
137
+ const extension = typeof datasource.getExtension === "function"
138
+ ? datasource.getExtension()
139
+ : typeof parser === "string"
140
+ ? parser
141
+ : parser.extension;
142
+ const directory = projectConfig.testsDirectoryPath;
143
+ const extensionSuffix = extension ? `.${extension}` : "";
144
+ const source = path.relative(rootDirectoryPath, `${path.join(directory, ...segments)}${extensionSuffix}`);
145
+ return source.split(path.sep).join("/");
146
+ }
147
+ function getTestCaseMetadata(set, entityType, storageKey, assertion, assertionIndex, matrixIndex, matrixValues) {
148
+ return {
149
+ id: JSON.stringify([set, entityType, storageKey, assertion.key ?? assertionIndex, matrixIndex]),
150
+ assertionIndex,
151
+ matrixIndex,
152
+ matrixValues,
153
+ };
154
+ }
155
+ function throwTestCaseNotFound(caseId) {
156
+ throw new error_1.FeaturevisorCLIError(`No test case matched --case=${caseId}.`, {
157
+ code: "test_case_not_found",
158
+ details: { case: caseId },
159
+ });
160
+ }
161
+ /**
162
+ * Feature assertions renamed `sticky` to `stickyFeatures`. Lint names the
163
+ * replacement. Running specs must not silently ignore the old field either.
164
+ */
165
+ function assertNoRemovedSticky(assertions, key) {
166
+ const own = (value) => !!value && typeof value === "object" && Object.prototype.hasOwnProperty.call(value, "sticky");
167
+ const found = assertions.some((assertion) => own(assertion) ||
168
+ (Array.isArray(assertion?.children) && assertion.children.some((child) => own(child))));
169
+ if (found) {
170
+ throw new error_1.FeaturevisorCLIError(`Test "${key}" uses \`sticky\`. Replace it with \`stickyFeatures\`, then run lint.`, { code: "removed_test_field", details: { test: key, field: "sticky" } });
171
+ }
172
+ }
173
+ /** A feature's rules for one environment, or its direct list when environments are not configured. */
174
+ function getRulesIn(feature, environment) {
175
+ const rules = feature.rules;
176
+ if (Array.isArray(rules))
177
+ return environment === false ? rules : [];
178
+ if (environment === false || !rules || typeof rules !== "object")
179
+ return [];
180
+ return rules[environment] || [];
181
+ }
49
182
  async function listEntities(deps, entityType) {
50
183
  const { datasource, options } = deps;
184
+ if (options.case !== undefined &&
185
+ (typeof options.case !== "string" || options.case.length === 0)) {
186
+ throw new error_1.FeaturevisorCLIError("Pass one nonempty case ID with --case.", {
187
+ code: "invalid_test_case",
188
+ });
189
+ }
51
190
  const result = [];
52
191
  let entityKeys = [];
192
+ let testSpecs = [];
53
193
  if (entityType === "feature") {
54
194
  entityKeys = await datasource.listFeatures();
55
195
  }
@@ -59,14 +199,15 @@ async function listEntities(deps, entityType) {
59
199
  else if (entityType === "attribute") {
60
200
  entityKeys = await datasource.listAttributes();
61
201
  }
62
- else if (entityType === "group") {
63
- entityKeys = await datasource.listGroups();
64
- }
65
202
  else if (entityType === "schema") {
66
203
  entityKeys = await datasource.listSchemas();
67
204
  }
68
205
  else if (entityType === "test") {
69
- entityKeys = await datasource.listTests();
206
+ testSpecs = await (0, scenarios_1.listTestSpecs)(datasource);
207
+ entityKeys = testSpecs.map((test) => test.key);
208
+ }
209
+ else if (entityType === "scenario") {
210
+ entityKeys = await datasource.listScenarios();
70
211
  }
71
212
  else if (entityType === "target") {
72
213
  entityKeys = await datasource.listTargets();
@@ -75,6 +216,9 @@ async function listEntities(deps, entityType) {
75
216
  entityKeys = await datasource.listVariables();
76
217
  }
77
218
  if (entityKeys.length === 0) {
219
+ if (entityType === "test" && typeof options.case === "string") {
220
+ throwTestCaseNotFound(options.case);
221
+ }
78
222
  return result;
79
223
  }
80
224
  let entitiesWithTests = {
@@ -89,10 +233,10 @@ async function listEntities(deps, entityType) {
89
233
  ? (0, validation_1.parseRegexOption)("--description", options.description, "i")
90
234
  : undefined;
91
235
  const keyRegex = options.keyPattern
92
- ? (0, validation_1.parseRegexOption)("--keyPattern", options.keyPattern, "i")
236
+ ? (0, validation_1.parseRegexOption)("--key-pattern", options.keyPattern, "i")
93
237
  : undefined;
94
238
  const assertionRegex = options.assertionPattern
95
- ? (0, validation_1.parseRegexOption)("--assertionPattern", options.assertionPattern, "i")
239
+ ? (0, validation_1.parseRegexOption)("--assertion-pattern", options.assertionPattern, "i")
96
240
  : undefined;
97
241
  if (entityType === "feature" && options.target) {
98
242
  const targets = await (0, targeting_1.resolveTargets)(datasource, options.target, { defaultToAll: false });
@@ -109,7 +253,7 @@ async function listEntities(deps, entityType) {
109
253
  entitiesWithTests = await getEntitiesWithTests(deps);
110
254
  entitiesWithTestsInitialized = true;
111
255
  }
112
- for (const key of entityKeys) {
256
+ for (const [entityIndex, key] of entityKeys.entries()) {
113
257
  let entity = {};
114
258
  if (entityType === "feature") {
115
259
  entity = (await datasource.readFeature(key));
@@ -120,14 +264,14 @@ async function listEntities(deps, entityType) {
120
264
  else if (entityType === "attribute") {
121
265
  entity = (await datasource.readAttribute(key));
122
266
  }
123
- else if (entityType === "group") {
124
- entity = (await datasource.readGroup(key));
125
- }
126
267
  else if (entityType === "schema") {
127
268
  entity = (await datasource.readSchema(key));
128
269
  }
129
270
  else if (entityType === "test") {
130
- entity = (await datasource.readTest(key));
271
+ entity = testSpecs[entityIndex];
272
+ }
273
+ else if (entityType === "scenario") {
274
+ entity = (await datasource.readScenario(key));
131
275
  }
132
276
  else if (entityType === "target") {
133
277
  entity = (await datasource.readTarget(key));
@@ -162,22 +306,19 @@ async function listEntities(deps, entityType) {
162
306
  if (targetFeatureKeys && !targetFeatureKeys.has(key)) {
163
307
  continue;
164
308
  }
165
- // --disabledIn=<environment>
166
- if (options.disabledIn && parsedFeature.rules && parsedFeature.rules[options.disabledIn]) {
167
- const disabledInEnvironment = parsedFeature.rules[options.disabledIn].every((rule) => {
168
- return rule.percentage === 0;
169
- });
170
- if (!disabledInEnvironment) {
309
+ // --disabled, or --disabled-in=<environment>: every rule is at 0%, or there are none
310
+ const disabledIn = options.disabled ? false : options.disabledIn;
311
+ if (typeof disabledIn !== "undefined") {
312
+ const rules = getRulesIn(parsedFeature, disabledIn);
313
+ if (rules.some((rule) => rule.percentage > 0)) {
171
314
  continue;
172
315
  }
173
316
  }
174
- // --enabledIn=<environment>
175
- if (options.enabledIn) {
176
- const rules = parsedFeature.rules && parsedFeature.rules[options.enabledIn];
177
- const enabledInEnvironment = Boolean(rules?.some((rule) => {
178
- return rule.percentage > 0;
179
- }));
180
- if (!enabledInEnvironment) {
317
+ // --enabled, or --enabled-in=<environment>: a rule is above 0%
318
+ const enabledIn = options.enabled ? false : options.enabledIn;
319
+ if (typeof enabledIn !== "undefined") {
320
+ const rules = getRulesIn(parsedFeature, enabledIn);
321
+ if (!rules.some((rule) => rule.percentage > 0)) {
181
322
  continue;
182
323
  }
183
324
  }
@@ -297,13 +438,24 @@ async function listEntities(deps, entityType) {
297
438
  let test = entity;
298
439
  const testEntityKey = test.feature ||
299
440
  test.segment ||
300
- test.variable;
441
+ test.variable ||
442
+ test.scenario;
301
443
  const testEntityType = test.segment
302
444
  ? "segment"
303
445
  : test.variable
304
446
  ? "variable"
305
- : "feature";
447
+ : test.scenario
448
+ ? "scenario"
449
+ : "feature";
306
450
  let testAssertions = test.assertions;
451
+ const set = typeof options.set === "string"
452
+ ? options.set
453
+ : options.set === null
454
+ ? null
455
+ : typeof datasource.getSet === "function" && typeof datasource.getSet() === "string"
456
+ ? datasource.getSet()
457
+ : null;
458
+ const applyMatrix = options.applyMatrix || typeof options.case === "string";
307
459
  if (typeof options.promotable !== "undefined" &&
308
460
  !matchesBooleanOption(options.promotable, test.promotable, true)) {
309
461
  continue;
@@ -312,12 +464,22 @@ async function listEntities(deps, entityType) {
312
464
  if (options.entityType && options.entityType !== testEntityType) {
313
465
  continue;
314
466
  }
467
+ if (testEntityType === "feature") {
468
+ assertNoRemovedSticky(testAssertions, key);
469
+ }
315
470
  // --apply-matrix
316
- if (options.applyMatrix) {
471
+ if (applyMatrix) {
317
472
  if (testEntityType === "feature") {
318
473
  let assertionsAfterApplyingMatrix = [];
319
474
  for (let aIndex = 0; aIndex < testAssertions.length; aIndex++) {
320
- const processedAssertions = (0, matrix_1.getFeatureAssertionsFromMatrix)(aIndex, testAssertions[aIndex]);
475
+ const authoredAssertion = testAssertions[aIndex];
476
+ const matrixValues = authoredAssertion.matrix
477
+ ? (0, matrix_1.getMatrixCombinations)(authoredAssertion.matrix)
478
+ : [{}];
479
+ const processedAssertions = (0, matrix_1.getFeatureAssertionsFromMatrix)(aIndex, authoredAssertion).map((assertion, matrixIndex) => ({
480
+ ...assertion,
481
+ _case: getTestCaseMetadata(set, testEntityType, key, authoredAssertion, aIndex, authoredAssertion.matrix ? matrixIndex : null, matrixValues[matrixIndex]),
482
+ }));
321
483
  assertionsAfterApplyingMatrix =
322
484
  assertionsAfterApplyingMatrix.concat(processedAssertions);
323
485
  }
@@ -326,20 +488,68 @@ async function listEntities(deps, entityType) {
326
488
  else if (testEntityType === "segment") {
327
489
  let assertionsAfterApplyingMatrix = [];
328
490
  for (let aIndex = 0; aIndex < testAssertions.length; aIndex++) {
329
- const processedAssertions = (0, matrix_1.getSegmentAssertionsFromMatrix)(aIndex, testAssertions[aIndex]);
491
+ const authoredAssertion = testAssertions[aIndex];
492
+ const matrixValues = authoredAssertion.matrix
493
+ ? (0, matrix_1.getMatrixCombinations)(authoredAssertion.matrix)
494
+ : [{}];
495
+ const processedAssertions = (0, matrix_1.getSegmentAssertionsFromMatrix)(aIndex, authoredAssertion).map((assertion, matrixIndex) => ({
496
+ ...assertion,
497
+ _case: getTestCaseMetadata(set, testEntityType, key, authoredAssertion, aIndex, authoredAssertion.matrix ? matrixIndex : null, matrixValues[matrixIndex]),
498
+ }));
330
499
  assertionsAfterApplyingMatrix =
331
500
  assertionsAfterApplyingMatrix.concat(processedAssertions);
332
501
  }
333
502
  testAssertions = assertionsAfterApplyingMatrix;
334
503
  }
335
- else if (testEntityType === "variable") {
504
+ else if (testEntityType === "variable" || testEntityType === "scenario") {
336
505
  let assertionsAfterApplyingMatrix = [];
337
506
  for (let aIndex = 0; aIndex < testAssertions.length; aIndex++) {
338
- assertionsAfterApplyingMatrix = assertionsAfterApplyingMatrix.concat((0, matrix_1.getVariableAssertionsFromMatrix)(aIndex, testAssertions[aIndex]));
507
+ const authoredAssertion = testAssertions[aIndex];
508
+ const matrixValues = authoredAssertion.matrix
509
+ ? (0, matrix_1.getMatrixCombinations)(authoredAssertion.matrix)
510
+ : [{}];
511
+ assertionsAfterApplyingMatrix = assertionsAfterApplyingMatrix.concat((0, matrix_1.getVariableAssertionsFromMatrix)(aIndex, authoredAssertion, testEntityType === "scenario" ? "scenario" : "assertion").map((assertion, matrixIndex) => ({
512
+ ...assertion,
513
+ _case: getTestCaseMetadata(set, testEntityType, key, authoredAssertion, aIndex, authoredAssertion.matrix ? matrixIndex : null, matrixValues[matrixIndex]),
514
+ })));
339
515
  }
340
516
  testAssertions = assertionsAfterApplyingMatrix;
341
517
  }
342
518
  }
519
+ if (typeof options.case === "string") {
520
+ testAssertions = testAssertions.filter((assertion) => assertion._case?.id === options.case);
521
+ if (testAssertions.length === 0)
522
+ continue;
523
+ }
524
+ if (!options.executionMetadata) {
525
+ delete test._test;
526
+ testAssertions = testAssertions.map((assertion) => {
527
+ const withoutMetadata = { ...assertion };
528
+ delete withoutMetadata._case;
529
+ return withoutMetadata;
530
+ });
531
+ }
532
+ else {
533
+ test._test = {
534
+ source: getTestSource(deps, key, testEntityType),
535
+ set,
536
+ entityType: testEntityType,
537
+ };
538
+ // Child descriptions are documentation for readers. Native runners do not receive them.
539
+ testAssertions = testAssertions.map((assertion) => {
540
+ const children = assertion.children;
541
+ if (!Array.isArray(children))
542
+ return assertion;
543
+ return {
544
+ ...assertion,
545
+ children: children.map((child) => {
546
+ const withoutDescription = { ...child };
547
+ delete withoutDescription.description;
548
+ return withoutDescription;
549
+ }),
550
+ };
551
+ });
552
+ }
343
553
  // --keyPattern=<pattern>
344
554
  if (keyRegex) {
345
555
  if (!keyRegex.test(testEntityKey)) {
@@ -358,13 +568,64 @@ async function listEntities(deps, entityType) {
358
568
  continue;
359
569
  }
360
570
  }
361
- entity.assertions = testAssertions;
571
+ entity.assertions =
572
+ testAssertions;
573
+ if (applyMatrix &&
574
+ ("variable" in test ||
575
+ "scenario" in test ||
576
+ (options.executionProtocol && "segment" in test))) {
577
+ const keys = new Set();
578
+ if ("segment" in test)
579
+ keys.add(test.segment);
580
+ const owner = "variable" in test ? test.variable : undefined;
581
+ for (const assertion of test.assertions) {
582
+ for (const expectation of [
583
+ assertion,
584
+ ...("children" in assertion ? assertion.children || [] : []),
585
+ ]) {
586
+ if (!("checks" in expectation))
587
+ continue;
588
+ if (!expectation.checks)
589
+ continue;
590
+ for (const reference of (0, checks_1.getCheckReferences)(expectation.checks, owner)) {
591
+ if (reference.segment)
592
+ keys.add(reference.segment);
593
+ }
594
+ }
595
+ }
596
+ if (keys.size) {
597
+ const definitions = [];
598
+ const pending = Array.from(keys);
599
+ for (let index = 0; index < pending.length; index++) {
600
+ const segment = pending[index];
601
+ if (!(await datasource.segmentExists(segment)))
602
+ throw new Error(`Unknown segment "${segment}"`);
603
+ const definition = await datasource.readSegment(segment);
604
+ definitions.push([
605
+ segment,
606
+ options.executionProtocol
607
+ ? { ...definition, conditions: (0, conditions_1.compileConditions)(definition.conditions) }
608
+ : definition,
609
+ ]);
610
+ (0, conditions_1.walkConditionLeaves)(definition.conditions, (leaf) => {
611
+ if (typeof leaf === "string" && !keys.has(leaf)) {
612
+ keys.add(leaf);
613
+ pending.push(leaf);
614
+ }
615
+ });
616
+ }
617
+ test._segments = Object.fromEntries(definitions);
618
+ }
619
+ }
362
620
  }
363
621
  result.push({
364
622
  ...entity,
365
623
  key,
366
624
  });
367
625
  }
626
+ if (entityType === "test" && typeof options.case === "string" && result.length === 0) {
627
+ throwTestCaseNotFound(options.case);
628
+ }
368
629
  return result;
369
630
  }
370
631
  function ucfirst(str) {
@@ -372,7 +633,14 @@ function ucfirst(str) {
372
633
  }
373
634
  function printResult({ result, entityType, options }) {
374
635
  if (options.json) {
375
- console.log(options.pretty ? JSON.stringify(result, null, 2) : JSON.stringify(result));
636
+ const output = options.executionProtocol
637
+ ? {
638
+ kind: "featurevisor.test-execution",
639
+ schemaVersion: 1,
640
+ tests: result,
641
+ }
642
+ : result;
643
+ console.log(options.pretty ? JSON.stringify(output, null, 2) : JSON.stringify(output));
376
644
  return;
377
645
  }
378
646
  if (result.length === 0) {
@@ -383,10 +651,11 @@ function printResult({ result, entityType, options }) {
383
651
  console.log(cliFormat_1.CLI_FORMAT_BOLD, `${ucfirst(entityType)}s`);
384
652
  console.log("");
385
653
  for (const item of result) {
386
- console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${item.key}`);
654
+ const composition = entityType === "variable" && item.compose ? " (composed)" : "";
655
+ console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${item.key}${composition}`);
387
656
  }
388
657
  console.log("");
389
- console.log(cliFormat_1.CLI_FORMAT_GREEN, `Found ${result.length} ${entityType}s.`);
658
+ console.log(cliFormat_1.CLI_FORMAT_GREEN, `Found ${result.length} ${entityType}${result.length === 1 ? "" : "s"}.`);
390
659
  }
391
660
  function getDatafileSizeParts(size) {
392
661
  if (size < 1024) {
@@ -461,37 +730,60 @@ function printDatafiles({ result, options }) {
461
730
  previousDirectory = directory;
462
731
  }
463
732
  console.log("");
464
- console.log(cliFormat_1.CLI_FORMAT_GREEN, `Found ${sortedResult.length} datafiles.`);
733
+ console.log(cliFormat_1.CLI_FORMAT_GREEN, `Found ${sortedResult.length} datafile${sortedResult.length === 1 ? "" : "s"}.`);
465
734
  }
466
735
  const listSelectors = [
467
736
  "datafiles",
468
737
  "features",
469
738
  "segments",
470
- "groups",
471
739
  "schemas",
472
740
  "attributes",
473
741
  "tests",
474
742
  "targets",
475
743
  "variables",
744
+ "scenarios",
476
745
  ];
477
- function assertListOptions(options) {
746
+ function toFlag(option) {
747
+ return `--${option.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;
748
+ }
749
+ function assertListEnvironmentOptions(options, environments) {
750
+ for (const option of ["enabledIn", "disabledIn"]) {
751
+ const environment = options[option];
752
+ if (typeof environment === "undefined")
753
+ continue;
754
+ if (!Array.isArray(environments)) {
755
+ const replacement = option === "enabledIn" ? "--enabled" : "--disabled";
756
+ throw new error_1.FeaturevisorCLIError(`This project does not configure environments. Use ${replacement} instead of ${toFlag(option)}.`, { code: "invalid_environment", details: { option, environment, available: [] } });
757
+ }
758
+ if (!environments.includes(environment)) {
759
+ throw new error_1.FeaturevisorCLIError(`Unknown environment "${environment}" for ${toFlag(option)}. Available environments: ${environments.join(", ")}.`, { code: "invalid_environment", details: { option, environment, available: environments } });
760
+ }
761
+ }
762
+ for (const option of ["enabled", "disabled"]) {
763
+ if (typeof options[option] === "undefined" || !Array.isArray(environments))
764
+ continue;
765
+ throw new error_1.FeaturevisorCLIError(`This project configures environments. Use ${toFlag(`${option}In`)}=<environment> instead of --${option}.`, { code: "invalid_environment", details: { option, available: environments } });
766
+ }
767
+ }
768
+ function assertListOptions(options, projectConfig) {
478
769
  const selected = listSelectors.filter((selector) => options[selector]);
479
770
  if (selected.length !== 1) {
480
771
  throw new error_1.FeaturevisorCLIError(selected.length === 0
481
- ? "Select one entity type to list."
772
+ ? `Select one entity type to list: ${listSelectors.map((selector) => `--${selector}`).join(", ")}.`
482
773
  : `Select only one entity type to list. Received: ${selected.join(", ")}.`, {
483
774
  code: "invalid_list_selection",
484
775
  details: { selected },
485
776
  });
486
777
  }
487
778
  const opposingOptions = [
779
+ ["enabled", "disabled"],
488
780
  ["withTests", "withoutTests"],
489
781
  ["withVariables", "withoutVariables"],
490
782
  ["withVariations", "withoutVariations"],
491
783
  ];
492
784
  for (const [positive, negative] of opposingOptions) {
493
785
  if (options[positive] && options[negative]) {
494
- throw new error_1.FeaturevisorCLIError(`Options --${positive} and --${negative} cannot be combined.`, {
786
+ throw new error_1.FeaturevisorCLIError(`Options ${toFlag(positive)} and ${toFlag(negative)} cannot be combined.`, {
495
787
  code: "conflicting_cli_options",
496
788
  details: { options: [positive, negative] },
497
789
  });
@@ -499,7 +791,9 @@ function assertListOptions(options) {
499
791
  }
500
792
  const selector = selected[0];
501
793
  const featureOnly = [
794
+ "disabled",
502
795
  "disabledIn",
796
+ "enabled",
503
797
  "enabledIn",
504
798
  "variable",
505
799
  "variation",
@@ -508,22 +802,32 @@ function assertListOptions(options) {
508
802
  "withVariations",
509
803
  "withoutVariations",
510
804
  ];
511
- const testOnly = ["entityType", "applyMatrix", "assertionPattern"];
805
+ const testOnly = [
806
+ "entityType",
807
+ "applyMatrix",
808
+ "assertionPattern",
809
+ "executionMetadata",
810
+ "executionProtocol",
811
+ "case",
812
+ ];
512
813
  for (const option of ["target", "tag"]) {
513
814
  if (!["features", "variables"].includes(selector) && typeof options[option] !== "undefined") {
514
- throw new error_1.FeaturevisorCLIError(`Option --${option} can only be used with --features or --variables.`, { code: "incompatible_cli_options", details: { selector, option } });
815
+ throw new error_1.FeaturevisorCLIError(`Option ${toFlag(option)} can only be used with --features or --variables.`, { code: "incompatible_cli_options", details: { selector, option } });
515
816
  }
516
817
  }
818
+ if (selector === "features") {
819
+ assertListEnvironmentOptions(options, projectConfig?.environments);
820
+ }
517
821
  if (selector !== "features") {
518
822
  const unsupported = featureOnly.filter((option) => typeof options[option] !== "undefined");
519
823
  if (unsupported.length > 0) {
520
- throw new error_1.FeaturevisorCLIError(`Option --${unsupported[0]} can only be used with --features.`, { code: "incompatible_cli_options", details: { selector, option: unsupported[0] } });
824
+ throw new error_1.FeaturevisorCLIError(`Option ${toFlag(unsupported[0])} can only be used with --features.`, { code: "incompatible_cli_options", details: { selector, option: unsupported[0] } });
521
825
  }
522
826
  }
523
827
  if (selector !== "tests") {
524
828
  const unsupported = testOnly.filter((option) => typeof options[option] !== "undefined");
525
829
  if (unsupported.length > 0) {
526
- throw new error_1.FeaturevisorCLIError(`Option --${unsupported[0]} can only be used with --tests.`, {
830
+ throw new error_1.FeaturevisorCLIError(`Option ${toFlag(unsupported[0])} can only be used with --tests.`, {
527
831
  code: "incompatible_cli_options",
528
832
  details: { selector, option: unsupported[0] },
529
833
  });
@@ -531,7 +835,7 @@ function assertListOptions(options) {
531
835
  }
532
836
  if (!["features", "segments", "variables"].includes(selector) &&
533
837
  (options.withTests || options.withoutTests)) {
534
- throw new error_1.FeaturevisorCLIError("Options --withTests and --withoutTests can only be used with --features, --segments, or --variables.", { code: "incompatible_cli_options", details: { selector } });
838
+ throw new error_1.FeaturevisorCLIError("Options --with-tests and --without-tests can only be used with --features, --segments, or --variables.", { code: "incompatible_cli_options", details: { selector } });
535
839
  }
536
840
  if (!["features", "segments", "attributes", "variables"].includes(selector) &&
537
841
  typeof options.archived !== "undefined") {
@@ -541,22 +845,35 @@ function assertListOptions(options) {
541
845
  const entityFilters = ["keyPattern", "description", "promotable"];
542
846
  const unsupported = entityFilters.find((option) => typeof options[option] !== "undefined");
543
847
  if (unsupported) {
544
- throw new error_1.FeaturevisorCLIError(`Option --${unsupported} cannot be used with --datafiles.`, {
848
+ throw new error_1.FeaturevisorCLIError(`Option ${toFlag(unsupported)} cannot be used with --datafiles.`, {
545
849
  code: "incompatible_cli_options",
546
850
  details: { selector, option: unsupported },
547
851
  });
548
852
  }
549
853
  }
550
854
  if (selector === "tests" && typeof options.description !== "undefined") {
551
- throw new error_1.FeaturevisorCLIError("Option --description cannot be used with --tests. Use --assertionPattern instead.", {
855
+ throw new error_1.FeaturevisorCLIError("Option --description cannot be used with --tests. Use --assertion-pattern instead.", {
552
856
  code: "incompatible_cli_options",
553
857
  details: { selector, option: "description" },
554
858
  });
555
859
  }
556
860
  }
861
+ function getExecutionOptions(options) {
862
+ return options.executionProtocol
863
+ ? { ...options, json: true, applyMatrix: true, executionMetadata: true }
864
+ : options;
865
+ }
557
866
  async function listProject(deps) {
558
- const { options } = deps;
559
- assertListOptions(options);
867
+ const options = getExecutionOptions(deps.options);
868
+ deps = { ...deps, options };
869
+ assertListOptions(options, deps.projectConfig);
870
+ if (options.scenarios) {
871
+ return printResult({
872
+ result: await listEntities(deps, "scenario"),
873
+ entityType: "scenario",
874
+ options,
875
+ });
876
+ }
560
877
  // datafiles
561
878
  if (options.datafiles) {
562
879
  const result = await deps.datasource.listDatafiles();
@@ -580,11 +897,6 @@ async function listProject(deps) {
580
897
  options,
581
898
  });
582
899
  }
583
- // groups
584
- if (options.groups) {
585
- const result = await listEntities(deps, "group");
586
- return printResult({ result, entityType: "group", options });
587
- }
588
900
  // schemas
589
901
  if (options.schemas) {
590
902
  const result = await listEntities(deps, "schema");
@@ -624,23 +936,29 @@ async function listProject(deps) {
624
936
  }
625
937
  exports.listPlugin = {
626
938
  command: "list",
939
+ description: "List project entities or built datafiles",
627
940
  handler: async function ({ rootDirectoryPath, projectConfig, datasource, parsed }) {
628
- (0, sets_1.assertProjectSetJsonSelection)(projectConfig, parsed.set, parsed.json);
629
- const executions = await (0, sets_1.getProjectSetExecutions)(projectConfig, datasource, parsed.set);
941
+ const options = getExecutionOptions(parsed);
942
+ (0, sets_1.assertProjectSetJsonSelection)(projectConfig, options.set, options.json);
943
+ const executions = await (0, sets_1.getProjectSetExecutions)(projectConfig, datasource, options.set);
630
944
  for (const execution of executions) {
631
- (0, sets_1.printSetHeader)(projectConfig, execution.set, parsed.json);
945
+ (0, sets_1.printSetHeader)(projectConfig, execution.set, options.json);
632
946
  await listProject({
633
947
  rootDirectoryPath,
634
948
  projectConfig: execution.projectConfig,
635
949
  datasource: execution.datasource,
636
- options: parsed,
950
+ options,
637
951
  });
638
952
  }
639
953
  },
640
954
  examples: [
641
955
  {
642
- command: "list",
643
- description: "list entities",
956
+ command: "list --features",
957
+ description: "List features",
958
+ },
959
+ {
960
+ command: "list --tests",
961
+ description: "List tests",
644
962
  },
645
963
  ],
646
964
  };