@git.zone/tspublish 1.9.1 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { logger } from './logging.js';
1
+ import { logger, logInfo, logSuccess, logWarn, logError, logHeader, logPackage, logProgress, logSeparator, logStart, logDone } from './logging.js';
2
2
  import * as plugins from './plugins.js';
3
3
  import * as interfaces from './interfaces/index.js';
4
4
 
@@ -15,24 +15,26 @@ export class TsPublish {
15
15
  }
16
16
 
17
17
  public async publish(monorepoDirArg: string) {
18
+ logHeader('TSPublish - Module Publisher');
18
19
  const publishModules = await this.getModuleSubDirs(monorepoDirArg);
19
- logger.log('info', `Found ${Object.keys(publishModules).length} publish modules:`);
20
+ logInfo(`Found ${Object.keys(publishModules).length} publish modules`);
21
+ logSeparator();
20
22
  for (const publishModule of Object.keys(publishModules)) {
21
- logger.log(
22
- 'info',
23
- `Publishing module: ${publishModule} -> ${publishModules[publishModule].name}`
24
- );
23
+ logPackage('Module found', `${publishModule} → ${publishModules[publishModule].name}`);
25
24
  }
26
25
  for (const publishModule of Object.keys(publishModules)) {
27
26
  // lets check wether there is a name
28
27
  if (!publishModules[publishModule].name) {
29
- logger.log('warn', `no name found in tspublish.json for ${publishModule}. Skipping...`);
28
+ logWarn(`No name found in tspublish.json for ${publishModule}. Skipping...`);
30
29
  continue;
31
30
  }
32
31
  const publishModuleInstance = new PublishModule(this, {
33
32
  monoRepoDir: monorepoDirArg,
34
33
  packageSubFolder: publishModule,
35
34
  });
35
+ const moduleCount = Object.keys(publishModules).indexOf(publishModule) + 1;
36
+ const totalCount = Object.keys(publishModules).length;
37
+ logProgress(moduleCount, totalCount, publishModules[publishModule].name || publishModule);
36
38
  await publishModuleInstance.init();
37
39
  await publishModuleInstance.createPublishModuleDir();
38
40
  await publishModuleInstance.build();
@@ -53,13 +55,13 @@ export class TsPublish {
53
55
  continue;
54
56
  }
55
57
 
56
- logger.log('info', `found publish module: ${subDir}`);
58
+ logPackage('Found module', subDir);
57
59
  publishModules[subDir] = JSON.parse(
58
60
  plugins.smartfile.fs.toStringSync(plugins.path.join(subDir, 'tspublish.json'))
59
61
  );
60
62
  }
61
- logger.log('ok', `found ${Object.keys(publishModules).length} publish modules`);
62
- logger.log('info', `Ordering publish modules...`);
63
+ logSuccess(`Found ${Object.keys(publishModules).length} publish modules`);
64
+ logInfo('Ordering publish modules...');
63
65
 
64
66
  return publishModules;
65
67
  }
package/ts/index.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import * as paths from './paths.js';
2
2
  import { TsPublish } from './classes.tspublish.js';
3
+ import { logStart } from './logging.js';
3
4
 
4
5
  export * from './classes.tspublish.js';
5
6
 
6
7
  export const runCli = async () => {
7
- console.log('Starting tspublish...');
8
+ logStart('tspublish');
8
9
  const tspublish = new TsPublish();
9
10
  await tspublish.publish(paths.cwd);
10
11
  };
package/ts/logging.ts CHANGED
@@ -3,3 +3,102 @@ import * as commitinfo from './00_commitinfo_data.js';
3
3
 
4
4
  export const logger = plugins.smartlog.Smartlog.createForCommitinfo(commitinfo.commitinfo);
5
5
  logger.enableConsole();
