@aneuhold/core-ts-lib 1.0.8 → 1.0.10

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.
Files changed (56) hide show
  1. package/lib/helperFunctions/dateFunctions.d.ts +9 -9
  2. package/lib/helperFunctions/dateFunctions.js +15 -15
  3. package/lib/helperFunctions/sleep.d.ts +6 -6
  4. package/lib/helperFunctions/sleep.js +12 -12
  5. package/lib/helperFunctions/stringFunctions.d.ts +8 -8
  6. package/lib/helperFunctions/stringFunctions.js +13 -13
  7. package/lib/index.d.ts +12 -11
  8. package/lib/index.d.ts.map +1 -1
  9. package/lib/index.js +54 -52
  10. package/lib/services/CLIService.d.ts +68 -68
  11. package/lib/services/CLIService.js +194 -194
  12. package/lib/services/StringService.d.ts +13 -13
  13. package/lib/services/StringService.js +18 -18
  14. package/lib/services/applications/ChromeService.d.ts +19 -19
  15. package/lib/services/applications/ChromeService.js +60 -60
  16. package/lib/services/applications/DockerService.d.ts +20 -20
  17. package/lib/services/applications/DockerService.js +88 -88
  18. package/lib/services/applications/FileSystemService.d.ts +18 -17
  19. package/lib/services/applications/FileSystemService.d.ts.map +1 -1
  20. package/lib/services/applications/FileSystemService.js +97 -87
  21. package/lib/services/applications/ITermService.d.ts +8 -0
  22. package/lib/services/applications/ITermService.d.ts.map +1 -0
  23. package/lib/services/applications/ITermService.js +45 -0
  24. package/lib/services/applications/OsaScriptService.d.ts +4 -0
  25. package/lib/services/applications/OsaScriptService.d.ts.map +1 -0
  26. package/lib/services/applications/OsaScriptService.js +31 -0
  27. package/lib/utils/CurrentEnv.d.ts +62 -61
  28. package/lib/utils/CurrentEnv.d.ts.map +1 -1
  29. package/lib/utils/CurrentEnv.js +137 -133
  30. package/lib/utils/Logger.d.ts +67 -67
  31. package/lib/utils/Logger.js +112 -112
  32. package/lib/utils/OsaScriptBuilder.d.ts +45 -0
  33. package/lib/utils/OsaScriptBuilder.d.ts.map +1 -0
  34. package/lib/utils/OsaScriptBuilder.js +53 -0
  35. package/package.json +1 -1
  36. package/lib/helperFunctions/applications/applications.d.ts +0 -21
  37. package/lib/helperFunctions/applications/applications.d.ts.map +0 -1
  38. package/lib/helperFunctions/applications/applications.js +0 -26
  39. package/lib/helperFunctions/applications/chromeApplication.d.ts +0 -8
  40. package/lib/helperFunctions/applications/chromeApplication.d.ts.map +0 -1
  41. package/lib/helperFunctions/applications/chromeApplication.js +0 -63
  42. package/lib/helperFunctions/applications/fileSystemApplication.d.ts +0 -8
  43. package/lib/helperFunctions/applications/fileSystemApplication.d.ts.map +0 -1
  44. package/lib/helperFunctions/applications/fileSystemApplication.js +0 -51
  45. package/lib/helperFunctions/cmd.d.ts +0 -54
  46. package/lib/helperFunctions/cmd.d.ts.map +0 -1
  47. package/lib/helperFunctions/cmd.js +0 -177
  48. package/lib/helperFunctions/fileFunctions.d.ts +0 -10
  49. package/lib/helperFunctions/fileFunctions.d.ts.map +0 -1
  50. package/lib/helperFunctions/fileFunctions.js +0 -43
  51. package/lib/helperFunctions/input.d.ts +0 -8
  52. package/lib/helperFunctions/input.d.ts.map +0 -1
  53. package/lib/helperFunctions/input.js +0 -48
  54. package/lib/utils/Log.d.ts +0 -69
  55. package/lib/utils/Log.d.ts.map +0 -1
  56. package/lib/utils/Log.js +0 -112
