feat(logging): Enhance logging and module publishing with color-coded output, progress tracking, and improved CLI startup
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
import { logger } from './logging.js';
|
||||
import { logger, logInfo, logSuccess, logWarn, logError, logBuild, logPublish, logOngoing, logStart, logDone } from './logging.js';
|
||||
|
||||
import { type ITsPublishJson } from './interfaces/index.js';
|
||||
import type { TsPublish } from './classes.tspublish.js';
|
||||
@@ -66,16 +66,15 @@ export class PublishModule {
|
||||
try {
|
||||
packageInfo = await smartnpmInstance.getPackageInfo(this.options.name);
|
||||
} catch (error) {
|
||||
logger.log('warn', `package does not yet seem to exist. Proceeding in 10 seconds...`);
|
||||
logWarn(`Package ${this.options.name} does not yet seem to exist. Proceeding in 10 seconds...`);
|
||||
await plugins.smartdelay.delayFor(10000);
|
||||
}
|
||||
if (packageInfo) {
|
||||
const availableVersions = packageInfo.allVersions.map((versionArg) => versionArg.version);
|
||||
logger.log('info', `available versions are: ${availableVersions.toString()}`);
|
||||
logInfo(`Available versions for ${this.options.name}: ${availableVersions.join(', ')}`);
|
||||
if (availableVersions.includes(this.options.version)) {
|
||||
logger.log(
|
||||
'error',
|
||||
`package ${this.options.name} already exists with version ${this.options.version}`
|
||||
logError(
|
||||
`Package ${this.options.name} already exists with version ${this.options.version}`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -162,6 +161,7 @@ export class PublishModule {
|
||||
}
|
||||
|
||||
public async createPublishModuleDir() {
|
||||
logOngoing(`Creating publish directory for ${this.options.name}`);
|
||||
this.options.publishModDirFullPath = plugins.path.join(
|
||||
this.options.monoRepoDir,
|
||||
`dist_publish_${this.options.packageSubFolder}`
|
||||
@@ -207,10 +207,12 @@ export class PublishModule {
|
||||
}
|
||||
|
||||
public async build() {
|
||||
logBuild(`Building ${this.options.name}...`);
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
});
|
||||
await smartshellInstance.exec(`cd ${this.options.publishModDirFullPath} && pnpm run build`);
|
||||
logSuccess(`Build completed for ${this.options.name}`);
|
||||
}
|
||||
|
||||
public async createBinCliSetup() {
|
||||
@@ -229,6 +231,7 @@ export class PublishModule {
|
||||
}
|
||||
|
||||
public async publish() {
|
||||
logPublish(`Publishing ${this.options.name} v${this.options.version}...`);
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
});
|
||||
@@ -242,5 +245,6 @@ export class PublishModule {
|
||||
} --no-git-checks --registry https://${registryUrl}`
|
||||
);
|
||||
}
|
||||
logSuccess(`Successfully published ${this.options.name} v${this.options.version}!`);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user