Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Jul 5, 2024
1 parent af113dc commit af34836
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ext/REPLExt/completions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ end

# TODO: Move
import Pkg: Operations, Types, Apps
function complete_installed_apps(options, partial)
function complete_installed_apps(options, partial; hint)
manifest = try
Types.read_manifest(joinpath(Apps.APP_ENV_FOLDER, "AppManifest.toml"))
catch err
Expand Down
21 changes: 10 additions & 11 deletions src/Apps/Apps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Apps
using Pkg
using Pkg.Types: AppInfo, PackageSpec, Context, EnvCache, PackageEntry, handle_repo_add!, handle_repo_develop!, write_manifest, write_project,
pkgerror
using Pkg.Operations: print_single, source_path
using Pkg.Operations: print_single, source_path, update_package_add
using Pkg.API: handle_package_input!
using TOML, UUIDs
import Pkg.Registry
Expand All @@ -21,9 +21,9 @@ const XDG_BIN_PATH = joinpath(homedir(), ".local", "bin")
# Helper Methods #
##################

function rm_julia_and_xdg_bin(name; kwargs)
function rm_julia_and_xdg_bin(name; kwargs...)
Base.rm(joinpath(JULIA_BIN_PATH, name); kwargs...)
Base.rm(joinpath(XDG_BIN_PATH, name); kwargs...)
# Base.rm(joinpath(XDG_BIN_PATH, name); kwargs...)
end

function handle_project_file(sourcepath)
Expand All @@ -43,6 +43,7 @@ end

function overwrite_if_different(file, content)
if !isfile(file) || read(file, String) != content
mkpath(dirname(file))
open(file, "w") do f
write(f, content)
end
Expand Down Expand Up @@ -103,7 +104,7 @@ function add(pkg::PackageSpec)
new = false
if pkg.repo.source !== nothing || pkg.repo.rev !== nothing
entry = Pkg.API.manifest_info(ctx.env.manifest, pkg.uuid)
pkg = Pkg.Operations.update_package_add(ctx, pkg, entry, false)
pkg = update_package_add(ctx, pkg, entry, false)
new = handle_repo_add!(ctx, pkg)
else
pkgs = [pkg]
Expand All @@ -117,7 +118,8 @@ function add(pkg::PackageSpec)

sourcepath = source_path(ctx.env.manifest_file, pkg)
project = handle_project_file(sourcepath)
project.path = sourcepath
# TODO: Wrong if package itself has a sourcepath?
project.entryfile = joinpath(sourcepath, "src", "$(project.name).jl")

# TODO: Type stab
# appdeps = get(project, "appdeps", Dict())
Expand Down Expand Up @@ -204,12 +206,7 @@ function status(pkg_or_app::Union{PackageSpec, Nothing}=nothing)

printstyled("[", string(dep.uuid)[1:8], "] "; color = :light_black)
print_single(stdout, dep)
single_app = length(info.apps) == 1
if !single_app
println()
else
print(":")
end
println()
for (appname, appinfo) in info.apps
if !is_pkg && pkg_or_app !== nothing && appname !== pkg_or_app
continue
Expand Down Expand Up @@ -313,10 +310,12 @@ function generate_shim(app::AppInfo, pkgname; julia_executable_path::String=join
# TODO: Only overwrite if app is "controlled" by Julia?
overwrite_if_different(julia_bin_filename, content)
if Sys.isunix()
#=
if isdir(XDG_BIN_PATH) && !isfile(joinpath(XDG_BIN_PATH, filename))
# TODO: Verify that this symlink is in fact pointing to the correct file.
symlink(julia_bin_filename, joinpath(XDG_BIN_PATH, filename))
end
=#
chmod(julia_bin_filename, 0o755)
end
end
Expand Down
7 changes: 3 additions & 4 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1347,8 +1347,8 @@ function rm(ctx::Context, pkgs::Vector{PackageSpec}; mode::PackageMode)
show_update(ctx.env, ctx.registries; io=ctx.io)
end

update_package_add(ctx::Context, pkg::PackageSpec, ::Nothing, source_path, source_repo, is_dep::Bool) = pkg
function update_package_add(ctx::Context, pkg::PackageSpec, entry::PackageEntry, source_path, source_repo, is_dep::Bool)
update_package_add(ctx::Context, pkg::PackageSpec, ::Nothing, is_dep::Bool) = pkg
function update_package_add(ctx::Context, pkg::PackageSpec, entry::PackageEntry, is_dep::Bool)
if entry.pinned
if pkg.version == VersionSpec()
println(ctx.io, "`$(pkg.name)` is pinned at `v$(entry.version)`: maintaining pinned version")
Expand Down Expand Up @@ -1492,8 +1492,7 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=Set{UUID}();
delete!(ctx.env.project.weakdeps, pkg.name)
entry = manifest_info(ctx.env.manifest, pkg.uuid)
is_dep = any(uuid -> uuid == pkg.uuid, [uuid for (name, uuid) in ctx.env.project.deps])
source_path, source_repo = get_path_repo(ctx.env.project, pkg.name)
pkgs[i] = update_package_add(ctx, pkg, entry, source_path, source_repo, is_dep)
pkgs[i] = update_package_add(ctx, pkg, entry, is_dep)
end

names = (p.name for p in pkgs)
Expand Down

0 comments on commit af34836

Please sign in to comment.