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

[GX-17505] Dismantle core-plugin #23

Merged
merged 7 commits into from
Jul 25, 2019
Merged

Conversation

DanielSanudo
Copy link
Contributor

Summary

Changelog

Test Plan


#### errorMiddleware

Executed after the `express` event. All middleware or middleware arrays returned from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want to mention middleware functions here?

});

it('adds the errorMiddleware', async () => {
const errorMiddlewares = [spy()];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these spies reset and cleaned, probably want to use sinon as sandbox here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from const { spy, stub } = require('sinon');.
I am not creating global mocks or anything, do they need to be reset and clean?

- [createServers](#createservers)
- [servers](#servers)
- [Configuration](#configuration-1)
- [LICENSE: MIT](#license-mit)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement in itself, but most of our warehouse modules use a license badge rather than adding section at the bottom. I think we want to be consistent, but not feeling strong about it at this point

const devServer = gasket.command === 'local';

// Retrieving the server handler
const handler = gasket.exec('createServers', devServer)[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be changed up slightly in a couple of ways:

  1. Let's not pass devServer through these several lifecycles. gasket.command === 'local' will always be available and it looks like only the nextjs-plugin needs it for nextApp.
  2. Let's make the createServers lifecycle an execWaterfall, which gives plugins the opportunity to adjust the createServers options (serverOpts). In our initial case, the express-plugin will add the handler to the config object, rather than just return a handle for the https-plugin to add. This will allow more flexibility and should be easier to document.



// Note: Not sure if this needs an await, maybe?
exec('nextExpress', { expressApp, app });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, probably should await this, in case there are modifications that affect things down the chain.

Also, probably would be most clear for consuming hooks to name these instances as next, and express:
exec('nextExpress', { next: app, express: expressApp })

@kinetifex
Copy link
Contributor

For some high-level context for additional reviewers, below is lifecycle flow @DanielSanudo and I discussed which he implemented here, to dismantle the core-plugin, where x means hook and -> means execute lifecycle.

build (command)
    x nextjs-plugin

start (command)
    x https-plugin
        -> createServers
        x express-plugin
            -> middleware
            -> express
                x nextjs-plugin
                    -> initWebpack()
                        x webpack-plugin
                            -> webpack
                            -> webpackChain
                    -> nextConfig
                    -> next
                    -> nextExpress (was ssr)
            -> errorMiddleware
        -> servers

@kinetifex
Copy link
Contributor

@DanielSanudo also, you'll need these generator files moved to the nextjs-plugin:
https://github.com/godaddy/gasket/tree/core-plugin/packages/gasket-core-plugin/generator

All except .gitignore.template and .gitignore.template, which I'm proposing will be owned by a git-plugin: #26

@DanielSanudo DanielSanudo force-pushed the core-plugin-extraction branch from 93df4e4 to b0a45d7 Compare July 24, 2019 16:08
serverOpts = await gasket.execWaterfall('createServers', serverOpts);

// create-servers does not support http or https being `null`
if (http) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update serverOpts with http/https also before passing to lifecycle

@kinetifex kinetifex mentioned this pull request Jul 24, 2019
5 tasks
@indexzero indexzero merged commit 536b127 into master Jul 25, 2019
@indexzero indexzero deleted the core-plugin-extraction branch July 25, 2019 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants