clever-tools 3.1.0 → 3.2.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
@@ -10,11 +10,6 @@ Clever Tools are availables from many channels. The simpler way to install them,
10
10
  npm install -g clever-tools
11
11
  ```
12
12
 
13
- If you want to install our latest beta release, you can run:
14
-
15
- ```sh
16
- npm install -g clever-tools@beta
17
- ```
18
13
  We also distribute binaries and packages for multiple systems and tools:
19
14
 
20
15
  * [GNU/Linux](docs/setup-systems.md#gnulinux)
@@ -161,5 +156,5 @@ clever deploy
161
156
 
162
157
  ## Automated releases
163
158
 
164
- This project uses Jenkins to build binaries, package them and release them automatically on the various repositories.
159
+ This project uses GitHub Actions to build binaries, package them and release them automatically on the various repositories.
165
160
  If you want to know more or if you need to release a new version, please read [RELEASE.md](./RELEASE.md) carefully.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clever-tools",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Command Line Interface for Clever Cloud.",
5
5
  "main": "bin/clever.js",
6
6
  "keywords": [
@@ -25,7 +25,7 @@
25
25
  "scripts/*.sh"
26
26
  ],
27
27
  "dependencies": {
28
- "@clevercloud/client": "^8.0.2",
28
+ "@clevercloud/client": "^8.1.0",
29
29
  "clf-date": "^0.2.0",
30
30
  "cliparse": "^0.3.3",
31
31
  "colors": "1.4.0",
@@ -9,9 +9,9 @@ async function create (params) {
9
9
  const [name] = params.args;
10
10
  const { org: orgaIdOrName, alias, region, github: githubOwnerRepo, format } = params.options;
11
11
  const { apps } = await AppConfig.loadApplicationConf();
12
-
12
+
13
13
  AppConfig.checkAlreadyLinked(apps, name, alias);
14
-
14
+
15
15
  const github = getGithubDetails(githubOwnerRepo);
16
16
  const app = await Application.create(name, typeName, region, orgaIdOrName, github);
17
17
  await AppConfig.addLinkedApplication(app, alias);
@@ -43,7 +43,7 @@ async function deploy (params) {
43
43
  default: {
44
44
  const upToDateMessage = `The clever-cloud application is up-to-date (${colors.green(remoteHeadCommitId)}).\nYou can set a policy with 'same-commit-policy' to handle differently when remote HEAD has the same commit as the one to push.\nOr try this command to restart the application:`;
45
45
  if (commitIdToPush !== deployedCommitId) {
46
- const restartWithId = `clever restart --commit ${commitIdToPush}`
46
+ const restartWithId = `clever restart --commit ${commitIdToPush}`;
47
47
  throw new Error(`${upToDateMessage}\n${colors.yellow(restartWithId)}`);
48
48
  }
49
49
  throw new Error(`${upToDateMessage}\n${colors.yellow('clever restart')}`);
@@ -1,4 +1,4 @@
1
- const { getHostAndTokens } = require('./send-to-api.js');
1
+ const { getHostAndTokens, processError } = require('./send-to-api.js');
2
2
  const colors = require('colors/safe');
3
3
  const { Deferred } = require('./utils.js');
4
4
  const Logger = require('../logger.js');
@@ -9,6 +9,11 @@ const { ApplicationLogStream } = require('@clevercloud/client/cjs/streams/applic
9
9
  const THROTTLE_ELEMENTS = 2000;
10
10
  const THROTTLE_PER_IN_MILLISECONDS = 100;
11
11
 
12
+ const retryConfiguration = {
13
+ enabled: true,
14
+ maxRetryCount: 6,
15
+ };
16
+
12
17
  async function displayLogs (params) {
13
18
 
14
19
  const deferred = params.deferred || new Deferred();
@@ -20,6 +25,8 @@ async function displayLogs (params) {
20
25
  tokens,
21
26
  ownerId,
22
27
  appId,
28
+ connectionTimeout: 10_000,
29
+ retryConfiguration,
23
30
  since,
24
31
  until,
25
32
  deploymentId,
@@ -33,10 +40,10 @@ async function displayLogs (params) {
33
40
 
34
41
  logStream
35
42
  .on('open', (event) => {
36
- Logger.debug(`stream opened! ${JSON.stringify({ appId, filter, deploymentId })}`);
43
+ Logger.debug(colors.blue(`Logs stream (open) ${JSON.stringify({ appId, filter, deploymentId })}`));
37
44
  })
38
45
  .on('error', (event) => {
39
- Logger.error(`an error occured: ${event.detail}`);
46
+ Logger.debug(colors.red(`Logs stream (error) ${event.error.message}`));
40
47
  })
41
48
  .onLog((log) => {
42
49
  Logger.println(formatLogLine(log));
@@ -45,6 +52,7 @@ async function displayLogs (params) {
45
52
  // start() is blocking until end of stream
46
53
  logStream.start()
47
54
  .then((reason) => deferred.resolve())
55
+ .catch(processError)
48
56
  .catch((error) => deferred.reject(error));
49
57
 
50
58
  return logStream;
@@ -23,12 +23,22 @@ async function sendToApi (requestParams) {
23
23
  .then(prefixUrl(conf.API_HOST))
24
24
  .then(addOauthHeader(tokens))
25
25
  .then((requestParams) => {
26
- if (process.env.CLEVER_VERBOSE) {
27
- Logger.debug(`${requestParams.method.toUpperCase()} ${requestParams.url} ? ${JSON.stringify(requestParams.queryParams)}`);
28
- }
26
+ Logger.debug(`${requestParams.method.toUpperCase()} ${requestParams.url} ? ${JSON.stringify(requestParams.queryParams)}`);
29
27
  return requestParams;
30
28
  })
31
- .then((requestParams) => request(requestParams, { retry: 1 }));
29
+ .then(request)
30
+ .catch(processError);
31
+ }
32
+
33
+ function processError (error) {
34
+ const code = error.code ?? error?.cause?.code;
35
+ if (code === 'EAI_AGAIN') {
36
+ throw new Error('Cannot reach the Clever Cloud API, please check your internet connection.', { cause: error });
37
+ }
38
+ if (code === 'ECONNRESET') {
39
+ throw new Error('The connection to the Clever Cloud API was closed abruptly, please try again.', { cause: error });
40
+ }
41
+ throw error;
32
42
  }
33
43
 
34
44
  function sendToWarp10 (requestParams) {
@@ -45,4 +55,4 @@ async function getHostAndTokens () {
45
55
  };
46
56
  }
47
57
 
48
- module.exports = { sendToApi, sendToWarp10, getHostAndTokens };
58
+ module.exports = { sendToApi, sendToWarp10, getHostAndTokens, processError };