From c722539088c00dae606cbe02647554945fdc7600 Mon Sep 17 00:00:00 2001 From: Malys Date: Mon, 13 Jan 2025 15:04:21 +0100 Subject: [PATCH] chore: create template of import_map.json to update SB version doc: explain dependencies update --- README.md | 29 ++++++++++++++++++++++++++++- deno.jsonc | 2 +- import_map.tpl | 15 +++++++++++++++ scripts/dependencies.xsh | 20 ++++++++++++++++++-- 4 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 import_map.tpl diff --git a/README.md b/README.md index 62d8ec8..e1080fe 100755 --- a/README.md +++ b/README.md @@ -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). @@ -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). @@ -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 diff --git a/deno.jsonc b/deno.jsonc index d84c411..0f27938 100755 --- a/deno.jsonc +++ b/deno.jsonc @@ -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", diff --git a/import_map.tpl b/import_map.tpl new file mode 100644 index 0000000..7b4ea40 --- /dev/null +++ b/import_map.tpl @@ -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" + } +} diff --git a/scripts/dependencies.xsh b/scripts/dependencies.xsh index 46a9e5e..53f604c 100644 --- a/scripts/dependencies.xsh +++ b/scripts/dependencies.xsh @@ -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') @@ -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]) \ No newline at end of file