Skip to content

Commit cfb5664

Browse files
authored
feat: Nx 19.3+ (#20)
1 parent 4e31717 commit cfb5664

File tree

10 files changed

+1567
-1842
lines changed

10 files changed

+1567
-1842
lines changed

.eslintrc.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@
3636
{
3737
"files": ["*.ts", "*.tsx"],
3838
"extends": ["plugin:@nx/typescript"],
39-
"rules": {}
39+
"rules": {
40+
"@typescript-eslint/no-extra-semi": "error",
41+
"no-extra-semi": "off"
42+
}
4043
},
4144
{
4245
"files": ["*.js", "*.jsx"],
4346
"extends": ["plugin:@nx/javascript"],
44-
"rules": {}
47+
"rules": {
48+
"@typescript-eslint/no-extra-semi": "error",
49+
"no-extra-semi": "off"
50+
}
4551
}
4652
]
4753
}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ testem.log
3939
.DS_Store
4040
Thumbs.db
4141

42-
.nx/cache
42+
.nx/cache
43+
.nx/workspace-data

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/dist
44
/coverage
55

6-
/.nx/cache
6+
/.nx/cache
7+
/.nx/workspace-data

package.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,37 @@
3232
},
3333
"private": true,
3434
"devDependencies": {
35-
"@nx/devkit": "18.2.3",
36-
"@nx/workspace": "18.2.3",
37-
"@nx/js": "18.2.3",
38-
"@nx/plugin": "18.2.3",
39-
"@nx/jest": "18.2.3",
40-
"@nx/node": "18.2.3",
41-
"@nx/eslint-plugin": "18.2.3",
42-
"@swc-node/register": "^1.9.0",
43-
"@swc/core": "^1.4.0",
35+
"@nx/devkit": "19.3.0",
36+
"@nx/workspace": "19.3.0",
37+
"@nx/js": "19.3.0",
38+
"@nx/plugin": "19.3.0",
39+
"@nx/jest": "19.3.0",
40+
"@nx/node": "19.3.0",
41+
"@nx/eslint-plugin": "19.3.0",
42+
"@swc-node/register": "1.9.2",
43+
"@swc/core": "1.6.1",
4444
"@types/jest": "~29.5.0",
4545
"@types/node": "^20.0.0",
46-
"@typescript-eslint/eslint-plugin": "7.5.0",
47-
"@typescript-eslint/parser": "7.5.0",
48-
"conventional-changelog-cli": "^2.2.0",
46+
"@typescript-eslint/eslint-plugin": "7.13.1",
47+
"@typescript-eslint/parser": "7.13.1",
48+
"conventional-changelog-cli": "^5.0.0",
4949
"dotenv": "~16.4.0",
5050
"eslint": "8.57.0",
5151
"eslint-config-prettier": "9.1.0",
5252
"github-contributors-list": "~1.2.3",
5353
"husky": "~9.0.0",
5454
"jest": "29.7.0",
55-
"nx-cloud": "18.0.0",
56-
"nx": "18.2.3",
55+
"nx-cloud": "19.0.0",
56+
"nx": "19.3.0",
5757
"parse-version-string": "^1.0.1",
58-
"prettier": "2.7.1",
59-
"rxjs": "~7.8.1",
58+
"prettier": "^2.8.0",
59+
"rxjs": "^7.8.1",
6060
"semver": "^7.5.4",
61-
"ts-jest": "29.1.2",
61+
"ts-jest": "29.1.5",
6262
"ts-node": "^10.9.0",
6363
"tslib": "^2.0.0",
64-
"typescript": "5.4.4",
65-
"@nx/eslint": "18.2.3"
64+
"typescript": "5.4.5",
65+
"@nx/eslint": "19.3.0"
6666
},
6767
"lint-staged": {
6868
"**/*.{js,ts,scss,json,html}": [

packages/plugin-tools/migrations.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
"version": "5.2.0",
6666
"description": "Migrate tools to 5.2.0",
6767
"implementation": "./src/migrations/update-5-2-0/update-5-2-0"
68+
},
69+
"update-to-5.3.0": {
70+
"cli": "nx",
71+
"version": "5.3.0",
72+
"description": "Migrate tools to 5.3.0",
73+
"implementation": "./src/migrations/update-5-3-0/update-5-3-0"
6874
}
6975
}
7076
}

