diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 02863fe305..965933caeb 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,4 +1,3 @@ { - // Extensions should be defined in `.devcontainer/devcontainer.json` instead of here. - "recommendations": [] -} \ No newline at end of file + "recommendations": ["esbenp.prettier-vscode", "firsttris.vscode-jest-runner"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 59482ff773..45bdb10c59 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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 @@ -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": [ diff --git a/libs/openchallenges/api-description/project.json b/libs/openchallenges/api-description/project.json index 719c1fa258..314e12df8d 100644 --- a/libs/openchallenges/api-description/project.json +++ b/libs/openchallenges/api-description/project.json @@ -45,6 +45,9 @@ "options": { "command": "prettier --check {projectRoot}" } + }, + "about": { + "executor": "@sagebionetworks/sage-monorepo:about" } }, "tags": [], diff --git a/libs/sage-monorepo/.eslintrc.json b/libs/sage-monorepo/.eslintrc.json new file mode 100644 index 0000000000..6b4ec01943 --- /dev/null +++ b/libs/sage-monorepo/.eslintrc.json @@ -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" + } + } + ] +} diff --git a/libs/sage-monorepo/README.md b/libs/sage-monorepo/README.md new file mode 100644 index 0000000000..76effa7cf3 --- /dev/null +++ b/libs/sage-monorepo/README.md @@ -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). diff --git a/libs/sage-monorepo/executors.json b/libs/sage-monorepo/executors.json new file mode 100644 index 0000000000..b800f7243e --- /dev/null +++ b/libs/sage-monorepo/executors.json @@ -0,0 +1,9 @@ +{ + "executors": { + "about": { + "implementation": "./src/executors/about/executor", + "schema": "./src/executors/about/schema.json", + "description": "about executor" + } + } +} diff --git a/libs/sage-monorepo/jest.config.ts b/libs/sage-monorepo/jest.config.ts new file mode 100644 index 0000000000..c990c000ed --- /dev/null +++ b/libs/sage-monorepo/jest.config.ts @@ -0,0 +1,11 @@ +/* eslint-disable */ +export default { + displayName: 'sage-monorepo', + preset: '../../jest.preset.js', + testEnvironment: 'node', + transform: { + '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../coverage/libs/sage-monorepo', +}; diff --git a/libs/sage-monorepo/package.json b/libs/sage-monorepo/package.json new file mode 100644 index 0000000000..cde10a07aa --- /dev/null +++ b/libs/sage-monorepo/package.json @@ -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" +} \ No newline at end of file diff --git a/libs/sage-monorepo/project.json b/libs/sage-monorepo/project.json new file mode 100644 index 0000000000..3f510ee047 --- /dev/null +++ b/libs/sage-monorepo/project.json @@ -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": [] +} diff --git a/libs/sage-monorepo/src/executors/about/executor.ts b/libs/sage-monorepo/src/executors/about/executor.ts new file mode 100644 index 0000000000..7b454f5a98 --- /dev/null +++ b/libs/sage-monorepo/src/executors/about/executor.ts @@ -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, + }; +} diff --git a/libs/sage-monorepo/src/executors/about/schema.d.ts b/libs/sage-monorepo/src/executors/about/schema.d.ts new file mode 100644 index 0000000000..258f4f8d48 --- /dev/null +++ b/libs/sage-monorepo/src/executors/about/schema.d.ts @@ -0,0 +1 @@ +export interface AboutExecutorSchema {} // eslint-disable-line diff --git a/libs/sage-monorepo/src/executors/about/schema.json b/libs/sage-monorepo/src/executors/about/schema.json new file mode 100644 index 0000000000..1579877681 --- /dev/null +++ b/libs/sage-monorepo/src/executors/about/schema.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://json-schema.org/schema", + "version": 2, + "title": "About executor", + "description": "", + "type": "object", + "properties": {}, + "required": [] +} diff --git a/libs/sage-monorepo/src/index.ts b/libs/sage-monorepo/src/index.ts new file mode 100644 index 0000000000..70abee0480 --- /dev/null +++ b/libs/sage-monorepo/src/index.ts @@ -0,0 +1 @@ +export * from './lib/sage-monorepo'; diff --git a/libs/sage-monorepo/src/lib/sage-monorepo.ts b/libs/sage-monorepo/src/lib/sage-monorepo.ts new file mode 100644 index 0000000000..b728043187 --- /dev/null +++ b/libs/sage-monorepo/src/lib/sage-monorepo.ts @@ -0,0 +1,3 @@ +export function sageMonorepo(): string { + return 'sage-monorepo'; +} diff --git a/libs/sage-monorepo/tsconfig.json b/libs/sage-monorepo/tsconfig.json new file mode 100644 index 0000000000..f5b85657a8 --- /dev/null +++ b/libs/sage-monorepo/tsconfig.json @@ -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" + } + ] +} diff --git a/libs/sage-monorepo/tsconfig.lib.json b/libs/sage-monorepo/tsconfig.lib.json new file mode 100644 index 0000000000..33eca2c2cd --- /dev/null +++ b/libs/sage-monorepo/tsconfig.lib.json @@ -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"] +} diff --git a/libs/sage-monorepo/tsconfig.spec.json b/libs/sage-monorepo/tsconfig.spec.json new file mode 100644 index 0000000000..f6d8ffcc9f --- /dev/null +++ b/libs/sage-monorepo/tsconfig.spec.json @@ -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"] +} diff --git a/nx.json b/nx.json index 3a6b1cdd03..ccd2d6ae5c 100644 --- a/nx.json +++ b/nx.json @@ -70,6 +70,11 @@ "{workspaceRoot}/.eslintrc.json", "{workspaceRoot}/tools/eslint-rules/**/*" ] + }, + "@nx/js:tsc": { + "cache": true, + "dependsOn": ["^build"], + "inputs": ["production", "^production"] } }, "namedInputs": { diff --git a/package.json b/package.json index f57d3f002e..67995e21bb 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tsconfig.base.json b/tsconfig.base.json index a6192bd034..fc664ba5a0 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -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" + ] +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 9f92902531..4952619f87 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4889,6 +4889,18 @@ __metadata: languageName: node linkType: hard +"@jest/environment@npm:^29.7.0": + version: 29.7.0 + resolution: "@jest/environment@npm:29.7.0" + dependencies: + "@jest/fake-timers": ^29.7.0 + "@jest/types": ^29.6.3 + "@types/node": "*" + jest-mock: ^29.7.0 + checksum: 6fb398143b2543d4b9b8d1c6dbce83fa5247f84f550330604be744e24c2bd2178bb893657d62d1b97cf2f24baf85c450223f8237cccb71192c36a38ea2272934 + languageName: node + linkType: hard + "@jest/expect-utils@npm:^29.6.2": version: 29.6.2 resolution: "@jest/expect-utils@npm:29.6.2" @@ -4922,6 +4934,20 @@ __metadata: languageName: node linkType: hard +"@jest/fake-timers@npm:^29.7.0": + version: 29.7.0 + resolution: "@jest/fake-timers@npm:29.7.0" + dependencies: + "@jest/types": ^29.6.3 + "@sinonjs/fake-timers": ^10.0.2 + "@types/node": "*" + jest-message-util: ^29.7.0 + jest-mock: ^29.7.0 + jest-util: ^29.7.0 + checksum: caf2bbd11f71c9241b458d1b5a66cbe95debc5a15d96442444b5d5c7ba774f523c76627c6931cca5e10e76f0d08761f6f1f01a608898f4751a0eee54fc3d8d00 + languageName: node + linkType: hard + "@jest/globals@npm:^29.6.2": version: 29.6.2 resolution: "@jest/globals@npm:29.6.2" @@ -5061,6 +5087,20 @@ __metadata: languageName: node linkType: hard +"@jest/types@npm:^29.6.3": + version: 29.6.3 + resolution: "@jest/types@npm:29.6.3" + dependencies: + "@jest/schemas": ^29.6.3 + "@types/istanbul-lib-coverage": ^2.0.0 + "@types/istanbul-reports": ^3.0.0 + "@types/node": "*" + "@types/yargs": ^17.0.8 + chalk: ^4.0.0 + checksum: a0bcf15dbb0eca6bdd8ce61a3fb055349d40268622a7670a3b2eb3c3dbafe9eb26af59938366d520b86907b9505b0f9b29b85cec11579a9e580694b87cd90fcc + languageName: node + linkType: hard + "@jridgewell/gen-mapping@npm:^0.3.0, @jridgewell/gen-mapping@npm:^0.3.2": version: 0.3.3 resolution: "@jridgewell/gen-mapping@npm:0.3.3" @@ -18345,6 +18385,20 @@ __metadata: languageName: node linkType: hard +"jest-environment-node@npm:^29.4.1": + version: 29.7.0 + resolution: "jest-environment-node@npm:29.7.0" + dependencies: + "@jest/environment": ^29.7.0 + "@jest/fake-timers": ^29.7.0 + "@jest/types": ^29.6.3 + "@types/node": "*" + jest-mock: ^29.7.0 + jest-util: ^29.7.0 + checksum: 501a9966292cbe0ca3f40057a37587cb6def25e1e0c5e39ac6c650fe78d3c70a2428304341d084ac0cced5041483acef41c477abac47e9a290d5545fd2f15646 + languageName: node + linkType: hard + "jest-environment-node@npm:^29.6.2": version: 29.6.2 resolution: "jest-environment-node@npm:29.6.2" @@ -18435,6 +18489,23 @@ __metadata: languageName: node linkType: hard +"jest-message-util@npm:^29.7.0": + version: 29.7.0 + resolution: "jest-message-util@npm:29.7.0" + dependencies: + "@babel/code-frame": ^7.12.13 + "@jest/types": ^29.6.3 + "@types/stack-utils": ^2.0.0 + chalk: ^4.0.0 + graceful-fs: ^4.2.9 + micromatch: ^4.0.4 + pretty-format: ^29.7.0 + slash: ^3.0.0 + stack-utils: ^2.0.3 + checksum: a9d025b1c6726a2ff17d54cc694de088b0489456c69106be6b615db7a51b7beb66788bea7a59991a019d924fbf20f67d085a445aedb9a4d6760363f4d7d09930 + languageName: node + linkType: hard + "jest-mock@npm:^29.4.3, jest-mock@npm:^29.6.2": version: 29.6.2 resolution: "jest-mock@npm:29.6.2" @@ -18446,6 +18517,17 @@ __metadata: languageName: node linkType: hard +"jest-mock@npm:^29.7.0": + version: 29.7.0 + resolution: "jest-mock@npm:29.7.0" + dependencies: + "@jest/types": ^29.6.3 + "@types/node": "*" + jest-util: ^29.7.0 + checksum: 81ba9b68689a60be1482212878973700347cb72833c5e5af09895882b9eb5c4e02843a1bbdf23f94c52d42708bab53a30c45a3482952c9eec173d1eaac5b86c5 + languageName: node + linkType: hard + "jest-pnp-resolver@npm:^1.2.2": version: 1.2.3 resolution: "jest-pnp-resolver@npm:1.2.3" @@ -18618,6 +18700,20 @@ __metadata: languageName: node linkType: hard +"jest-util@npm:^29.7.0": + version: 29.7.0 + resolution: "jest-util@npm:29.7.0" + dependencies: + "@jest/types": ^29.6.3 + "@types/node": "*" + chalk: ^4.0.0 + ci-info: ^3.2.0 + graceful-fs: ^4.2.9 + picomatch: ^2.2.3 + checksum: 042ab4980f4ccd4d50226e01e5c7376a8556b472442ca6091a8f102488c0f22e6e8b89ea874111d2328a2080083bf3225c86f3788c52af0bd0345a00eb57a3ca + languageName: node + linkType: hard + "jest-validate@npm:^29.6.2": version: 29.6.2 resolution: "jest-validate@npm:29.6.2" @@ -25054,6 +25150,7 @@ __metadata: 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 keycloak-angular: 12.1.0