Skip to content

Commit 32b2eb9

Browse files
committed
init
0 parents  commit 32b2eb9

File tree

13 files changed

+337
-0
lines changed

13 files changed

+337
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.yml]
11+
indent_style = space
12+
indent_size = 2

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/funding.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
patreon: abranhe
2+
open_collective: abranhe
3+
custom: https://cash.me/$abranhe

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: build
2+
on: [push]
3+
4+
jobs:
5+
test:
6+
name: Node.js ${{ matrix.node_version }}
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
node_version: [8, 10, 12]
11+
12+
steps:
13+
- uses: actions/checkout@master
14+
- name: Use Node.js ${{ matrix.node_version }}
15+
uses: actions/setup-node@v1
16+
with:
17+
version: ${{ matrix.node_version }}
18+
- name: Test
19+
run: |
20+
npm install
21+
npm test

.github/workflows/publish.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- uses: actions/setup-node@v1
13+
with:
14+
node-version: 12
15+
16+
publish-npm:
17+
name: Publish to npm
18+
needs: build
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v1
22+
- uses: actions/setup-node@v1
23+
with:
24+
node-version: 12
25+
registry-url: https://registry.npmjs.org/
26+
- run: npm publish
27+
env:
28+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
29+
30+
publish-gpr:
31+
name: Publish to GH Registry
32+
needs: build
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v1
36+
- uses: actions/setup-node@v1
37+
with:
38+
node-version: 12
39+
registry-url: https://npm.pkg.github.com/
40+
scope: '@abranhe'
41+
- name: Rename package to match GitHub repository
42+
run: |-
43+
sed -i"" -E "s|\"name\": \".*\"|\"name\": \"@${GITHUB_REPOSITORY}\"|" package.json
44+
- run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
45+
- run: npm publish --access public
46+
env:
47+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
yarn.lock
3+
DS_Store

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
language: node_js
2+
node_js:
3+
- '12'
4+
- '10'
5+
- '8'
6+
7+
notifications:
8+
email: false

index.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
'use strict';
2+
3+
module.exports = schema => {
4+
const {
5+
toJSON,
6+
normalizeId,
7+
removeVersion,
8+
removePrivatePaths,
9+
toJSON: {transform} = {}
10+
} = schema.options;
11+
12+
const json = {
13+
transform(doc, ret, options) {
14+
if (!removePrivatePaths) {
15+
const {paths} = schema;
16+
17+
for (const path in paths) {
18+
if (paths[path].options && paths[path].options.private) {
19+
if (ret[path]) {
20+
delete ret[path];
21+
}
22+
}
23+
}
24+
}
25+
26+
if (!removeVersion) {
27+
const {__v} = ret;
28+
29+
if (!__v) {
30+
delete ret.__v;
31+
}
32+
}
33+
34+
if (!normalizeId) {
35+
const {_id, id} = ret;
36+
37+
if (_id && !id) {
38+
ret.id = _id.toString();
39+
delete ret._id;
40+
}
41+
}
42+
43+
if (transform) {
44+
return transform(doc, ret, options);
45+
}
46+
}
47+
};
48+
49+
schema.options.toJSON = {...toJSON, ...json};
50+
};

license

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Abraham Hernandez <[email protected]> (abranhe.com)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)