Skip to content

Commit 21e1386

Browse files
committed
feat: update to last of Nx 15.9.x series
1 parent d5a2827 commit 21e1386

File tree

13 files changed

+2425
-3133
lines changed

13 files changed

+2425
-3133
lines changed

package.json

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@
3131
},
3232
"private": true,
3333
"devDependencies": {
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",
34+
"@angular-devkit/schematics": "15.2.7",
35+
"@angular/core": "15.2.8",
36+
"@nrwl/angular": "~15.9.2",
37+
"@nrwl/devkit": "~15.9.2",
38+
"@nrwl/eslint-plugin-nx": "~15.9.2",
39+
"@nrwl/express": "~15.9.2",
40+
"@nrwl/jest": "~15.9.2",
41+
"@nrwl/js": "~15.9.2",
42+
"@nrwl/linter": "~15.9.2",
43+
"@nrwl/nx-cloud": "~15.1.0",
44+
"@nrwl/web": "~15.9.2",
45+
"@nrwl/nx-plugin": "~15.9.2",
46+
"@nrwl/workspace": "~15.9.2",
4147
"@swc-node/register": "^1.4.2",
4248
"@swc/core": "^1.2.173",
4349
"@types/fs-extra": "^9.0.11",
@@ -56,13 +62,13 @@
5662
"fs-extra": "^10.1.0",
5763
"jest": "28.1.3",
5864
"jsonc-parser": "3.0.0",
59-
"nx": "15.3.3",
65+
"nx": "^15.0.0",
6066
"plist": "^3.0.4",
6167
"prettier": "^2.7.0",
6268
"ts-jest": "28.0.8",
6369
"ts-node": "10.9.1",
6470
"tslib": "^2.4.0",
65-
"typescript": "4.8.4",
71+
"typescript": "~4.9.5",
6672
"xml2js": "^0.4.23"
6773
}
6874
}

packages/nx/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/nx",
3-
"version": "4.2.0",
3+
"version": "15.0.0",
44
"description": "NativeScript Plugin for Nx",
55
"repository": {
66
"type": "git",
@@ -33,10 +33,10 @@
3333
"@angular-devkit/schematics": "^15.0.0",
3434
"@nrwl/devkit": "^15.0.0",
3535
"@nrwl/jest": "^15.0.0",
36-
"fs-extra": "^10.1.0",
37-
"ignore": "^5.0.4",
38-
"jsonc-parser": "3.0.0",
36+
"@nrwl/js": "^15.0.0",
37+
"fs-extra": "^11.1.0",
38+
"ignore": "^5.2.4",
3939
"plist": "^3.0.1",
40-
"xml2js": "~0.4.23"
40+
"xml2js": "~0.5.0"
4141
}
4242
}

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

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,82 @@
11

2-
import { readJson, readProjectConfiguration, readWorkspaceConfiguration, Tree } from '@nrwl/devkit';
2+
import { readJson, readProjectConfiguration, Tree } from '@nrwl/devkit';
33
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
44
import { applicationGenerator } from './application';
55
import { angularVersion, nsAngularVersion, rxjsVersion, zonejsVersion } from '../../utils/versions';
66

