Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Angular File Generator is a Visual Studio Code extension that allows you to generate Angular files with a few clicks. It is based on the Angular CLI and uses the same schematics as the CLI. It also allows you to generate files from the terminal.

License

NotificationsYou must be signed in to change notification settings

ManuelGil/vscode-angular-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Visual Studio Marketplace VersionVisual Studio Marketplace InstallsVisual Studio Marketplace DownloadsVisual Studio Marketplace RatingGitHub Repo starsGitHub license

The fastest way to generate Angular files, right from your editor.

Stop memorizing CLI commands and switching contexts. This extension integrates the Angular CLI into the VSCode UI, letting you scaffold components, services, and modules with a simple right-click.

Angular File Generator Demo

Key Features

  • Accelerate Development: Quickly scaffold components, services, and other schematics directly from the editor.
  • Enforce Project Standards: Ensure consistency with standardized file structures and support for custom templates.
  • Reduce Command-Line Errors: Guided UI minimizes mistakes and forgotten flags inng generate commands.
  • Maintain Focus: Scaffold, code, and test without leaving your development environment.
  • Stay Up-to-Date: Full compatibility with the latest Angular features, including standalone components and signals.

Workflow Comparison: UI vs. CLI

Here's how much simpler it is to create a new component:

The Old Way (CLI)

ng generate component path/to/my-feature

The Fast Way (This Extension)

  1. Right-click a folder in the Explorer.
  2. SelectAngular File Generator: Generate Component With CLI.
  3. Enter thepath/to/my-feature and press Enter.

The extension then creates all necessary files with the correct boilerplate and updates the relevant module automatically.

Table of Contents

Description

Angular File Generator seamlessly integrates the Angular CLI into any VSCode-based editor (including VSCode, VSCodium, WindSurf, Cursor, and others), enabling you to generate files and navigate your Angular project efficiently, without nested menus or manual command-line input.

Key capabilities:

  • Generate all major Angular artifacts (components,services,modules,pipes,guards,interceptors,resolvers,directives,classes,enums,interfaces,tests, andtemplates) with a single click.
  • Run Angular CLI commands (ng generate) directly from the editor.
  • Use custom templates to match your team's standards.
  • Instantly convert JSON blocks to TypeScript interfaces.
  • Explore files, routes, and modules from a dedicated sidebar.
  • Access built-in snippets for Angular 20+ reactivity APIs (signal,computed,effect, etc.).

Compatibility: Supports Angular 9-20+, fully aligned with Angular 20 conventions: suffix omission, dash-case file naming, and standalone components.

Features

File Generation Commands (Click to Expand)

File Generation

TitlePurpose
Angular: Generate ClassCreates a new, generic class definition
Angular: Generate ComponentCreates a new, generic component definition
Angular: Generate DirectiveCreates a new, generic directive definition
Angular: Generate EnumGenerates a new, generic enum definition
Angular: Generate GuardGenerates a new, generic route guard definition
Angular: Generate InterceptorCreates a new, generic interceptor definition
Angular: Generate InterfaceCreates a new, generic interface definition
Angular: Generate ModuleCreates a new, generic NgModule definition
Angular: Generate PipeCreates a new, generic pipe definition
Angular: Generate ResolverGenerates a new, generic resolver definition
Angular: Generate ServiceCreates a new, generic service definition
Angular: Generate TestCreates a new, generic test definition
Angular: Generate TemplateCreates a new file with a template definition
CLI Commands (Click to Expand)

Commands

TitlePurpose
Angular: New ApplicationCreates a new Angular application
Angular: Start ServerBuilds and serves your application, rebuilding on file changes
Angular: VersionOutputs Angular CLI version
Angular: Run TestsRuns unit tests in a project
Angular: Run E2EBuilds and serves an Angular application, then runs end-to-end tests
Angular: Disable AnalyticsDisables analytics gathering and reporting for the user
Angular: Enable AnalyticsEnables analytics gathering and reporting for the user
Angular: Info AnalyticsPrints analytics gathering and reporting configuration in the console
Angular: Prompt AnalyticsPrompts the user to set analytics gathering status interactively
Angular: Clean CacheDeletes persistent disk cache from disk
Angular: Disable CacheDisables persistent disk cache for all projects in the workspace
Angular: Enable CacheEnables disk cache for all projects in the workspace
Angular: Info CachePrints persistent disk cache configuration and statistics in the console
Angular: Generate Component with CLICreates a new, generic component definition using Angular CLI
Angular: Generate Guard with CLICreates a new, generic guard definition using Angular CLI
Angular: Generate Pipe with CLICreates a new, generic pipe definition using Angular CLI
Angular: Generate Service with CLICreates a new, generic service definition using Angular CLI
Angular: Generate EnvironmentsGenerates and configures environment files for a project
Angular: Generate LibraryCreates a new, generic library project in the current workspace
Built-in Snippets (Click to Expand)