@@ -1,133 +1,137 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TerminalType = exports.OperatingSystemType = exports.ShellType = void 0;
7
- const promises_1 = require("fs/promises");
8
- const path_1 = __importDefault(require("path"));
9
- const CLIService_1 = __importDefault(require("../services/CLIService"));
10
- const Logger_1 = __importDefault(require("./Logger"));
11
- /**
12
- * The type of shell that the current environment is running.
13
- */
14
- var ShellType;
15
- (function (ShellType) {
16
- ShellType[ShellType["PowerShellCore"] = 0] = "PowerShellCore";
17
- ShellType[ShellType["PowerShellDesktop"] = 1] = "PowerShellDesktop";
18
- ShellType[ShellType["Bash"] = 2] = "Bash";
19
- ShellType[ShellType["Zsh"] = 3] = "Zsh";
20
- ShellType[ShellType["CommandPrompt"] = 4] = "CommandPrompt";
21
- ShellType[ShellType["Unknown"] = 5] = "Unknown";
22
- })(ShellType = exports.ShellType || (exports.ShellType = {}));
23
- var OperatingSystemType;
24
- (function (OperatingSystemType) {
25
- OperatingSystemType[OperatingSystemType["Windows"] = 0] = "Windows";
26
- OperatingSystemType[OperatingSystemType["MacOSX"] = 1] = "MacOSX";
27
- OperatingSystemType[OperatingSystemType["Linux"] = 2] = "Linux";
28
- OperatingSystemType[OperatingSystemType["Unknown"] = 3] = "Unknown";
29
- })(OperatingSystemType = exports.OperatingSystemType || (exports.OperatingSystemType = {}));
30
- /**
31
- * The type of terminal that the current enviornment is running.
32
- */
33
- var TerminalType;
34
- (function (TerminalType) {
35
- TerminalType[TerminalType["WindowsTerminal"] = 0] = "WindowsTerminal";
36
- TerminalType[TerminalType["Unknown"] = 1] = "Unknown";
37
- })(TerminalType = exports.TerminalType || (exports.TerminalType = {}));
38
- /**
39
- * Provides information relevant to the current environment this script is
40
- * running in.
41
- */
42
- class CurrentEnv {
43
- /**
44
- * Returns the type of terminal the current environment is using.
45
- */
46
- static terminal() {
47
- // See https://stackoverflow.com/questions/59733731/how-to-detect-if-running-in-the-new-windows-terminal
48
- // for information on why this method was chosen.
49
- if (process.env.WT_SESSION) {
50
- return TerminalType.WindowsTerminal;
51
- }
52
- return TerminalType.Unknown;
53
- }
54
- /**
55
- * Returns the type of shell the current environment is using.
56
- *
57
- * This might be arbitrary because it seems that the exec command will use
58
- * whatever the default shell is or whatever is specified as the shell
59
- * option.
60
- */
61
- static async shell() {
62
- const currentOs = CurrentEnv.os;
63
- if (currentOs === OperatingSystemType.Windows) {
64
- // Command comes from: https://stackoverflow.com/questions/34471956/how-to-determine-if-im-in-powershell-or-cmd
65
- const { output } = await CLIService_1.default.execCmd('(dir 2>&1 *`|echo CMD);&<# rem #>echo ($PSVersionTable).PSEdition');
66
- switch (output) {
67
- case 'CMD':
68
- return ShellType.CommandPrompt;
69
- case 'Desktop':
70
- return ShellType.PowerShellDesktop;
71
- case 'Core':
72
- return ShellType.PowerShellCore;
73
- default:
74
- Logger_1.default.verbose.failure(`No recognizable shell returned for Windows environment.`);
75
- }
76
- }
77
- else if (currentOs === OperatingSystemType.MacOSX) {
78
- // Mighbt want to use process.env.SHELL for Linux environments
79
- }
80
- return ShellType.Unknown;
81
- }
82
- /**
83
- * Gets all file names in the current directory.
84
- */
85
- static async fileNamesInDir() {
86
- return (0, promises_1.readdir)(path_1.default.resolve('.'));
87
- }
88
- /**
89
- * Runs the startup script for the current system. This command exits the
90
- * package.
91
- *
92
- * The startup scripts are defined in the
93
- * [dotfiles repo](https://github.com/aneuhold/dotfiles).
94
- */
95
- static async runStartupScript() {
96
- let cmd = '';
97
- if (CurrentEnv.os === OperatingSystemType.Windows) {
98
- // & says to powershell that you actually want to run the script in the
99
- // quotes afterwards
100
- // Also just running the startup script for now because of some infinite
101
- // loop issues with specifying arguments
102
- cmd = `& "$Home\\startup.ps1"`;
103
- }
104
- else {
105
- cmd = 'zsh';
106
- const args = ['startup.sh'];
107
- await CLIService_1.default.spawnCmd(cmd, args, process.env.HOME);
108
- return;
109
- }
110
- Logger_1.default.info(`Executing the following command: "${cmd}"`);
111
- const { output } = await CLIService_1.default.execCmd(cmd);
112
- Logger_1.default.info(output);
113
- process.exit();
114
- }
115
- /**
116
- * Determines the type of operating system in the current environment.
117
- *
118
- * This looks to be O(1) complexity.
119
- */
120
- static get os() {
121
- if (process.platform === 'win32') {
122
- return OperatingSystemType.Windows;
123
- }
124
- if (process.platform === 'darwin') {
125
- return OperatingSystemType.MacOSX;
126
- }
127
- return OperatingSystemType.Unknown;
128
- }
129
- static folderName() {
130
- return path_1.default.basename(path_1.default.resolve('.'));
131
- }
132
- }
133
- exports.default = CurrentEnv;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TerminalType = exports.OperatingSystemType = exports.ShellType = void 0;
7
+ const promises_1 = require("fs/promises");
8
+ const path_1 = __importDefault(require("path"));
9
+ const CLIService_1 = __importDefault(require("../services/CLIService"));
10
+ const Logger_1 = __importDefault(require("./Logger"));
11
+ /**
12
+ * The type of shell that the current environment is running.
13
+ */
14
+ var ShellType;
15
+ (function (ShellType) {
16
+ ShellType[ShellType["PowerShellCore"] = 0] = "PowerShellCore";
17
+ ShellType[ShellType["PowerShellDesktop"] = 1] = "PowerShellDesktop";
18
+ ShellType[ShellType["Bash"] = 2] = "Bash";
19
+ ShellType[ShellType["Zsh"] = 3] = "Zsh";
20
+ ShellType[ShellType["CommandPrompt"] = 4] = "CommandPrompt";
21
+ ShellType[ShellType["Unknown"] = 5] = "Unknown";
22
+ })(ShellType = exports.ShellType || (exports.ShellType = {}));
23
+ var OperatingSystemType;
24
+ (function (OperatingSystemType) {
25
+ OperatingSystemType[OperatingSystemType["Windows"] = 0] = "Windows";
26
+ OperatingSystemType[OperatingSystemType["MacOSX"] = 1] = "MacOSX";
27
+ OperatingSystemType[OperatingSystemType["Linux"] = 2] = "Linux";
28
+ OperatingSystemType[OperatingSystemType["Unknown"] = 3] = "Unknown";
29
+ })(OperatingSystemType = exports.OperatingSystemType || (exports.OperatingSystemType = {}));
30
+ /**
31
+ * The type of terminal that the current enviornment is running.
32
+ */
33
+ var TerminalType;
34
+ (function (TerminalType) {
35
+ TerminalType[TerminalType["WindowsTerminal"] = 0] = "WindowsTerminal";
36
+ TerminalType[TerminalType["ITerm2"] = 1] = "ITerm2";
37
+ TerminalType[TerminalType["Unknown"] = 2] = "Unknown";
38
+ })(TerminalType = exports.TerminalType || (exports.TerminalType = {}));
39
+ /**
40
+ * Provides information relevant to the current environment this script is
41
+ * running in.
42
+ */
43
+ class CurrentEnv {
44
+ /**
45
+ * Returns the type of terminal the current environment is using.
46
+ */
47
+ static terminal() {
48
+ // See https://stackoverflow.com/questions/59733731/how-to-detect-if-running-in-the-new-windows-terminal
49
+ // for information on why this method was chosen.
50
+ if (process.env.WT_SESSION) {
51
+ return TerminalType.WindowsTerminal;
52
+ }
53
+ if (process.env.TERM_PROGRAM && process.env.TERM_PROGRAM === 'iTerm.app') {
54
+ return TerminalType.ITerm2;
55
+ }
56
+ return TerminalType.Unknown;
57
+ }
58
+ /**
59
+ * Returns the type of shell the current environment is using.
60
+ *
61
+ * This might be arbitrary because it seems that the exec command will use
62
+ * whatever the default shell is or whatever is specified as the shell
63
+ * option.
64
+ */
65
+ static async shell() {
66
+ const currentOs = CurrentEnv.os;
67
+ if (currentOs === OperatingSystemType.Windows) {
68
+ // Command comes from: https://stackoverflow.com/questions/34471956/how-to-determine-if-im-in-powershell-or-cmd
69
+ const { output } = await CLIService_1.default.execCmd('(dir 2>&1 *`|echo CMD);&<# rem #>echo ($PSVersionTable).PSEdition');
70
+ switch (output) {
71
+ case 'CMD':
72
+ return ShellType.CommandPrompt;
73
+ case 'Desktop':
74
+ return ShellType.PowerShellDesktop;
75
+ case 'Core':
76
+ return ShellType.PowerShellCore;
77
+ default:
78
+ Logger_1.default.verbose.failure(`No recognizable shell returned for Windows environment.`);
79
+ }
80
+ }
81
+ else if (currentOs === OperatingSystemType.MacOSX) {
82
+ // Mighbt want to use process.env.SHELL for Linux environments
83
+ }
84
+ return ShellType.Unknown;
85
+ }
86
+ /**
87
+ * Gets all file names in the current directory.
88
+ */
89
+ static async fileNamesInDir() {
90
+ return (0, promises_1.readdir)(path_1.default.resolve('.'));
91
+ }
92
+ /**
93
+ * Runs the startup script for the current system. This command exits the
94
+ * package.
95
+ *
96
+ * The startup scripts are defined in the
97
+ * [dotfiles repo](https://github.com/aneuhold/dotfiles).
98
+ */
99
+ static async runStartupScript() {
100
+ let cmd = '';
101
+ if (CurrentEnv.os === OperatingSystemType.Windows) {
102
+ // & says to powershell that you actually want to run the script in the
103
+ // quotes afterwards
104
+ // Also just running the startup script for now because of some infinite
105
+ // loop issues with specifying arguments
106
+ cmd = `& "$Home\\startup.ps1"`;
107
+ }
108
+ else {
109
+ cmd = 'zsh';
110
+ const args = ['startup.sh'];
111
+ await CLIService_1.default.spawnCmd(cmd, args, process.env.HOME);
112
+ return;
113
+ }
114
+ Logger_1.default.info(`Executing the following command: "${cmd}"`);
115
+ const { output } = await CLIService_1.default.execCmd(cmd);
116
+ Logger_1.default.info(output);
117
+ process.exit();
118
+ }
119
+ /**
120
+ * Determines the type of operating system in the current environment.
121
+ *
122
+ * This looks to be O(1) complexity.
123
+ */
124
+ static get os() {
125
+ if (process.platform === 'win32') {
126
+ return OperatingSystemType.Windows;
127
+ }
128
+ if (process.platform === 'darwin') {
129
+ return OperatingSystemType.MacOSX;
130
+ }
131
+ return OperatingSystemType.Unknown;
132
+ }
133
+ static folderName() {
134
+ return path_1.default.basename(path_1.default.resolve('.'));
135
+ }
136
+ }
137
+ exports.default = CurrentEnv;
@@ -1,68 +1,68 @@
1
- export default class Logger {
2
- static verboseLoggingEnabled: boolean;
3
- /**
4
- * Private variable that sets if any logging on this instance of the Log
5
- * should only log if the `verboseLoggingEnabled` is set to true.
6
- */
7
- private logOnlyIfVerbose;
8
- constructor(logOnlyIfVerbose?: boolean);
9
- /**
10
- * Sets the logging of the next chained function to only be activated
11
- * if verbose logging is turned on.
12
- */
13
- static get verbose(): Logger;
14
- /**
15
- * Logs info to the console. Prepends `â„šī¸` to each message.
16
- */
17
- info(msg: string, skipNewline?: boolean): void;
18
- /**
19
- * Static version of {@link Logger.prototype.info}.
20
- *
21
- * @see Logger.prototype.info
22
- */
23
- static info(msg: string, skipNewline?: boolean): void;
24
- /**
25
- * Logs a success message to the console. Prepends `✅` to each message.
26
- *
27
- * @param msg
28
- */
29
- success(msg: string): void;
30
- /**
31
- * Static version of {@link Logger.prototype.success}.
32
- *
33
- * @see Logger.prototype.success
34
- */
35
- static success(msg: string): void;
36
- /**
37
- * Logs a failure message to the console. Prepends `🔴` to each message.
38
- *
39
- * See {@link error} for logging errors.
40
- *
41
- * This doesn't use a `console.error` entry. Just a `console.log` entry.
42
- * @param msg
43
- */
44
- failure(msg: string): void;
45
- /**
46
- * Static version of {@link Logger.prototype.failure}.
47
- *
48
- * @see Logger.prototype.failure
49
- */
50
- static failure(msg: string): void;
51
- /**
52
- * Logs an error message to the console. Only use this for errors that will
53
- * likely stop execution. Prepends `💀` to each message and uses `console.error`.
54
- *
55
- * See {@link failure} for logging simple failures.
56
- *
57
- * @param msg
58
- */
59
- error(msg: string): void;
60
- /**
61
- * Static version of {@link Logger.prototype.error}.
62
- *
63
- * @see Logger.prototype.error
64
- */
65
- static error(msg: string): void;
66
- private shouldLog;
67
- }
1
+ export default class Logger {
2
+ static verboseLoggingEnabled: boolean;
3
+ /**
4
+ * Private variable that sets if any logging on this instance of the Log
5
+ * should only log if the `verboseLoggingEnabled` is set to true.
6
+ */
7
+ private logOnlyIfVerbose;
8
+ constructor(logOnlyIfVerbose?: boolean);
9
+ /**
10
+ * Sets the logging of the next chained function to only be activated
11
+ * if verbose logging is turned on.
12
+ */
13
+ static get verbose(): Logger;
14
+ /**
15
+ * Logs info to the console. Prepends `â„šī¸` to each message.
16
+ */
17
+ info(msg: string, skipNewline?: boolean): void;
18
+ /**
19
+ * Static version of {@link Logger.prototype.info}.
20
+ *
21
+ * @see Logger.prototype.info
22
+ */
23
+ static info(msg: string, skipNewline?: boolean): void;
24
+ /**
25
+ * Logs a success message to the console. Prepends `✅` to each message.
26
+ *
27
+ * @param msg
28
+ */
29
+ success(msg: string): void;
30
+ /**
31
+ * Static version of {@link Logger.prototype.success}.
32
+ *
33
+ * @see Logger.prototype.success
34
+ */
35
+ static success(msg: string): void;
36
+ /**
37
+ * Logs a failure message to the console. Prepends `🔴` to each message.
38
+ *
39
+ * See {@link error} for logging errors.
40
+ *
41
+ * This doesn't use a `console.error` entry. Just a `console.log` entry.
42
+ * @param msg
43
+ */
44
+ failure(msg: string): void;
45
+ /**
46
+ * Static version of {@link Logger.prototype.failure}.
47
+ *
48
+ * @see Logger.prototype.failure
49
+ */
50
+ static failure(msg: string): void;
51
+ /**
52
+ * Logs an error message to the console. Only use this for errors that will
53
+ * likely stop execution. Prepends `💀` to each message and uses `console.error`.
54
+ *
55
+ * See {@link failure} for logging simple failures.
56
+ *
57
+ * @param msg
58
+ */
59
+ error(msg: string): void;
60
+ /**
61
+ * Static version of {@link Logger.prototype.error}.
62
+ *
63
+ * @see Logger.prototype.error
64
+ */
65
+ static error(msg: string): void;
66
+ private shouldLog;
67
+ }
68
68
  //# sourceMappingURL=Logger.d.ts.map
