mudhost 1.0.0 → 1.1.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.
package/README.md CHANGED
@@ -26,7 +26,7 @@ https://my-project-main-12345.your-domain.com
26
26
  ## Commands
27
27
 
28
28
  Login
29
- ```bash
29
+ ```bashz
30
30
  npx mudhost login [options]
31
31
  ```
32
32
  Deploy
package/bin/hosting.js CHANGED
@@ -1,9 +1,9 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const { CLI } = require('../src/cli');
4
4
 
5
5
  const cli = new CLI();
6
6
  cli.run().catch(error => {
7
- console.error('❌ Error:', error.message);
7
+ console.error('❌ Error:', error);
8
8
  process.exit(1);
9
9
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mudhost",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "CLI for Hosting - deploy preview environments with one command",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
package/src/auth.js CHANGED
@@ -11,7 +11,13 @@ class AuthManager {
11
11
  }
12
12
 
13
13
  async login(apiUrl, options) {
14
- let { username, password } = options;
14
+ let { username, password, token } = options;
15
+
16
+ if (token) {
17
+ await this.config.set('token', token);
18
+ await this.config.set('apiUrl', apiUrl);
19
+ return token;
20
+ }
15
21
 
16
22
  // Если credentials не предоставлены, запросим их
17
23
  if (!username || !password) {
@@ -57,7 +63,7 @@ class AuthManager {
57
63
  if (error.response?.status === 401) {
58
64
  throw new Error('Invalid credentials');
59
65
  }
60
- throw new Error(`Login failed: ${error.message}`);
66
+ throw new Error(`Login failed: ${error}`);
61
67
  }
62
68
  }
63
69
 
@@ -86,7 +92,7 @@ class AuthManager {
86
92
  console.log(` Role: ${chalk.bold(user.role)}`);
87
93
  console.log(` API: ${chalk.bold(config.apiUrl)}`);
88
94
  } catch (error) {
89
- throw new Error(`Failed to get user info: ${error.message}`);
95
+ throw new Error(`Failed to get user info: ${error}`);
90
96
  }
91
97
  }
92
98
 
package/src/cli.js CHANGED
@@ -25,6 +25,7 @@ class CLI {
25
25
  .description('Login to Mud Hosting')
26
26
  .option('-u, --username <username>', 'Username')
27
27
  .option('-p, --password <password>', 'Password')
28
+ .option('-t, --token <token>', 'Token (overrides username and password)')
28
29
  .option('--api <url>', 'API URL', 'http://localhost:8000')
29
30
  .action(async (options) => {
30
31
  await this.handleLogin(options);
@@ -97,7 +98,7 @@ class CLI {
97
98
  await this.auth.login(apiUrl, options);
98
99
  console.log(chalk.green('✅ Login successful!'));
99
100
  } catch (error) {
100
- console.error(chalk.red('❌ Login failed:'), error.message);
101
+ console.error(chalk.red('❌ Login failed:'), error);
101
102
  process.exit(1);
102
103
  }
103
104
  }
@@ -113,7 +114,7 @@ class CLI {
113
114
  try {
114
115
  await this.deploy.deploy(projectId, distDir, options, apiUrl);
115
116
  } catch (error) {
116
- console.error(chalk.red('❌ Deployment failed:'), error.message);
117
+ console.error(chalk.red('❌ Deployment failed:'), error);
117
118
  process.exit(1);
118
119
  }
119
120
  }
@@ -129,7 +130,7 @@ class CLI {
129
130
  try {
130
131
  await this.deploy.listDeployments(apiUrl, options.project);
131
132
  } catch (error) {
132
- console.error(chalk.red('❌ Failed to list deployments:'), error.message);
133
+ console.error(chalk.red('❌ Failed to list deployments:'), error);
133
134
  process.exit(1);
134
135
  }
135
136
  }
@@ -145,7 +146,7 @@ class CLI {
145
146
  try {
146
147
  await this.deploy.deleteDeployment(deploymentId, apiUrl);
147
148
  } catch (error) {
148
- console.error(chalk.red('❌ Failed to delete deployment:'), error.message);
149
+ console.error(chalk.red('❌ Failed to delete deployment:'), error);
149
150
  process.exit(1);
150
151
  }
151
152
  }
@@ -161,7 +162,7 @@ class CLI {
161
162
  try {
162
163
  await this.auth.whoami(apiUrl);
163
164
  } catch (error) {
164
- console.error(chalk.red('❌ Failed to get user info:'), error.message);
165
+ console.error(chalk.red('❌ Failed to get user info:'), error);
165
166
  process.exit(1);
166
167
  }
167
168
  }
package/src/deploy.js CHANGED
@@ -38,7 +38,7 @@ class DeployManager {
38
38
  return files;
39
39
  } catch (error) {
40
40
  spinner.fail();
41
- throw new Error(`Failed to read files: ${error.message}`);
41
+ throw new Error(`Failed to read files: ${error}`);
42
42
  }
43
43
  }
44
44
 
@@ -92,7 +92,7 @@ class DeployManager {
92
92
 
93
93
  if (error.response) {
94
94
  const status = error.response.status;
95
- const message = error.response.data?.error || error.message;
95
+ const message = error.response.data?.error || error;
96
96
 
97
97
  switch (status) {
98
98
  case 401:
@@ -104,7 +104,7 @@ class DeployManager {
104
104
  }
105
105
  }
106
106
 
107
- throw new Error(`Deployment failed: ${error.message}`);
107
+ throw new Error(`Deployment failed: ${error}`);
108
108
  }
109
109
  }
110
110
 
@@ -150,7 +150,7 @@ class DeployManager {
150
150
 
151
151
  } catch (error) {
152
152
  spinner.fail();
153
- throw new Error(`Failed to list deployments: ${error.message}`);
153
+ throw new Error(`Failed to list deployments: ${error}`);
154
154
  }
155
155
  }
156
156
 
@@ -169,7 +169,7 @@ class DeployManager {
169
169
  throw new Error(`Deployment not found: ${deploymentId}`);
170
170
  }
171
171
 
172
- throw new Error(`Failed to delete deployment: ${error.message}`);
172
+ throw new Error(`Failed to delete deployment: ${error}`);
173
173
  }
174
174
  }
175
175
  }