question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Simplify configuration syntax

See original GitHub issue

Our current configuration syntax has the following issues:

  1. Retrieving plugin outputs is problematic because plugin order conflicts with lifecycle order (see #186). This makes it very hard with the current design for plugins to communicate outputs/information to the user or to other plugins.
  2. Users don’t understand when plugin methods are executed and in which order, because this is done implicitly/magically. This means they have to always run netlify build --dry. They should not have to use a separate command to understand what’s going on with their build.
  3. Users will want some plugin methods to run at different times than what the plugins is doing by default. We currently fix this by letting each plugin define its own runsOn option, but this requires more work for both the plugin author and the user.

This is a proposal that would solve all those problems by drawing inspiration from GitHub actions design. It also re-uses their syntax so it’s already familiar to our users.

This solution keeps config.build.lifecycle.* so users can still run specific hooks during different lifecycles: post-deploy, pre-build, on errors, etc.

A plugin would look like this:

module.exports = {
  name: 'netlify-plugin-example',
  methods: {
    doThis({ pluginConfig: { foo } }) {
      console.log(`Done after build: ${foo}`)
      return { exampleUrl: 'url' }
    },
    doThat({ outputs: { exampleUrl } }) {
      console.log(`Output from previous step: ${exampleUrl}`)
      console.log('Done after deploy')
    },
  },
}

A configuration would look like this (notice the plugins property is not needed anymore):

build:
  lifecycle:
    build:
      - npm run build
      - uses: netlify-plugin-example#doThis
        with:
          foo: bar
    deploy: 
      - echo ${outputs:exampleUrl}
      - uses: netlify-plugin-example#doThat
      - uses: netlify-plugin-another
        with:
          url: ${outputs:exampleUrl} 

What do you think?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
biilmanncommented, Nov 13, 2019

Have a bunch of thoughts on this and it might be good to setup a shirt call to talk through. Here’s my initial super brief take since I’m at the A16Z Summit without a lot of time to write something longer.

I think we’re still not quite there with the configuration format, but from a product philosophy perspective I do think the current plugin syntax is closer to the mark than the Actions inspired version.

I think users should be able to add things like a lighthouse score plugin without having to touch lifecycles at all and still just use the current one step command: "yarn build" kind of syntax.

I could also easily imagine a future where plugins could be activated from the UI without touching the config file at all, and the separate plugin config makes more sense in that world in my opinion.

In my view we should do more to make the build steps and what happens in them obvious in the UI, rather than focusing on teaching our users to build more complex flows in configuration files.

I’ll need more time to dig into the current set of plugins to see if there’s opportunity to simplify the syntax more, but I think we should make sure that the syntax we choose works in a way where you can easily imagine an existing user adding a plug-in to their current build without restructuring the existing toml file to be based on life cycles.

1reaction
sdrascommented, Nov 9, 2019

For me, @ehmicky’s design proposal is actually cleaner. I’ve found

plugins:
  - type: netlify-plugin-one

to be a bit verbose without adding much value. Coming from working with actions, this unifies our configuration and will be a little easier for devs with that experience to follow. This piece is important- the likelihood that a dev would be exploring both actions and our build plugins is high. And as I mentioned in the very first call about Build Plugins, this ability to support GitHub actions is a force multiplier and allows us to work much more effectively in the ecosystem.

I’m also really interested in having the plugin return outputs for other plugins to consume. Funnily enough, this was also another point I brought up in the first meeting, though less from a “one returning another” standpoint and more from a “we could have an orchestrator like durable functions”, though one could argue that the configuration file is the orchestrator here.

All in all, I’m very much in favor of @ehmicky’s proposal! Great work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simplify Terraform Configuration with Locals
Use Terraform local values to simplify your configuration and avoid duplication of reused expressions.
Read more >
Beginners Guide to 3D Printing G-Code Commands - Simplify3D
This guide covers the 10 most common G-Code commands used in 3D printing. Learn what each command does & view examples that you...
Read more >
Simp - Lean community
Lean has a "simplifier", called simp , that consults a database of facts called simp lemmas to (hopefully) simplify hypotheses and goals.
Read more >
Inside my basic print settings in Simplify 3D. - YouTube
Today we journey down the rabbit hole and I show you the settings I use in Simplify 3D.Resources: You can now help the...
Read more >
Simplify Eclipse Che configuration format (CheCluster API v2)
Simplify Eclipse Che configuration format (CheCluster API v2) #20758 ; kind/task Internal things, technical debt, and to-do tasks to be performed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found