JamieMason / syncpack

Consistent dependency versions in large JavaScript Monorepos.
https://jamiemason.github.io/syncpack/
MIT License
1.46k stars 51 forks source link

fix(output): show useful message when a dependency type is not found #234

Open guillempuche opened 4 months ago

guillempuche commented 4 months ago

Description

I run syncpack list on my Yarn monorepo. There's something is not good on my package.json or Syncpack.

Logs

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

TypeError: Cannot read properties of undefined (reading 'read')
    at file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/dist/get-package-json-files/package-json-file.js:20:81
    at Array.map (<anonymous>)
    at PackageJsonFile.getInstances (file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/dist/get-package-json-files/package-json-file.js:20:49)
    at file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/dist/get-instances/index.js:9:305
    at file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/fiberRuntime.js:1303:243
    at body (file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/core.js:444:17)
    at FiberRuntime.While (file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/fiberRuntime.js:1021:14)
    at file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/fiberRuntime.js:1068:31
    at Object.context (file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/tracer.js:73:17)
    at FiberRuntime.runLoop (file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/fiberRuntime.js:1063:28) {
  name: '(FiberFailure) TypeError',
  [Symbol(effect/Runtime/FiberFailure)]: Symbol(effect/Runtime/FiberFailure),
  [Symbol(effect/Runtime/FiberFailure/Cause)]: {
    _tag: 'Die',
    defect: TypeError: Cannot read properties of undefined (reading 'read')
        at file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/dist/get-package-json-files/package-json-file.js:20:81
        at Array.map (<anonymous>)
        at PackageJsonFile.getInstances (file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/dist/get-package-json-files/package-json-file.js:20:49)
        at file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/dist/get-instances/index.js:9:305
        at file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/fiberRuntime.js:1303:243
        at body (file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/core.js:444:17)
        at FiberRuntime.While (file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/fiberRuntime.js:1021:14)
        at file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/fiberRuntime.js:1068:31
        at Object.context (file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/tracer.js:73:17)
        at FiberRuntime.runLoop (file:///Users/guillem/programacio/codi/cites/xiroi/xiroi/node_modules/syncpack/node_modules/effect/dist/esm/internal/fiberRuntime.js:1063:28)
  }
}

Suggested Solution

Point where is the error.

Help Needed

I add you, @JamieMason, to my private monorepo to check it.

JamieMason commented 4 months ago

hey @guillempuchem, it's a small typo of peers -> peer

/** @type {import("syncpack").RcFile} */
export default {
-   dependencyTypes: ['dev', 'prod', 'overrides', 'peers', 'resolutions'],
+   dependencyTypes: ['dev', 'prod', 'overrides', 'peer', 'resolutions'],

I'll leave this open for this to be handled properly with a useful message, thanks.

guillempuche commented 4 months ago

Thanks Jamie! This will be a good improvement.