2024-10-26 23:51:17 +00:00
|
|
|
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
|
2024-10-27 00:13:12 +00:00
|
|
|
logger.log('info', 'Formatting tsconfig.json...');
|
2024-10-26 23:51:17 +00:00
|
|
|
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();
|
2024-10-27 00:09:04 +00:00
|
|
|
const publishModules = await tsPublishInstance.getModuleSubDirs(paths.cwd);
|
2024-10-26 23:51:17 +00:00
|
|
|
for (const publishModule of Object.keys(publishModules)) {
|
|
|
|
const publishConfig = publishModules[publishModule];
|
2024-11-05 00:57:39 +00:00
|
|
|
tsconfigObject.compilerOptions.paths[`${publishConfig.name}`] = [`./${publishModule}/index.js`];
|
2024-10-26 23:51:17 +00:00
|
|
|
}
|
|
|
|
tsconfigSmartfile.setContentsFromString(JSON.stringify(tsconfigObject, null, 2));
|
|
|
|
await tsconfigSmartfile.write();
|
|
|
|
};
|