Skip to content

Commit

Permalink
WIP: migrate to typescript and release v1. (#15)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
leafty authored Sep 30, 2021
1 parent 1c0a9cd commit 94d3963
Show file tree
Hide file tree
Showing 25 changed files with 7,547 additions and 1,253 deletions.
22 changes: 22 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
root: true,
env: {
node: true,
jest: true,
},
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
2 changes: 2 additions & 0 deletions .github/workflows/nodejs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ jobs:
run: yarn build
- name: Run tests
run: yarn test
- name: Run linter
run: yarn lint
150 changes: 146 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@

# Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node
# Custom paths

# Yarn v2 (not using Zero-Installs)
.yarn/*
!.yarn/releases
!.yarn/plugins
.pnp.*

# Created by https://www.gitignore.io/api/osx,git,vim,node,code,linux,windows
# Edit at https://www.gitignore.io/?templates=osx,git,vim,node,code,linux,windows

### Code ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### Node ###
# Logs
Expand All @@ -25,6 +69,7 @@ lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output
Expand All @@ -48,6 +93,9 @@ jspm_packages/
# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

Expand Down Expand Up @@ -76,6 +124,18 @@ typings/
# nuxt.js build output
.nuxt

# rollup.js default build output
dist/

# Uncomment the public line if your project uses Gatsby
# https://nextjs.org/blog/next-9-1#public-directory-support
# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
# public

# Storybook build outputs
.out
.storybook-out

# vuepress build output
.vuepress/dist

Expand All @@ -88,4 +148,86 @@ typings/
# DynamoDB Local files
.dynamodb/

# End of https://www.gitignore.io/api/node
# Temporary folders
tmp/
temp/

### OSX ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist

# Auto-generated tag files
tags

# Persistent undo
[._]*.un~

# Coc configuration directory
.vim

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/osx,git,vim,node,code,linux,windows
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"typescript.tsdk": ".vscode/pnpify/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
630 changes: 630 additions & 0 deletions .yarn/releases/yarn-sources.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarnPath: .yarn/releases/yarn-sources.js
5 changes: 0 additions & 5 deletions Makefile

This file was deleted.

31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ var config = yaml_config.load(__dirname + '/config/config.yml');
console.log(config);
```

Or with Typescript:
```ts
import { loadAsync } from 'node-yaml-config';

async function main() {
const config = await loadAsync(__dirname + '/config/config.yml');
console.log(config);
}
main();
```

## Configuration Files

In your configuration file:
Expand Down Expand Up @@ -52,6 +63,10 @@ production:
## API
### read(filename)
Reads the configuration found in `filename`.

### load(filename[, env])

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

The file is loaded synchronously.

### readAsync(filename)

Same as `read` but returns a Promise.

### loadAsync(filename[, env])

Same as `load` but returns a Promise.

**node-yaml-config** keeps parsed yaml files in memory to avoid reading files again.

### reloadAsync(filename)

Same as `reload` but returns a Promise.

## License

Copyright (c) 2012-2013 Johann-Michael Thiebaut <[johann.thiebaut@gmail.com](mailto:johann.thiebaut@gmail.com)>
Copyright (c) 2012-2021 Johann-Michael Thiebaut <[johann.thiebaut@gmail.com](mailto:johann.thiebaut@gmail.com)>

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:

Expand Down
5 changes: 5 additions & 0 deletions examples/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { load } from 'node-yaml-config';

const config = load('examples/config.yml');

console.log(config);
69 changes: 0 additions & 69 deletions lib/node-yaml-config.js

This file was deleted.

Loading

0 comments on commit 94d3963

Please sign in to comment.