Skip to content

Commit 5952dfe

Browse files
authored
feat: Nx 12.4 support with Angular 12 and builder improvements (#28)
1 parent 5cb1766 commit 5952dfe

32 files changed

+8436
-28981
lines changed

package-lock.json

Lines changed: 0 additions & 28885 deletions
This file was deleted.

package.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,37 @@
2525
"help": "nx help",
2626
"doctoc": "doctoc packages/nx/README.md",
2727
"workspace-generator": "nx workspace-generator",
28+
"clean": "npx rimraf node_modules package-lock.json yarn.lock",
2829
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
2930
"reset.changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
3031
},
3132
"private": true,
3233
"devDependencies": {
33-
"@angular-devkit/architect": "~0.1102.6",
34-
"@angular-devkit/core": "^11.2.6",
35-
"@angular-devkit/schematics": "^11.2.6",
36-
"@nrwl/cli": "12.0.7",
37-
"@nrwl/eslint-plugin-nx": "12.0.7",
38-
"@nrwl/jest": "12.0.7",
39-
"@nrwl/nx-plugin": "12.0.7",
40-
"@nrwl/tao": "12.0.7",
41-
"@nrwl/workspace": "12.0.7",
34+
"@angular-devkit/architect": "^0.1200.0",
35+
"@angular-devkit/core": "^12.0.0",
36+
"@angular-devkit/schematics": "^12.0.0",
37+
"@nrwl/cli": "12.4.0",
38+
"@nrwl/eslint-plugin-nx": "12.4.0",
39+
"@nrwl/jest": "12.4.0",
40+
"@nrwl/nx-plugin": "12.4.0",
41+
"@nrwl/tao": "12.4.0",
42+
"@nrwl/workspace": "12.4.0",
4243
"@types/jest": "26.0.8",
4344
"@types/node": "14.14.33",
44-
"@typescript-eslint/eslint-plugin": "4.19.0",
45-
"@typescript-eslint/parser": "4.19.0",
45+
"@typescript-eslint/eslint-plugin": "^4.3.0",
46+
"@typescript-eslint/parser": "^4.3.0",
4647
"conventional-changelog-cli": "^2.1.1",
4748
"cz-conventional-changelog": "^3.3.0",
48-
"doctoc": "^1.4.0",
49+
"doctoc": "^2.0.0",
4950
"dotenv": "8.2.0",
5051
"eslint": "7.22.0",
5152
"eslint-config-prettier": "8.1.0",
52-
"jest": "26.2.2",
53+
"jest": "27.0.3",
54+
"jsonc-parser": "3.0.0",
5355
"prettier": "2.2.1",
54-
"strip-json-comments": "^3.1.1",
55-
"ts-jest": "26.4.0",
56+
"ts-jest": "27.0.3",
5657
"ts-node": "9.1.1",
5758
"tslint": "6.1.3",
58-
"typescript": "4.1.4"
59+
"typescript": "4.2.4"
5960
}
6061
}