77
describe('app', () => {
8-
let appTree: Tree;
8+
let tree: Tree;
99

1010
beforeEach(() => {
11-
appTree = createTreeWithEmptyWorkspace();
11+
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
12+
tree.write('/apps/.gitignore', '');
13+
tree.write('/libs/.gitignore', '');
1214
});
1315

14-
it('should update workspace.json', async () => {
15-
await applicationGenerator(appTree, { name: 'myApp' });
16-
const config = readProjectConfiguration(appTree, 'nativescript-my-app');
16+
it('should update project.json', async () => {
17+
await applicationGenerator(tree, { name: 'myApp' });
18+
const config = readProjectConfiguration(tree, 'nativescript-my-app');
1719

1820
expect(config.root).toEqual('apps/nativescript-my-app');
1921
});
2022

2123
it('should generate files', async () => {
22-
await applicationGenerator(appTree, { name: 'myApp', framework: 'vanilla' });
24+
await applicationGenerator(tree, { name: 'myApp', framework: 'vanilla' });
2325
const appPath = 'apps/nativescript-my-app';
24-
expect(appTree.exists(`${appPath}/src/app-root.xml`)).toBeTruthy();
25-
expect(appTree.exists(`${appPath}/src/main-page.ts`)).toBeTruthy();
26-
checkFiles(appTree, appPath);
26+
expect(tree.exists(`${appPath}/src/app-root.xml`)).toBeTruthy();
27+
expect(tree.exists(`${appPath}/src/main-page.ts`)).toBeTruthy();
28+
checkFiles(tree, appPath);
2729
});
2830

2931
it('nested in directory: should generate files', async () => {
30-
await applicationGenerator(appTree, { name: 'myApp', directory: 'mobile', framework: 'vanilla' });
32+
await applicationGenerator(tree, { name: 'myApp', directory: 'mobile', framework: 'vanilla' });
3133
const appPath = 'apps/mobile/nativescript-my-app';
32-
expect(appTree.exists(`${appPath}/src/app-root.xml`)).toBeTruthy();
33-
expect(appTree.exists(`${appPath}/src/main-page.ts`)).toBeTruthy();
34+
expect(tree.exists(`${appPath}/src/app-root.xml`)).toBeTruthy();
35+
expect(tree.exists(`${appPath}/src/main-page.ts`)).toBeTruthy();
3436

35-
checkFiles(appTree, appPath, '../../../');
37+
checkFiles(tree, appPath, '../../../');
3638
});
3739

3840
it('Angular with Routing: should generate files', async () => {
39-
await applicationGenerator(appTree, { name: 'myApp', framework: 'angular', routing: true });
41+
await applicationGenerator(tree, { name: 'myApp', framework: 'angular', routing: true });
4042
const appPath = 'apps/nativescript-my-app';
41-
checkAngularFiles(appTree, appPath);
43+
checkAngularFiles(tree, appPath);
4244

43-
expect(appTree.exists(`${appPath}/src/app.routing.ts`)).toBeTruthy();
44-
expect(appTree.exists(`${appPath}/src/features/home/home.module.ts`)).toBeTruthy();
45+
expect(tree.exists(`${appPath}/src/app.routing.ts`)).toBeTruthy();
46+
expect(tree.exists(`${appPath}/src/features/home/home.module.ts`)).toBeTruthy();
4547

4648
// should also save framework as default in plugin settings
47-
const packageJson = readJson(appTree, `package.json`);
49+
const packageJson = readJson(tree, `package.json`);
4850
expect(packageJson['nativescript-nx'].framework).toEqual('angular');
4951

50-
checkFiles(appTree, appPath);
52+
checkFiles(tree, appPath);
5153
});
5254

5355
it('Angular without Routing: should generate files', async () => {
54-
await applicationGenerator(appTree, { name: 'myApp', framework: 'angular', routing: false });
56+
await applicationGenerator(tree, { name: 'myApp', framework: 'angular', routing: false });
5557
const appPath = 'apps/nativescript-my-app';
56-
checkAngularFiles(appTree, appPath);
58+
checkAngularFiles(tree, appPath);
5759

58-
expect(appTree.exists(`${appPath}/src/app.routing.ts`)).toBeFalsy();
59-
expect(appTree.exists(`${appPath}/src/features/home/home.module.ts`)).toBeFalsy();
60+
expect(tree.exists(`${appPath}/src/app.routing.ts`)).toBeFalsy();
61+
expect(tree.exists(`${appPath}/src/features/home/home.module.ts`)).toBeFalsy();
6062

61-
checkFiles(appTree, appPath);
63+
checkFiles(tree, appPath);
6264
});
6365

6466
it('Angular nested in directory: should generate files', async () => {
65-
await applicationGenerator(appTree, { name: 'myApp', framework: 'angular', directory: 'mobile', routing: true });
67+
await applicationGenerator(tree, { name: 'myApp', framework: 'angular', directory: 'mobile', routing: true });
6668
const appPath = 'apps/mobile/nativescript-my-app';
67-
checkAngularFiles(appTree, appPath);
69+
checkAngularFiles(tree, appPath);
6870

69-
expect(appTree.exists(`${appPath}/src/app.routing.ts`)).toBeTruthy();
70-
expect(appTree.exists(`${appPath}/src/features/home/home.module.ts`)).toBeTruthy();
71+
expect(tree.exists(`${appPath}/src/app.routing.ts`)).toBeTruthy();
72+
expect(tree.exists(`${appPath}/src/features/home/home.module.ts`)).toBeTruthy();
7173

72-
checkFiles(appTree, appPath, '../../../');
74+
checkFiles(tree, appPath, '../../../');
7375
});
7476

7577
it('should add angular dependencies when framework is angular', async () => {
76-
await applicationGenerator(appTree, { name: 'myApp', framework: 'angular' });
77-
const packageJson = readJson(appTree, `package.json`);
78+
await applicationGenerator(tree, { name: 'myApp', framework: 'angular' });
79+
const packageJson = readJson(tree, `package.json`);
7880

7981
expect(packageJson['dependencies']['@angular/animations']).toEqual(angularVersion);
8082
expect(packageJson['dependencies']['@angular/common']).toEqual(angularVersion);
@@ -90,8 +92,8 @@ describe('app', () => {
9092
});
9193

9294
it('should not add angular dependencies when framework is not angular', async () => {
93-
await applicationGenerator(appTree, { name: 'myApp', framework: '' });
94-
const packageJson = readJson(appTree, `package.json`);
95+
await applicationGenerator(tree, { name: 'myApp', framework: '' });
96+
const packageJson = readJson(tree, `package.json`);
9597

9698
expect(packageJson['dependencies']['@angular/animations']).toBeFalsy();
9799
expect(packageJson['dependencies']['@angular/common']).toBeFalsy();

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Tree, addProjectConfiguration, generateFiles, joinPathFragments, installPackagesTask } from '@nrwl/devkit';
2+
import { initGenerator } from '@nrwl/js';
23
import { getAppName, getDefaultTemplateOptions, getFrontendFramework, getPrefix, missingArgument, PluginHelpers, prerun, updateNxProjects, updatePackageScripts } from '../../utils';
34
import { angularVersion, nsAngularVersion, nsWebpackVersion, nsNgToolsVersion, nsCoreVersion, typescriptVersion, rxjsVersion, zonejsVersion, nsIOSRuntimeVersion, nsAndroidRuntimeVersion } from '../../utils/versions';
45
import { appResources } from '../app-resources/app-resources';
@@ -11,6 +12,10 @@ export async function applicationGenerator(tree: Tree, options: Schema) {
1112

1213
prerun(tree, options, true);
1314
PluginHelpers.applyAppNamingConvention(tree, options, 'nativescript');
15+
16+
await initGenerator(tree, {
17+
skipFormat: true,
18+
});
1419
addAppFiles(tree, options, options.name);
1520
// add extra files per options
1621
if (options.routing && ['angular'].includes(options.framework)) {
Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { readJson, readWorkspaceConfiguration, Tree, updateWorkspaceConfiguration } from '@nrwl/devkit';
1+
import { readJson, readNxJson, readProjectConfiguration, Tree, updateNxJson, updateProjectConfiguration } from '@nrwl/devkit';
22
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
33
import { init } from './init';
44

55
describe('init', () => {
66
let tree: Tree;
77

88
beforeEach(() => {
9-
tree = createTreeWithEmptyWorkspace();
9+
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
10+
tree.write('/apps/.gitignore', '');
11+
tree.write('/libs/.gitignore', '');
1012
});
1113

1214
it('should add nativescript dependencies', async () => {
@@ -29,23 +31,4 @@ describe('init', () => {
2931

3032
expect(content).toMatch(/# NativeScript/);
3133
});
32-
33-
describe('defaultCollection', () => {
34-
beforeEach(() => {
35-
tree = createTreeWithEmptyWorkspace();
36-
});
37-
38-
it('should be set if none was set before', async () => {
39-
let workspaceJson = readWorkspaceConfiguration(tree);
40-
updateWorkspaceConfiguration(tree, {
41-
version: 2,
42-
cli: {
43-
defaultCollection: null,
44-
},
45-
});
46-
await init(tree, {});
47-
workspaceJson = readWorkspaceConfiguration(tree);
48-
expect(workspaceJson.cli.defaultCollection).toEqual('@nativescript/nx');
49-
});
50-
});
5134
});

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import { readWorkspaceConfiguration, Tree, updateJson, updateWorkspaceConfiguration } from '@nrwl/devkit';
1+
import { Tree, updateJson } from '@nrwl/devkit';
2+
import { initGenerator } from '@nrwl/js';
23
import { nsCoreVersion, nsTypesVersion, nsThemeVersion } from '../../utils/versions';
34
import { Schema } from './schema';
45

56
export async function init(tree: Tree, options: Schema) {
7+
initGenerator(tree, {
8+
skipFormat: true,
9+
});
610
updateJson(tree, 'package.json', json => {
711
if (!json.dependencies) {
812
json.dependencies = {};

packages/nx/src/generators/library/library.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import { readJson, readProjectConfiguration, readWorkspaceConfiguration, Tree, updateJson, updateWorkspaceConfiguration } from '@nrwl/devkit';
1+
import { readJson, readProjectConfiguration, Tree, updateJson } from '@nrwl/devkit';
22
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
33
import { library } from './library';
44

55
describe('lib', () => {
66
let tree: Tree;
77

88
beforeEach(() => {
9-
tree = createTreeWithEmptyWorkspace();
9+
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
10+
tree.write('/apps/.gitignore', '');
11+
tree.write('/libs/.gitignore', '');
1012
});
1113

1214
describe('not nested', () => {
13-
it('should update workspace.json', async () => {
14-
await library(tree, { name: 'myLib' });
15+
it('should update project.json', async () => {
16+
await library(tree, { name: 'myLib', unitTestRunner: 'none' });
1517
const libName = `nativescript-my-lib`;
1618

1719
expect(tree.exists(`libs/${libName}/tsconfig.json`)).toBeTruthy();
@@ -34,7 +36,7 @@ describe('lib', () => {
3436
});
3537

3638
it('groupByName: should update workspace.json', async () => {
37-
await library(tree, { name: 'myLib', groupByName: true });
39+
await library(tree, { name: 'myLib', groupByName: true, unitTestRunner: 'none' });
3840
const libName = `my-lib-nativescript`;
3941
const projectConfig = readProjectConfiguration(tree, libName);
4042

packages/nx/src/generators/library/library.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { generateFiles, joinPathFragments, Tree, readJson } from '@nrwl/devkit';
22
import { getDefaultTemplateOptions, PluginHelpers, prerun, updateJsonFile } from '../../utils';
3-
import { libraryGenerator } from '@nrwl/workspace';
3+
import { initGenerator, libraryGenerator } from '@nrwl/js';
44

5-
export function library(tree: Tree, options: any) {
5+
export async function library(tree: Tree, options: any) {
66
prerun(tree, options, true);
77
PluginHelpers.applyAppNamingConvention(tree, options, 'nativescript');
8-
libraryGenerator(tree, options);
9-
10-
console.log(tree.children('libs'));
8+
await initGenerator(tree, {
9+
skipFormat: true,
10+
});
11+
await libraryGenerator(tree, {
12+
name: options.name,
13+
directory: options.directory,
14+
});
1115

1216
// add extra files
1317
const directory = options.directory ? `${options.directory}/` : '';

packages/nx/src/utils/general.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Tree, serializeJson, getWorkspacePath, readJson } from '@nrwl/devkit';
2-
import { stringUtils as nxStringUtils, updateWorkspaceInTree } from '@nrwl/workspace';
1+
import { Tree, serializeJson, readJson } from '@nrwl/devkit';
2+
import { stringUtils as nxStringUtils } from '@nrwl/workspace';
33

44
export interface IPluginSettings {
55
prefix?: string;
@@ -110,6 +110,7 @@ export function getDefaultTemplateOptions() {
110110
npmScope: getNpmScope(),
111111
prefix: getPrefix(),
112112
dot: '.',
113+
standaloneAsDefault: false
113114
};
114115
}
115116

@@ -209,22 +210,6 @@ export function updatePackageScripts(tree: Tree, scripts: any) {
209210
return updateJsonFile(tree, path, packageJson);
210211
}
211212

212-
export function readWorkspaceJson(tree: Tree) {
213-
return readJson(tree, getWorkspacePath(tree));
214-
}
215-
216-
export function updateWorkspace(updates: any) {
217-
return <any>updateWorkspaceInTree((json) => {
218-
for (const key in updates) {
219-
json[key] = {
220-
...(json[key] || {}),
221-
...updates[key],
222-
};
223-
}
224-
return json;
225-
});
226-
}
227-
228213
export function updateNxProjects(tree: Tree, projects: any) {
229214
const path = 'nx.json';
230215
const nxJson = readJson(tree, path);

0 commit comments

Comments
 (0)