Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
dist
src/**/*.test.ts
57 changes: 55 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"plugins": ["@typescript-eslint", "autofix"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
Expand All @@ -15,6 +15,59 @@
"@typescript-eslint/explicit-module-boundary-types": ["error"],
"@typescript-eslint/member-ordering": ["error"],
"@typescript-eslint/no-unused-vars": ["error", { "ignoreRestSiblings": true }],
"@typescript-eslint/no-non-null-assertion": ["error"]
"@typescript-eslint/no-non-null-assertion": ["error"],
"arrow-body-style": ["error", "as-needed"],
"quotes": ["error", "single"],
"spaced-comment": ["error"],
"no-duplicate-imports": ["error"],
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports",
}
],
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "always-multiline"
}
],
"autofix/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true,
"destructuredArrayIgnorePattern": "^_"
}
],
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "classProperty",
"format": ["camelCase", "UPPER_CASE"],
"modifiers": ["private", "readonly", "static"]
},
{
"selector": "default",
"format": ["camelCase"]
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"]
},
{
"selector": "typeLike",
"format": ["PascalCase"]
},
{
"selector": "enumMember",
"format": ["PascalCase"]
}
],
"brace-style": ["error"]
}
}
26 changes: 0 additions & 26 deletions .github/workflows/main.yml

This file was deleted.

107 changes: 107 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: update
on:
push:
branches:
- 'feature/**'
- 'bugfix/**'
jobs:
setup:
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: checkout code
uses: actions/checkout@v3
- name: setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: install dependencies
run: npm install
- name: Zip code and environment variables
run: |
pwd
ls -lah
touch code.artifact.tar.gz
tar --exclude=code.artifact.tar.gz -czf code.artifact.tar.gz .
ls -lh code.artifact.tar.gz | awk '{ print "a tarball file named "$9" with a size of "$5" was successfully created."}'
- name: Upload code, env vars and dependencies artifacts
uses: actions/upload-artifact@v3
with:
name: code.artifact
retention-days: 1
path: code.artifact.tar.gz

coverage:
needs:
- setup
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Download code, env vars artifacts
uses: actions/download-artifact@v3
with:
name: code.artifact
path: .
- name: Unzip code and env vars
run: |
ls -la
ls -lh code.artifact.tar.gz | awk '{ print "a tarball file named "$9" with a size of "$5" was successfully recovered."}'
tar -xzf code.artifact.tar.gz
rm code.artifact.tar.gz
- name: setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Test
run: |
yarn run test:coverage

lint:
needs:
- setup
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Download code, env vars artifacts
uses: actions/download-artifact@v3
with:
name: code.artifact
path: .
- name: Unzip code and env vars
run: |
ls -la
ls -lh code.artifact.tar.gz | awk '{ print "a tarball file named "$9" with a size of "$5" was successfully recovered."}'
tar -xzf code.artifact.tar.gz
rm code.artifact.tar.gz
- name: setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: lint
run: |
yarn run lint

build:
needs:
- setup
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Download code, env vars artifacts
uses: actions/download-artifact@v3
with:
name: code.artifact
path: .
- name: Unzip code and env vars
run: |
ls -la
ls -lh code.artifact.tar.gz | awk '{ print "a tarball file named "$9" with a size of "$5" was successfully recovered."}'
tar -xzf code.artifact.tar.gz
rm code.artifact.tar.gz
- name: setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: build
run: |
yarn run build
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@typescript-eslint/parser": "^5.42.1",
"babel-jest": "^29.3.1",
"eslint": "^8.27.0",
"eslint-plugin-autofix": "^1.1.0",
"jest": "^29.3.1",
"nodemon": "^2.0.20",
"rimraf": "^3.0.2",
Expand Down
14 changes: 7 additions & 7 deletions src/Environment.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import StringDictReaderReadOnly from "./StringDictionaryReader/ReadOnly";
import StringDictReaderReadOnly from './StringDictionaryReader/ReadOnly';

enum EnvironmentName {
Development = "development",
Production = "production",
Test = "test",
Development = 'development',
Production = 'production',
Test = 'test',
}

