feat: improve monorepo dev experience

This commit is contained in:
2023-10-27 22:45:44 +02:00
parent f618725598
commit c6ab4ae48b
124 changed files with 2647 additions and 2857 deletions

View File

@@ -0,0 +1,76 @@
{
"name": "@openstapps/tsup-plugin",
"description": "Validator for @openstapps/core",
"version": "3.0.0",
"type": "module",
"license": "GPL-3.0-only",
"repository": "git@gitlab.com:openstapps/openstapps.git",
"author": "Thea Schöbl <dev@theaninova.de>",
"keywords": [
"StApps",
"StAppsCore",
"converter",
"core",
"validator"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib",
"README.md",
"CHANGELOG.md"
],
"scripts": {
"build": "tsup-node --dts",
"docs": "typedoc --json ./docs/docs.json --options ../../typedoc.base.json src/index.ts",
"format": "prettier . -c --ignore-path ../../.gitignore",
"format:fix": "prettier --write . --ignore-path ../../.gitignore",
"lint": "eslint --ext .ts src/",
"lint:fix": "eslint --fix --ext .ts src/",
"test": "c8 mocha"
},
"dependencies": {
"colorette": "2.0.20"
},
"devDependencies": {
"@openstapps/eslint-config": "workspace:*",
"@openstapps/prettier-config": "workspace:*",
"@openstapps/tsconfig": "workspace:*",
"@types/chai": "4.3.5",
"@types/fs-extra": "9.0.13",
"@types/glob": "8.0.1",
"@types/json-schema": "7.0.14",
"@types/mocha": "10.0.1",
"@types/mustache": "4.2.2",
"@types/node": "18.15.3",
"c8": "7.14.0",
"chai": "4.3.7",
"esbuild": "0.17.19",
"mocha": "10.2.0",
"mocha-junit-reporter": "2.2.0",
"nock": "13.3.1",
"ts-node": "10.9.1",
"tsup": "6.7.0",
"typedoc": "0.24.8",
"typescript": "5.1.6"
},
"tsup": {
"entry": [
"src/app.ts",
"src/index.ts"
],
"sourcemap": true,
"clean": true,
"format": "esm",
"outDir": "lib"
},
"prettier": "@openstapps/prettier-config",
"eslintConfig": {
"extends": [
"@openstapps"
]
},
"eslintIgnore": [
"resources"
]
}

View File

@@ -0,0 +1,31 @@
import {Options} from 'tsup';
import {writeFile, stat} from 'fs/promises';
import {bold, green} from 'colorette';
type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[]
? ElementType
: never;
export type Plugin = ArrayElement<Required<Options>['plugins']>;
export type PluginContext = ThisParameterType<Required<Plugin>['buildEnd']>;
/**
* Utility function for generating files in a TSUp plugin
*/
export function generateFiles(
label: string,
build: (this: PluginContext) => Promise<Record<string, string | Buffer>>,
) {
return async function (this: PluginContext) {
this.logger.info(label, 'Build start');
const time = performance.now();
const result = await build.call(this);
this.logger.success(label, `⚡️ Build success in ${Math.floor(performance.now() - time)}ms`);
for (const file in result) {
const filePath = `${this.options.outDir}/${file}`;
await writeFile(filePath, result[file]);
const info = await stat(filePath);
this.logger.success(label, bold(filePath), green(`${(info.size / 1000).toFixed(2)} KB`));
}
};
}

View File

@@ -0,0 +1,3 @@
{
"extends": "@openstapps/tsconfig"
}