featureparity 0.0.31 → 0.0.33
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.
- checksums.yaml +4 -4
- data/lib/fp/cli.rb +7 -1
- data/lib/fp/client.rb +5 -0
- data/lib/fp/commands/analyze.rb +2 -2
- data/lib/fp/commands/attach.rb +2 -2
- data/lib/fp/commands/attachments.rb +1 -1
- data/lib/fp/commands/check.rb +29 -0
- data/lib/fp/commands/ci_report.rb +1 -1
- data/lib/fp/commands/comment.rb +1 -1
- data/lib/fp/commands/comments.rb +1 -1
- data/lib/fp/commands/export.rb +2 -2
- data/lib/fp/commands/help.rb +66 -48
- data/lib/fp/commands/history.rb +2 -2
- data/lib/fp/commands/init.rb +42 -11
- data/lib/fp/commands/list.rb +3 -3
- data/lib/fp/commands/mark.rb +242 -50
- data/lib/fp/commands/matrix.rb +2 -2
- data/lib/fp/commands/profile.rb +2 -1
- data/lib/fp/commands/propose.rb +1 -1
- data/lib/fp/commands/propose_change.rb +1 -1
- data/lib/fp/commands/report.rb +2 -2
- data/lib/fp/commands/repos.rb +6 -6
- data/lib/fp/commands/setup.rb +2 -1
- data/lib/fp/commands/show.rb +10 -2
- data/lib/fp/commands/showroom.rb +6 -6
- data/lib/fp/commands/skill.rb +153 -0
- data/lib/fp/commands/surfaces.rb +5 -5
- data/lib/fp/commands/whoami.rb +34 -3
- data/lib/fp/commands.rb +1 -0
- data/lib/fp/config.rb +16 -6
- data/lib/fp/junit.rb +13 -0
- data/lib/fp/repo_detector.rb +17 -2
- data/lib/fp/version.rb +1 -1
- data/skills/fp/SKILL.md +31 -29
- data/skills/fp/references/cli.md +110 -75
- metadata +4 -4
data/lib/fp/commands/mark.rb
CHANGED
|
@@ -1,24 +1,52 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'digest'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'json'
|
|
6
|
+
require 'tmpdir'
|
|
7
|
+
|
|
3
8
|
module Fp
|
|
4
9
|
module Commands
|
|
5
|
-
# fp mark <slug> <file>:<line> [--surface a,b] [--type e2e]
|
|
10
|
+
# fp mark <slug> <file>:<line>|<file>::<test name> [more targets…] [--surface a,b] [--type e2e]
|
|
11
|
+
# [--comment '#'] [--dry-run]
|
|
12
|
+
#
|
|
13
|
+
# Insert an fp:<slug> marker directly above a test, in that file's own comment syntax
|
|
14
|
+
# and indentation (Fizzy #1786). Marking by hand across Ruby, JS, Swift and SQL meant a
|
|
15
|
+
# script per language and the occasional marker the scanner didn't recognise; this
|
|
16
|
+
# writes one the scanner reads back, and says which test it binds to. Purely local: no
|
|
17
|
+
# API key, no network.
|
|
6
18
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
19
|
+
# A test can be named instead of numbered (`file::test name`), and several targets can
|
|
20
|
+
# go in one call (Fizzy #1987). An agent that reads a file once and then marks three of
|
|
21
|
+
# its tests by line number put the second and third markers one and two lines too low,
|
|
22
|
+
# because each insert pushes everything below it down. A name is found in the file as
|
|
23
|
+
# it is when the command runs, and the line numbers given in one call all refer to the
|
|
24
|
+
# file before that call changes it.
|
|
25
|
+
#
|
|
26
|
+
# Separate calls are covered too (Fizzy #1991). fp remembers the marker lines it put
|
|
27
|
+
# into a file for a while, and while nothing else has edited that file, a line number
|
|
28
|
+
# that no longer points at a test is also read as it was numbered before those
|
|
29
|
+
# markers went in. So `fp mark a f:3`, `fp mark b f:7`, `fp mark c f:11`, all from one
|
|
30
|
+
# read of the file, land on the three tests that were on lines 3, 7 and 11.
|
|
12
31
|
class Mark < Base
|
|
13
32
|
help_summary 'Insert an fp:<slug> marker above a test, in the file\'s own comment syntax'
|
|
14
|
-
help_usage 'fp mark <slug> <file>:<line> [--surface a,b] [--type <test-type>] [--dry-run]'
|
|
33
|
+
help_usage 'fp mark <slug> <file>:<line>|<file>::<test name> [more targets…] [--surface a,b] [--type <test-type>] [--dry-run]'
|
|
15
34
|
help_flag :surface, 'Pin the marker to these surfaces (fp:slug@a,b); omit to use --surface at report time'
|
|
16
35
|
help_flag :type, 'Pin the kind of test (fp:slug@surface:e2e); needs --surface'
|
|
17
36
|
help_flag :comment, "Comment prefix to use when the extension isn't known (e.g. '#', '//', '--')"
|
|
18
37
|
help_flag :dry_run, 'Show the marker and where it would go; change nothing'
|
|
19
38
|
help_example 'fp mark academic_experience_required_fields spec/models/academic_experience_spec.rb:52'
|
|
39
|
+
help_example "fp mark locker_rejects_oversize tests/test_parcel_locker.py::test_rejects_oversize_parcel"
|
|
40
|
+
help_example "fp mark required_fields 'spec/models/user_spec.rb::requires an email' spec/models/user_spec.rb:40"
|
|
20
41
|
help_example 'fp mark checkout_flow e2e/checkout.spec.ts:10 --surface web --type e2e'
|
|
21
|
-
help_note "
|
|
42
|
+
help_note "A target is <file>:<line> (the `it`/`test`/`def test_` line) or <file>::<test name> (the name as the file declares it;\n" \
|
|
43
|
+
"a pytest id like file.py::TestClass::test_x works too). The marker goes directly above the test.\n" \
|
|
44
|
+
"Marking several tests in one file? Name them, and the line numbers can't go stale. Line numbers given in one call\n" \
|
|
45
|
+
"all refer to the file before that call. Across separate calls each insert shifts the lines below it down by one;\n" \
|
|
46
|
+
"fp allows for the markers it added itself, so line numbers from one read of the file keep working, and it says\n" \
|
|
47
|
+
"so when it moved one. If a number could mean two tests, fp asks for the name instead of guessing.\n" \
|
|
48
|
+
"The \"It binds to:\" line is the check: if it names the wrong test, or fp warns that no test declaration was\n" \
|
|
49
|
+
"recognised, the marker landed on the wrong line.\n" \
|
|
22
50
|
'Marking a test binds it to a requirement: never mark a test that is currently failing to make it count.'
|
|
23
51
|
|
|
24
52
|
KNOWN_FLAGS = {
|
|
@@ -41,18 +69,25 @@ module Fp
|
|
|
41
69
|
SLUG_RE = /\A[a-z0-9][a-z0-9_-]*\z/.freeze
|
|
42
70
|
KEY_RE = /\A[a-z0-9_-]+\z/.freeze
|
|
43
71
|
|
|
72
|
+
# How many of a file's test names to list when a named test isn't there.
|
|
73
|
+
NAMES_SHOWN = 12
|
|
74
|
+
|
|
75
|
+
# How long fp remembers the markers it inserted into a file, in seconds. Long enough
|
|
76
|
+
# for an agent working down a file from one read of it, short enough that a line
|
|
77
|
+
# number from a later, fresh read is rarely second-guessed.
|
|
78
|
+
JOURNAL_TTL = 30 * 60
|
|
79
|
+
|
|
44
80
|
def run(args)
|
|
45
81
|
opts, positional = parse_flags(args, KNOWN_FLAGS)
|
|
46
|
-
slug,
|
|
82
|
+
slug, *locations = positional
|
|
47
83
|
|
|
48
|
-
|
|
49
|
-
output.error('Usage: fp mark <slug> <file>:<line>')
|
|
84
|
+
if slug.nil? || locations.empty?
|
|
85
|
+
output.error('Usage: fp mark <slug> <file>:<line>|<file>::<test name> [more targets…]')
|
|
50
86
|
exit 1
|
|
51
87
|
end
|
|
52
88
|
|
|
53
89
|
fail_with("'#{slug}' isn't a valid slug (lowercase letters, numbers, - and _).") unless slug.match?(SLUG_RE)
|
|
54
90
|
|
|
55
|
-
path, line_no = parse_location(location)
|
|
56
91
|
surfaces = (opts[:surface] || '').split(',').map(&:strip).reject(&:empty?)
|
|
57
92
|
bad = surfaces.reject { |s| s.match?(KEY_RE) }
|
|
58
93
|
fail_with("Invalid surface key(s): #{bad.join(', ')}") unless bad.empty?
|
|
@@ -61,50 +96,195 @@ module Fp
|
|
|
61
96
|
fail_with('--type needs --surface: a marker pins its kind after its surfaces (fp:slug@api:e2e)') if surfaces.empty?
|
|
62
97
|
end
|
|
63
98
|
|
|
99
|
+
marker = "fp:#{slug}"
|
|
100
|
+
marker += "@#{surfaces.join(',')}" unless surfaces.empty?
|
|
101
|
+
marker += ":#{opts[:type]}" if opts[:type]
|
|
102
|
+
|
|
103
|
+
# Resolve every target against the files as they are now, before anything is
|
|
104
|
+
# written, so one target can't move another and a bad target changes nothing.
|
|
105
|
+
targets = locations.map { |location| parse_location(location) }
|
|
106
|
+
files = targets.map { |t| t[:path] }.uniq.to_h { |path| [path, File.read(path).lines] }
|
|
107
|
+
earlier = files.to_h { |path, lines| [path, earlier_inserts(path, lines)] }
|
|
108
|
+
targets.each { |t| t[:line] = resolve_line(t, files[t[:path]], earlier[t[:path]]) }
|
|
109
|
+
targets = targets.uniq { |t| [t[:path], t[:line]] }
|
|
110
|
+
|
|
111
|
+
results = targets.group_by { |t| t[:path] }.flat_map do |path, file_targets|
|
|
112
|
+
mark_file(path, files[path], file_targets, slug, marker, opts, earlier[path])
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
report(results)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
|
|
120
|
+
# Insert the marker above each target in one file. Targets go in from the bottom up,
|
|
121
|
+
# so every line number still means what it meant when the command started; each
|
|
122
|
+
# result's `line` is then where its marker sits in the file as written.
|
|
123
|
+
def mark_file(path, lines, file_targets, slug, marker, opts, earlier = [])
|
|
64
124
|
prefix = opts[:comment] || comment_prefix_for(path)
|
|
65
125
|
unless prefix
|
|
66
126
|
fail_with("Don't know the comment syntax for #{File.basename(path)}. Pass --comment, e.g. --comment '#' or --comment '//'.")
|
|
67
127
|
end
|
|
68
128
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
129
|
+
updated = lines.dup
|
|
130
|
+
results = file_targets.sort_by { |t| -t[:line] }.map do |target|
|
|
131
|
+
line_no = target[:line]
|
|
132
|
+
if already_marked?(updated, line_no, marker)
|
|
133
|
+
next { file: path, original_line: line_no, marker: marker, already: true }
|
|
134
|
+
end
|
|
73
135
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
136
|
+
test_line = updated[line_no - 1]
|
|
137
|
+
comment_line = "#{test_line[/\A[ \t]*/]}#{prefix} #{marker}#{line_ending(test_line)}"
|
|
138
|
+
updated.insert(line_no - 1, comment_line)
|
|
139
|
+
found = Fp::JUnit.scan_markers(updated.join).find { |m| m[:line] == line_no && m[:slug] == slug }
|
|
140
|
+
unless found
|
|
141
|
+
fail_with("A '#{prefix}' comment isn't one fp's scanner reads as a marker. Use #, //, -- or /* … */.")
|
|
142
|
+
end
|
|
77
143
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
144
|
+
{ file: path, original_line: line_no, marker: marker, found: found, comment_line: comment_line.strip,
|
|
145
|
+
given_line: target[:given_line] }
|
|
146
|
+
end
|
|
81
147
|
|
|
82
|
-
|
|
83
|
-
|
|
148
|
+
File.write(path, updated.join) unless opts[:dry_run]
|
|
149
|
+
|
|
150
|
+
# A marker moves down one line for every marker inserted above it.
|
|
151
|
+
inserted = results.reject { |r| r[:already] }.map { |r| r[:original_line] }
|
|
152
|
+
results = results.sort_by { |r| r[:original_line] }.map do |r|
|
|
153
|
+
r.merge(line: r[:original_line] + inserted.count { |l| l < r[:original_line] }, dry_run: opts[:dry_run])
|
|
84
154
|
end
|
|
85
155
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
156
|
+
unless opts[:dry_run] || inserted.empty?
|
|
157
|
+
# Markers from earlier calls move down too: one line for each insert at or above them.
|
|
158
|
+
moved = earlier.map { |line| line + inserted.count { |l| l <= line } }
|
|
159
|
+
remember_inserts(path, updated, moved + results.reject { |r| r[:already] }.map { |r| r[:line] })
|
|
90
160
|
end
|
|
161
|
+
results
|
|
162
|
+
end
|
|
91
163
|
|
|
92
|
-
|
|
93
|
-
|
|
164
|
+
# The marker lines fp inserted into this file in earlier calls, as line numbers in the
|
|
165
|
+
# file as it stands, oldest first. Empty once anything else has edited the file (its
|
|
166
|
+
# content no longer matches what fp wrote) or the note is older than JOURNAL_TTL.
|
|
167
|
+
def earlier_inserts(path, lines)
|
|
168
|
+
note = JSON.parse(File.read(journal_file(path)))
|
|
169
|
+
return [] unless note['sha'] == Digest::SHA256.hexdigest(lines.join)
|
|
170
|
+
return [] if Time.now.to_i - note['at'].to_i > JOURNAL_TTL
|
|
171
|
+
|
|
172
|
+
Array(note['inserted']).map(&:to_i)
|
|
173
|
+
rescue StandardError
|
|
174
|
+
[]
|
|
94
175
|
end
|
|
95
176
|
|
|
96
|
-
|
|
177
|
+
# Best effort: without the note, line numbers are simply read as the file stands.
|
|
178
|
+
def remember_inserts(path, lines, inserted)
|
|
179
|
+
file = journal_file(path)
|
|
180
|
+
FileUtils.mkdir_p(File.dirname(file), mode: 0o700)
|
|
181
|
+
Dir.glob(File.join(File.dirname(file), '*.json')).each do |old|
|
|
182
|
+
File.delete(old) if Time.now - File.mtime(old) > JOURNAL_TTL
|
|
183
|
+
end
|
|
184
|
+
File.write(file, JSON.generate('sha' => Digest::SHA256.hexdigest(lines.join), 'at' => Time.now.to_i,
|
|
185
|
+
'inserted' => inserted))
|
|
186
|
+
rescue StandardError
|
|
187
|
+
nil
|
|
188
|
+
end
|
|
97
189
|
|
|
190
|
+
def journal_file(path)
|
|
191
|
+
File.join(Dir.tmpdir, "fp-mark-#{Process.uid}", "#{Digest::SHA256.hexdigest(File.expand_path(path))}.json")
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# <file>::<test name> or <file>:<line>. The name form is checked first, so a test
|
|
195
|
+
# named with digits isn't read as a line number.
|
|
98
196
|
def parse_location(location)
|
|
197
|
+
if (m = location.match(/\A(.+?)::(.+)\z/))
|
|
198
|
+
path = m[1]
|
|
199
|
+
fail_with("No such file: #{path}") unless File.file?(path)
|
|
200
|
+
return { path: path, name: m[2] }
|
|
201
|
+
end
|
|
202
|
+
|
|
99
203
|
m = location.match(/\A(.+):(\d+)\z/)
|
|
100
|
-
fail_with("Give the test's location as <file>:<line> (got '#{location}').") unless m
|
|
204
|
+
fail_with("Give the test's location as <file>:<line> or <file>::<test name> (got '#{location}').") unless m
|
|
101
205
|
|
|
102
206
|
path = m[1]
|
|
103
207
|
line_no = m[2].to_i
|
|
104
208
|
fail_with("No such file: #{path}") unless File.file?(path)
|
|
105
209
|
fail_with('Line numbers start at 1.') if line_no < 1
|
|
106
210
|
|
|
107
|
-
|
|
211
|
+
{ path: path, line: line_no }
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def resolve_line(target, lines, earlier = [])
|
|
215
|
+
path = target[:path]
|
|
216
|
+
if target[:name]
|
|
217
|
+
line_for_name(path, lines, target[:name])
|
|
218
|
+
else
|
|
219
|
+
fail_with("#{path} has #{lines.length} line(s); there is no line #{target[:line]}.") if target[:line] > lines.length
|
|
220
|
+
line = line_allowing_for_earlier_marks(path, lines, target[:line], earlier)
|
|
221
|
+
target[:given_line] = target[:line] if line != target[:line]
|
|
222
|
+
line
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# A line number may have been read before fp's earlier markers pushed the file's
|
|
227
|
+
# lines down. Read it both ways: as the file stands, and as it was numbered before
|
|
228
|
+
# each run of those markers went in. When exactly one reading lands on a test
|
|
229
|
+
# declaration, that is the test. When none does, the number is taken as given, as it
|
|
230
|
+
# always was. When several do, nothing says which was meant, so nothing is written.
|
|
231
|
+
def line_allowing_for_earlier_marks(path, lines, given, earlier)
|
|
232
|
+
return given if earlier.empty?
|
|
233
|
+
|
|
234
|
+
readings = (0..earlier.length).filter_map { |known| line_numbered_without(lines, given, earlier[known..]) }.uniq
|
|
235
|
+
tests = readings.select { |line| Fp::JUnit.test_declared_on(lines[line - 1]) }
|
|
236
|
+
return given if tests.empty?
|
|
237
|
+
return tests.first if tests.length == 1
|
|
238
|
+
|
|
239
|
+
choices = tests.sort.map do |line|
|
|
240
|
+
name = Fp::JUnit.test_declared_on(lines[line - 1]).first
|
|
241
|
+
" #{path}::#{name} (line #{line} now)"
|
|
242
|
+
end
|
|
243
|
+
fail_with("fp added markers to #{path} a moment ago, so line #{given} could mean more than one test. " \
|
|
244
|
+
"Name the one you mean:\n#{choices.join("\n")}")
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# The line that was numbered `given` before the marker lines in `unseen` existed.
|
|
248
|
+
def line_numbered_without(lines, given, unseen)
|
|
249
|
+
count = 0
|
|
250
|
+
(1..lines.length).each do |line|
|
|
251
|
+
next if unseen.include?(line)
|
|
252
|
+
|
|
253
|
+
count += 1
|
|
254
|
+
return line if count == given
|
|
255
|
+
end
|
|
256
|
+
nil
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# The line declaring the test called `name`. Tried as given, then as the last part
|
|
260
|
+
# of a pytest id (TestClass::test_x), then without a pytest parameter suffix
|
|
261
|
+
# (test_x[case-1]), so an id copied out of a runner's output finds its test.
|
|
262
|
+
def line_for_name(path, lines, name)
|
|
263
|
+
declared = lines.each_with_index.filter_map do |line, i|
|
|
264
|
+
decl = Fp::JUnit.test_declared_on(line)
|
|
265
|
+
[decl.first, i + 1] if decl
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
candidates = [name, name.split('::').last]
|
|
269
|
+
candidates += candidates.map { |n| n.sub(/\[[^\]]*\]\z/, '') }
|
|
270
|
+
candidates.uniq.each do |candidate|
|
|
271
|
+
hits = declared.select { |n, _| n == candidate }.map(&:last)
|
|
272
|
+
return hits.first if hits.length == 1
|
|
273
|
+
next if hits.empty?
|
|
274
|
+
|
|
275
|
+
fail_with("#{path} declares '#{candidate}' more than once (lines #{hits.join(', ')}). " \
|
|
276
|
+
"Mark it as #{path}:<line> instead.")
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
known = declared.map(&:first).uniq
|
|
280
|
+
hint = if known.empty?
|
|
281
|
+
'fp recognises no test declarations in it; mark it as <file>:<line> instead.'
|
|
282
|
+
else
|
|
283
|
+
shown = known.first(NAMES_SHOWN).map { |n| " #{n}" }.join("\n")
|
|
284
|
+
more = known.length > NAMES_SHOWN ? "\n …and #{known.length - NAMES_SHOWN} more" : ''
|
|
285
|
+
"The tests it declares:\n#{shown}#{more}"
|
|
286
|
+
end
|
|
287
|
+
fail_with("No test named '#{name}' in #{path}. #{hint}")
|
|
108
288
|
end
|
|
109
289
|
|
|
110
290
|
def comment_prefix_for(path)
|
|
@@ -137,24 +317,36 @@ module Fp
|
|
|
137
317
|
s
|
|
138
318
|
end
|
|
139
319
|
|
|
140
|
-
def report(
|
|
141
|
-
data =
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
320
|
+
def report(results)
|
|
321
|
+
data = results.map do |r|
|
|
322
|
+
{ file: r[:file], line: r[:line], marker: r[:marker], already_marked: r[:already] || false,
|
|
323
|
+
dry_run: r[:dry_run] || false, binds_to: r[:found] && r[:found][:title] }.compact
|
|
324
|
+
end
|
|
325
|
+
# One target answers with the one object it always has; several with a list.
|
|
326
|
+
output.success(data.length == 1 ? data.first : { marks: data }) do
|
|
327
|
+
results.each { |r| print_result(r) }
|
|
328
|
+
end
|
|
329
|
+
end
|
|
148
330
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
331
|
+
def print_result(result)
|
|
332
|
+
path = result[:file]
|
|
333
|
+
line_no = result[:line]
|
|
334
|
+
if result[:already]
|
|
335
|
+
puts "#{path}:#{line_no} is already marked #{result[:marker]}; nothing changed."
|
|
336
|
+
return
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
if result[:given_line]
|
|
340
|
+
puts "Line #{result[:given_line]} was numbered before fp's earlier markers in #{path}; that test is on line #{result[:original_line]} now."
|
|
341
|
+
end
|
|
342
|
+
verb = result[:dry_run] ? 'Would insert' : 'Inserted'
|
|
343
|
+
puts "#{verb} at #{path}:#{line_no}:"
|
|
344
|
+
puts " #{result[:comment_line]}"
|
|
345
|
+
if result[:found][:title]
|
|
346
|
+
puts "It binds to: #{result[:found][:title]}"
|
|
347
|
+
else
|
|
348
|
+
puts "⚠️ No test declaration was recognised below line #{line_no}. Check that the line is the test itself;"
|
|
349
|
+
puts ' if the runner reports file paths, the marker still binds by file.'
|
|
158
350
|
end
|
|
159
351
|
end
|
|
160
352
|
|
data/lib/fp/commands/matrix.rb
CHANGED
|
@@ -19,8 +19,8 @@ module Fp
|
|
|
19
19
|
help_flag :surface, 'Limit to one surface'
|
|
20
20
|
help_flag :level, 'Evaluate against this enforcement level (off/regression/covered/strict)'
|
|
21
21
|
help_flag :csv, 'Emit CSV instead of the ASCII table'
|
|
22
|
-
help_example 'fp matrix --project
|
|
23
|
-
help_example 'fp matrix --project
|
|
22
|
+
help_example 'fp matrix --project acme'
|
|
23
|
+
help_example 'fp matrix --project acme --csv > matrix.csv'
|
|
24
24
|
|
|
25
25
|
KNOWN_FLAGS = {
|
|
26
26
|
project: :string,
|
data/lib/fp/commands/profile.rb
CHANGED
|
@@ -54,7 +54,8 @@ module Fp
|
|
|
54
54
|
|
|
55
55
|
# The global CLI parser consumes --api-url before the command runs, so
|
|
56
56
|
# honor it via the config object when the local flag wasn't captured.
|
|
57
|
-
|
|
57
|
+
# Saved without a trailing /api: the website used to hand that form out (Fizzy #1980).
|
|
58
|
+
api_url = Config.normalize_api_url(opts[:api_url] || config&.explicit_api_url)
|
|
58
59
|
Config.save_profile(name, api_key: opts[:api_key], api_url: api_url, environment: opts[:environment])
|
|
59
60
|
|
|
60
61
|
effective_url = api_url || Config.get_setting('api_url') || Config::DEFAULT_API_URL
|
data/lib/fp/commands/propose.rb
CHANGED
|
@@ -33,7 +33,7 @@ module Fp
|
|
|
33
33
|
help_flag :source_ref, 'A place in the repo it was read from, e.g. app/models/order.rb:42 (repeatable)'
|
|
34
34
|
help_flag :file, 'YAML or JSON file of requirements to propose in one batch (validated all-or-nothing)'
|
|
35
35
|
help_flag :dry_run, 'Validate and lint the wording; write nothing'
|
|
36
|
-
help_example 'fp propose --project
|
|
36
|
+
help_example 'fp propose --project acme --slug print_qr --name "Print QR on container label" --why "Staff mis-type the ID without a scannable code" --required api,customer_ios --acceptance "QR scans to the container detail page"'
|
|
37
37
|
help_example 'fp propose --file requirements.yml --dry-run', 'Lint a batch and show what would be created'
|
|
38
38
|
help_example 'fp propose --file requirements.yml --source-type repo_scan', 'Create the batch; flags are defaults for every entry'
|
|
39
39
|
help_note "Agents can only create drafts. A human activates it in the web app.\n" \
|
|
@@ -31,7 +31,7 @@ module Fp
|
|
|
31
31
|
help_flag :source_url, 'URL of the card/issue/thread that prompted this proposal'
|
|
32
32
|
help_flag :source_context, 'Free-form note about what prompted this proposal'
|
|
33
33
|
help_flag :source_ref, 'A place in the repo that prompted it, e.g. app/models/order.rb:42 (repeatable)'
|
|
34
|
-
help_example 'fp propose-change print_qr --project
|
|
34
|
+
help_example 'fp propose-change print_qr --project acme --acceptance "QR scans after 24h at -20C" --reason "Cold-chain rollout"'
|
|
35
35
|
help_example 'fp propose-change summon_can_be_undone --tags rules,units --reason "Rulebook check reads the first tag"'
|
|
36
36
|
help_example 'fp propose-change print_qr --removal --reason "Superseded by print_container_label"'
|
|
37
37
|
help_note "Applies the change and drops the requirement to draft for a human to review. --reason and\n" \
|
data/lib/fp/commands/report.rb
CHANGED
|
@@ -40,8 +40,8 @@ module Fp
|
|
|
40
40
|
help_flag :base_dir, 'Where relative test-file paths in the report resolve from'
|
|
41
41
|
help_flag :attach_media, 'With --junit: upload the videos/screenshots the run recorded ([[ATTACHMENT|…]]) as visual evidence'
|
|
42
42
|
help_flag :stamp_all, 'With --junit: put --pr/--work-item on every receipt, not only on tests in files this branch changed'
|
|
43
|
-
help_example 'fp report print_container_qr --project
|
|
44
|
-
help_example 'fp report --junit junit.xml --project
|
|
43
|
+
help_example 'fp report print_container_qr --project acme --surface api --file spec/qr_spec.rb --repo acme/app'
|
|
44
|
+
help_example 'fp report --junit junit.xml --project acme --surface api --repo acme/app',
|
|
45
45
|
'Batch-upload from a JUnit report (slugs come from fp:<slug> markers)'
|
|
46
46
|
help_note "Agents report 'present' or 'stub' only. CI writes 'passing'/'failing' via fp ci-report.\n" \
|
|
47
47
|
"Always pass --test-type when a surface has more than one suite, or they overwrite each other.\n" \
|
data/lib/fp/commands/repos.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Fp
|
|
|
8
8
|
# ~/.config/fp/config.yml under `repos`, scoped by project slug. This is a
|
|
9
9
|
# per-installation convenience (not stored in the FP web app): when an agent
|
|
10
10
|
# picks up a requirement affecting, say, the `customer_android` surface, it can
|
|
11
|
-
# run `fp repos get customer_android --project
|
|
11
|
+
# run `fp repos get customer_android --project acme` to learn which local
|
|
12
12
|
# directory to work in. Analogous to how `brainiac projects` maps repos to names.
|
|
13
13
|
#
|
|
14
14
|
# fp repos set <surface> <path> --project <slug> [--repo org/repo]
|
|
@@ -23,8 +23,8 @@ module Fp
|
|
|
23
23
|
'fp repos unset <surface> --project <slug>'
|
|
24
24
|
help_flag :project, 'Project slug (falls back to .featureparity.yml)'
|
|
25
25
|
help_flag :repo, 'Optional org/repo to record alongside the local path (set only)'
|
|
26
|
-
help_example 'fp repos set customer_android ~/code/customer-android --project
|
|
27
|
-
help_example 'cd "$(fp repos get customer_android --project
|
|
26
|
+
help_example 'fp repos set customer_android ~/code/customer-android --project acme --repo acme/customer-android'
|
|
27
|
+
help_example 'cd "$(fp repos get customer_android --project acme)"'
|
|
28
28
|
help_note 'Stored per-installation in ~/.config/fp/config.yml, not in the web app.'
|
|
29
29
|
|
|
30
30
|
KNOWN_FLAGS = {
|
|
@@ -170,9 +170,9 @@ module Fp
|
|
|
170
170
|
puts
|
|
171
171
|
puts 'Examples:'
|
|
172
172
|
puts ' fp repos set customer_android ~/code/customer-android \\'
|
|
173
|
-
puts ' --project
|
|
174
|
-
puts ' fp repos get customer_android --project
|
|
175
|
-
puts ' cd "$(fp repos get customer_android --project
|
|
173
|
+
puts ' --project acme --repo acme/customer-android'
|
|
174
|
+
puts ' fp repos get customer_android --project acme'
|
|
175
|
+
puts ' cd "$(fp repos get customer_android --project acme)"'
|
|
176
176
|
exit 1
|
|
177
177
|
end
|
|
178
178
|
end
|
data/lib/fp/commands/setup.rb
CHANGED
|
@@ -34,7 +34,8 @@ module Fp
|
|
|
34
34
|
|
|
35
35
|
api_key = resolve_api_key(opts)
|
|
36
36
|
profile_name = resolve_profile_name(opts)
|
|
37
|
-
|
|
37
|
+
# Without a trailing /api: the key check and every later call add it themselves.
|
|
38
|
+
api_url = Config.normalize_api_url(resolve_api_url(opts))
|
|
38
39
|
environment = opts[:environment] || Config.environment_for(api_url || Config::DEFAULT_API_URL)
|
|
39
40
|
|
|
40
41
|
puts "Validating API key..."
|
data/lib/fp/commands/show.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Fp
|
|
|
8
8
|
help_summary 'Show a requirement, its acceptance criteria, and evidence receipts'
|
|
9
9
|
help_usage 'fp show <slug> --project <slug>'
|
|
10
10
|
help_flag :project, 'Project slug (falls back to .featureparity.yml)'
|
|
11
|
-
help_example 'fp show print_container_qr --project
|
|
11
|
+
help_example 'fp show print_container_qr --project acme'
|
|
12
12
|
|
|
13
13
|
def run(args)
|
|
14
14
|
opts, positional = parse_flags(args)
|
|
@@ -163,7 +163,12 @@ module Fp
|
|
|
163
163
|
# change to this requirement, oldest first. Derived from events so the history is
|
|
164
164
|
# additive — older sources aren't lost when a new one is recorded.
|
|
165
165
|
puts 'Source Trail:'
|
|
166
|
-
|
|
166
|
+
own_type = req['source_type']
|
|
167
|
+
own_context = req['source_context']
|
|
168
|
+
if source_history.empty? && (own_type || own_context)
|
|
169
|
+
puts " - #{own_type}" if own_type
|
|
170
|
+
puts " #{own_context}" if own_context
|
|
171
|
+
elsif source_history.empty?
|
|
167
172
|
puts ' (no sources recorded)'
|
|
168
173
|
else
|
|
169
174
|
source_history.each do |src|
|
|
@@ -196,6 +201,9 @@ module Fp
|
|
|
196
201
|
else
|
|
197
202
|
puts " Status: #{e['status']}"
|
|
198
203
|
end
|
|
204
|
+
# The requirement was retired and the default branch's CI no longer runs
|
|
205
|
+
# this test: the feature is out of this surface (Fizzy #1820).
|
|
206
|
+
puts " Removed: #{e['removed_at']} (CI no longer runs this test)" if e['removed_at']
|
|
199
207
|
# A pull request's CI may have written over the merged verdict; show both
|
|
200
208
|
# when they differ so "failing" next to "PR: …" reads as the branch's
|
|
201
209
|
# result, not the default branch's.
|
data/lib/fp/commands/showroom.rb
CHANGED
|
@@ -31,12 +31,12 @@ module Fp
|
|
|
31
31
|
help_flag :caption, 'media add/edit: text shown under the image or video (edit: empty clears)'
|
|
32
32
|
help_flag :position, 'media add/edit: slot within its card or the gallery, 1 is first; others shift (edit: empty moves it last)'
|
|
33
33
|
help_flag :yes, 'media remove: skip the typed-filename confirmation'
|
|
34
|
-
help_example 'fp showroom --project
|
|
35
|
-
help_example 'fp showroom media add e2e/checkout.webm --project
|
|
36
|
-
help_example 'fp showroom media add overview.png --project
|
|
37
|
-
help_example 'fp showroom media add app-icon.png --project
|
|
38
|
-
help_example 'fp showroom media edit <id> --project
|
|
39
|
-
help_example 'fp showroom media remove <id> --project
|
|
34
|
+
help_example 'fp showroom --project acme'
|
|
35
|
+
help_example 'fp showroom media add e2e/checkout.webm --project acme --surface web --caption "Checking out"'
|
|
36
|
+
help_example 'fp showroom media add overview.png --project acme --position 1'
|
|
37
|
+
help_example 'fp showroom media add app-icon.png --project acme --surface ios --icon'
|
|
38
|
+
help_example 'fp showroom media edit <id> --project acme --caption ""'
|
|
39
|
+
help_example 'fp showroom media remove <id> --project acme --yes'
|
|
40
40
|
help_note "Prints the welcome note, the gallery, and each surface's card, then the surfaces that are NOT shown and why.\n" \
|
|
41
41
|
"Write the content with `fp projects edit --showroom-welcome` and `fp surfaces edit --showroom-*`.\n" \
|
|
42
42
|
"Media: png, jpg, gif, webp, mp4, webm, mov; max 100 MB. SVG and PDF are refused.\n" \
|