Skip to content

Commit 1123cc8

Browse files
authored
feat: validate bookmark files (#42)
The JSON structure supported by this extension was never explictly documented and only explained by examples. Due to upcoming features and knowing how manipulating (deeply) nested JSON by hand is error-prone it makes sense to perform validation before attempting to import the bookmark files. I defined a JSON schema and additionally published it to a public location. JSON Schema for Bookmarks: https://frederikb.github.io/bookmarksync/schemas/bookmarks.1-0-0.schema.json In the (rare) case that the schema is updated we need to ensure that the new version is published as well. The schema is versioned according to SchemaVer. As a side benefit, users may also reference the schema in their bookmark JSON files, via a $schema entry on the root and gain immediate validation in their editor (if supported). Fixes #29
1 parent 84e5203 commit 1123cc8

File tree

8 files changed

+275
-42
lines changed

8 files changed

+275
-42
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
"xo": "^0.57.0"
5656
},
5757
"dependencies": {
58+
"@hyperjump/json-schema": "^1.7.2",
59+
"@hyperjump/browser": "^1.1.3",
5860
"@octokit/plugin-retry": "^6.0.1",
5961
"@octokit/rest": "^20.0.2",
6062
"@webext-core/job-scheduler": "^1.0.0",

pnpm-lock.yaml

Lines changed: 74 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Structure your JSON file for bookmarks as per the schema defined at [https://fre
8989

9090
```json
9191
{
92+
"$schema": "https://frederikb.github.io/bookmarksync/schemas/bookmarks.1-0-0.schema.json",
9293
"name": "Bookmarks 1",
9394
"bookmarks": [
9495
{
@@ -149,4 +150,5 @@ Distributed under the MIT License. See [`LICENSE`](LICENSE) for more information
149150
## 📣 Acknowledgements
150151

151152
- [Octokit](https://github.com/octokit/core.js): Seamless GitHub API integration.
153+
- [Hyperjump - JSON Schema](https://github.com/hyperjump-io/json-schema): JSON Schema tooling.
152154
- This project was bootstrapped with [Web Extension Toolkit (wxt.dev)](https://wxt.dev).

src/entrypoints/background.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default defineBackground({
1010

1111
main() {
1212
registerSyncBookmarks(new GitHubBookmarksLoader());
13+
1314
const syncBookmarks = getSyncBookmarks();
1415

1516
const jobs = defineJobScheduler();

0 commit comments

Comments
 (0)