Skip to content

Commit 831ba6d

Browse files
committed
Allow using non-absolute command names
1 parent 7c77690 commit 831ba6d

5 files changed

Lines changed: 61 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.1.1] - 2025-10-05
2+
3+
- Allow using non-absolute command names
4+
15
## [1.1.0] - 2025-08-22
26

37
- Handle new Foobara 0.1.0 type declarations

Gemfile.lock

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
PATH
22
remote: .
33
specs:
4-
foobara-typescript-react-command-form-generator (1.1.0)
4+
foobara-typescript-react-command-form-generator (1.1.1)
55
foobara (>= 0.1.1, < 2.0.0)
66
foobara-typescript-remote-command-generator (< 2.0.0)
77

88
GEM
99
remote: https://rubygems.org/
1010
specs:
1111
ast (2.4.3)
12-
bigdecimal (3.2.2)
12+
bigdecimal (3.2.3)
1313
byebug (12.0.0)
1414
coderay (1.1.3)
1515
diff-lcs (1.6.2)
1616
docile (1.4.1)
1717
ffi (1.17.2-x86_64-linux-gnu)
18-
foobara (0.1.7)
18+
foobara (0.1.15)
1919
bigdecimal
2020
foobara-lru-cache (< 2.0.0)
2121
foobara-util (< 2.0.0)
2222
inheritable-thread-vars (< 2.0.0)
2323
foobara-files-generator (0.1.0)
2424
foobara (>= 0.1.1, < 2.0.0)
2525
foobara-lru-cache (1.0.0)
26-
foobara-rubocop-rules (1.0.1)
26+
foobara-rubocop-rules (1.0.3)
2727
rubocop
2828
rubocop-rspec
2929
foobara-spec-helpers (0.0.4)
3030
foobara-util
31-
foobara-typescript-remote-command-generator (1.1.1)
32-
foobara (>= 0.1.4, < 2.0.0)
31+
foobara-typescript-remote-command-generator (1.1.4)
32+
foobara (>= 0.1.14, < 2.0.0)
3333
foobara-files-generator (< 2.0.0)
34-
foobara-util (1.0.2)
35-
formatador (1.2.0)
34+
foobara-util (1.0.3)
35+
formatador (1.2.1)
3636
reline
3737
guard (2.19.1)
3838
formatador (>= 0.2.4)
@@ -52,14 +52,14 @@ GEM
5252
rspec (>= 2.99.0, < 4.0)
5353
inheritable-thread-vars (0.0.3)
5454
io-console (0.8.1)
55-
json (2.13.2)
55+
json (2.15.0)
5656
language_server-protocol (3.17.0.5)
5757
lint_roller (1.1.0)
5858
listen (3.9.0)
5959
rb-fsevent (~> 0.10, >= 0.10.3)
6060
rb-inotify (~> 0.9, >= 0.9.10)
6161
logger (1.7.0)
62-
lumberjack (1.4.0)
62+
lumberjack (1.4.2)
6363
method_source (1.1.0)
6464
nenv (0.3.0)
6565
notiffany (0.1.3)
@@ -70,7 +70,7 @@ GEM
7070
parser (3.3.9.0)
7171
ast (~> 2.4.1)
7272
racc
73-
prism (1.4.0)
73+
prism (1.5.1)
7474
pry (0.15.2)
7575
coderay (~> 1.1)
7676
method_source (~> 1.0)
@@ -83,7 +83,7 @@ GEM
8383
rb-fsevent (0.11.2)
8484
rb-inotify (0.11.1)
8585
ffi (~> 1.0)
86-
regexp_parser (2.11.2)
86+
regexp_parser (2.11.3)
8787
reline (0.6.2)
8888
io-console (~> 0.5)
8989
rspec (3.13.1)
@@ -101,25 +101,25 @@ GEM
101101
rspec-mocks (3.13.5)
102102
diff-lcs (>= 1.2.0, < 2.0)
103103
rspec-support (~> 3.13.0)
104-
rspec-support (3.13.5)
105-
rubocop (1.80.0)
104+
rspec-support (3.13.6)
105+
rubocop (1.81.1)
106106
json (~> 2.3)
107107
language_server-protocol (~> 3.17.0.2)
108108
lint_roller (~> 1.1.0)
109109
parallel (~> 1.10)
110110
parser (>= 3.3.0.2)
111111
rainbow (>= 2.2.2, < 4.0)
112112
regexp_parser (>= 2.9.3, < 3.0)
113-
rubocop-ast (>= 1.46.0, < 2.0)
113+
rubocop-ast (>= 1.47.1, < 2.0)
114114
ruby-progressbar (~> 1.7)
115115
unicode-display_width (>= 2.4.0, < 4.0)
116-
rubocop-ast (1.46.0)
116+
rubocop-ast (1.47.1)
117117
parser (>= 3.3.7.2)
118118
prism (~> 1.4)
119119
rubocop-rake (0.7.1)
120120
lint_roller (~> 1.1)
121121
rubocop (>= 1.72.1)
122-
rubocop-rspec (3.6.0)
122+
rubocop-rspec (3.7.0)
123123
lint_roller (~> 1.1)
124124
rubocop (~> 1.72, >= 1.72.1)
125125
ruby-progressbar (1.13.0)
@@ -131,9 +131,9 @@ GEM
131131
simplecov-html (0.13.2)
132132
simplecov_json_formatter (0.1.4)
133133
thor (1.4.0)
134-
unicode-display_width (3.1.5)
135-
unicode-emoji (~> 4.0, >= 4.0.4)
136-
unicode-emoji (4.0.4)
134+
unicode-display_width (3.2.0)
135+
unicode-emoji (~> 4.1)
136+
unicode-emoji (4.1.0)
137137

