Skip to content

Commit

Permalink
setup: add wrapper superturbo for turbo to set some default values
Browse files Browse the repository at this point in the history
  • Loading branch information
pkerschbaum committed Oct 22, 2023
1 parent b488972 commit 0815c80
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm exec turbo build lint
pnpm exec superturbo build lint
pnpm lint-staged
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
"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/[email protected]\" dlx create-pnpm-patch-via-ts-patch --typescript-version=5.2.2"
},
"devDependencies": {
"@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",
Expand Down
14 changes: 14 additions & 0 deletions platform/superturbo/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -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',
},
};
10 changes: 10 additions & 0 deletions platform/superturbo/lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @ts-check
import {
baseConfig,
jsConfig,
} from '@pkerschbaum-homepage/config-lint-staged/lint-staged-base.mjs';

export default {
...baseConfig,
...jsConfig,
};
38 changes: 38 additions & 0 deletions platform/superturbo/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
35 changes: 35 additions & 0 deletions platform/superturbo/src/turbo-wrapper.mjs
Original file line number Diff line number Diff line change
@@ -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;
}
});
20 changes: 20 additions & 0 deletions platform/superturbo/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -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"]
}
14 changes: 14 additions & 0 deletions platform/superturbo/tsconfig.project.json
Original file line number Diff line number Diff line change
@@ -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"]
}
45 changes: 45 additions & 0 deletions platform/superturbo/turbo.json
Original file line number Diff line number Diff line change
@@ -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/**"]
}
}
}
48 changes: 48 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit 0815c80

@vercel
Copy link

@vercel vercel bot commented on 0815c80 Oct 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.