Skip to content

Commit b9abb37

Browse files
authored
Introduce Posts & Post Types Selects
1 parent b21880f commit b9abb37

36 files changed

+4764
-3406
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
charset = utf-8
33
end_of_line = lf
44
indent_size = 4
5-
indent_style = space
5+
indent_style = tab
66
insert_final_newline = true
77
max_line_length = 120
88
tab_width = 4

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ const baseConfiguration = require('@wordpress/scripts/config/.eslintrc.js');
22

33
module.exports = {
44
...baseConfiguration,
5+
rules: {
6+
...baseConfiguration.rules,
7+
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
8+
},
59
settings: {
610
'import/resolver': {
711
typescript: {},

.github/workflows/js-qa.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: JS Quality Assurance
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
paths:
10+
- '**/workflows/*js*'
11+
- '**.js'
12+
- '**.jsx'
13+
- '**.ts'
14+
- '**.tsx'
15+
- '**.json'
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
if: "!github.event.pull_request.draft"
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Setup Node
26+
uses: actions/setup-node@v2
27+
with:
28+
cache: 'yarn'
29+
node-version: '16'
30+
31+
- name: Install
32+
run: yarn install
33+
34+
- name: Coding Style
35+
run: yarn cs
36+
37+
- name: Linting JavaScript
38+
run: yarn lint:js
39+
40+
- name: Unit Tests
41+
run: yarn test

.github/workflows/php-qa.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: PHP Quality Assurance
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
8+
paths:
9+
- '**.php'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
if: "!contains(github.event.head_commit.message, '--skip ci') && !github.event.pull_request.draft"
15+
strategy:
16+
matrix:
17+
php-versions: [ '8.0' ]
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v3
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php-versions }}
26+
27+
- name: Check syntax error in sources
28+
run: find ./src/ ./tests/ -type f -name '*.php' -print0 | xargs -0 -L 1 -P 4 -- php -l
29+
30+
- name: Install dependencies
31+
uses: "ramsey/composer-install@v1"
32+
33+
- name: Check code styles
34+
run: composer cs

.prettierignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
*.json
2-
*.scss
3-
*.css
4-
51
.psalm
62
.github
73

84
./coverage
95
./vendor
106
./node_modules
11-
./public
7+
./build

.prettierrc.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1-
const prettierConfig = require('@wordpress/scripts/config/.prettierrc.js')
1+
const prettierConfig = require('@wordpress/scripts/config/.prettierrc.js');
22

3-
module.exports = prettierConfig
3+
module.exports = {
4+
...prettierConfig,
5+
importOrder: [
6+
'<THIRD_PARTY_MODULES>',
7+
'^@jest/(.*)$',
8+
'^@testing-library/(.*)$',
9+
'^@faker-js/faker',
10+
'^@wordpress/(.*)$',
11+
'^[./]',
12+
],
13+
importOrderSeparation: true,
14+
importOrderSortSpecifiers: false,
15+
importOrderCaseInsensitive: false,
16+
};

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"php.suggest.basic": true,
3+
"php.validate.enable": true,
4+
"php.validate.executablePath": "/usr/bin/php",
5+
"php.format.codeStyle": "Off",
6+
"phpCodeSniffer.standardCustom": "./phpcs.xml",
7+
"phpCodeSniffer.standard": "Custom",
8+
"phpCodeSniffer.autoExecutable": true,
9+
"[php]": {
10+
"editor.defaultFormatter": "obliviousharmony.vscode-php-codesniffer"
11+
},
12+
"prettier.configPath": ".prettierrc.js"
13+
}

.wp-env.json

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
{
2-
"core": "WordPress/WordPress",
3-
"plugins": [
4-
"."
5-
],
6-
"env": {
7-
"development": {
8-
"phpVersion": "8.0",
9-
"mappings": {
10-
"wp-content/plugins/entities-search": "."
11-
}
12-
}
13-
}
2+
"core": "./vendor/roots/wordpress-no-content",
3+
"plugins": ["."],
4+
"env": {
5+
"development": {
6+
"phpVersion": "8.0",
7+
"mappings": {
8+
"wp-content/plugins/entities-search": "."
9+
}
10+
}
11+
}
1412
}

