Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build fixups + use Artifacts #13

Merged
merged 12 commits into from
Dec 13, 2021
6 changes: 6 additions & 0 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[dash_textarea_autocomplete_resources]
git-tree-sha1 = "<sha1>"

[[dash_textarea_autocomplete_resources.download]]
sha256 = "<sha256>"
url = "<url>"
9 changes: 7 additions & 2 deletions dash_textarea_autocomplete/package-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
"build:js": "webpack --mode production",
"build:backends": "dash-generate-components ./src/lib/components dash_textarea_autocomplete -p package-info.json --r-prefix '' --jl-prefix ''",
"build:backends-activated": "(. venv/bin/activate || venv\\scripts\\activate && npm run build:py_and_r)",
"build": "npm run build:js && npm run build:backends",
"build:activated": "npm run build:js && npm run build:backends-activated"
"build:create-tar-file-from-deps": "tar -czf ./deps.tar.gz ./deps && mv ./deps.tar.gz ./deps",
Felix-Gauthier marked this conversation as resolved.
Show resolved Hide resolved
"build": "npm run build:js && npm run build:backends && npm run build:create-tar-file-from-deps",
"build:activated": "npm run build:js && npm run build:backends-activated",
"postbuild:fixup-external-url-jl": "sed -i 's/https:\\/\\/unpkg.com\\/dash_textarea_autocomplete/https:\\/\\/unpkg.com\\/dash-textarea-autocomplete/' src/DashTextareaAutocomplete.jl",
"postbuild:fixup-dash-version-project-jl": "sed -i 's/Dash = \"0.1.3\"/Dash = \"0.1.3, 1.0\"/' Project.toml",
"postbuild:fixup-resources-path-jl": "sed -i 's/realpath(joinpath( @__DIR__, \"..\", \"deps\"))/artifact\"dash_textarea_autocomplete_resources\"/' src/DashTextareaAutocomplete.jl",
"postbuild": "npm run postbuild:fixup-external-url-jl && npm run postbuild:fixup-dash-version-project-jl && npm run postbuild:fixup-resources-path-jl"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a lot of manual fix-ups, it would be nice to follow up on creating PR in the dash repo so we can remove each of these one by one. We can create Issues here to track it potentially ?

Copy link
Owner

Choose a reason for hiding this comment

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

Good point!

I would start by opening an issue in https://github.com/plotly/dash/issues mentioning that the "proper" way (and the one that's work with PackageCompiler.jl 😏 ) to handle artifacts in Julia now is by defining Artifact.toml.

Then, we should mention that Artifact.toml only accepts tarball, so we would need to tar the min.js and min.js.map files together in the build process so that the tarball is part of the npm registry and has a permanent URL available from unpkg.com

We could also reference this PR (they can see it, it's opensource 🎊 ) to put things in context.

},
"author": "Etienne Tetreault-Pinard <[email protected]>",
"license": "MIT",
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
"build:js": "webpack --mode production",
"build:backends": "dash-generate-components ./src/lib/components dash_textarea_autocomplete -p package-info.json --r-prefix '' --jl-prefix ''",
"build:backends-activated": "(. venv/bin/activate || venv\\scripts\\activate && npm run build:py_and_r)",
"build": "npm run build:js && npm run build:backends",
"build:activated": "npm run build:js && npm run build:backends-activated"
"build:create-tar-file-from-deps": "tar -czf ./deps.tar.gz ./deps && mv ./deps.tar.gz ./deps",
"build": "npm run build:js && npm run build:backends && npm run build:create-tar-file-from-deps",
"build:activated": "npm run build:js && npm run build:backends-activated",
"postbuild:fixup-external-url-jl": "sed -i 's/https:\\/\\/unpkg.com\\/dash_textarea_autocomplete/https:\\/\\/unpkg.com\\/dash-textarea-autocomplete/' src/DashTextareaAutocomplete.jl",
"postbuild:fixup-dash-version-project-jl": "sed -i 's/Dash = \"0.1.3\"/Dash = \"0.1.3, 1.0\"/' Project.toml",
Felix-Gauthier marked this conversation as resolved.
Show resolved Hide resolved
"postbuild:fixup-resources-path-jl": "sed -i 's/realpath(joinpath( @__DIR__, \"..\", \"deps\"))/artifact\"dash_textarea_autocomplete_resources\"/' src/DashTextareaAutocomplete.jl",
"postbuild": "npm run postbuild:fixup-external-url-jl && npm run postbuild:fixup-dash-version-project-jl && npm run postbuild:fixup-resources-path-jl"
Felix-Gauthier marked this conversation as resolved.
Show resolved Hide resolved
},
"author": "Etienne Tetreault-Pinard <[email protected]>",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions src/DashTextareaAutocomplete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module DashTextareaAutocomplete
using Dash

const resources_path = realpath(joinpath( @__DIR__, "..", "deps"))
const resources_path = artifact"dash_textarea_autocomplete_resources"
const version = "1.1.0"

include("jl/dashtextareaautocomplete.jl")
Expand All @@ -16,14 +16,14 @@ function __init__()
[
DashBase.Resource(
relative_package_path = "dash_textarea_autocomplete.min.js",
external_url = "https://unpkg.com/dash_textarea_autocomplete@1.1.0/dash_textarea_autocomplete/dash_textarea_autocomplete.min.js",
external_url = "https://unpkg.com/dash-textarea-autocomplete@1.1.0/dash_textarea_autocomplete/dash_textarea_autocomplete.min.js",
Copy link
Owner

Choose a reason for hiding this comment

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

Do we actually need these externarl_url definitions now that we're set to use Artifacts and a tarball?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, we didn't need them before since they never actually worked 😏

If we're going to have an external_url resource, it'd be nice if it was a functioning link even if we won't rely on it because of artifacts.

Maybe there's a case where artifacts can't be acquired and this would be the fallback ?

dynamic = nothing,
async = nothing,
type = :js
),
DashBase.Resource(
relative_package_path = "dash_textarea_autocomplete.min.js.map",
external_url = "https://unpkg.com/dash_textarea_autocomplete@1.1.0/dash_textarea_autocomplete/dash_textarea_autocomplete.min.js.map",
external_url = "https://unpkg.com/dash-textarea-autocomplete@1.1.0/dash_textarea_autocomplete/dash_textarea_autocomplete.min.js.map",
dynamic = true,
async = nothing,
type = :js
Expand Down