meocord 4.0.0-beta.2 → 4.0.0-beta.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # meocord
2
2
 
3
+ ## 4.0.0-beta.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#40](https://github.com/l7aromeo/meocord/pull/40) [`3629edd`](https://github.com/l7aromeo/meocord/commit/3629eddaf20bd0947d24e5582aa167b2c0ca0d47) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Lint `meocord.config.ts`. The shared ESLint config from `meocord/eslint` ignored it, so the config
8
+ alone skipped the rules every other file follows — unused imports, formatting. It is linted like the
9
+ rest now; the typecheck it already gets is unchanged.
10
+
11
+ - [#40](https://github.com/l7aromeo/meocord/pull/40) [`80b8302`](https://github.com/l7aromeo/meocord/commit/80b83021894ef8a964a12ac1610c2ec9b40f344e) Thanks [@l7aromeo](https://github.com/l7aromeo)! - Exit with code 1 when the login fails, whatever the entry point does. `app.start()` now sets
12
+ `process.exitCode = 1` before rejecting, so an existing `main.ts` whose `catch` only logs the error no
13
+ longer exits 0 — no `process.exitCode = 1` needs adding to it, and new applications' `main.ts` no
14
+ longer carries one.
15
+
3
16
  ## 4.0.0-beta.2
4
17
 
5
18
  ### Major Changes
@@ -109,9 +109,12 @@ class MeoCordApp {
109
109
  /**
110
110
  * Registers the Discord event handlers and logs in.
111
111
  *
112
- * Rejects when the login fails -- an invalid token, or Discord unreachable -- so the caller can
113
- * stop with a non-zero exit code. A bot that never came online is a failed start, and a
114
- * supervisor such as Docker's `restart: on-failure` or systemd can only tell if the process says so.
112
+ * Rejects when the login fails -- an invalid token, or Discord unreachable -- and sets the exit
113
+ * code to 1 first. A bot that never came online is a failed start, and a supervisor such as
114
+ * Docker's `restart: on-failure` or systemd can only tell if the process says so. The exit code is
115
+ * set here rather than left to the entry point because an entry point that catches the rejection
116
+ * to log it has handled it, and the process would otherwise end with 0. A later `start()` that
117
+ * logs in -- an entry point retrying -- clears the code again, if this is what set it.
115
118
  */ async start() {
116
119
  this.logger.log('Starting bot...');
117
120
  this.bot.on('clientReady', ()=>this.runListener('clientReady', async ()=>{
@@ -128,7 +131,19 @@ class MeoCordApp {
128
131
  user,
129
132
  action: enum_index.ReactionHandlerAction.REMOVE
130
133
  })));
131
- await this.bot.login(this.discordToken);
134
+ try {
135
+ await this.bot.login(this.discordToken);
136
+ } catch (error) {
137
+ if (process.exitCode === undefined || process.exitCode === 0) {
138
+ process.exitCode = 1;
139
+ MeoCordApp.failedLoginSetExitCode = true;
140
+ }
141
+ throw error;
142
+ }
143
+ if (MeoCordApp.failedLoginSetExitCode && process.exitCode === 1) {
144
+ process.exitCode = undefined;
145
+ MeoCordApp.failedLoginSetExitCode = false;
146
+ }
132
147
  this.logger.log('Bot is online!');
133
148
  }
134
149
  async registerCommands() {
@@ -508,6 +523,7 @@ class MeoCordApp {
508
523
  process.on('SIGTERM', ()=>this.gracefulShutdown());
509
524
  }
510
525
  }
526
+ /** Whether a failed login set the process exit code, so a later successful one knows to clear it. */ MeoCordApp.failedLoginSetExitCode = false;
511
527
 
512
528
  /**
513
529
  * File written beside a bundle that carries native addons, naming the platform it was built for.
@@ -11,8 +11,4 @@ async function bootstrap() {
11
11
  logger.log('Application started')
12
12
  }
13
13
 
14
- bootstrap().catch(error => {
15
- logger.error('Error during startup:', error)
16
- // A bot that never came online is a failed start: exit non-zero, so Docker, systemd or CI see it.
17
- process.exitCode = 1
18
- })
14
+ bootstrap().catch(error => logger.error('Error during startup:', error))
@@ -91,9 +91,12 @@ class MeoCordApp {
91
91
  /**
92
92
  * Registers the Discord event handlers and logs in.
93
93
  *
94
- * Rejects when the login fails -- an invalid token, or Discord unreachable -- so the caller can
95
- * stop with a non-zero exit code. A bot that never came online is a failed start, and a
96
- * supervisor such as Docker's `restart: on-failure` or systemd can only tell if the process says so.
94
+ * Rejects when the login fails -- an invalid token, or Discord unreachable -- and sets the exit
95
+ * code to 1 first. A bot that never came online is a failed start, and a supervisor such as
96
+ * Docker's `restart: on-failure` or systemd can only tell if the process says so. The exit code is
97
+ * set here rather than left to the entry point because an entry point that catches the rejection
98
+ * to log it has handled it, and the process would otherwise end with 0. A later `start()` that
99
+ * logs in -- an entry point retrying -- clears the code again, if this is what set it.
97
100
  */ async start() {
98
101
  this.logger.log('Starting bot...');
99
102
  this.bot.on('clientReady', ()=>this.runListener('clientReady', async ()=>{
@@ -110,7 +113,19 @@ class MeoCordApp {
110
113
  user,
111
114
  action: ReactionHandlerAction.REMOVE
112
115
  })));
113
- await this.bot.login(this.discordToken);
116
+ try {
117
+ await this.bot.login(this.discordToken);
118
+ } catch (error) {
119
+ if (process.exitCode === undefined || process.exitCode === 0) {
120
+ process.exitCode = 1;
121
+ MeoCordApp.failedLoginSetExitCode = true;
122
+ }
123
+ throw error;
124
+ }
125
+ if (MeoCordApp.failedLoginSetExitCode && process.exitCode === 1) {
126
+ process.exitCode = undefined;
127
+ MeoCordApp.failedLoginSetExitCode = false;
128
+ }
114
129
  this.logger.log('Bot is online!');
115
130
  }
116
131
  async registerCommands() {
@@ -490,5 +505,6 @@ class MeoCordApp {
490
505
  process.on('SIGTERM', ()=>this.gracefulShutdown());
491
506
  }
492
507
  }
508
+ /** Whether a failed login set the process exit code, so a later successful one knows to clear it. */ MeoCordApp.failedLoginSetExitCode = false;
493
509
 
494
510
  export { MeoCordApp };
@@ -1,4 +1,4 @@
1
- var version = "4.0.0-beta.2";
1
+ var version = "4.0.0-beta.3";
2
2
  var packageJson = {
3
3
  version: version};
4
4
 
@@ -39,12 +39,17 @@ declare class MeoCordApp {
39
39
  */
40
40
  private updateActivity;
41
41
  private getInstance;
42
+ /** Whether a failed login set the process exit code, so a later successful one knows to clear it. */
43
+ private static failedLoginSetExitCode;
42
44
  /**
43
45
  * Registers the Discord event handlers and logs in.
44
46
  *
45
- * Rejects when the login fails -- an invalid token, or Discord unreachable -- so the caller can
46
- * stop with a non-zero exit code. A bot that never came online is a failed start, and a
47
- * supervisor such as Docker's `restart: on-failure` or systemd can only tell if the process says so.
47
+ * Rejects when the login fails -- an invalid token, or Discord unreachable -- and sets the exit
48
+ * code to 1 first. A bot that never came online is a failed start, and a supervisor such as
49
+ * Docker's `restart: on-failure` or systemd can only tell if the process says so. The exit code is
50
+ * set here rather than left to the entry point because an entry point that catches the rejection
51
+ * to log it has handled it, and the process would otherwise end with 0. A later `start()` that
52
+ * logs in -- an entry point retrying -- clears the code again, if this is what set it.
48
53
  */
49
54
  start(): Promise<void>;
50
55
  registerCommands(): Promise<void>;
@@ -39,12 +39,17 @@ declare class MeoCordApp {
39
39
  */
40
40
  private updateActivity;
41
41
  private getInstance;
42
+ /** Whether a failed login set the process exit code, so a later successful one knows to clear it. */
43
+ private static failedLoginSetExitCode;
42
44
  /**
43
45
  * Registers the Discord event handlers and logs in.
44
46
  *
45
- * Rejects when the login fails -- an invalid token, or Discord unreachable -- so the caller can
46
- * stop with a non-zero exit code. A bot that never came online is a failed start, and a
47
- * supervisor such as Docker's `restart: on-failure` or systemd can only tell if the process says so.
47
+ * Rejects when the login fails -- an invalid token, or Discord unreachable -- and sets the exit
48
+ * code to 1 first. A bot that never came online is a failed start, and a supervisor such as
49
+ * Docker's `restart: on-failure` or systemd can only tell if the process says so. The exit code is
50
+ * set here rather than left to the entry point because an entry point that catches the rejection
51
+ * to log it has handled it, and the process would otherwise end with 0. A later `start()` that
52
+ * logs in -- an entry point retrying -- clears the code again, if this is what set it.
48
53
  */
49
54
  start(): Promise<void>;
50
55
  registerCommands(): Promise<void>;
@@ -77,7 +77,7 @@ const specConfig = {
77
77
  }
78
78
 
79
79
  module.exports = [
80
- { ignores: ['docs/*', 'build/*', 'lib/*', 'dist/*', 'meocord.config.ts', 'vitest.config.ts'] },
80
+ { ignores: ['docs/*', 'build/*', 'lib/*', 'dist/*', 'vitest.config.ts'] },
81
81
  ...recommendedTypeScriptConfigs,
82
82
  specConfig,
83
83
  eslintConfigPrettier,
@@ -77,7 +77,7 @@ const specConfig = {
77
77
  }
78
78
 
79
79
  export default [
80
- { ignores: ['docs/*', 'build/*', 'lib/*', 'dist/*', 'meocord.config.ts', 'vitest.config.ts'] },
80
+ { ignores: ['docs/*', 'build/*', 'lib/*', 'dist/*', 'vitest.config.ts'] },
81
81
  ...recommendedTypeScriptConfigs,
82
82
  specConfig,
83
83
  eslintConfigPrettier,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "meocord",
3
3
  "description": "Decorator-based Discord bot framework built on discord.js. Brings NestJS-style controllers, dependency injection, guards, and testing utilities to bot development — with a full CLI and TypeScript-first design.",
4
- "version": "4.0.0-beta.2",
4
+ "version": "4.0.0-beta.3",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=22.13"