mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
feat: generator updates
This commit is contained in:
@@ -13,24 +13,24 @@
|
||||
"core",
|
||||
"validator"
|
||||
],
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"types": "src/types.d.ts",
|
||||
"main": "src/index.js",
|
||||
"files": [
|
||||
"lib",
|
||||
"README.md",
|
||||
"CHANGELOG.md"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup-node --dts",
|
||||
"docs": "typedoc --json ./docs/docs.json --options ../../typedoc.base.json src/index.ts",
|
||||
"docs": "typedoc --json ./docs/docs.json --options ../../typedoc.base.json src/index.js",
|
||||
"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/",
|
||||
"lint": "tsc --noEmit && eslint --ext .js src/",
|
||||
"lint:fix": "eslint --fix --ext .js src/",
|
||||
"test": "c8 mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"colorette": "2.0.20"
|
||||
"colorette": "2.0.20",
|
||||
"tsup": "7.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
@@ -49,21 +49,9 @@
|
||||
"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": [
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
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
|
||||
* @typedef {import('./types.js').PluginContext} PluginContext
|
||||
* @typedef {import('./types.js').Plugin} Plugin
|
||||
*
|
||||
* @param label {string}
|
||||
* @param build {(this: PluginContext) => Promise<Record<string, string | Buffer>>}
|
||||
* @returns {(this: PluginContext) => Promise<void>}
|
||||
*/
|
||||
export function generateFiles(
|
||||
label: string,
|
||||
build: (this: PluginContext) => Promise<Record<string, string | Buffer>>,
|
||||
) {
|
||||
return async function (this: PluginContext) {
|
||||
export function generateFiles(label, build) {
|
||||
return async function () {
|
||||
this.logger.info(label, 'Build start');
|
||||
const time = performance.now();
|
||||
const result = await build.call(this);
|
||||
10
packages/tsup-plugin/src/types.d.ts
vendored
Normal file
10
packages/tsup-plugin/src/types.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import {Options} from 'tsup';
|
||||
|
||||
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']>;
|
||||
|
||||
export {generateFiles} from './index.js';
|
||||
Reference in New Issue
Block a user