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

using a seperate file to define scripts and paching them into package.json #63

Open
KilianKilmister opened this issue Jul 12, 2020 · 1 comment

Comments

@KilianKilmister
Copy link

KilianKilmister commented Jul 12, 2020

Is there any interest for adding the possibility to patch the package.json with scripts defined in a seperate file?

It wouldn't be hard to implement and would allow users to use YAML, JS or JSON5 and their pleasantness.
This would also allow the command and the description to be right next to eachother, which i would like

command could look like this:

ntl -p/--patch path/to/file (defaulting to <pkg-root>/.ntlrc.<ext>)

so the structure would be something like:

{
    "build": {
      "command": "make build",
      "description": "Builds the project"
    },
    "coverage": {
      "command": "jest --coverage",
      "description": "Run test outputing code coverage"
    },
    "test": {
      "command": "jest"
    },
  // or if it has no desc, a shorthand
  "lint": "standard src/**/*.js"
}

this could be used together with general configs #23 like:

{
  // config properites...
 "scripts": {
  // like above...
  }
}

this would also expose a common surface for a module that extends ntl, as config properties can be easily added. we could also add a complementary API that lets you import these scripts (for eg. for usage with npm run-script)

this could also be extended down the line to rather easily implement monorepo support #58 via a 'namespace': {<name>: <path/to/package>} property or something like that.

I'm planning on writing a patcher that does something like this (without the many practicallity featueres of course) for a module i'm writing. so if there is interest in this, i could provide a fundament and help with the further implementation

@ruyadorno
Copy link
Owner

ruyadorno commented Oct 23, 2020

That sounds like something that would be interesting to have for sure! 😄 As you pointed out I think the place to start would be to get a proper file config as discussed in #23 so that we could also allow scripts/descriptions/more metadata to live there and be more flexible with regards to user format preference.

I don't even think it would need to be behind a flag such as --patch and would just make it the default behavior for any scripts defined in your .ntlrc file to overwrite the ones defined in package.json

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

No branches or pull requests

2 participants