@mantiq/cli 0.1.3 → 0.1.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantiq/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Command runner, code generators, dev server",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/IO.ts CHANGED
@@ -17,15 +17,16 @@ const FG = {
17
17
  cyan: `${ESC}36m`,
18
18
  white: `${ESC}37m`,
19
19
  gray: `${ESC}90m`,
20
+ emerald: `${ESC}38;2;52;211;153m`,
20
21
  } as const
21
22
 
22
23
  export class IO {
23
24
  info(msg: string): void {
24
- console.log(`${FG.blue} INFO${RESET} ${msg}`)
25
+ console.log(`${FG.gray} INFO${RESET} ${msg}`)
25
26
  }
26
27
 
27
28
  success(msg: string): void {
28
- console.log(`${FG.green} DONE${RESET} ${msg}`)
29
+ console.log(`${FG.emerald} DONE${RESET} ${msg}`)
29
30
  }
30
31
 
31
32
  error(msg: string): void {
@@ -60,8 +61,14 @@ export class IO {
60
61
  yellow(msg: string): string { return `${FG.yellow}${msg}${RESET}` }
61
62
  cyan(msg: string): string { return `${FG.cyan}${msg}${RESET}` }
62
63
  gray(msg: string): string { return `${FG.gray}${msg}${RESET}` }
64
+ emerald(msg: string): string { return `${FG.emerald}${msg}${RESET}` }
63
65
  bold(msg: string): string { return `${BOLD}${msg}${RESET}` }
64
66
 
67
+ /** Print brand mark */
68
+ brand(): void {
69
+ console.log(`\n ${FG.emerald}mantiq${RESET} ${DIM}framework${RESET}\n`)
70
+ }
71
+
65
72
  /** Print a table with aligned columns */
66
73
  table(headers: string[], rows: string[][]): void {
67
74
  // Strip ANSI codes for width calculation
package/src/Kernel.ts CHANGED
@@ -37,8 +37,14 @@ export class Kernel {
37
37
  try {
38
38
  const mod = await import(dir + '/' + file)
39
39
  for (const exported of Object.values(mod)) {
40
- if (typeof exported === 'function' && (exported as any).prototype?.name && (exported as any).prototype?.handle) {
41
- this.register(new (exported as any)())
40
+ if (typeof exported !== 'function') continue
41
+ try {
42
+ const instance = new (exported as any)()
43
+ if (instance.name && typeof instance.handle === 'function') {
44
+ this.register(instance)
45
+ }
46
+ } catch {
47
+ // Not instantiable or not a command
42
48
  }
43
49
  }
44
50
  } catch {
@@ -82,8 +88,7 @@ export class Kernel {
82
88
  }
83
89
 
84
90
  private showHelp(_parsed: ParsedArgs): void {
85
- this.io.heading('MantiqJS CLI')
86
- this.io.newLine()
91
+ this.io.brand()
87
92
  this.io.line(' Usage: mantiq <command> [arguments] [options]')
88
93
  this.io.newLine()
89
94
 
@@ -104,7 +109,7 @@ export class Kernel {
104
109
 
105
110
  for (const [prefix, cmds] of sortedGroups) {
106
111
  if (prefix) {
107
- this.io.line(` ${this.io.yellow(prefix)}`)
112
+ this.io.line(` ${this.io.emerald(prefix)}`)
108
113
  }
109
114
  const sorted = cmds.sort((a, b) => a.name.localeCompare(b.name))
110
115
  for (const cmd of sorted) {
@@ -8,8 +8,7 @@ export class AboutCommand extends Command {
8
8
  override async handle(_args: ParsedArgs): Promise<number> {
9
9
  const env = process.env
10
10
 
11
- this.io.heading('MantiqJS Framework')
12
- this.io.line('')
11
+ this.io.brand()
13
12
 
14
13
  // Environment
15
14
  this.io.info(' Environment')
@@ -57,7 +56,7 @@ export class AboutCommand extends Command {
57
56
  for (const pkg of packages) {
58
57
  try {
59
58
  require.resolve(`@mantiq/${pkg}`)
60
- this.io.line(` ${this.io.green('●')} @mantiq/${pkg}`)
59
+ this.io.line(` ${this.io.emerald('●')} @mantiq/${pkg}`)
61
60
  } catch {
62
61
  this.io.line(` ${this.io.gray('○')} @mantiq/${pkg}`)
63
62
  }