@nrwl/cli
Advanced tools
Comparing version 8.2.2-beta.1 to 8.3.0-beta.1
#!/usr/bin/env node | ||
'use strict'; | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
try { | ||
process.title = | ||
'nx ' + | ||
Array.from(process.argv) | ||
.slice(2) | ||
.join(' '); | ||
} catch (_) { | ||
process.title = 'nx'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fs_1 = require("fs"); | ||
var path = require("path"); | ||
function isLocalProject(dir) { | ||
if (path.dirname(dir) === dir) | ||
return false; | ||
var configPath = path.join(dir, 'angular.json'); | ||
if (fileExists(configPath)) { | ||
return true; | ||
} | ||
else { | ||
return isLocalProject(path.dirname(dir)); | ||
} | ||
} | ||
const nxPath = pathInner(process.cwd()); | ||
if (nxPath) { | ||
require(nxPath); | ||
} else { | ||
console.error('Could not find nx installed locally'); | ||
process.exit(1); | ||
function findLocalNx(dir) { | ||
if (path.dirname(dir) === dir) | ||
return null; | ||
var nxPath = path.join(dir, 'node_modules', '.bin', 'nx'); | ||
if (fileExists(nxPath)) { | ||
return nxPath; | ||
} | ||
else { | ||
return findLocalNx(path.dirname(dir)); | ||
} | ||
} | ||
function pathInner(dir) { | ||
if (path.dirname(dir) === dir) return null; | ||
const nxPath = path.join(dir, 'node_modules', '.bin', 'nx'); | ||
if (fileExists(nxPath)) { | ||
return nxPath; | ||
} else { | ||
return pathInner(path.dirname(dir)); | ||
} | ||
} | ||
function fileExists(filePath) { | ||
try { | ||
return fs.statSync(filePath).isFile(); | ||
} catch (err) { | ||
return false; | ||
} | ||
try { | ||
return fs_1.statSync(filePath).isFile(); | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
var inLocal = isLocalProject(__dirname); | ||
if (inLocal) { | ||
/** | ||
* The commandsObject is a Yargs object declared in `nx-commands.ts`, | ||
* It is exposed and bootstrapped here to provide CLI features. | ||
*/ | ||
var w = require('@nrwl/workspace'); | ||
if (w.supportedNxCommands.includes(process.argv[2])) { | ||
// The commandsObject is a Yargs object declared in `nx-commands.ts`, | ||
// It is exposed and bootstrapped here to provide CLI features. | ||
w.commandsObject.argv; | ||
} | ||
else { | ||
require(w.closestCli(__dirname)); | ||
} | ||
} | ||
else { | ||
require(findLocalNx(process.cwd())); | ||
} |
{ | ||
"name": "@nrwl/cli", | ||
"version": "8.2.2-beta.1", | ||
"version": "8.3.0-beta.1", | ||
"description": "", | ||
@@ -10,8 +10,11 @@ "repository": { | ||
"keywords": [ | ||
"RxJS", | ||
"Monorepo", | ||
"Angular", | ||
"Workspace", | ||
"NgRx", | ||
"Schematics", | ||
"Angular CLI" | ||
"React", | ||
"Web", | ||
"Node", | ||
"Nest", | ||
"Jest", | ||
"Cypress", | ||
"CLI" | ||
], | ||
@@ -18,0 +21,0 @@ "bin": { |
127
README.md
@@ -6,5 +6,4 @@ <p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/nx-logo.png" width="450"></p> | ||
[![Build Status](https://travis-ci.org/nrwl/nx.svg?branch=master)](https://travis-ci.org/nrwl/nx) | ||
[![License](https://img.shields.io/npm/l/@nrwl/schematics.svg?style=flat-square)]() | ||
[![NPM Version](https://badge.fury.io/js/%40nrwl%2Fnx.svg)](https://www.npmjs.com/@nrwl/schematics) | ||
[![NPM Downloads](https://img.shields.io/npm/dt/@nrwl/schematics.svg?style=flat-square)](https://www.npmjs.com/@nrwl/schematics) | ||
[![License](https://img.shields.io/npm/l/@nrwl/workspace.svg?style=flat-square)]() | ||
[![NPM Version](https://badge.fury.io/js/%40nrwl%2Fworkspace.svg)](https://www.npmjs.com/@nrwl/workspace) | ||
[![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]() | ||
@@ -31,3 +30,3 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
π **Nx is a set of Angular CLI power-ups for modern development.** | ||
π **Extensible Dev Tools for Monorepos.** | ||
@@ -38,24 +37,12 @@ ## Nx Helps You | ||
Using Nx, you can add Cypress, Jest, Prettier, and Nest into your dev workflow. Nx sets up these tools and allows you to use them seamlessly. Nx fully integrates with the other modern tools you already use and love. | ||
Using Nx, you can add TypeScript, Cypress, Jest, Prettier, and Nest into your dev workflow. Nx sets up these tools and allows you to use them seamlessly. Nx fully integrates with the other modern tools you already use and love. | ||
### Build Full-Stack Applications | ||
With Nx, you can build full-stack applications using Angular and Node.js frameworks such as Nest and Express. You can share code between the frontend and the backend. And you can use the familiar `ng build/test/serve` commands to power whole dev experience. | ||
With Nx, you can build full-stack applications using modern frameworks. You can share code between the frontend and the backend. And you can use the same `build/test/serve` commands throughout the whole dev experience. | ||
### Develop Like Google | ||
### Develop like Google, Facebook, and Microsoft | ||
With Nx, you can develop multiple full-stack applications holistically and share code between them all in the same workspace. Nx provides advanced tools which help you scale your enterprise development. Nx helps enforce your organizationβs standards and community best practices. | ||
With Nx, you can develop multiple full-stack applications holistically and share code between them all in the same workspace. Nx provides advanced tools which help you scale your enterprise development. Nx also helps enforce your organizationβs standards and community best practices. | ||
## A la carte | ||
Most importantly, you can use these power-ups a la carte. Just want to build a single Angular application using Cypress? Nx is still an excellent choice for that. | ||
## Does it replace Angular CLI? | ||
Nx **is not** a replacement for Angular CLI. **An Nx workspace is an Angular CLI workspace.** | ||
- You run same `ng build`, `ng serve` commands. | ||
- You configure your projects in `angular.json`. | ||
- Anything you can do in a standard Angular CLI project, you can also do in an Nx workspace. | ||
# Getting Started | ||
@@ -83,8 +70,10 @@ | ||
## Adding Nx to an Existing Angular CLI workspace | ||
If it's your first Nx project, the command will recommend you to install `@nrwl/cli` globally, so you can invoke `nx` directly without going through yarn or npm. | ||
If you already have a regular Angular CLI project, you can add Nx power-ups by running: | ||
### Adding Nx to an Existing Angular CLI workspace | ||
If you are an Angular user, you can also add Nx to your existing Angular CLI project by running: | ||
```bash | ||
ng add @nrwl/schematics | ||
ng add @nrwl/workspace | ||
``` | ||
@@ -94,52 +83,53 @@ | ||
Unlike the CLI, an Nx workspace starts blank. There are no applications to build, serve, and test. To create one run: | ||
By default, an Nx workspace starts blank. There are no applications to build, serve, and test. To create one, you need to add capabilities to the workspace. | ||
**To add an Angular app, run:** | ||
```bash | ||
ng g application myapp | ||
yarn add @nrwl/angular | ||
nx g @nrwl/angular:app myapp # or just "nx g myapp" | ||
``` | ||
The result will look like this: | ||
```bash | ||
npm install --save-dev @nrwl/angular | ||
nx g @nrwl/angular:app myapp # or just "nx g myapp" | ||
``` | ||
**To add a React app, run:** | ||
```bash | ||
yarn add @nrwl/react | ||
nx g @nrwl/react:app myapp # or just "nx g myapp" | ||
``` | ||
```bash | ||
npm install --save-dev @nrwl/react | ||
nx g @nrwl/react:app myapp # or just "nx g myapp" | ||
``` | ||
**To add a web components app, run:** | ||
```bash | ||
yarn add @nrwl/web | ||
nx g @nrwl/web:app myapp # or just "nx g myapp" | ||
``` | ||
```bash | ||
npm install --save-dev @nrwl/web | ||
nx g @nrwl/web:app myapp # or just "nx g myapp" | ||
``` | ||
If `nx g` fails, use: `yarn nx g @nrwl/web:app myapp` or `npm run nx -- g @nrwl/web:app myapp`. | ||
Regardless of what framework you chose, the resulting file tree will look like this: | ||
```treeview | ||
<workspace name>/ | ||
βββ README.md | ||
βββ angular.json | ||
βββ apps/ | ||
βΒ Β βββ myapp/ | ||
βΒ Β βΒ Β βββ browserslist | ||
βΒ Β βΒ Β βββ jest.conf.js | ||
βΒ Β βΒ Β βββ src/ | ||
βΒ Β βΒ Β βΒ Β βββ app/ | ||
βΒ Β βΒ Β βΒ Β βββ assets/ | ||
βΒ Β βΒ Β βΒ Β βββ environments/ | ||
βΒ Β βΒ Β βΒ Β βββ favicon.ico | ||
βΒ Β βΒ Β βΒ Β βββ index.html | ||
βΒ Β βΒ Β βΒ Β βββ main.ts | ||
βΒ Β βΒ Β βΒ Β βββ polyfills.ts | ||
βΒ Β βΒ Β βΒ Β βββ styles.scss | ||
βΒ Β βΒ Β βΒ Β βββ test.ts | ||
βΒ Β βΒ Β βββ tsconfig.app.json | ||
βΒ Β βΒ Β βββ tsconfig.json | ||
βΒ Β βΒ Β βββ tsconfig.spec.json | ||
βΒ Β βΒ Β βββ tslint.json | ||
βΒ Β βββ myapp-e2e/ | ||
βΒ Β Β Β βββ cypress.json | ||
βΒ Β Β Β βββ src/ | ||
βΒ Β Β Β βΒ Β βββ fixtures/ | ||
βΒ Β Β Β βΒ Β βΒ Β βββ example.json | ||
βΒ Β Β Β βΒ Β βββ integration/ | ||
βΒ Β Β Β βΒ Β βΒ Β βββ app.spec.ts | ||
βΒ Β Β Β βΒ Β βββ plugins/ | ||
βΒ Β Β Β βΒ Β βΒ Β βββ index.ts | ||
βΒ Β Β Β βΒ Β βββ support/ | ||
βΒ Β Β Β βΒ Β Β Β βββ app.po.ts | ||
βΒ Β Β Β βΒ Β Β Β βββ commands.ts | ||
βΒ Β Β Β βΒ Β Β Β βββ index.ts | ||
βΒ Β Β Β βββ tsconfig.e2e.json | ||
βΒ Β Β Β βββ tsconfig.json | ||
βΒ Β Β Β βββ tslint.json | ||
βββ libs/ | ||
βββ tools/ | ||
βββ nx.json | ||
βββ package.json | ||
βββ tools/ | ||
βββ tsconfig.json | ||
@@ -149,8 +139,10 @@ βββ tslint.json | ||
All the files that the CLI would have in a new project are still here, just in a different folder structure which makes it easier to create more applications and libraries in the future. | ||
## Serving Application | ||
Run `ng serve myapp` to serve the newly generated application! | ||
- Run `nx serve myapp` to serve the newly generated application! | ||
- Run `nx test myapp` to test it. | ||
- Run `nx e2e myapp-e2e` to run e2e tests for it. | ||
Angular users can also run `ng g/serve/test/e2e`. | ||
You are good to go! | ||
@@ -160,2 +152,4 @@ | ||
<p align="center"><a href="https://www.youtube.com/watch?v=mVKMse-gFBI" target="_blank"><img src="https://raw.githubusercontent.com/nrwl/nx/master/nx-video-img.png" width="450"></p></a> | ||
### Documentation | ||
@@ -168,3 +162,3 @@ | ||
- [Angular Enterprise Monorepo Patterns](https://go.nrwl.io/angular-enterprise-monorepo-patterns-new-book?utm_campaign=Book%3A%20Monorepo%20Patterns%2C%20Jan%202019&utm_source=Github&utm_medium=Banner%20Ad) | ||
- [Enterprise Monorepo Patterns](https://go.nrwl.io/angular-enterprise-monorepo-patterns-new-book?utm_campaign=Book%3A%20Monorepo%20Patterns%2C%20Jan%202019&utm_source=Github&utm_medium=Banner%20Ad) | ||
@@ -183,7 +177,2 @@ ### Videos | ||
### Podcasts and Shows | ||
- [ngAir 140: Nx for Enterprise Angular Development](https://www.youtube.com/watch?v=qYNiOKDno_I) | ||
- [ngHouston: NX Demo](https://www.youtube.com/watch?v=E_UlU2Yv4G0) | ||
## Misc | ||
@@ -190,0 +179,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
5
56
9962
184
3