feat(logging): Enhance logging and module publishing with color-coded output, progress tracking, and improved CLI startup
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { logger } from './logging.js';
|
||||
import { logger, logInfo, logSuccess, logWarn, logError, logHeader, logPackage, logProgress, logSeparator, logStart, logDone } from './logging.js';
|
||||
import * as plugins from './plugins.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
|
||||
@@ -15,24 +15,26 @@ export class TsPublish {
|
||||
}
|
||||
|
||||
public async publish(monorepoDirArg: string) {
|
||||
logHeader('TSPublish - Module Publisher');
|
||||
const publishModules = await this.getModuleSubDirs(monorepoDirArg);
|
||||
logger.log('info', `Found ${Object.keys(publishModules).length} publish modules:`);
|
||||
logInfo(`Found ${Object.keys(publishModules).length} publish modules`);
|
||||
logSeparator();
|
||||
for (const publishModule of Object.keys(publishModules)) {
|
||||
logger.log(
|
||||
'info',
|
||||
`Publishing module: ${publishModule} -> ${publishModules[publishModule].name}`
|
||||
);
|
||||
logPackage('Module found', `${publishModule} → ${publishModules[publishModule].name}`);
|
||||
}
|
||||
for (const publishModule of Object.keys(publishModules)) {
|
||||
// lets check wether there is a name
|
||||
if (!publishModules[publishModule].name) {
|
||||
logger.log('warn', `no name found in tspublish.json for ${publishModule}. Skipping...`);
|
||||
logWarn(`No name found in tspublish.json for ${publishModule}. Skipping...`);
|
||||
continue;
|
||||
}
|
||||
const publishModuleInstance = new PublishModule(this, {
|
||||
monoRepoDir: monorepoDirArg,
|
||||
packageSubFolder: publishModule,
|
||||
});
|
||||
const moduleCount = Object.keys(publishModules).indexOf(publishModule) + 1;
|
||||
const totalCount = Object.keys(publishModules).length;
|
||||
logProgress(moduleCount, totalCount, publishModules[publishModule].name || publishModule);
|
||||
await publishModuleInstance.init();
|
||||
await publishModuleInstance.createPublishModuleDir();
|
||||
await publishModuleInstance.build();
|
||||
@@ -53,13 +55,13 @@ export class TsPublish {
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.log('info', `found publish module: ${subDir}`);
|
||||
logPackage('Found module', subDir);
|
||||
publishModules[subDir] = JSON.parse(
|
||||
plugins.smartfile.fs.toStringSync(plugins.path.join(subDir, 'tspublish.json'))
|
||||
);
|
||||
}
|
||||
logger.log('ok', `found ${Object.keys(publishModules).length} publish modules`);
|
||||
logger.log('info', `Ordering publish modules...`);
|
||||
logSuccess(`Found ${Object.keys(publishModules).length} publish modules`);
|
||||
logInfo('Ordering publish modules...');
|
||||
|
||||
return publishModules;
|
||||
}
|
||||
|
Reference in New Issue
Block a user