Skip to content
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

feat(rust): move to nx plugin v2 #27

Merged
merged 9 commits into from
Nov 20, 2023
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
"rules": {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": "warn"
}
},
{
"files": ["*.js", "*.jsx"],
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ Thumbs.db
# Added by cargo

/target

.nx/cache
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

/dist
/coverage

/.nx/cache
3 changes: 2 additions & 1 deletion e2e/rust-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "e2e/rust-e2e/jest.config.js",
"runInBand": true
"runInBand": true,
"passWithNoTests": false
},
"dependsOn": ["rust:build"]
}
Expand Down
75 changes: 59 additions & 16 deletions migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,78 @@
"migrations": [
{
"cli": "nx",
"version": "16.6.0-beta.6",
"description": "Prefix outputs with {workspaceRoot}/{projectRoot} if needed",
"implementation": "./src/migrations/update-15-0-0/prefix-outputs",
"version": "17.0.0-beta.1",
"description": "Updates the default cache directory to .nx/cache",
"implementation": "./src/migrations/update-17-0-0/move-cache-directory",
"package": "nx",
"name": "16.6.0-prefix-outputs"
"name": "17.0.0-move-cache-directory"
},
{
"cli": "nx",
"version": "16.8.0-beta.3",
"description": "Escape $ in env variables",
"implementation": "./src/migrations/update-16-8-0/escape-dollar-sign-env-variables",
"version": "17.0.0-beta.3",
"description": "Use minimal config for tasksRunnerOptions",
"implementation": "./src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options",
"package": "nx",
"name": "16.8.0-escape-dollar-sign-env"
"name": "17.0.0-use-minimal-config-for-tasks-runner-options"
},
{
"version": "17.0.0-rc.1",
"description": "Migration for v17.0.0-rc.1",
"implementation": "./src/migrations/update-17-0-0/rm-default-collection-npm-scope",
"package": "nx",
"name": "rm-default-collection-npm-scope"
},
{
"cli": "nx",
"version": "16.9.0-beta.1",
"description": "Replace imports of Module Federation utils frm @nx/devkit to @nx/webpack",
"implementation": "./src/migrations/update-16-9-0/migrate-mf-util-usage",
"package": "@nx/devkit",
"name": "update-16-9-0-migrate-mf-usage-to-webpack"
},
{
"cli": "nx",
"version": "16.6.0-beta.0",
"description": "Explicitly set 'updateBuildableProjectDepsInPackageJson' to 'true' in targets that rely on that value as the default.",
"factory": "./src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps",
"version": "16.8.2-beta.0",
"description": "Remove invalid options (strict, noInterop) for ES6 type modules.",
"factory": "./src/migrations/update-16-8-2/update-swcrc",
"package": "@nx/js",
"name": "explicitly-set-projects-to-update-buildable-deps"
"name": "16-8-2-update-swcrc"
},
{
"cli": "nx",
"version": "16.5.0-beta.2",
"description": "Add test-setup.ts to ignored files in production input",
"implementation": "./src/migrations/update-16-5-0/add-test-setup-to-inputs-ignore",
"version": "17.0.2",
"description": "Remove deprecated build options",
"implementation": "./src/migrations/update-17-0-0/remove-deprecated-build-options",
"package": "@nx/js",
"name": "update-17-0-0-remove-deprecated-build-options"
},
{
"version": "17.1.0-beta.2",
"description": "Move jest executor options to nx.json targetDefaults",
"implementation": "./src/migrations/update-17-1-0/move-options-to-target-defaults",
"package": "@nx/jest",
"name": "add-test-setup-to-inputs-ignore"
"name": "move-options-to-target-defaults"
},
{
"version": "16.8.0",
"description": "update-16-8-0-add-ignored-files",
"implementation": "./src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files",
"package": "@nx/eslint",
"name": "update-16-8-0-add-ignored-files"
},
{
"version": "17.0.0-beta.7",
"description": "update-17-0-0-rename-to-eslint",
"implementation": "./src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint",
"package": "@nx/eslint",
"name": "update-17-0-0-rename-to-eslint"
},
{
"version": "17.1.0-beta.1",
"description": "Updates for @typescript-utils/utils v6.9.1+",
"implementation": "./src/migrations/update-17-1-0/update-typescript-eslint",
"package": "@nx/eslint",
"name": "update-typescript-eslint"
}
]
}
38 changes: 19 additions & 19 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
{
"npmScope": "monodon",
"affected": {
"defaultBase": "main"
},
"tasksRunnerOptions": {
"default": {
"runner": "nx-cloud",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"],
"accessToken": "ZTY5ODM4MGMtNTcxNi00OGFiLWIwY2EtYTQxYzNmZTZjYWM2fHJlYWQtd3JpdGU="
}
}
},
"workspaceLayout": {
"appsDir": "e2e",
"libsDir": "packages"
Expand All @@ -20,16 +10,25 @@
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"link-plugin": {
"dependsOn": ["build"]
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
"inputs": ["production", "^production"],
"cache": true
},
"lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
"cache": true
},
"@nx/jest:jest": {
"cache": true,
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"options": {
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"namedInputs": {
Expand All @@ -43,5 +42,6 @@
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/src/test-setup.[jt]s"
]
}
},
"nxCloudAccessToken": "ZTY5ODM4MGMtNTcxNi00OGFiLWIwY2EtYTQxYzNmZTZjYWM2fHJlYWQtd3JpdGU="
}
34 changes: 16 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,39 @@
"packageManager": "[email protected]",
"dependencies": {
"@ltd/j-toml": "1.38.0",
"@nx/devkit": "16.8.0-rc.0",
"@nx/js": "16.8.0-rc.0",
"@nx/devkit": "17.1.2",
"@nx/js": "17.1.2",
"chalk": "^4.1.2",
"tslib": "^2.0.0"
},
"devDependencies": {
"@commitlint/cli": "17.3.0",
"@commitlint/config-conventional": "17.3.0",
"@jscutlery/semver": "^2.29.0",
"@nx/eslint-plugin": "16.8.0-rc.0",
"@nx/jest": "16.8.0-rc.0",
"@nx/linter": "16.8.0-rc.0",
"@nx/node": "16.8.0-rc.0",
"@nx/plugin": "16.8.0-rc.0",
"@nx/workspace": "16.8.0-rc.0",
"@swc-node/register": "^1.4.2",
"@swc/core": "^1.2.173",
"@nx/eslint-plugin": "17.1.2",
"@nx/jest": "17.1.2",
"@nx/node": "17.1.2",
"@nx/plugin": "17.1.2",
"@nx/workspace": "17.1.2",
"@swc-node/register": "1.6.8",
"@swc/core": "1.3.96",
"@types/jest": "29.4.0",
"@types/node": "18.7.1",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/parser": "6.11.0",
"dotenv": "~10.0.0",
"eslint": "8.46.0",
"eslint-config-prettier": "8.1.0",
"eslint-config-prettier": "9.0.0",
"husky": "^8.0.0",
"jest": "29.4.3",
"jsonc-eslint-parser": "^2.1.0",
"nx": "16.8.0-rc.0",
"nx-cloud": "16.3.0",
"nx": "17.1.2",
"prettier": "2.8.0",
"ts-jest": "29.1.0",
"ts-node": "10.9.1",
"tslib": "^2.0.0",
"typescript": "5.1.6",
"verdaccio": "^5.25.0"
"typescript": "5.2.2",
"verdaccio": "^5.25.0",
"@nx/eslint": "17.1.2"
}
}