@@ -1,112 +1,112 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class Logger {
4
- static verboseLoggingEnabled = false;
5
- /**
6
- * Private variable that sets if any logging on this instance of the Log
7
- * should only log if the `verboseLoggingEnabled` is set to true.
8
- */
9
- logOnlyIfVerbose = false;
10
- constructor(logOnlyIfVerbose) {
11
- if (logOnlyIfVerbose) {
12
- this.logOnlyIfVerbose = logOnlyIfVerbose;
13
- }
14
- }
15
- /**
16
- * Sets the logging of the next chained function to only be activated
17
- * if verbose logging is turned on.
18
- */
19
- static get verbose() {
20
- return new Logger(true);
21
- }
22
- /**
23
- * Logs info to the console. Prepends `â„šī¸` to each message.
24
- */
25
- info(msg, skipNewline) {
26
- if (this.shouldLog()) {
27
- const printMessage = `â„šī¸ ${msg}`;
28
- if (skipNewline) {
29
- process.stdout.write(printMessage);
30
- }
31
- else {
32
- console.log(printMessage);
33
- }
34
- }
35
- }
36
- /**
37
- * Static version of {@link Logger.prototype.info}.
38
- *
39
- * @see Logger.prototype.info
40
- */
41
- static info(msg, skipNewline) {
42
- new Logger().info(msg, skipNewline);
43
- }
44
- /**
45
- * Logs a success message to the console. Prepends `✅` to each message.
46
- *
47
- * @param msg
48
- */
49
- success(msg) {
50
- if (this.shouldLog()) {
51
- console.log(`✅ ${msg}`);
52
- }
53
- }
54
- /**
55
- * Static version of {@link Logger.prototype.success}.
56
- *
57
- * @see Logger.prototype.success
58
- */
59
- static success(msg) {
60
- new Logger().success(msg);
61
- }
62
- /**
63
- * Logs a failure message to the console. Prepends `🔴` to each message.
64
- *
65
- * See {@link error} for logging errors.
66
- *
67
- * This doesn't use a `console.error` entry. Just a `console.log` entry.
68
- * @param msg
69
- */
70
- failure(msg) {
71
- if (this.shouldLog()) {
72
- console.log(`🔴 ${msg}`);
73
- }
74
- }
75
- /**
76
- * Static version of {@link Logger.prototype.failure}.
77
- *
78
- * @see Logger.prototype.failure
79
- */
80
- static failure(msg) {
81
- new Logger().failure(msg);
82
- }
83
- /**
84
- * Logs an error message to the console. Only use this for errors that will
85
- * likely stop execution. Prepends `💀` to each message and uses `console.error`.
86
- *
87
- * See {@link failure} for logging simple failures.
88
- *
89
- * @param msg
90
- */
91
- error(msg) {
92
- if (this.shouldLog()) {
93
- console.error(`💀 ${msg}`);
94
- }
95
- }
96
- /**
97
- * Static version of {@link Logger.prototype.error}.
98
- *
99
- * @see Logger.prototype.error
100
- */
101
- static error(msg) {
102
- new Logger().error(msg);
103
- }
104
- shouldLog() {
105
- if (!this.logOnlyIfVerbose ||
106
- (this.logOnlyIfVerbose && Logger.verboseLoggingEnabled)) {
107
- return true;
108
- }
109
- return false;
110
- }
111
- }
112
- exports.default = Logger;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Logger {
4
+ static verboseLoggingEnabled = false;
5
+ /**
6
+ * Private variable that sets if any logging on this instance of the Log
7
+ * should only log if the `verboseLoggingEnabled` is set to true.
8
+ */
9
+ logOnlyIfVerbose = false;
10
+ constructor(logOnlyIfVerbose) {
11
+ if (logOnlyIfVerbose) {
12
+ this.logOnlyIfVerbose = logOnlyIfVerbose;
13
+ }
14
+ }
15
+ /**
16
+ * Sets the logging of the next chained function to only be activated
17
+ * if verbose logging is turned on.
18
+ */
19
+ static get verbose() {
20
+ return new Logger(true);
21
+ }
22
+ /**
23
+ * Logs info to the console. Prepends `â„šī¸` to each message.
24
+ */
25
+ info(msg, skipNewline) {
26
+ if (this.shouldLog()) {
27
+ const printMessage = `â„šī¸ ${msg}`;
28
+ if (skipNewline) {
29
+ process.stdout.write(printMessage);
30
+ }
31
+ else {
32
+ console.log(printMessage);
33
+ }
34
+ }
35
+ }
36
+ /**
37
+ * Static version of {@link Logger.prototype.info}.
38
+ *
39
+ * @see Logger.prototype.info
40
+ */
41
+ static info(msg, skipNewline) {
42
+ new Logger().info(msg, skipNewline);
43
+ }
44
+ /**
45
+ * Logs a success message to the console. Prepends `✅` to each message.
46
+ *
47
+ * @param msg
48
+ */
49
+ success(msg) {
50
+ if (this.shouldLog()) {
51
+ console.log(`✅ ${msg}`);
52
+ }
53
+ }
54
+ /**
55
+ * Static version of {@link Logger.prototype.success}.
56
+ *
57
+ * @see Logger.prototype.success
58
+ */
59
+ static success(msg) {
60
+ new Logger().success(msg);
61
+ }
62
+ /**
63
+ * Logs a failure message to the console. Prepends `🔴` to each message.
64
+ *
65
+ * See {@link error} for logging errors.
66
+ *
67
+ * This doesn't use a `console.error` entry. Just a `console.log` entry.
68
+ * @param msg
69
+ */
70
+ failure(msg) {
71
+ if (this.shouldLog()) {
72
+ console.log(`🔴 ${msg}`);
73
+ }
74
+ }
75
+ /**
76
+ * Static version of {@link Logger.prototype.failure}.
77
+ *
78
+ * @see Logger.prototype.failure
79
+ */
80
+ static failure(msg) {
81
+ new Logger().failure(msg);
82
+ }
83
+ /**
84
+ * Logs an error message to the console. Only use this for errors that will
85
+ * likely stop execution. Prepends `💀` to each message and uses `console.error`.
86
+ *
87
+ * See {@link failure} for logging simple failures.
88
+ *
89
+ * @param msg
90
+ */
91
+ error(msg) {
92
+ if (this.shouldLog()) {
93
+ console.error(`💀 ${msg}`);
94
+ }
95
+ }
96
+ /**
97
+ * Static version of {@link Logger.prototype.error}.
98
+ *
99
+ * @see Logger.prototype.error
100
+ */
101
+ static error(msg) {
102
+ new Logger().error(msg);
103
+ }
104
+ shouldLog() {
105
+ if (!this.logOnlyIfVerbose ||
106
+ (this.logOnlyIfVerbose && Logger.verboseLoggingEnabled)) {
107
+ return true;
108
+ }
109
+ return false;
110
+ }
111
+ }
112
+ exports.default = Logger;