Skip to content

Commit

Permalink
Some Pkg tweaks (#1292)
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp authored Jul 6, 2021
1 parent bfc398a commit 163b7ce
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 49 deletions.
6 changes: 2 additions & 4 deletions frontend/components/CellInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import _ from "../imports/lodash.js"
import { utf8index_to_ut16index } from "../common/UnicodeTools.js"
import { has_ctrl_or_cmd_pressed, map_cmd_to_ctrl_on_mac } from "../common/KeyboardShortcuts.js"
import { PlutoContext } from "../common/PlutoContext.js"
import { nbpkg_fingerprint, PkgStatusMark, PkgActivateMark } from "./PkgStatusMark.js"
import { nbpkg_fingerprint, PkgStatusMark, PkgActivateMark, pkg_disablers } from "./PkgStatusMark.js"

//@ts-ignore
import { mac, chromeOS } from "https://cdn.jsdelivr.net/gh/codemirror/CodeMirror@5.60.0/src/util/browser.js"
Expand Down Expand Up @@ -158,9 +158,7 @@ export const CellInput = ({
}
}

const disablers = ["Pkg.activate(", "Pkg.API.activate(", "Pkg.develop(", "Pkg.API.develop(", "Pkg.add(", "Pkg.API.add("]

const match = _.find(disablers, (f_name) => line.includes(f_name))
const match = _.find(pkg_disablers, (f_name) => line.includes(f_name))
if (match != null) {
// if the widget already exists, keep it, if not, create a new one
const widget = get(pkg_bubbles.current, `disable-pkg-${match}-${line_i}`, () =>
Expand Down
13 changes: 13 additions & 0 deletions frontend/components/PkgStatusMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,16 @@ export const PkgActivateMark = ({ package_name, refresh_cm }) => {

return node
}

// This list appears multiple times in our codebase. Be sure to match edits everywhere.
export const pkg_disablers = [
"Pkg.activate(",
"Pkg.API.activate(",
"Pkg.develop(",
"Pkg.API.develop(",
"Pkg.add(",
"Pkg.API.add(",
// https://juliadynamics.github.io/DrWatson.jl/dev/project/#DrWatson.quickactivate
"quickactivate(",
"@quickactivate",
]
8 changes: 4 additions & 4 deletions sample/JavaScript.jl
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,8 @@ HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
[compat]
HypertextLiteral = "^0.7.0"
PlutoUI = "^0.7.9"
HypertextLiteral = "~0.8.0"
PlutoUI = "~0.7.9"
"""

# ╔═╡ 00000000-0000-0000-0000-000000000002
Expand All @@ -1012,9 +1012,9 @@ deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
[[HypertextLiteral]]
git-tree-sha1 = "3cd97ad41c50d81e698ec625d52753556cab994e"
git-tree-sha1 = "1e3ccdc7a6f7b577623028e0095479f4727d8ec1"
uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
version = "0.7.0"
version = "0.8.0"
[[InteractiveUtils]]
deps = ["Markdown"]
Expand Down
58 changes: 29 additions & 29 deletions sample/Plots.jl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ Try changing the function for the base plot, or the addition in the bottom cell.

# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[compat]
Plots = "~1.16.4"
[deps]
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
[compat]
Plots = "~1.18.0"
"""

# ╔═╡ 00000000-0000-0000-0000-000000000002
Expand Down Expand Up @@ -269,9 +269,9 @@ version = "0.12.8"
[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "e4e2b39db08f967cc1360951f01e8a75ec441cab"
git-tree-sha1 = "dc7dedc2c2aa9faf59a55c622760a25cbefbe941"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.30.0"
version = "3.31.0"
[[CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
Expand All @@ -284,9 +284,9 @@ uuid = "d38c429a-6771-53c6-b99e-75d170b6e991"
version = "0.5.7"
[[DataAPI]]
git-tree-sha1 = "dfb3b7e89e395be1e25c2ad6d7690dc29cc53b1d"
git-tree-sha1 = "ee400abb2298bd13bfc3df1c412ed228061a2385"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.6.0"
version = "1.7.0"
[[DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
Expand Down Expand Up @@ -389,9 +389,9 @@ version = "0.57.3+0"
[[GeometryBasics]]
deps = ["EarCut_jll", "IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"]
git-tree-sha1 = "4136b8a5668341e58398bb472754bff4ba0456ff"
git-tree-sha1 = "15ff9a14b9e1218958d3530cc288cf31465d9ae2"
uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
version = "0.3.12"
version = "0.3.13"
[[Gettext_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "XML2_jll"]
Expand All @@ -411,10 +411,10 @@ uuid = "42e2da0e-8278-4e71-bc24-59509adca0fe"
version = "1.0.2"
[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "MbedTLS", "NetworkOptions", "Sockets", "URIs"]
git-tree-sha1 = "86ed84701fbfd1142c9786f8e53c595ff5a4def9"
deps = ["Base64", "Dates", "IniFile", "Logging", "MbedTLS", "NetworkOptions", "Sockets", "URIs"]
git-tree-sha1 = "c6a1fff2fd4b1da29d3dccaffb1e1001244d844e"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.9.10"
version = "0.9.12"
[[IniFile]]
deps = ["Test"]
Expand Down Expand Up @@ -528,9 +528,9 @@ version = "1.42.0+0"
[[Libiconv_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "8d22e127ea9a0917bc98ebd3755c8bd31989381e"
git-tree-sha1 = "42b62845d70a619f063a7da093d995ec8e15e778"
uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
version = "1.16.1+0"
version = "1.16.1+1"
[[Libmount_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand Down Expand Up @@ -655,15 +655,15 @@ version = "2.0.1"
[[PlotUtils]]
deps = ["ColorSchemes", "Colors", "Dates", "Printf", "Random", "Reexport", "Statistics"]
git-tree-sha1 = "ae9a295ac761f64d8c2ec7f9f24d21eb4ffba34d"
git-tree-sha1 = "501c20a63a34ac1d015d5304da0e645f42d91c9f"
uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043"
version = "1.0.10"
version = "1.0.11"
[[Plots]]
deps = ["Base64", "Contour", "Dates", "FFMPEG", "FixedPointNumbers", "GR", "GeometryBasics", "JSON", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "PlotThemes", "PlotUtils", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "Requires", "Scratch", "Showoff", "SparseArrays", "Statistics", "StatsBase", "UUIDs"]
git-tree-sha1 = "e69bc8f4728cb6db3ac16e728dc52f9e5ab722b9"
git-tree-sha1 = "9f126950870ef24ce75cdd841f4b7cf34affc6d2"
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
version = "1.16.4"
version = "1.18.0"
[[Preferences]]
deps = ["TOML"]
Expand Down Expand Up @@ -696,9 +696,9 @@ version = "1.1.1"
[[RecipesPipeline]]
deps = ["Dates", "NaNMath", "PlotUtils", "RecipesBase"]
git-tree-sha1 = "7a5026a6741c14147d1cb6daf2528a77ca28eb51"
git-tree-sha1 = "9b8e57e3cca8828a1bc759840bfe48d64db9abfb"
uuid = "01d81517-befc-4cb6-b9ec-a95719d0359c"
version = "0.3.2"
version = "0.3.3"
[[Reexport]]
git-tree-sha1 = "5f6c21241f0f655da3952fd60aa18477cf96c220"
Expand Down Expand Up @@ -748,9 +748,9 @@ uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "42378d3bab8b4f57aa1ca443821b752850592668"
git-tree-sha1 = "896d55218776ab8f23fb7b222a5a4a946d4aafc2"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.2.2"
version = "1.2.5"
[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
Expand All @@ -768,10 +768,10 @@ uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.33.8"
[[StructArrays]]
deps = ["Adapt", "DataAPI", "Tables"]
git-tree-sha1 = "44b3afd37b17422a62aea25f04c1f7e09ce6b07f"
deps = ["Adapt", "DataAPI", "StaticArrays", "Tables"]
git-tree-sha1 = "000e168f5cc9aded17b6999a560b7c11dda69095"
uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
version = "0.5.1"
version = "0.6.0"
[[TOML]]
deps = ["Dates"]
Expand All @@ -785,9 +785,9 @@ version = "1.0.1"
[[Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "aa30f8bb63f9ff3f8303a06c604c8500a69aa791"
git-tree-sha1 = "8ed4a3ea724dac32670b062be3ef1c1de6773ae8"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.4.3"
version = "1.4.4"
[[Tar]]
deps = ["ArgTools", "SHA"]
Expand All @@ -811,9 +811,9 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
[[Wayland_jll]]
deps = ["Artifacts", "Expat_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Pkg", "XML2_jll"]
git-tree-sha1 = "dc643a9b774da1c2781413fd7b6dcd2c56bb8056"
git-tree-sha1 = "3e61f0b86f90dacb0bc0e73a0c5a83f6a8636e23"
uuid = "a2964d1f-97da-50d4-b82a-358c7fce9d89"
version = "1.17.0+4"
version = "1.19.0+0"
[[Wayland_protocols_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Wayland_jll"]
Expand Down
2 changes: 1 addition & 1 deletion sample/PlutoUI.jl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ PLUTO_PROJECT_TOML_CONTENTS = """
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
[compat]
PlutoUI = "^0.7.9"
PlutoUI = "~0.7.9"
"""

# ╔═╡ 00000000-0000-0000-0000-000000000002
Expand Down
5 changes: 4 additions & 1 deletion src/analysis/topological_order.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ function cell_precedence_heuristic(topology::NotebookTopology, cell::Cell)::Real
1
elseif Symbol("Pkg.API.activate") top.references ||
Symbol("Pkg.activate") top.references ||
Symbol("@pkg_str") top.references
Symbol("@pkg_str") top.references ||
# https://juliadynamics.github.io/DrWatson.jl/dev/project/#DrWatson.quickactivate
Symbol("quickactivate") top.references ||
Symbol("@quickactivate") top.references
2
elseif Symbol("Pkg.API.add") top.references ||
Symbol("Pkg.add") top.references ||
Expand Down
2 changes: 1 addition & 1 deletion src/notebook/Notebook.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function save_notebook(io, notebook::Notebook)
ptoml_contents = isfile(ptoml_path) ? read(ptoml_path, String) : ""
mtoml_contents = isfile(mtoml_path) ? read(mtoml_path, String) : ""

!isempty(ptoml_contents) || !isempty(mtoml_contents)
!isempty(strip(ptoml_contents))
else
false
end
Expand Down
9 changes: 7 additions & 2 deletions src/packages/Packages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ const tiers = [

const pkg_token = Token()


# This list appears multiple times in our codebase. Be sure to match edits everywhere.
function use_plutopkg(topology::NotebookTopology)
!any(values(topology.nodes)) do node
Symbol("Pkg.activate") node.references ||
Symbol("Pkg.API.activate") node.references ||
Symbol("Pkg.develop") node.references ||
Symbol("Pkg.API.develop") node.references ||
Symbol("Pkg.add") node.references ||
Symbol("Pkg.API.add") node.references
Symbol("Pkg.API.add") node.references ||
# https://juliadynamics.github.io/DrWatson.jl/dev/project/#DrWatson.quickactivate
Symbol("quickactivate") node.references ||
Symbol("@quickactivate") node.references
end
end

Expand Down
21 changes: 14 additions & 7 deletions src/packages/PkgCompat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,17 @@ function dependencies(ctx)
Pkg.dependencies(ctx.env)
end
catch e
@error """
Pkg error: you might need to use
if !occursin(r"expected.*exist.*manifest", sprint(showerror, e))
@error """
Pkg error: you might need to use
Pluto.reset_notebook_environment(notebook_path)
Pluto.reset_notebook_environment(notebook_path)
to reset this notebook's environment.
to reset this notebook's environment.
Before doing so, consider sending your notebook file to https://github.com/fonsp/Pluto.jl/issues together with the following info:
""" Pluto.PLUTO_VERSION VERSION exception=(e,catch_backtrace())
Before doing so, consider sending your notebook file to https://github.com/fonsp/Pluto.jl/issues together with the following info:
""" Pluto.PLUTO_VERSION VERSION exception=(e,catch_backtrace())
end

Dict()
end
Expand Down Expand Up @@ -368,6 +370,11 @@ end
# WRITING COMPAT ENTRIES
###


_project_key_order = ["name", "uuid", "keywords", "license", "desc", "deps", "compat"]
project_key_order(key::String) =
something(findfirst(x -> x == key, _project_key_order), length(_project_key_order) + 1)

# ✅ Public API
function _modify_compat(f!::Function, ctx::PkgContext)::PkgContext
toml = Pkg.TOML.parsefile(project_file(ctx))
Expand All @@ -378,7 +385,7 @@ function _modify_compat(f!::Function, ctx::PkgContext)::PkgContext
isempty(compat) && delete!(toml, "compat")

write(project_file(ctx), sprint() do io
Pkg.TOML.print(io, toml; sorted=true)
Pkg.TOML.print(io, toml; sorted=true, by=(key -> (project_key_order(key), key)))
end)

return load_ctx(ctx)
Expand Down

2 comments on commit 163b7ce

@fonsp
Copy link
Owner Author

@fonsp fonsp commented on 163b7ce Jul 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/40376

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.15.0 -m "<description of version>" 163b7ce199c97cea95df7776fe5740300c57b669
git push origin v0.15.0

Please sign in to comment.