chore: added documentation

This commit is contained in:
Morten Olsen
2024-01-12 11:10:30 +01:00
committed by GitHub
parent 0cf2e44dec
commit fac5ba7d63
8 changed files with 882 additions and 18 deletions

View File

@@ -1,10 +1,18 @@
First lets install the CLI, which allow us to interact with a mini-loader server, but also run our workloads locally to validate that they are working
## Getting Started with mini loader CLI
Welcome to the mini loader CLI! This guide will walk you through the installation of the CLI, creating a simple script, and executing it locally to ensure everything works smoothly.
### Step 1: Install the CLI
The mini loader CLI is your gateway to interacting with a mini-loader server and running workloads locally for validation. Install it globally using npm with the following command:
```bash
npm install -g @morten-olsen/mini-loader-cli
```
Next we need a script - lets start simple with a script which will just output a single artifact called “hello”
### Step 2: Create Your First Script
Now, let's write a basic script that outputs a single artifact named “hello”. Create a new file with the following JavaScript code:
```javascript
import { artifacts } from "@morten-olsen/mini-loader";
@@ -12,18 +20,25 @@ import { artifacts } from "@morten-olsen/mini-loader";
artifacts.create('hello', 'world');
```
We save our script as `script.mjs`
Save this file as `script.mjs`.
Note that we are referencing a package we dont have. mini-loader support automatically downloading packages when it prepares the script. We could also have initialised a node project and installed the dependency (useful if you are using typescript and want typings)
#### A Note on Dependencies
In this script, we're using the `@morten-olsen/mini-loader` package, which might not be installed in your local environment. No worries though, as mini loader can automatically download necessary packages when preparing the script. Alternatively, for a more structured approach (especially if you're using TypeScript), you can initialize a Node.js project and install the dependencies for complete access to typings.
Next we want to execute our script locally to validate that it actually works as we intended
### Step 3: Run the Script Locally
To validate that your script is functioning correctly, execute it locally using the following command:
```bash
mini-loader local run script.mjs -ai
```
Note the `-ai` which tells the CLI to download any packages referenced when it bundles the script
The `-ai` flag instructs the CLI to automatically download any referenced packages when bundling the script.
This should output that the script indeed created a new artifact named “hello”
After running the command, you should see an output confirming that a new artifact named “hello” was created successfully.
[Next: setting up the server](./setup-server.md)
### What's Next?
Congratulations on setting up and running your first script with mini loader! You're now ready to take the next step.
[Next: Setting Up the Server](./setup-server.md)