Skip to content

Commit

Permalink
Merge pull request #30 from GhassenRjab/feat/typescript
Browse files Browse the repository at this point in the history
Migrate project to TypeScript
  • Loading branch information
GhassenRjab authored Jan 6, 2024
2 parents c5c0f3f + 5f68a6f commit 09e881d
Show file tree
Hide file tree
Showing 31 changed files with 3,894 additions and 11,438 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ end_of_line = crlf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
trim_trailing_whitespace = true
13 changes: 13 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-env node */
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
env: {
node: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
};
16 changes: 0 additions & 16 deletions .eslintrc.json

This file was deleted.

18 changes: 9 additions & 9 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
17 changes: 0 additions & 17 deletions .github/workflows/sync-base-branches.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/sync-main-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Sync main branch
on:
push:
branches:
- main
jobs:
sync-codecov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm ci
- run: npm run test:coverage
- uses: codecov/codecov-action@v3
add-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm ci
- name: Extract package version
id: pkg
run: echo "::set-output name=version::$(node -p "require('./package.json').version")"
- name: Create Tag
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git tag v${{ steps.pkg.outputs.version }}
git push origin v${{ steps.pkg.outputs.version }}
9 changes: 5 additions & 4 deletions .github/workflows/validate-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ jobs:
run-validations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
node-version: "20"
- run: npm ci
- run: npm run format:check
- run: npm run lint
- run: npm run test:coverage
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
8 changes: 7 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
# Source files
/src

# Benchmark files
/benchmark

# Fixtures
/fixtures

# Code coverage
/coverage

Expand All @@ -12,7 +18,7 @@
/.eslintrc.json
/.eslintignore
/babel.config.json
/rollup.config.js
/tsconfig.json
/.gitattributes
/MIGRATING.md
/CONTRIBUTING.md
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [4.0.0]

### Changed
### Changed [4.0.0]

- [#27](https://github.com/GhassenRjab/categorize/pull/27) Use NodeJS 16 in CI and update dependencies ([@GhassenRjab](https://github.com/GhassenRjab))
- [e9a23f0](https://github.com/GhassenRjab/categorize/commit/e9a23f0) Update dependencies ([@GhassenRjab](https://github.com/GhassenRjab))
- Migrate project to TypeScript
- Improve performance

## [3.2.5] - 2021-05-16

Expand Down
13 changes: 8 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

Pull requests are welcome.

The project contains two main branches:
The project's main branch is `main`. It contains the latest released code.

- `main`: contains the latest released code;
- `develop`: contains active development.
New feature branches should be created based on `main` branch.

Branches for new futures should be created based on `develop` branch.
We need to update package.json version inside our feature branch according to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Branches for fixes should be created based on main `branch`.
Once a feature branch is merged, GitHub Actions will create a tag based on package.json version.

GitHub will create a draft release based on this tag.

We need to publish this release first. GitHub Actions will publish the new version to npm once the release is published.
28 changes: 28 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Migration guides

## From v3 to v4

Two new breaking changes have been introduced with v4

### Named exports

We no use named exports. Hence `categorize` needs to be imported with this syntax

CommonJS syntax

```js
const { categorize } = require("categorize");
```

ESM syntax

```js
import { categorize } from "categorize";
```

### A new options parameter

By default an item is matched only with the first category. If your categories can host items from other categories you should set `singleCategoryMatch` to `false` in the third and optional parameter `options`

```js
const result = categorize(items, categories, { singleCategoryMatch: false });
```

## From v2 to v3

No migrations needed with this version. We just added `rollup` as build tool and added the browser build in our examples.
Expand Down
Loading

0 comments on commit 09e881d

Please sign in to comment.