Skip to content
Merged

v5 #33

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
443178f
chore: update license
ghostdevv Sep 4, 2022
0291aa9
chore: update settings
ghostdevv Sep 4, 2022
61aaf36
chore: update workflows
ghostdevv Sep 4, 2022
2982d68
feat: wip
ghostdevv Sep 4, 2022
6913959
feat: create method
ghostdevv Sep 4, 2022
46fda81
chore: remove old
ghostdevv Sep 4, 2022
610ad3e
refactor: move url to methods
ghostdevv Sep 4, 2022
268ba70
chore: update exports
ghostdevv Sep 4, 2022
7dbc952
refactor: make util
ghostdevv Sep 4, 2022
19b35f8
feat: type linguist
ghostdevv Sep 4, 2022
35eac40
refactor: fix type
ghostdevv Sep 4, 2022
082d086
feat: type linguist
ghostdevv Sep 4, 2022
4c1a511
refactor: improve resolveLanguageId
ghostdevv Sep 4, 2022
6bda887
fix: type
ghostdevv Sep 4, 2022
cd113e5
fix: include default for create
ghostdevv Sep 4, 2022
f10922f
feat: wip testing
ghostdevv Sep 4, 2022
e70b47e
fix: improve getting
ghostdevv Sep 4, 2022
c2317df
fix: tests
ghostdevv Sep 4, 2022
0fbceee
feat: test structures
ghostdevv Sep 4, 2022
814b664
refactor: shift responsibility of file index
ghostdevv Sep 4, 2022
299e553
refactor: capitalise readme
ghostdevv Sep 4, 2022
4618453
docs: wip
ghostdevv Sep 4, 2022
5c947ae
fix: fn parameter
ghostdevv Sep 4, 2022
af83214
docs: update
ghostdevv Sep 4, 2022
3877901
docs: update
ghostdevv Sep 4, 2022
e5129a9
fix: exports
ghostdevv Sep 4, 2022
f14b49b
feat: docs
ghostdevv Sep 4, 2022
3cb48b9
docs: update
ghostdevv Sep 4, 2022
05fba46
chore: update build
ghostdevv Sep 5, 2022
d7e711a
fix: repo name
ghostdevv Sep 5, 2022
3bb3bd4
chore: update exports
ghostdevv Sep 5, 2022
0712ba8
docs: update
ghostdevv Sep 5, 2022
5a04f6a
fix: add files
ghostdevv Sep 5, 2022
589fea5
fix: use options.
ghostdevv Sep 5, 2022
62bff2c
chore: update version
ghostdevv Sep 5, 2022
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
37 changes: 24 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
name: Test Suite CI
name: Tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm i
- run: npm test
- uses: actions/checkout@v2

- name: Setup Node 16
uses: actions/setup-node@v1
with:
node-version: 16
registry-url: https://registry.npmjs.org/

- name: Setup PNPM
uses: pnpm/[email protected]
with:
version: 7.0.0

- name: Install
run: pnpm install

- name: Test
run: pnpm test
35 changes: 0 additions & 35 deletions .github/workflows/release-cd.yml

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release Package & Test

on:
release:
types: [created]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v2

- name: Setup Node 16
uses: actions/setup-node@v1
with:
node-version: 16
registry-url: https://registry.npmjs.org/

- name: Setup PNPM
uses: pnpm/[email protected]
with:
version: 7.0.0

- name: Install
run: pnpm install

- name: Test
run: pnpm test

publish-npm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node 16
uses: actions/setup-node@v1
with:
node-version: 16
registry-url: https://registry.npmjs.org/

- name: Setup PNPM
uses: pnpm/[email protected]
with:
version: 7.0.0

- name: Install
run: pnpm install

- name: Build
run: pnpm build

