Skip to content

Commit

Permalink
[WIP] All Package directory restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Nov 22, 2022
1 parent 2e0dc46 commit 561a4a3
Show file tree
Hide file tree
Showing 337 changed files with 489 additions and 350 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/test-turbo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ jobs:
${{ runner.os }}-yarn-
- name: Install JavaScript dependencies
working-directory: src/Turbo/Tests/app
working-directory: src/Turbo/tests/app
run: yarn install

- name: Build JavaScript
working-directory: src/Turbo/Tests/app
working-directory: src/Turbo/tests/app
run: yarn build

- name: Create DB
working-directory: src/Turbo/Tests/app
working-directory: src/Turbo/tests/app
run: php public/index.php doctrine:schema:create

- name: Run tests
Expand Down Expand Up @@ -139,15 +139,15 @@ jobs:
${{ runner.os }}-yarn-
- name: Install JavaScript dependencies
working-directory: src/Turbo/Tests/app
working-directory: src/Turbo/tests/app
run: yarn install

- name: Build JavaScript
working-directory: src/Turbo/Tests/app
working-directory: src/Turbo/tests/app
run: yarn build

- name: Create DB
working-directory: src/Turbo/Tests/app
working-directory: src/Turbo/tests/app
run: php public/index.php doctrine:schema:create

