Skip to content

Commit

Permalink
chore: update packages (#28)
Browse files Browse the repository at this point in the history
* chore: update packages

* chore: format files

* chore: fix typo in README

* chore: disable no explicit any rule

* refactor: types

* chore: update workflow

* chore: update workflow

* chore: update README

* 0.2.0

* chore: update package-lock.json

* chore: add release.yml

* chore: add security badge
  • Loading branch information
BatuhanW authored Dec 29, 2023
1 parent 85a8e69 commit 30c029a
Show file tree
Hide file tree
Showing 12 changed files with 4,070 additions and 4,199 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{ "code": 100, "tabWidth": 2, "ignoreComments": true, "ignoreTrailingComments": true }
],
"quotes": ["error", "single"],
"expect-type/expect": ["error", { "disableExpectTypeSnapshotFix": false }]
"expect-type/expect": ["error", { "disableExpectTypeSnapshotFix": false }],
"@typescript-eslint/no-explicit-any": "off"
}
}
31 changes: 12 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: main
on:
push:
branches:
- 'main'
- main
pull_request:
types:
- opened
Expand All @@ -14,37 +14,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install dependencies
uses: bahmutov/npm-install@v1
with:
useLockFile: false
run: npm ci

- name: Run ESLint
run: npx eslint . --ext .ts
run: npm run lint

test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [10, 12, 14, 15]
node: [16, 18, 20]

runs-on: ${{ matrix.os }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
uses: bahmutov/npm-install@v1
with:
useLockFile: false
run: npm ci

- name: Run tests
run: npm t
Expand All @@ -55,22 +51,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 12
node-version: 18

- name: Install dependencies
uses: bahmutov/npm-install@v1
with:
useLockFile: false
run: npm ci

- name: Codeclimate Test Coverage
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: npm run test:coverage
debug: true
19 changes: 19 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish Package to npmjs
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
with:
node-version: 18

- run: npm ci

- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.snap.json
package-lock.json
60 changes: 29 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# 🧠 🔒 Haf 🦺 ✏️

[![npm version](https://img.shields.io/npm/v/@batuhanw/haf.svg)](https://www.npmjs.com/package/@batuhanw/haf)
![CI](https://github.com/BatuhanW/haf/workflows/main/badge.svg)
[![Known Vulnerabilities](https://snyk.io/test/github/BatuhanW/haf/badge.svg?targetFile=package.json)](https://snyk.io/test/github/BatuhanW/haf?targetFile=package.json)
[![Maintainability](https://api.codeclimate.com/v1/badges/4315aa36678fe4181b77/maintainability)](https://codeclimate.com/github/BatuhanW/haf/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/4315aa36678fe4181b77/test_coverage)](https://codeclimate.com/github/BatuhanW/haf/test_coverage)
[![Dependencies](https://status.david-dm.org/gh/batuhanw/haf.svg)](https://status.david-dm.org/gh/batuhanw/haf)
[![Dev Dependencies](https://status.david-dm.org/gh/batuhanw/haf.svg?type=dev)](https://status.david-dm.org/gh/batuhanw/haf)

Haf is a fully typed 🔒, cross-platform, persistent 💾 config ⚙️ solution for your NodeJS projects with a great developer experience!

Expand Down Expand Up @@ -50,32 +50,30 @@ interface DogSchema {
### 2. Initiate Haf

```typescript
import Haf from '@batuhanw/haf'

const haf = new Haf<DogSchema>(
{
name: 'myDog',
defaultSchema: {
name: 'Pop',
age: 2,
toys: ['socks', 'toilet paper'],
vaccines: [
{ name: 'rabbies', date: '2020-01-01' },
{ name: 'parasite', date: '2020-01-01', next: '2020-01-03' },
],
appearance: {
eyeColor: 'brown',
hairColor: {
primary: 'white',
secondary: undefined,
otherColors: ['black'],
},
import Haf from '@batuhanw/haf';

const haf = new Haf<DogSchema>({
name: 'myDog',
defaultSchema: {
name: 'Pop',
age: 2,
toys: ['socks', 'toilet paper'],
vaccines: [
{ name: 'rabbies', date: '2020-01-01' },
{ name: 'parasite', date: '2020-01-01', nextDate: '2020-01-03' },
],
appearance: {
eyeColor: 'brown',
hairColor: {
primary: 'white',
secondary: undefined,
otherColors: ['black'],
},
sterilizedAt: undefined,
hasPuppies: false,
}
}
)
},
sterilizedAt: undefined,
hasPuppies: false,
},
});
```

### 3. Enjoy
Expand All @@ -100,7 +98,7 @@ haf.set('name', 'Pop');
haf.set('appearance.hairColor', { primary: 'white' });
haf.set('appearance.hairColor.secondary', 'brown');
haf.set('appearance.hairColor.secondary', undefined);
haf.set('appearance.hairColor.otherColors', ['black']) // This will overwrite existing array
haf.set('appearance.hairColor.otherColors', ['black']); // This will overwrite existing array

haf.set('name', 1); // type error
haf.set('toys', [1, 2]); // type error
Expand All @@ -114,11 +112,11 @@ haf.set('appearance.haircolor', { notExist: 'white' }); //type error
Appends given values to the existing array

```typescript
haf.get('toys') // ['socks', 'toilet paper']
haf.get('toys'); // ['socks', 'toilet paper']

haf.append('toys', 'human hand', 'bone')
haf.append('toys', 'human hand', 'bone');

haf.get('toys') // ['socks', 'toilet paper', 'human hand', 'bone']
haf.get('toys'); // ['socks', 'toilet paper', 'human hand', 'bone']
```

#### Delete
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ["spec/types.spec.ts"]
testPathIgnorePatterns: ['spec/types.spec.ts'],
};
Loading

0 comments on commit 30c029a

Please sign in to comment.