Skip to content

Update plugin for latest NX, refactor, implement prompts, shorthands #57

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 23 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"nx": "nx",
"start": "nx serve",
"build": "nx build nx",
"build": "nx prepare nx",
"test": "nx run-many --target=test --all --parallel",
"lint": "nx workspace-lint && nx lint",
"e2e": "nx e2e",
Expand Down Expand Up @@ -46,13 +46,14 @@
"@types/jest": "29.5.13",
"@types/node": "^20.0.0",
"@types/plist": "^3.0.2",
"@types/xml2js": "^0.4.9",
"conventional-changelog-cli": "^5.0.0",
"cz-conventional-changelog": "^3.3.0",
"doctoc": "^2.0.0",
"dotenv": "~16.4.0",
"enquirer": "^2.4.1",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"fast-xml-parser": "^4.5.0",
"fs-extra": "^11.2.0",
"jest": "29.7.0",
"nx": "20.0.3",
Expand All @@ -62,8 +63,8 @@
"ts-jest": "29.2.5",
"ts-node": "10.9.2",
"tslib": "^2.8.0",
"typescript": "^5.6.0",
"xml2js": "^0.6.2"
"typescript": "^5.6.0"
},
"dependencies": {}
}

117 changes: 72 additions & 45 deletions packages/nx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,27 @@ Here's an example app config:
"executor": "@nativescript/nx:build",
"options": {
"noHmr": true,
"production": true,
"uglify": true,
"forDevice": true,
"release": true,
"forDevice": true
"android": {
"copyTo": "./dist/app.apk",
"keyStorePath": "/path/to/android.keystore",
"keyStoreAlias": "app",
"keyStorePassword": "pass",
"keyStoreAliasPassword": "pass"
},
"ios": {
"copyTo": "./dist/app.ipa"
}
},
"configurations": {
"prod": {
"production": {
"production": true,
"release": true,
"android": {
"keyStorePassword": "productionpw"
},
"fileReplacements": [
{
"replace": "./src/environments/environment.ts",
Expand All @@ -262,56 +276,69 @@ Here's an example app config:
}
}
},
"ios": {
"executor": "@nativescript/nx:build",
"debug": {
"executor": "@nativescript/nx:debug",
"options": {
"platform": "ios"
"noHmr": true,
"uglify": false,
"release": false,
"forDevice": false,
"prepare": false
},
"configurations": {
"build": {
"provision": "AppStore Profile",
"copyTo": "./dist/build.ipa"
},
"prod": {
"combineWithConfig": "build:prod"
"fileReplacements": [
{
"replace": "./src/environments/environment.ts",
"with": "./src/environments/environment.prod.ts"
}
]
}
}
},
"android": {
"executor": "@nativescript/nx:build",
"prepare": {
"executor": "@nativescript/nx:prepare",
"options": {
"platform": "android"
"noHmr": true,
"production": true,
"uglify": true,
"release": true,
"forDevice": true,
"prepare": true
},
"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"
"fileReplacements": [
{
"replace": "./src/environments/environment.ts",
"with": "./src/environments/environment.prod.ts"
}
]
}
}
},
"test": {
"executor": "@nativescript/nx:test",
"outputs": ["coverage/apps/nativescript-mobile"],
"clean": {
"executor": "@nativescript/nx:clean",
"options": {}
},
"lint": {
"executor": "@nx/linter:eslint",
"options": {
"coverage": false
},
"configurations": {
"android": {},
"ios": {}
"lintFilePatterns": [
"apps/nativescript-app/**/*.ts",
"apps/nativescript-app/src/**/*.html"
]
}
},
"clean": {
"executor": "@nativescript/nx:build",
"test": {
"executor": "@nativescript/nx:test",
"outputs": [
"coverage/apps/nativescript-app"
],
"options": {
"clean": true
}
"coverage": true
},
"configurations": {}
}
}
}
Expand All @@ -322,33 +349,33 @@ Here's an example app config:
**Android:**

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

**iOS:** (Mac only)

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

#### Run tests

**Android:**

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

**iOS:** (Mac only)

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

You can generate coverage reports by using the flag with iOS or Android, for example:

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

You can also set this option in the config, for example:
Expand Down Expand Up @@ -380,15 +407,15 @@ Build with an environment configuration enabled (for example, with `prod`):
**Android:**

```sh
npx nx run <app-name>:build:prod --platform=android
npx nx build <app-name> android --c=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 run <app-name>:build:prod --platform=android \
npx nx build <app-name> android --c=prod \
--aab \
--key-store-path=<path-to-your-keystore> \
--key-store-password=<your-key-store-password> \
Expand All @@ -400,15 +427,15 @@ npx nx run <app-name>:build:prod --platform=android \
**iOS:** (Mac only)

```sh
npx nx run <app-name>:build:prod --platform=ios
npx nx build <app-name> iod --c=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 run <app-name>:build:prod --platform=ios \
npx nx build <app-name> ios --c=prod \
--provision <provisioning-profile-name> \
--copy-to ./dist/build.ipa
```
Expand All @@ -418,7 +445,7 @@ npx nx run <app-name>:build:prod --platform=ios \
It can be helpful to clean the app at times. This will clear out old dependencies plus iOS/Android platform files to give your app a nice reset.

```sh
npx nx run <app-name>:clean
npx nx clean <app-name>
```

## Create NativeScript library
Expand Down
58 changes: 49 additions & 9 deletions packages/nx/executors.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,65 @@
"executors": {
"build": {
"implementation": "./src/executors/build/executor",
"schema": "./src/executors/build/schema.json",
"description": "NativeScript builder"
"schema": "./src/executors/build/build.schema.json",
"description": "NativeScript executor"
},
"debug": {
"implementation": "./src/executors/build/executor",
"schema": "./src/executors/build/debug.schema.json",
"description": "NativeScript debug executor"
},
"run": {
"implementation": "./src/executors/build/executor",
"schema": "./src/executors/build/run.schema.json",
"description": "NativeScript run executor"
},
"prepare": {
"implementation": "./src/executors/build/executor",
"schema": "./src/executors/build/prepare.schema.json",
"description": "NativeScript prepare executor"
},
"test": {
"implementation": "./src/executors/test/executor",
"schema": "./src/executors/test/schema.json",
"implementation": "./src/executors/build/executor",
"schema": "./src/executors/build/test.schema.json",
"description": "Start the NativeScript unit test runner"
},
"clean": {
"implementation": "./src/executors/build/executor",
"schema": "./src/executors/build/clean.schema.json",
"description": "NativeScript clean executor"
}
},
"builders": {
"build": {
"implementation": "./src/executors/build/builder",
"schema": "./src/executors/build/schema.json",
"description": "build executor"
"schema": "./src/executors/build/build.schema.json",
"description": "NativeScript build builder"
},
"debug": {
"implementation": "./src/executors/build/builder",
"schema": "./src/executors/build/debug.schema.json",
"description": "NativeScript debug builder"
},
"run": {
"implementation": "./src/executors/build/builder",
"schema": "./src/executors/build/run.schema.json",
"description": "NativeScript run builder"
},
"prepare": {
"implementation": "./src/executors/build/builder",
"schema": "./src/executors/build/prepare.schema.json",
"description": "NativeScript prepare builder"
},
"test": {
"implementation": "./src/executors/test/builder",
"schema": "./src/executors/test/schema.json",
"description": "test executor"
"implementation": "./src/executors/build/builder",
"schema": "./src/executors/build/test.schema.json",
"description": "NativeScript test builder"
},
"clean": {
"implementation": "./src/executors/build/builder",
"schema": "./src/executors/build/clean.schema.json",
"description": "NativeScript clean builder"
}
}
}
13 changes: 13 additions & 0 deletions packages/nx/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
"jestConfig": "packages/nx/jest.config.ts"
}
},
"prepare": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "ts-node -P ./packages/nx/tsconfig.lib.json ./packages/nx/src/utils/generate-schemas.ts"
},
{
"command": "nx build nx"
}
]
}
},
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
Expand Down
Loading