Class: Foobara::RemoteGenerator::WriteTypescriptToDisk
Constant Summary
TruncatedInspect::MAX_LENGTH
Instance Attribute Summary
#paths_to_source_code
Class Method Summary
collapse
Instance Method Summary
collapse
#delete_old_files_if_needed, #generate_generated_files_json, #generated_files_json_filename, #run_cmd_and_return_output, #run_cmd_and_write_output, #stats, #write_all_files_to_disk, #write_file_to_disk
Methods inherited from Command
install!
#inspect, truncating
Methods included from Concern
foobara_class_methods_module_for, foobara_concern?, included
Class Method Details
.generator_key ⇒ Object
6
|
# File 'src/write_typescript_to_disk.rb', line 6
def self.generator_key = "typescript-remote-commands"
|
Instance Method Details
#eslint_fix ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'src/write_typescript_to_disk.rb', line 69
def eslint_fix
cmd = "npx eslint 'src/**/*.{js,jsx,ts,tsx}' --fix"
Open3.popen3(cmd) do |_stdin, stdout, stderr, wait_thr|
exit_status = wait_thr.value
unless exit_status.success?
out = stdout.read
err = stderr.read
if fail_if_does_not_pass_linter?
add_runtime_error :failed_to_lint, stdout: out, stderr: err
else
warn "WARNING: could not #{cmd}\n#{out}\n#{err}"
end
end
end
end
|
#execute ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'src/write_typescript_to_disk.rb', line 29
def execute
generate_typescript
generate_generated_files_json
delete_old_files_if_needed
write_all_files_to_disk
run_post_generation_tasks
stats
end
|
#fail_if_does_not_pass_linter? ⇒ Boolean
90
|
# File 'src/write_typescript_to_disk.rb', line 90
def fail_if_does_not_pass_linter? = fail_if_does_not_pass_linter
|
#generate_typescript ⇒ Object
53
54
55
56
57
58
59
60
61
|
# File 'src/write_typescript_to_disk.rb', line 53
def generate_typescript
inputs = raw_manifest ? { raw_manifest: } : { manifest_url: }
inputs[:auto_dirty_queries] = auto_dirty_queries
inputs[:no_foobara_auth] = no_foobara_auth
self.paths_to_source_code = run_subcommand!(GenerateTypescript, inputs)
end
|
#run_post_generation_tasks ⇒ Object
63
64
65
66
67
|
# File 'src/write_typescript_to_disk.rb', line 63
def run_post_generation_tasks
Dir.chdir(project_directory || output_directory) do
eslint_fix
end
end
|
#validate ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'src/write_typescript_to_disk.rb', line 39
def validate
if raw_manifest.nil? && manifest_url.nil?
add_runtime_error(symbol: :missing_manifest, message: "Must provide either raw_manifest or manifest_url")
end
end
|