Skip to content

Commit d511987

Browse files
authored
feat: Nx 15.3+ with NativeScript 8.4+ (#66)
1 parent 507cd22 commit d511987

File tree

14 files changed

+1436
-372
lines changed

14 files changed

+1436
-372
lines changed

migrations.json

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

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
},
3232
"private": true,
3333
"devDependencies": {
34-
"@angular/core": "~14.2.0",
35-
"@nrwl/angular": "15.1.1",
36-
"@nrwl/cli": "15.1.1",
37-
"@nrwl/eslint-plugin-nx": "15.1.1",
38-
"@nrwl/jest": "15.1.1",
39-
"@nrwl/nx-plugin": "15.1.1",
40-
"@nrwl/workspace": "15.1.1",
34+
"@angular/core": "15.0.4",
35+
"@nrwl/angular": "15.3.3",
36+
"@nrwl/cli": "15.3.3",
37+
"@nrwl/eslint-plugin-nx": "15.3.3",
38+
"@nrwl/jest": "15.3.3",
39+
"@nrwl/nx-plugin": "15.3.3",
40+
"@nrwl/workspace": "15.3.3",
4141
"@swc-node/register": "^1.4.2",
4242
"@swc/core": "^1.2.173",
4343
"@types/fs-extra": "^9.0.11",
@@ -56,7 +56,7 @@
5656
"fs-extra": "^10.1.0",
5757
"jest": "28.1.3",
5858
"jsonc-parser": "3.0.0",
59-
"nx": "15.1.1",
59+
"nx": "15.3.3",
6060
"plist": "^3.0.4",
6161
"prettier": "^2.7.0",
6262
"ts-jest": "28.0.8",

packages/nx/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ yarn create-nx-workspace@latest
6464
If you run into any issue with latest Nx workspace version you may want to try the last known stable version with the following:
6565

6666
```sh
67-
npx create-nx-workspace@15.1.1
67+
npx create-nx-workspace@15.3.3
6868

6969
Need to install the following packages:
70-
create-nx-workspace@15.1.1
70+
create-nx-workspace@15.3.3
7171
Ok to proceed? (y) y
7272

7373
> NX Let's create a new workspace [https://nx.dev/getting-started/intro]

packages/nx/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
"migrations": "./migrations.json"
2929
},
3030
"dependencies": {
31-
"@angular-devkit/architect": "^0.1400.0",
32-
"@angular-devkit/core": "^14.0.0",
33-
"@angular-devkit/schematics": "^14.0.0",
31+
"@angular-devkit/architect": "^0.1500.0",
32+
"@angular-devkit/core": "^15.0.0",
33+
"@angular-devkit/schematics": "^15.0.0",
34+
"@nrwl/devkit": "^15.0.0",
3435
"fs-extra": "^10.1.0",
3536
"ignore": "^5.0.4",
3637
"jsonc-parser": "3.0.0",

packages/nx/src/generators/app-resources/files/__name__/Android/app.gradle

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
// Add your native dependencies here:
2-
3-
// Uncomment to add recyclerview-v7 dependency
4-
//dependencies {
5-
// implementation 'com.android.support:recyclerview-v7:+'
6-
//}
7-
8-
// If you want to add something to be applied before applying plugins' include.gradle files
9-
// e.g. project.ext.googlePlayServicesVersion = "15.0.1"
10-
// create a file named before-plugins.gradle in the current directory and place it there
1+
// You can add your native dependencies here
2+
dependencies {
3+
// implementation 'androidx.multidex:multidex:2.0.1'
4+
}
115

126
android {
7+
// compileSdkVersion 32
8+
// buildToolsVersion "32.0.0"
9+
// ndkVersion ""
10+
1311
defaultConfig {
14-
minSdkVersion 17
12+
minSdkVersion 21
13+
// targetSdkVersion 32
14+
15+
// Version Information
16+
versionCode 1
17+
versionName "1.0.0"
18+
1519
generatedDensities = []
1620
}
21+
1722
aaptOptions {
1823
additionalParameters "--no-version-vectors"
1924
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// this configurations is loaded before building plugins, as well as before building
2+
// the app - this is where you can apply global settings and overrides
3+
4+
project.ext {
5+
// androidXAppCompat = "1.4.1"
6+
// androidXExifInterface = "1.3.3"
7+
// androidXFragment = "1.4.1"
8+
// androidXMaterial = "1.5.0"
9+
// androidXMultidex = "2.0.1"
10+
// androidXTransition = "1.4.1"
11+
// androidXViewPager = "1.0.0"
12+
13+
// useKotlin = true
14+
// kotlinVersion = "1.6.0"
15+
}

packages/nx/src/generators/app-resources/files/__name__/Android/src/main/AndroidManifest.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@
1919
android:allowBackup="true"
2020
android:icon="@mipmap/ic_launcher"
2121
android:label="@string/app_name"
22-
android:theme="@style/AppTheme">
22+
android:theme="@style/AppTheme"
23+
android:hardwareAccelerated="true">
2324

2425
<activity
2526
android:name="com.tns.NativeScriptActivity"
2627
android:label="@string/title_activity_kimera"
2728
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
28-
android:theme="@style/LaunchScreenTheme">
29+
android:theme="@style/LaunchScreenTheme"
30+
android:hardwareAccelerated="true"
31+
android:launchMode="singleTask"
32+
android:exported="true">
2933

3034
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
3135

packages/nx/src/generators/application/application.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { readJson, Tree, updateJson, addProjectConfiguration, generateFiles, joinPathFragments, installPackagesTask } from '@nrwl/devkit';
1+
import { Tree, addProjectConfiguration, generateFiles, joinPathFragments, installPackagesTask } from '@nrwl/devkit';
22
import { getAppName, getDefaultTemplateOptions, getFrontendFramework, getPrefix, missingArgument, PluginHelpers, prerun, updateNxProjects, updatePackageScripts } from '../../utils';
33
import { angularVersion, nsAngularVersion, nsWebpackVersion, nsNgToolsVersion, nsCoreVersion, typescriptVersion, rxjsVersion, zonejsVersion, nsIOSRuntimeVersion, nsAndroidRuntimeVersion } from '../../utils/versions';
44
import { appResources } from '../app-resources/app-resources';
@@ -31,7 +31,7 @@ export async function applicationGenerator(tree: Tree, options: Schema) {
3131
case 'angular':
3232
frontendFrameworkConfig = {
3333
build: {
34-
builder: '@nativescript/nx:build',
34+
executor: '@nativescript/nx:build',
3535
options: {
3636
noHmr: true,
3737
production: true,
@@ -60,7 +60,7 @@ export async function applicationGenerator(tree: Tree, options: Schema) {
6060
targets: {
6161
...frontendFrameworkConfig,
6262
ios: {
63-
builder: '@nativescript/nx:build',
63+
executor: '@nativescript/nx:build',
6464
options: {
6565
platform: 'ios',
6666
},
@@ -74,7 +74,7 @@ export async function applicationGenerator(tree: Tree, options: Schema) {
7474
},
7575
},
7676
android: {
77-
builder: '@nativescript/nx:build',
77+
executor: '@nativescript/nx:build',
7878
options: {
7979
platform: 'android',
8080
},
@@ -88,13 +88,13 @@ export async function applicationGenerator(tree: Tree, options: Schema) {
8888
},
8989
},
9090
clean: {
91-
builder: '@nativescript/nx:build',
91+
executor: '@nativescript/nx:build',
9292
options: {
9393
clean: true,
9494
},
9595
},
9696
lint: {
97-
builder: '@nrwl/linter:eslint',
97+
executor: '@nrwl/linter:eslint',
9898
options: {
9999
lintFilePatterns: [`${appPath}/**/*.ts`, `${appPath}/src/**/*.html`],
100100
},

packages/nx/src/generators/init/init.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ export async function init(tree: Tree, options: Schema) {
2222

2323
return json;
2424
});
25-
const config = readWorkspaceConfiguration(tree);
26-
if (!config.cli?.defaultCollection) {
27-
updateWorkspaceConfiguration(tree, {
28-
version: 2,
29-
cli: {
30-
defaultCollection: '@nativescript/nx'
31-
}
32-
});
33-
}
3425
}
3526

3627
export default init;
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
import { generateFiles, joinPathFragments, Tree } from '@nrwl/devkit';
2-
import { getDefaultTemplateOptions, getJsonFromFile, PluginHelpers, prerun, updateJsonFile } from '../../utils';
1+
import { generateFiles, joinPathFragments, Tree, readJson } from '@nrwl/devkit';
2+
import { getDefaultTemplateOptions, PluginHelpers, prerun, updateJsonFile } from '../../utils';
33
import { libraryGenerator } from '@nrwl/workspace';
44

55
export function library(tree: Tree, options: any) {
6+
prerun(tree, options, true);
7+
PluginHelpers.applyAppNamingConvention(tree, options, 'nativescript');
8+
libraryGenerator(tree, options);
69

7-
prerun(tree, options, true);
8-
PluginHelpers.applyAppNamingConvention(tree, options, 'nativescript'),
9-
libraryGenerator(tree, options)
10+
console.log(tree.children('libs'));
1011

11-
// add extra files
12-
const directory = options.directory ? `${options.directory}/` : '';
13-
generateFiles(tree, joinPathFragments(__dirname, 'files'), `libs/${directory}${options.name}`, {
14-
...(options as any),
15-
...getDefaultTemplateOptions(),
16-
pathOffset: directory ? '../../../' : '../../',
17-
})
12+
// add extra files
13+
const directory = options.directory ? `${options.directory}/` : '';
14+
generateFiles(tree, joinPathFragments(__dirname, 'files'), `libs/${directory}${options.name}`, {
15+
...(options as any),
16+
...getDefaultTemplateOptions(),
17+
pathOffset: directory ? '../../../' : '../../',
18+
});
1819

19-
// update library tsconfig for {N} development
20-
const tsConfigPath = `libs/${directory}${options.name}/tsconfig.json`;
21-
const tsConfigJson = getJsonFromFile(tree, tsConfigPath);
22-
if (tsConfigJson && tsConfigJson.files) {
23-
tsConfigJson.files.push('./references.d.ts');
24-
}
25-
if (tsConfigJson && tsConfigJson.include) {
26-
tsConfigJson.include.push('**/*.ts');
27-
}
28-
updateJsonFile(tree, tsConfigPath, tsConfigJson);
29-
20+
// update library tsconfig for {N} development
21+
const tsConfigPath = `libs/${directory}${options.name}/tsconfig.json`;
22+
const tsConfigJson = readJson(tree, tsConfigPath);
23+
if (tsConfigJson && tsConfigJson.files) {
24+
tsConfigJson.files.push('./references.d.ts');
25+
}
26+
if (tsConfigJson && tsConfigJson.include) {
27+
tsConfigJson.include.push('**/*.ts');
28+
}
29+
updateJsonFile(tree, tsConfigPath, tsConfigJson);
3030
}
3131

32-
export default library;
32+
export default library;

0 commit comments

Comments
 (0)