@razroo/razzle
v1.0.2
Published
Razzle is an extensible, easy to understand, easy contribute, easy to use Codemod library.
Downloads
1
Readme
Razzle is an extensible, easy to understand, easy to contribute, easy to use Codemod library. Razzle-dazzle your codebase like you've never before.
Novelty behind Razzle library
Easy To Understand
What the Razzle library does that is unique, is that it creates a unified interface across different programming languages. It uses a simple object to make modifications. e.g.
Typescript
{
"import": '{ NgModule }',
"path": '@angular/core'
}
SCSS
{
"import": '',
"path": 'libs/common/styles/razroo-styles.scss'
}
So your engineers can understand how it works for one programming language and use the same syntax for a different programming language.
Easy To Contribute
Razzle uses a tree of switch case statements to determine type of codemod to use. Simply specify programming language e.g. angular
and fileType e.g. .ts
and Codemod will take care of the rest.
Extensible
If you want to add your own custom codemods, or add your own, you can simply plug and play to the Razroo codemod library.
Assumption Made
Razzle is always used in an editing circumstance. There is no need to speicify that file is being edited.
Benefits of such
- This will be consumer facing. By allowing a singular object, we can simplify the frontend shown to users in the content management system.
- Developers don't have to dig into specifics for each programming language. They can simply keep an eye on the top level interface.
Further reading via Razroo blog(soon to be it's own documentation site)
blog.razroo.com
APIS Available
Typescript
import
editImport
classDeclaration
classMethod
addNgModuleImport
addNgModuleProvider
addNgModuleImportToSpec
addToVariableObject
addConstructorMethod
{
nodeType: 'addConstructorMethod',
codeBlock: 'userService',
type: 'UserService'
}
- addVariableDeclarationStatement
{
nodeType: 'addVariableDeclarationStatement',
codeBlock: 'gtag',
type: 'Function'
}
JSON
editJson
addJsonKeyValue
SCSS
addScssBlock
import
Angular HTML + HTML
editHtmlTag
{
"nodeType": "editHtmlTag",
"codeBlock": "matSort",
"tagNameToModify": "mat-table"
}
addSiblingHtml
{
"nodeType": "addSiblingHtml",
"codeBlock": "<script async src=\"https://www.googletagmanager.com/gtag/js?id=G-YOUR-GOOGLE-ID\"></script>",
"tagNameToInsert": "script",
"siblingTagName": "link"
},
insertIntoHtmlTag
{
"nodeType": "insertIntoHtmlTag",
"codeBlock": "<div class=\"Toolbar__Icons\"><fa-icon [icon]=\"faBell\" aria-hidden=\"false\" aria-label=\"Notification Icon\"></fa-icon> <fa-icon [icon]=\"faQuestionCircle\" aria-hidden=\"false\" aria-label=\"Question Icon\"></fa-icon> <fa-icon [icon]=\"faUserCircle\" aria-hidden=\"false\" aria-label=\"Account Icon\"></fa-icon></div>",
"tagNameToInsertInto": "mat-toolbar"
}