Skip to content

Commit

Permalink
Merge branch 'main' into move-extrainfo-to-meta
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelSuwinski authored Mar 27, 2024
2 parents a03c484 + 9993bf1 commit 13bb4c5
Show file tree
Hide file tree
Showing 77 changed files with 25,360 additions and 238 deletions.
18 changes: 18 additions & 0 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"sourceType": "unambiguous",
"presets": [
[
"@babel/preset-env",
{
"targets": {
"chrome": 100,
"safari": 15,
"firefox": 91
}
}
],
"@babel/preset-typescript",
"@babel/preset-react"
],
"plugins": []
}
9 changes: 9 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
'airbnb/hooks',
'prettier',
'plugin:markdown/recommended',
'plugin:storybook/recommended'
],
rules: {
'prettier/prettier': 'error',
Expand Down
27 changes: 19 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,28 @@ jobs:
name: Continuous integration
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
-
name: Checkout
uses: actions/checkout@v4
-
name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 'current'
- name: Install dependencies
-
name: Setup npm
uses: bahmutov/npm-install@v1
with:
install-command: yarn --immutable
-
name: Install dependencies
run: yarn install
- name: Check build
-
name: Check build
run: yarn build
- name: Check coding standards
-
name: Check coding standards
run: yarn lint
- name: Run tests
-
name: Run tests
run: yarn test
25 changes: 16 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,29 @@ jobs:
name: Create and publish a release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
-
name: Checkout
uses: actions/checkout@v4
-
name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 'current'
registry-url: https://registry.npmjs.org
- name: Install dependencies
-
name: Install dependencies
run: yarn install
- name: Check build
-
name: Check build
run: yarn build
- name: Check coding standards
-
name: Check coding standards
run: yarn lint
- name: Run tests
-
name: Run tests
run: yarn test
- name: Publish to npm
-
name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
70 changes: 70 additions & 0 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Storybook

on:
push:
branches:
- main
pull_request: ~
workflow_dispatch: ~

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
tests:
name: Tests
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build Docker images
uses: docker/bake-action@v4
with:
pull: true
load: true
files: |
compose.yaml
set: |
*.cache-from=type=gha,scope=${{github.ref}}
*.cache-from=type=gha,scope=refs/heads/main
*.cache-to=type=gha,scope=${{github.ref}},mode=max
-
name: Start services
run: docker compose -f compose.yaml -f compose.ci.yaml up --wait --no-build
-
name: Check HTTP reachability
run: curl -v --fail-with-body http://localhost
-
name: Check PWA reachability
run: "curl -vk --fail-with-body -H 'Accept: text/html' https://localhost"
-
name: Check API reachability
run: "curl -vk --fail-with-body -H 'Accept: application/ld+json' https://localhost"
-
name: Create test database
run: docker compose exec -T php bin/console -e test doctrine:database:create
-
name: Run migrations
run: docker compose exec -T php bin/console -e test doctrine:migrations:migrate --no-interaction
# -
# name: Doctrine Schema Validator
# run: docker compose exec -T pwa pnpm run storybook
lint:
name: Docker Lint
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Lint Dockerfiles
uses: hadolint/[email protected]
with:
recursive: true

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/lib/
node_modules/
/yarn.lock
.vscode/
.env.local
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
api
32 changes: 32 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { StorybookConfig } from '@storybook/react-webpack5';

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-onboarding',
'@storybook/addon-interactions',
],
framework: {
name: '@storybook/react-webpack5',
options: {},
},
docs: {
autodocs: 'tag',
},
env: (config) => ({
...config,
}),
async webpackFinal(config, { configType }) {
config.resolve = {
...config.resolve,
extensionAlias: {
'.js': ['.ts', '.js', '.tsx'],
},
};
return config;
},
};

export default config;
15 changes: 15 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Preview } from '@storybook/react';

const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 3.4.5

* Fix validation errors shown as "Server communication error" when creating an entity

## 3.4.4

* Enum support in field guesser
* Fix random error message about apiSchema being null

## 3.4.3

* Fix inconsistencies between dark and light theme
Expand Down
65 changes: 43 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,45 @@ Then, if it appears that it's a real bug, you may report it using GitHub by foll

### Writing a Pull Request

Please base your changes on the `master` branch.
Please base your changes on the `main` branch.

### Installing the Source Version
### Two ways to write your patch

To install the source version of API Platform Admin in your project and contribute a patch, follow the instructions below.
You can patch `@api-platform/admin` by two different ways:
- by linking `@api-platform/admin` sources to an existing project;
- by installing this project and running it through Storybook.

Create your client that will use `api-platform-admin` (replace `<yourproject>` by your project's name):
#### Linking the Source Version to an existing project

```shell
yarn create react-app <yourproject>
cd <yourproject>
yarn add @api-platform/admin
```
If you already have a project in progress, you can develop directly from it.

The instructions below explain how to install the source version of API Platform Admin in your project and contribute a patch.

Replace `src/App.js` by this one:
Your client should already use `@api-platform/admin` and its bootstrap file (usually: `src/App.tsx`) should at least contains:

```javascript
```tsx
import React from 'react';
import { HydraAdmin } from '@api-platform/admin';

export default () => <HydraAdmin entrypoint="https://demo.api-platform.com" />; // Replace with your own API entrypoint
function App() {
return (
<HydraAdmin entrypoint="https://demo.api-platform.com" />
)
}

export default App
```

Install your own version of `@api-platform/admin`:

```shell
```console
cd ..
git clone https://github.com/api-platform/admin.git
```

Link it:

```shell
```console
cd admin
yarn link
cd ../<yourproject>
Expand All @@ -63,36 +69,51 @@ yarn link "@api-platform/admin"

Use the React version of your project to build `@api-platform/admin`:

```shell
```console
cd node_modules/react/
yarn link
cd ../../../admin
yarn link react
```

Start your `api-platform-admin` version:
Build continuously your `@api-platform/admin` version:

```shell
yarn install
```console
yarn install --force
yarn watch
```

Open a new terminal console with the same path.

Start your client:

```shell
```console
cd ../<yourproject>/
yarn start
yarn install --force
yarn dev --force
```

You can now hack in the cloned repository of `api-platform-admin`.
> You can now hack in the cloned repository of `api-platform-admin`.
#### Running Admin through Storybook

If you don't have an existing API Platform application, or don't want to use `yarn link`, you can use one of the bundled example APIs, and visualize the admin through [Storybook](https://storybook.js.org/).

Install everything:

```shell
docker compose up
```

Go to http://localhost, accept the self-signed certificate, and see the running Admin.

To stop and prune the simple API Platform backend:

### Testing Your Changes

Before sending a Pull Request, make sure the tests pass correctly:

```shell
```console
yarn test
```

Expand Down
Loading

0 comments on commit 13bb4c5

Please sign in to comment.