Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions .github/workflows/build-and-push.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Build and test
on: push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: npm ci
- run: npm run fmt:check --workspaces
- run: npm run build:all
- run: npm run test --workspaces
12 changes: 5 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ on:
- "v*"
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -19,14 +13,18 @@ jobs:
- uses: actions/setup-node@v2
- uses: actions/configure-pages@v3
- run: npm ci
- run: npm run build:all
- run: npm run docs
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v1
with:
path: docs/

# Deployment job
deploy:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
pages: write
id-token: write
environment:
name: docs
url: ${{ steps.deployment.outputs.page_url }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ node_modules
.vscode
.nyc_output
dist
*.tsbuildinfo

docs
102 changes: 55 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,58 @@
# toolbox-devvit [![npm version](https://img.shields.io/npm/v/toolbox-devvit.svg)](https://www.npmjs.com/package/toolbox-devvit)

Helpers for working with /r/toolbox data from Devvit community apps. [Read the documentation.](https://toolbox-team.github.io/toolbox-devvit/)

## Installation

```bash
npm install --production toolbox-devvit
```

## Usage Example

```ts
import {Devvit} from '@devvit/public-api';
import {ToolboxClient} from 'toolbox-devvit';

Devvit.configure({
redditAPI: true,
// ...
});

// A simple action that creates a usernote on a post's author
Devvit.addMenuItem({
location: 'post',
label: 'Create Test Usernote',
description: 'Creates a Toolbox usernote for testing',
onPress: async (event, {reddit, ui, postId}) => {
const subredditName = (await reddit.getCurrentSubreddit()).name;
const username = (await reddit.getPostById(postId!)).authorName;
const text = 'Hihi i am a note';
const wikiRevisionReason = 'Create note via my custom app';

const toolbox = new ToolboxClient(reddit);
await toolbox.addUsernote(subredditName, {
username,
text,
}, wikiRevisionReason);

ui.showToast({
appearance: 'success',
text: 'Note added!',
});
},
});

export default Devvit;
```
# Toolbox Storage Helpers

A collection of packages for working with /r/toolbox data.

## Packages

See the README in each package for more information.

### [`toolbox-storage`](/packages/toolbox-storage/) [![npm version](https://img.shields.io/npm/v/toolbox-storage.svg)](https://www.npmjs.com/package/toolbox-storage)

Defines basic helpers classes for reading and manipulating the storage formats.
This package includes no data fetching/API helpers; you'll have to read to/write
from the relevant wiki pages yourself.

### [`toolbox-devvit`](/packages/toolbox-devvit/) [![npm version](https://img.shields.io/npm/v/toolbox-devvit.svg)](https://www.npmjs.com/package/toolbox-devvit)

Wraps the basic helpers in a Devvit-specific client class which handles data
fetching for you via Devvit's built-in API client.

## Development/Contributing

This project uses [npm workspaces][npm-workspaces]. Run `npm install` from the
root directory in order to install dependencies for all packages and create
`node_modules` symlinks for packages that depend on each other.

### Package scripts

Each package defines several scripts for itself, which include:

- `fmt` formats the package's source code.
- `fmt:check` checks the format without making any changes to files.
- `build` compiles the package and its tests.
- `test` runs the package's tests. Make sure you run `build` first.
- `coverage` compiles and runs tests and generates a test coverage report.

Each of these scripts can be run in two ways:

- To run for a single package, run `npm run <script>` from the package's
directory.
- To run for all packages at once, `npm run <script> --workspaces` from the
repo's root directory.

### Project scripts

These scripts are defined in the root `package.json` rather than in the
`package.json` of each individual package and are mostly used for CI/release
purposes. Run them with `npm run <script>` in the root directory.

- `build:all` builds all packages at once. This is functionally identical to
running the individual package `build` scripts, but avoids invoking Typescript
multiple times which makes it faster.
- `docs` generates API documentation for all packages at once, combining it
into a single folder for all packages which can be uploaded to Github Pages.

[npm-workspaces]: https://docs.npmjs.com/cli/using-npm/workspaces

## License

Expand Down
Loading