@versu/cli 0.6.6 → 0.6.8
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/README.md +65 -14
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +22 -6
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +150 -10
- package/dist/logger.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -92,7 +92,6 @@ Calculate and apply semantic version changes.
|
|
|
92
92
|
| `--no-push-changes` | Don't commit and push changes | - |
|
|
93
93
|
| `--generate-changelog` | Generate or update changelog files for changed modules | `true` |
|
|
94
94
|
| `--no-generate-changelog` | Don't generate changelogs | - |
|
|
95
|
-
| `--output-file <value>` | Write calculated versions to a file in JSON format | - |
|
|
96
95
|
|
|
97
96
|
> 📖 **Detailed Pre-release Documentation**: See [@versu/core PRERELEASE.md](../core/PRERELEASE.md) for comprehensive examples and use cases.
|
|
98
97
|
|
|
@@ -177,28 +176,72 @@ VERSU CLI uses the same configuration system as the core library. Configuration
|
|
|
177
176
|
|
|
178
177
|
```json
|
|
179
178
|
{
|
|
180
|
-
"
|
|
181
|
-
|
|
182
|
-
"
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
179
|
+
"versionRules": {
|
|
180
|
+
"defaultBump": "patch",
|
|
181
|
+
"commitTypeBumps": {
|
|
182
|
+
"feat": "minor",
|
|
183
|
+
"fix": "patch",
|
|
184
|
+
"perf": "patch",
|
|
185
|
+
"refactor": "patch",
|
|
186
|
+
"docs": "ignore",
|
|
187
|
+
"test": "ignore",
|
|
188
|
+
"chore": "ignore"
|
|
189
|
+
},
|
|
190
|
+
"dependencyBumps": {
|
|
191
|
+
"major": "major",
|
|
192
|
+
"minor": "minor",
|
|
193
|
+
"patch": "patch"
|
|
194
|
+
}
|
|
189
195
|
},
|
|
190
|
-
"
|
|
191
|
-
"
|
|
192
|
-
|
|
193
|
-
|
|
196
|
+
"changelog": {
|
|
197
|
+
"root": {
|
|
198
|
+
"context": {
|
|
199
|
+
"prependPlaceholder": "<!-- CHANGELOG -->"
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
"module": {
|
|
203
|
+
"context": {
|
|
204
|
+
"prependPlaceholder": "<!-- CHANGELOG -->"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
194
207
|
}
|
|
195
208
|
}
|
|
196
209
|
```
|
|
197
210
|
|
|
198
211
|
For more configuration examples, see the [core package documentation](../core).
|
|
199
212
|
|
|
213
|
+
**Advanced Changelog Configuration:**
|
|
214
|
+
|
|
215
|
+
VERSU supports [conventional-changelog-writer](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer) options for customizing changelog generation. For advanced customization with functions (transforms, sorting, templates), use JavaScript configuration files:
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
218
|
+
// versu.config.js
|
|
219
|
+
module.exports = {
|
|
220
|
+
versionRules: {
|
|
221
|
+
// ... version rules
|
|
222
|
+
},
|
|
223
|
+
changelog: {
|
|
224
|
+
module: {
|
|
225
|
+
options: {
|
|
226
|
+
groupBy: 'type',
|
|
227
|
+
commitsGroupsSort: (a, b) => {
|
|
228
|
+
const order = { feat: 1, fix: 2, perf: 3 };
|
|
229
|
+
return (order[a.title] || 99) - (order[b.title] || 99);
|
|
230
|
+
},
|
|
231
|
+
transform: (commit, context) => {
|
|
232
|
+
// Custom commit transformation
|
|
233
|
+
return commit;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
```
|
|
240
|
+
|
|
200
241
|
## Gradle Project Support
|
|
201
242
|
|
|
243
|
+
Gradle support is provided by the **[@versu/plugin-gradle](../plugin-gradle)** package.
|
|
244
|
+
|
|
202
245
|
The CLI supports Gradle projects with:
|
|
203
246
|
|
|
204
247
|
- **Multi-module projects** via `settings.gradle(.kts)`
|
|
@@ -269,6 +312,11 @@ Breaking changes trigger **major** version bumps:
|
|
|
269
312
|
- name: Install VERSU CLI
|
|
270
313
|
run: npm install -g @versu/cli
|
|
271
314
|
|
|
315
|
+
- name: Install Adapter
|
|
316
|
+
run: |
|
|
317
|
+
# install required adapters
|
|
318
|
+
npm install -g @versu/plugin-gradle
|
|
319
|
+
|
|
272
320
|
- name: Version modules
|
|
273
321
|
run: versu --adapter gradle
|
|
274
322
|
```
|
|
@@ -279,6 +327,7 @@ Breaking changes trigger **major** version bumps:
|
|
|
279
327
|
version:
|
|
280
328
|
script:
|
|
281
329
|
- npm install -g @versu/cli
|
|
330
|
+
- npm install -g @versu/plugin-gradle
|
|
282
331
|
- versu --adapter gradle
|
|
283
332
|
```
|
|
284
333
|
|
|
@@ -288,6 +337,7 @@ version:
|
|
|
288
337
|
stage('Version') {
|
|
289
338
|
steps {
|
|
290
339
|
sh 'npm install -g @versu/cli'
|
|
340
|
+
sh 'npm install -g @versu/plugin-gradle'
|
|
291
341
|
sh 'versu --adapter gradle'
|
|
292
342
|
}
|
|
293
343
|
}
|
|
@@ -380,6 +430,7 @@ npm publish --workspace packages/cli --access public
|
|
|
380
430
|
|
|
381
431
|
- **[@versu/core](../core)** - Core library for custom integrations
|
|
382
432
|
- **[@versu/action](../action)** - GitHub Actions integration
|
|
433
|
+
- **[@versu/plugin-gradle](../plugin-gradle)** - Gradle adapter plugin
|
|
383
434
|
|
|
384
435
|
## License
|
|
385
436
|
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export default class Version extends Command {
|
|
|
9
9
|
};
|
|
10
10
|
static flags: {
|
|
11
11
|
version: import("@oclif/core/interfaces").BooleanFlag<void>;
|
|
12
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
13
|
"dry-run": import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
14
|
adapter: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
15
|
"push-tags": import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAS,MAAM,aAAa,CAAC;AAInD,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;IAC1C,OAAgB,WAAW,SAAkD;IAE7E,OAAgB,QAAQ,WAKtB;IAEF,MAAM,CAAC,IAAI;;;;MAMT;IAEF,OAAgB,KAAK
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAS,MAAM,aAAa,CAAC;AAInD,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;IAC1C,OAAgB,WAAW,SAAkD;IAE7E,OAAgB,QAAQ,WAKtB;IAEF,MAAM,CAAC,IAAI;;;;MAMT;IAEF,OAAgB,KAAK;;;;;;;;;;;;;;MAyDnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA6B3B"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Args, Command, Flags } from "@oclif/core";
|
|
2
|
-
import { VersuRunner, initLogger } from "@versu/core";
|
|
2
|
+
import { VersuRunner, initLogger, logger } from "@versu/core";
|
|
3
3
|
import { OclifLogger } from "./logger.js";
|
|
4
4
|
export default class Version extends Command {
|
|
5
5
|
static description = "Calculate and apply semantic version changes";
|
|
@@ -18,6 +18,10 @@ export default class Version extends Command {
|
|
|
18
18
|
};
|
|
19
19
|
static flags = {
|
|
20
20
|
version: Flags.version({ char: 'v' }),
|
|
21
|
+
verbose: Flags.boolean({
|
|
22
|
+
description: "Show detailed debug output",
|
|
23
|
+
default: false,
|
|
24
|
+
}),
|
|
21
25
|
"dry-run": Flags.boolean({
|
|
22
26
|
description: "Run without writing or pushing changes",
|
|
23
27
|
default: false,
|
|
@@ -68,7 +72,7 @@ export default class Version extends Command {
|
|
|
68
72
|
};
|
|
69
73
|
async run() {
|
|
70
74
|
const { flags, args } = await this.parse(Version);
|
|
71
|
-
initLogger(new OclifLogger(this));
|
|
75
|
+
initLogger(new OclifLogger(this, {}, flags.verbose));
|
|
72
76
|
try {
|
|
73
77
|
const options = {
|
|
74
78
|
repoRoot: args.repositoryRoot,
|
|
@@ -89,7 +93,7 @@ export default class Version extends Command {
|
|
|
89
93
|
}
|
|
90
94
|
catch (error) {
|
|
91
95
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
92
|
-
|
|
96
|
+
logger.error("Command failed", { error: errorMessage });
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,WAAW,EAAiB,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,WAAW,EAAiB,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;IAC1C,MAAM,CAAU,WAAW,GAAG,8CAA8C,CAAC;IAE7E,MAAM,CAAU,QAAQ,GAAG;QACzB,qCAAqC;QACrC,sDAAsD;QACtD,+CAA+C;Q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AG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACzD,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC"}
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
import { Command } from
|
|
2
|
-
import type { Logger } from
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import type { Logger } from "@versu/core";
|
|
3
|
+
/**
|
|
4
|
+
* CLI Logger implementation with beautiful formatting using chalk and ora
|
|
5
|
+
* Implements the core Logger interface for presentation in the CLI
|
|
6
|
+
*/
|
|
3
7
|
export declare class OclifLogger implements Logger {
|
|
4
8
|
private readonly cmd;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
private readonly context;
|
|
10
|
+
private spinner;
|
|
11
|
+
private groupDepth;
|
|
12
|
+
private verbose;
|
|
13
|
+
constructor(cmd: Command, context?: Record<string, unknown>, verbose?: boolean);
|
|
14
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
15
|
+
/**
|
|
16
|
+
* Helper method to handle spinner-aware logging with consistent formatting
|
|
17
|
+
*/
|
|
18
|
+
private logWithSpinner;
|
|
19
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
20
|
+
warning(message: string | Error, context?: Record<string, unknown>): void;
|
|
8
21
|
error(message: string | Error, context?: Record<string, unknown>): void;
|
|
9
|
-
|
|
22
|
+
child(context: Record<string, unknown>): Logger;
|
|
23
|
+
startGroup(name: string): void;
|
|
24
|
+
group<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
|
25
|
+
endGroup(): void;
|
|
10
26
|
}
|
|
11
27
|
//# sourceMappingURL=logger.d.ts.map
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAsE1C;;;GAGG;AACH,qBAAa,WAAY,YAAW,MAAM;IAMtC,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN1B,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,OAAO,CAAU;gBAGN,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACtD,OAAO,UAAQ;IAKjB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAQ/D;;OAEG;IACH,OAAO,CAAC,cAAc;IA4BtB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAU9D,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAUzE,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAWvE,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAI/C,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAWxB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IA6B9D,QAAQ,IAAI,IAAI;CAWjB"}
|
package/dist/logger.js
CHANGED
|
@@ -1,21 +1,161 @@
|
|
|
1
|
-
import Debug from
|
|
2
|
-
|
|
1
|
+
import Debug from "debug";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
const debug = Debug("versu");
|
|
5
|
+
function indent(str, spaces) {
|
|
6
|
+
const indentation = " ".repeat(spaces);
|
|
7
|
+
return indentation + str;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Formats context object for beautiful CLI display
|
|
11
|
+
*/
|
|
12
|
+
function formatContext(context, baseIndent = 0) {
|
|
13
|
+
if (!context || Object.keys(context).length === 0)
|
|
14
|
+
return "";
|
|
15
|
+
const entries = Object.entries(context).map(([key, value]) => {
|
|
16
|
+
let formattedValue;
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
if (value.length === 0) {
|
|
19
|
+
formattedValue = "none";
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
formattedValue = value.join(", ");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (typeof value === "object" && value !== null) {
|
|
26
|
+
formattedValue = JSON.stringify(value);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
formattedValue = String(value);
|
|
30
|
+
}
|
|
31
|
+
return { key, formattedValue, length: key.length + formattedValue.length };
|
|
32
|
+
});
|
|
33
|
+
// Calculate total inline length
|
|
34
|
+
const totalLength = entries.reduce((sum, e) => sum + e.length, 0);
|
|
35
|
+
const hasLongValue = entries.some(e => e.formattedValue.length > 50);
|
|
36
|
+
// Use inline format for simple cases: <= 3 keys and reasonable total length
|
|
37
|
+
if (entries.length <= 3 && totalLength < 80 && !hasLongValue) {
|
|
38
|
+
const inline = entries
|
|
39
|
+
.map(e => `${chalk.dim(e.key)}=${chalk.cyan(e.formattedValue)}`)
|
|
40
|
+
.join(" ");
|
|
41
|
+
return ` ${chalk.dim("(")}${inline}${chalk.dim(")")}`;
|
|
42
|
+
}
|
|
43
|
+
// Use multi-line format for complex cases
|
|
44
|
+
// Account for base indentation + icon (2 chars: "ℹ ")
|
|
45
|
+
const lineIndent = " ".repeat(baseIndent + 2);
|
|
46
|
+
const multiline = entries
|
|
47
|
+
.map(e => `${lineIndent}${chalk.dim(e.key)}: ${chalk.cyan(e.formattedValue)}`)
|
|
48
|
+
.join("\n");
|
|
49
|
+
return "\n" + multiline;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Formats a message with optional context for CLI output
|
|
53
|
+
*/
|
|
54
|
+
function formatMessage(message, context, baseIndent = 0) {
|
|
55
|
+
const result = message instanceof Error ? message.toString() : message;
|
|
56
|
+
const contextString = formatContext(context, baseIndent);
|
|
57
|
+
return `${result}${contextString}`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* CLI Logger implementation with beautiful formatting using chalk and ora
|
|
61
|
+
* Implements the core Logger interface for presentation in the CLI
|
|
62
|
+
*/
|
|
3
63
|
export class OclifLogger {
|
|
4
64
|
cmd;
|
|
5
|
-
|
|
65
|
+
context;
|
|
66
|
+
spinner = null;
|
|
67
|
+
groupDepth = 0;
|
|
68
|
+
verbose;
|
|
69
|
+
constructor(cmd, context = {}, verbose = false) {
|
|
6
70
|
this.cmd = cmd;
|
|
71
|
+
this.context = context;
|
|
72
|
+
this.verbose = verbose;
|
|
73
|
+
}
|
|
74
|
+
debug(message, context) {
|
|
75
|
+
// Debug messages only shown in verbose mode
|
|
76
|
+
if (this.verbose) {
|
|
77
|
+
const baseIndent = this.groupDepth * 2;
|
|
78
|
+
debug(formatMessage(message, { ...this.context, ...context }, baseIndent));
|
|
79
|
+
}
|
|
7
80
|
}
|
|
8
|
-
|
|
9
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Helper method to handle spinner-aware logging with consistent formatting
|
|
83
|
+
*/
|
|
84
|
+
logWithSpinner(logFn, icon, color, message, context, isError = false) {
|
|
85
|
+
const baseIndent = this.groupDepth * 2;
|
|
86
|
+
const formatted = formatMessage(message, { ...this.context, ...context }, baseIndent);
|
|
87
|
+
const output = indent(color(icon) + " " + formatted, baseIndent);
|
|
88
|
+
if (this.spinner) {
|
|
89
|
+
if (isError) {
|
|
90
|
+
this.spinner.fail();
|
|
91
|
+
this.spinner = null;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
this.spinner.stop();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
logFn(output);
|
|
98
|
+
if (this.spinner && !isError) {
|
|
99
|
+
this.spinner.start();
|
|
100
|
+
}
|
|
10
101
|
}
|
|
11
|
-
|
|
12
|
-
this.cmd.
|
|
102
|
+
info(message, context) {
|
|
103
|
+
this.logWithSpinner((msg) => this.cmd.log(msg), "ℹ", chalk.blue, message, context);
|
|
104
|
+
}
|
|
105
|
+
warning(message, context) {
|
|
106
|
+
this.logWithSpinner((msg) => this.cmd.warn(msg), "⚠", chalk.yellow, message, context);
|
|
13
107
|
}
|
|
14
108
|
error(message, context) {
|
|
15
|
-
this.cmd.error(message, context);
|
|
109
|
+
this.logWithSpinner((msg) => this.cmd.error(msg), "✖", chalk.red, message, context, true);
|
|
110
|
+
}
|
|
111
|
+
child(context) {
|
|
112
|
+
return new OclifLogger(this.cmd, { ...this.context, ...context }, this.verbose);
|
|
113
|
+
}
|
|
114
|
+
startGroup(name) {
|
|
115
|
+
// Stop any active spinner before starting a group
|
|
116
|
+
if (this.spinner) {
|
|
117
|
+
this.spinner.succeed();
|
|
118
|
+
this.spinner = null;
|
|
119
|
+
}
|
|
120
|
+
this.cmd.log(indent(chalk.bold.cyan(name), this.groupDepth));
|
|
121
|
+
this.groupDepth++;
|
|
122
|
+
}
|
|
123
|
+
async group(name, fn) {
|
|
124
|
+
this.startGroup(name);
|
|
125
|
+
try {
|
|
126
|
+
// Start spinner for the group operation
|
|
127
|
+
this.spinner = ora({
|
|
128
|
+
indent: this.groupDepth,
|
|
129
|
+
color: "cyan",
|
|
130
|
+
}).start();
|
|
131
|
+
const result = await fn();
|
|
132
|
+
// Succeed the spinner when done
|
|
133
|
+
if (this.spinner) {
|
|
134
|
+
this.spinner.succeed(chalk.green("Complete"));
|
|
135
|
+
this.spinner = null;
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
if (this.spinner) {
|
|
141
|
+
this.spinner.fail(chalk.red("Failed"));
|
|
142
|
+
this.spinner = null;
|
|
143
|
+
}
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
this.endGroup();
|
|
148
|
+
}
|
|
16
149
|
}
|
|
17
|
-
|
|
18
|
-
|
|
150
|
+
endGroup() {
|
|
151
|
+
if (this.groupDepth > 0) {
|
|
152
|
+
this.groupDepth--;
|
|
153
|
+
}
|
|
154
|
+
// Clean up spinner if still active
|
|
155
|
+
if (this.groupDepth === 0 && this.spinner) {
|
|
156
|
+
this.spinner.stop();
|
|
157
|
+
this.spinner = null;
|
|
158
|
+
}
|
|
19
159
|
}
|
|
20
160
|
}
|
|
21
161
|
//# sourceMappingURL=logger.js.map
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],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,CAAC;gBACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACtB,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;IAED,QAAQ;QACN,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,CAAC;QAED,mCAAmC;QACnC,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versu/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"description": "VERSU (CLI)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,8 +38,10 @@
|
|
|
38
38
|
"types": "dist/index.d.ts",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@oclif/core": "^4.8.0",
|
|
41
|
-
"@versu/core": "^0.6.
|
|
42
|
-
"
|
|
41
|
+
"@versu/core": "^0.6.8",
|
|
42
|
+
"chalk": "^5.6.2",
|
|
43
|
+
"oclif": "^4.14.0",
|
|
44
|
+
"ora": "^9.3.0"
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
47
|
"@oclif/dev-cli": "^1.26.10",
|