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

Npm script rule forces unnecessary duplication #578

Closed
cefn opened this issue Dec 1, 2022 · 1 comment
Closed

Npm script rule forces unnecessary duplication #578

cefn opened this issue Dec 1, 2022 · 1 comment

Comments

@cefn
Copy link

cefn commented Dec 1, 2022

The pattern I'd like to lean into, is to have npm always 'drop in' to wireit and exploit its dependency support, meaning named npm script targets are mostly cruft I have to scroll up and down and maintain.

Experimenting with the below package.json config I received the error at bottom, requiring that there should be a matching named npm script target for every entry in wireit for a reason I don't understand. Honestly this seems totally unnecessary and will just lead to duplication, scrolling and errors for no reason that I can see (I am ready to be educated).

I would rather have this requirement removed, at least for the top-level package in a monorepo, and probably for all packages (logic would look in both scripts and in wireit). Having the targets ONLY defined in the wireit property is preferred in some or many cases.

In this context I am also desperate for features around #23 to allow wildcarding package paths, (package directories) and defining upstream packages (package dependencies that live in the same repo) so that relations can be maintained in a terse way with minimal manual duplication.

You can see how e.g. the wireit.test.dependencies has to be manually maintained, (to duplicate information already in the root package.json workspaces and monorepo folder structure) and within example:test the upstream dependencies of build ( "packages/example-consumer1:test", "packages/example-consumer2:test" ) have to be manually maintained (to duplicate information already in package.json dependencies).

Not requiring named npm scripts is another way to avoid pointless duplicate info. Would it be good to remove this code (both from wireit and from people's package.json).

  "scripts": {
    "qa": "wireit",
    "qa:watch": "npm run qa --watch"
  },
  "wireit": {
    "test": {
      "dependencies": [
        "packages/example:test",
        "packages/example-consumer1:test",
        "packages/example-consumer2:test"
      ]
    },
    "lint": {
      "command": "eslint --color --cache --cache-location .eslintcache .",
      "files": [
        "**/*.ts",
        ".eslintignore",
        ".eslintrc.cjs"
      ],
      "output": []
    },
    "qa": {
      "$comment": "'test' forces build on a per-project basis",
      "dependencies": [
        "test",
        "lint"
      ]
    }
  },
[github/starter]$ npm run qa

> starter@1.0.0 qa
> wireit

❌ package.json:29:5 Script "test" not found in the scripts section of this package.json.
        "test": {
        ~~~~~~
❌ package.json:34:5 Script "lint" not found in the scripts section of this package.json.
        "lint": {
        ~~~~~~
@augustjk
Copy link
Collaborator

This has been implemented in #653

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