Socket
Socket
Sign inDemoInstall

@nx/devkit

Package Overview
Dependencies
146
Maintainers
4
Versions
400
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
2.9M
decreased by-20.86%
Maintainers
4
Created
Weekly downloads
 

Package description

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

Readme

Source

Nx - Smart Monorepos · Fast CI

CircleCI License NPM Version Semantic Release Commitizen friendly Join the chat at https://gitter.im/nrwl-nx/community Join us on the Official Nx Discord Server


Nx: Smart Monorepos · Fast CI

Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.

This package contains a set of utilities for creating Nx plugins.

Getting Started

Creating an Nx Workspace

Using npx

npx create-nx-workspace

Using npm init

npm init nx-workspace

Using yarn create

yarn create nx-workspace

Adding Nx to an Existing Repository

Run:

npx nx@latest init

Documentation & Resources

Nx - Smart Monorepos · Fast CI

Keywords

FAQs

Last updated on 25 Apr 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc