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

@angular-devkit/schematics

Package Overview
Dependencies
Maintainers
2
Versions
790
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angular-devkit/schematics

Angular Schematics - Library

  • 19.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.1M
decreased by-3.06%
Maintainers
2
Weekly downloads
 
Created

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

Keywords

FAQs

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