- name: Run tests
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"private": true,
"workspaces": [
"src/**/Resources/assets",
"src/**/assets"
],
"scripts": {
"build": "yarn rollup -c",
"test": "yarn workspaces run jest",
"lint": "yarn workspaces run eslint src test",
"format": "prettier src/*/Resources/assets/src/*.ts src/*/Resources/assets/test/*.js {,src/*/}*.{json,md} --write",
"format": "prettier src/*/assets/src/*.ts src/*/assets/test/*.js {,src/*/}*.{json,md} --write",
"check-lint": "yarn lint --no-fix",
"check-format": "yarn format --no-write --check"
},
Expand Down Expand Up @@ -61,7 +60,6 @@
"overrides": [
{
"files": [
"src/*/Resources/assets/test/**/*.ts",
"src/*/assets/test/**/*.ts"
],
"extends": [
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const wildcardExternalsPlugin = (peerDependencies) => ({
}
});

const files = glob.sync("src/**/assets/src/*controller.ts");
const files = glob.sync("src/React/assets/src/*controller.ts");
const packages = files.map((file) => {
const absolutePath = path.join(__dirname, file);
const packageData = require(pkgUp.sync({ cwd: absolutePath }));
Expand Down
2 changes: 1 addition & 1 deletion src/Autocomplete/.symfony.bundle.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
branches: ["2.x"]
maintained_branches: ["2.x"]
doc_dir: "src/Resources/doc"
doc_dir: "doc"
13 changes: 12 additions & 1 deletion src/Autocomplete/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# CHANGELOG

## Unreleased
## 2.6.0

- [BC BREAK]: The path to `routes.php` changed and you should update your
route import accordingly:

```diff
# config/routes/ux_autocomplete.yaml
ux_autocomplete:
- resource: '@AutocompleteBundle/Resources/routes.php'
+ resource: '@AutocompleteBundle/config/routes.php'
prefix: '/autocomplete'
```

- Fix issue where `max_results` was not passed as a Stimulus value (#538)

Expand Down
31 changes: 17 additions & 14 deletions src/Autocomplete/assets/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class extends Controller {
noMoreResultsText: String,
minCharacters: Number,
tomSelectOptions: Object,
}
};

readonly urlValue: string;
readonly optionsAsHtmlValue: boolean;
Expand Down Expand Up @@ -53,7 +53,7 @@ export default class extends Controller {
}

#getCommonConfig(): Partial<TomSettings> {
const plugins: any = {}
const plugins: any = {};

// multiple values excepted if this is NOT A select (i.e. input) or a multiple select
const isMultiple = !this.selectElement || this.selectElement.multiple;
Expand All @@ -80,7 +80,7 @@ export default class extends Controller {
onItemAdd: () => {
this.tomSelect.setTextboxValue('');
},
onInitialize: function() {
onInitialize: function () {
const tomSelect = this as any;
tomSelect.wrapper.setAttribute('data-live-ignore', '');
},
Expand Down Expand Up @@ -114,12 +114,12 @@ export default class extends Controller {
};
},
render: {
item: function(item: any) {
item: function (item: any) {
return `<div>${item.text}</div>`;
},
option: function(item: any) {
option: function (item: any) {
return `<div>${item.text}</div>`;
}
},
},
});

Expand All @@ -139,9 +139,12 @@ export default class extends Controller {
load: function (query: string, callback: (results?: any) => void) {
const url = this.getUrl(query);
fetch(url)
.then(response => response.json())
.then((response) => response.json())
// important: next_url must be set before invoking callback()
.then(json => { this.setNextUrl(query, json.next_page); callback(json.results) })
.then((json) => {
this.setNextUrl(query, json.next_page);
callback(json.results);
})
.catch(() => callback());
},
shouldLoad: function (query: string) {
Expand All @@ -150,16 +153,16 @@ export default class extends Controller {
return query.length >= minLength;
},
// avoid extra filtering after results are returned
score: function(search: string) {
return function(item: any) {
score: function (search: string) {
return function (item: any) {
return 1;
};
},
render: {
option: function(item: any) {
option: function (item: any) {
return `<div>${item.text}</div>`;
},
item: function(item: any) {
item: function (item: any) {
return `<div>${item.text}</div>`;
},
no_more_results: (): string => {
Expand All @@ -186,7 +189,7 @@ export default class extends Controller {
/**
* Returns the element, but only if it's a select element.
*/
get selectElement(): HTMLSelectElement|null {
get selectElement(): HTMLSelectElement | null {
if (!(this.element instanceof HTMLSelectElement)) {
return null;
}
Expand All @@ -197,7 +200,7 @@ export default class extends Controller {
/**
* Getter to help typing.
*/
get formElement(): HTMLInputElement|HTMLSelectElement {
get formElement(): HTMLInputElement | HTMLSelectElement {
if (!(this.element instanceof HTMLInputElement) && !(this.element instanceof HTMLSelectElement)) {
throw new Error('Autocomplete Stimulus controller can only be used no an <input> or <select>.');
}
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Autocomplete/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/bin/.phpunit/phpunit.xsd"
colors="true"
bootstrap="tests/bootstrap.php"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
5 changes: 5 additions & 0 deletions src/Autocomplete/src/AutocompleteBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ public function build(ContainerBuilder $container)
{
$container->addCompilerPass(new AutocompleteFormTypePass());
}

public function getPath(): string
{
return \dirname(__DIR__);
}
}
2 changes: 1 addition & 1 deletion src/Autocomplete/src/Maker/MakeAutocompleteField.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
);
$generator->generateClass(
$classDetails->getFullName(),
__DIR__.'/../Resources/skeletons/AutocompleteField.tpl.php',
__DIR__.'./skeletons/AutocompleteField.tpl.php',
[
'variables' => $variables,
]
Expand Down
8 changes: 7 additions & 1 deletion src/Autocomplete/tests/Fixtures/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Symfony\UX\Autocomplete\Tests\Fixtures\Autocompleter\CustomProductAutocompleter;
use Symfony\UX\Autocomplete\Tests\Fixtures\Form\ProductType;
use Twig\Environment;
use Zenstruck\Foundry\ZenstruckFoundryBundle;

final class Kernel extends BaseKernel
{
Expand Down Expand Up @@ -61,6 +62,7 @@ public function registerBundles(): iterable
yield new AutocompleteBundle();
yield new SecurityBundle();
yield new MakerBundle();
yield new ZenstruckFoundryBundle();
}

protected function configureContainer(ContainerConfigurator $c): void
Expand All @@ -79,6 +81,10 @@ protected function configureContainer(ContainerConfigurator $c): void
'default_path' => '%kernel.project_dir%/tests/Fixtures/templates',
]);

$c->extension('zenstruck_foundry', [
'auto_refresh_proxies' => false,
]);

$c->extension('doctrine', [
'dbal' => ['url' => '%env(resolve:DATABASE_URL)%'],
'orm' => [
Expand Down Expand Up @@ -144,7 +150,7 @@ protected function configureContainer(ContainerConfigurator $c): void

protected function configureRoutes(RoutingConfigurator $routes): void
{
$routes->import('@AutocompleteBundle/Resources/routes.php')
$routes->import('@AutocompleteBundle/config/routes.php')
->prefix('/test/autocomplete');

$routes->add('test_form', '/test-form')->controller('kernel::testForm');
Expand Down
16 changes: 0 additions & 16 deletions src/Autocomplete/tests/bootstrap.php

This file was deleted.

6 changes: 3 additions & 3 deletions src/Chartjs/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
/.gitignore export-ignore
/.symfony.bundle.yaml export-ignore
/phpunit.xml.dist export-ignore
/Resources/assets/test export-ignore
/Resources/assets/jest.config.js export-ignore
/Tests export-ignore
/assets/test export-ignore
/assets/jest.config.js export-ignore
/tests export-ignore
2 changes: 1 addition & 1 deletion src/Chartjs/.symfony.bundle.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
branches: ["2.x"]
maintained_branches: ["2.x"]
doc_dir: "Resources/doc"
doc_dir: "doc"
7 changes: 7 additions & 0 deletions src/Chartjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## 2.6.0

- [BC BREAK] The `assets/` directory was moved from `Resources/assets/` to `assets/`. Make
sure the path in your `package.json` file is updated accordingly.

- The directory structure of the bundle was updated to match modern best-practices.

## 2.0

- Support for `stimulus` version 2 was removed and support for `@hotwired/stimulus`
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const config = require('../../../../jest.config.js');
const config = require('../../../jest.config.js');

config.setupFilesAfterEnv.push('./test/setup.js');

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 7 additions & 5 deletions src/Chartjs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
],
"autoload": {
"psr-4": {
"Symfony\\UX\\Chartjs\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
"Symfony\\UX\\Chartjs\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Symfony\\UX\\Chartjs\\Tests\\": "tests/"
}
},
"require": {
"php": ">=7.2.5",
Expand Down
File renamed without changes.
9 changes: 2 additions & 7 deletions src/Chartjs/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@

<testsuites>
<testsuite name="Test Suite">
<directory>Tests</directory>
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>.</directory>
<exclude>
<directory>./Tests</directory>
<directory>./Resources</directory>
<directory>./vendor</directory>
</exclude>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@
*/
class ChartjsBundle extends Bundle
{
public function getPath(): string
{
return \dirname(__DIR__);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/Cropperjs/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
/.gitignore export-ignore
/.symfony.bundle.yaml export-ignore
/phpunit.xml.dist export-ignore
/Resources/assets/test export-ignore
/Resources/assets/jest.config.js export-ignore
/Tests export-ignore
/assets/test export-ignore
/assets/jest.config.js export-ignore
/tests export-ignore
2 changes: 1 addition & 1 deletion src/Cropperjs/.symfony.bundle.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
branches: ["2.x"]
maintained_branches: ["2.x"]
doc_dir: "Resources/doc"
doc_dir: "doc"
7 changes: 7 additions & 0 deletions src/Cropperjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## 2.6.0

- [BC BREAK] The `assets/` directory was moved from `Resources/assets/` to `assets/`. Make
sure the path in your `package.json` file is updated accordingly.

- The directory structure of the bundle was updated to match modern best-practices.

## 2.0

- Support for `stimulus` version 2 was removed and support for `@hotwired/stimulus`
Expand Down
1 change: 0 additions & 1 deletion src/Cropperjs/Resources/assets/jest.config.js

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions src/Cropperjs/assets/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../../jest.config.js');
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 561a4a3

Please sign in to comment.