nukadoko 0.5.0 → 0.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +553 -3
- data/README.ja.md +22 -6
- data/README.md +13 -7
- data/docs/ci.ja.md +542 -0
- data/docs/ci.md +635 -0
- data/docs/commands.ja.md +1524 -0
- data/docs/commands.md +1281 -0
- data/docs/engines.json +19 -0
- data/docs/execution-events.ja.md +336 -0
- data/docs/execution-events.md +423 -0
- data/docs/glossary.json +1348 -0
- data/docs/guide.ja.md +733 -0
- data/docs/guide.md +815 -0
- data/docs/intent.ja.md +133 -0
- data/docs/intent.md +156 -0
- data/docs/layout.ja.md +442 -0
- data/docs/layout.md +399 -0
- data/docs/releasing.ja.md +186 -0
- data/docs/releasing.md +237 -0
- data/docs/ruby/reference.ja.md +302 -0
- data/docs/ruby/reference.md +368 -0
- data/docs/spec.ja.md +8916 -0
- data/docs/spec.md +11250 -0
- data/docs/tutorial.ja.md +451 -0
- data/docs/tutorial.md +458 -0
- data/docs/typescript/adopting.ja.md +231 -0
- data/docs/typescript/adopting.md +251 -0
- data/docs/typescript/doors.ja.md +301 -0
- data/docs/typescript/doors.md +329 -0
- data/docs/typescript/migration-playwright-test.ja.md +189 -0
- data/docs/typescript/migration-playwright-test.md +212 -0
- data/docs/typescript/migration.ja.md +391 -0
- data/docs/typescript/migration.md +505 -0
- data/docs/typescript/reference.ja.md +176 -0
- data/docs/typescript/reference.md +197 -0
- data/docs/typescript/upgrading.ja.md +1774 -0
- data/docs/typescript/upgrading.md +2224 -0
- data/docs/web-app.ja.md +627 -0
- data/docs/web-app.md +659 -0
- data/docs/writing-scenarios.ja.md +544 -0
- data/docs/writing-scenarios.md +563 -0
- data/lib/nukadoko/base.rb +12 -5
- data/lib/nukadoko/changed_files.rb +95 -0
- data/lib/nukadoko/check.rb +459 -51
- data/lib/nukadoko/claim_drops.rb +271 -0
- data/lib/nukadoko/claim_line.rb +24 -4
- data/lib/nukadoko/claim_rules.rb +143 -1
- data/lib/nukadoko/claim_sides.rb +157 -9
- data/lib/nukadoko/cli.rb +403 -50
- data/lib/nukadoko/codes.json +246 -21
- data/lib/nukadoko/codes.rb +21 -4
- data/lib/nukadoko/command.rb +120 -13
- data/lib/nukadoko/command_help.rb +128 -0
- data/lib/nukadoko/compat.rb +469 -0
- data/lib/nukadoko/criteria.rb +1 -1
- data/lib/nukadoko/definition.rb +157 -7
- data/lib/nukadoko/error_frames.rb +6 -3
- data/lib/nukadoko/events/count.rb +146 -0
- data/lib/nukadoko/events/counted.rb +114 -0
- data/lib/nukadoko/events/format.rb +257 -0
- data/lib/nukadoko/events/lists.rb +154 -0
- data/lib/nukadoko/events/path.rb +285 -0
- data/lib/nukadoko/events/read.rb +284 -0
- data/lib/nukadoko/events/reader.rb +490 -0
- data/lib/nukadoko/events/selection.rb +252 -0
- data/lib/nukadoko/events/tally.rb +438 -0
- data/lib/nukadoko/features.rb +2 -2
- data/lib/nukadoko/fixtures.rb +160 -35
- data/lib/nukadoko/http_recording.rb +6 -2
- data/lib/nukadoko/intent.rb +364 -0
- data/lib/nukadoko/intent_file.rb +81 -0
- data/lib/nukadoko/intent_view.rb +190 -0
- data/lib/nukadoko/js_json.rb +2 -1
- data/lib/nukadoko/judge.rb +2 -2
- data/lib/nukadoko/judgment_file.rb +22 -1
- data/lib/nukadoko/judgments.rb +33 -3
- data/lib/nukadoko/measure_mcp.rb +202 -0
- data/lib/nukadoko/parts.rb +8 -2
- data/lib/nukadoko/path_view.rb +252 -0
- data/lib/nukadoko/place_rows.rb +161 -0
- data/lib/nukadoko/program.rb +1265 -51
- data/lib/nukadoko/program_log.rb +122 -0
- data/lib/nukadoko/program_shape.rb +385 -0
- data/lib/nukadoko/project_fixtures.rb +43 -10
- data/lib/nukadoko/project_program.rb +5 -4
- data/lib/nukadoko/repeated_prefix.rb +310 -0
- data/lib/nukadoko/report_run.rb +3 -3
- data/lib/nukadoko/run.rb +1156 -159
- data/lib/nukadoko/run_record.rb +70 -46
- data/lib/nukadoko/scaffold.rb +24 -6
- data/lib/nukadoko/schema.rb +15 -2
- data/lib/nukadoko/secrets.rb +55 -5
- data/lib/nukadoko/states.rb +478 -0
- data/lib/nukadoko/step.rb +71 -2
- data/lib/nukadoko/step_fixtures.rb +52 -3
- data/lib/nukadoko/summary.rb +803 -30
- data/lib/nukadoko/table.rb +4 -2
- data/lib/nukadoko/text_fit.rb +20 -7
- data/lib/nukadoko/trace.rb +152 -45
- data/lib/nukadoko/tree_passes.rb +95 -33
- data/lib/nukadoko/underneath.rb +311 -0
- data/lib/nukadoko/verdict.rb +18 -1
- data/lib/nukadoko/version.rb +1 -1
- data/lib/nukadoko/vocabulary.rb +166 -23
- data/lib/nukadoko/walk.rb +2 -2
- data/lib/nukadoko/walk_step.rb +1 -1
- data/lib/nukadoko.rb +23 -0
- data/llms.txt +42 -35
- data/sig/generated/nukadoko/base.rbs +4 -4
- data/sig/generated/nukadoko/changed_files.rbs +42 -0
- data/sig/generated/nukadoko/check.rbs +147 -10
- data/sig/generated/nukadoko/claim_drops.rbs +135 -0
- data/sig/generated/nukadoko/claim_line.rbs +11 -0
- data/sig/generated/nukadoko/claim_rules.rbs +49 -4
- data/sig/generated/nukadoko/claim_sides.rbs +63 -12
- data/sig/generated/nukadoko/cli.rbs +80 -7
- data/sig/generated/nukadoko/codes.rbs +19 -4
- data/sig/generated/nukadoko/command.rbs +68 -1
- data/sig/generated/nukadoko/command_help.rbs +18 -0
- data/sig/generated/nukadoko/compat.rbs +392 -0
- data/sig/generated/nukadoko/criteria.rbs +1 -1
- data/sig/generated/nukadoko/definition.rbs +50 -0
- data/sig/generated/nukadoko/error_frames.rbs +1 -1
- data/sig/generated/nukadoko/events/count.rbs +69 -0
- data/sig/generated/nukadoko/events/counted.rbs +70 -0
- data/sig/generated/nukadoko/events/format.rbs +163 -0
- data/sig/generated/nukadoko/events/lists.rbs +47 -0
- data/sig/generated/nukadoko/events/path.rbs +161 -0
- data/sig/generated/nukadoko/events/read.rbs +109 -0
- data/sig/generated/nukadoko/events/reader.rbs +226 -0
- data/sig/generated/nukadoko/events/selection.rbs +100 -0
- data/sig/generated/nukadoko/events/tally.rbs +227 -0
- data/sig/generated/nukadoko/features.rbs +6 -4
- data/sig/generated/nukadoko/fixtures.rbs +67 -11
- data/sig/generated/nukadoko/http_recording.rbs +1 -1
- data/sig/generated/nukadoko/intent.rbs +132 -0
- data/sig/generated/nukadoko/intent_file.rbs +46 -0
- data/sig/generated/nukadoko/intent_view.rbs +69 -0
- data/sig/generated/nukadoko/judgment_file.rbs +7 -1
- data/sig/generated/nukadoko/judgments.rbs +10 -0
- data/sig/generated/nukadoko/measure_mcp.rbs +104 -0
- data/sig/generated/nukadoko/parts.rbs +2 -2
- data/sig/generated/nukadoko/path_view.rbs +105 -0
- data/sig/generated/nukadoko/place_rows.rbs +43 -0
- data/sig/generated/nukadoko/program.rbs +627 -23
- data/sig/generated/nukadoko/program_log.rbs +67 -0
- data/sig/generated/nukadoko/program_shape.rbs +147 -0
- data/sig/generated/nukadoko/project_fixtures.rbs +16 -3
- data/sig/generated/nukadoko/project_program.rbs +2 -1
- data/sig/generated/nukadoko/repeated_prefix.rbs +172 -0
- data/sig/generated/nukadoko/report_run.rbs +1 -1
- data/sig/generated/nukadoko/run.rbs +286 -41
- data/sig/generated/nukadoko/run_record.rbs +20 -12
- data/sig/generated/nukadoko/scaffold.rbs +3 -0
- data/sig/generated/nukadoko/schema.rbs +5 -0
- data/sig/generated/nukadoko/secrets.rbs +26 -3
- data/sig/generated/nukadoko/states.rbs +214 -0
- data/sig/generated/nukadoko/step.rbs +58 -1
- data/sig/generated/nukadoko/step_fixtures.rbs +39 -0
- data/sig/generated/nukadoko/summary.rbs +256 -2
- data/sig/generated/nukadoko/table.rbs +3 -2
- data/sig/generated/nukadoko/trace.rbs +108 -33
- data/sig/generated/nukadoko/tree_passes.rbs +36 -8
- data/sig/generated/nukadoko/underneath.rbs +141 -0
- data/sig/generated/nukadoko/verdict.rbs +8 -0
- data/sig/generated/nukadoko/vocabulary.rbs +45 -6
- data/skills/nukadoko/SKILL.md +18 -18
- data/skills/nukadoko/references/checking-steps.md +16 -83
- data/skills/nukadoko/references/diagnosing.md +6 -6
- data/skills/nukadoko/references/done.md +22 -0
- data/skills/nukadoko/references/evidence.md +19 -6
- data/skills/nukadoko/references/exploring.md +22 -7
- data/skills/nukadoko/references/fixtures.md +12 -32
- data/skills/nukadoko/references/judgments.md +18 -0
- data/skills/nukadoko/references/maintenance.md +1 -1
- data/skills/nukadoko/references/merge-risk.md +1 -1
- data/skills/nukadoko/references/parts.md +46 -23
- data/skills/nukadoko/references/{perturbed-worlds.md → perturbed-systems.md} +30 -12
- data/skills/nukadoko/references/program.md +168 -169
- data/skills/nukadoko/references/reviewing.md +20 -20
- data/skills/nukadoko/references/ruby/checking-steps.md +106 -0
- data/skills/nukadoko/references/ruby/examples/cli.md +212 -0
- data/skills/nukadoko/references/ruby/fixtures.md +34 -0
- data/skills/nukadoko/references/ruby/program.md +112 -0
- data/skills/nukadoko/references/ruby/step-files.md +115 -0
- data/skills/nukadoko/references/running.md +34 -34
- data/skills/nukadoko/references/scenario-rules.md +7 -6
- data/skills/nukadoko/references/states.md +7 -1
- data/skills/nukadoko/references/step-files.md +41 -120
- data/skills/nukadoko/references/typescript/checking-steps.md +129 -0
- data/skills/nukadoko/references/{examples → typescript/examples}/cli.md +1 -1
- data/skills/nukadoko/references/{examples → typescript/examples}/http-api.md +6 -6
- data/skills/nukadoko/references/{examples → typescript/examples}/workflow.md +1 -1
- data/skills/nukadoko/references/typescript/fixtures.md +56 -0
- data/skills/nukadoko/references/typescript/program.md +111 -0
- data/skills/nukadoko/references/typescript/step-files.md +104 -0
- data/skills/nukadoko/references/verdicts.md +10 -10
- data/skills/nukadoko/references/writing-steps.md +67 -67
- data/skills/nukadoko/references/writing-the-feature.md +1 -1
- data/skills/nukadoko-verification/SKILL.md +13 -8
- metadata +103 -7
- data/skills/nukadoko/references/ruby.md +0 -80
data/lib/nukadoko/codes.rb
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
require "json"
|
|
5
5
|
|
|
6
|
-
# Every code a finding or a refusal can carry, with its description
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# Every code a finding or a refusal can carry, with its description, the
|
|
7
|
+
# edit that gets past it, and the registry it comes from (`check`, `run`,
|
|
8
|
+
# or `refusal`), as the TypeScript engine's registries hold them
|
|
9
|
+
# (`bin/sync-codes` writes codes.json from them), so one code reads the
|
|
10
|
+
# same in either engine and `nuka check --codes` lists the same codes in
|
|
11
|
+
# the same order. Data only.
|
|
10
12
|
module Nukadoko
|
|
11
13
|
module Engine
|
|
12
14
|
module Codes
|
|
@@ -14,6 +16,21 @@ module Nukadoko
|
|
|
14
16
|
|
|
15
17
|
#: (String) -> String?
|
|
16
18
|
def self.fix(code) = ALL.dig(code, "fix")
|
|
19
|
+
|
|
20
|
+
# A code `nuka check` itself reports. A run code can carry a warning
|
|
21
|
+
# or a note too, so the severity alone cannot tell.
|
|
22
|
+
#: (String) -> bool
|
|
23
|
+
def self.check?(code) = ALL.dig(code, "source") == "check"
|
|
24
|
+
|
|
25
|
+
#: (String) -> String?
|
|
26
|
+
def self.severity(code) = ALL.dig(code, "severity")
|
|
27
|
+
|
|
28
|
+
# Every code as a finding with no location: its severity, the code,
|
|
29
|
+
# its description as the message, and its general fix.
|
|
30
|
+
#: () -> Array[Hash[Symbol, String]]
|
|
31
|
+
def self.listed
|
|
32
|
+
ALL.map { |code, entry| { severity: entry["severity"], code: code, message: entry["description"], fix: entry["fix"] } }
|
|
33
|
+
end
|
|
17
34
|
end
|
|
18
35
|
end
|
|
19
36
|
end
|
data/lib/nukadoko/command.rb
CHANGED
|
@@ -24,12 +24,23 @@ module Nukadoko
|
|
|
24
24
|
# `unbundled: true` runs the command with the environment from before
|
|
25
25
|
# Bundler set up nuka (no BUNDLE_GEMFILE, no -rbundler/setup in RUBYOPT),
|
|
26
26
|
# for a command in another Ruby project, which has a Gemfile of its own.
|
|
27
|
+
# A system whose program declares stepsReach: "url" refuses the call
|
|
28
|
+
# before anything starts, with CommandRefused: there, a service URL is
|
|
29
|
+
# the only way the code that runs with the scenarios reaches the program.
|
|
27
30
|
#: (String, ?Array[String], ?cwd: String, ?env: Hash[String | Symbol, String], ?input: String?, ?stdin: String?, ?timeout: Numeric?, ?redact: Hash[String | Symbol, String], ?files: bool, ?unbundled: bool) -> Hash[Symbol, untyped]
|
|
28
31
|
def self.run_command(command, args = [], cwd: Dir.pwd, env: {}, input: nil, stdin: nil, timeout: nil, redact: {}, files: false, unbundled: false)
|
|
29
32
|
stdin = input.nil? ? stdin : input
|
|
30
33
|
held = Engine::Secrets.new(redact.to_h { |name, value| [name.to_s, value.to_s] })
|
|
31
34
|
recording = Engine::Processes.current
|
|
32
35
|
cwd = File.expand_path(cwd)
|
|
36
|
+
# Refused before the spawn, in a system that declares stepsReach: "url".
|
|
37
|
+
# The entry is pushed even so, and with no exit code: a step that
|
|
38
|
+
# rescues the error still leaves the reason in its record, so no
|
|
39
|
+
# refusal passes silently.
|
|
40
|
+
if (refused = Engine::Reach.refusal("Nukadoko.run_command"))
|
|
41
|
+
recording&.push({ command: held.redact([command, *args]), cwd: cwd, refused: "steps-reach-url" })
|
|
42
|
+
raise refused
|
|
43
|
+
end
|
|
33
44
|
# A tool that copies TRACEPARENT into its requests makes the program's
|
|
34
45
|
# log lines for them the step's. A value the step chose is kept.
|
|
35
46
|
env = env.transform_keys(&:to_s)
|
|
@@ -54,7 +65,92 @@ module Nukadoko
|
|
|
54
65
|
{ exitCode: status.exitstatus, signal: signal, stdout: stdout, stderr: stderr, **(changes ? { files: changes } : {}) }
|
|
55
66
|
end
|
|
56
67
|
|
|
68
|
+
# Raised instead of starting a process, in a system whose program declares
|
|
69
|
+
# stepsReach: "url". There, a service URL is the only way the code that
|
|
70
|
+
# runs with the scenarios reaches the program, so one set of steps runs
|
|
71
|
+
# against services nukadoko starts and against services that are only
|
|
72
|
+
# URLs. `code` is the finding a run reports for it, so a step that
|
|
73
|
+
# rescues the error can tell it from a program that failed.
|
|
74
|
+
class CommandRefused < StandardError
|
|
75
|
+
#: () -> String
|
|
76
|
+
def code = "command-refused"
|
|
77
|
+
|
|
78
|
+
attr_reader :environment #: String
|
|
79
|
+
attr_reader :place #: String?
|
|
80
|
+
|
|
81
|
+
#: (String, String, String?) -> void
|
|
82
|
+
def initialize(helper, environment, place)
|
|
83
|
+
@environment = environment
|
|
84
|
+
@place = place
|
|
85
|
+
super(Engine::Reach.refusal_text(helper, environment, place))
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# A step or a fixture read setup_result where nothing made a value for it.
|
|
90
|
+
class SetupResultMissing < StandardError; end
|
|
91
|
+
|
|
57
92
|
module Engine
|
|
93
|
+
# The rule a system declares with stepsReach, and where in the pass the
|
|
94
|
+
# code that called runs, which together decide whether
|
|
95
|
+
# Nukadoko.run_command may start a process. The rule is the system's, so
|
|
96
|
+
# it is held for the process that runs its steps; the place is per
|
|
97
|
+
# thread, like the processes a step records.
|
|
98
|
+
#
|
|
99
|
+
# Only the helper that starts a process is refused. A step's browser is
|
|
100
|
+
# how it reaches a URL, and a bare Kernel#system is out of this
|
|
101
|
+
# module's sight: nukadoko never saw it, so it can neither refuse nor
|
|
102
|
+
# record it.
|
|
103
|
+
module Reach
|
|
104
|
+
@rule = nil #: Hash[Symbol, String]?
|
|
105
|
+
|
|
106
|
+
#: () -> Hash[Symbol, String]?
|
|
107
|
+
def self.rule = @rule
|
|
108
|
+
|
|
109
|
+
# Declares `reach` for `environment` from the start of the system's
|
|
110
|
+
# setup until it stops, and gives back what takes it away again.
|
|
111
|
+
#: (String, String) -> ^() -> void
|
|
112
|
+
def self.declare(reach, environment)
|
|
113
|
+
previous = @rule
|
|
114
|
+
@rule = { reach: reach, environment: environment }
|
|
115
|
+
-> { @rule = previous }
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
#: () -> String?
|
|
119
|
+
def self.place = Thread.current[:nukadoko_reach_place]
|
|
120
|
+
|
|
121
|
+
# Runs the block so that a refusal in it names `place`: `setup`,
|
|
122
|
+
# `step "..."`, `fixture "..."`, or a hook.
|
|
123
|
+
#: [T] (String) { () -> T } -> T
|
|
124
|
+
def self.at(place)
|
|
125
|
+
previous = Thread.current[:nukadoko_reach_place]
|
|
126
|
+
Thread.current[:nukadoko_reach_place] = place
|
|
127
|
+
yield
|
|
128
|
+
ensure
|
|
129
|
+
Thread.current[:nukadoko_reach_place] = previous
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# The error that refuses `helper` here, or nil where it may run: no
|
|
133
|
+
# system, or a system whose stepsReach is "any".
|
|
134
|
+
#: (String) -> CommandRefused?
|
|
135
|
+
def self.refusal(helper)
|
|
136
|
+
held = @rule
|
|
137
|
+
return nil unless held && held[:reach] == "url"
|
|
138
|
+
|
|
139
|
+
CommandRefused.new(helper, held[:environment].to_s, place)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# What a refusal says: the helper, where it was called, the
|
|
143
|
+
# environment that declared the rule, and the request to send
|
|
144
|
+
# instead. The TypeScript engine's words, with its own helper name.
|
|
145
|
+
#: (String, String, String?) -> String
|
|
146
|
+
def self.refusal_text(helper, environment, place)
|
|
147
|
+
where = place || "in code that runs with the scenarios"
|
|
148
|
+
%(#{helper} is refused #{where}: environment "#{environment}" declares stepsReach: "url", ) +
|
|
149
|
+
"so code that runs with the scenarios reaches the program only through a service URL. " \
|
|
150
|
+
"Send the request to the service's URL instead (base_url, or services[:<name>].url), such as its test API."
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
58
154
|
# The processes the running step started, kept per thread so a step
|
|
59
155
|
# that calls run_command from a helper is still measured.
|
|
60
156
|
module Processes
|
|
@@ -94,22 +190,33 @@ module Nukadoko
|
|
|
94
190
|
options[:pgroup] = true if group && groups?
|
|
95
191
|
# A nil value unsets the variable, which Open3's signature leaves out.
|
|
96
192
|
Open3.popen3(_ = env, *argv, **options) do |stdin, out, err, thread|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
193
|
+
readers = [] #: Array[Thread]
|
|
194
|
+
begin
|
|
195
|
+
stdin.write(input.to_s)
|
|
196
|
+
stdin.close
|
|
197
|
+
readers = [Thread.new { out.read }, Thread.new { err.read }]
|
|
198
|
+
timed_out = timeout && !thread.join(timeout)
|
|
199
|
+
stop(thread, group) if timed_out
|
|
200
|
+
status = thread.value
|
|
201
|
+
[readers[0].value.to_s.force_encoding("UTF-8"), readers[1].value.to_s.force_encoding("UTF-8"), status, timed_out]
|
|
202
|
+
rescue Exception # rubocop:disable Lint/RescueException
|
|
203
|
+
# A deadline around the call (the step's own timeout) lands here.
|
|
204
|
+
# Open3 then waits for the program to close, so without the stop
|
|
205
|
+
# a program that hangs holds the step past its deadline.
|
|
206
|
+
stop(thread, group)
|
|
207
|
+
readers.each(&:join)
|
|
208
|
+
raise
|
|
107
209
|
end
|
|
108
|
-
status = thread.value
|
|
109
|
-
[readers[0].value.to_s.force_encoding("UTF-8"), readers[1].value.to_s.force_encoding("UTF-8"), status, timed_out]
|
|
110
210
|
end
|
|
111
211
|
end
|
|
112
212
|
|
|
213
|
+
#: (Process::Waiter, bool) -> void
|
|
214
|
+
def self.stop(thread, group)
|
|
215
|
+
Process.kill("TERM", group && groups? ? -thread.pid : thread.pid)
|
|
216
|
+
rescue Errno::ESRCH
|
|
217
|
+
nil
|
|
218
|
+
end
|
|
219
|
+
|
|
113
220
|
# `ended` when no process of the group still runs as the leader closed.
|
|
114
221
|
#: (Integer) -> String
|
|
115
222
|
def self.group_state(pid)
|
|
@@ -201,7 +308,7 @@ module Nukadoko
|
|
|
201
308
|
@dirs = []
|
|
202
309
|
end
|
|
203
310
|
|
|
204
|
-
# A directory under the
|
|
311
|
+
# A directory under the machine's temporary directory, named
|
|
205
312
|
# `<prefix>-` and six characters, as the TypeScript engine names it.
|
|
206
313
|
#: (?String) -> String
|
|
207
314
|
def dir(prefix = "nukadoko-scratch")
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
3
|
+
|
|
4
|
+
# What `nuka <command> --help` prints: the command's usage, what it is for, and the flags
|
|
5
|
+
# it reads. The flags listed here are the ones the command acts on, so the table of what
|
|
6
|
+
# each engine offers (docs/engines.json) can be checked against this text, and a refusal
|
|
7
|
+
# that says "the command's --help lists its flags" points at something that exists.
|
|
8
|
+
module Nukadoko
|
|
9
|
+
module CommandHelp
|
|
10
|
+
# @rbs!
|
|
11
|
+
# type entry = { usage: String, summary: String, flags: Array[[String, String]] }
|
|
12
|
+
|
|
13
|
+
JSON_FLAG = ["--json", "machine-readable output"].freeze #: [String, String]
|
|
14
|
+
|
|
15
|
+
COMMANDS = {
|
|
16
|
+
"init" => {
|
|
17
|
+
usage: "nuka init",
|
|
18
|
+
summary: "set up a project; ends with a self-check",
|
|
19
|
+
flags: [["--allure", "also write allurerc.mjs and an empty .nukadoko/export/allure-results/ for nuka report --format allure"]]
|
|
20
|
+
},
|
|
21
|
+
"scaffold" => {
|
|
22
|
+
usage: "nuka scaffold [name]",
|
|
23
|
+
summary: "typed step template that fails until implemented",
|
|
24
|
+
flags: [
|
|
25
|
+
["--feature <path>", "a feature file or a directory of them: write one stub for each line nuka check calls undefined-step"],
|
|
26
|
+
["--pattern <text>", "the feature line text the step matches; each {key:type} capture becomes an args field"],
|
|
27
|
+
["--then", "a claim step for a Then line: claims in place of run, against a value the line states"],
|
|
28
|
+
["--command [entry point]", "a When step that runs a program in scratch.dir (or in --cwd's directory) and returns exitCode, stdout, and stderr"],
|
|
29
|
+
["--description <text>", "what the step does, written as its description; without it the description is a TODO nuka check reports"],
|
|
30
|
+
["--from <step>.<key>", "chain that key of an earlier step's returns into args; repeatable"],
|
|
31
|
+
["--cwd <key>", "with --command: run the program in the directory this args key holds"],
|
|
32
|
+
["--argv <key>", "with --command: split this string capture into argv elements on whitespace"],
|
|
33
|
+
["--request \"<METHOD> <path>\"", "a When step that sends one request and returns status and body"],
|
|
34
|
+
["--body <key>", "with --request: send this args key as the request's data"],
|
|
35
|
+
["--replace", "overwrite the step file while it is still, byte for byte, what scaffold writes; any other file is refused"]
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"check" => {
|
|
39
|
+
usage: "nuka check [feature..]",
|
|
40
|
+
summary: "static checks: pattern/schema mismatches, claim steps and where they are bound, undefined steps per feature, " \
|
|
41
|
+
"duplicate patterns, config coherence, and notes on unused declarations",
|
|
42
|
+
flags: [JSON_FLAG,
|
|
43
|
+
["--fail-on <code>", "exit 1 when a finding with this code is reported (repeatable, or comma-separated); the finding keeps its " \
|
|
44
|
+
"severity in the output, only the exit code changes. For a job that gates on one note, such as pattern-unbound"],
|
|
45
|
+
["--codes", "list every finding code nuka check can produce, with a one-line description, instead of checking a project"],
|
|
46
|
+
["--env <name>", "check as a nuka run with the same --env flags would run (repeatable)"]]
|
|
47
|
+
},
|
|
48
|
+
"run" => {
|
|
49
|
+
usage: "nuka run [feature..]",
|
|
50
|
+
summary: "check, then execute scenarios from a feature file or a directory of them (features/ when none is given); step records + run.json",
|
|
51
|
+
flags: [
|
|
52
|
+
["--no-check", "skip the check before executing, to run a scenario check refuses"],
|
|
53
|
+
["--env <name>", "target a named environment of the program in nukadoko.config.rb; repeat it to run each selected scenario once in each"],
|
|
54
|
+
["--tag <expression>", "run only the scenarios whose tags meet this expression, \"@name\" or \"not @name\"; repeat it, and a scenario has to meet every one"],
|
|
55
|
+
["--records", "write each scenario's run.json entry to stdout as one JSON line, as the scenario finishes"],
|
|
56
|
+
["--json", "print the run's result (run.json) on stdout as one JSON document, and no progress lines on stderr"],
|
|
57
|
+
["--concurrency <n>", "run n worker processes at once, one whole feature file per worker (default 1)"],
|
|
58
|
+
["--repeat <n>", "run every selected scenario n times in this one invocation (default 1)"],
|
|
59
|
+
["--proof-runs <n>", "run a control cell until the same claim in Then has broken at the same line this many times (default 2)"],
|
|
60
|
+
["--order file|shuffled[:<seed>]", "the order each environment's pass runs its scenarios in; shuffled:<seed> runs that order again"],
|
|
61
|
+
["--base <ref>", "compare each scenario with the commit a git ref names: new and changed criteria also run against the base's code"],
|
|
62
|
+
["--step", "walk one scenario one step at a time; follow it with nuka step wait"]
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"report" => {
|
|
66
|
+
usage: "nuka report [run]",
|
|
67
|
+
summary: "render a finished run as Markdown, Allure results, or a cucumber-messages stream, from its run directory alone",
|
|
68
|
+
flags: [
|
|
69
|
+
["--format markdown|allure|messages", "markdown: the run summary; allure: an allure-results directory; messages: a cucumber-messages NDJSON stream"],
|
|
70
|
+
["--out <path>", "where to write: a file for markdown and messages (stdout without it), a directory for allure"],
|
|
71
|
+
["--json", "print the result (run id, format, what was written) as one JSON document; needs --out for markdown and messages"]
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"verdict" => {
|
|
75
|
+
usage: "nuka verdict",
|
|
76
|
+
summary: "say whether the newest run judged the working tree as it is now and left nothing red; exits 1 when it did not, and never starts a run",
|
|
77
|
+
flags: [JSON_FLAG, ["--trailer", "print one git trailer line (Nukadoko-Verdict: ...) and exit 0 whatever it says, to stamp a commit"]]
|
|
78
|
+
},
|
|
79
|
+
"judge" => {
|
|
80
|
+
usage: "nuka judge <target>",
|
|
81
|
+
summary: "show the values a run read for a criterion whose Then asks for a judgment (<feature file>:<scenario line>), " \
|
|
82
|
+
"or record a judgment of them with --meets or --misses",
|
|
83
|
+
flags: [
|
|
84
|
+
["--run <id>", "the run whose records hold the values; the newest run that ended when omitted"],
|
|
85
|
+
["--meets", "record that each value meets the quality its sentence names"],
|
|
86
|
+
["--misses", "record that each value does not: the criterion fails until the value changes"],
|
|
87
|
+
["--by <who>", "who judged, as they name themselves"],
|
|
88
|
+
["--because <sentence>", "why the values meet or miss the sentence, in one sentence"],
|
|
89
|
+
JSON_FLAG
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
"steps" => {
|
|
93
|
+
usage: "nuka steps [feature..]",
|
|
94
|
+
summary: "list the vocabulary: name, patterns, description, mutates; with a target (a feature file, file:line, or directory), " \
|
|
95
|
+
"only the steps its lines bind and the steps those call through parts, each with the lines that bind it",
|
|
96
|
+
flags: [JSON_FLAG]
|
|
97
|
+
},
|
|
98
|
+
"describe" => { usage: "nuka describe <name>", summary: "full contract, schemas as JSON Schema", flags: [] },
|
|
99
|
+
"do" => {
|
|
100
|
+
usage: "nuka do <name>",
|
|
101
|
+
summary: "execute one typed step; step record to stdout",
|
|
102
|
+
flags: [
|
|
103
|
+
["--args <json>", "step arguments as a JSON object (may be omitted only when --use supplies every key)"],
|
|
104
|
+
["--env <name>", "target a named environment"],
|
|
105
|
+
["--use <record id>", "step record id whose result fills this step's from keys (repeatable)"]
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"step" => { usage: "nuka step", summary: "follow and answer a walk of nuka run --step, one pause at a time", flags: [] },
|
|
109
|
+
"clean" => {
|
|
110
|
+
usage: "nuka clean",
|
|
111
|
+
summary: "delete accumulated runs, do records, and what nuka report wrote under export/, in the state directory",
|
|
112
|
+
flags: [["--dry-run", "list what would be removed without removing it"], JSON_FLAG]
|
|
113
|
+
},
|
|
114
|
+
"skill" => { usage: "nuka skill", summary: "path the agent-facing skills' source directory", flags: [] },
|
|
115
|
+
"sig" => { usage: "nuka sig", summary: "write sig/nukadoko/steps.rbs, the RBS of each step's args and returns, for Steep", flags: [] }
|
|
116
|
+
}.freeze #: Hash[String, entry]
|
|
117
|
+
|
|
118
|
+
#: (String) -> String
|
|
119
|
+
def self.text(command)
|
|
120
|
+
entry = COMMANDS.fetch(command)
|
|
121
|
+
options = [["--help", "Show help"], *entry[:flags]] #: Array[[String, String]]
|
|
122
|
+
width = options.map { |flag, _| flag.length }.max || 0
|
|
123
|
+
lines = [entry[:usage], "", entry[:summary], "", "Options:"]
|
|
124
|
+
lines.concat(options.map { |flag, text| " #{flag.ljust(width)} #{text}" })
|
|
125
|
+
"#{lines.join("\n")}\n"
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|