9 changes: 3 additions & 6 deletions packages/rust/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"projectType": "library",
"targets": {
"lint": {
"executor": "@nx/linter:eslint",
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": [
"packages/rust/**/*.ts",
Expand All @@ -20,8 +20,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/packages/rust"],
"options": {
"jestConfig": "packages/rust/jest.config.ts",
"passWithNoTests": true
"jestConfig": "packages/rust/jest.config.ts"
}
},
"build": {
Expand All @@ -31,7 +30,6 @@
"outputPath": "dist/packages/rust",
"tsConfig": "packages/rust/tsconfig.lib.json",
"packageJson": "packages/rust/package.json",
"buildableProjectDepsInPackageJsonType": "dependencies",
"main": "packages/rust/src/index.ts",
"assets": [
"packages/rust/*.md",
Expand All @@ -55,8 +53,7 @@
"glob": "executors.json",
"output": "."
}
],
"updateBuildableProjectDepsInPackageJson": true
]
}
},
"version": {
Expand Down
3 changes: 2 additions & 1 deletion packages/rust/src/generators/add-napi/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import { NAPI_VERSION } from '../../utils/versions';
import { AddNapiGeneratorSchema } from './schema';
import { getRootTsConfigPathInTree } from '@nx/js';
import { getNpmScope } from '@nx/js/src/utils/package-json/get-npm-scope';

interface NormalizedSchema extends AddNapiGeneratorSchema {
projectName: string;
Expand Down Expand Up @@ -76,7 +77,7 @@ function normalizeOptions(
options: AddNapiGeneratorSchema,
project: ProjectConfiguration
): NormalizedSchema {
const { npmScope } = getWorkspaceLayout(tree);
const npmScope = getNpmScope(tree);
const projectName = project.name ?? options.project;
const packageName = npmScope
? `@${npmScope}/${names(projectName).fileName}`
Expand Down
Loading
Loading