diff --git a/.husky/pre-commit b/.husky/pre-commit index c33bdfb..fcc9aa1 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,5 +1,5 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -pnpm exec turbo build lint +pnpm exec superturbo build lint pnpm lint-staged diff --git a/package.json b/package.json index 6cefee7..1c20c5d 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,10 @@ "nuke:artifacts": "pnpm --parallel run nuke:artifacts", "nuke:compute-cache": "del-cli \"*/**/.turbo\"", "nuke:node-modules": "del-cli \"**/node_modules\"", - "lint": "turbo lint", - "lint:fix": "turbo lint:fix", + "lint": "superturbo lint", + "lint:fix": "superturbo lint:fix", "format": "prettier --write --ignore-unknown .", - "build": "turbo build", + "build": "superturbo build", "dev": "pnpm --parallel --filter=\"./packages/*\" run dev", "create-pnpm-patch-via-ts-patch": "pnpm --package=\"@pkerschbaum/pkg-management@1.1.1\" dlx create-pnpm-patch-via-ts-patch --typescript-version=5.2.2" }, @@ -18,6 +18,7 @@ "@pkerschbaum-homepage/config-eslint": "workspace:*", "@pkerschbaum-homepage/config-stylelint": "workspace:*", "@pkerschbaum-homepage/config-typescript": "workspace:*", + "@pkerschbaum-homepage/superturbo": "workspace:*", "del-cli": "^5.1.0", "husky": "^8.0.3", "lint-staged": "^15.0.2", diff --git a/platform/superturbo/.eslintrc.cjs b/platform/superturbo/.eslintrc.cjs new file mode 100644 index 0000000..9872fe6 --- /dev/null +++ b/platform/superturbo/.eslintrc.cjs @@ -0,0 +1,14 @@ +// @ts-check +const baseEslintConfig = require('@pkerschbaum-homepage/config-eslint/eslint-ecma.cjs'); + +module.exports = { + ...baseEslintConfig, + parserOptions: { + ...baseEslintConfig.parserOptions, + tsconfigRootDir: __dirname, + }, + rules: { + ...baseEslintConfig.rules, + 'n/no-process-env': 'off', + }, +}; diff --git a/platform/superturbo/lint-staged.config.mjs b/platform/superturbo/lint-staged.config.mjs new file mode 100644 index 0000000..8fc762c --- /dev/null +++ b/platform/superturbo/lint-staged.config.mjs @@ -0,0 +1,10 @@ +// @ts-check +import { + baseConfig, + jsConfig, +} from '@pkerschbaum-homepage/config-lint-staged/lint-staged-base.mjs'; + +export default { + ...baseConfig, + ...jsConfig, +}; diff --git a/platform/superturbo/package.json b/platform/superturbo/package.json new file mode 100644 index 0000000..3b52988 --- /dev/null +++ b/platform/superturbo/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pkerschbaum-homepage/superturbo", + "private": true, + "type": "module", + "bin": { + "superturbo": "./src/turbo-wrapper.mjs" + }, + "scripts": { + "internal:build:compile": "tsc -p ./tsconfig.build.json", + "nuke": "pnpm run nuke:artifacts && del-cli --dot=true node_modules", + "nuke:artifacts": "del-cli --dot=true *.tsbuildinfo", + "build": "pnpm run internal:build:compile", + "dev": "pnpm run internal:build:compile -w --preserveWatchOutput", + "lint": "pnpm run lint:js", + "lint:fix": "pnpm run lint:js:file . --fix", + "lint:js": "pnpm run lint:js:file .", + "lint:js:file": "eslint --max-warnings 0" + }, + "devDependencies": { + "@types/node": "^20.8.7", + "@typescript-eslint/eslint-plugin": "^6.8.0", + "@typescript-eslint/parser": "^6.8.0", + "eslint": "^8.52.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-code-import-patterns": "^3.0.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-import": "^2.28.1", + "eslint-plugin-n": "^16.2.0", + "eslint-plugin-only-warn": "^1.1.0", + "eslint-plugin-regexp": "^2.1.0", + "eslint-plugin-unicorn": "^48.0.1", + "typescript": "^5.2.2", + "typescript-transform-paths": "^3.4.6" + }, + "peerDependencies": { + "turbo": "^1.10.16" + } +} diff --git a/platform/superturbo/src/turbo-wrapper.mjs b/platform/superturbo/src/turbo-wrapper.mjs new file mode 100755 index 0000000..6c395e1 --- /dev/null +++ b/platform/superturbo/src/turbo-wrapper.mjs @@ -0,0 +1,35 @@ +#!/usr/bin/env node +/** + * this module is a simple wrapper for "turbo" which + * - if no explicit "concurrency" is given, sets a default of 100% (to utilize all logical processors, see https://turbo.build/repo/docs/reference/command-line-reference/run#--concurrency) + * - and sets some default CLI arguments (e.g. "--env-mode=strict") + */ +import { spawn } from 'node:child_process'; +import { argv } from 'node:process'; +import url from 'node:url'; + +const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); + +const [_execPath, _jsFilePath, ...commandLineArguments] = argv; + +commandLineArguments.push( + '--no-update-notifier', + '--env-mode=strict', + '--framework-inference=false', +); + +if (!commandLineArguments.some((arg) => arg.startsWith('--concurrency'))) { + commandLineArguments.push('--concurrency=100%'); +} + +spawn('turbo', commandLineArguments, { + cwd: process.cwd(), + stdio: 'inherit', + env: process.env, + // set shell to true for windows (https://stackoverflow.com/a/54515183) + shell: process.platform === 'win32', +}).on('exit', (code) => { + if (code !== null) { + process.exitCode = code; + } +}); diff --git a/platform/superturbo/tsconfig.build.json b/platform/superturbo/tsconfig.build.json new file mode 100644 index 0000000..b2315d8 --- /dev/null +++ b/platform/superturbo/tsconfig.build.json @@ -0,0 +1,20 @@ +{ + "extends": "@pkerschbaum-homepage/config-typescript/tsconfig.json", + "compilerOptions": { + /* Modules */ + "module": "node16", + "types": ["node"], + "paths": { + "#pkg/*": ["./src/*"] + }, + "rootDir": "./src", + + /* Emit */ + "noEmit": true, + + /* JavaScript Support */ + "checkJs": true + }, + "include": ["src/**/*"], + "exclude": ["**/node_modules", "**/*.spec.ts"] +} diff --git a/platform/superturbo/tsconfig.project.json b/platform/superturbo/tsconfig.project.json new file mode 100644 index 0000000..2dccf75 --- /dev/null +++ b/platform/superturbo/tsconfig.project.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.build.json", + "compilerOptions": { + /* Modules */ + "paths": { + "#pkg/*": ["./src/*"], + "#pkg-test/*": ["./test/*"] + }, + "rootDir": null, + "rootDirs": ["./src", "./test"] + }, + "include": ["src/**/*", "test/**/*"], + "exclude": ["**/node_modules"] +} diff --git a/platform/superturbo/turbo.json b/platform/superturbo/turbo.json new file mode 100644 index 0000000..b76cdf5 --- /dev/null +++ b/platform/superturbo/turbo.json @@ -0,0 +1,45 @@ +{ + "$schema": "https://turbo.build/schema.json", + "extends": ["//"], + "pipeline": { + "build": { + "cache": true, + "inputs": [ + "../../platform/config-typescript/tsconfig.json", + "src/**", + "test/**", + "package.json", + "tsconfig.build.json" + ], + "outputs": ["*.tsbuildinfo"] + }, + "lint": { + "cache": true, + "inputs": [ + "../../platform/config-typescript/tsconfig.json", + "../../platform/config-eslint/eslint-ecma.cjs", + "src/**", + "test/**", + ".eslintrc.js", + "package.json", + "tsconfig.build.json", + "tsconfig.project.json" + ], + "outputs": [] + }, + "lint:fix": { + "cache": true, + "inputs": [ + "../../platform/config-typescript/tsconfig.json", + "../../platform/config-eslint/eslint-ecma.cjs", + "src/**", + "test/**", + ".eslintrc.js", + "package.json", + "tsconfig.build.json", + "tsconfig.project.json" + ], + "outputs": ["src/**", "test/**"] + } + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 97fb7cb..7b2248f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,6 +25,9 @@ importers: '@pkerschbaum-homepage/config-typescript': specifier: workspace:* version: link:platform/config-typescript + '@pkerschbaum-homepage/superturbo': + specifier: workspace:* + version: link:platform/superturbo del-cli: specifier: ^5.1.0 version: 5.1.0 @@ -304,6 +307,51 @@ importers: platform/config-typescript: {} + platform/superturbo: + devDependencies: + '@types/node': + specifier: ^20.8.7 + version: 20.8.7 + '@typescript-eslint/eslint-plugin': + specifier: ^6.8.0 + version: 6.8.0(@typescript-eslint/parser@6.8.0)(eslint@8.52.0)(typescript@5.2.2) + '@typescript-eslint/parser': + specifier: ^6.8.0 + version: 6.8.0(eslint@8.52.0)(typescript@5.2.2) + eslint: + specifier: ^8.52.0 + version: 8.52.0 + eslint-config-prettier: + specifier: ^9.0.0 + version: 9.0.0(eslint@8.52.0) + eslint-plugin-code-import-patterns: + specifier: ^3.0.0 + version: 3.0.0 + eslint-plugin-eslint-comments: + specifier: ^3.2.0 + version: 3.2.0(eslint@8.52.0) + eslint-plugin-import: + specifier: ^2.28.1 + version: 2.28.1(@typescript-eslint/parser@6.8.0)(eslint@8.52.0) + eslint-plugin-n: + specifier: ^16.2.0 + version: 16.2.0(eslint@8.52.0) + eslint-plugin-only-warn: + specifier: ^1.1.0 + version: 1.1.0 + eslint-plugin-regexp: + specifier: ^2.1.0 + version: 2.1.0(eslint@8.52.0) + eslint-plugin-unicorn: + specifier: ^48.0.1 + version: 48.0.1(eslint@8.52.0) + typescript: + specifier: ^5.2.2 + version: 5.2.2(patch_hash=ne7pl63axb4w5i5sendwnvsoyu) + typescript-transform-paths: + specifier: ^3.4.6 + version: 3.4.6(typescript@5.2.2) + packages: /@aashutoshrathi/word-wrap@1.2.6: