Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extract-dependencies-from-sources

Package Overview
Dependencies
Maintainers
0
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extract-dependencies-from-sources

Inferring dependencies from the source code of a monorepo app

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

extract-dependencies-from-sources

Open in Visual Studio Code npm bundle size Github workflow Quality Gate Status Maintainability Rating Security Rating Reliability Rating Coverage Lines of Code Technical Debt Code Smells Bugs Vulnerabilities Duplicated Lines (%) Last commit

Inferring dependencies from the source code of a monorepo app

        

⚡ Quickstart

🔶 Install

yarn add -D extract-dependencies-from-sources
pnpm i -D extract-dependencies-from-sources

🔶 Usage

🧿 cjs
extractDeps --packagejson ./package.json --path codebasePath

Options:
  --help          Show help                                            [boolean]
  --version       Show version number                                  [boolean]
  --packagejson   Root package.json path  [required] [default: "./package.json"]
  --path          Codebase path                                       [required]
  --externaldeps  Path to external dependencies file (optional)

Examples:
  extractDeps --packagejson ./package.json --path ./apps/back --path
  ./libs/back

Inferring dependencies from the source code of a monorepo app

For example, running the following command will replace the dependencies property of the root package.json with the dependencies found in the codebases located in apps/back and libs/back/database.

yarn extractDeps --path apps/back --path libs/back/database
🧿 esm
extractDepsEsm --packagejson ./package.json --path codebasePath

Options:
  --help          Show help                                            [boolean]
  --version       Show version number                                  [boolean]
  --packagejson   Root package.json path  [required] [default: "./package.json"]
  --path          Codebase path                                       [required]
  --externaldeps  Path to external dependencies file (optional)

Examples:
  extractDeps --packagejson ./package.json --path ./apps/back --path
  ./libs/back

Inferring dependencies from the source code of a monorepo app
🧿 node

You can also use the function directly in your code:

import { getCodebasesDependencies } from 'extract-dependencies-from-sources';
import { readJson } from 'fs-extra';

const data = await readJson('./package.json');
const deps = await getCodebasesDependencies(data.dependencies, [
  'apps/front/auth',
  'lib/front/components',
]);

🔶 Including external dependencies

You can also specify external dependencies to include in the output by providing a path to a yaml file containing a map of dependencies:

external-deps.yml

externaldeps:
  - msw: ^1.1.0
  - eslint: ~8.36.0

You can then use the --externaldeps option to include them:

yarn extractDeps --path apps/front --externaldeps ./external-deps.yml

FAQs

Package last updated on 03 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc