Skip to content

Commit

Permalink
chore: Added playground and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexnortung committed Feb 21, 2024
1 parent bded3a4 commit df5479f
Show file tree
Hide file tree
Showing 46 changed files with 24,367 additions and 6,555 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./build/
access: public
- run: npx changelogithub
env:
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test

on:
push:
branches:
- main
pull_request:

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 20]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm ci
- run: npm run build:playground
- name: Install playground
run: npm ci
working-directory: ./playground
- name: Build playground
run: npm run build
working-directory: ./playground
- name: Test step
run: npm run test
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,10 @@ example of revalidating page

## Development

To develop on this plugin first open a strapi project and navigate to `src/plugins/` and clone this repo or your fork
To develop on this plugin use the playground in this repo.

```bash
cd src/plugins
git clone [email protected]:Oak-Digital/strapi-plugin-revalidator.git revalidator
cd revalidator
cd playground
```

Install dependencies with the
Expand All @@ -325,20 +323,7 @@ Then to make sure the build is always up to date run
npm run develop
```

Add the following basic config to `config/plugins.ts`

```typescript
export default ({ env }) => ({
// ...
revalidator: {
enabled: true,
resolve: "./src/plugins/revalidator",
},
// ...
});
```

In another terminal go to the root of your project and run `strapi develop --watch-admin`. This can probably also be run like the following depending on your setup.
In another terminal go to the playground folder and run `strapi develop --watch-admin`. This can probably also be run like the following depending on your setup.

```bash
npm run develop -- --watch-admin
Expand Down
3 changes: 2 additions & 1 deletion admin/src/pluginId.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pluginPkg from '../../package.json';

/* const pluginId = pluginPkg.name.replace(/^(@[^-,.][\w,-]+\/|strapi-)plugin-/i, ''); */
const pluginId = "revalidator";
// TODO: typescript doesn't import json as literals
const pluginId = pluginPkg.strapi.name as "revalidator";

export default pluginId;
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/__tests__/?(*.)+(spec|test).ts'],
// transform: {},
// globalSetup: './playground/__tests__/setup-strapi.ts',
// setupFilesAfterEnv: ['./playground/__tests__/setup-strapi.ts'],
// globalTeardown: './playground/__tests__/teardown-strapi.ts',
coverageDirectory: './coverage/',
collectCoverage: true,
};
Loading

0 comments on commit df5479f

Please sign in to comment.