138138
PLATFORMS
139139
x86_64-linux

spec/write_typescript_react_command_form_to_disk_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727
).to include("const [firstName, setFirstName] = useState<string | undefined>(undefined)")
2828
end
2929

30+
context "with a partial command name" do
31+
let(:command_name) { "CommandWithDomainButNoOrg" }
32+
33+
it "is success" do
34+
expect(outcome).to be_success
35+
expect(
36+
command.paths_to_source_code.keys
37+
).to include("forms/SomeDomainWithoutOrg/CommandWithDomainButNoOrgForm.tsx")
38+
end
39+
end
40+
3041
context "without a manifest or url" do
3142
let(:raw_manifest) { nil }
3243

src/generate_typescript_react_command_form.rb

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,32 @@ def find_command_manifest
4343
self.command_manifest = Manifest::Command.new(manifest_data, [:command, command_name])
4444
rescue Manifest::InvalidPath
4545
valid_keys = manifest_data["command"].keys.sort
46-
message = "Invalid command name: #{command_name}. Expected one of #{valid_keys.join(", ")}"
47-
error = BadCommandNameError.new(
48-
message:,
49-
context: {
50-
bad_name: command_name,
51-
valid_names: valid_keys
52-
},
53-
path: [:command_name]
54-
)
5546

56-
add_input_error(error)
57-
halt!
47+
suffix = command_name
48+
49+
unless suffix.start_with?("::")
50+
suffix = "::#{suffix}"
51+
end
52+
53+
matching_command_names = valid_keys.select { |key| key.end_with?(suffix) }
54+
55+
if matching_command_names.size == 1
56+
best_command_name = matching_command_names.first
57+
self.command_manifest = Manifest::Command.new(manifest_data, [:command, best_command_name])
58+
else
59+
message = "Invalid command name: #{command_name}. Expected one of #{valid_keys.join(", ")}"
60+
error = BadCommandNameError.new(
61+
message:,
62+
context: {
63+
bad_name: command_name,
64+
valid_names: valid_keys
65+
},
66+
path: [:command_name]
67+
)
68+
69+
add_input_error(error)
70+
halt!
71+
end
5872
end
5973

6074
def add_command_manifest_to_set_of_elements_to_generate

version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Foobara
22
module Generators
33
module TypescriptReactCommandFormGenerator
4-
VERSION = "1.1.0".freeze
4+
VERSION = "1.1.1".freeze
55
MINIMUM_RUBY_VERSION = ">= 3.4.0".freeze
66
end
77
end

0 commit comments

Comments
 (0)