Skip to content

Commit

Permalink
feat: v4 (#3)
Browse files Browse the repository at this point in the history
* feat: init v4 plugin

* feat(server): migrate server functionality

* feat(admin): migrate admin functionality

* 2.0.0
  • Loading branch information
ComfortablyCoding authored Feb 10, 2022
1 parent ed2bfce commit bdadab5
Show file tree
Hide file tree
Showing 59 changed files with 1,307 additions and 3,124 deletions.
7 changes: 5 additions & 2 deletions .eslintrc.frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ module.exports = {
parser: '@babel/eslint-parser',
env: {
browser: true,
commonjs: true,
es6: true,
},
plugins: ['react'],
extends: ['eslint:recommended', 'plugin:react/recommended', 'prettier'],
parserOptions: {
requireConfigFile: false,
ecmaVersion: 2018,
ecmaFeatures: {
jsx: true,
},
sourceType: 'module',
babelOptions: {
presets: ['@babel/preset-react'],
},
},
settings: {
react: {
version: '16.5.2',
version: 'detect',
},
},
};
6 changes: 2 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const backendESLint = require('./.eslintrc.backend.js');

module.exports = {
$schema: 'https://json.schemastore.org/eslintrc',
// parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 2018,
},
Expand All @@ -18,12 +17,11 @@ module.exports = {
},
overrides: [
{
files: ['/**/*'],
excludedFiles: ['/admin/**/*'],
files: ['server/**/*'],
...backendESLint,
},
{
files: ['/admin/**/*'],
files: ['admin/**/*'],
...frontendESLint,
},
],
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock.json
79 changes: 65 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# strapi-plugin-website-builder

A plugin for [Strapi](https://github.com/strapi/strapi) that provides the ability to manually trigger website builds
A plugin for [Strapi](https://github.com/strapi/strapi) that provides the ability to trigger website builds manually, periodically or through model events.

## Requirements

The installation requirements are the same as Strapi itself and can be found in the documentation on the [Quick Start](https://strapi.io/documentation/developer-docs/latest/getting-started/quick-start.html) page in the Prerequisites info card.

**Supported Strapi versions**:
### Supported Strapi versions

- Strapi v3.6.8
- v4.x.x

(While this plugin may work with the older Strapi versions, they are not supported.)

**It is recommended to always use the latest version of Strapi when starting new projects**.
**NOTE**: While this plugin may work with the older Strapi versions, they are not supported, it is always recommended to use the latest version of Strapi.

## Installation

Expand All @@ -28,27 +26,80 @@ yarn add strapi-plugin-website-builder

## Configuration

Generate a config file at `config/plugins.js` with the following structure,
The plugin configuration is stored in a config file located at `./config/plugins.js`.

The plugin has different structures depending on the type of trigger for the build. Each of the following sample configurations are the minimums needed for their respective trigger type.

### Manual Configuration

```javascript
module.exports = ({ env }) => ({
'website-builder': {
enabled: true,
url: 'https://link-to-hit-on-trigger.com',
trigger: {
type: 'manual',
},
},
});
```

### Cron/Periodic Configuration

```javascript
module.exports = ({ env }) => ({
'website-builder': {
// This is the URL that will be POST to on trigger. Required
enabled: true,
url: 'https://link-to-hit-on-trigger.com',
// Object of any headers you might need. Optional
headers: {
'Content-Type': 'application/json',
trigger: {
type: 'cron',
cron: '* * 1 * * *',
},
},
});
```

### Event Configuration

```javascript
module.exports = ({ env }) => ({
'website-builder': {
enabled: true,
url: 'https://link-to-hit-on-trigger.com',
trigger: {
type: 'event',
events: [
{
model: 'recipes',
types: ['create', 'delete'],
},
],
},
// Max number of logs to store. Defaults to 5
maxNumOfLogs: 5,
},
});
```

**IMPORTANT NOTE**: Make sure any sensitive data is stored in env files.

#### The Complete Plugin Configuration Object

| Property | Description | Type | Required |
| -------- | ----------- | ---- | -------- |
| url | The trigger URL for the website build. | String | Yes |
| headers | Any headers to send along with the request. | Object | No |
| body | Any body data to send along with the request. | Object | No |
| trigger | The trigger conditions for the build. | Object | Yes |
| trigger.type | The type of trigger. The current supported options are `manual`,`cron` and `event` | String | Yes |
| trigger.cron | The cron expression to use for cron trigger. The supported expressions are the same as in the [strapi docs](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/cronjobs.html#cron-jobs) | String | Only if the type is cron |
| trigger.events | The events to use for the event trigger. | Array | Only if the type is event |
| trigger.events.model | The model to listen for events on. | String | Yes |
| trigger.events.types | The model events to trigger on. The current supported events are `create`, `update` and `delete` | Array | Yes |

## Usage

Once the plugin has been installed and configured, it will show in the sidebar as `Website Builder`.
To trigger a manual build select the `Website Builder` menu item in the sidebar and click
the `Trigger Build` button to start the build process.
the `Trigger Build` button to start a build process.

## Bugs
If any bugs are found please report them as a [Github Issue](https://github.com/ComfortablyCoding/strapi-plugin-website-builder/issues)
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@

import { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { pluginId } from '../../utils/constants';
import { pluginId } from '../../pluginId';

const Initializer = ({ updatePlugin }) => {
const Initializer = ({ setPlugin }) => {
const ref = useRef();
ref.current = updatePlugin;
ref.current = setPlugin;

useEffect(() => {
ref.current(pluginId, 'isReady', true);
ref.current(pluginId);
}, []);

return null;
};

Initializer.propTypes = {
updatePlugin: PropTypes.func.isRequired,
setPlugin: PropTypes.func.isRequired,
};

export default Initializer;
36 changes: 0 additions & 36 deletions admin/src/components/LogTable.js

This file was deleted.

12 changes: 12 additions & 0 deletions admin/src/components/PluginIcon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
*
* PluginIcon
*
*/

import React from 'react';
import Play from '@strapi/icons/Play';

const PluginIcon = () => <Play />;

export default PluginIcon;
96 changes: 0 additions & 96 deletions admin/src/containers/HomePage/index.js

This file was deleted.

Loading

0 comments on commit bdadab5

Please sign in to comment.