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

@nx/devkit

Package Overview
Dependencies
Maintainers
4
Versions
746
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nx/devkit

The Nx Devkit is used to customize Nx for different technologies and use cases. It contains many utility functions for reading and writing files, updating configuration, working with Abstract Syntax Trees(ASTs), and more. Learn more about [extending Nx by

  • 20.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.2M
decreased by-16.92%
Maintainers
4
Weekly downloads
 
Created

What is @nx/devkit?

The @nx/devkit package is a set of utilities for building and managing development workflows, particularly in the context of monorepos managed by Nx. It provides APIs for creating plugins, generating files from templates, and interacting with the Nx workspace configuration.

What are @nx/devkit's main functionalities?

Plugin Creation

This code sample demonstrates how to create a simple Nx plugin that writes a greeting to a file, formats the files in the workspace, and schedules a task to install npm packages.

import { Tree, formatFiles, installPackagesTask } from '@nrwl/devkit';

export default async function (tree: Tree, schema: any) {
  tree.write('hello.txt', `Hello ${schema.name}!`);
  await formatFiles(tree);
  return () => {
    installPackagesTask(tree);
  };
}

Workspace Configuration Interaction

This code sample shows how to read and update the workspace configuration in an Nx workspace using the @nx/devkit package.

import { updateWorkspaceConfiguration, readWorkspaceConfiguration } from '@nrwl/devkit';

export function updateWorkspace(tree) {
  const config = readWorkspaceConfiguration(tree);
  config.version = 2;
  updateWorkspaceConfiguration(tree, config);
}

Generating Files from Templates

This example illustrates how to generate files in an Nx workspace from a set of templates, using the options provided to customize the generated output.

import { generateFiles, joinPathFragments } from '@nrwl/devkit';

export function generateComponent(tree, options) {
  const templatePath = './path/to/templates';
  const targetPath = joinPathFragments('libs', options.name);
  generateFiles(tree, templatePath, targetPath, options);
}

Other packages similar to @nx/devkit

Keywords

FAQs

Package last updated on 15 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