mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-03-08 07:42:34 +00:00
feat: improve monorepo dev experience
This commit is contained in:
76
packages/tsup-plugin/package.json
Normal file
76
packages/tsup-plugin/package.json
Normal 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"
|
||||
]
|
||||
}
|
||||
31
packages/tsup-plugin/src/index.ts
Normal file
31
packages/tsup-plugin/src/index.ts
Normal 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`));
|
||||
}
|
||||
};
|
||||
}
|
||||
3
packages/tsup-plugin/tsconfig.json
Normal file
3
packages/tsup-plugin/tsconfig.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "@openstapps/tsconfig"
|
||||
}
|
||||
Reference in New Issue
Block a user