servyx-cli 0.1.0 → 0.1.1

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
@@ -20,7 +20,7 @@ cd servyx-cli && npm install && npm link
20
20
  ## Quick start
21
21
 
22
22
  ```bash
23
- # 1. Authenticate (defaults to http://127.0.0.1:3871)
23
+ # 1. Authenticate (defaults to https://cli.servyxhq.com)
24
24
  servyx login
25
25
 
26
26
  # 2. Link your project directory to an app
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "servyx-cli",
3
- "version": "0.1.0",
4
- "description": "Servyx CLI — rsync local projects and deploy via the Servyx platform",
3
+ "version": "0.1.1",
4
+ "description": "Servyx CLI — Upload local projects and deploy via the Servyx platform",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "servyx": "./bin/servyx.js"
@@ -75,7 +75,16 @@ export async function runDeploy(options = {}) {
75
75
  console.log(pc.green('Rsync complete.'));
76
76
 
77
77
  console.log(pc.bold('Starting deployment...'));
78
- const startResult = await startDeployment(appId, message);
78
+ let startResult;
79
+ try {
80
+ startResult = await startDeployment(appId, message);
81
+ } catch (err) {
82
+ if (err.code === 'APP_NOT_FOUND') {
83
+ console.error(pc.red('Application not found by server-service.'));
84
+ console.error(pc.yellow('Run servyx link again — cli-service and server-service must use the same database.'));
85
+ }
86
+ throw err;
87
+ }
79
88
  const deployment = startResult?.data?.deployment;
80
89
  const deploymentId = deployment?.id;
81
90
 
package/src/lib/api.js CHANGED
@@ -5,7 +5,7 @@ function createClient(token = getToken()) {
5
5
  const baseURL = `${getApiBaseUrl()}/api/v1/cli`;
6
6
  return axios.create({
7
7
  baseURL,
8
- timeout: 60000,
8
+ timeout: 120000,
9
9
  headers: {
10
10
  'Content-Type': 'application/json',
11
11
  ...(token ? { Authorization: `Bearer ${token}` } : {}),
@@ -14,6 +14,18 @@ function createClient(token = getToken()) {
14
14
  });
15
15
  }
16
16
 
17
+ function mapNetworkError(err, action = 'request') {
18
+ if (err?.response || err?.status) throw err;
19
+ if (['ECONNRESET', 'ECONNREFUSED', 'ENOTFOUND', 'ETIMEDOUT'].includes(err?.code)) {
20
+ const hint = new Error(
21
+ `Cannot reach Servyx API at ${getApiBaseUrl()} (${err.code}). Is cli-service running?`,
22
+ );
23
+ hint.code = err.code;
24
+ throw hint;
25
+ }
26
+ throw err;
27
+ }
28
+
17
29
  function unwrap(response) {
18
30
  if (response.status >= 200 && response.status < 300) {
19
31
  return response.data;
@@ -43,8 +55,12 @@ export async function getDeployTarget(appId) {
43
55
  }
44
56
 
45
57
  export async function startDeployment(appId, message) {
46
- const client = createClient();
47
- return unwrap(await client.post(`/apps/${appId}/deployments`, { message }));
58
+ try {
59
+ const client = createClient();
60
+ return unwrap(await client.post(`/apps/${appId}/deployments`, { message }));
61
+ } catch (err) {
62
+ mapNetworkError(err, 'start deployment');
63
+ }
48
64
  }
49
65
 
50
66
  export async function getDeployment(deploymentId) {
package/src/lib/config.js CHANGED
@@ -29,7 +29,7 @@ export function getApiBaseUrl() {
29
29
  const env = process.env.SERVYX_API_URL;
30
30
  if (env) return env.replace(/\/+$/, '');
31
31
  const cfg = loadGlobalConfig();
32
- return (cfg?.apiUrl || 'http://127.0.0.1:3871').replace(/\/+$/, '');
32
+ return (cfg?.apiUrl || 'https://cli.servyxhq.com').replace(/\/+$/, '');
33
33
  }
34
34
 
35
35
  export function getToken() {