@types/index.d.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import type { Set } from 'immutable';
2+
import React from 'react';
3+
4+
import { BaseEntityRecords, Context } from '@wordpress/core-data';
5+
6+
type ComponentStateAware<V> = {
7+
value: Set<V>;
8+
setValue(value: ComponentStateAware<V>['value']): void;
9+
};
10+
11+
export default EntitiesSearch;
12+
13+
declare namespace EntitiesSearch {
14+
type PostType<C extends Context = 'view'> = BaseEntityRecords.Type<C>;
15+
16+
type ViewablePostType = Readonly<{
17+
[K in keyof PostType<'edit'>]: K extends 'viewable'
18+
? true
19+
: PostType<'edit'>[K];
20+
}>;
21+
22+
type Record<V extends any> = Readonly<{
23+
value: V;
24+
label: string;
25+
}>;
26+
27+
type EntitiesRecords<Entity> = Readonly<{
28+
records(): Set<Entity>;
29+
isResolving(): boolean;
30+
errored(): boolean;
31+
succeed(): boolean;
32+
}>;
33+
34+
/**
35+
* Components
36+
*/
37+
interface PostTypeSelect<V> {
38+
readonly value: Record<V> | null;
39+
readonly options: Set<NonNullable<PostTypeSelect<V>['value']>>;
40+
readonly onChange: (value: PostTypeSelect<V>['value']) => void;
41+
}
42+
43+
interface PostsSelect<V> {
44+
readonly value: Set<Record<V>> | null;
45+
readonly options: NonNullable<PostsSelect<V>['value']>;
46+
readonly onChange: (values: PostsSelect<V>['value']) => void;
47+
}
48+
49+
interface PostsController<P, T> {
50+
readonly postsComponent: React.ComponentType<ComponentStateAware<P>>;
51+
readonly typesComponent: React.ComponentType<ComponentStateAware<T>>;
52+
}
53+
}

composer.json

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
{
2-
"name": "widoz/entities-search",
3-
"description": "A WordPress package to search Entities including Rest API Endpoints and React Components",
4-
"type": "library",
5-
"license": "GPL-v2-or-later",
6-
"autoload": {
7-
"psr-4": {
8-
"Widoz\\EntitiesSearch\\": "sources/php/src/"
9-
}
10-
},
11-
"authors": [
12-
{
13-
"name": "guido scialfa",
14-
"email": "[email protected]"
15-
}
16-
],
17-
"minimum-stability": "stable",
18-
"require": {
19-
"php": ">=8.0"
20-
},
21-
"require-dev": {
22-
"roots/wordpress": "^6.2",
23-
"inpsyde/modularity": "^1.5"
24-
},
25-
"config": {
26-
"platform": {
27-
"php": "8.0"
28-
},
29-
"allow-plugins": {
30-
"roots/wordpress-core-installer": true
31-
}
32-
},
33-
"extra": {
34-
"wordpress-install-dir": "vendor/wordpress/wordpress",
35-
"installer-disable": [
36-
"wordpress"
37-
]
38-
}
2+
"name": "widoz/entities-search",
3+
"description": "A WordPress package to search Entities including Rest API Endpoints and React Components",
4+
"type": "library",
5+
"license": "GPL-v2-or-later",
6+
"version": "1.0.0",
7+
"autoload": {
8+
"psr-4": {
9+
"Widoz\\EntitiesSearch\\": "sources/php/src/"
10+
}
11+
},
12+
"authors": [
13+
{
14+
"name": "guido scialfa",
15+
"email": "[email protected]"
16+
}
17+
],
18+
"minimum-stability": "stable",
19+
"require": {
20+
"php": ">=8.0"
21+
},
22+
"require-dev": {
23+
"inpsyde/modularity": "^1.5",
24+
"inpsyde/php-coding-standards": "^1.0",
25+
"roots/wordpress-no-content": "^6.3"
26+
},
27+
"config": {
28+
"platform": {
29+
"php": "8.0"
30+
},
31+
"allow-plugins": {
32+
"dealerdirect/phpcodesniffer-composer-installer": true
33+
}
34+
},
35+
"scripts": {
36+
"cs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs",
37+
"cs:fix": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"
38+
}
3939
}

0 commit comments

Comments
 (0)