# @uqt/ng-node

> Angular CLI builders for node applications

Latest version **2.0.0** (published 2021-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @uqt/ng-node
pnpm add @uqt/ng-node
yarn add @uqt/ng-node
bun add @uqt/ng-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2021-01-03 |
| First published | 2019-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 21.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jonathon Adams |
| Maintainers | uqt |
| Keywords | Angular, ng, Builder, node |

## Links

- npm: https://www.npmjs.com/package/@uqt/ng-node
- Repository: https://github.com/jonathonadams/ng-node
- Homepage: https://github.com/jonathonadams/ng-node#readme
- Issues: https://github.com/jonathonadams/ng-node/issues
- npm.io page: https://npm.io/package/@uqt/ng-node

## Dependencies (6)

- [glob](https://npm.io/package/glob.md) ^7.1.6
- [dotenv](https://npm.io/package/dotenv.md) ^8.1.0
- [cp-file](https://npm.io/package/cp-file.md) ^9.0.0
- [cross-env](https://npm.io/package/cross-env.md) ^7.0.3
- [tree-kill](https://npm.io/package/tree-kill.md) ^1.2.2
- [@uqt/ts-path-replace](https://npm.io/package/@uqt/ts-path-replace.md) ^1.1.1

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2021-01-03
- 1.0.2 — 2020-07-22
- 1.0.1 — 2020-07-21
- 1.0.0 — 2020-07-19
- 0.0.6 — 2020-01-23
- 0.0.5 — 2019-10-20
- 0.0.4 — 2019-10-20
- 0.0.3 — 2019-10-15
- 0.0.2 — 2019-10-10

## README

# @uqt/ng-node

Angular CLI Builder for building and executing node applications.

## Why this package

With the stable release of Angular CLI Builders API (angular v8), the Angular CLI can be extended to run custom build targets.

It is common in monorepo design have both frontend and backend applications in the same repository, sharing common code. Most builders tend to use WebPack to build server applications as well as not catering for other non JavaScrip files (i.e. `.graphql` schema files).

Check out [Nrwl](https://nrwl.io/) for more info on monorepos and the amazing tools they provide to support them

## Angular CLI Builders

Two builders are provided with this package. A `build` and `execute` builder.

The `build` builder will:

1. Compile your TypeScript code
2. Re-write and replace the TypeScrip alias paths (`@some/alias`) to relative paths(`../../some/relative/paths`) using [@uqt/ts-path-replace](https://github.com/unquenchablethyrst/ts-paths-replace)
3. Copy all non TypeScript (.ts) files from the project `rooDir` to the `outDir`
4. The builder will exit once steps 1 - 3 complete.

The `execute` builder will:

1. Compile your TypeScript code
2. Re-write and replace the TypeScrip alias paths (`@some/alias`) to relative paths(`../../some/relative/paths`) using [@uqt/ts-path-replace](https://github.com/unquenchablethyrst/ts-paths-replace)
3. Copy all non TypeScript (.ts) files from the project `rooDir` to the `outDir`
4. Run your application
5. Watch for changes in the source files and repeat the steps 1 - 4 on each change

## Installation

```bash
npm install --save-dev @uqt/ng-node
```

## Usage

To use the custom builders, configure your `angular.json` like such.

```JavaScript
// angular.json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  ...
  "projects":{
    ...
    "<PROJECT_NAME>": {
      ...
      "architect": {
        "build": {
          "builder": "@uqt/ng-node:build", // Use the 'build' target when building
          "options": {
            "tsConfig": "apps/servers/api/tsconfig.app.json"
            "outputPath": "dist/api",
            "src": "apps/servers/api/src",
          }
        },
        "serve": {
          "builder": "@uqt/ng-node:execute", // Use the 'execute' target when serving as the serve builder
          "options": {
            "tsConfig": "apps/servers/api/tsconfig.app.json",
            "outputPath": "dist/api",
            "src": "apps/servers/api/src",
            "main": "main.js",
            "envPath": "apps/servers/api/.env" // Optional path to environment variables
          }
        }
      }
    }
  }
}
```

Then run the commands with the Angular CLI as you normally would.

```bash
# Build once can complete
ng build <PROJECT_NAME>

# Build, run the application and watch for changes in the output and recompile
ng serve <PROJECT_NAME>
```

## API Documentation

**Options** \<Object\>

| Option         | Builder         | Description                                                                |
| -------------- | --------------- | -------------------------------------------------------------------------- |
| **tsConfig**   | Build / Execute | Path to the json config file to process **Required**                       |
| **outputPath** | Build / Execute | Path to the output directory of the project **Required**                   |
| **src**        | Build / Execute | Path to the src directory of the project **Required**                      |
| **main**       | Execute         | The main entry point to the application (the file to execute) **Required** |
| **envPath**    | Execute         | Optional path to an environment variable file **Optional**                 |

## Example

For an example of using these builders in a code sharing monorepo that includes a frontend written in Angular and a backend written in [Koa](https://koajs.com/) that includes [GraphQL](https://graphql.org/), please see [zero-to-production.dev](https://zero-to-production.dev)

## Versioning

The package follows [semver](https://semver.org/) versioning and releases are automated by [semantic release](https://www.npmjs.com/package/semantic-release)

## Contributing

Contributions and PR's are welcome!

### Commit Message Guidelines

https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit

---
_Source: https://npm.io/package/@uqt/ng-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