packages/plugin-tools/package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/plugin-tools",
3-
"version": "5.2.5",
3+
"version": "5.3.0",
44
"description": "NativeScript plugin tooling for workspaces",
55
"homepage": "https://nativescript.org",
66
"repository": {
@@ -27,21 +27,21 @@
2727
},
2828
"dependencies": {
2929
"xml2js": "~0.6.0",
30-
"@nativescript/nx": "^18.0.0",
31-
"@nx/angular": "^18.0.0",
32-
"@nx/devkit": "^18.0.0",
33-
"@nx/workspace": "^18.0.0",
34-
"@nx/js": "^18.0.0",
35-
"@nx/plugin": "^18.0.0",
36-
"@nx/jest": "^18.0.0",
37-
"@nx/node": "^18.0.0",
38-
"@nx/eslint-plugin": "^18.0.0",
39-
"nx-cloud": "^18.0.0",
40-
"@nstudio/focus": "^17.0.0",
30+
"@nativescript/nx": "^19.0.0",
31+
"@nx/angular": "^19.0.0",
32+
"@nx/devkit": "^19.0.0",
33+
"@nx/workspace": "^19.0.0",
34+
"@nx/js": "^19.0.0",
35+
"@nx/plugin": "^19.0.0",
36+
"@nx/jest": "^19.0.0",
37+
"@nx/node": "^19.0.0",
38+
"@nx/eslint-plugin": "^19.0.0",
39+
"nx-cloud": "^19.0.0",
40+
"@nstudio/focus": "^19.0.0",
4141
"@nstudio/nps-i": "^2.0.0",
42-
"@types/node": "^12.0.0",
43-
"@typescript-eslint/eslint-plugin": "7.5.0",
44-
"@typescript-eslint/parser": "7.5.0",
42+
"@types/node": "^20.0.0",
43+
"@typescript-eslint/eslint-plugin": "7.13.1",
44+
"@typescript-eslint/parser": "7.13.1",
4545
"eslint": "^8.46.0",
4646
"eslint-config-prettier": "^8.1.0",
4747
"husky": "^9.0.0",
@@ -55,6 +55,6 @@
5555
"rimraf": "^5.0.0",
5656
"ts-node": "^10.0.0",
5757
"ts-patch": "^3.0.0",
58-
"@nx/eslint": "^18.0.0"
58+
"@nx/eslint": "^19.0.0"
5959
}
6060
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"migrations": [
3+
{
4+
"cli": "nx",
5+
"version": "19.2.0-beta.2",
6+
"description": "Updates the default workspace data directory to .nx/workspace-data",
7+
"implementation": "./src/migrations/update-19-2-0/move-workspace-data-directory",
8+
"package": "nx",
9+
"name": "19-2-0-move-graph-cache-directory"
10+
},
11+
{
12+
"cli": "nx",
13+
"version": "19.2.2-beta.0",
14+
"description": "Updates the nx wrapper.",
15+
"implementation": "./src/migrations/update-17-3-0/update-nxw",
16+
"package": "nx",
17+
"name": "19-2-2-update-nx-wrapper"
18+
},
19+
{
20+
"version": "19.2.4-beta.0",
21+
"description": "Set project name in nx.json explicitly",
22+
"implementation": "./src/migrations/update-19-2-4/set-project-name",
23+
"x-repair-skip": true,
24+
"package": "nx",
25+
"name": "19-2-4-set-project-name"
26+
},
27+
{
28+
"cli": "nx",
29+
"version": "19.1.0-beta.6",
30+
"description": "Migrate no-extra-semi rules into user config, out of nx extendable configs",
31+
"implementation": "./src/migrations/update-19-1-0-migrate-no-extra-semi/migrate-no-extra-semi",
32+
"package": "@nx/eslint-plugin",
33+
"name": "update-19-1-0-rename-no-extra-semi"
34+
}
35+
]
36+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import { formatFiles, Tree, updateJson } from '@nx/devkit';
2+
import { readModulePackageJson } from 'nx/src/utils/package-json';
3+
import { updateDemoAppPackages } from '../../utils/migrations';
4+
import { dirname } from 'path';
5+
const migrations = require('./migrations-to-run.json');
6+
7+
function readPackageMigrationConfig(packageName: string, dir?: string) {
8+
const { path: packageJsonPath, packageJson: json } = readModulePackageJson(packageName, dir ? [dir] : undefined);
9+
10+
const migrationConfigOrFile = json['nx-migrations'] || json['ng-update'];
11+
12+
if (!migrationConfigOrFile) {
13+
return { packageJson: json, migrations: null, packageGroup: [] };
14+
}
15+
16+
const migrationsConfig =
17+
typeof migrationConfigOrFile === 'string'
18+
? {
19+
migrations: migrationConfigOrFile,
20+
packageGroup: [],
21+
}
22+
: migrationConfigOrFile;
23+
24+
try {
25+
const migrationFile = require.resolve(migrationsConfig.migrations, {
26+
paths: [dirname(packageJsonPath)],
27+
});
28+
29+
return {
30+
packageJson: json,
31+
migrations: migrationFile,
32+
packageGroup: migrationsConfig.packageGroup,
33+
};
34+
} catch {
35+
return {
36+
packageJson: json,
37+
migrations: null,
38+
packageGroup: migrationsConfig.packageGroup,
39+
};
40+
}
41+
}
42+
43+
export default async function (tree: Tree) {
44+
updateDependencies(tree);
45+
updateJson(tree, 'tsconfig.base.json', (json) => {
46+
json.compilerOptions = json.compilerOptions || {};
47+
json.compilerOptions.target = 'ES2020';
48+
json.compilerOptions.module = 'ESNext';
49+
json.compilerOptions.lib = ['ESNext', 'dom'];
50+
return json;
51+
});
52+
updateDemoAppPackages(tree, {
53+
devDependencies: {
54+
'@nativescript/android': '~8.7.0',
55+
'@nativescript/ios': '~8.7.0',
56+
},
57+
});
58+
for (const migration of migrations.migrations) {
59+
const packageName = migration.package;
60+
const implRelativePath = migration.implementation || migration.factory;
61+
const collectionPath = readPackageMigrationConfig(packageName).migrations;
62+
let implPath: string;
63+
64+
if (collectionPath) {
65+
let fn: any;
66+
try {
67+
try {
68+
implPath = require.resolve(implRelativePath, {
69+
paths: [dirname(collectionPath)],
70+
});
71+
} catch (e) {
72+
// workaround for a bug in node 12
73+
implPath = require.resolve(`${dirname(collectionPath)}/${implRelativePath}`);
74+
}
75+
76+
fn = require(implPath).default;
77+
} catch (e) {
78+
// ignore, most likely missing package
79+
}
80+
if (fn) {
81+
await fn(tree, {});
82+
}
83+
}
84+
}
85+
// TODO: Edit the generators to use the new tsconfig
86+
87+
await formatFiles(tree);
88+
89+
console.log(`\n NOTE: Your plugin workspace is now migrated. Run this to finish the dependency cleanup:`);
90+
console.log(`\n`);
91+
console.log(` npm run setup`);
92+
console.log(`\n`);
93+
console.log(` This will ensure your workspace is properly reset with all the updates.`);
94+
console.log(` It is also recommended to clean all your demo apps.`);
95+
console.log(`\n`);
96+
}
97+
98+
function updateDependencies(tree: Tree) {
99+
updateJson(tree, 'package.json', (json) => {
100+
if (json.devDependencies['@angular/core']) {
101+
json.devDependencies['@angular-devkit/build-angular'] = '^18.0.0';
102+
for (const key in json.devDependencies) {
103+
if (key.indexOf('@angular/') > -1) {
104+
json.devDependencies[key] = '^18.0.0';
105+
}
106+
if (key.indexOf('@angular-eslint/') > -1) {
107+
json.devDependencies[key] = '^18.0.0';
108+
}
109+
}
110+
}
111+
json.devDependencies['@nativescript/angular'] = '^18.0.0';
112+
json.devDependencies['@nativescript/core'] = '~8.7.0';
113+
json.devDependencies['@nativescript/types'] = '~8.7.0';
114+
json.devDependencies['@ngtools/webpack'] = '^18.0.0';
115+
json.devDependencies['husky'] = '~9.0.0';
116+
json.devDependencies['ng-packagr'] = '^18.0.0';
117+
json.devDependencies['rxjs'] = '~7.8.0';
118+
json.devDependencies['zone.js'] = '~0.14.0';
119+
json.devDependencies['typescript'] = '~5.4.0';
120+
121+
if (json.devDependencies['ts-patch']) {
122+
json.devDependencies['ts-patch'] = '^3.0.0';
123+
}
124+
return json;
125+
});
126+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export const toolsVersion = '*';
2-
export const nxVersion = '18.2.3';
2+
export const nxVersion = '19.3.0';

0 commit comments

Comments
 (0)