Skip to content

Commit 94d3963

Browse files
authored
WIP: migrate to typescript and release v1. (#15)
* Migrate to yarn v2 * Re-implemented in Typescript * Add eslint and prettier * Made API more consistent * Setup GitHub workflow * Removed Travis CI config * Updated README * Updated version
1 parent 1c0a9cd commit 94d3963

25 files changed

+7547
-1253
lines changed

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
sourceType: 'module',
6+
},
7+
plugins: ['@typescript-eslint/eslint-plugin'],
8+
extends: [
9+
'plugin:@typescript-eslint/eslint-recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
'prettier',
12+
],
13+
root: true,
14+
env: {
15+
node: true,
16+
jest: true,
17+
},
18+
rules: {
19+
'@typescript-eslint/interface-name-prefix': 'off',
20+
'@typescript-eslint/no-explicit-any': 'off',
21+
},
22+
};

.github/workflows/nodejs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ jobs:
2828
run: yarn build
2929
- name: Run tests
3030
run: yarn test
31+
- name: Run linter
32+
run: yarn lint

.gitignore

Lines changed: 146 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,50 @@
1-
2-
# Created by https://www.gitignore.io/api/node
3-
# Edit at https://www.gitignore.io/?templates=node
1+
# Custom paths
2+
3+
# Yarn v2 (not using Zero-Installs)
4+
.yarn/*
5+
!.yarn/releases
6+
!.yarn/plugins
7+
.pnp.*
8+
9+
# Created by https://www.gitignore.io/api/osx,git,vim,node,code,linux,windows
10+
# Edit at https://www.gitignore.io/?templates=osx,git,vim,node,code,linux,windows
11+
12+
### Code ###
13+
.vscode/*
14+
!.vscode/settings.json
15+
!.vscode/tasks.json
16+
!.vscode/launch.json
17+
!.vscode/extensions.json
18+
19+
### Git ###
20+
# Created by git for backups. To disable backups in Git:
21+
# $ git config --global mergetool.keepBackup false
22+
*.orig
23+
24+
# Created by git when using merge tools for conflicts
25+
*.BACKUP.*
26+
*.BASE.*
27+
*.LOCAL.*
28+
*.REMOTE.*
29+
*_BACKUP_*.txt
30+
*_BASE_*.txt
31+
*_LOCAL_*.txt
32+
*_REMOTE_*.txt
33+
34+
### Linux ###
35+
*~
36+
37+
# temporary files which can be created if a process still has a handle open of a deleted file
38+
.fuse_hidden*
39+
40+
# KDE directory preferences
41+
.directory
42+
43+
# Linux trash folder which might appear on any partition or disk
44+
.Trash-*
45+
46+
# .nfs files are created when an open file is removed but is still being accessed
47+
.nfs*
448

549
### Node ###
650
# Logs
@@ -25,6 +69,7 @@ lib-cov
2569

2670
# Coverage directory used by tools like istanbul
2771
coverage
72+
*.lcov
2873

2974
# nyc test coverage
3075
.nyc_output
@@ -48,6 +93,9 @@ jspm_packages/
4893
# TypeScript v1 declaration files
4994
typings/
5095

96+
# TypeScript cache
97+
*.tsbuildinfo
98+
5199
# Optional npm cache directory
52100
.npm
53101

@@ -76,6 +124,18 @@ typings/
76124
# nuxt.js build output
77125
.nuxt
78126

127+
# rollup.js default build output
128+
dist/
129+
130+
# Uncomment the public line if your project uses Gatsby
131+
# https://nextjs.org/blog/next-9-1#public-directory-support
132+
# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
133+
# public
134+
135+
# Storybook build outputs
136+
.out
137+
.storybook-out
138+
79139
# vuepress build output
80140
.vuepress/dist
81141

@@ -88,4 +148,86 @@ typings/
88148
# DynamoDB Local files
89149
.dynamodb/
90150

91-
# End of https://www.gitignore.io/api/node
151+
# Temporary folders
152+
tmp/
153+
temp/
154+
155+
### OSX ###
156+
# General
157+
.DS_Store
158+
.AppleDouble
159+
.LSOverride
160+
161+
# Icon must end with two \r
162+
Icon
163+
164+
# Thumbnails
165+
._*
166+
167+
# Files that might appear in the root of a volume
168+
.DocumentRevisions-V100
169+
.fseventsd
170+
.Spotlight-V100
171+
.TemporaryItems
172+
.Trashes
173+
.VolumeIcon.icns
174+
.com.apple.timemachine.donotpresent
175+
176+
# Directories potentially created on remote AFP share
177+
.AppleDB
178+
.AppleDesktop
179+
Network Trash Folder
180+
Temporary Items
181+
.apdisk
182+
183+
### Vim ###
184+
# Swap
185+
[._]*.s[a-v][a-z]
186+
[._]*.sw[a-p]
187+
[._]s[a-rt-v][a-z]
188+
[._]ss[a-gi-z]
189+
[._]sw[a-p]
190+
191+
# Session
192+
Session.vim
193+
Sessionx.vim
194+
195+
# Temporary
196+
.netrwhist
197+
198+
# Auto-generated tag files
199+
tags
200+
201+
# Persistent undo
202+
[._]*.un~
203+
204+
# Coc configuration directory
205+
.vim
206+
207+
### Windows ###
208+
# Windows thumbnail cache files
209+
Thumbs.db
210+
Thumbs.db:encryptable
211+
ehthumbs.db
212+
ehthumbs_vista.db
213+
214+
# Dump file
215+
*.stackdump
216+
217+
# Folder config file
218+
[Dd]esktop.ini
219+
220+
# Recycle Bin used on file shares
221+
$RECYCLE.BIN/
222+
223+
# Windows Installer files
224+
*.cab
225+
*.msi
226+
*.msix
227+
*.msm
228+
*.msp
229+
230+
# Windows shortcuts
231+
*.lnk
232+
233+
# End of https://www.gitignore.io/api/osx,git,vim,node,code,linux,windows

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"typescript.tsdk": ".vscode/pnpify/typescript/lib",
3+
"typescript.enablePromptUseWorkspaceTsdk": true
4+
}

.yarn/releases/yarn-sources.js

Lines changed: 630 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarnPath: .yarn/releases/yarn-sources.js

Makefile

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ var config = yaml_config.load(__dirname + '/config/config.yml');
2020
console.log(config);
2121
```
2222

23+
Or with Typescript:
24+
```ts
25+
import { loadAsync } from 'node-yaml-config';
26+
27+
async function main() {
28+
const config = await loadAsync(__dirname + '/config/config.yml');
29+
console.log(config);
30+
}
31+
main();
32+
```
33+
2334
## Configuration Files
2435

2536
In your configuration file:
@@ -52,6 +63,10 @@ production:
5263
5364
## API
5465
66+
### read(filename)
67+
68+
Reads the configuration found in `filename`.
69+
5570
### load(filename[, env])
5671

5772
Load the configuration found in `filename` with the environment based on `NODE_ENV`. The environment can be forced with the `env` argument.
@@ -64,9 +79,23 @@ Reload the configuration found in `filename`. Later calls to `load` will show th
6479

6580
The file is loaded synchronously.
6681

82+
### readAsync(filename)
83+
84+
Same as `read` but returns a Promise.
85+
86+
### loadAsync(filename[, env])
87+
88+
Same as `load` but returns a Promise.
89+
90+
**node-yaml-config** keeps parsed yaml files in memory to avoid reading files again.
91+
92+
### reloadAsync(filename)
93+
94+
Same as `reload` but returns a Promise.
95+
6796
## License
6897

69-
Copyright (c) 2012-2013 Johann-Michael Thiebaut <[[email protected]](mailto:[email protected])>
98+
Copyright (c) 2012-2021 Johann-Michael Thiebaut <[[email protected]](mailto:[email protected])>
7099

71100
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:
72101

0 commit comments

Comments
 (0)