Skip to content

Commit

Permalink
update package
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Apr 19, 2023
1 parent b23bac4 commit f60bcbc
Show file tree
Hide file tree
Showing 18 changed files with 528 additions and 867 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ dist
# Runme wasm download dir
/wasm

deno.lock
.bin
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.11.0
v18.15.0
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2022-2023] Stateful Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
91 changes: 25 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Runme.js [![Test Changes](https://github.com/stateful/runmejs/actions/workflows/test.yaml/badge.svg)](https://github.com/stateful/runmejs/actions/workflows/test.yaml) [![npm version](https://badge.fury.io/js/runme.svg)](https://badge.fury.io/js/runme) [![deno module](https://shield.deno.dev/x/runme)](https://deno.land/x/runme)

> A JavaScript module to use Runme in Node.js, Deno or browser environments.
> A JavaScript module to use [Runme](https://runme.dev) in Node.js.
_Runme.js_ contains the the [Runme CLI](https://github.com/stateful/runme) as WASM and allows to access its functionality through a simple JavaScript interface.
_Runme.js_ contains the the [Runme CLI](https://github.com/stateful/runme) and allows to access its functionality through a simple JavaScript interface. The CLI binary is downloaded and cached when the interface is first being used.

## Install

You can run this module in Node.js and Deno environments.

### Node.js

Install the module through NPM:
Expand All @@ -25,80 +23,41 @@ npm i -g runme
runme list
```

### Deno

You can import the module directly from the Deno module hosting service via `https://deno.land/x/runme@0.4.3/mod.ts`.

## Usage

The module exposes the following methods:

### `deserialize`
### `run`

Deserialize markdown into an AST:
Run code cells from markdown files:

```ts
import { deserialize } from 'runme'
// or when using Deno:
// import { deserialize } from 'https://deno.land/x/runme@0.4.3/mod.ts'

console.log(await deserialize(
'## Hello World\n' +
'```sh\n' +
'echo "Hello World"\n'
'```'
))
/**
* outputs:
* [{
* kind: 1,
* languageId: "",
* value: "# Hello World",
* }, {
* kind: 2,
* languageId: "sh",
* metadata: {
* "runme.dev/name": "echo-hello",
* },
* value: 'echo "Hello World"',
* }]
*/
```ts { name="runExample" }
import { run } from 'runme'

await run(
'./README.md',
{ id: 'runExample' }
)
```

### `serialize`
### `server`

Serialize an AST into markdown:
Start a Runme execution session:

```ts
import { serialize } from 'runme'
// or when using Deno:
// import { serialize } from 'https://deno.land/x/runme@0.4.3/mod.ts'

console.log(await serialize([
{
kind: 1,
value: '# Hello World'
}, {
kind: 2
languageId: 'sh',
value: 'echo "Hello World"'
}
])

/**
* outputs:
* -----------------------
* ## Hello World
*
* ```sh
* echo "Hello World"
* ```
*
* -----------------------
*/
import { createServer, run } from 'runme'

const server = await createServer('localhost:1234')
await run(
'./README.md',
{ id: 'runExample', server }
)
```

---

<p align="center"><small>Copyright 2022 © <a href="http://stateful.com/">Stateful</a> – Apache 2.0 License</small></p>
'# Hello World\n```sh\n```'),
<p align="center">
<small>
Copyright 2023 © <a href="http://stateful.com/">Stateful</a> – Apache 2.0 License
</small>
</p>
3 changes: 0 additions & 3 deletions deno.json

This file was deleted.

5 changes: 0 additions & 5 deletions import_map.json

This file was deleted.

Loading

0 comments on commit f60bcbc

Please sign in to comment.