Skip to content

feat: Nx 12.4 support with Angular 12 and builder improvements #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28,885 changes: 0 additions & 28,885 deletions package-lock.json

This file was deleted.

33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,37 @@
"help": "nx help",
"doctoc": "doctoc packages/nx/README.md",
"workspace-generator": "nx workspace-generator",
"clean": "npx rimraf node_modules package-lock.json yarn.lock",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"reset.changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
},
"private": true,
"devDependencies": {
"@angular-devkit/architect": "~0.1102.6",
"@angular-devkit/core": "^11.2.6",
"@angular-devkit/schematics": "^11.2.6",
"@nrwl/cli": "12.0.7",
"@nrwl/eslint-plugin-nx": "12.0.7",
"@nrwl/jest": "12.0.7",
"@nrwl/nx-plugin": "12.0.7",
"@nrwl/tao": "12.0.7",
"@nrwl/workspace": "12.0.7",
"@angular-devkit/architect": "^0.1200.0",
"@angular-devkit/core": "^12.0.0",
"@angular-devkit/schematics": "^12.0.0",
"@nrwl/cli": "12.4.0",
"@nrwl/eslint-plugin-nx": "12.4.0",
"@nrwl/jest": "12.4.0",
"@nrwl/nx-plugin": "12.4.0",
"@nrwl/tao": "12.4.0",
"@nrwl/workspace": "12.4.0",
"@types/jest": "26.0.8",
"@types/node": "14.14.33",
"@typescript-eslint/eslint-plugin": "4.19.0",
"@typescript-eslint/parser": "4.19.0",
"@typescript-eslint/eslint-plugin": "^4.3.0",
"@typescript-eslint/parser": "^4.3.0",
"conventional-changelog-cli": "^2.1.1",
"cz-conventional-changelog": "^3.3.0",
"doctoc": "^1.4.0",
"doctoc": "^2.0.0",
"dotenv": "8.2.0",
"eslint": "7.22.0",
"eslint-config-prettier": "8.1.0",
"jest": "26.2.2",
"jest": "27.0.3",
"jsonc-parser": "3.0.0",
"prettier": "2.2.1",
"strip-json-comments": "^3.1.1",
"ts-jest": "26.4.0",
"ts-jest": "27.0.3",
"ts-node": "9.1.1",
"tslint": "6.1.3",
"typescript": "4.1.4"
"typescript": "4.2.4"
}
}
3 changes: 0 additions & 3 deletions packages/nx/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": ["packages/nx/tsconfig.*?.json"]
},
"rules": {}
},
{
Expand Down
98 changes: 93 additions & 5 deletions packages/nx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Getting started](#getting-started)
- [Create a new Nx workspace](#create-a-new-nx-workspace)
- [Install NativeScript plugin](#install-nativescript-plugin)
Expand All @@ -25,9 +24,15 @@
- [`--groupByName`](#--groupbyname)
- [Develop on simulators and devices](#develop-on-simulators-and-devices)
- [Configuration options](#configuration-options)
- [Run with a specific configuration](#run-with-a-specific-configuration)
- [Create a build](#create-a-build)
- [Clean](#clean)
- [Create NativeScript library](#create-nativescript-library)
- [`--groupByName`](#--groupbyname-1)
- [Using NativeScript plugins](#using-nativescript-plugins)
- [Installing NativeScript plugins at app-level](#installing-nativescript-plugins-at-app-level)
- [Installing NativeScript plugins at workspace-level](#installing-nativescript-plugins-at-workspace-level)
- [Known issues](#known-issues)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand All @@ -39,7 +44,7 @@
npx create-nx-workspace@latest --cli=nx --preset=empty

// If you run into any issue with latest Nx workspace version you may want to try the last known stable version with the following:
npx create-nx-workspace@12.2 --cli=nx --preset=empty
npx create-nx-workspace@12.4 --cli=nx --preset=empty
```

### Install NativeScript plugin
Expand Down Expand Up @@ -151,10 +156,39 @@ A custom builder is provided via `@nativescript/nx:build` with the following opt
"type": "boolean",
"default": false,
"description": "Build in production mode using the --env.production flag"
},
"copyTo": {
"type": "string",
"description": "When building, copy the package to this location."
},
"provision": {
"type": "string",
"description": "(iOS Only) When building, use this provision profile name."
},
"aab": {
"type": "boolean",
"default": false,
"description": "(Android Only) When building, create an Android App Bundle (.aab file)."
},
"keyStorePath": {
"type": "string",
"description": "(Android Only) When building, use the keystore file at this location."
},
"keyStorePassword": {
"type": "string",
"description": "(Android Only) When building, use this keystore password."
},
"keyStoreAlias": {
"type": "string",
"description": "(Android Only) When building, use this keystore alias."
},
"keyStoreAliasPassword": {
"type": "string",
"description": "(Android Only) When building, use this keystore alias password."
}
```

The options follow the [NativeScript command line options]().
The options follow the [NativeScript command line option flags](https://docs.nativescript.org/development-workflow.html#run).

Here's an example app config:

Expand Down Expand Up @@ -191,6 +225,10 @@ Here's an example app config:
"platform": "ios"
},
"configurations": {
"build": {
"provision": "AppStore Profile",
"copyTo": "./dist/build.ipa"
},
"prod": {
"combineWithConfig": "build:prod"
}
Expand All @@ -202,6 +240,14 @@ Here's an example app config:
"platform": "android"
},
"configurations": {
"build": {
"aab": true,
"keyStorePath": "./tools/keystore.jks",
"keyStorePassword": "your-password",
"keyStoreAlias": "keystore-alias",
"keyStoreAliasPassword": "keystore-alias-password",
"copyTo": "./dist/build.aab"
},
"prod": {
"combineWithConfig": "build:prod"
}
Expand All @@ -217,20 +263,62 @@ Here's an example app config:
}
```

#### Run with a specific configuration

**Android:**

```sh
npx nx run <app-name>:android:prod
```

**iOS:** (Mac only)

```sh
npx nx run <app-name>:ios:prod
```

#### Create a build

Instead of running the app on a simulator or device you can create a build for the purposes of distribution/release. Various release settings will be needed for iOS and Android which can be passed as additional command line arguments. [See more in the NativeScript docs here](https://docs.nativescript.org/releasing.html#overview). Any additional cli flags as stated in the docs can be passed on the end of the `nx build` command that follows.

The key difference is usage of `nx build` instead of `nx run`.

Build with an environment configuration enabled (for example, with `prod`):

**Android:**

```sh
npx nx run <app-name>:android:prod
npx nx build <app-name>:android:prod
```

You can pass additional NativeScript CLI options as flags on the end of you build command.

* example of building AAB bundle for upload to Google Play:

```
npx nx build <app-name>:android:prod \
--aab \
--key-store-path <path-to-your-keystore> \
--key-store-password <your-key-store-password> \
--key-store-alias <your-alias-name> \
--key-store-alias-password <your-alias-password> \
--copy-to ./dist/build.aab
```

**iOS:** (Mac only)

```sh
npx nx run <app-name>:ios:prod
npx nx build <app-name>:ios:prod
```

As mentioned, you can pass any additional NativeScript CLI options as flags on the end of your nx build command:

* example of building IPA for upload to iOS TestFlight:

```
npx nx build <app-name>:ios:prod \
--provision <provisioning-profile-name> \
--copy-to ./dist/build.ipa
```

#### Clean
Expand Down
5 changes: 2 additions & 3 deletions packages/nx/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ module.exports = {
displayName: 'nx',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
},
'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' },
},
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/packages/nx',
testEnvironment: 'node',
};
16 changes: 7 additions & 9 deletions packages/nx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/nx",
"version": "1.0.4",
"version": "2.0.0",
"description": "NativeScript Plugin for Nx",
"repository": {
"type": "git",
Expand Down Expand Up @@ -29,13 +29,11 @@
"migrations": "./migrations.json"
},
"dependencies": {
"@angular-devkit/architect": "~0.1102.6",
"@angular-devkit/core": "^11.2.6",
"@angular-devkit/schematics": "^11.2.6",
"metro-resolver": "~0.65.0",
"fs-extra": "~9.1.0",
"ignore": "^5.1.8",
"node-fetch": "~2.6.1",
"strip-json-comments": "2.0.1"
"@angular-devkit/architect": "^0.1200.0",
"@angular-devkit/core": "^12.0.0",
"@angular-devkit/schematics": "^12.0.0",
"fs-extra": "^9.1.0",
"ignore": "^5.0.4",
"jsonc-parser": "3.0.0"
}
}
Loading