packages/nx/.eslintrc.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
"overrides": [
66
{
77
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8-
"parserOptions": {
9-
"project": ["packages/nx/tsconfig.*?.json"]
10-
},
118
"rules": {}
129
},
1310
{

packages/nx/README.md

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
1717
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
1818

19-
2019
- [Getting started](#getting-started)
2120
- [Create a new Nx workspace](#create-a-new-nx-workspace)
2221
- [Install NativeScript plugin](#install-nativescript-plugin)
@@ -25,9 +24,15 @@
2524
- [`--groupByName`](#--groupbyname)
2625
- [Develop on simulators and devices](#develop-on-simulators-and-devices)
2726
- [Configuration options](#configuration-options)
27+
- [Run with a specific configuration](#run-with-a-specific-configuration)
28+
- [Create a build](#create-a-build)
2829
- [Clean](#clean)
2930
- [Create NativeScript library](#create-nativescript-library)
3031
- [`--groupByName`](#--groupbyname-1)
32+
- [Using NativeScript plugins](#using-nativescript-plugins)
33+
- [Installing NativeScript plugins at app-level](#installing-nativescript-plugins-at-app-level)
34+
- [Installing NativeScript plugins at workspace-level](#installing-nativescript-plugins-at-workspace-level)
35+
- [Known issues](#known-issues)
3136

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

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

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

4550
### Install NativeScript plugin
@@ -151,10 +156,39 @@ A custom builder is provided via `@nativescript/nx:build` with the following opt
151156
"type": "boolean",
152157
"default": false,
153158
"description": "Build in production mode using the --env.production flag"
159+
},
160+
"copyTo": {
161+
"type": "string",
162+
"description": "When building, copy the package to this location."
163+
},
164+
"provision": {
165+
"type": "string",
166+
"description": "(iOS Only) When building, use this provision profile name."
167+
},
168+
"aab": {
169+
"type": "boolean",
170+
"default": false,
171+
"description": "(Android Only) When building, create an Android App Bundle (.aab file)."
172+
},
173+
"keyStorePath": {
174+
"type": "string",
175+
"description": "(Android Only) When building, use the keystore file at this location."
176+
},
177+
"keyStorePassword": {
178+
"type": "string",
179+
"description": "(Android Only) When building, use this keystore password."
180+
},
181+
"keyStoreAlias": {
182+
"type": "string",
183+
"description": "(Android Only) When building, use this keystore alias."
184+
},
185+
"keyStoreAliasPassword": {
186+
"type": "string",
187+
"description": "(Android Only) When building, use this keystore alias password."
154188
}
155189
```
156190

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

159193
Here's an example app config:
160194

@@ -191,6 +225,10 @@ Here's an example app config:
191225
"platform": "ios"
192226
},
193227
"configurations": {
228+
"build": {
229+
"provision": "AppStore Profile",
230+
"copyTo": "./dist/build.ipa"
231+
},
194232
"prod": {
195233
"combineWithConfig": "build:prod"
196234
}
@@ -202,6 +240,14 @@ Here's an example app config:
202240
"platform": "android"
203241
},
204242
"configurations": {
243+
"build": {
244+
"aab": true,
245+
"keyStorePath": "./tools/keystore.jks",
246+
"keyStorePassword": "your-password",
247+
"keyStoreAlias": "keystore-alias",
248+
"keyStoreAliasPassword": "keystore-alias-password",
249+
"copyTo": "./dist/build.aab"
250+
},
205251
"prod": {
206252
"combineWithConfig": "build:prod"
207253
}
@@ -217,20 +263,62 @@ Here's an example app config:
217263
}
218264
```
219265

266+
#### Run with a specific configuration
267+
268+
**Android:**
269+
270+
```sh
271+
npx nx run <app-name>:android:prod
272+
```
273+
274+
**iOS:** (Mac only)
275+
276+
```sh
277+
npx nx run <app-name>:ios:prod
278+
```
279+
220280
#### Create a build
221281

282+
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.
283+
284+
The key difference is usage of `nx build` instead of `nx run`.
285+
222286
Build with an environment configuration enabled (for example, with `prod`):
223287

224288
**Android:**
225289

226290
```sh
227-
npx nx run <app-name>:android:prod
291+
npx nx build <app-name>:android:prod
292+
```
293+
294+
You can pass additional NativeScript CLI options as flags on the end of you build command.
295+
296+
* example of building AAB bundle for upload to Google Play:
297+
298+
```
299+
npx nx build <app-name>:android:prod \
300+
--aab \
301+
--key-store-path <path-to-your-keystore> \
302+
--key-store-password <your-key-store-password> \
303+
--key-store-alias <your-alias-name> \
304+
--key-store-alias-password <your-alias-password> \
305+
--copy-to ./dist/build.aab
228306
```
229307

230308
**iOS:** (Mac only)
231309

232310
```sh
233-
npx nx run <app-name>:ios:prod
311+
npx nx build <app-name>:ios:prod
312+
```
313+
314+
As mentioned, you can pass any additional NativeScript CLI options as flags on the end of your nx build command:
315+
316+
* example of building IPA for upload to iOS TestFlight:
317+
318+
```
319+
npx nx build <app-name>:ios:prod \
320+
--provision <provisioning-profile-name> \
321+
--copy-to ./dist/build.ipa
234322
```
235323

236324
#### Clean

packages/nx/jest.config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ module.exports = {
22
displayName: 'nx',
33
preset: '../../jest.preset.js',
44
globals: {
5-
'ts-jest': {
6-
tsConfig: '<rootDir>/tsconfig.spec.json',
7-
},
5+
'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' },
86
},
97
transform: {
108
'^.+\\.[tj]sx?$': 'ts-jest',
119
},
1210
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
1311
coverageDirectory: '../../coverage/packages/nx',
12+
testEnvironment: 'node',
1413
};

packages/nx/package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/nx",
3-
"version": "1.0.4",
3+
"version": "2.0.0",
44
"description": "NativeScript Plugin for Nx",
55
"repository": {
66
"type": "git",
@@ -29,13 +29,11 @@
2929
"migrations": "./migrations.json"
3030
},
3131
"dependencies": {
32-
"@angular-devkit/architect": "~0.1102.6",
33-
"@angular-devkit/core": "^11.2.6",
34-
"@angular-devkit/schematics": "^11.2.6",
35-
"metro-resolver": "~0.65.0",
36-
"fs-extra": "~9.1.0",
37-
"ignore": "^5.1.8",
38-
"node-fetch": "~2.6.1",
39-
"strip-json-comments": "2.0.1"
32+
"@angular-devkit/architect": "^0.1200.0",
33+
"@angular-devkit/core": "^12.0.0",
34+
"@angular-devkit/schematics": "^12.0.0",
35+
"fs-extra": "^9.1.0",
36+
"ignore": "^5.0.4",
37+
"jsonc-parser": "3.0.0"
4038
}
4139
}

0 commit comments

Comments
 (0)