@@ -15,13 +15,6 @@ using Pkg.Types: VersionTypes
1515using .. BinaryPlatforms
1616using .. Artifacts: artifact_paths
1717
18-
19- function preview_info (ctx:: Context )
20- if ctx. preview
21- printstyled (ctx. io, " ───── Preview mode ─────\n " ; color= Base. info_color (), bold= true )
22- end
23- end
24-
2518include (" generate.jl" )
2619
2720dependencies () = dependencies (Context ())
@@ -75,15 +68,12 @@ function develop(ctx::Context, pkgs::Vector{PackageSpec}; shared::Bool=true,
7568 pkgerror (" Can not specify version when tracking a repo." )
7669 end
7770
78- preview_info (ctx)
79-
8071 new_git = handle_repos_develop! (ctx, pkgs, shared)
8172
8273 any (pkg -> Types. collides_with_project (ctx, pkg), pkgs) &&
8374 pkgerror (" Cannot `develop` package with the same name or uuid as the project" )
8475
8576 Operations. develop (ctx, pkgs, new_git; strict= strict, platform= platform)
86- preview_info (ctx)
8777 return
8878end
8979
@@ -107,7 +97,6 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}; strict::Bool=false,
10797 end
10898 end
10999
110- preview_info (ctx)
111100 Types. update_registries (ctx)
112101
113102 repo_pkgs = [pkg for pkg in pkgs if (pkg. repo. url != = nothing || pkg. repo. rev != = nothing )]
@@ -124,7 +113,6 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}; strict::Bool=false,
124113 pkgerror (" Cannot add package with the same name or uuid as the project" )
125114
126115 Operations. add (ctx, pkgs, new_git; strict= strict, platform= platform)
127- preview_info (ctx)
128116 return
129117end
130118
@@ -147,14 +135,12 @@ function rm(ctx::Context, pkgs::Vector{PackageSpec}; mode=PKGMODE_PROJECT, kwarg
147135 end
148136
149137 Context! (ctx; kwargs... )
150- preview_info (ctx)
151138
152139 project_deps_resolve! (ctx, pkgs)
153140 manifest_resolve! (ctx, pkgs)
154141 ensure_resolved (ctx, pkgs)
155142
156143 Operations. rm (ctx, pkgs)
157- preview_info (ctx)
158144 return
159145end
160146
@@ -171,7 +157,6 @@ function up(ctx::Context, pkgs::Vector{PackageSpec};
171157 foreach (pkg -> pkg. mode = mode, pkgs)
172158
173159 Context! (ctx; kwargs... )
174- preview_info (ctx)
175160 if update_registry
176161 Types. clone_default_registries (ctx)
177162 Types. update_registries (ctx; force= true )
@@ -192,7 +177,6 @@ function up(ctx::Context, pkgs::Vector{PackageSpec};
192177 ensure_resolved (ctx, pkgs)
193178 end
194179 Operations. up (ctx, pkgs, level)
195- preview_info (ctx)
196180 return
197181end
198182
@@ -206,7 +190,6 @@ pin(pkgs::Vector{PackageSpec}; kwargs...) = pin(Context(), pkgs; k
206190function pin (ctx:: Context , pkgs:: Vector{PackageSpec} ; kwargs... )
207191 pkgs = deepcopy (pkgs) # deepcopy for avoid mutating PackageSpec members
208192 Context! (ctx; kwargs... )
209- preview_info (ctx)
210193
211194 for pkg in pkgs
212195 pkg. name != = nothing || pkg. uuid != = nothing ||
@@ -230,7 +213,6 @@ free(pkgs::Vector{PackageSpec}; kwargs...) = free(Context(), pkgs;
230213function free (ctx:: Context , pkgs:: Vector{PackageSpec} ; kwargs... )
231214 pkgs = deepcopy (pkgs) # deepcopy for avoid mutating PackageSpec members
232215 Context! (ctx; kwargs... )
233- preview_info (ctx)
234216
235217 for pkg in pkgs
236218 pkg. name != = nothing || pkg. uuid != = nothing ||
@@ -264,7 +246,6 @@ function test(ctx::Context, pkgs::Vector{PackageSpec};
264246 test_args = Cmd (test_args)
265247 pkgs = deepcopy (pkgs) # deepcopy for avoid mutating PackageSpec members
266248 Context! (ctx; kwargs... )
267- preview_info (ctx)
268249 if isempty (pkgs)
269250 ctx. env. pkg === nothing && pkgerror (" trying to test unnamed project" ) # TODO Allow this?
270251 push! (pkgs, ctx. env. pkg)
@@ -289,7 +270,6 @@ for a period of `collect_delay`; which defaults to thirty days.
289270"""
290271function gc (ctx:: Context = Context (); collect_delay:: Period = Day (30 ), kwargs... )
291272 Context! (ctx; kwargs... )
292- preview_info (ctx)
293273 env = ctx. env
294274
295275 # First, we load in our `manifest_usage.toml` files which will tell us when our
@@ -349,27 +329,25 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(30), kwargs...)
349329 all_index_files = Set (filter (isfile, all_index_files))
350330
351331 # Immediately write this back as condensed manifest_usage.toml files
352- if ! ctx. preview
353- function write_condensed_usage (usage_by_depot, fname)
354- for (depot, usage) in usage_by_depot
355- # Keep only the keys of the files that are still extant
356- usage = filter (p -> p[1 ] in all_index_files, usage)
357-
358- # Expand it back into a dict of arrays-of-dicts
359- usage = Dict (k => [Dict (" time" => v)] for (k, v) in usage)
360-
361- # Write it out to disk within this depot
362- usage_path = joinpath (logdir (depot), fname)
363- if ! isempty (usage) || isfile (usage_path)
364- open (usage_path, " w" ) do io
365- TOML. print (io, usage, sorted= true )
366- end
332+ function write_condensed_usage (usage_by_depot, fname)
333+ for (depot, usage) in usage_by_depot
334+ # Keep only the keys of the files that are still extant
335+ usage = filter (p -> p[1 ] in all_index_files, usage)
336+
337+ # Expand it back into a dict of arrays-of-dicts
338+ usage = Dict (k => [Dict (" time" => v)] for (k, v) in usage)
339+
340+ # Write it out to disk within this depot
341+ usage_path = joinpath (logdir (depot), fname)
342+ if ! isempty (usage) || isfile (usage_path)
343+ open (usage_path, " w" ) do io
344+ TOML. print (io, usage, sorted= true )
367345 end
368346 end
369347 end
370- write_condensed_usage (manifest_usage_by_depot, " manifest_usage.toml" )
371- write_condensed_usage (artifact_usage_by_depot, " artifact_usage.toml" )
372348 end
349+ write_condensed_usage (manifest_usage_by_depot, " manifest_usage.toml" )
350+ write_condensed_usage (artifact_usage_by_depot, " artifact_usage.toml" )
373351
374352 # Next, we will process the manifest.toml and artifacts.toml files separately,
375353 # extracting from them the paths of the packages and artifacts that they reference.
@@ -553,8 +531,8 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(30), kwargs...)
553531 merge_orphanages! (new_orphanage, depot_orphaned_packages, packages_to_delete, old_orphanage)
554532 merge_orphanages! (new_orphanage, depot_orphaned_artifacts, artifacts_to_delete, old_orphanage)
555533
556- # Write out the `new_orphanage` for this depot, if we're not in preview mode.
557- if ! ctx . preview && ( ! isempty (new_orphanage) || isfile (orphanage_file) )
534+ # Write out the `new_orphanage` for this depot
535+ if ! isempty (new_orphanage) || isfile (orphanage_file)
558536 mkpath (dirname (orphanage_file))
559537 open (orphanage_file, " w" ) do io
560538 TOML. print (io, new_orphanage, sorted= true )
@@ -586,12 +564,10 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(30), kwargs...)
586564 # Delete paths for unreachable package versions and artifacts, and computing size saved
587565 function delete_path (path)
588566 path_size = recursive_dir_size (path)
589- if ! ctx. preview
590- try
591- Base. rm (path; recursive= true )
592- catch
593- @warn " Failed to delete $path "
594- end
567+ try
568+ Base. rm (path; recursive= true )
569+ catch
570+ @warn " Failed to delete $path "
595571 end
596572 printpkgstyle (ctx, :Deleted , Types. pathrepr (path) * " (" * pretty_byte_str (path_size) * " )" )
597573 return path_size
@@ -607,18 +583,16 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(30), kwargs...)
607583 end
608584
609585 # Prune package paths that are now empty
610- if ! ctx. preview
611- for depot in depots ()
612- packagedir = abspath (depot, " packages" )
613- ! isdir (packagedir) && continue
586+ for depot in depots ()
587+ packagedir = abspath (depot, " packages" )
588+ ! isdir (packagedir) && continue
614589
615- for name in readdir (packagedir)
616- name_path = joinpath (packagedir, name)
617- ! isdir (name_path) && continue
618- ! isempty (readdir (name_path)) && continue
590+ for name in readdir (packagedir)
591+ name_path = joinpath (packagedir, name)
592+ ! isdir (name_path) && continue
593+ ! isempty (readdir (name_path)) && continue
619594
620- Base. rm (name_path)
621- end
595+ Base. rm (name_path)
622596 end
623597 end
624598
@@ -639,8 +613,6 @@ function gc(ctx::Context=Context(); collect_delay::Period=Day(30), kwargs...)
639613 printpkgstyle (ctx, :Deleted , " no artifacts or packages" )
640614 end
641615
642- preview_info (ctx)
643-
644616 return
645617end
646618
@@ -652,7 +624,6 @@ function build(ctx::Context, pkgs::Vector{PackageSpec}; verbose=false, kwargs...
652624 pkgs = deepcopy (pkgs) # deepcopy for avoid mutating PackageSpec members
653625 Context! (ctx; kwargs... )
654626
655- preview_info (ctx)
656627 if isempty (pkgs)
657628 if ctx. env. pkg != = nothing
658629 push! (pkgs, ctx. env. pkg)
@@ -667,7 +638,6 @@ function build(ctx::Context, pkgs::Vector{PackageSpec}; verbose=false, kwargs...
667638 manifest_resolve! (ctx, pkgs)
668639 ensure_resolved (ctx, pkgs)
669640 Operations. build (ctx, pkgs, verbose)
670- preview_info (ctx)
671641end
672642
673643precompile () = precompile (Context ())
0 commit comments