Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@nx/devkit
Advanced tools
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
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.
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);
}
Yeoman is a generic scaffolding system that allows the creation of any kind of app. It can be used to scaffold complete projects or parts of projects, and it's not tied to a specific project structure like @nx/devkit is with Nx workspaces.
Plop is a micro-generator framework that provides a simple template-based system for code generation. It's less opinionated than @nx/devkit and can be used in any project, not just Nx workspaces.
Hygen is a scalable code generator that's fast and simple. It's similar to @nx/devkit in that it helps automate the creation of code, but it's not specifically designed for Nx workspaces and can be used in various types of projects.
Nx is a build system, optimized for monorepos, with plugins for popular frameworks and tools and advanced CI capabilities including caching and distribution.
This package contains a set of utilities for creating Nx plugins.
Using npx
npx create-nx-workspace
Using npm init
npm init nx-workspace
Using yarn create
yarn create nx-workspace
Run:
npx nx@latest init
FAQs
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
The npm package @nx/devkit receives a total of 3,265,395 weekly downloads. As such, @nx/devkit popularity was classified as popular.
We found that @nx/devkit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.