Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: twig node migration #1102

Draft
wants to merge 138 commits into
base: wip-laravel-11
Choose a base branch
from
Draft

WIP: twig node migration #1102

wants to merge 138 commits into from

Conversation

mjauvin
Copy link
Member

@mjauvin mjauvin commented Apr 16, 2024

Starting with Twig 3.9.0, Nodes using "echo" or "print" are deprecated and should use "yield":

ref. twigphp/Twig@0990f81

@mjauvin mjauvin added this to the 1.3.0 milestone Apr 16, 2024
@mjauvin mjauvin self-assigned this Apr 16, 2024
@mjauvin mjauvin marked this pull request as draft April 16, 2024 21:10
mjauvin and others added 11 commits April 18, 2024 07:46
Adds support for all the Arr::*() helpers through array_*() functions in Twig
Also improved support for datetime values using periods as a separator.
… config

Commit 609ad74 introduced support for the "no-progress" option. A "%noProgress%" placeholder has been added into the Mix compilation file which is replaced by a boolean depending on if this option is used or not.

However, while we properly handled the "mix:compile" command, we forgot to add this to the "mix:watch" command too. This should fix this.
mjauvin and others added 3 commits April 25, 2024 15:49
The "encryption" option is redundant as encryption is always forced for port 465 & encryption will be automatically enabled using STARTTLS for other ports (e.g. 25 and 587) if available from the mail server CAPABILITIES by the underlying Laravel & Symfony libaries.
Removed in 9c1d2a8, but the mail driver plugins only provide the config values when using the backend mail settings page.
jaxwilko and others added 30 commits July 14, 2024 20:39
This PR adds support for enabling the Mix manifest, see Laravel Mix Asset Versioning (https://github.com/orgs/wintercms/discussions/476#discussioncomment-10088281).

The change here uses the existing options method provided by Mix to override our default behaviour.

// Enable default manifest
mix.options({
    manifest: true,
});

// Disable manifiest (default behaviour)
mix.options({
    manifest: false,
});

// Set a custom path for the manifest
mix.options({
    manifest: 'assets/manifest.json',
});
This PR adds a new `BundleManager` class which is responsible for managing the different "asset bundles" available in Winter. Bundles will automatically be offered by the `vite:create` & `mix:create` scaffolding commands as option flags.

This allows us to:
- Have a single entity responsible for managing versions
- Allow the user to configure their own bundles / overwrite the existing bundles if desired
- Manage the update process better by reducing magic numbers in the system

I've also cleaned up some of the install logic and added some user feedback similar to `create:plugin` when running `{$compiler}:create`.

In addition to the above, this PR removes the majority of the fixtures for Mix/Vite configs and now lets subscribers modify the base config on the fly.

```php
\System\Classes\Asset\BundleManager::instance()->registerCallback(function ($manager) {
    // Register a bundle (using a compiler as a key and having an array as a value means that the array 
    // will be squashed into the bundle when that compiler is being called, else the array will be discarded):
    $manager->registerBundle('jaxjs', [
        'jaxjs' => 'v1.0.0',
        'mix' => [
            'mix-jaxjs-adapter' => 'v1.2.0'
        ],
        'vite' => [
            'vite-jaxjs-adapter' => 'v1.6.0'
        ],
    ]);
    
    // Register a setup handler (is executed on install to allow for bundles to generate their own config
    // files / prep the plugin)
    $manager->registerSetupHandler('jaxjs', function (string $packagePath, string $packageType) {
        $this->writeFile(
            $packagePath . '/jax.js',
            File::get(__DIR__ . '/../fixtures/jax.js')
        );
    });

    // Register a scaffold handler (is executed during stub/config generation), `contentType`
    // can be: vite, mix, js, css.
    $manager->registerScaffoldHandler('jaxjs', function (string $contents, string $contentType) {
        return match ($contentType) {
            'mix' => $contents . PHP_EOL . <<<JAVASCRIPT
            console.log('jaxjs installed');
            JAVASCRIPT,
             'vite' => $contents . PHP_EOL . '// example',
            'css' => $content . PHP_EOL . $this->getFixture('css/jaxjs.css.fixture'),
            'js' => $this->getFixture('js/jaxjs.fixture')
            default => $contents
        };
    });
]);
```
Once the configs have been set, either via a config file, or from config calls in a plugin, the following can be ran in the CLI:
```bash
./artisan vite:create Acme.Plugin --jaxjs
# Or
./artisan mix:create Acme.Plugin --jaxjs
```

Plugins can call these methods to register handlers to modify either stub or config generation, or do additional tasks when the `{$compiler}:create` command is ran.

> **NOTE**: `setupHandlers` & `scaffoldHandlers` are executed within the context of `AssetCreate` this means they have access to the internal properties of the class such as `assetType` (`mix` or `vite`) and have access to methods such as `writeFile()` & `getFixture()`.
The Storm version of Relation will be converted to an interface when Laravel-style relations is merged, but it makes sense to change these now anyway as the static method is defined in Laravel and was not overwritten by the Storm wrapper.
This fix allows nested objects within the request data to be correctly converted to nested form data when sending the request.

Previously, if the data option in a Request contained nested objects or arrays within the data, these were being incorrectly converted to [Array array] or [Object object], as the FormData object would simply convert them to strings. With this fix, we traverse the data structure and ensure that they are given the right key in order to keep the shape of the data in the POST data.
Console command to purge all entries in resized storage folder.
No longer used or useful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.