feat(mod_format): Add support for tsconfig.json formatting

This commit is contained in:
Philipp Kunz 2024-10-27 01:51:17 +02:00
parent 74f4cb3034
commit 00f06b48f3
7 changed files with 95 additions and 42 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## 2024-10-27 - 1.10.0 - feat(mod_format)
Add support for tsconfig.json formatting
- Added a new script to format tsconfig.json.
- Updated package.json to include `@git.zone/tspublish` as a dependency.
## 2024-10-23 - 1.9.126 - fix(format)
Remove redundant package.json property checks

View File

@ -55,10 +55,11 @@
"@git.zone/tsbuild": "^2.1.84",
"@git.zone/tsrun": "^1.2.49",
"@git.zone/tstest": "^1.0.90",
"@types/node": "^22.7.4"
"@types/node": "^22.8.1"
},
"dependencies": {
"@git.zone/tsdoc": "^1.3.12",
"@git.zone/tspublish": "^1.4.0",
"@push.rocks/commitinfo": "^1.0.12",
"@push.rocks/early": "^4.0.4",
"@push.rocks/gulp-function": "^3.0.7",

93
pnpm-lock.yaml generated
View File

@ -8,6 +8,9 @@ dependencies:
'@git.zone/tsdoc':
specifier: ^1.3.12
version: 1.3.12
'@git.zone/tspublish':
specifier: ^1.4.0
version: 1.4.0
'@push.rocks/commitinfo':
specifier: ^1.0.12
version: 1.0.12
@ -105,13 +108,13 @@ devDependencies:
version: 2.1.84
'@git.zone/tsrun':
specifier: ^1.2.49
version: 1.2.49(@types/node@22.7.9)
version: 1.2.49(@types/node@22.8.1)
'@git.zone/tstest':
specifier: ^1.0.90
version: 1.0.90(@types/node@22.7.9)
version: 1.0.90(@types/node@22.8.1)
'@types/node':
specifier: ^22.7.4
version: 22.7.9
specifier: ^22.8.1
version: 22.8.1
packages:
@ -578,13 +581,25 @@ packages:
- zod
dev: false
/@git.zone/tsrun@1.2.49(@types/node@22.7.9):
/@git.zone/tspublish@1.4.0:
resolution: {integrity: sha512-j+uiAAc3Cf0ATKBbkADI9PpdVr4ZyrAQ3b8QJHbPiYn7IPr+7RggXymgVCRRQokDZlQhgce8AqZwJyfdzFlGcA==}
hasBin: true
dependencies:
'@push.rocks/smartcli': 4.0.11
'@push.rocks/smartfile': 11.0.21
'@push.rocks/smartlog': 3.0.7
'@push.rocks/smartnpm': 2.0.4
'@push.rocks/smartpath': 5.0.18
'@push.rocks/smartshell': 3.0.6
dev: false
/@git.zone/tsrun@1.2.49(@types/node@22.8.1):
resolution: {integrity: sha512-RnUDdny6jAuuBLx7HqUE38JsHx9nnUUYkDM5vAOREoc6oCI9XVM0QeqIdwFmDz6eeDLBH1+yqjSQPoW5UvflJA==}
hasBin: true
dependencies:
'@push.rocks/smartfile': 11.0.21
'@push.rocks/smartshell': 3.0.6
ts-node: 10.9.2(@types/node@22.7.9)(typescript@5.5.2)
ts-node: 10.9.2(@types/node@22.8.1)(typescript@5.5.2)
typescript: 5.5.2
transitivePeerDependencies:
- '@swc/core'
@ -592,13 +607,13 @@ packages:
- '@types/node'
dev: true
/@git.zone/tstest@1.0.90(@types/node@22.7.9):
/@git.zone/tstest@1.0.90(@types/node@22.8.1):
resolution: {integrity: sha512-McytXK46GiReEps7wHWW6zOHYCFF4sywjj6auHjhGqzOogA2Wju1YtZRL+o+OAUb61kQxNFRras6Xg/4Zth0Bw==}
hasBin: true
dependencies:
'@api.global/typedserver': 3.0.51
'@git.zone/tsbundle': 2.0.15
'@git.zone/tsrun': 1.2.49(@types/node@22.7.9)
'@git.zone/tsrun': 1.2.49(@types/node@22.8.1)
'@push.rocks/consolecolor': 2.0.2
'@push.rocks/smartbrowser': 2.0.6
'@push.rocks/smartdelay': 3.0.5
@ -657,7 +672,7 @@ packages:
'@inquirer/figures': 1.0.7
'@inquirer/type': 2.0.0
'@types/mute-stream': 0.0.4
'@types/node': 22.7.9
'@types/node': 22.8.1
'@types/wrap-ansi': 3.0.0
ansi-escapes: 4.3.2
cli-width: 4.1.0
@ -2083,7 +2098,7 @@ packages:
/@types/accepts@1.3.7:
resolution: {integrity: sha512-Pay9fq2lM2wXPWbteBsRAGiWH2hig4ZE2asK+mm7kUzlxRTfL961rj89I6zV/E3PcIkDqyuBEcMxFT7rccugeQ==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
dev: true
/@types/babel__code-frame@7.0.6:
@ -2094,7 +2109,7 @@ packages:
resolution: {integrity: sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==}
dependencies:
'@types/connect': 3.4.38
'@types/node': 22.7.9
'@types/node': 22.8.1
/@types/buffer-json@2.0.3:
resolution: {integrity: sha512-ItD4UfF3Q5jA+PEV6ZUWEHvlWaXJbd0rpuBKOIrEebM053FHaJddKsgUf0vy7nLSTs44nqFj3Mh8J3TiT0xv4g==}
@ -2116,21 +2131,21 @@ packages:
/@types/clean-css@4.2.11:
resolution: {integrity: sha512-Y8n81lQVTAfP2TOdtJJEsCoYl1AnOkqDqMvXb9/7pfgZZ7r8YrEyurrAvAoAjHOGXKRybay+5CsExqIH6liccw==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
source-map: 0.6.1
dev: true
/@types/co-body@6.1.3:
resolution: {integrity: sha512-UhuhrQ5hclX6UJctv5m4Rfp52AfG9o9+d9/HwjxhVB5NjXxr5t9oKgJxN8xRHgr35oo8meUEHUPFWiKg6y71aA==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
'@types/qs': 6.9.16
dev: true
/@types/connect@3.4.38:
resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
/@types/content-disposition@0.5.8:
resolution: {integrity: sha512-QVSSvno3dE0MgO76pJhmv4Qyi/j0Yk9pBp0Y7TJ2Tlj+KCgJWY6qX7nnxCOLkZ3VYRSIk1WTxCvwUSdx6CCLdg==}
@ -2150,13 +2165,13 @@ packages:
'@types/connect': 3.4.38
'@types/express': 5.0.0
'@types/keygrip': 1.0.6
'@types/node': 22.7.9
'@types/node': 22.8.1
dev: true
/@types/cors@2.8.17:
resolution: {integrity: sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
dev: true
/@types/debounce@1.2.4:
@ -2178,7 +2193,7 @@ packages:
/@types/express-serve-static-core@4.19.6:
resolution: {integrity: sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
'@types/qs': 6.9.16
'@types/range-parser': 1.2.7
'@types/send': 0.17.4
@ -2186,7 +2201,7 @@ packages:
/@types/express-serve-static-core@5.0.0:
resolution: {integrity: sha512-AbXMTZGt40T+KON9/Fdxx0B2WK5hsgxcfXJLr5bFpZ7b4JCex2WyQPTEKdXqfHiY5nKKBScZ7yCoO6Pvgxfvnw==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
'@types/qs': 6.9.16
'@types/range-parser': 1.2.7
'@types/send': 0.17.4
@ -2212,25 +2227,25 @@ packages:
/@types/from2@2.3.5:
resolution: {integrity: sha512-giavnjf3kNlJnE+HpZA1CQ3UKHxgehzsTuIMGda8pGMbOiLYGVNADEskey44OZcADHm/HOoBany8IV+0x28XFw==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
dev: false
/@types/fs-extra@11.0.4:
resolution: {integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==}
dependencies:
'@types/jsonfile': 6.1.4
'@types/node': 22.7.9
'@types/node': 22.8.1
/@types/glob@8.1.0:
resolution: {integrity: sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==}
dependencies:
'@types/minimatch': 5.1.2
'@types/node': 22.7.9
'@types/node': 22.8.1
/@types/gunzip-maybe@1.4.2:
resolution: {integrity: sha512-2uqXZg1jTCKE1Pjbab8qb74+f2+i9h/jz8rQ+jRR+zaNJF75zWwrpbX8/TjF4m56m3KFOg9umHdCJ074KwiVxg==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
dev: false
/@types/hast@3.0.4:
@ -2281,7 +2296,7 @@ packages:
/@types/jsonfile@6.1.4:
resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
/@types/keygrip@1.0.6:
resolution: {integrity: sha512-lZuNAY9xeJt7Bx4t4dx0rYCDqGPW8RXhQZK1td7d4H6E9zYbLoOtjBvfwdTKpsyxQI/2jv+armjX/RW+ZNpXOQ==}
@ -2303,7 +2318,7 @@ packages:
'@types/http-errors': 2.0.4
'@types/keygrip': 1.0.6
'@types/koa-compose': 3.2.8
'@types/node': 22.7.9
'@types/node': 22.8.1
dev: true
/@types/mdast@4.0.4:
@ -2336,20 +2351,20 @@ packages:
/@types/mute-stream@0.0.4:
resolution: {integrity: sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
dev: false
/@types/node-fetch@2.6.11:
resolution: {integrity: sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
form-data: 4.0.1
dev: false
/@types/node-forge@1.3.11:
resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
dev: true
/@types/node@18.19.59:
@ -2358,8 +2373,8 @@ packages:
undici-types: 5.26.5
dev: false
/@types/node@22.7.9:
resolution: {integrity: sha512-jrTfRC7FM6nChvU7X2KqcrgquofrWLFDeYC1hKfwNWomVvrn7JIksqf344WN2X/y8xrgqBd2dJATZV4GbatBfg==}
/@types/node@22.8.1:
resolution: {integrity: sha512-k6Gi8Yyo8EtrNtkHXutUu2corfDf9su95VYVP10aGYMMROM6SAItZi0w1XszA6RtWTHSVp5OeFof37w0IEqCQg==}
dependencies:
undici-types: 6.19.8
@ -2391,13 +2406,13 @@ packages:
resolution: {integrity: sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==}
dependencies:
'@types/mime': 1.3.5
'@types/node': 22.7.9
'@types/node': 22.8.1
/@types/serve-static@1.15.7:
resolution: {integrity: sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==}
dependencies:
'@types/http-errors': 2.0.4
'@types/node': 22.7.9
'@types/node': 22.8.1
'@types/send': 0.17.4
/@types/sinon-chai@3.2.12:
@ -2423,13 +2438,13 @@ packages:
/@types/tar-stream@2.2.3:
resolution: {integrity: sha512-if3mugZfjVkXOMZdFjIHySxY13r6GXPpyOlsDmLffvyI7tLz9wXE8BFjNivXsvUeyJ1KNlOpfLnag+ISmxgxPw==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
dev: false
/@types/through2@2.0.41:
resolution: {integrity: sha512-ryQ0tidWkb1O1JuYvWKyMLYEtOWDqF5mHerJzKz/gQpoAaJq2l/dsMPBF0B5BNVT34rbARYJ5/tsZwLfUi2kwQ==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
/@types/trusted-types@2.0.7:
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
@ -2463,20 +2478,20 @@ packages:
/@types/ws@7.4.7:
resolution: {integrity: sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
dev: true
/@types/ws@8.5.12:
resolution: {integrity: sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==}
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
dev: true
/@types/yauzl@2.10.3:
resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==}
requiresBuild: true
dependencies:
'@types/node': 22.7.9
'@types/node': 22.8.1
optional: true
/@ungap/structured-clone@1.2.0:
@ -3352,7 +3367,7 @@ packages:
dependencies:
'@types/cookie': 0.4.1
'@types/cors': 2.8.17
'@types/node': 22.7.9
'@types/node': 22.8.1
accepts: 1.3.8
base64id: 2.0.0
cookie: 0.4.2
@ -6328,7 +6343,7 @@ packages:
/trough@2.2.0:
resolution: {integrity: sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==}
/ts-node@10.9.2(@types/node@22.7.9)(typescript@5.5.2):
/ts-node@10.9.2(@types/node@22.8.1)(typescript@5.5.2):
resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==}
hasBin: true
peerDependencies:
@ -6347,7 +6362,7 @@ packages:
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3
'@tsconfig/node16': 1.0.4
'@types/node': 22.7.9
'@types/node': 22.8.1
acorn: 8.13.0
acorn-walk: 8.3.4
arg: 4.1.3

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/cli',
version: '1.9.126',
version: '1.10.0',
description: 'A CLI toolbelt to streamline local development cycles by using various gitzone utilities.'
}

View File

@ -5,6 +5,12 @@ import * as paths from '../paths.js';
import { logger } from '../gitzone.logging.js';
export const run = async (argvArg: any) => {
if (argvArg.format) {
const formatMod = await import('../mod_format/index.js');
await formatMod.run();
}
logger.log('info', `gathering facts...`);
const aidoc = new plugins.tsdoc.AiDoc();
await aidoc.start();

View File

@ -0,0 +1,23 @@
import * as plugins from './mod.plugins.js';
import * as paths from '../paths.js';
import { logger } from '../gitzone.logging.js';
import { Project } from '../classes.project.js';
export const run = async (projectArg: Project) => {
// lets care about tsconfig.json
const tsconfigSmartfile = await plugins.smartfile.SmartFile.fromFilePath(plugins.path.join(paths.cwd, 'tsconfig.json'));
const tsconfigObject = JSON.parse(tsconfigSmartfile.contentBuffer.toString());
tsconfigObject.compilerOptions = tsconfigObject.compilerOptions || {};
tsconfigObject.compilerOptions.baseUrl = '.';
tsconfigObject.compilerOptions.paths = {};
const tsPublishMod = await import('@git.zone/tspublish');
const tsPublishInstance = new tsPublishMod.TsPublish();
const publishModules = tsPublishInstance.getModuleSubDirs(paths.cwd);
for (const publishModule of Object.keys(publishModules)) {
const publishConfig = publishModules[publishModule];
tsconfigObject.compilerOptions.paths[`${publishConfig.moduleName}`] = [`./${publishModule}/index.ts`];
}
tsconfigSmartfile.setContentsFromString(JSON.stringify(tsconfigObject, null, 2));
await tsconfigSmartfile.write();
};

View File

@ -1,7 +1,7 @@
import * as plugins from './mod.plugins.js';
import { Project } from '../classes.project.js';
export let run = async (write: boolean = true): Promise<any> => {
export let run = async (writeArg: boolean = true): Promise<any> => {
const project = await Project.fromCwd();
// cleanup
@ -31,6 +31,8 @@ export let run = async (write: boolean = true): Promise<any> => {
// format TypeScript
const formatPrettier = await import('./format.prettier.js');
await formatPrettier.run(project);
const formatTsConfig = await import('./format.tsconfig.js');
await formatTsConfig.run(project);
// format readme.md
const formatReadme = await import('./format.readme.js');