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

devDependency with non semVer value silently fails #140

Closed
jmatsushita opened this issue Jun 9, 2023 · 8 comments
Closed

devDependency with non semVer value silently fails #140

jmatsushita opened this issue Jun 9, 2023 · 8 comments

Comments

@jmatsushita
Copy link

jmatsushita commented Jun 9, 2023

Description

I have this line in my package.json:

  "devDependencies": {
    "@changesets/cli": "patch:@changesets/cli@npm%3A2.26.0#~/.yarn/patches/@changesets-cli-npm-2.26.0-49d5c5f72d.patch",

With it, syncpack lint fails silently (retuning exit code 1), not showing anything sketchy even with SYNCPACK_VERBOSE-true

When removing it, everything works again. Note that I'm using yarn 4.0.0-rc.45 in case there's been some changes in the patch: protocol...

Update

Any non semVer value seems to fail:

{
  "devDependencies": {
    "a": "b"
  }
}
@jmatsushita
Copy link
Author

I should add that this also happens when there's similar patch: values in the resolutions field.

Also a workaround is to isIgnored: true in semverGroups matching the dependency. In my example that would be:

{
  "semverGroups": [
    {
      "packages": [
        "**"
      ],
      "dependencies": [
        "@changesets/cli"
      ],
      "isIgnored": true
    }
  ]
}

@jmatsushita
Copy link
Author

Note that the syntax for resolutions has to include the @version suffix:

{
  "semverGroups": [
    {
      "types": [
        "resolutions"
      ],
      "packages": [
        "**"
      ],
      "dependencies": [
        "@changesets/cli@^2.26.0"
      ],
      "isIgnored": true
    },
    {
      "packages": [
        "**"
      ],
      "dependencies": [
        "@changesets/cli"
      ],
      "isIgnored": true
    }
  ]
}

@jmatsushita
Copy link
Author

Oh. There is a much simpler reproducer! In an empty folder with this package.json:

{
  "devDependencies": {
    "a": "b"
  }
}

Running npx syncpack lint exits with status code 1 silently. Here's the log:

$ SYNCPACK_VERBOSE=true npx syncpack lint                                                                                 ~/dev/workshop/iios-syncpack
? readConfigFileSync( undefined )
? no config file found
? readFileSync( ...syncpack/package.json )
? readYamlFileSync( ...syncpack/pnpm-workspace.yaml )
? readFileSync(...syncpack/lerna.json )
? globSync( package.json )
? globSync( packages/*/package.json )
? Error: "glob" did not match "packages/*/package.json":
    at /.npm/_npx/be9d1b14e10e64b8/node_modules/tightrope/cjs/result/filter.js:12:23
    at /.npm/_npx/be9d1b14e10e64b8/node_modules/tightrope/cjs/result/lib/with-catch.js:9:20
    at curriedFn (/.npm/_npx/be9d1b14e10e64b8/node_modules/tightrope/cjs/fn/curry.js:7:20)
    at /.npm/_npx/be9d1b14e10e64b8/node_modules/tightrope/cjs/fn/pipe.js:5:36
    at Array.reduce (<anonymous>)
    at pipe (/.npm/_npx/be9d1b14e10e64b8/node_modules/tightrope/cjs/fn/pipe.js:5:16)
    at resolvePattern (/.npm/_npx/be9d1b14e10e64b8/node_modules/syncpack/dist/get-package-json-files/get-file-paths.js:26:36)
    at /.npm/_npx/be9d1b14e10e64b8/node_modules/syncpack/dist/lib/$R.js:18:32
    at /.npm/_npx/be9d1b14e10e64b8/node_modules/tightrope/cjs/fn/pipe.js:5:36
    at Array.reduce (<anonymous>)
? readFileSync( /...syncpack/package.json )
? add a@b to dev:versionsByName package.json
? add a@b to dev:versionsByName package.json
? exit( 1 )

@jmatsushita jmatsushita changed the title devDependency with patch: silently fails. devDependency with non semVer value silently fails Jun 9, 2023
@JamieMason
Copy link
Owner

I need to improve the output messaging to make it clearer what is happening (#132) but you should only get an exit 1 when unsupported versions do not match each other. Could it be that "@changesets/cli" is not always "patch:@changesets/cli@npm%3A2.26.0#~/.yarn/patches/@changesets-cli-npm-2.26.0-49d5c5f72d.patch"? It's possible though that syncpack lint-semver-ranges is what's returning 1, if you run eg syncpack list does that exit 0?

Since v10 syncpack will error on versions it considers invalid, but the messaging needs to improve to help understand and fix them. Downgrading to v9 should hopefully avoid this for now as it doesn't have this strictness.

JamieMason added a commit that referenced this issue Jun 18, 2023
Closes #140

When linting semver ranges, warn on non-semver versions but don't error

Closes #139

Handle !negated globs

Closes #132

Show more detailed information about errors and warnings

Closes #111

Throw when config is invalid, instead of defaulting
@JamieMason
Copy link
Owner

Released in 10.6.1. Any problems, please let me know.

If you find syncpack useful, please star the project or help us spread the word to other Developers.

@jmatsushita
Copy link
Author

Thank you, just tested it and it's a great improvement. I starred the repo too ⭐

@JamieMason
Copy link
Owner

Great 👍

@JamieMason
Copy link
Owner

Update: 12.0.0-alpha.0 adds better support for non-semver version formats and there is a new Getting Started guide. The output when there are errors should also be more detailed now too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants