Code snippets collection for writing @angular-devkit/schematics
- 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.
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 |
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 |
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 |
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 |
- Generate a schematic set by
F1
->Schematics: Generate A Schematic
. - Add semicolon to single line snippet.
- Because of some technical problem, now we are in 4.0.1 😜.
- Now we support snippet in
schema.json
andcollection.json
separately. - In ver1, we use
sch-schema-*
andsch-coll-*
to identify the snippet type in json file, but now we don't have to, so we removeschema-
andcoll-
prefix. - Because it's a breaking change, so let's upgrade to
2.0.0
- Initially add snippets
MIT