{"name":"@semrel-extra/topo","version":"1.4.3","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":{"@types/toposort":"^2.0.3","fast-glob":"^3.2.11","toposort":"^2.0.2","tslib":"^2.4.0"},"devDependencies":{"@types/micromatch":"^4.0.2","c8":"^7.12.0","esbuild":"^0.14.51","esbuild-node-externals":"^1.4.1","loadr":"^0.1.1","micromatch":"^4.0.5","prettier":"^2.7.1","tsc-esm-fix":"^2.20.0","tsm":"^2.2.2","typescript":"^4.7.4","uvu":"^0.5.6"},"prettier":{"arrowParens":"avoid","quoteProps":"consistent","semi":false,"singleQuote":true,"trailingComma":"none"},"gitHead":"c43456d74ff14c97955b276ec1b369a1b77ed422","_id":"@semrel-extra/topo@1.4.3","_nodeVersion":"12.22.7","_npmVersion":"6.14.15","dist":{"integrity":"sha512-PRHF+xNdNJzYFK+Agg2D3IRITfmDoNqKYMRTWtAdWpEi3PauJ0x+WCZpUST6t3HihOfWRlhgZ1A7pR2nTQCGPg==","shasum":"5063a0c52a0b60d4461119899ecdd3b406f076a0","tarball":"http://registry-npm.ywwl.com/@semrel-extra/topo/download/@semrel-extra/topo-1.4.3.tgz","fileCount":8,"unpackedSize":17863,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDjT/m5wLlCRtQ5sd6CRF5wZQmXtRH0rJdK6sNXF9CLZAiALEzDXDA2WMf2kjTktGGCyCahIP1BYccOpHhHp5KE0ww=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi5ELPACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoeeQ//exTPk1Jnn0+STFKsiikedLYfe5EUTuRZanD2tbfe3SPvTBMp\r\nlkMJka1/B9/yj1HhEGcG3AAuHP1DFDAajuh1nFRGRY7QYrBV1AXXWAbav6AJ\r\nBzYZbOdHxOvKyBZY203vHn9Z7Pv7q7K8nu2SwVvnH7q/5+PeCvgizcBPNIWn\r\nmXl31c5djb9/CriHVjxS93ZbWKsn/tWONF8hv+NescPKAigo2G6xJd+YrtSV\r\nlAkdrmv95qcpjYZYF+iPI9ejHbRH+Chv7QC+w1LHwosGfkKvHPfVlU5JWtUT\r\npwCevpMqiAD/BaJuKz32r7p4bk2x+a6fjaROlG0MfKRGXrwxjFZhKdkG9dbs\r\nigbnYSc8XuTJA132RxNKaKJQi9FHsb5KiM593z5vmA33yBsdrhTSHPIUd2JU\r\npGFzSgUfeSOxhHQLLVqIYwZWsw0sFdvztbtoLch4fHMn5pcedZ9bSYGdFEgM\r\nfGiKldFZ8wyAxB9B4PYmpAzFjvJChsFNiiA9i3iefqeFD5u6GZl6VFBUOxNx\r\nmNiQGSvOhzQMALKH6y5PY5rIX4cy4pVNt3yli1MLXaZ7//9UUpDrz+mzQiBS\r\nbUCGJCYTuiJ4Fu7ZwU/xBnHN8HdN6MG7Do06MX1Dkx+6AqkVcxPtOuvtY0f4\r\ncTaR7dXTUqb/W34q8p6FUX+WHsVTPNtl4uI=\r\n=HMgg\r\n-----END PGP SIGNATURE-----\r\n","size":5302,"noattachment":false,"key":"/@semrel-extra/topo/-/@semrel-extra/topo-1.4.3.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.4.3_1659126479261_0.7480519068956712"},"_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":1659126479417,"_cnpm_publish_time":1659126479417,"dist-tags":{"latest":"1.14.1"}}