clever-tools 2.8.0 → 2.8.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/CHANGELOG.md +4 -0
- package/README.md +34 -2
- package/package.json +31 -27
- package/src/commands/notify-email.js +1 -0
- package/src/models/accesslogs.js +2 -1
- package/src/models/configuration.js +36 -8
- package/src/models/deployments.js +1 -0
- package/src/models/fs-utils.js +2 -5
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -26,6 +26,14 @@ npm install -g clever-tools@beta
|
|
|
26
26
|
|
|
27
27
|
#### Debian/Ubuntu (.deb)
|
|
28
28
|
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
##### Warning
|
|
32
|
+
|
|
33
|
+
Bintray is ending on May 1st 2021, we will migrate hosting as soon as possible. Please refer to the dedicated [issue](https://github.com/CleverCloud/clever-tools/issues/454) to track the migration.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
29
37
|
If you are using a GNU/Linux distribution that uses `.deb` packages like Debian or Ubuntu, you can run:
|
|
30
38
|
|
|
31
39
|
```sh
|
|
@@ -46,6 +54,14 @@ echo "deb https://dl.bintray.com/clevercloud/deb unstable beta" | tee -a /etc/ap
|
|
|
46
54
|
|
|
47
55
|
#### CentOS/Fedora (.rpm)
|
|
48
56
|
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
##### Warning
|
|
60
|
+
|
|
61
|
+
Bintray is ending on May 1st 2021, we will migrate hosting as soon as possible. Please refer to the dedicated [issue](https://github.com/CleverCloud/clever-tools/issues/454) to track the migration.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
49
65
|
If you are using a GNU/Linux distribution that uses `.rpm` packages like CentOS or Fedora, you can run:
|
|
50
66
|
|
|
51
67
|
```sh
|
|
@@ -131,7 +147,15 @@ NOTES:
|
|
|
131
147
|
|
|
132
148
|
#### Using chocolatey
|
|
133
149
|
|
|
134
|
-
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
##### Warning
|
|
153
|
+
|
|
154
|
+
Bintray is ending on May 1st 2021, we will migrate hosting as soon as possible. Please refer to the dedicated [issue](https://github.com/CleverCloud/clever-tools/issues/454) to track the migration.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
If you are using Windows and you have [chocolatey](https://chocolatey.org) installed, you can run:
|
|
135
159
|
|
|
136
160
|
```bash
|
|
137
161
|
choco sources add -n=clevercloud -s='https://api.bintray.com/nuget/clevercloud/nupkg'
|
|
@@ -160,6 +184,14 @@ docker pull clevercloud/clever-tools
|
|
|
160
184
|
docker run --rm clever-tools <command>
|
|
161
185
|
```
|
|
162
186
|
|
|
187
|
+
#### Dockerfile
|
|
188
|
+
|
|
189
|
+
In your `Dockerfile` you can copy the clever-tools CLI from the image itself with a simple one liner:
|
|
190
|
+
|
|
191
|
+
```Dockerfile
|
|
192
|
+
COPY --from=clevercloud/clever-tools /bin/clever /usr/local/bin/clever
|
|
193
|
+
```
|
|
194
|
+
|
|
163
195
|
### Via Nix
|
|
164
196
|
|
|
165
197
|
If you are using Nix, you will find a Nix derivation on Fretlink's Github repository: https://github.com/fretlink/clever-tools-nix
|
|
@@ -168,7 +200,7 @@ If you are using Nix, you will find a Nix derivation on Fretlink's Github reposi
|
|
|
168
200
|
|
|
169
201
|
The clever-tools CLI comes with a comprehensive auto-completion system.
|
|
170
202
|
Some installation methods like `.deb` packages, `.rpm` packages or brew will try to enable it automatically.
|
|
171
|
-
If it does not work, try this for bash:
|
|
203
|
+
If it does not work, try this for bash:
|
|
172
204
|
|
|
173
205
|
```bash
|
|
174
206
|
clever --bash-autocomplete-script $(which clever) | sudo tee /usr/share/bash-completion/completions/clever
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clever-tools",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "Command Line Interface for Clever Cloud.",
|
|
5
5
|
"main": "bin/clever.js",
|
|
6
6
|
"keywords": [
|
|
@@ -25,45 +25,45 @@
|
|
|
25
25
|
"scripts/*.sh"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@clevercloud/client": "^7.
|
|
28
|
+
"@clevercloud/client": "^7.4.0",
|
|
29
29
|
"clf-date": "^0.2.0",
|
|
30
30
|
"cliparse": "^0.3.3",
|
|
31
|
-
"colors": "
|
|
31
|
+
"colors": "1.4.0",
|
|
32
32
|
"common-env": "^6.4.0",
|
|
33
|
-
"eventsource": "^1.0
|
|
34
|
-
"isomorphic-git": "1.
|
|
33
|
+
"eventsource": "^1.1.0",
|
|
34
|
+
"isomorphic-git": "^1.8.2",
|
|
35
35
|
"linux-release-info": "^3.0.0",
|
|
36
|
-
"lodash": "^4.17.
|
|
36
|
+
"lodash": "^4.17.21",
|
|
37
37
|
"mkdirp": "^1.0.4",
|
|
38
|
-
"moment": "^2.
|
|
38
|
+
"moment": "^2.29.1",
|
|
39
39
|
"opn": "^6.0.0",
|
|
40
|
-
"slugify": "^1.
|
|
41
|
-
"string-length": "^
|
|
42
|
-
"superagent": "^6.
|
|
40
|
+
"slugify": "^1.5.3",
|
|
41
|
+
"string-length": "^4.0.2",
|
|
42
|
+
"superagent": "^6.1.0",
|
|
43
43
|
"text-table": "^0.2.0",
|
|
44
|
-
"update-notifier": "^
|
|
45
|
-
"ws": "^7.
|
|
44
|
+
"update-notifier": "^5.1.0",
|
|
45
|
+
"ws": "^7.4.6",
|
|
46
46
|
"xdg": "^0.1.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"aws-sdk": "^2.
|
|
50
|
-
"chai": "^4.
|
|
51
|
-
"del": "^
|
|
52
|
-
"eslint": "^7.
|
|
53
|
-
"eslint-config-standard": "^
|
|
54
|
-
"eslint-plugin-import": "^2.
|
|
49
|
+
"aws-sdk": "^2.919.0",
|
|
50
|
+
"chai": "^4.3.4",
|
|
51
|
+
"del": "^6.0.0",
|
|
52
|
+
"eslint": "^7.27.0",
|
|
53
|
+
"eslint-config-standard": "^16.0.3",
|
|
54
|
+
"eslint-plugin-import": "^2.23.4",
|
|
55
55
|
"eslint-plugin-node": "^11.1.0",
|
|
56
|
-
"eslint-plugin-promise": "^
|
|
57
|
-
"eslint-plugin-standard": "^
|
|
58
|
-
"fs-extra": "^
|
|
59
|
-
"glob": "^7.1.
|
|
60
|
-
"grunt": "^1.
|
|
61
|
-
"grunt-cli": "^1.3
|
|
56
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
57
|
+
"eslint-plugin-standard": "^5.0.0",
|
|
58
|
+
"fs-extra": "^10.0.0",
|
|
59
|
+
"glob": "^7.1.7",
|
|
60
|
+
"grunt": "^1.4.1",
|
|
61
|
+
"grunt-cli": "^1.4.3",
|
|
62
62
|
"grunt-http": "^2.3.3",
|
|
63
63
|
"grunt-mocha-test": "^0.13.3",
|
|
64
|
-
"mocha": "^8.
|
|
65
|
-
"pkg": "^
|
|
66
|
-
"semver": "^7.3.
|
|
64
|
+
"mocha": "^8.4.0",
|
|
65
|
+
"pkg": "^5.2.1",
|
|
66
|
+
"semver": "^7.3.5"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"pretest": "npm run lint",
|
|
@@ -83,5 +83,9 @@
|
|
|
83
83
|
"scripts": [
|
|
84
84
|
"src/**/*.js"
|
|
85
85
|
]
|
|
86
|
+
},
|
|
87
|
+
"volta": {
|
|
88
|
+
"node": "12.22.8",
|
|
89
|
+
"npm": "6.14.15"
|
|
86
90
|
}
|
|
87
91
|
}
|
package/src/models/accesslogs.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const fs = require('fs');
|
|
3
|
+
const { promises: fs } = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const util = require('util');
|
|
6
|
-
|
|
7
|
-
const readFile = util.promisify(fs.readFile);
|
|
8
|
-
const writeFile = util.promisify(fs.writeFile);
|
|
9
5
|
|
|
10
6
|
const commonEnv = require('common-env');
|
|
11
7
|
const mkdirp = require('mkdirp');
|
|
@@ -14,7 +10,7 @@ const xdg = require('xdg');
|
|
|
14
10
|
const Logger = require('../logger.js');
|
|
15
11
|
const env = commonEnv(Logger);
|
|
16
12
|
|
|
17
|
-
function
|
|
13
|
+
function getConfigDir () {
|
|
18
14
|
if (process.platform === 'win32') {
|
|
19
15
|
return path.resolve(process.env.APPDATA, 'clever-cloud');
|
|
20
16
|
}
|
|
@@ -23,6 +19,37 @@ function getConfigPath () {
|
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
21
|
|
|
22
|
+
function getConfigPath () {
|
|
23
|
+
const configDir = getConfigDir();
|
|
24
|
+
return path.resolve(configDir, 'clever-tools.json');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function isFile (path) {
|
|
28
|
+
try {
|
|
29
|
+
const pathStat = await fs.stat(path);
|
|
30
|
+
return pathStat.isFile();
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function maybeMigrateFromLegacyConfigurationPath () {
|
|
38
|
+
// This used to be a file
|
|
39
|
+
const configDir = getConfigDir();
|
|
40
|
+
const legacyConfig = await isFile(configDir);
|
|
41
|
+
// If it is still a file, we replace it with a dir and move it inside
|
|
42
|
+
if (legacyConfig) {
|
|
43
|
+
const tmpConfigFile = `${configDir}.tmp`;
|
|
44
|
+
const configFile = getConfigPath();
|
|
45
|
+
|
|
46
|
+
// Rename so that we can create the directory
|
|
47
|
+
await fs.rename(configDir, tmpConfigFile);
|
|
48
|
+
await mkdirp(configDir, { mode: 0o700 });
|
|
49
|
+
await fs.rename(tmpConfigFile, configFile);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
26
53
|
async function loadOAuthConf () {
|
|
27
54
|
Logger.debug('Load configuration from environment variables');
|
|
28
55
|
if (process.env.CLEVER_TOKEN != null && process.env.CLEVER_SECRET != null) {
|
|
@@ -32,8 +59,9 @@ async function loadOAuthConf () {
|
|
|
32
59
|
};
|
|
33
60
|
}
|
|
34
61
|
Logger.debug('Load configuration from ' + conf.CONFIGURATION_FILE);
|
|
62
|
+
await maybeMigrateFromLegacyConfigurationPath();
|
|
35
63
|
try {
|
|
36
|
-
const rawFile = await readFile(conf.CONFIGURATION_FILE);
|
|
64
|
+
const rawFile = await fs.readFile(conf.CONFIGURATION_FILE);
|
|
37
65
|
return JSON.parse(rawFile);
|
|
38
66
|
}
|
|
39
67
|
catch (error) {
|
|
@@ -47,7 +75,7 @@ async function writeOAuthConf (oauthData) {
|
|
|
47
75
|
const configDir = path.dirname(conf.CONFIGURATION_FILE);
|
|
48
76
|
try {
|
|
49
77
|
await mkdirp(configDir, { mode: 0o700 });
|
|
50
|
-
await writeFile(conf.CONFIGURATION_FILE, JSON.stringify(oauthData));
|
|
78
|
+
await fs.writeFile(conf.CONFIGURATION_FILE, JSON.stringify(oauthData));
|
|
51
79
|
}
|
|
52
80
|
catch (error) {
|
|
53
81
|
throw new Error(`Cannot write configuration to ${conf.CONFIGURATION_FILE}\n${error.message}`);
|
|
@@ -30,6 +30,7 @@ async function waitForDeploymentStart ({ ownerId, appId, deploymentId, commitId,
|
|
|
30
30
|
const isNew = knownDeployments.every(({ uuid }) => uuid !== d.uuid);
|
|
31
31
|
return isNew && d.commit === commitId;
|
|
32
32
|
}
|
|
33
|
+
return false;
|
|
33
34
|
});
|
|
34
35
|
if (deployment != null) {
|
|
35
36
|
Logger.debug(`Deployment has started (state:${deployment.state})`);
|
package/src/models/fs-utils.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { join } = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const { promisify } = require('util');
|
|
6
|
-
|
|
7
|
-
const fsStat = promisify(fs.stat);
|
|
4
|
+
const { promises: fs } = require('fs');
|
|
8
5
|
|
|
9
6
|
function findPath (dir, name) {
|
|
10
7
|
const fullPath = join(dir, name);
|
|
11
|
-
return
|
|
8
|
+
return fs.stat(fullPath)
|
|
12
9
|
.then(() => dir)
|
|
13
10
|
.catch((e) => {
|
|
14
11
|
if (e.code === 'ENOENT' && dir !== '/') {
|