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

feat(cli): improve error messages #132

Closed
jamiehaywood opened this issue May 10, 2023 · 4 comments
Closed

feat(cli): improve error messages #132

jamiehaywood opened this issue May 10, 2023 · 4 comments

Comments

@jamiehaywood
Copy link

Description

I have a syncpack config:

module.exports = {
  customTypes: [],
  dependencyTypes: ['dev', 'peer', 'prod', 'workspace'],
  semverGroups: [
    {
      range: '^',
      dependencies: ['@my-internal-pkg/**'],
      packages: ['**'],
      isIgnored: true,
      dependencyTypes: ['dependencies', 'resolutions', 'overrides', 'pnpmOverrides', 'workspace'],
    },
  ],
  semverRange: '',
  sortAz: [
    'contributors',
    'dependencies',
    'devDependencies',
    'keywords',
    'peerDependencies',
    'resolutions',
    'scripts',
  ],
  sortFirst: ['name', 'description', 'version', 'author'],
  versionGroups: [],
}

When I run yarn syncpack fix-mismatches

I get an error from Zod validation:

cause: ZodError: [
    {
      "code": "unrecognized_keys",
      "keys": [
        "range"
      ],
      "path": [
        "semverGroups",
        0
      ],
      "message": "Unrecognized key(s) in object: 'range'"
    }
  ]

I'm not sure why this would be the case, because the docs and the code allow for the semverGroups object to have a key of range?

Suggested Solution

Not sure if this is a cosmiconfig issue or something else.

@jamiehaywood
Copy link
Author

Interestingly, when I remove isIgnored: true it doesn't throw an error

@JamieMason
Copy link
Owner

Hey Jamie, it's because the group needs to be either one (ignored) or the other (set to a range) so with them both being set it's not clear what to do. Zod will be removed in the next release and I'll do some work to improve the error messages a little too.

@JamieMason JamieMason changed the title "Unrecognized key(s) in object: 'range'" - syncpack.config.cjs feat: Improve error messages May 10, 2023
@JamieMason JamieMason changed the title feat: Improve error messages feat(cli): improve error messages May 28, 2023
JamieMason added a commit that referenced this issue May 28, 2023
Closes #124

When using the `workspace` dependency type, packages installing that dependency
no longer have to exactly match the `version` property of the package.json of
origin.

If the version or version range used by every dependent package matches, it is
considered valid.

Closes #130

JavaScript config files now have support for TypeScript IntelliSense.

https://jamiemason.github.io/syncpack/config-file#typescript-intellisense

Closes #114
Refs #109
Refs #125

Unsupported versions can now at least be managed via `pinVersion`, where
previously anything which was not valid semver would be ignored.

Refs #111
Refs #132

TypeScript IntelliSense support helps catch invalid config, but more work is
needed to display useful error messages at runtime.

Refs #48
Refs #3

Syncpack's internals are now better organised, so providing a Node.js API and
general lint and fix CLI commands are now closer to being released.

BREAKING CHANGES:

Although they are still not auto-fixable, unsupported versions which were
previously ignored are now acknowledged, which may introduce mismatches which
previously would have been considered valid.

This release was also a huge rewrite of Syncpack's internals and, while there
is a large amount of tests, some scenarios may have been missed.

If you run into any problems, please create an issue.
JamieMason added a commit that referenced this issue May 28, 2023
Closes #124

When using the `workspace` dependency type, packages installing that dependency no longer have to exactly match the `version` property of the package.json of origin.

If the version or version range used by every dependent package matches, it is considered valid.

Closes #130
Closes #131

JavaScript config files now have support for TypeScript IntelliSense.

https://jamiemason.github.io/syncpack/config-file#typescript-intellisense

Closes #114
Refs #109
Refs #125

Unsupported versions can now at least be managed via `pinVersion`, where previously anything which was not valid semver would be ignored.

Refs #111
Refs #132

TypeScript IntelliSense support helps catch invalid config, but more work is needed to display useful error messages at runtime.

Refs #48
Refs #3

Syncpack's internals are now better organised, so providing a Node.js API and general lint and fix CLI commands are now closer to being released.

BREAKING CHANGES:

- `fix-mismatches` will now exit with a status code of 1 if there are mismatches among unsupported versions which syncpack cannot auto-fix.
- Although they are still not auto-fixable, unsupported versions which were previously ignored are now acknowledged, which may introduce mismatches which previously would have been considered valid.
- This release was also a huge rewrite of Syncpack's internals and, while there is a large amount of tests, some scenarios may have been missed.
- If you run into any problems, please create an issue.
JamieMason added a commit that referenced this issue May 28, 2023
### #124

When using the `workspace` dependency type, packages installing that dependency no longer have to exactly match the `version` property of the package.json of origin.

Closes #124

If the version or version range used by every dependent package matches, it is considered valid.

### #130, #131

JavaScript config files now have support for TypeScript IntelliSense.

Closes #130
Closes #131

https://jamiemason.github.io/syncpack/config-file#typescript-intellisense

### #109, #114, #125

Unsupported versions can now at least be managed via `pinVersion`, where previously anything which was not valid semver would be ignored.

Closes #114

### #111, #132

TypeScript IntelliSense support helps catch invalid config, but more work is needed to display useful error messages at runtime.

### #48, #3

Syncpack's internals are now better organised, so providing a Node.js API and general lint and fix CLI commands are now closer to being released.

BREAKING CHANGE:

- `fix-mismatches` will now exit with a status code of 1 if there are mismatches among unsupported versions which syncpack cannot auto-fix.
- Although they are still not auto-fixable, unsupported versions which were previously ignored are now acknowledged, which may introduce mismatches which previously would have been considered valid.
- This release was also a huge rewrite of Syncpack's internals and, while there is a large amount of tests, some scenarios may have been missed.
- If you run into any problems, please create an issue.
@JamieMason
Copy link
Owner

In syncpack@10.0.0 @jamiehaywood's intellisense work will now catch this scenario, but some runtime validation with useful error messages would be good. Leaving this issue open for that side of things.

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.

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