Dyarn
General info
Dyarn: the Deno runner help.
After the Disq Code Bot team discovered Deno and some of itâs magic with typescript, we decided using it instead of Node. But we only missed two little things: the package.json with itâs scripts property and the yarn <script> (or npm run <script> if you prefer). So we created dyarn, to help you with running scripts using config.json file that is supported by Deno and that latter be automatically imported (based on Denoâs documentation: https://deno.land/manual@v1.17.1/getting_started/configuration_file).
We plan on maybe adding some more things that we miss from Nodeâs packages managers, to make Deno workflow even more efficient.
If you have any suggestion, donât mind opening an issue please!!
Technologies
Dependency free!
Setup
Note: Deno must be installed in your local environment. Tested on version 1.17, if you spot a problem in other versions, please do not hesitate opening an issue
- âŚDownload
# Using Deno install
deno install --allow-run --allow-read --name dyarn https://deno.land/x/dyarn@v1.0.3/mod.tsNote: You must give run and read permissions, to script (if not given at install youâll be prompted at runtime, but we highly recomed to grant at install, we are trying to make things easier, not adding additional prompts). Otherwise, script wonât be able to access/run required files
- âŚUsage
After installing, in your projectâs root directory, add a
config.jsonfile where weâl add the scripts config:
{
"dyarnOptions": {
//Here you'll pass you main file path, by default runner will search for a "mod.ts" file in the current running directory
"mainFile": "mod.ts",
//Here you'l provide all your scripts with their command/alias, Deno command and Deno flags
"scripts": {
"dev": {
//Deno original commands
"invoker": "run",
//Deno original flags
"flags": "--watch --all"
}
}
}
}- ⌠finally running
dyarn <script name> <dyarn flags>Voila, you should be able to see your script runningâŚ
Uninstalling
deno uninstall dyarnConfigs file
As our objective is to make you life a little easier with Deno commands, adding a custom config file or adding more flags, well⌠wouldnât help a lot. So by default (you may if you wanât, change this with the: --config={path} flag after dyarn invoker) dyarn uses Deno recommended config file name (and later auto identifiable file by Deno): config.json.
All dyarn options should be passed inside the dyarnOptions keys inside the config.json file.
{
"dyarnOptions": {
//...
// Your options here
}
}And here is the json schema/options:
mainFile: Your main file that will be ran by default. Is not required and if not defined will look for amod.tsfile.scripts: Here youâll pass all the scripts you want to use with dyarn inside an object. The scripts keys will be the commands used when running dyarn⌠e.g.: in dyarn config"scripts": { "dev": {...} }}will be dyarn dev in your CLI. At least one script is strictly required (why? well for the moment if it isnât for this, dyarn is basically useless. We plan on adding more functionalities, but for the moment this is it). Each script is an object that accepts the following properties:invoker: the original Deno command that Deno will run when you run dayrn with the respective script (parent key). This option is required in every scriptflags: the original Deno flags that Deno will run along with the Deno invoker when you use dyarn. This option is not required. This way your app will run with no permissions. Dyarn will pass them before passing your file path
(More about Deno flags)
customFile: in case you wanât to run a different file for this specific script, you may use this option. As the other options, it does not affect your other scripts. This option is not required. (may be useful for running test por example, which normally requires to reference a different file, e.g.:_tests/test_mod.ts)Note: If defined, will override your
mainFileoption in dyarnâs root config for this scriptappFlags: you may sometimes define flags inside your own apps, so we added this where you can put them. As they are custom and should be read by your app, Dyarn passes them after passing your app path on the CLI, just as when running Deno commandâs directly in the CLI. Not required and have no influence neither on Deno nor Dyarn.
Dyarn flags
These flags are custom dyarn flags and are not at all related to Deno neither influence in your Appâs runtime:
--config=: if you wanât to create a custom dyarn config file or put it in a custom directory
Contributing
For contributions, you may open an issue or pull request, we will give a look into it and decide whaât should be done. But before consider following these for:
- new features: fork this repo and create a new branch under this name format âfeature/â
- fixes: fork this repo and create a new branch following this format âfix/â (in both cases open a pul request when finished)