Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/DSI-HUG/ngx-schematics-utilities

πŸš€ Useful utilities for Angular Schematics
https://github.com/DSI-HUG/ngx-schematics-utilities

angular angular-cli angular-devkit ast blueprints code-generation devkit helpers scaffolding schematics sdk template tooling tools typescript utilities utils

Last synced: 2 months ago
JSON representation

πŸš€ Useful utilities for Angular Schematics

Awesome Lists containing this project

README

        


@hug/ngx-schematics-utilities





hug-logo




Useful utilities for Angular Schematics





npm version


npm donwloads


license GPLv3


docs-site



build status


PRs welcome


#### Schematics

> Schematics are generators that transform an existing filesystem.

> They can create files, refactor existing files, or move files around.

[More info][schematics]

## Getting started

This library provide a large set of utilities that can be used while developing a schematic for Angular.

πŸ‘‰ Learn about it on the πŸ“š [docs site][docs-site].

#### Example

![preview](preview.gif "Preview")

```ts
export default (options: MySchematicOptions): Rule =>
schematic('my-schematic', [
modifyJsonFile('tsconfig.json', ['compilerOptions', 'strict'], true),
rule((tree, context): Rule => {
... return renameFile('old-file', 'new-file');
... return chain([]);
... return noop();
}),

workspace()
.spawn('ng', ['add', '@angular/material', '--skip-confirmation'])
.addPackageJsonDevDependencies(['eslint'])
.packageInstallTask()
.logInfo('Doing some cool stuff')
.isAngularVersion('<= 11', (): Rule => {
...
})
.toRule(),

application(options.project)
.deployFiles(options)
.addProviderToBootstrapApplication('__MAIN__', 'provideAnimations()', '@angular/platform-browser/animations'),
.addImportToFile('__SRC__/file.ts', 'environment', './environments/environment')
.deleteFiles(['karma.conf.js'])
.rule(({ project }: ChainableApplicationContext) => {
return createOrUpdateFile(project.pathFromRoot('README.md'), project.name);
})
.toRule(),

library(options.project)
.downloadFile('https://my-cdn.com/icons/icon.png', '__SRC__/assets/icons/icon.png')
.toRule(),

runAtEnd(logAction('Have a look at `./package.json` file and make modifications as needed.'))

], options);
```

## Development

See the [developer docs][developer].

## Contributing

#### > Want to Help?

Want to file a bug, contribute some code or improve documentation? Excellent!

But please read up first on the guidelines for [contributing][contributing], and learn about submission process, coding rules and more.

#### > Code of Conduct

Please read and follow the [Code of Conduct][codeofconduct], and help us keep this project open and inclusive.

## Credits

Copyright (C) 2021 [HUG - Hôpitaux Universitaires Genève][dsi-hug]

[![love@hug](https://img.shields.io/badge/@hug-%E2%9D%A4%EF%B8%8Flove-magenta)][dsi-hug]

[developer]: https://github.com/dsi-hug/ngx-schematics-utilities/blob/main/DEVELOPER.md
[contributing]: https://github.com/dsi-hug/ngx-schematics-utilities/blob/main/CONTRIBUTING.md
[codeofconduct]: https://github.com/dsi-hug/ngx-schematics-utilities/blob/main/CODE_OF_CONDUCT.md
[dsi-hug]: https://github.com/dsi-hug
[schematics]: https://angular.io/guide/schematics
[docs-site]: https://dsi-hug.github.io/ngx-schematics-utilities