source
If for some reason you do not want to use the same files as your package manager, you can use the source config to provide an alternative list of glob patterns to override which package.json files syncpack will operate on.
Syncpack will look in the following places for glob patterns matching package.json files, in this order of precedence, and stop looking when a match is found:
- If
--sourceCLI options are provided, use those. - If
sourceis defined in configuration, use that. - If using npm workspaces or Yarn workspaces, read
workspacesfrom./package.json. - If using pnpm, read
packagesfrom./pnpm-workspace.yaml. - If using Lerna, read
packagesfrom./lerna.json. - Default to
'package.json'and'packages/*/package.json'.
Adding sources without replacing discovery
By default, --source and source replace the discovered patterns. To keep workspace discovery and add extra patterns on top, set sourceMode to "extend" (or pass --source-mode extend). Discovered patterns come first; your patterns are appended last, so gitignore-style negations such as !apps/legacy can exclude discovered entries.
Polyrepos
In this example we have a directory on our machine called my-projects where we git clone all of the repositories we work on for our company.
Despite us not having a monorepo, a .syncpackrc.json placed alongside each git clone allows us to use syncpack to find and fix problems.
{ "source": ["./*/package.json", "./*/packages/*/package.json"]}