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(sage-monorepo): explore Nx executors to standardize tasks across projects #2655

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
// Extensions should be defined in `.devcontainer/devcontainer.json` instead of here.
"recommendations": []
}
"recommendations": ["esbenp.prettier-vscode", "firsttris.vscode-jest-runner"]
}
18 changes: 0 additions & 18 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,11 @@
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.tabSize": 4
// This settings still works even if VS Code does not recognize it.
// "notebook.formatOnSave.enabled": true
},
"[json][jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
// "[typescript]": {
// "editor.defaultFormatter": "dbaeumer.vscode-eslint",
// "editor.formatOnSave": false
// },
// "[javascript]": {
// "editor.defaultFormatter": "dbaeumer.vscode-eslint",
// "editor.formatOnSave": true
// },
"java.format.enabled": false,
"[java]": {
"editor.formatOnSave": false
Expand All @@ -47,14 +37,6 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
// "emeraldwalk.runonsave": {
// "commands": [
// {
// "match": "\\.(java|sql)$",
// "cmd": "node_modules/.bin/nx affected --base=HEAD --target=format"
// }
// ]
// },
"eslint.workingDirectories": ["."],
"sqltools.autoOpenSessionFiles": false,
"sqltools.connections": [
Expand Down
3 changes: 3 additions & 0 deletions libs/openchallenges/api-description/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
"options": {
"command": "prettier --check {projectRoot}"
}
},
"about": {
"executor": "@sagebionetworks/sage-monorepo:about"
}
},
"tags": [],
Expand Down
32 changes: 32 additions & 0 deletions libs/sage-monorepo/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
},
{
"files": ["./package.json", "./executors.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/nx-plugin-checks": "error"
}
}
]
}
11 changes: 11 additions & 0 deletions libs/sage-monorepo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# sage-monorepo

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build sage-monorepo` to build the library.

## Running unit tests

Run `nx test sage-monorepo` to execute the unit tests via [Jest](https://jestjs.io).
9 changes: 9 additions & 0 deletions libs/sage-monorepo/executors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"executors": {
"about": {
"implementation": "./src/executors/about/executor",
"schema": "./src/executors/about/schema.json",
"description": "about executor"
}
}
}
11 changes: 11 additions & 0 deletions libs/sage-monorepo/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'sage-monorepo',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/libs/sage-monorepo',
};
12 changes: 12 additions & 0 deletions libs/sage-monorepo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "sage-monorepo",
"version": "0.0.1",
"dependencies": {
"tslib": "^2.3.0"
},
"type": "commonjs",
"main": "./src/index.js",
"typings": "./src/index.d.ts",
"private": true,
"executors": "./executors.json"
}
29 changes: 29 additions & 0 deletions libs/sage-monorepo/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "sage-monorepo",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/sage-monorepo/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/sage-monorepo",
"main": "libs/sage-monorepo/src/index.ts",
"tsConfig": "libs/sage-monorepo/tsconfig.lib.json",
"assets": ["libs/sage-monorepo/*.md"]
}
},
"lint": {
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/sage-monorepo/jest.config.ts"
}
}
},
"tags": []
}
8 changes: 8 additions & 0 deletions libs/sage-monorepo/src/executors/about/executor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { AboutExecutorSchema } from './schema';

export default async function runExecutor(options: AboutExecutorSchema) {
console.log('Executor ran for About', options);
return {
success: true,
};
}
1 change: 1 addition & 0 deletions libs/sage-monorepo/src/executors/about/schema.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export interface AboutExecutorSchema {} // eslint-disable-line
9 changes: 9 additions & 0 deletions libs/sage-monorepo/src/executors/about/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/schema",
"version": 2,
"title": "About executor",
"description": "",
"type": "object",
"properties": {},
"required": []
}
1 change: 1 addition & 0 deletions libs/sage-monorepo/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/sage-monorepo';
3 changes: 3 additions & 0 deletions libs/sage-monorepo/src/lib/sage-monorepo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function sageMonorepo(): string {
return 'sage-monorepo';
}
22 changes: 22 additions & 0 deletions libs/sage-monorepo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
10 changes: 10 additions & 0 deletions libs/sage-monorepo/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
9 changes: 9 additions & 0 deletions libs/sage-monorepo/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
}
5 changes: 5 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/tools/eslint-rules/**/*"
]
},
"@nx/js:tsc": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
}
},
"namedInputs": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"ibm-openapi-validator": "1.7.0",
"jest": "29.4.3",
"jest-environment-jsdom": "29.4.3",
"jest-environment-node": "^29.4.1",
"jest-preset-angular": "14.0.3",
"jsonc-eslint-parser": "2.1.0",
"ng-packagr": "17.2.1",
Expand Down
83 changes: 63 additions & 20 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,89 @@
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2017", "dom"],
"lib": [
"es2017",
"dom"
],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"baseUrl": ".",
"paths": {
"@sagebionetworks/openchallenges/about": ["libs/openchallenges/about/src/index.ts"],
"@sagebionetworks/openchallenges/about": [
"libs/openchallenges/about/src/index.ts"
],
"@sagebionetworks/openchallenges/api-client-angular": [
"libs/openchallenges/api-client-angular/src/index.ts"
],
"@sagebionetworks/openchallenges/assets": ["libs/openchallenges/assets/src/index.ts"],
"@sagebionetworks/openchallenges/auth": ["libs/openchallenges/auth/src/index.ts"],
"@sagebionetworks/openchallenges/challenge": ["libs/openchallenges/challenge/src/index.ts"],
"@sagebionetworks/openchallenges/assets": [
"libs/openchallenges/assets/src/index.ts"
],
"@sagebionetworks/openchallenges/auth": [
"libs/openchallenges/auth/src/index.ts"
],
"@sagebionetworks/openchallenges/challenge": [
"libs/openchallenges/challenge/src/index.ts"
],
"@sagebionetworks/openchallenges/challenge-search": [
"libs/openchallenges/challenge-search/src/index.ts"
],
"@sagebionetworks/openchallenges/config": ["libs/openchallenges/config/src/index.ts"],
"@sagebionetworks/openchallenges/home": ["libs/openchallenges/home/src/index.ts"],
"@sagebionetworks/openchallenges/login": ["libs/openchallenges/login/src/index.ts"],
"@sagebionetworks/openchallenges/not-found": ["libs/openchallenges/not-found/src/index.ts"],
"@sagebionetworks/openchallenges/config": [
"libs/openchallenges/config/src/index.ts"
],
"@sagebionetworks/openchallenges/home": [
"libs/openchallenges/home/src/index.ts"
],
"@sagebionetworks/openchallenges/login": [
"libs/openchallenges/login/src/index.ts"
],
"@sagebionetworks/openchallenges/not-found": [
"libs/openchallenges/not-found/src/index.ts"
],
"@sagebionetworks/openchallenges/org-profile": [
"libs/openchallenges/org-profile/src/index.ts"
],
"@sagebionetworks/openchallenges/org-search": ["libs/openchallenges/org-search/src/index.ts"],
"@sagebionetworks/openchallenges/pages": ["libs/openchallenges/pages/src/index.ts"],
"@sagebionetworks/openchallenges/signup": ["libs/openchallenges/signup/src/index.ts"],
"@sagebionetworks/openchallenges/styles": ["libs/openchallenges/styles/src/index.ts"],
"@sagebionetworks/openchallenges/team": ["libs/openchallenges/team/src/index.ts"],
"@sagebionetworks/openchallenges/themes": ["libs/openchallenges/themes/src/index.ts"],
"@sagebionetworks/openchallenges/ui": ["libs/openchallenges/ui/src/index.ts"],
"@sagebionetworks/openchallenges/org-search": [
"libs/openchallenges/org-search/src/index.ts"
],
"@sagebionetworks/openchallenges/pages": [
"libs/openchallenges/pages/src/index.ts"
],
"@sagebionetworks/openchallenges/signup": [
"libs/openchallenges/signup/src/index.ts"
],
"@sagebionetworks/openchallenges/styles": [
"libs/openchallenges/styles/src/index.ts"
],
"@sagebionetworks/openchallenges/team": [
"libs/openchallenges/team/src/index.ts"
],
"@sagebionetworks/openchallenges/themes": [
"libs/openchallenges/themes/src/index.ts"
],
"@sagebionetworks/openchallenges/ui": [
"libs/openchallenges/ui/src/index.ts"
],
"@sagebionetworks/openchallenges/user-profile": [
"libs/openchallenges/user-profile/src/index.ts"
],
"@sagebionetworks/openchallenges/util": ["libs/openchallenges/util/src/index.ts"],
"@sagebionetworks/shared/util": ["libs/shared/typescript/util/src/index.ts"],
"@sagebionetworks/openchallenges/util": [
"libs/openchallenges/util/src/index.ts"
],
"@sagebionetworks/shared/util": [
"libs/shared/typescript/util/src/index.ts"
],
"@sagebionetworks/shared/web-components": [
"libs/shared/typescript/web-components/src/index.ts"
],
"@sagebionetworks/sage-monorepo": [
"libs/sage-monorepo/src/index.ts"
]
}
},
"exclude": ["node_modules", "tmp"]
}
"exclude": [
"node_modules",
"tmp"
]
}
Loading
Loading