@@ -5,7 +5,7 @@ module Geode::Commands
55 @summary = " install dependencies from shard.yml"
66 @description = <<-DESC
77 Installs dependencies from a shard.yml file. This includes development dependencies
8- unless you include the '--production' flag.
8+ unless you specify the '--production' flag.
99 DESC
1010
1111 add_usage " install [-D|--without-development] [-E|--skip-executables] [--frozen]" \
@@ -47,95 +47,33 @@ module Geode::Commands
4747 def run (arguments : Cling ::Arguments , options : Cling ::Options ) : Nil
4848 ensure_local_shard!
4949
50- shards = Process .find_executable " shards"
51- fatal(
52- " Could not find the Shards executable" ,
53- " (wrapped around for dependency resolution)" ,
54- ) unless shards
55-
56- args = %w[install --skip-executables --skip-postinstall]
57- args << " --frozen" if options.has? " frozen"
58- args << " --no-color" if options.has? " no-color"
59- if value = options.get?(" jobs" ).try & .as_i
60- args << " --jobs=#{ value } "
61- end
62- args << " --local" if options.has? " local"
63- args << " --production" if options.has? " production"
64- args << " --without-development" if options.has? " without-development"
65-
66- start = Time .monotonic
67- deps = [] of String
68-
69- Process .run(shards, args) do |proc |
70- while message = proc.output.gets
71- if message.includes?(" Installing" ) || message.includes?(" Using" )
72- deps << message.split(' ' , 3 )[1 ]
73- end
74- puts message
75- end
76- puts
77- end
50+ reader, writer = IO .pipe(write_blocking: true )
51+ Shards ::Log .backend = ::Log ::IOBackend .new writer
7852
79- if $? .success?
80- if deps.empty? || (options.has?(" skip-executables" ) && options.has?(" skip-postinstall" ))
81- success " Install completed in #{ format_time(Time .monotonic - start) } "
82- return
83- end
53+ if options.has? " production"
54+ Shards .frozen = true
55+ Shards .with_development = false
8456 else
85- fatal " Install failed (#{ format_time(Time .monotonic - start) } )"
57+ Shards .frozen = options.has? " frozen"
58+ Shards .with_development = ! options.has?(" without-development" )
8659 end
8760
88- shards = [] of Shard
89- Dir .each_child( " lib " ) do | child |
90- next if child.starts_with? '.'
91- next unless Shard .exists? child
61+ Shards .skip_executables = options.has? " skip-executables "
62+ Shards .jobs = options.get( " jobs " ).to_i32 if options.has?( " jobs " )
63+ Shards .local = options.has? " local "
64+ Shards .skip_postinstall = options.has? " skip-postinstall "
9265
93- shards << Shard .load child
94- rescue YAML ::ParseException
95- warn " Failed to parse shard.yml contents for '#{ child } '"
96- end
97-
98- unless options.has? " skip-postinstall"
99- shards.select(& .has_postinstall?).each do |shard |
100- if script = shard.find_target_script " postinstall" , Geode ::HOST_PLATFORM
101- run_postinstall shard.name, script
102- else
103- warn " No postinstall script available for this platform"
104- end
105- end
106- end
107-
108- unless options.has? " skip-executables"
109- Dir .mkdir_p " bin"
110-
111- shards.reject(& .executables.empty?).each do |shard |
112- shard.executables.each do |exe |
113- src = Path [" lib" ] / shard.name / " bin" / exe
114-
115- {% if flag?(:win32 ) % }
116- unless File .exists?(src) || exe.ends_with?(" .exe" )
117- src = Path [src.basename, exe + " .exe" ]
118- end
119- {% end % }
120-
121- unless File .exists? src
122- warn " Executable '#{ exe } ' not found for #{ shard.name } "
123- next
124- end
125-
126- dest = Path [" bin" , exe].expand
127- unless File .exists? dest
128- begin
129- File .copy src, dest
130- info " Added executable '#{ exe } '"
131- rescue
132- error " Failed to link #{ shard.name } executable '#{ exe } '"
133- end
134- end
66+ spawn do
67+ while input = reader.gets
68+ if input.starts_with? " Fetching"
69+ uri = URI .parse input.split(' ' )[1 ]
70+ stdout << " • " << uri.path << " (" << uri.hostname << " )\n "
13571 end
13672 end
13773 end
13874
75+ start = Time .monotonic
76+ Shards ::Commands ::WrapInstall .new(stdout, stderr).run
13977 success " Install completed in #{ format_time(Time .monotonic - start) } "
14078 end
14179
0 commit comments