Skip to content

Commit

Permalink
Switched package from babel to swc for faster test execution.
Browse files Browse the repository at this point in the history
Updated version for release.
Fixed missing fields in serialization.
  • Loading branch information
mbrich committed Jun 16, 2023
1 parent f9242c3 commit 8d083e6
Show file tree
Hide file tree
Showing 8 changed files with 2,054 additions and 962 deletions.
14 changes: 13 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
module.exports = {
extends: ['@toreda/eslint-config']
extends: ['@toreda/eslint-config'],
rules: {
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/prefer-namespace-keyword': 'error'
},
overrides: [
{
files: ['*.spec.ts'],
rules: {
'max-len': 'off'
}
}
]
};
7 changes: 7 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"jsc": {
"parser": {
"syntax": "typescript"
}
}
}
29 changes: 15 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ 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).

## [v1.0.0]
Renamed package to Fate.
Fate can be serialized into a string and be instantiate from a serialized string.
## [0.6.8] - 2023-06-16
* Fixed serialization bug where `errorCode` and `success` were not included during serialization, but were included when deserializing.

## [v0.3.0]
Defaults to fail on 1 or more errors.
can not succeed if payload is not set.
added isSuccess and isFailure methods.
complete method will try to set the state to failure or success
erros method returns a boolean for whether the ActionResult has failed
error method and message method accept any type and convert
new getData method return the payload or a list of errors if failure has occurred
payload can be set during instantiation

## [0.3.0]
* Defaults to fail on 1 or more errors but cann't succeed if payload is not set.
* Added `isSuccess` and `isFailure` methods.
* `complete` method will try to set the state to failure or success
* `errors` method returns a boolean for whether the ActionResult has failed
* `error` method and message method accept any type and convert
* New getData method return the payload or a list of errors if failure has occurred
* payload can be set during instantiation


### Added
- Initial early release. Project API is not stable until v1.0.0+

[v0.1.0]: https://github.com/toreda/action-result/compare/v0.0.0...v0.1.0
[unreleased]: https://github.com/toreda/action-result/compare/v0.0.0...HEAD
[0.6.8]: https://github.com/toreda/action-result/compare/v0.3.0...v0.6.8
[0.3.0]: https://github.com/toreda/action-result/compare/v0.1.0...v0.3.0
[0.1.0]: https://github.com/toreda/action-result/compare/v0.0.0...v0.1.0
[unreleased]: https://github.com/toreda/action-result/compare/v0.0.0...HEAD
10 changes: 5 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module.exports = {
'coverage/',
'webpack.config.js'
],
moduleFileExtensions: ['ts', 'js', 'json'],
moduleNameMapper: {'^src/(.*)': '<rootDir>/src/$1'},
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/'],
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest'
},
testRegex: '(/__tests__/.*|(\\.|/)(spec))\\.ts$',
testResultsProcessor: 'jest-sonar-reporter',
transform: {'^.+\\.tsx?$': 'ts-jest'}
moduleFileExtensions: ['ts', 'js', 'json'],
testResultsProcessor: 'jest-sonar-reporter'
};
41 changes: 20 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@toreda/fate",
"version": "0.6.7",
"version": "0.6.8",
"description": "",
"public": true,
"main": "./dist/index.js",
Expand All @@ -21,31 +21,30 @@
"prettier": "@toreda/prettier-config",
"homepage": "https://github.com/toreda/fate#readme",
"devDependencies": {
"@babel/register": "^7.16.7",
"@toreda/build-tools": "^0.6.4",
"@swc/core": "^1.3.64",
"@swc/jest": "^0.2.26",
"@toreda/build-tools": "^0.8.0",
"@toreda/eslint-config": "^2.2.0",
"@toreda/log": "^0.6.16",
"@toreda/prettier-config": "^1.0.1",
"@toreda/types": "^2.6.0",
"@toreda/strong-types": "^0.28.5",
"@toreda/types": "^2.16.0",
"@types/gulp": "^4.0.9",
"@types/jest": "^27.0.3",
"@types/node": "^17.0.7",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"@typescript-eslint/typescript-estree": "^5.7.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.1",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"@typescript-eslint/typescript-estree": "^5.59.11",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"gulp": "^4.0.2",
"gulp-typescript": "^6.0.0-alpha.1",
"jest": "^27.4.5",
"jest": "^29.5.0",
"jest-sonar-reporter": "^2.0.0",
"prettier": "^2.5.1",
"ts-jest": "^27.1.2",
"ts-loader": "^9.2.6",
"ts-node": "^10.4.0",
"typescript": "^4.5.4"
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
"typescript": "^5.1.3"
},
"dependencies": {
"@toreda/log": "^0.6.12",
"@toreda/strong-types": "^0.28.4"
}
"dependencies": {}
}
5 changes: 4 additions & 1 deletion src/fate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ export class Fate<T = unknown> {
const state: Record<string, unknown> = {
data: this.data,
errorThreshold: this.errorThreshold,
status: this.status()
status: this.status(),
done: this.done(),
errorCode: this.errorCode(),
success: this.success()
};

if (includeLogs) {
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
"strictPropertyInitialization": true,
"target": "es2015",
"traceResolution": false
},
"ts-node": {
"swc": true
}
}
Loading

0 comments on commit 8d083e6

Please sign in to comment.