Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jsejcksn/deno-userscript-bundler
Bundle userscripts using Deno
https://github.com/jsejcksn/deno-userscript-bundler
Last synced: about 22 hours ago
JSON representation
Bundle userscripts using Deno
- Host: GitHub
- URL: https://github.com/jsejcksn/deno-userscript-bundler
- Owner: jsejcksn
- License: mit
- Created: 2021-05-05T22:26:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-16T22:52:24.000Z (5 months ago)
- Last Synced: 2024-11-02T11:12:37.386Z (14 days ago)
- Language: JavaScript
- Homepage:
- Size: 154 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# deno-userscript-bundler
---
## ⚠️ Notice
A breaking change was introduced in Deno
[v`1.22.0`](https://github.com/denoland/deno/releases/tag/v1.22.0),
which affects this repository:> BREAKING: Remove unstable `Deno.emit` and `Deno.formatDiagnostics` APIs
> ([#14463](https://github.com/denoland/deno/pull/14463))The removed APIs were relocated to a third-party module,
[`deno.land/x/emit`](https://deno.land/x/emit),
but were only migrated in part. At the time of writing of this notice,
[issues](https://github.com/denoland/deno_emit/issues) exist which prevent
refactoring this codebase without disruption. I plan to update this project
after those issues have been resolved.In the iterim, a potential workaround is to use Deno's
[`compile` API](https://deno.land/[email protected]/tools/compiler)
with Deno
[v`1.21.3`](https://github.com/denoland/deno/releases/tag/v1.21.3)
to create a binary as a substitute for [installing](#install) the script.---
## To-do
- Write documentation
- Write tests## Install
```
deno install --unstable --name uscript-deno main.ts
```> To avoid being prompted for permissions every time, install with the following permissions:
```
deno install --unstable --allow-net --allow-read --allow-run --allow-write --name uscript-deno main.ts
```(Some permissions aren't strictly necessary, but allow for an enhanced experience — e.g. `--allow-run` is only used to open files in VS Code and to get the correct Windows path in WSL)
## Use
Generate a new directory with a script template (main.ts) and metablock template (metablock.yaml)
```sh
uscript-deno new $DIR
# uscript-deno new path/to/new/dir
```
```
Created:
path/to/new/dir
├ main.ts
└ metablock.yaml
```Bundle userscript
```sh
uscript-deno bundle $ENTRYPOINT
# uscript-deno bundle path/to/project/main.ts
```
```
Written:
path/to/project/main.bundle.user.js
```Run in development mode: Watches entrypoint file for changes and bundles again on each change. Also provides metablock userscript on localhost server for quick installation by a script manager extension (e.g. Tampermonkey) (requires fs access by the script manager)
```sh
uscript-deno dev $ENTRYPOINT
# uscript-deno dev path/to/project/main.ts
```
```
Development userscript metablock at:
http://localhost:10741/meta.user.jsWatching for file changes…
Use ctrl+c to stop.18:33:11.796 Bundling…
18:33:13.211 Done (1416ms)
…
```Generate TSConfig for use with VS Code Deno extension
```sh
# print to stdout
uscript-deno tsconfig# or write to file
uscript-deno tsconfig -o $TSCONFIG_PATH
# uscript-deno tsconfig -o path/to/new/tsconfig.json
```
```
Written:
path/to/new/tsconfig.json
```## Notes
Template file data can be modified before installing and are located at [`data/templates.ts`](data/templates.ts)