6
+
7
+ // Color-coded log level indicators
8
+ const logIcons = {
9
+ info: plugins.consolecolor.coloredString('ℹ', 'cyan'),
10
+ success: plugins.consolecolor.coloredString('✓', 'green'),
11
+ warn: plugins.consolecolor.coloredString('⚠', 'orange'),
12
+ error: plugins.consolecolor.coloredString('✖', 'red'),
13
+ start: plugins.consolecolor.coloredString('▶', 'blue'),
14
+ done: plugins.consolecolor.coloredString('✔', 'green'),
15
+ package: plugins.consolecolor.coloredString('📦', 'blue'),
16
+ build: plugins.consolecolor.coloredString('🔨', 'cyan'),
17
+ publish: plugins.consolecolor.coloredString('🚀', 'green'),
18
+ };
19
+
20
+ // Helper function for info messages with color
21
+ export const logInfo = (message: string, data?: any) => {
22
+ const coloredMessage = `${logIcons.info} ${plugins.consolecolor.coloredString(message, 'cyan')}`;
23
+ logger.log('info', coloredMessage, data);
24
+ };
25
+
26
+ // Helper function for success messages
27
+ export const logSuccess = (message: string, data?: any) => {
28
+ const coloredMessage = `${logIcons.success} ${plugins.consolecolor.coloredString(message, 'green')}`;
29
+ logger.log('ok', coloredMessage, data);
30
+ };
31
+
32
+ // Helper function for warning messages
33
+ export const logWarn = (message: string, data?: any) => {
34
+ const coloredMessage = `${logIcons.warn} ${plugins.consolecolor.coloredString(message, 'orange')}`;
35
+ logger.log('warn', coloredMessage, data);
36
+ };
37
+
38
+ // Helper function for error messages
39
+ export const logError = (message: string, data?: any) => {
40
+ const coloredMessage = `${logIcons.error} ${plugins.consolecolor.coloredString(message, 'red')}`;
41
+ logger.log('error', coloredMessage, data);
42
+ };
43
+
44
+ // Helper function for start of operations
45
+ export const logStart = (operation: string) => {
46
+ const coloredMessage = `${logIcons.start} ${plugins.consolecolor.coloredString(`Starting ${operation}...`, 'blue')}`;
47
+ logger.log('info', coloredMessage);
48
+ };
49
+
50
+ // Helper function for completion of operations
51
+ export const logDone = (operation: string) => {
52
+ const coloredMessage = `${logIcons.done} ${plugins.consolecolor.coloredString(`Completed ${operation}`, 'green')}`;
53
+ logger.log('ok', coloredMessage);
54
+ };
55
+
56
+ // Helper function for package-related messages
57
+ export const logPackage = (message: string, packageName: string) => {
58
+ const coloredMessage = `${logIcons.package} ${message}: ${plugins.consolecolor.coloredString(packageName, 'blue', 'white')}`;
59
+ logger.log('info', coloredMessage);
60
+ };
61
+
62
+ // Helper function for build-related messages
63
+ export const logBuild = (message: string) => {
64
+ const coloredMessage = `${logIcons.build} ${plugins.consolecolor.coloredString(message, 'cyan')}`;
65
+ logger.log('info', coloredMessage);
66
+ };
67
+
68
+ // Helper function for publish-related messages
69
+ export const logPublish = (message: string) => {
70
+ const coloredMessage = `${logIcons.publish} ${plugins.consolecolor.coloredString(message, 'green')}`;
71
+ logger.log('info', coloredMessage);
72
+ };
73
+
74
+ // Create a visual separator for different phases
75
+ export const logSeparator = () => {
76
+ const separator = plugins.consolecolor.coloredString('━'.repeat(60), 'cyan');
77
+ console.log(separator);
78
+ };
79
+
80
+ // Create a header for major sections
81
+ export const logHeader = (title: string) => {
82
+ logSeparator();
83
+ const header = plugins.consolecolor.coloredString(` ${title.toUpperCase()} `, 'white', 'blue');
84
+ console.log(header);
85
+ logSeparator();
86
+ };
87
+
88
+ // Helper for indicating ongoing operations
89
+ export const logOngoing = (text: string) => {
90
+ const spinnerIcon = plugins.consolecolor.coloredString('⟳', 'cyan');
91
+ const coloredMessage = `${spinnerIcon} ${plugins.consolecolor.coloredString(text, 'cyan')}`;
92
+ logger.log('info', coloredMessage);
93
+ };
94
+
95
+ // Progress indicator helper
96
+ export const logProgress = (current: number, total: number, item: string) => {
97
+ const percentage = Math.round((current / total) * 100);
98
+ const progressBar = '█'.repeat(Math.floor(percentage / 5)) + '░'.repeat(20 - Math.floor(percentage / 5));
99
+ const coloredProgress = plugins.consolecolor.coloredString(
100
+ `[${progressBar}] ${percentage}% - ${item}`,
101
+ percentage === 100 ? 'green' : 'blue'
102
+ );
103
+ logger.log('info', coloredProgress);
104
+ };
package/ts/plugins.ts CHANGED
@@ -3,6 +3,7 @@ import * as path from 'path';
3
3
  export { path };
4
4
 
5
5
  // @push.rocks scope
6
+ import * as consolecolor from '@push.rocks/consolecolor';
6
7
  import * as smartfile from '@push.rocks/smartfile';
7
8
  import * as smartcli from '@push.rocks/smartcli';
8
9
  import * as smartdelay from '@push.rocks/smartdelay';
@@ -12,4 +13,4 @@ import * as smartpath from '@push.rocks/smartpath';
12
13
  import * as smartrequest from '@push.rocks/smartrequest';
13
14
  import * as smartshell from '@push.rocks/smartshell';
14
15
 
15
- export { smartfile, smartcli, smartdelay, smartlog, smartnpm, smartpath, smartrequest, smartshell };
16
+ export { consolecolor, smartfile, smartcli, smartdelay, smartlog, smartnpm, smartpath, smartrequest, smartshell };