Home

Awesome

<h1 align="center"> @hug/ngx-schematics-utilities </h1> <p align="center"> <br/> <a href="https://www.hug.ch"> <img src="https://cdn.hug.ch/svgs/hug/hug-logo-horizontal.svg" alt="hug-logo" height="54px" /> </a> <br/><br/> <i>Useful utilities for Angular Schematics</i> <br/><br/> </p> <p align="center"> <a href="https://www.npmjs.com/package/@hug/ngx-schematics-utilities"> <img src="https://img.shields.io/npm/v/@hug/ngx-schematics-utilities.svg?color=blue&logo=npm" alt="npm version" /></a> <a href="https://npmcharts.com/compare/@hug/ngx-schematics-utilities?minimal=true"> <img src="https://img.shields.io/npm/dw/@hug/ngx-schematics-utilities.svg?color=blue&logo=npm" alt="npm donwloads" /></a> <a href="https://github.com/dsi-hug/ngx-schematics-utilities/blob/main/LICENSE"> <img src="https://img.shields.io/badge/license-GPLv3-ff69b4.svg" alt="license GPLv3" /></a> <a href="https://dsi-hug.github.io/ngx-schematics-utilities"> <img src="https://img.shields.io/badge/docs-site-blue" alt="docs-site" /></a> </p> <p align="center"> <a href="https://github.com/dsi-hug/ngx-schematics-utilities/actions/workflows/ci_tests.yml"> <img src="https://github.com/dsi-hug/ngx-schematics-utilities/actions/workflows/ci_tests.yml/badge.svg" alt="build status" /></a> <a href="https://github.com/dsi-hug/ngx-schematics-utilities/blob/main/CONTRIBUTING.md#-submitting-a-pull-request-pr"> <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs welcome" /></a> </p> <hr/>

Schematics

Schematics are generators that transform an existing filesystem.<br /> They can create files, refactor existing files, or move files around.

More info

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.

Example

preview

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.

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, and learn about submission process, coding rules and more.

> Code of Conduct

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

Credits

Copyright (C) 2021 HUG - Hôpitaux Universitaires Genève

love@hug