Skip to content

Commit

Permalink
feat: support node >= 14 and browserify (drop spread operator for Obj…
Browse files Browse the repository at this point in the history
…ect.assign), bump deps, modernize project setup with GitHub CI
  • Loading branch information
titanism committed Nov 9, 2022
1 parent 054ae90 commit 7cbe1ef
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 7,159 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional']
};
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.*.js
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* text=auto
* text=auto eol=lf
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI
on:
- push
- pull_request
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
node_version:
- 14
- 16
- 18
name: Node ${{ matrix.node_version }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@
node_modules
coverage
.nyc_output
locales/
package-lock.json
yarn.lock

Thumbs.db
tmp/
temp/
*.lcov
.env
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install lint-staged && npm test
5 changes: 5 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
"*.md": filenames => filenames.map(filename => `remark ${filename} -qfo`),
'package.json': 'fixpack',
'*.js': 'xo --fix'
};
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
singleQuote: true,
bracketSpacing: true,
trailingComma: 'none'
};
1 change: 0 additions & 1 deletion .remarkignore

This file was deleted.

3 changes: 3 additions & 0 deletions .remarkrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: ['preset-github']
};
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .xo-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
prettier: true,
space: true,
extends: ['xo-lass']
};
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# [**@ladjs/env**](https://github.com/ladjs/env)

[![build status](https://img.shields.io/travis/ladjs/env.svg)](https://travis-ci.org/ladjs/env)
[![code coverage](https://img.shields.io/codecov/c/github/ladjs/env.svg)](https://codecov.io/gh/ladjs/env)
[![build status](https://github.com/ladjs/env/actions/workflows/ci.yml/badge.svg)](https://github.com/ladjs/env/actions/workflows/ci.yml)
[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)
Expand All @@ -27,12 +26,6 @@
npm install @ladjs/env
```

[yarn][]:

```sh
yarn add @ladjs/env
```


## Usage

Expand Down Expand Up @@ -82,6 +75,4 @@ const env = require('@ladjs/env')({

[npm]: https://www.npmjs.com/

[yarn]: https://yarnpkg.com/

[dotenv-extended]: https://github.com/keithmorris/node-dotenv-extended
32 changes: 18 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@ const Mustache = require('mustache');
const dotenvParseVariables = require('dotenv-parse-variables');

const setupEnv = (config = {}) => {
config = {
encoding: 'utf8',
silent: true,
path: '.env',
defaults: '.env.defaults',
schema: '.env.schema',
errorOnMissing: true,
errorOnExtra: false,
errorOnRegex: false,
includeProcessEnv: true,
assignToProcessEnv: true,
overrideProcessEnv: false,
...config
};
// eslint-disable-next-line prefer-object-spread
config = Object.assign(
{
encoding: 'utf8',
silent: true,
path: '.env',
defaults: '.env.defaults',
schema: '.env.schema',
errorOnMissing: true,
errorOnExtra: false,
errorOnRegex: false,
includeProcessEnv: true,
assignToProcessEnv: true,
overrideProcessEnv: false
},
config
);

let env = dotenvExtended.load(config);
const keys = Object.keys(env);
Expand All @@ -35,6 +38,7 @@ const setupEnv = (config = {}) => {
}

env = dotenvParseVariables(env);
// eslint-disable-next-line n/prefer-global/process
Object.assign(process.env, env);
return env;
};
Expand Down
107 changes: 34 additions & 73 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,104 +13,65 @@
"dependencies": {
"dotenv-extended": "^2.9.0",
"dotenv-parse-variables": "^2.0.0",
"mustache": "^4.1.0"
"mustache": "^4.2.0"
},
"devDependencies": {
"ava": "^3.15.0",
"codecov": "^3.8.1",
"@commitlint/cli": "^17.2.0",
"@commitlint/config-conventional": "^17.2.0",
"ava": "^5.0.1",
"codecov": "^3.8.2",
"cross-env": "^7.0.3",
"eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.3.1",
"husky": "^5.0.9",
"lint-staged": "^10.5.4",
"eslint": "^8.27.0",
"eslint-config-xo-lass": "^2.0.1",
"fixpack": "^4.0.0",
"husky": "^8.0.2",
"lint-staged": "^13.0.3",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"remark-cli": "^9.0.0",
"remark-preset-github": "^4.0.1",
"xo": "^0.37.1"
"remark-cli": "^11.0.0",
"remark-preset-github": "^4.0.4",
"xo": "^0.52.4"
},
"engines": {
"node": ">=8.3"
"node": ">=14"
},
"files": [
"index.js"
],
"homepage": "https://github.com/ladjs/env",
"keywords": [
".env",
"@ladjs/env",
"lass",
"env",
"config",
"configuration",
"development",
"dot",
"dotenv",
"twelve",
"dynamic",
"env",
"environment",
"factor",
".env",
"dot",
"variable",
"parse",
"file",
"environment",
"config",
"configuration",
"lass",
"load",
"dynamic",
"specific",
"parse",
"production",
"development"
"specific",
"twelve",
"variable"
],
"license": "MIT",
"lint-staged": {
"*.{js,jsx,mjs,ts,tsx,css,less,scss,json,graphql}": [
"prettier --write --single-quote --trailing-comma none",
"git add"
],
"*.md": [
"remark . -qfo",
"git add"
]
},
"main": "index.js",
"remarkConfig": {
"plugins": [
"preset-github"
]
},
"repository": {
"type": "git",
"url": "https://github.com/ladjs/env"
},
"scripts": {
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"lint": "xo && remark . -qfo",
"lint": "xo --fix && remark . -qfo && fixpack",
"precommit": "lint-staged && npm test",
"test": "npm run lint && npm run test-coverage",
"prepare": "husky install",
"pretest": "npm run lint",
"test": "npm run test-coverage",
"test-coverage": "nyc ava"
},
"xo": {
"extends": "prettier",
"plugins": [
"prettier"
],
"parserOptions": {
"sourceType": "script"
},
"rules": {
"prettier/prettier": [
"error",
{
"singleQuote": true,
"bracketSpacing": true,
"trailingComma": "none"
}
],
"max-len": [
"error",
{
"code": 80,
"ignoreUrls": true
}
],
"capitalized-comments": "off",
"camelcase": "off",
"no-warning-comments": "off"
},
"space": true
}
}
2 changes: 2 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const process = require('process');
const path = require('path');

const test = require('ava');

const env = require('..');
Expand Down
Loading

0 comments on commit 7cbe1ef

Please sign in to comment.