Snippets

PrefixPurpose
ng_class_moduleexport class Module {}
ng_class_routing_moduleexport class RoutingModule {}
ng_const_routesexport const routes: Routes = []
ng_class_componentexport class Component {}
ng_class_standalone_componentexport class Component {}
ng_class_serviceexport class Service {}
ng_const_environmentexport const environment = {}
ng_oninitngOnInit {}
ng_on_destroyngOnDestroy {}
ng_unsubscribeprivate unsubscribe: Subscription[] = []
ng_subscribethis.unsubscribe.push(this.subscr);
ng_signalconst mySignal = signal(...)
ng_computedconst myComputed = computed(() => ...)
ng_effecteffect(() => ...)
ng_linked_signalconst myLinkedSignal = linkedSignal(...)
ng_to_signalconst signalFromObservable = toSignal(...)
ng_resourceconst myResource = resource(() => ...)
ng_class_standalone_component_reactivityexport class Component {}
ng_on_destroy_reactivityimplements OnDestroy {}
ng_if@if (condition) {}
ng_if_else@if (condition) {} @else {}
ng_if_else_if@if (condition) {} @else if (condition) {}
ng_else_if@else if (condition) {}
ng_else@else {}
ng_for@for (condition) {}
ng_empty@empty {}
ng_switch@switch (condition) {}
ng_case@case (condition) {}
ng_default@default {}
ng_defer@defer (condition) {}
ng_placeholder@placeholder {}
ng_loading@loading {}
ng_router_outlet<router-outlet></router-outlet>
ng_router_link<a routerLink=""></a>

Main Features

Flat, Descriptive Context Menu

Angular File Generator adds a single entry to the Explorer's context menu in any VSCode-based editor, no nested submenus. From there you can:

  • Generate Component / Service / Module / Pipe / Guard / Interceptor / Resolver / Directive / Class / Enum / Interface / Spec / Template

    • Opens a dialog to enter the name and default flags (e.g.,--style=scss,--standalone if enabled).
    • Internally invokesng generate <artifact> <name> --flags... or uses a built-in boilerplate engine.
  • Generate with CLI → [same list of artifacts]

    • Shows the exact same list but delegates directly tong generate.
    • If your settings haveangular.fileGenerator.omitSuffix: true andtypeSeparator: "-", it generates files using Angular 20 conventions (e.g.,user-profile.ts instead ofuser-profile.component.ts).
  • Generate Custom (Templates)

    • If you defineangular.submenu.templates in your settings, each custom template appears here.
    • Selecting a template prompts you for values like{{ComponentName}},{{entityName}}, or{{style}}, then generates the corresponding files with those placeholders replaced.
  • Transform JSON to TS

    • Select a JSON block in the editor, right-click → "Angular File Generator → Transform JSON to TS." Angular File Generator usesjson-to-ts to generate a TypeScript interface with detected fields and types.

Sidebar "Angular File Generator" Panel

Angular File Generator adds a new icon to VSCode's Activity Bar. Clicking it opens a panel with four lists:

  1. List Files

    • Settings:
      • angular.files.include: which extensions to show (e.g.,["ts"]).
      • angular.files.exclude: glob patterns to hide folders/files (e.g.,"**/node_modules/**").
      • angular.files.watch: which folders or name patterns to group files (e.g., "modules," "components").
      • angular.files.showPath: iftrue, appends the folder path in parentheses (e.g.,layout.module.ts (src/app/...)).
    • Behavior:
      • A TreeView: expand a group (e.g., "Modules: 64") to see its files.
      • Click a file to open it at the correct line.
      • No right-click actions, just click to open.
  2. List Routes

    • Behavior:
      • Shows each routing module (e.g.,app-routing.module.ts) with its routes (path: 'auth',path: '', etc.).
      • Click a route to open that file and jump to its definition.
      • "Refresh" button reloads the list after changes.
      • No right-click, just click.
  3. List Modules

    • Behavior:
      • Lists each*.module.ts file (e.g.,layout.module.ts) with child entries fordeclarations,imports, andexports.
      • Click any entry to open the file and scroll to that section.
      • "Refresh" button updates the list.
      • No right-click, just click.
  4. Feedback

    • Behavior:
      • A simple list: About Us, Report Issues, Rate Us, Support Us.
      • Click an item to open its link in your browser.
      • No right-click, just click.

