neonctl 0.6.0 → 0.7.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/package.json +2 -1
- package/src/api/operations.js +4 -2
- package/src/commands/auth.js +5 -1
- package/src/commands/projects.js +3 -1
- package/src/commands/roles.js +1 -1
- package/src/index.js +5 -3
- package/src/writer.js +12 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neonctl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "CLI tool for NeonDB Cloud management",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "NeonDB",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"cli-table": "^0.3.11",
|
|
27
27
|
"open": "^8.4.0",
|
|
28
28
|
"openid-client": "^5.1.9",
|
|
29
|
+
"yaml": "^2.1.1",
|
|
29
30
|
"yargs": "^17.5.1"
|
|
30
31
|
},
|
|
31
32
|
"publishConfig": {
|
package/src/api/operations.js
CHANGED
|
@@ -10,18 +10,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getOperation = exports.waitOperationFinalState = void 0;
|
|
13
|
+
const log_1 = require("../log");
|
|
13
14
|
const gateway_1 = require("./gateway");
|
|
14
15
|
function sleep(ms) {
|
|
15
16
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
16
17
|
}
|
|
17
18
|
// wait 20 sec max.
|
|
18
19
|
const waitOperationFinalState = (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
for (let i = 0; i <
|
|
20
|
+
for (let i = 0; i < 20; i++) {
|
|
20
21
|
const operation = yield (0, exports.getOperation)(Object.assign({}, props));
|
|
21
22
|
if (operation.status == 'finished') {
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
log_1.log.info(`Waiting for operation "${props.operation_id}" to finish`);
|
|
26
|
+
yield sleep(1000);
|
|
25
27
|
}
|
|
26
28
|
throw Error(`timeout while waiting for operation ${props.operation_id}`);
|
|
27
29
|
});
|
package/src/commands/auth.js
CHANGED
|
@@ -94,7 +94,11 @@ const ensureAuth = (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
const token = tokenSet.access_token || 'UNKNOWN';
|
|
97
|
-
yield validateToken({
|
|
97
|
+
yield validateToken({
|
|
98
|
+
apiHost: props['api-host'],
|
|
99
|
+
token,
|
|
100
|
+
output: 'json',
|
|
101
|
+
});
|
|
98
102
|
props.token = token;
|
|
99
103
|
return;
|
|
100
104
|
}
|
package/src/commands/projects.js
CHANGED
|
@@ -13,7 +13,9 @@ exports.create = exports.list = void 0;
|
|
|
13
13
|
const projects_1 = require("../api/projects");
|
|
14
14
|
const writer_1 = require("../writer");
|
|
15
15
|
const list = (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
(0, writer_1.writeOut)(props)(yield (0, projects_1.listProjects)(props), {
|
|
16
|
+
(0, writer_1.writeOut)(props)(yield (0, projects_1.listProjects)(props), {
|
|
17
|
+
fields: ['id', 'name', 'region_name', 'created_at'],
|
|
18
|
+
});
|
|
17
19
|
});
|
|
18
20
|
exports.list = list;
|
|
19
21
|
const create = (props) => __awaiter(void 0, void 0, void 0, function* () {
|
package/src/commands/roles.js
CHANGED
|
@@ -13,6 +13,6 @@ exports.resetPwd = void 0;
|
|
|
13
13
|
const writer_1 = require("../writer");
|
|
14
14
|
const roles_1 = require("../api/roles");
|
|
15
15
|
const resetPwd = (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
(0, writer_1.writeOut)(props)(yield (0, roles_1.resetPassword)(props), { fields: [] });
|
|
16
|
+
(0, writer_1.writeOut)(props)(yield (0, roles_1.resetPassword)(props), { fields: ['dsn'] });
|
|
17
17
|
});
|
|
18
18
|
exports.resetPwd = resetPwd;
|
package/src/index.js
CHANGED
|
@@ -52,9 +52,11 @@ const builder = yargs
|
|
|
52
52
|
.scriptName(package_json_1.default.name)
|
|
53
53
|
.usage('usage: $0 <cmd> [args]')
|
|
54
54
|
.help()
|
|
55
|
-
.option('
|
|
56
|
-
describe: 'Set output format
|
|
57
|
-
type: '
|
|
55
|
+
.option('output', {
|
|
56
|
+
describe: 'Set output format',
|
|
57
|
+
type: 'string',
|
|
58
|
+
choices: ['json', 'yaml', 'table'],
|
|
59
|
+
default: 'table',
|
|
58
60
|
})
|
|
59
61
|
.option('api-host', {
|
|
60
62
|
describe: 'The API host',
|
package/src/writer.js
CHANGED
|
@@ -4,9 +4,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.writeOut = void 0;
|
|
7
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
7
8
|
const cli_table_1 = __importDefault(require("cli-table"));
|
|
9
|
+
// Allow PIPE to finish reading before the end of the output.
|
|
10
|
+
process.stdout.on('error', function (err) {
|
|
11
|
+
if (err.code == 'EPIPE') {
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
8
15
|
const writeOut = (props) => (data, config) => {
|
|
9
|
-
if (props.
|
|
16
|
+
if (props.output == 'yaml') {
|
|
17
|
+
process.stdout.write(yaml_1.default.stringify(data, null, 2));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (props.output == 'json') {
|
|
10
21
|
process.stdout.write(JSON.stringify(data, null, 2));
|
|
11
22
|
return;
|
|
12
23
|
}
|