@releasekit/version 0.1.0 → 0.1.1-next.0

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,128 +0,0 @@
1
- // src/utils/logging.ts
2
- import chalk from "chalk";
3
- import figlet from "figlet";
4
-
5
- // src/utils/jsonOutput.ts
6
- var _jsonOutputMode = false;
7
- var _jsonData = {
8
- dryRun: false,
9
- updates: [],
10
- changelogs: [],
11
- tags: []
12
- };
13
- function enableJsonOutput(dryRun = false) {
14
- _jsonOutputMode = true;
15
- _jsonData.dryRun = dryRun;
16
- _jsonData.updates = [];
17
- _jsonData.changelogs = [];
18
- _jsonData.tags = [];
19
- _jsonData.commitMessage = void 0;
20
- }
21
- function isJsonOutputMode() {
22
- return _jsonOutputMode;
23
- }
24
- function addPackageUpdate(packageName, newVersion, filePath) {
25
- if (!_jsonOutputMode) return;
26
- _jsonData.updates.push({
27
- packageName,
28
- newVersion,
29
- filePath
30
- });
31
- }
32
- function addChangelogData(data) {
33
- if (!_jsonOutputMode) return;
34
- _jsonData.changelogs.push(data);
35
- }
36
- function addTag(tag) {
37
- if (!_jsonOutputMode) return;
38
- _jsonData.tags.push(tag);
39
- }
40
- function setCommitMessage(message) {
41
- if (!_jsonOutputMode) return;
42
- _jsonData.commitMessage = message;
43
- }
44
- function printJsonOutput() {
45
- if (_jsonOutputMode) {
46
- console.log(JSON.stringify(_jsonData, null, 2));
47
- }
48
- }
49
-
50
- // src/utils/logging.ts
51
- function log(message, level = "info") {
52
- const showDebug = process.env.DEBUG === "true" || process.env.DEBUG === "1";
53
- if (level === "debug" && !showDebug) {
54
- return;
55
- }
56
- let chalkFn;
57
- switch (level) {
58
- case "success":
59
- chalkFn = chalk.green;
60
- break;
61
- case "warning":
62
- chalkFn = chalk.yellow;
63
- break;
64
- case "error":
65
- chalkFn = chalk.red;
66
- break;
67
- case "debug":
68
- chalkFn = chalk.gray;
69
- break;
70
- default:
71
- chalkFn = chalk.blue;
72
- }
73
- if (isJsonOutputMode()) {
74
- if (level === "error") {
75
- chalkFn(message);
76
- console.error(message);
77
- }
78
- return;
79
- }
80
- const formattedMessage = level === "debug" ? `[DEBUG] ${message}` : message;
81
- if (level === "error") {
82
- console.error(chalkFn(formattedMessage));
83
- } else {
84
- console.log(chalkFn(formattedMessage));
85
- }
86
- }
87
-
88
- // src/errors/baseError.ts
89
- var BasePackageVersionerError = class _BasePackageVersionerError extends Error {
90
- constructor(message, code, suggestions) {
91
- super(message);
92
- this.code = code;
93
- this.suggestions = suggestions;
94
- this.name = this.constructor.name;
95
- }
96
- /**
97
- * Log the error with consistent formatting and optional suggestions
98
- * This centralizes all error output formatting and behavior
99
- */
100
- logError() {
101
- log(this.message, "error");
102
- if (this.suggestions?.length) {
103
- log("\nSuggested solutions:", "info");
104
- this.suggestions.forEach((suggestion, i) => {
105
- log(`${i + 1}. ${suggestion}`, "info");
106
- });
107
- }
108
- }
109
- /**
110
- * Type guard to check if an error is a package-versioner error
111
- * @param error Error to check
112
- * @returns true if error is a BasePackageVersionerError
113
- */
114
- static isPackageVersionerError(error) {
115
- return error instanceof _BasePackageVersionerError;
116
- }
117
- };
118
-
119
- export {
120
- enableJsonOutput,
121
- addPackageUpdate,
122
- addChangelogData,
123
- addTag,
124
- setCommitMessage,
125
- printJsonOutput,
126
- log,
127
- BasePackageVersionerError
128
- };