🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@angular-devkit/schematics

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
a

@angular-devkit/schematics

Angular Schematics - Library

19.2.12
latest
100

Supply Chain Security

100

Vulnerability

100

Quality

97

Maintenance

100

License

Version published
Weekly downloads
8.9M
-10.08%
Maintainers
2
Weekly downloads
 
Created
Issues
280

What is @angular-devkit/schematics?

@angular-devkit/schematics is a powerful tool for creating and managing code transformations in Angular projects. It allows developers to automate tasks such as generating components, services, and other Angular constructs, as well as performing code modifications and migrations.

What are @angular-devkit/schematics's main functionalities?

Generating a Component

This feature allows you to generate a new Angular component by creating the necessary TypeScript file with a basic component structure.

const { Rule, SchematicContext, Tree } = require('@angular-devkit/schematics');

function createComponent(options) {
  return (tree, _context) => {
    const content = `import { Component } from '@angular/core';

@Component({
  selector: 'app-${options.name}',
  templateUrl: './${options.name}.component.html',
  styleUrls: ['./${options.name}.component.css']
})
export class ${options.name.charAt(0).toUpperCase() + options.name.slice(1)}Component { }
`;
    tree.create(`/src/app/${options.name}/${options.name}.component.ts`, content);
    return tree;
  };
}

module.exports = { createComponent };

Updating a File

This feature allows you to update an existing file by replacing specified text with new text.

const { Rule, SchematicContext, Tree } = require('@angular-devkit/schematics');

function updateFile(options) {
  return (tree, _context) => {
    const filePath = options.path;
    if (tree.exists(filePath)) {
      const content = tree.read(filePath).toString('utf-8');
      const updatedContent = content.replace(options.oldText, options.newText);
      tree.overwrite(filePath, updatedContent);
    }
    return tree;
  };
}

module.exports = { updateFile };

Deleting a File

This feature allows you to delete a specified file from the project.

const { Rule, SchematicContext, Tree } = require('@angular-devkit/schematics');

function deleteFile(options) {
  return (tree, _context) => {
    const filePath = options.path;
    if (tree.exists(filePath)) {
      tree.delete(filePath);
    }
    return tree;
  };
}

module.exports = { deleteFile };

Other packages similar to @angular-devkit/schematics

FAQs

Package last updated on 14 May 2025

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