Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldszar committed Jun 24, 2020
0 parents commit bf74e2b
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Github CI

on:
pull_request:
branches:
- master

push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12

- name: Install
run: npm install

- name: Test
run: npm test

- name: Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
yarn.lock
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
11 changes: 11 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Conf = require('conf');

declare namespace Vault {
interface Options<T> extends Omit<Conf.Options<T>, 'configName' | 'cwd' | 'projectName' | 'projectSuffix' | 'projectVersion'> {}
}

declare class Vault<T> extends Conf<T> {
constructor(nodecg: any, options?: Vault.Options<T>);
}

export = Vault;
15 changes: 15 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const Conf = require('conf');

class Vault extends Conf {
constructor(nodecg, options) {
super({
...options,
configName: nodecg.bundleName,
projectName: nodecg.bundleName,
projectVersion: nodecg.bundleVersion,
cwd: 'db/vaults'
});
}
}

module.exports = Vault;
4 changes: 4 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {expectType} from 'tsd';
import Vault = require('.');

expectType<Vault<any>>(new Vault<any>(null));
21 changes: 21 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020-present Alexandre Breteau

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.
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "nodecg-vault",
"version": "0.0.0-development",
"description": "Add vaults to NodeCG for storing bundle secrets",
"author": "Alexandre Breteau <contact@seldszar.fr> (https://seldszar.fr)",
"repository": "seldszar/nodecg-vault",
"license": "MIT",
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"nodecg",
"vault"
],
"dependencies": {
"conf": "^6.2.4"
},
"devDependencies": {
"@commitlint/cli": "^9.0.1",
"@commitlint/config-conventional": "^9.0.1",
"ava": "^3.9.0",
"husky": "^4.2.5",
"lint-staged": "^10.2.11",
"tsd": "^0.11.0",
"xo": "^0.32.0"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,ts}": "xo --fix"
}
}
28 changes: 28 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# nodecg-vault

> Add vaults to NodeCG for storing bundle secrets.
# Install

```bash
$ npm install nodecg-vault
```

# Usage

```javascript
const Vault = require('nodecg-vault');

export = (nodecg) => {
const vault = new Vault(nodecg);

// Writes a new secret
vault.set("mySecret", "Spark is the best!");

// Reads the secret
console.log(vault.get("mySecret"));

// Deletes the secret
vault.delete("mySecret");
};
```
22 changes: 22 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const test = require('ava');
const fs = require('fs');
const Vault = require('.');

const nodecg = {
bundleName: 'lorem',
bundleVersion: '1.0.0'
};

test.afterEach(() => {
fs.rmdirSync('db', {recursive: true});
});

test('creates a new vault', t => {
const vault = new Vault(nodecg, {
defaults: {
mySecret: 'Spark is the best!'
}
});

t.is(vault.get('mySecret'), 'Spark is the best!');
});

0 comments on commit bf74e2b

Please sign in to comment.