artlogic/nabs

[Discussion] Strategy Change

Opened this issue · 1 comments

Sorry for taking so long in providing feedback.

I like the idea of breaking out the command from the package.json file as they can become long and difficult to read; and really ugly to comment. However, it feels a little weird to me to have a source file (nabs.yml) that exists to make changes to package.json. The reason, I think, that it feels weird to me is because when you make changes to the nabs.yml file you also must remember to run the conversion for package.json as well.

I've been thinking about this a little bit. My, two, suggestions for thought exploration are:

  1. Is there a way to "capture" npm run ... calls and do something with nabs before, after, or instead of letting npm do its work? If so this might be a better solution.
  2. If the first option isn't possible, maybe register the "tasks" in the package.json script directives and have them simply execute nabs "tasks".
  3. If you are OK with a global package executable however you could skip the package.json completely IMHO.

I personally avoid installing any npm modules globally as a rule. I've even thought about setting up my shell to include $(cwd)/node_modules/.bin/ to my path so that I can install modules locally but use them as if they were global.

Short Answers

  1. No but neat idea.
  2. What you describe sounds like Scripty.
  3. What you describe sounds like nps.
  4. Likewise I only have 1 global installed. Any dependency's binary can be run as:
    • yarn <bin>
    • npx <bin> (auto-installs if not found)
    • $(npm bin)/<bin>

Comparison

What makes nabs special is that it's not magic at all. It's just package scripts. npm's stance has consistently been (npm/npm#4482) package.json is a machine manifest not a config file. Meanwhile package scripts are our build system. Each project approaches this impedance mismatch differently.

Project Description Pros Cons
edit-script Open package script in an editor and save back to package.json.
  • Scripts stay in package.json.
  • Scripts are no less unwieldy to manage.
  • Scripty Run executable file from a directory structure resembling nabs's config.
  • Scripts are still run by package scripts.
  • Short scripts in numerous files and directories is nearly as unwieldy.
  • nps Run shell string from a config resembling nabs's.
  • YAML configuration.
  • No duplication with package scripts.
  • Sexy CLI.
  • Not package scripts at all. npm start <script> instead of npm run <script>.
  • Standard tools don't detect them (yet).
  • No before/after hooks.
  • "Magic". The script key is passed to the system shell in a child process. Tricky with environment variables.
  • nabs You have arrived.
  • YAML configuration.
  • Scripts are still run by package scripts.
  • nabs needs to be run after every change to nabs.yml. It's too rare for a watch command. A build tool plugin would make sense.