Skip to content

Commit

Permalink
chore: create template of import_map.json to update SB version
Browse files Browse the repository at this point in the history
doc: explain dependencies update
  • Loading branch information
malys committed Jan 13, 2025
1 parent 6cd63bd commit c722539
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ Open your `PLUGS` note in SilverBullet and add this plug to the list:
Then run the {[Plugs: Update]} command and off you go!
## Dependencies
### Dev
* [Deno](https://deno.land/)
* [Xonsh](https://github.com/xonsh/xonsh)
* [SilverBullet](https://github.com/silverbulletmd/silverbullet)
### Production
* [Markmap](https://github.com/markmap/markmap)
* [D3](https://github.com/d3/d3)
* [SilverBullet](https://github.com/silverbulletmd/silverbullet)
## Usage
Create a markdwon file using [MarkMap format](https://markmap.js.org/repl).
Expand Down Expand Up @@ -84,6 +98,12 @@ Create a markdwon file using [MarkMap format](https://markmap.js.org/repl).

![](./mindmap.png)

## Versionning

This plug is versioned including [Semantic Versions](https://semver.org/) of 3 different components:

`internal version-markmap version-silverbullet version`

## Contributing

If you find bugs, report them on the [issue tracker on GitHub](https://github.com/malys/silverbullet-mindmap/issues).
Expand Down Expand Up @@ -123,9 +143,16 @@ deno run release
deno run publish
```


SilverBullet will automatically sync and load the new version of the plug (or speed up this process by running the {[Sync: Now]} command).

#### Templating

`scripts/dependencies.xsh` is a script used to update template files. It downloads the latest version of each dependency and replaces the placeholders (`_VERSION_`) in the template with the new versions.

* `import_map.tpl` is the template used to generate the `import_map.json` file. It contains a list of dependencies to be included in the plug. The template can be edited to add or remove dependencies.
* `mindmap.plug.js` is also updated with last dependencies versions.


## License

MIT, following SilverBullet
Expand Down
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.2.1",
"version": "0.3.1",
"importMap": "import_map.json",
"tasks": {
"publish": "deno run build && xonsh scripts/release.xsh && xonsh scripts/publish.xsh",
Expand Down
15 changes: 15 additions & 0 deletions import_map.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"imports": {
"@silverbulletmd/silverbullet": "jsr:@silverbulletmd/silverbullet@_SB_VERSION_",
"@silverbulletmd/silverbullet/lib/frontmatter": "jsr:@silverbulletmd/silverbullet@_SB_VERSION_/lib/frontmatter",
"@silverbulletmd/silverbullet/syscalls": "jsr:@silverbulletmd/silverbullet@_SB_VERSION_/syscalls",
"@silverbulletmd/silverbullet/lib/tree": "jsr:@silverbulletmd/silverbullet@_SB_VERSION_/lib/tree",
"@silverbulletmd/silverbullet/lib/parse_query": "jsr:@silverbulletmd/silverbullet@_SB_VERSION_/lib/parse_query",
"@silverbulletmd/silverbullet/lib/attribute": "jsr:@silverbulletmd/silverbullet@_SB_VERSION_/lib/attribute",
"@silverbulletmd/silverbullet/types": "jsr:@silverbulletmd/silverbullet@_SB_VERSION_/types",
"$common/": "https://deno.land/x/silverbullet@_SB_VERSION_/common/",
"@std/encoding":"jsr:@std/encoding"
}
}
20 changes: 18 additions & 2 deletions scripts/dependencies.xsh
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/usr/bin/env xonsh
# Update dependencies

import json
import requests
import os
from hashlib import sha256
from base64 import b64encode

#Get sulverbullet last version
def getLastestVersionGithub(PROJECT_NAME):
url = f"https://api.github.com/repos/{PROJECT_NAME}/releases/latest"
response = requests.get(url)
return response.json()["name"]

def download_and_hash_file(input):
resource_data = requests.get(input).content
integrity_checksum = b64encode(sha256(resource_data).digest()).decode('utf-8')
Expand Down Expand Up @@ -54,5 +60,15 @@ with open(TARGET,"w",encoding="utf-8") as f:
f.write(content)
f.close()

LATEST_VERSION=getLastestVersionGithub("silverbulletmd/silverbullet")
with open("import_map.tpl","r",encoding="utf-8") as f:
content=f.read()
f.close
content=content.replace("_SB_VERSION_",LATEST_VERSION)
with open("import_map.json","w",encoding="utf-8") as f:
f.write(content)
f.close


print(TAGS[0]+"-"+TAGS[1]+"-"+LATEST_VERSION)

print(TAGS[0]+"-"+TAGS[1])

0 comments on commit c722539

Please sign in to comment.