class Environment extends StringDictReaderReadOnly {
private static readonly CURRENT_ENVIRONMENT_KEY = "NODE_ENV";
private static readonly CURRENT_ENVIRONMENT_KEY = 'NODE_ENV';

private defaultEnvironmentValues: Record<string, string> = {};

Expand All @@ -18,7 +18,7 @@ class Environment extends StringDictReaderReadOnly {
public get content(): Record<string, string> {
return {
...this.defaultEnvironmentValues,
...this.dict
...this.dict,
};
}

Expand All @@ -44,7 +44,7 @@ class Environment extends StringDictReaderReadOnly {
public getEnvName<T = string>(): EnvironmentName | T {
return this.get(
Environment.CURRENT_ENVIRONMENT_KEY,
EnvironmentName.Development
EnvironmentName.Development,
) as EnvironmentName | T;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Error/EnvironmentVariableParseError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class EnvironmentVariableParseError extends Error {
constructor(
public readonly variableName: string,
public readonly targetedType: TargetedType,
public readonly input: unknown
public readonly input: unknown,
) {
super(`Could not parse environment variable "${variableName}" as ${targetedType}. Input was "${input}".`);
}
Expand Down
12 changes: 6 additions & 6 deletions src/StringDictionaryReader/ReadOnly.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createReadStream, existsSync, readFileSync, ReadStream } from "fs";
import EnvironmentVariableParseError, { TargetedType } from "../Error/EnvironmentVariableParseError";
import UndefinedEnvironmentVariableError from "../Error/UndefinedEnvironmentVariableError";
import { type ReadStream, createReadStream, existsSync, readFileSync } from 'fs';
import EnvironmentVariableParseError, { TargetedType } from '../Error/EnvironmentVariableParseError';
import UndefinedEnvironmentVariableError from '../Error/UndefinedEnvironmentVariableError';

type ReadFileOptions = {
flags?: string | undefined;
Expand Down Expand Up @@ -102,13 +102,13 @@ class StringDictionaryReaderReadOnly {
encoding: 'utf8',
autoClose: true,
emitClose: true,
...options
}
...options,
},
);

return new Promise((resolve, reject) => {
stream.on('error', reject);
stream.on('open', () => { resolve(stream); });
stream.on('open', () => resolve(stream));
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/StringDictionaryReader/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import StringDictionaryReaderReadOnly from "./ReadOnly";
import StringDictionaryReaderReadOnly from './ReadOnly';

class StringDictionaryReader extends StringDictionaryReaderReadOnly {
public constructor(dict: Record<string, string> = {}) {
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Environment from "./Environment";
import StringDictionaryReader from "./StringDictionaryReader";
import StringDictionaryReaderReadOnly from "./StringDictionaryReader/ReadOnly";
import Environment from './Environment';
import StringDictionaryReader from './StringDictionaryReader';
import StringDictionaryReaderReadOnly from './StringDictionaryReader/ReadOnly';

export default Environment;
export { StringDictionaryReader, StringDictionaryReaderReadOnly };
28 changes: 27 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,22 @@ escape-string-regexp@^4.0.0:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==

eslint-plugin-autofix@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-autofix/-/eslint-plugin-autofix-1.1.0.tgz#157231b9e0f787e3d28e924da05cca46864960ce"
integrity sha512-aKQ7s6CTeJRJgnhSlsGI7kQhnNCa1q3UYBM+9PTEgvdC5b+GjV/SZA233VNqkoBldb7/BkeWBRjorUjxeUfrxA==
dependencies:
eslint-rule-composer "^0.3.0"
espree "^9.0.0"
esutils "^2.0.2"
lodash "^4.17.20"
string-similarity "^4.0.3"

eslint-rule-composer@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz#79320c927b0c5c0d3d3d2b76c8b4a488f25bbaf9"
integrity sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==

eslint-scope@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
Expand Down Expand Up @@ -2030,7 +2046,7 @@ eslint@^8.27.0:
strip-json-comments "^3.1.0"
text-table "^0.2.0"

espree@^9.4.0:
espree@^9.0.0, espree@^9.4.0:
version "9.4.1"
resolved "https://registry.yarnpkg.com/espree/-/espree-9.4.1.tgz#51d6092615567a2c2cff7833445e37c28c0065bd"
integrity sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==
Expand Down Expand Up @@ -2924,6 +2940,11 @@ lodash.merge@^4.6.2:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==

lodash@^4.17.20:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==

lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
Expand Down Expand Up @@ -3414,6 +3435,11 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

string-similarity@^4.0.3:
version "4.0.4"
resolved "https://registry.yarnpkg.com/string-similarity/-/string-similarity-4.0.4.tgz#42d01ab0b34660ea8a018da8f56a3309bb8b2a5b"
integrity sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
Expand Down