Configurable Naming Conventions

Angular File Generator offers two naming modes for files and classes:

A. Legacy Mode (Angular 9-19)

"angular.fileGenerator.omitSuffix":false,"angular.fileGenerator.typeSeparator":"."
  • Generates traditional names likemy-component.component.ts,my-service.service.ts, etc.
  • This mode is suitable for projects that maintain legacy naming conventions.

B. Angular 20+ Mode

"angular.fileGenerator.omitSuffix":true,"angular.fileGenerator.typeSeparator":"-"
  • Creates dash-separated filenames without redundant suffixes. Examples:

    • user-profile.ts (instead ofuser-profile.component.ts)
    • auth-service.ts (instead ofauth-service.service.ts)
  • If you also set"angular.components.standalone": true, Angular File Generator generates standalone components that includestandalone: true and importCommonModule.

This flexibility lets you migrate gradually between conventions without reconfiguring every template manually.

Built-in Snippets for Modern Development (Angular 20+)

Although Angular File Generatordoes not include full templates that automatically injectsignal,computed, etc., it provides severalsnippets to accelerate the adoption of Angular's reactivity APIs. Type a prefix and press Tab to expand the snippet:

  1. Signal (ng_signal)

    import{signal}from'@angular/core';constmySignal=signal(initialValue);
  2. Computed (ng_computed)

    import{computed}from'@angular/core';constmyComputed=computed(()=>expression);
  3. Effect (ng_effect)

    import{effect}from'@angular/core';effect(()=>{// reactive logic});
  4. LinkedSignal (ng_linked_signal)

    import{linkedSignal}from'@angular/core';constmyLinkedSignal=linkedSignal(sourceSignal,(v)=>transformation);
  5. ToSignal (ng_to_signal)

    import{toSignal}from'@angular/core/rxjs-interop';constsignalFromObs=toSignal(myObservable,{initialValue:defaultValue});
  6. Resource (ng_resource)

    import{resource}from'@angular/core';constmyResource=resource(()=>fetch('/api/data').then(r=>r.json()));

Note on Custom Templates:To generate files that include specific imports likesignal orcomputed by default, it is recommended to create a custom template under theangular.submenu.templates setting. This allows for full control over the generated boilerplate.

Configuration

Essential Project Configuration

For optimal performance and to align with project conventions, consider adding the following options to your.vscode/settings.json file.

{// 1. Enable/Disable the extension"angular.enable":true,// 2. Standalone components by default"angular.components.standalone":true,"angular.components.style":"scss",// 'css', 'less', 'sass', 'styl'// 3. Naming mode (Legacy vs. Angular 20+)"angular.fileGenerator.omitSuffix":true,// true for Angular 20+ (omit .component.ts, .service.ts, etc.)"angular.fileGenerator.typeSeparator":"-",// '-' for dash-separated; '.' for legacy"angular.fileGenerator.skipFolderConfirmation":false,// true to skip folder-confirmation dialogs// 4. Filters for "List Files""angular.files.include": ["ts"],"angular.files.exclude": ["**/node_modules/**","**/dist/**","**/.*/**"  ],"angular.files.watch": ["modules","components","services"],// folders to scan"angular.files.showPath":true,// show full path in list// 5. Working directory for CLI commands (monorepo)"angular.terminal.cwd":"packages/my-angular-app",// adjust to your structure"angular.fileGenerator.useRootWorkspace":false,// Use the root workspace folder as the current working directory to resolve relative paths// 6. Custom CLI commands"angular.submenu.customCommands": [    {"name":"Feature Module (OnPush + Routing)","command":"ng g m","args":"--routing --flat --change-detection OnPush"    }  ],// 7. Custom templates"angular.submenu.templates": [    {"name":"Corporate Component","description":"Component with header + basic logging","type":"component","template": ["/* Company XYZ - Confidential */","import { Component } from '@angular/core';","import { LoggingService } from 'src/app/shared/logging.service';","@Component({","  selector: 'app-{{entityName}}',","  standalone: true,","  imports: [CommonModule],","  templateUrl: './{{entityName}}.component.html',","  styleUrls: ['./{{entityName}}.component.{{style}}'],","})","export class {{ComponentName}}Component {","  constructor(private logger: LoggingService) {","    this.logger.log('{{ComponentName}} initialized');","  }","}"      ]    }  ]}

Settings Options

SettingDescriptionDefault
angular.enableEnable or disable the extensiontrue
angular.components.standaloneGenerate standalone components by defaulttrue
angular.components.styleDefault style file extension for new components (css,scss, etc.)css
angular.files.includeFile extensions to include in the sidebar["ts"]
angular.files.excludeGlob patterns to exclude from the sidebar["**/node_modules/**", ...]
angular.files.watchFolders (by type) to watch in the sidebar (modules,components,services)["modules","components","services"]
angular.files.showPathShow file paths in the sidebartrue
angular.terminal.cwdAbsolute path for terminal current working directory(none)
angular.fileGenerator.useRootWorkspaceAllow using the root workspace folder to resolve relative paths(none)
angular.submenu.customCommandsList of custom CLI commands to show under a submenu[]
angular.submenu.templatesList of custom file templates for quick generation[]
angular.submenu.activateItemItems (by category) to activate in the submenu{ see example }
angular.fileGenerator.skipFolderConfirmationSkip folder confirmation dialog when generating filesfalse
angular.fileGenerator.omitSuffixOmit file suffixes (e.g.,.component.ts,.service.ts)false
angular.fileGenerator.typeSeparatorSeparator between name and type in filenames (e.g.,name.type.ts)"."

Placeholders in customCommands and templates

You can now use dynamic placeholders{{ComponentName}},{{entityName}}, and{{style}} in yourcustomCommands andcustomTemplates. After selecting a template or custom command:

  1. VS Code will prompt you for each placeholder:

    • ComponentName: must be PascalCase (e.g.UserProfile)
    • entityName: camelCase or kebab-case (e.g.userProfile oruser-profile)
    • style: style extension (e.g.scss,css), default taken from your config
  2. The extension will substitute each{{Key}} with your input before running the command or writing the file.

Example in.vscode/settings.json:

"angular.submenu.customCommands": [  {"name":"Custom Component","command":"ng g c","args":"{{entityName}} --style {{style}} --standalone true --change-detection OnPush"  }],"angular.submenu.templates": [  {"name":"Corporate Component","description":"Component with header + basic logging","type":"component","template": ["import { Component } from '@angular/core';","@Component({","  selector: 'app-{{entityName}}',","  templateUrl: './{{entityName}}.component.html',","  styleUrls: ['./{{entityName}}.component.{{style}}'],","})","export class {{ComponentName}}Component {","  constructor() { }","}"    ]  }]
PlaceholderDescription
{{ComponentName}}Prompts for a PascalCase class name (e.g.User,AuthService).
{{entityName}}Prompts for an entity name in camelCase or kebab-case (e.g.user,user-profile).
{{style}}Uses your configured style (e.g.scss,css) without prompting if defined; else prompts for style extension.

File Naming Without Suffixes

Angular 19 and earlier generated filenames with explicit suffixes:

  • Before (Angular ≤19)

    • ng g c useruser.component.ts (exportsclass UserComponent)
    • ng g s useruser.service.ts (exportsclass UserService)

Angular 20 conventions encourage simpler filenames:

  • Now (Angular 20)

    • ng g c useruser.ts (exportsclass User)
    • ng g s useruser.ts (exportsclass User)

This extension follows this convention by default, generating files without the.component.ts or.service.ts suffixes. To enable this behavior, setangular.fileGenerator.omitSuffix totrue in your.vscode/settings.json.

{"angular.fileGenerator.omitSuffix":true}

This aligns with Angular 20's approach to file naming and simplifies your project structure.

Tip: To restore the old.component.ts /.service.ts suffixes, add the following to yourangular.json:

{"projects": {"your-app": {"schematics": {"@schematics/angular:component": {"type":"component" },"@schematics/angular:directive": {"type":"directive" },"@schematics/angular:service": {"type":"service" },"@schematics/angular:guard": {"typeSeparator":"." },"@schematics/angular:interceptor": {"typeSeparator":"." },"@schematics/angular:module": {"typeSeparator":"." },"@schematics/angular:pipe": {"typeSeparator":"." },"@schematics/angular:resolver": {"typeSeparator":"." }      }    }  }}

Usage

  1. Open an Angular project in your VSCode-based editor (Angular 9 → Angular 20+).

  2. Ensure that yoursettings.json has"angular.enable": true.

  3. In theExplorer, right-click on a folder or file, select"Angular File Generator", and choose an action:

    • Generate a component, service, module, pipe, guard, etc.
    • Transform JSON to TS.
    • Run an Angular CLI command.
    • Use a custom template.
  4. To use theCommand Palette, pressCtrl+Shift+P on Windows/Linux or⌘+Shift+P on macOS, type "Angular File Generator," and pick the desired command.

  5. Tobrowse your code with side panels:

    • Click the Angular File Generator icon in the Activity Bar.
    • Navigate under "List Files," "List Routes," or "List Modules."
    • Use the "Refresh" button after adding or removing files, routes, or modules.
  6. Tocreate custom templates that include imports for signals, computed, etc., editangular.submenu.templates in yoursettings.json following the structure shown above.

Installation

  1. Open your VSCode-based editor (e.g., VSCode, VSCodium, WindSurf, Cursor).
  2. Go to theExtensions view (Ctrl+Shift+X on Windows/Linux or⌘+Shift+X on macOS).
  3. Search for"Angular File Generator" (author: Manuel Gil).
  4. ClickInstall.
  5. (Optional) Clone or download the repository and open the folder in VSCode to test the latest development version.

Resources

Contributing

Angular File Generator is open-source and welcomes community contributions:

  1. Fork theGitHub repository.

  2. Create a new branch:

    git checkout -b feature/your-feature
  3. Make your changes, commit them, and push to your fork.

  4. Submit a Pull Request against themain branch.

Before contributing, please review theContribution Guidelines for coding standards, testing, and commit message conventions. Open an Issue if you find a bug or want to request a new feature.

Code of Conduct

We are committed to providing a friendly, safe, and welcoming environment for all, regardless of gender, sexual orientation, disability, ethnicity, religion, or other personal characteristic. Please review ourCode of Conduct before participating in our community.

Changelog

For a complete list of changes, see theCHANGELOG.md.

Authors

See also the list ofcontributors who participated in this project.

Follow Me

  • GitHub:GitHub followers
  • X (formerly Twitter):X Follow

Other Extensions

  • Auto BarrelAutomatically generates and maintains barrel (index.ts) files for your TypeScript projects.

  • Angular File GeneratorGenerates boilerplate and navigates your Angular (9→20+) project from within the editor, with commands for components, services, directives, modules, pipes, guards, reactive snippets, and JSON2TS transformations.

  • NestJS File GeneratorSimplifies creation of controllers, services, modules, and more for NestJS projects, with custom commands and Swagger snippets.

  • NestJS SnippetsReady-to-use code patterns for creating controllers, services, modules, DTOs, filters, interceptors, and more in NestJS.

  • T3 Stack / NextJS / ReactJS File GeneratorAutomates file creation (components, pages, hooks, API routes, etc.) in T3 Stack (Next.js, React) projects and can start your dev server from VSCode.

  • Drizzle ORM SnippetsCollection of code snippets to speed up Drizzle ORM usage, defines schemas, migrations, and common database operations in TypeScript/JavaScript.

  • CodeIgniter 4 SparkScaffolds controllers, models, migrations, libraries, and CLI commands in CodeIgniter 4 projects using Spark, directly from the editor.

  • CodeIgniter 4 SnippetsSnippets for accelerating development with CodeIgniter 4, including controllers, models, validations, and more.

  • CodeIgniter 4 Shield SnippetsSnippets tailored to CodeIgniter 4 Shield for faster authentication and security-related code.

  • Mustache Template Engine - Snippets & AutocompleteSnippets and autocomplete support for Mustache templates, making HTML templating faster and more reliable.

Recommended Browser Extension

For developers who work with.vsix files for offline installations or distribution, the complementaryOne-Click VSIX extension is recommended, available for both Chrome and Firefox.

One-Click VSIX integrates a direct "Download Extension" button into each VSCode Marketplace page, ensuring the file is saved with the.vsix extension, even if the server provides a.zip archive. This simplifies the process of installing or sharing extensions offline by eliminating the need for manual file renaming.

License

This project is licensed under theMIT License. See theLICENSE file for details.

About

Angular File Generator is a Visual Studio Code extension that allows you to generate Angular files with a few clicks. It is based on the Angular CLI and uses the same schematics as the CLI. It also allows you to generate files from the terminal.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp