Skip to content

Commit

Permalink
Drop support for node 16 (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dulajdeshan authored Feb 11, 2024
1 parent b652ee7 commit 92a4cc9
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 143 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js/16
- name: Use Node.js/18
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
Expand All @@ -28,4 +28,4 @@ jobs:
- name: Install dependencies
run: yarn
- name: Lint
run: yarn lint
run: yarn lint
5 changes: 2 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Publish
on:
release:
Expand All @@ -10,8 +9,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
- run: yarn
- run: yarn publish
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js/16
- name: Use Node.js/18
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
Expand All @@ -28,4 +28,4 @@ jobs:
- name: Install dependencies
run: yarn
- name: Test
run: yarn test
run: yarn test
68 changes: 40 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<img style="width: 100%; height: auto;" src="public/preview.png" alt="UI preview" />
</div>

A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provides an integration with powerful
[mathjs](https://mathjs.org/) library.
A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provides an integration with powerful
[mathjs](https://mathjs.org/) library.

## Table of Contents

Expand All @@ -35,12 +35,13 @@ A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provid
- [💕Special Thanks](#-special-thanks)

## ✨ Features

- [Strapi Custom Field](https://docs.strapi.io/dev-docs/custom-fields) for calculating the provided formula.
- [mathjs](https://mathjs.org/) integration.
- Supports numbers, big numbers, complex numbers, fractions, units, strings, arrays, and matrices.
- Is compatible with JavaScript’s built-in Math library.
- Contains a flexible expression parser.
- Does symbolic computation.
- Supports numbers, big numbers, complex numbers, fractions, units, strings, arrays, and matrices.
- Is compatible with JavaScript’s built-in Math library.
- Contains a flexible expression parser.
- Does symbolic computation.
- Comes with a large set of built-in functions and constants.
- Calculating the `formula` with the provided `scope` using the powerful `mathjs.evaluate` method. [Read More.](https://mathjs.org/docs/expressions/parsing.html#evaluate)

Expand All @@ -52,63 +53,73 @@ Complete installation requirements are exact the same as for Strapi itself and c
documentation](https://docs.strapi.io/dev-docs/quick-start).

> Before installing Strapi, the following requirements must be installed on your computer:
> - Node.js: Only Maintenance and LTS versions are supported (v16, v18, and v20).
>
> - Node.js: Only Maintenance and LTS versions are supported (v18, and v20).
> - Node v18.x is recommended for Strapi v4.3.9 and above
> - Node v16.x is recommended for Strapi v4.0.x to v4.3.8.
> - Your preferred Node.js package manager:
> - npm (v6 and above)
> - yarn
## 🦾 Installation

```shell
yarn add strapi-plugin-field-formula@latest
```

**OR**

```shell
npm install strapi-plugin-field-formula@latest
```

After successful installation you could re-build the Strapi instance. You could use the next commands (default) inside
your Strapi project:

```shell
yarn build
yarn develop
```

## ⚙️ Configuration

As a next step you must configure the plugin following the [official Strapi documentation](https://docs.strapi.io/dev-docs/plugins/documentation#configuration).

We need to enable the plugin by adding it to the Strapi plugin config file located in `./config/plugins.js` of your Strapi
We need to enable the plugin by adding it to the Strapi plugin config file located in `./config/plugins.js` of your Strapi
project. If this file does not exist yer, you have to create it manually.

Copy and paste the following config into you `./config/plugins.js` file:

```javascript
// ./config/plugins.js`
module.exports = {
// ...
'field-formula': {
enabled: true
"field-formula": {
enabled: true,
},
//...
}
//...
};
```

My congratulation 😄! You have successfully installed and configured the **Strapi Plugin Field Formula**.

## ♾️ Usage
> Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support
for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated
solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.
Powerful and easy to use.

Here is some examples, but to use this plugin on the full 100%, you have to read the official [Mathjs](https://mathjs.org/examples/index.html)
documentation, and especially the [expressions](https://mathjs.org/examples/expressions.js.html) part as `formula` is
> Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support
> for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated
> solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.
> Powerful and easy to use.
Here is some examples, but to use this plugin on the full 100%, you have to read the official [Mathjs](https://mathjs.org/examples/index.html)
documentation, and especially the [expressions](https://mathjs.org/examples/expressions.js.html) part as `formula` is
the same thing as `mathjs.evaluate` method 🤫

> Function `evaluate` accepts a single **(in our case)** `expression` or an array with expressions as the first argument
and has an optional second argument containing a `scope` with variables and functions. The scope can be a regular
JavaScript Object, or Map **(JSON in our case)**. The scope will be used to resolve symbols, and to write assigned
variables or function.
> and has an optional second argument containing a `scope` with variables and functions. The scope can be a regular
> JavaScript Object, or Map **(JSON in our case)**. The scope will be used to resolve symbols, and to write assigned
> variables or function.
### Example 1

```
formula: sqrt(x^y + r^k)
scope: {
Expand All @@ -121,26 +132,27 @@ result: 32.12475680841802
```

### Example 2

```
formula: cos(x deg)
scope: { "x": 45 }
result: 0.7071067811865476
```

## 🛠️ Contributing
See the [CONTRIBUTING.md](https://github.com/BorysShulyak/strapi-plugin-field-formula/blob/main/CONTRIBUTING.md)

See the [CONTRIBUTING.md](https://github.com/BorysShulyak/strapi-plugin-field-formula/blob/main/CONTRIBUTING.md)
document.

## 🗺️ Roadmap

- Object response to unleash more difficult expressions.

## ❤️ Support or Donate
If you are enjoying this plugin and feel extra appreciative, you could [buy me a book](https://bmc.link/borisshulyak)

If you are enjoying this plugin and feel extra appreciative, you could [buy me a book](https://bmc.link/borisshulyak)
📖 or 3 📖📖📖.

## 💕 Special Thanks
- I want to say thank you to **my wife Diana** for her love, daily support, motivation and inspiration.




- I want to say thank you to **my wife Diana** for her love, daily support, motivation and inspiration.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"test": "jest --testPathPattern='\\/__tests__\\/.*\\.(?:test|spec)\\.js$' --ci 2>&1"
},
"dependencies": {
"@strapi/design-system": "^1.6.3",
"@strapi/helper-plugin": "^4.12.5",
"@strapi/icons": "^1.11.0",
"prop-types": "^15.7.2",
"@strapi/design-system": "^1.14.1",
"@strapi/helper-plugin": "^4.20.0",
"@strapi/icons": "^1.14.1",
"prop-types": "^15.8.1",
"axios": "1.6.0",
"mathjs": "11.11.1"
},
Expand Down Expand Up @@ -49,14 +49,14 @@
"styled-components": "^5.3.6"
},
"peerDependencies": {
"@strapi/strapi": "^4.4.0",
"@strapi/strapi": "^4.20.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^5.3.4",
"styled-components": "^5.3.6"
},
"engines": {
"node": ">=14.19.1 <=18.x.x",
"node": ">=18.0.0 <=20.x.x",
"npm": ">=6.0.0"
},
"repository": {
Expand Down
Loading

0 comments on commit 92a4cc9

Please sign in to comment.