@@ -111,7 +111,6 @@ function _resolve(manifest::Manifest, pkgname=nothing)
111111 # TODO : Julia path
112112 generate_shims_for_apps (pkg. name, pkg. apps, dirname (projectfile), joinpath (Sys. BINDIR, " julia" ))
113113 end
114-
115114 write_manifest (manifest, app_manifest_file ())
116115end
117116
@@ -145,10 +144,12 @@ function add(pkg::PackageSpec)
145144 new = Pkg. Operations. download_source (ctx, pkgs)
146145 end
147146
147+ # Run Pkg.build()?
148+
149+ Base. rm (joinpath (app_env_folder (), pkg. name); force= true , recursive= true )
148150 sourcepath = source_path (ctx. env. manifest_file, pkg)
149151 project = get_project (sourcepath)
150152 # TODO : Wrong if package itself has a sourcepath?
151-
152153 entry = PackageEntry (;apps = project. apps, name = pkg. name, version = project. version, tree_hash = pkg. tree_hash, path = pkg. path, repo = pkg. repo, uuid= pkg. uuid)
153154 manifest. deps[pkg. uuid] = entry
154155
@@ -193,6 +194,50 @@ function develop(pkg::PackageSpec)
193194 @info " For package: $(pkg. name) installed apps: $(join (keys (project. apps), " ," )) "
194195end
195196
197+
198+ update (pkgs_or_apps:: String ) = update ([pkgs_or_apps])
199+ function update (pkgs_or_apps:: Vector )
200+ for pkg_or_app in pkgs_or_apps
201+ if pkg_or_app isa String
202+ pkg_or_app = PackageSpec (pkg_or_app)
203+ end
204+ update (pkg_or_app)
205+ end
206+ end
207+
208+ function update (pkg:: Union{PackageSpec, Nothing} = nothing )
209+ ctx = app_context ()
210+ manifest = ctx. env. manifest
211+ deps = Pkg. Operations. load_manifest_deps (manifest)
212+ for dep in deps
213+ info = manifest. deps[dep. uuid]
214+ if pkg === nothing || info. name != = pkg. name
215+ continue
216+ end
217+ Pkg. activate (joinpath (app_env_folder (), info. name)) do
218+ # precompile only after updating all apps?
219+ if pkg != = nothing
220+ Pkg. update (pkg)
221+ else
222+ Pkg. update ()
223+ end
224+ end
225+ sourcepath = abspath (source_path (ctx. env. manifest_file, info))
226+ project = get_project (sourcepath)
227+ # Get the tree hash from the project file
228+ manifest_file = manifestfile_path (joinpath (app_env_folder (), info. name))
229+ manifest_app = Pkg. Types. read_manifest (manifest_file)
230+ manifest_entry = manifest_app. deps[info. uuid]
231+
232+ entry = PackageEntry (;apps = project. apps, name = manifest_entry. name, version = manifest_entry. version, tree_hash = manifest_entry. tree_hash,
233+ path = manifest_entry. path, repo = manifest_entry. repo, uuid = manifest_entry. uuid)
234+
235+ manifest. deps[dep. uuid] = entry
236+ Pkg. Types. write_manifest (manifest, app_manifest_file ())
237+ end
238+ return
239+ end
240+
196241function status (pkgs_or_apps:: Vector )
197242 if isempty (pkgs_or_apps)
198243 status ()
257302
258303
259304function require_not_empty (pkgs, f:: Symbol )
260-
261- if pkgs == nothing || isempty (pkgs)
305+ if pkgs === nothing || isempty (pkgs)
262306 pkgerror (" app $f requires at least one package" )
263307 end
264308end
@@ -306,7 +350,7 @@ function rm(pkg_or_app::Union{PackageSpec, Nothing}=nothing)
306350 end
307351 end
308352 end
309-
353+ # XXX : What happens if something fails above and we do not write out the updated manifest?
310354 Pkg. Types. write_manifest (manifest, app_manifest_file ())
311355 return
312356end
0 commit comments