- name: Publish
run: |
pnpm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}"
pnpm publish --no-git-checks
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
dev
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,17 @@
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[svelte]": {
"editor.defaultFormatter": "svelte.svelte-vscode",
"editor.formatOnSave": true
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features",
"editor.formatOnSave": true
}
}
8 changes: 7 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
SEE: https://ghosts-tools.mit-license.org/
Copyright © 2022 - Present GHOST <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
168 changes: 168 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Sourcebin

[![](https://img.shields.io/npm/v/sourcebin?label=Latest%20Version&style=for-the-badge&logo=npm&color=informational)](https://www.npmjs.com/package/sourcebin)
[![](https://img.shields.io/static/v1?label=Project%20Creator&message=GHOST&color=informational&style=for-the-badge)](https://ghostdev.xyz)
[![](https://img.shields.io/github/workflow/status/ghostdevv/sourcebin/Test%20Suite%20CI?style=for-the-badge)](https://github.com/ghostdevv/sourcebin)

Fast and simple package to get and create bins from [sourcebin](https://sourceb.in/)

# Requirements

```
NodeJS >= 14.x
```

# Install

```
npm install sourcebin
```

# Docs

This README is the best place to learn how to use this package, you can also [take a look at our API docs](https://ghostdevv.github.io/sourcebin/index.html)

# Setup

```js
// Import individual methods
import { create, get, url } from 'sourcebin';

// Import all methods
import * as sourcebin from 'sourcebin';

// Use required
const { create, get, url } = require('sourcebin');
```

# Get a bin

`get(options)`

```js
const bin = await get({
key: 'qXO2NVhRc6'
});
```

## Options

| Option | Description | Default | Required |
|----------------|-----------------------------------|---------|----------|
| `key` | The key to get | n/a | ✅ |
| `fetchContent` | Should the bin content be fetched | `true` | ❌ |

# Create a bin

`create(options)`

```js
const bin = await create(
{
title: 'bin name',
description: 'test bin',
files: [
{
content: 'Hello World',
language: 'text',
},
],
},
);
```

## Options

| Option | Description | Required |
|----------------|------------------------|----------|
| `title` | Title of the bin | ❌ |
| `description` | Description of the bin | ❌ |
| `files` | Bin files - see below | ✅ |

### File Options

| Option | Description | Default | Required |
|----------------|----------------------------------|---------|----------|
| `content` | Contents of the file | n/a | ✅ |
| `language` | What language should the file be | `text` | ❌ |

# Url Helper

If you want to get information about a bin try the `url` function.

```js
const urlData = url('iQznILdZRP');

// or

const urlData = url('https://sourceb.in/iQznILdZRP');
```

This returns an object that looks like:

```js
{
key: 'iQznILdZRP',
url: 'https://sourceb.in/iQznILdZRP',
short: 'http://srcb.in/iQznILdZRP'
}
```

# FAQ

- ## Multiple files in one bin

This is not currently possible with this wrapper as sourcebin doesn't have a token system for authentication, only pro users are able to have multiple files in one bin. This may come in the future

- ## Migrate from v4 to v5

v5 is a overhaull of `sourcebin` so we changed some apis.

### Get a bin

Instead of passing the `key` then `options` it's now one object.

```diff
- const bin = await get('qXO2NVhRc6');
+ const bin = await get({ key: 'qXO2NVhRc6' });

- const bin = await get('qXO2NVhRc6', { fetchContent: false });
+ const bin = await get({ key: 'qXO2NVhRc6', fetchContent: false });
```

### Create a bin

We also unified the options for this function:

```diff
- const bin = await create(
- [
- {
- content: 'Hello World',
- language: 'text',
- },
- ],
- {
- title: 'bin name',
- description: 'test bin',
- },
- );

+ const bin = await create(
+ {
+ title: 'bin name',
+ description: 'test bin',
+ files: [
+ {
+ content: 'Hello World',
+ language: 'text',
+ },
+ ],
+ }
+ );
```

# Support

- Join the [discord](https://discord.gg/2Vd4wAjJnm)
- Create a issue on the [github](https://github.com/ghostdevv/sourcebin)
1 change: 1 addition & 0 deletions docs/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
Loading