{"name":"@semrel-extra/topo","version":"1.7.0","description":"Helper to resolve monorepo dependencies graph","publishConfig":{"access":"public"},"main":"./target/es5/index.cjs","types":"./target/es5/index.d.ts","type":"module","exports":{"require":"./target/es5/index.cjs","import":"./target/es6/index.mjs","module":"./target/es6/index.mjs"},"scripts":{"build":"yarn build:es6 && yarn build:es5","build:es6":"yarn build:es6:target && yarn build:es6:libdef && yarn build:es6:ext","build:es6:target":"node ./build.es6.cjs","build:es6:libdef":"tsc --emitDeclarationOnly --outDir target/es6","build:es6:ext":"tsc-esm-fix --target=target/es6 --ext=.mjs","build:es5":"yarn build:es5:target && yarn build:es5:libdef && yarn build:es5:ext","build:es5:target":"node ./build.es5.cjs","build:es5:libdef":"tsc --emitDeclarationOnly --outDir target/es5","build:es5:ext":"rename 's/\\.js$/\\.cjs/' target/es5/*.js","test":"yarn test:unit && yarn lint","test:unit":"c8 -r html -r text -r lcov loadr -- uvu 'src/test/' -i fixturess","lint":"prettier --write src","postupdate":"yarn && yarn build && yarn test"},"repository":{"type":"git","url":"git+https://github.com/semrel-extra/topo.git"},"keywords":["topo","graph","monorepo"],"author":{"name":"Anton Golub","email":"antongolub@antongolub.com"},"license":"MIT","bugs":{"url":"https://github.com/semrel-extra/topo/issues"},"homepage":"https://github.com/semrel-extra/topo#readme","dependencies":{"fast-glob":"^3.2.12","toposource":"^1.1.1","tslib":"^2.5.0"},"devDependencies":{"@types/micromatch":"^4.0.2","@types/node":"^18.14.1","c8":"^7.13.0","esbuild":"^0.17.10","esbuild-node-externals":"^1.6.0","loadr":"^0.1.1","micromatch":"^4.0.5","prettier":"^2.8.4","tsc-esm-fix":"^2.20.12","tsm":"^2.3.0","typescript":"^4.9.5","uvu":"^0.5.6"},"prettier":{"arrowParens":"avoid","quoteProps":"consistent","semi":false,"singleQuote":true,"trailingComma":"none"},"gitHead":"0538494c29efd0e8860dae5b8cff92faa8cc75f3","_id":"@semrel-extra/topo@1.7.0","_nodeVersion":"18.15.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-DqDJpD4VXwOtXf5EyHIxc0RUwb0y/HbsdMKwS2Si2UYK0OcfnNG4aMQUd2VG/KkVNQkbNwhsffEUNEPXAgYnyA==","shasum":"ef90200810e2d7d7922223aa0e3aa1905bfd8036","tarball":"http://registry-npm.ywwl.com/@semrel-extra/topo/download/@semrel-extra/topo-1.7.0.tgz","fileCount":12,"unpackedSize":20667,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHdKti/A2Wf+wLhVd+0G2fUB+AxYP+pN8YE/JbDxBNTLAiEA65eiRWzhna9IBmV5WPy5Onjmr51irwJ3di2NFgzocuA="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkIw92ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpw5Q//ZnFP2zQXjFH5LvZ4BfQ+DEbyiPlAEfedVudSQtuzic6VqOm/\r\nBiJQQg0PsrNdM5pq9Y6peSakrPDynI7AwqolI9zv+MOiOM6AGTTuHEFCRs1X\r\nIDeyM5ah6MMe+b85wI9t+xvPuA1nddHHAUuoCt+qX8ZbfERhYcOwUepb1JNV\r\nob9JfnwgBvn7HPxcWe6dz+BaFvZZtvH3IS0hgWjMIMKLMOo6d4keQ++I8iqS\r\nNUabCORbLHZ0UB4WclhkFarUhgrg/UgWTPIeI9BgKqnFFA2Qm+p8kNUQR24e\r\nr6+g3DGglkUZ1iEkMdWI/QoSQlSLwSpQl8WFdPGZPTG83ALqirqL+3hQhwYD\r\nkH3NMisRiQmb8Jq7L3crjf5NA3KLGEgF9EadJoh3PWKZtdu8XteYVcJGwxsg\r\nPl5a+fxj0GWY92qXUydcY54dNJBXp8j/K95ush6fvwQv/ctQP8yrPFaOOWnq\r\nS6wNP7RPCcPnFVLAmg1kDXckgOwQn2X5yFPLFK7CSFtc9piJZ8sNFI5BYKeO\r\n0FWNItMCqajVoSD+tLdWJk6FT3u/d/AFkUNLOmO4cwAVhLUWbFZAFDkU4EbP\r\nVtqK8wJbRvGvCIsKp84qKYz2M+iscLBjyMaonzYEgZCgo2KGcawC9Xa19KJ/\r\nImvFQ4Cddcj3FHPAqezhfjePKMNHBBsueO8=\r\n=R5LR\r\n-----END PGP SIGNATURE-----\r\n","size":6011,"noattachment":false,"key":"/@semrel-extra/topo/-/@semrel-extra/topo-1.7.0.tgz"},"_npmUser":{"name":"semrel-extra-bot","email":"semrel-extra-bot@hotmail.com"},"directories":{},"maintainers":[{"name":"dhoulb","email":"dave@shax.com"},{"name":"semrel-extra-bot","email":"semrel-extra-bot@hotmail.com"},{"name":"antongolub","email":"golub.anton@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/topo_1.7.0_1680019317969_0.24976497220018135"},"_hasShrinkwrap":false,"readme":"# @semrel-extra/topo\n\n[![CI](https://github.com/semrel-extra/topo/workflows/CI/badge.svg)](https://github.com/semrel-extra/topo/actions)\n[![Maintainability](https://api.codeclimate.com/v1/badges/48b31cd38b905b729beb/maintainability)](https://codeclimate.com/github/semrel-extra/topo/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/48b31cd38b905b729beb/test_coverage)](https://codeclimate.com/github/semrel-extra/topo/test_coverage)\n\n> Helpers to assist monorepo dependencies traversals\n\n## Install\n```shell\nyarn add @semrel-extra/topo\n```\n\n## Usage\n```ts\nimport { topo } from '@semrel-extra/topo'\n\nconst graph = topo({\n  workspaces: ['packages/*'],\n  cwd: '/path/to/project/root'\n})\n\n{\n  queue: ['pkg-a', 'pkg-b', 'pkg-z', 'pkg-y', 'pkg-x'],\n  nodes: ['pkg-a', 'pkg-b', 'pkg-x', 'pkg-y', 'pkg-z'],\n  edges: [\n    ['pkg-a', 'pkg-b'],\n    ['pkg-z', 'pkg-y'],\n    ['pkg-y', 'pkg-x'],\n  ],\n  // packages entries map\n  packages: {\n    'pkg-a': {\n      manifest: {\n        name: 'pkg-a',\n        dependencies: {}\n      },\n      manifestPath: '/path/to/project/root/packages/a/package.json',\n      path: 'packages/a', // legacy\n      relPath: 'packages/a',\n      absPath: '/path/to/project/root/packages/a'\n    },\n    'pkg-b': {...},\n    ...\n  }\n}\n```\n\n### `pkgFilter() / filter()`\nFilter option is a function: gets `IPackageEntry` as argument, returns `boolean`\n```ts\nconst graph = topo({\n  workspaces: ['packages/*'],\n  cwd: '/path/to/project/root',\n  filter: ({manifest}) => !manifest.private // to omit private packages from graph\n})\n```\n\n### `depFilter()`\nApplies filter to any kind of pkg dependencies to omit them from the graph.\n```ts\nconst gpaph = topo({\n  workspaces: ['packages/*'],\n  cwd: '/path/to/project/root',\n  depFilter: ({version}) => version.startsWith('workspace:') // include only workspace deps\n})\n```\n\n### `workspacesExtra`\nInjects extra pattern to the resolved `workspaces` value from `package.json` / `pnpm-workspace.yaml`\n```ts\nconst gpaph = topo({\n  workspacesExtra: ['!packages/foo'],\n  cwd: '/path/to/project/root'\n})\n\n```\n\n### `traverseDeps()`\nIterates up to the pkg deps graph.\n```ts\nimport {topo, traverseDeps} from '@semrel-extra/topo'\n\nconst {packages} = topo({\n  workspaces: ['packages/*'],\n  cwd: '/path/to/project/root'\n})\nconst pkg = packages['pkg-a']\nconst cb = async ({name, pkg}: IDepEntry) => {\n  await traverseDeps({pkg, packages, cb})\n}\n\nawait traverseDeps({packages, pkg, cb})\n```\n\n### `traverseQueue()`\nIterates over the queue of packages in the order of their dependencies.\n```ts\nimport {topo, traverseQueue} from '@semrel-extra/topo'\n\nconst {queue, prev} = await topo({\n  workspaces: ['packages/*'],\n  cwd: '/path/to/project/root'\n})\nconst cb = async (name: string) => {\n  // some async action\n}\nawait traverseQueue({ queue, prev, cb })\n```\n\n### `iterateDeps()`\nWalks through the package dependencies and applies the `cb()` for each.\n```ts\nconst results: any[] = []\nconst manifest = {\n  name: 'foo',\n  version: '0.0.0',\n  dependencies: {\n    bar: '1.0.0'\n  },\n  devDependencies: {\n    baz: '2.0.0'\n  }\n}\n\niterateDeps(manifest, ({ name, version, scope, deps }) => {\n  results.push({ name, version, scope, deps })\n})\n```\n\n## License\n[MIT](./LICENSE)\n","publish_time":1680019318155,"_cnpm_publish_time":1680019318155,"dist-tags":{"latest":"1.14.1"}}