Skip to content

Commit

Permalink
Merge pull request #13 from etpinard/add-build-fixups-and-add-artifacts
Browse files Browse the repository at this point in the history
Add build fixups + use Artifacts
  • Loading branch information
Felix-Gauthier authored Dec 13, 2021
2 parents 7ac2cd0 + f6ede40 commit 3f110cd
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 10 deletions.
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 = "40556a4d143e9e1b25db0e0f434e9415989b3385"

[[dash_textarea_autocomplete_resources.download]]
sha256 = "5b3b5fb207ce04e53c3a91bbe9378e794b49d8017351c3e142eb4353e107d113"
url = "https://unpkg.com/dash-textarea-autocomplete@{version}/dash_textarea_autocomplete/deps.tar.gz"
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This project was generated by the [dash-component-boilerplate](https://github.com/plotly/dash-component-boilerplate) it contains the minimal set of code required to create your own custom Dash component.

_N.B.: because of the current usage of `postbuild_fixups.sh` build script, this project can only be build on a Linux distribution_

---

## Install dependencies
Expand All @@ -15,7 +17,6 @@ This project was generated by the [dash-component-boilerplate](https://github.co
$ python3 -m venv venv
$ . venv/bin/activate
```
_Note: venv\Scripts\activate for windows_
3. Install python packages required to build components.
```
Expand All @@ -39,6 +40,8 @@ This project was generated by the [dash-component-boilerplate](https://github.co
```
$ npm run build
```
**N.B.**
+ We use `postbuild_fixups.sh` to re-write certain lines in the generated Julia files of this package to allow usage of Julia's [Artifact](https://pkgdocs.julialang.org/v1/artifacts/#Artifacts) system.
2. Run and modify the `usage.py` sample dash app:
```
$ python usage.py
Expand Down
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ authors = ["Etienne Tetreault-Pinard <[email protected]>"]
version = "1.1.0"

[deps]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Dash = "1b08a953-4be3-4667-9a23-3db579824955"

[compat]
julia = "1.2"
julia = "1.3"
Dash = "0.1.3, 1.0"
7 changes: 5 additions & 2 deletions dash_textarea_autocomplete/package-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
"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:fixups": "./postbuild_fixups.sh $npm_package_version",
"postbuild": "npm run postbuild:fixups"
},
"author": "Etienne Tetreault-Pinard <[email protected]>",
"license": "MIT",
Expand Down
Binary file added deps/deps.tar.gz
Binary file not shown.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
"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:fixups": "./postbuild_fixups.sh $npm_package_version",
"postbuild": "npm run postbuild:fixups"
},
"author": "Etienne Tetreault-Pinard <[email protected]>",
"license": "MIT",
Expand Down
28 changes: 28 additions & 0 deletions postbuild_fixups.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

version=${1?Please specify version}

# src/DashTextareaAutocomplete
declare -a moduleregs=(\
's/https:\/\/unpkg.com\/dash_textarea_autocomplete/https:\/\/unpkg.com\/dash-textarea-autocomplete/' \
's/realpath(joinpath( @__DIR__, \"..\", \"deps\"))/artifact\"dash_textarea_autocomplete_resources\"/' \
's/using Dash/using Dash, Pkg.Artifacts/')

for reg in "${moduleregs[@]}"
do
sed -i "$reg" src/DashTextareaAutocomplete.jl
done

# Project.toml
declare -a projectregs=(\
's/\[deps\]/\[deps\]\nPkg = \"44cfe95a-1eb2-52ea-b672-e2afdf69b78f\"/' \
's/Dash = \"0.1.3\"/Dash = \"0.1.3, 1.0\"/' \
's/julia = \"1.2\"/julia = \"1.3\"/')

for reg in "${projectregs[@]}"
do
sed -i "$reg" Project.toml
done

# Artifacts.toml
sed -i "s/[1-999]\.[0-999]\.[0-999]\|{version}/${version}/" Artifacts.toml
8 changes: 4 additions & 4 deletions src/DashTextareaAutocomplete.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

module DashTextareaAutocomplete
using Dash
using Dash, Pkg.Artifacts

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",
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

0 comments on commit 3f110cd

Please sign in to comment.