├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .github ├── ap.png ├── ap2.png ├── ap3.png ├── demo.gif └── workflows │ └── release.yaml ├── .gitignore ├── .npmrc ├── LICENSE ├── README.md ├── bun.lockb ├── esbuild.config.mjs ├── manifest.json ├── package.json ├── src ├── main.ts └── settings │ └── tokenMessage.ts ├── styles.css ├── tsconfig.json ├── version-bump.mjs └── versions.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = tab 9 | indent_size = 4 10 | tab_width = 4 11 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | main.js 4 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "env": { "node": true }, 5 | "plugins": [ 6 | "@typescript-eslint" 7 | ], 8 | "extends": [ 9 | "eslint:recommended", 10 | "plugin:@typescript-eslint/eslint-recommended", 11 | "plugin:@typescript-eslint/recommended" 12 | ], 13 | "parserOptions": { 14 | "sourceType": "module" 15 | }, 16 | "rules": { 17 | "no-unused-vars": "off", 18 | "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], 19 | "@typescript-eslint/ban-ts-comment": "off", 20 | "no-prototype-builtins": "off", 21 | "@typescript-eslint/no-empty-function": "off" 22 | } 23 | } -------------------------------------------------------------------------------- /.github/ap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xroko/obsidian-arena-plugin/27c9c051c3581d87a9f9b693d46fb98eb4cdc60d/.github/ap.png -------------------------------------------------------------------------------- /.github/ap2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xroko/obsidian-arena-plugin/27c9c051c3581d87a9f9b693d46fb98eb4cdc60d/.github/ap2.png -------------------------------------------------------------------------------- /.github/ap3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xroko/obsidian-arena-plugin/27c9c051c3581d87a9f9b693d46fb98eb4cdc60d/.github/ap3.png -------------------------------------------------------------------------------- /.github/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xroko/obsidian-arena-plugin/27c9c051c3581d87a9f9b693d46fb98eb4cdc60d/.github/demo.gif -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release Obsidian plugin 2 | 3 | on: 4 | push: 5 | tags: 6 | - "*" 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | permissions: write-all 12 | steps: 13 | - uses: actions/checkout@v3 14 | - name: Use Node.js 15 | uses: actions/setup-node@v3 16 | with: 17 | node-version: "18.x" 18 | 19 | - name: Build plugin 20 | run: | 21 | npm install 22 | npm run build 23 | 24 | - name: Create release 25 | env: 26 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 27 | run: | 28 | tag="${GITHUB_REF#refs/tags/}" 29 | 30 | gh release create "$tag" \ 31 | --title="$tag" \ 32 | --draft \ 33 | main.js manifest.json styles.css 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # vscode 2 | .vscode 3 | 4 | # Intellij 5 | *.iml 6 | .idea 7 | 8 | # npm 9 | node_modules 10 | 11 | # Don't include the compiled main.js file in the repo. 12 | # They should be uploaded to GitHub releases instead. 13 | main.js 14 | 15 | # Exclude sourcemaps 16 | *.map 17 | 18 | # obsidian 19 | data.json 20 | 21 | # Exclude macOS Finder (System Explorer) View States 22 | .DS_Store 23 | 24 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | tag-version-prefix="" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 0xroko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Are.na plugin for Obsidian 2 | 3 | Allows you to save [Are.na](are.na/about) blocks as Obsidian notes. 4 | 5 | ![demo](./.github/demo.gif) 6 | 7 | [Install here](https://obsidian.md/plugins?id=arena) 8 | 9 | ## Features 10 | 11 | > [!IMPORTANT] 12 | > If you want to save private blocks, you need to [create a personal access token](#create-your-arena-personal-access-token) 13 | 14 | - Local first, save Are.na blocks in your Obsidian notes 15 | - Display Are.na blocks in your Obsidian notes, block <-> note 16 | - Support for all block types 17 | - Easily open Are.na blocks in your browser 18 | - No DB -> file name is the block id 19 | 20 | If you want to see a feature implemented, open an issue or a PR. 21 | 22 | ## Usage 23 | 24 | ### Create your Are.na personal access token 25 | 26 | 1. Go to [dev.are.na/oauth/applications](https://dev.are.na/oauth/applications) and login with your Are.na account (this is the official Are.na API) 27 | ![](./.github/ap.png) 28 | 29 | 2. Create a new application 30 | ![](./.github/ap2.png) 31 | 32 | - Name the application whatever you want (e.g. Obsidian plugin) 33 | - Set the redirect URI to `https://example.com` (it doesn't matter) 34 | - Submit 35 | 36 | 3. Copy the `Personal Access Token` and enter it in the plugin settings 37 | ![](./.github/ap3.png) 38 | 39 | ### Insert block 40 | 41 | 1. Open the command palette and search for `Insert Are.na block` 42 | 2. Done! Block will be inserted in your current note (and saved locally in `are.na` folder) 43 | -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xroko/obsidian-arena-plugin/27c9c051c3581d87a9f9b693d46fb98eb4cdc60d/bun.lockb -------------------------------------------------------------------------------- /esbuild.config.mjs: -------------------------------------------------------------------------------- 1 | import esbuild from "esbuild"; 2 | import process from "process"; 3 | import builtins from "builtin-modules"; 4 | 5 | const banner = `/* 6 | THIS IS A GENERATED/BUNDLED FILE BY ESBUILD 7 | if you want to view the source, please visit the github repository of this plugin 8 | */ 9 | `; 10 | 11 | const prod = process.argv[2] === "production"; 12 | 13 | const context = await esbuild.context({ 14 | banner: { 15 | js: banner, 16 | }, 17 | entryPoints: ["src/main.ts"], 18 | bundle: true, 19 | external: [ 20 | "obsidian", 21 | "electron", 22 | "@codemirror/autocomplete", 23 | "@codemirror/collab", 24 | "@codemirror/commands", 25 | "@codemirror/language", 26 | "@codemirror/lint", 27 | "@codemirror/search", 28 | "@codemirror/state", 29 | "@codemirror/view", 30 | "@lezer/common", 31 | "@lezer/highlight", 32 | "@lezer/lr", 33 | ...builtins, 34 | ], 35 | format: "cjs", 36 | target: "es2018", 37 | logLevel: "info", 38 | sourcemap: prod ? false : "inline", 39 | treeShaking: true, 40 | outfile: "main.js", 41 | }); 42 | 43 | if (prod) { 44 | await context.rebuild(); 45 | process.exit(0); 46 | } else { 47 | await context.watch(); 48 | } 49 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "arena", 3 | "name": "Are.na unofficial", 4 | "minAppVersion": "1.5.8", 5 | "version": "1.0.3", 6 | "description": "Allows you to save Are.na blocks as notes.", 7 | "author": "0xroko", 8 | "authorUrl": "https://github.com/0xroko", 9 | "isDesktopOnly": false 10 | } 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "obsidian-arena-plugin", 3 | "version": "1.0.3", 4 | "description": "", 5 | "main": "main.js", 6 | "scripts": { 7 | "dev": "node esbuild.config.mjs", 8 | "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", 9 | "version": "node version-bump.mjs && git add manifest.json versions.json" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "MIT", 14 | "devDependencies": { 15 | "@types/node": "^16.11.6", 16 | "@typescript-eslint/eslint-plugin": "5.29.0", 17 | "@typescript-eslint/parser": "5.29.0", 18 | "builtin-modules": "3.3.0", 19 | "esbuild": "0.17.3", 20 | "obsidian": "latest", 21 | "tslib": "2.4.0", 22 | "typescript": "4.7.4" 23 | }, 24 | "dependencies": { 25 | "arena-ts": "^0.1.4" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { ArenaClient } from "arena-ts"; 2 | import { 3 | App, 4 | ItemView, 5 | Modal, 6 | Notice, 7 | Platform, 8 | Plugin, 9 | PluginSettingTab, 10 | Setting, 11 | TFile, 12 | addIcon, 13 | requestUrl, 14 | } from "obsidian"; 15 | import { buildTokenSettingsMessage } from "src/settings/tokenMessage"; 16 | 17 | // compliant with icon guidelines 18 | addIcon( 19 | "arena-logo-icon", 20 | "" 21 | ); 22 | 23 | const ARENA_DIR = "are.na"; 24 | 25 | const parseArenaUrl = (url: string) => { 26 | // block/ 27 | const expr = /block\/(\d+)/; 28 | const match = url.match(expr); 29 | if (match) { 30 | return match[1]; 31 | } 32 | return null; 33 | }; 34 | 35 | interface ArenaPluginSettings { 36 | arenaPrivateAccessToken: string | null; 37 | arenaDir: string; 38 | } 39 | 40 | const DEFAULT_SETTINGS: ArenaPluginSettings = { 41 | arenaPrivateAccessToken: null, 42 | arenaDir: ARENA_DIR, 43 | }; 44 | 45 | export default class ArenaPlugin extends Plugin { 46 | settings: ArenaPluginSettings; 47 | arenaClient: ArenaClient; 48 | 49 | async createFileOrReplace(path: string, data: string) { 50 | // check if file exists 51 | const file = this.app.vault.getAbstractFileByPath(path); 52 | if (file && file instanceof TFile) { 53 | this.app.vault.modify(file, data); 54 | return file; 55 | } 56 | 57 | const newFile = await this.app.vault.create(path, data); 58 | return newFile; 59 | } 60 | 61 | async createFileOrReplaceBinary(path: string, data: ArrayBuffer) { 62 | // check if file exists 63 | const file = this.app.vault.getAbstractFileByPath(path); 64 | if (file && file instanceof TFile) { 65 | this.app.vault.modifyBinary(file, data); 66 | return file; 67 | } 68 | 69 | const newFile = await this.app.vault.createBinary(path, data); 70 | return newFile; 71 | } 72 | 73 | async initArenaClient() { 74 | this.arenaClient = new ArenaClient({ 75 | token: this.settings.arenaPrivateAccessToken, 76 | }); 77 | } 78 | 79 | // main function returns file for further use (e.g. insert into editor) 80 | async saveBlock(blockId: string) { 81 | try { 82 | // @ts-ignore 83 | const block = await this.arenaClient.block(blockId).get(); 84 | let file: TFile | null = null; 85 | if (block.class === "Image" && block.image) { 86 | const extension = block.image.content_type.split("/")[1]; 87 | 88 | const arrayBuffer = await requestUrl(block.image.original.url) 89 | .arrayBuffer; 90 | 91 | // save image to attachments folder 92 | file = await this.createFileOrReplaceBinary( 93 | `${ARENA_DIR}/${block.id}.${extension}`, 94 | arrayBuffer 95 | ); 96 | } else if (block.embed) { 97 | file = await this.createFileOrReplace( 98 | `${ARENA_DIR}/${block.id}.md`, 99 | ` 100 | ${block.embed.html} 101 | ` 102 | ); 103 | } else if (block.class === "Text") { 104 | // save image to attachments folder 105 | file = await this.createFileOrReplace( 106 | `${ARENA_DIR}/${block.id}.md`, 107 | block.content || "" 108 | ); 109 | } else if (block.class === "Link") { 110 | let imgFile: TFile | null = null; 111 | // also download image if it exists 112 | if (block.image) { 113 | const extension = block.image.content_type.split("/")[1]; 114 | const arrayBuffer = await requestUrl( 115 | block.image.original.url 116 | ).arrayBuffer; 117 | imgFile = await this.createFileOrReplaceBinary( 118 | `${ARENA_DIR}/${block.id}.${extension}`, 119 | arrayBuffer 120 | ); 121 | } 122 | file = await this.createFileOrReplace( 123 | `${ARENA_DIR}/${block.id}.md`, 124 | `[![[${imgFile?.name}]]](${block.source?.url})` 125 | ); 126 | } else if (block.class === "Attachment" && block.attachment) { 127 | const arrayBuffer = await requestUrl(block.attachment.url) 128 | .arrayBuffer; 129 | file = await this.createFileOrReplaceBinary( 130 | `${ARENA_DIR}/${block.id}.${block.attachment.extension}`, 131 | arrayBuffer 132 | ); 133 | } 134 | if (!file) { 135 | new Notice("Could not create file"); 136 | 137 | return; 138 | } 139 | return file; 140 | } catch (error) { 141 | if (error.status && error.status === 401) { 142 | if (!this.settings.arenaPrivateAccessToken) { 143 | new Notice( 144 | "Following Are.na block requires a personal access token. Please enter one in the settings." 145 | ); 146 | return null; 147 | } 148 | new Notice( 149 | "Invalid Are.na token, please make sure it's correct." 150 | ); 151 | return null; 152 | } 153 | console.log("Error saving block", error); 154 | new Notice("Error saving block"); 155 | return null; 156 | } 157 | } 158 | 159 | isLogged() { 160 | // for now true because auth is not needed for getting 161 | return true; 162 | } 163 | 164 | isMobile() { 165 | return Platform.isMobile; 166 | } 167 | 168 | async loadCommands() {} 169 | 170 | async onload() { 171 | await this.loadSettings(); 172 | 173 | this.registerEvent( 174 | this.app.workspace.on("file-menu", (menu, file) => { 175 | if (file.parent?.name.includes(ARENA_DIR)) { 176 | menu.addItem((item) => { 177 | // open in arena 178 | item.setTitle("Open in Are.na") 179 | .onClick(async () => { 180 | window.open( 181 | `https://are.na/block/${ 182 | file.name.split(".")[0] 183 | }` 184 | ); 185 | }) 186 | .setIcon("arena-logo-icon"); 187 | }); 188 | } 189 | }) 190 | ); 191 | 192 | this.addSettingTab(new ArenaSettingsTab(this.app, this)); 193 | 194 | // all of the commands below are are only available on desktop (requires electron APIs) 195 | if (this.isMobile()) { 196 | return; 197 | } 198 | 199 | await this.initArenaClient(); 200 | 201 | this.app.workspace.onLayoutReady(async () => { 202 | const arenaDir = this.app.vault.getAbstractFileByPath( 203 | this.settings.arenaDir 204 | ); 205 | 206 | if (!arenaDir) { 207 | await this.app.vault.createFolder(this.settings.arenaDir); 208 | } 209 | }); 210 | 211 | const checkCallback = (checking: boolean) => { 212 | if (this.isLogged() && !this.app.workspace.activeEditor) { 213 | if (!checking) { 214 | new InsertBlockModal(this.app, async (url) => { 215 | const id = parseArenaUrl(url); 216 | if (!id) { 217 | new Notice("Invalid Are.na url"); 218 | return; 219 | } 220 | 221 | const file = await this.saveBlock(id); 222 | 223 | if (!file) { 224 | return; 225 | } 226 | 227 | const canvasView = 228 | this.app.workspace.getActiveViewOfType(ItemView); 229 | if (canvasView?.getViewType() === "canvas") { 230 | // hot mess since there's no api for this 231 | const canvas = (canvasView as any)?.canvas; 232 | /* 233 | new oX(i,(function(e) { 234 | i.createFileNode({ 235 | pos: t, 236 | size: n, 237 | file: e 238 | }) 239 | } 240 | */ 241 | canvas.createFileNode({ 242 | pos: canvas.pointer, 243 | size: canvas.config.defaultFileNodeDimensions, 244 | file: file, 245 | }); 246 | } 247 | }).open(); 248 | } 249 | return true; 250 | } 251 | 252 | return false; 253 | }; 254 | 255 | this.addCommand({ 256 | id: "insert-arena-block", 257 | name: "Insert Are.na block", 258 | checkCallback: checkCallback, 259 | }); 260 | 261 | // editorCheckCallback with this binding 262 | const editorCheckCallback = ( 263 | checking: boolean, 264 | editor: { replaceSelection: (arg0: string) => void } 265 | ) => { 266 | if (this.isLogged()) { 267 | if (!checking) { 268 | new InsertBlockModal(this.app, async (url) => { 269 | const id = parseArenaUrl(url); 270 | if (!id) { 271 | new Notice("Invalid Are.na url!"); 272 | return; 273 | } 274 | 275 | const file = await this.saveBlock(id); 276 | 277 | if (!file) { 278 | return; 279 | } 280 | 281 | editor.replaceSelection(`![[${file.name}]]`); 282 | }).open(); 283 | } 284 | return true; 285 | } 286 | return false; 287 | }; 288 | 289 | this.addCommand({ 290 | id: "insert-arena-block-editor", 291 | name: "Insert Are.na block (editor)", 292 | editorCheckCallback: editorCheckCallback, 293 | }); 294 | } 295 | 296 | onunload() {} 297 | 298 | async logout() { 299 | this.settings.arenaPrivateAccessToken = null; 300 | await this.saveSettings(); 301 | } 302 | 303 | async loadSettings() { 304 | this.settings = Object.assign( 305 | {}, 306 | DEFAULT_SETTINGS, 307 | await this.loadData() 308 | ); 309 | } 310 | 311 | async saveSettings() { 312 | await this.saveData(this.settings); 313 | } 314 | } 315 | 316 | class InsertBlockModal extends Modal { 317 | app: App; 318 | url: string; 319 | onSubmit: (blockUrl: string) => void; 320 | 321 | constructor(app: App, onSubmit: (blockUrl: string) => void) { 322 | super(app); 323 | this.app = app; 324 | this.onSubmit = onSubmit; 325 | } 326 | 327 | blockUrl: string; 328 | 329 | onOpen() { 330 | const { contentEl } = this; 331 | contentEl.createEl("h3", { text: "Insert Are.na block" }); 332 | contentEl.createEl("form", {}, (form) => { 333 | const input = form.createEl("input", { 334 | placeholder: "https://are.na/block/123", 335 | type: "text", 336 | }) as HTMLInputElement; 337 | input.onchange = (e) => { 338 | this.url = input.value; 339 | }; 340 | form.onsubmit = (e) => { 341 | e.preventDefault(); 342 | this.onSubmit(this.url); 343 | this.close(); 344 | }; 345 | form.createEl("button", { text: "Submit", cls: "arena-sumbit" }); 346 | }); 347 | } 348 | 349 | onClose() { 350 | const { contentEl } = this; 351 | contentEl.empty(); 352 | } 353 | } 354 | 355 | class ArenaSettingsTab extends PluginSettingTab { 356 | plugin: ArenaPlugin; 357 | 358 | constructor(app: App, plugin: ArenaPlugin) { 359 | super(app, plugin); 360 | this.plugin = plugin; 361 | } 362 | 363 | display(): void { 364 | const { containerEl } = this; 365 | 366 | containerEl.empty(); 367 | 368 | const message = buildTokenSettingsMessage(); 369 | 370 | new Setting(containerEl) 371 | .setName("Are.na Personal Access Token (optional)") 372 | .setDesc(message) 373 | .addText((b) => 374 | b 375 | .setPlaceholder("Paste your Are.na token here") 376 | .setValue( 377 | this.plugin.settings.arenaPrivateAccessToken || "" 378 | ) 379 | .onChange(async (value) => { 380 | this.plugin.settings.arenaPrivateAccessToken = value; 381 | this.plugin.saveSettings(); 382 | await this.plugin.initArenaClient(); 383 | }) 384 | ); 385 | } 386 | } 387 | -------------------------------------------------------------------------------- /src/settings/tokenMessage.ts: -------------------------------------------------------------------------------- 1 | export const createLink = (url: string, text: string) => { 2 | const link = document.createElement("a"); 3 | link.href = url; 4 | link.innerText = text; 5 | link.target = "_blank"; 6 | return link; 7 | }; 8 | 9 | export const buildTokenSettingsMessage = () => { 10 | const message = document.createDocumentFragment(); 11 | 12 | message.appendChild( 13 | document.createTextNode( 14 | "Token is only required for saving private blocks." 15 | ) 16 | ); 17 | 18 | message.appendChild(document.createElement("br")); 19 | 20 | message.appendChild(document.createTextNode("Visit ")); 21 | 22 | message.appendChild( 23 | createLink("https://dev.are.na/oauth/applications", "Are.na API") 24 | ); 25 | 26 | message.appendChild( 27 | document.createTextNode(" to get your personal access token.") 28 | ); 29 | 30 | message.appendChild(document.createElement("br")); 31 | 32 | message.appendChild( 33 | document.createTextNode( 34 | "You will have to create a new application and copy the `Personal Access Token`." 35 | ) 36 | ); 37 | 38 | message.appendChild(document.createElement("br")); 39 | 40 | message.appendChild( 41 | document.createTextNode("For a detailed guide, check out ") 42 | ); 43 | 44 | message.appendChild( 45 | createLink( 46 | "https://github.com/0xroko/obsidian-arena-plugin?tab=readme-ov-file#create-your-arena-personal-access-token", 47 | "creating your Personal Access Token instructions" 48 | ) 49 | ); 50 | 51 | message.appendChild( 52 | document.createTextNode(" on how to create Personal Access Token.") 53 | ); 54 | 55 | return message; 56 | }; 57 | -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This CSS file will be included with your plugin, and 4 | available in the app when your plugin is enabled. 5 | 6 | If your plugin does not need CSS, delete this file. 7 | 8 | */ 9 | 10 | .arena-sumbit { 11 | display: block; 12 | margin-left: auto; 13 | margin-top: var(--size-4-1); 14 | } 15 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "inlineSourceMap": true, 5 | "inlineSources": true, 6 | "module": "ESNext", 7 | "target": "ES6", 8 | "allowJs": true, 9 | "noImplicitAny": true, 10 | "moduleResolution": "node", 11 | "importHelpers": true, 12 | "isolatedModules": true, 13 | "strictNullChecks": true, 14 | "types": [], 15 | "lib": [ 16 | "DOM", 17 | "ES5", 18 | "ES6", 19 | "ES7" 20 | ] 21 | }, 22 | "include": [ 23 | "**/*.ts" 24 | ] 25 | } -------------------------------------------------------------------------------- /version-bump.mjs: -------------------------------------------------------------------------------- 1 | import { readFileSync, writeFileSync } from "fs"; 2 | 3 | const targetVersion = process.env.npm_package_version; 4 | 5 | // read minAppVersion from manifest.json and bump version to target version 6 | let manifest = JSON.parse(readFileSync("manifest.json", "utf8")); 7 | const { minAppVersion } = manifest; 8 | manifest.version = targetVersion; 9 | writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t")); 10 | 11 | // update versions.json with target version and minAppVersion from manifest.json 12 | let versions = JSON.parse(readFileSync("versions.json", "utf8")); 13 | versions[targetVersion] = minAppVersion; 14 | writeFileSync("versions.json", JSON.stringify(versions, null, "\t")); 15 | -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "1.0.0": "0.15.0", 3 | "1.0.1": "1.5.8", 4 | "1.0.2": "1.5.8", 5 | "1.0.3": "1.5.8" 6 | } 7 | --------------------------------------------------------------------------------