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

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

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');