Coder Social home page Coder Social logo

Comments (3)

srs avatar srs commented on June 22, 2024

Hi.
I'm a fan of concrete tasks and have not used task rules that much. Concrete tasks could be created using NodeTask and NpmTask right now, but do you suggest creating them using a list of some sort? If you have some ideas on how that would look I would be very interested.

BR,
Sten Roger

from gradle-node-plugin.

dougborg avatar dougborg commented on June 22, 2024

Yeah I have a couple ideas on this, but after thinking about it for a while, I am not really sure how much value it will end up providing. I'll outline what I was thinking though for anyone else who thinks it may be useful. Or maybe I will just end up talking myself into thinking it is a good idea after all.

My basic thought on approach was to create tasks automatically by use the output of npm completion or npm --help to generate a list of tasks for npm. For the grunt plugin, we would load up a list of tasks by either analyzing the Gruntfile, invoking grunt -h, or running some javascript to grab a task list from grunt some other way. It may even make sense to just have a list of tasks we know would be useful and maintain it as we see fit.

You could then loop through the list to create your tasks:

def npmCommands = [ "npm update", "npm cache clean", "npm config set" ]

npmCommands.each { String npmCommand ->

  def npmArgs = (npmCommand - "npm").tokenize()
  def taskName = "npm" + npmArgs*.capitalize().join()

  project.task(taskName, type: NpmTask) {
    group = 'Node'
    description = "Run \'${npmCommand}\'."
    args = npmArgs
  }
}

Concrete tasks may be easier for users to reason about and are a bit more discoverable than task rules. The show up nicely when you run gradle tasks:

...

Node tasks
----------
nodeSetup - Download and install a local node/npm version.
npmCacheClean - Run 'npm cache clean'.
npmConfigSet - Run 'npm config set'.
npmInstall - Install node packages from package.json.
npmSetup - Setup a specific version of npm to be used by the build.
npmUpdate - Run 'npm update'.

...

from gradle-node-plugin.

srs avatar srs commented on June 22, 2024

That's pretty nice. I like the idea that you could specify something like this:

node {
  npmCommands = [ "npm update", "npm cache clean", "npm config set" ]
}

And then it will automatically create the task definitions for you. But not sure if that's a feature that is really needed. Just looks nice :-)

from gradle-node-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.