Skip to content

wellwind/vscode-schematics-snippets

Repository files navigation

Schematics Snippets

Code snippets collection for writing @angular-devkit/schematics

Features

  • Generate schematic file: F1 -> Schematics: Generate A Schematic.
  • Snippets: Use sch-* snippets to generate schematics related codes.
  • Sometimes we might use TypeScript Compiler API, there are ts-* snippets to generate some useful AST (Abstract Syntax Tree) manipulation code.
  • For the full generated code of snippet, see it here.

Generate schematic file

featire: generate schematic file

Snippets

In *.ts

Snippet Name Generated Code Description
sch-default-function code Generate an export function with schematics template
sch-rule code Generate a basic rule of schematics
sch-tree-create code Create a file to the tree
sch-tree-overwrite code Overwrite a file content from the tree
sch-tree-delete code Delete a file from the tree
sch-tree-delete-directory code Delete a directory from the tree
sch-tree-rename code Rename a file from the tree
sch-tree-read code Read a file from the tree
sch-tree-exist code Check a file exist in the tree
sch-import-external-schematic code Import externalSchematic
sch-external-schematics code Run external schematics
sch-import-chain code Import chain rule
sch-chain-rules code Chain schematic rules
sch-import-apply-merge-templates code Import rules to apply and merge templates
sch-apply-merge-templates code Apply and merge templates
sch-read-json-file code Read json file
sch-write-json-file code Write json file
sch-create-json-file code Create json file
sch-import-install-package-task code Import install package task
sch-install-package code Run install package task
sch-set-package-dependencies code Set dependencies to package.json
sch-set-package-dev-dependencies code Set devDependencies to package.json
sch-set-package-scripts code Set script to package.json

In schema.json

Snippet Name Generated Code Description
sch-default-json code schema.json template
sch-property code Add a property to schema.json
sch-property-prompt-input code Add a property to schema.json contains prompt input
sch-property-prompt-yes-no code Add a property to schema.json contains prompt Y/N
sch-property-prompt-selection code Add a property to schema.json contains prompt selection
sch-property-dollar-default code Property $default

In collection.json

Snippet Name Generated Code Description
sch-new-schematic-default code Add a schematic to collection.json by deafult function
sch-new-schematic-function-name code Add a schematic to collection.json by function name
sch-ng-add code Add a schematic of "ng-add" to collection.json

TypeScript Compiler API Snippets

Snippet Name Generated Code Description
ts-import code Import TypeScript Compiler API
ts-string-to-ast code Convert string to AST node
ts-ast-to-code code Convert AST node to code

Release Notes

5.0.0

  • Generate a schematic set by F1 -> Schematics: Generate A Schematic.
  • Add semicolon to single line snippet.

4.0.1

  • Because of some technical problem, now we are in 4.0.1 😜.

2.0.0

  • Now we support snippet in schema.json and collection.json separately.
  • In ver1, we use sch-schema-* and sch-coll-* to identify the snippet type in json file, but now we don't have to, so we remove schema- and coll- prefix.
  • Because it's a breaking change, so let's upgrade to 2.0.0

1.0.0

  • Initially add snippets

LICENSE

MIT

Releases

No releases published

Packages

No packages published