@adinsure-ops/ops-cli 4.8.3 → 5.0.0-rc4

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.
Files changed (89) hide show
  1. package/CHANGELOGS.md +52 -36
  2. package/LICENSE +1 -1
  3. package/README.md +32 -242
  4. package/bin/dev.cmd +3 -0
  5. package/bin/dev.js +6 -0
  6. package/bin/run.cmd +1 -1
  7. package/bin/run.js +8 -0
  8. package/lib/command.base.d.ts +9 -5
  9. package/lib/command.base.jira.d.ts +7 -8
  10. package/lib/command.base.jira.js +26 -24
  11. package/lib/command.base.js +69 -57
  12. package/lib/commands/docker/update-image-version.d.ts +6 -9
  13. package/lib/commands/docker/update-image-version.js +35 -34
  14. package/lib/commands/doctor.d.ts +15 -5
  15. package/lib/commands/doctor.js +219 -186
  16. package/lib/commands/download/client.d.ts +10 -7
  17. package/lib/commands/download/client.js +60 -52
  18. package/lib/commands/download/identity-server.d.ts +9 -7
  19. package/lib/commands/download/identity-server.js +59 -53
  20. package/lib/commands/download/jmeter.d.ts +5 -5
  21. package/lib/commands/download/jmeter.js +54 -49
  22. package/lib/commands/download/keycloak-scim.d.ts +6 -6
  23. package/lib/commands/download/keycloak-scim.js +56 -51
  24. package/lib/commands/download/platform.d.ts +9 -7
  25. package/lib/commands/download/platform.js +59 -53
  26. package/lib/commands/download/scheduler.d.ts +9 -7
  27. package/lib/commands/download/scheduler.js +59 -53
  28. package/lib/commands/download/server.d.ts +9 -7
  29. package/lib/commands/download/server.js +59 -53
  30. package/lib/commands/download/signalr.d.ts +9 -7
  31. package/lib/commands/download/signalr.js +59 -53
  32. package/lib/commands/download/studio.d.ts +12 -9
  33. package/lib/commands/download/studio.js +107 -82
  34. package/lib/commands/gitlab/get-tag-pipeline.d.ts +11 -14
  35. package/lib/commands/gitlab/get-tag-pipeline.js +95 -92
  36. package/lib/commands/gitlab/next-nightly-tag.d.ts +10 -12
  37. package/lib/commands/gitlab/next-nightly-tag.js +96 -98
  38. package/lib/commands/jira/issue.d.ts +6 -8
  39. package/lib/commands/jira/issue.js +25 -23
  40. package/lib/commands/jira/labels.d.ts +9 -12
  41. package/lib/commands/jira/labels.js +52 -51
  42. package/lib/commands/log/add.d.ts +6 -8
  43. package/lib/commands/log/add.js +92 -87
  44. package/lib/commands/log/generate.d.ts +9 -10
  45. package/lib/commands/log/generate.js +112 -107
  46. package/lib/commands/log/validate.d.ts +2 -2
  47. package/lib/commands/log/validate.js +47 -43
  48. package/lib/commands/login.d.ts +9 -10
  49. package/lib/commands/login.js +101 -97
  50. package/lib/commands/npm/check-publish.d.ts +7 -8
  51. package/lib/commands/npm/check-publish.js +59 -54
  52. package/lib/commands/npm/dependency-update.d.ts +14 -12
  53. package/lib/commands/npm/dependency-update.js +94 -86
  54. package/lib/commands/npm/publish.d.ts +8 -9
  55. package/lib/commands/npm/publish.js +154 -140
  56. package/lib/commands/nuget/dependency-update.d.ts +15 -10
  57. package/lib/commands/nuget/dependency-update.js +60 -49
  58. package/lib/commands/sql.d.ts +24 -20
  59. package/lib/commands/sql.js +245 -226
  60. package/lib/commands/translate.d.ts +15 -16
  61. package/lib/commands/translate.js +109 -104
  62. package/lib/commands/version.d.ts +29 -19
  63. package/lib/commands/version.js +215 -190
  64. package/lib/config.js +3 -6
  65. package/lib/hooks/init/version-override.d.ts +2 -2
  66. package/lib/hooks/init/version-override.js +15 -13
  67. package/lib/index.d.ts +1 -1
  68. package/lib/index.js +1 -4
  69. package/lib/lib/command.d.ts +2 -0
  70. package/lib/lib/command.js +65 -58
  71. package/lib/lib/gitlab.d.ts +8 -2
  72. package/lib/lib/gitlab.js +94 -82
  73. package/lib/lib/npm.d.ts +7 -3
  74. package/lib/lib/npm.js +72 -60
  75. package/lib/lib/npmrc.d.ts +5 -0
  76. package/lib/lib/npmrc.js +20 -13
  77. package/lib/lib/nuget.d.ts +2 -0
  78. package/lib/lib/nuget.js +20 -17
  79. package/lib/security/cache.js +31 -27
  80. package/lib/security/context.d.ts +2 -1
  81. package/lib/security/context.js +106 -103
  82. package/lib/types/changelog.types.js +1 -2
  83. package/lib/types/npm.types.d.ts +5 -5
  84. package/lib/types/npm.types.js +1 -2
  85. package/oclif.manifest.json +1223 -1
  86. package/package.json +50 -46
  87. package/bin/run +0 -5
  88. package/lib/commands/prepare-content.d.ts +0 -29
  89. package/lib/commands/prepare-content.js +0 -386
@@ -1,257 +1,290 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const chalk_1 = require("chalk");
5
- const cli_ux_1 = require("cli-ux");
6
- const fs = require("fs-extra");
7
- const command_base_1 = require("../command.base");
8
- const command_2 = require("../lib/command");
9
- class Doctor extends command_base_1.default {
1
+ import { __awaiter } from "tslib";
2
+ import { Flags, ux } from '@oclif/core';
3
+ import chalk from 'chalk';
4
+ import fs from 'fs-extra';
5
+ import CommandBase from '../command.base.js';
6
+ import ChildProcessCommand from '../lib/command.js';
7
+ class Doctor extends CommandBase {
10
8
  constructor() {
11
9
  super(...arguments);
12
- this.cp = new command_2.default();
10
+ this.cp = new ChildProcessCommand();
13
11
  this.nvm = false;
14
12
  this.yarn = false;
15
13
  this.node = false;
16
- this.missing_packages = 0;
14
+ this.missingPackages = 0;
17
15
  }
18
16
  /**
19
- * Check if nvm is installed
17
+ * Check if Git is installed
18
+ * @param {boolean} fix Try to install Git if found missing
19
+ * @returns {void}
20
20
  */
21
- async gitCheck(fix) {
22
- cli_ux_1.default.action.start('Checking git', undefined, { stdout: true });
23
- try {
24
- let output = await this.cp.runCommand(['git', '--version']);
25
- if (output.error) {
26
- cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
27
- }
28
- else {
29
- let version = output.data.split(' ')[2].split('\n')[0];
30
- cli_ux_1.default.action.stop(`${chalk_1.default.green(version)}`);
31
- }
32
- }
33
- catch (_a) {
34
- cli_ux_1.default.action.stop(`${chalk_1.default.red('git is missing')}`);
35
- if (fix) {
36
- await this.gitInstall();
21
+ gitCheck(fix) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ ux.action.start('Checking git', undefined, { stdout: true });
24
+ try {
25
+ const output = yield this.cp.runCommand(['git', '--version']);
26
+ if (output.error) {
27
+ ux.action.stop(`${chalk.red(output.error)}`);
28
+ }
29
+ else {
30
+ const version = output.data.split(' ')[2].split('\n')[0];
31
+ ux.action.stop(`${chalk.green(version)}`);
32
+ }
37
33
  }
38
- else {
39
- this.missing_packages++;
40
- this.warn(`Looks like git is missing.
34
+ catch (_a) {
35
+ ux.action.stop(`${chalk.red('git is missing')}`);
36
+ if (fix) {
37
+ yield this.gitInstall();
38
+ }
39
+ else {
40
+ this.missingPackages++;
41
+ this.warn(`Looks like git is missing.
41
42
  Official documentation on how to install git can be found here: (https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)`);
43
+ }
42
44
  }
43
- }
45
+ });
44
46
  }
45
- async gitInstall() {
46
- switch (process.platform) {
47
- case 'linux':
48
- await this.gitLinuxInstall();
49
- break;
50
- case 'win32':
51
- break;
52
- default:
53
- this.warn('unsupported platform. skipping git install.');
54
- }
47
+ gitInstall() {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ switch (process.platform) {
50
+ case 'linux': {
51
+ yield this.gitLinuxInstall();
52
+ break;
53
+ }
54
+ case 'win32': {
55
+ break;
56
+ }
57
+ default: {
58
+ this.warn('unsupported platform. skipping git install.');
59
+ }
60
+ }
61
+ });
55
62
  }
56
- async gitLinuxInstall() {
57
- this.log(`Try to install git on ubuntu. Sudo is required`);
58
- try {
59
- await this.cp.runCommand(['sudo', 'apt', 'update']);
60
- await this.cp.runCommand(['sudo', 'apt', 'install', 'git']);
61
- await this.gitCheck(false);
62
- }
63
- catch (_a) {
64
- cli_ux_1.default.action.stop(`${chalk_1.default.red('error installing git.')}`);
65
- }
63
+ gitLinuxInstall() {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ this.log(`Try to install git on ubuntu. Sudo is required`);
66
+ try {
67
+ yield this.cp.runCommand(['sudo', 'apt', 'update']);
68
+ yield this.cp.runCommand(['sudo', 'apt', 'install', 'git']);
69
+ yield this.gitCheck(false);
70
+ }
71
+ catch (_a) {
72
+ ux.action.stop(`${chalk.red('error installing git.')}`);
73
+ }
74
+ });
66
75
  }
67
- async gitWindowsInstall() {
68
- // https://github.com/git-for-windows/git/releases/download/v2.33.1.windows.1/Git-2.33.1-64-bit.exe
69
- // %USERPROFILE%\Downloads
76
+ gitWindowsInstall() {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ // https://github.com/git-for-windows/git/releases/download/v2.33.1.windows.1/Git-2.33.1-64-bit.exe
79
+ // %USERPROFILE%\Downloads
80
+ });
70
81
  }
71
82
  /**
72
83
  * Check if nvm is installed
84
+ * @returns {void}
73
85
  */
74
- async nvmCheck() {
75
- cli_ux_1.default.action.start('Checking nvm', undefined, { stdout: true });
76
- if (process.platform !== 'win32') {
77
- if (process.env.NVM_DIR) {
78
- try {
79
- let data = await fs.readJSON(`${process.env.NVM_DIR}/package.json`);
80
- cli_ux_1.default.action.stop(`${chalk_1.default.green(data.version)}`);
81
- this.nvm = true;
86
+ nvmCheck() {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ ux.action.start('Checking nvm', undefined, { stdout: true });
89
+ if (process.platform !== 'win32') {
90
+ if (process.env.NVM_DIR) {
91
+ try {
92
+ const data = yield fs.readJSON(`${process.env.NVM_DIR}/package.json`);
93
+ ux.action.stop(`${chalk.green(data.version)}`);
94
+ this.nvm = true;
95
+ }
96
+ catch (_a) {
97
+ ux.action.stop(`${chalk.red('not installed')}`);
98
+ }
82
99
  }
83
- catch (_a) {
84
- cli_ux_1.default.action.stop(`${chalk_1.default.red('not installed')}`);
100
+ else {
101
+ ux.action.stop(`${chalk.red('nvm is missing (install manually from https://github.com/nvm-sh/nvm#installing-and-updating')}`);
85
102
  }
103
+ return;
86
104
  }
87
- else {
88
- cli_ux_1.default.action.stop(`${chalk_1.default.red('nvm is missing (install manually from https://github.com/nvm-sh/nvm#installing-and-updating')}`);
89
- }
90
- return;
91
- }
92
- try {
93
- let output = await this.cp.runCommand(['nvm', 'version']);
94
- if (output.error) {
95
- cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
105
+ try {
106
+ const output = yield this.cp.runCommand(['nvm', 'version']);
107
+ if (output.error) {
108
+ ux.action.stop(`${chalk.red(output.error)}`);
109
+ }
110
+ else {
111
+ const version = output.data.split('\n')[0];
112
+ this.nvm = true;
113
+ ux.action.stop(`${chalk.green(version)}`);
114
+ }
96
115
  }
97
- else {
98
- let version = output.data.split('\n')[0];
99
- this.nvm = true;
100
- cli_ux_1.default.action.stop(`${chalk_1.default.green(version)}`);
116
+ catch (_b) {
117
+ ux.action.stop(`${chalk.red('nvm is missing (install manually from https://github.com/coreybutler/nvm-windows/releases)')}`);
101
118
  }
102
- }
103
- catch (_b) {
104
- cli_ux_1.default.action.stop(`${chalk_1.default.red('nvm is missing (install manually from https://github.com/coreybutler/nvm-windows/releases)')}`);
105
- }
119
+ });
106
120
  }
107
121
  /**
108
122
  * Check which node is installed
123
+ * @param {boolean} fix Try to install Node if found missing
124
+ * @returns {void}
109
125
  */
110
- async nodeCheck(fix) {
111
- cli_ux_1.default.action.start('Checking node', undefined, { stdout: true });
112
- try {
113
- let output = await this.cp.runCommand(['node', '--version']);
114
- if (output.error) {
115
- cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
116
- }
117
- else {
118
- let version = output.data.split('\n')[0];
119
- if (version) {
120
- cli_ux_1.default.action.stop(`${chalk_1.default.green(version)}`);
121
- this.node = true;
122
- // only check yarn if node is installed
123
- await this.yarnCheck(fix);
126
+ nodeCheck(fix) {
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ ux.action.start('Checking node', undefined, { stdout: true });
129
+ try {
130
+ const output = yield this.cp.runCommand(['node', '--version']);
131
+ if (output.error) {
132
+ ux.action.stop(`${chalk.red(output.error)}`);
124
133
  }
125
134
  else {
126
- cli_ux_1.default.action.stop(`${chalk_1.default.red('failed getting version')}`);
135
+ const version = output.data.split('\n')[0];
136
+ if (version) {
137
+ ux.action.stop(`${chalk.green(version)}`);
138
+ this.node = true;
139
+ // only check yarn if node is installed
140
+ yield this.yarnCheck(fix);
141
+ }
142
+ else {
143
+ ux.action.stop(`${chalk.red('failed getting version')}`);
144
+ }
127
145
  }
128
146
  }
129
- }
130
- catch (_a) {
131
- cli_ux_1.default.action.stop(`${chalk_1.default.red('node is missing')}`);
132
- if (fix && this.nvm) {
133
- await this.nodeInstall();
134
- }
135
- else {
136
- this.missing_packages++;
147
+ catch (_a) {
148
+ ux.action.stop(`${chalk.red('node is missing')}`);
149
+ if (fix && this.nvm) {
150
+ yield this.nodeInstall();
151
+ }
152
+ else {
153
+ this.missingPackages++;
154
+ }
137
155
  }
138
- }
156
+ });
139
157
  }
140
158
  /**
141
159
  * Check which node is installed
160
+ * @returns {void}
142
161
  */
143
- async nodeInstall() {
144
- cli_ux_1.default.action.start('installing node 15.6.0', undefined, { stdout: true });
145
- if (!this.nvm) {
146
- return cli_ux_1.default.action.stop(`${chalk_1.default.red('only works with nvm isntalled')}`);
147
- }
148
- try {
149
- let output = await this.cp.runCommand(['nvm', 'install', '15.6.0']);
150
- if (output.error) {
151
- cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
162
+ nodeInstall() {
163
+ return __awaiter(this, void 0, void 0, function* () {
164
+ ux.action.start('installing node 15.6.0', undefined, { stdout: true });
165
+ if (!this.nvm) {
166
+ return ux.action.stop(`${chalk.red('only works with nvm isntalled')}`);
152
167
  }
153
- else {
154
- let nvmUserOutput = await this.cp.runCommand(['nvm', 'use', '15.6.0']);
155
- if (nvmUserOutput.error) {
156
- cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
168
+ try {
169
+ const output = yield this.cp.runCommand(['nvm', 'install', '15.6.0']);
170
+ if (output.error) {
171
+ ux.action.stop(`${chalk.red(output.error)}`);
172
+ }
173
+ else {
174
+ const nvmUserOutput = yield this.cp.runCommand(['nvm', 'use', '15.6.0']);
175
+ if (nvmUserOutput.error) {
176
+ ux.action.stop(`${chalk.red(output.error)}`);
177
+ }
178
+ ux.action.stop(`${chalk.green('Done')}`);
157
179
  }
158
- cli_ux_1.default.action.stop(`${chalk_1.default.green('Done')}`);
159
180
  }
160
- }
161
- catch (_a) {
162
- cli_ux_1.default.action.stop(`${chalk_1.default.red('failed')}`);
163
- }
181
+ catch (_a) {
182
+ ux.action.stop(`${chalk.red('failed')}`);
183
+ }
184
+ });
164
185
  }
165
186
  /**
166
187
  * Check which yarn is installed
188
+ * @param {boolean} fix Try to install yarn if found missing
189
+ * @returns {void}
167
190
  */
168
- async yarnCheck(fix) {
169
- cli_ux_1.default.action.start('Checking yarn', undefined, { stdout: true });
170
- try {
171
- let output = await this.cp.runCommand(['yarn', '--version']);
172
- if (output.error) {
173
- cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
174
- }
175
- else {
176
- let version = output.data.split('\n')[0];
177
- if (version) {
178
- this.yarn = true;
179
- cli_ux_1.default.action.stop(`${chalk_1.default.green(version)}`);
191
+ yarnCheck(fix) {
192
+ return __awaiter(this, void 0, void 0, function* () {
193
+ ux.action.start('Checking yarn', undefined, { stdout: true });
194
+ try {
195
+ const output = yield this.cp.runCommand(['yarn', '--version']);
196
+ if (output.error) {
197
+ ux.action.stop(`${chalk.red(output.error)}`);
180
198
  }
181
199
  else {
182
- cli_ux_1.default.action.stop(`${chalk_1.default.red('yarn is missing')}`);
200
+ const version = output.data.split('\n')[0];
201
+ if (version) {
202
+ this.yarn = true;
203
+ ux.action.stop(`${chalk.green(version)}`);
204
+ }
205
+ else {
206
+ ux.action.stop(`${chalk.red('yarn is missing')}`);
207
+ }
183
208
  }
184
209
  }
185
- }
186
- catch (_a) {
187
- this.missing_packages++;
188
- cli_ux_1.default.action.stop(`${chalk_1.default.red('yarn is missing')}`);
189
- if (fix) {
190
- await this.yarnInstall();
210
+ catch (_a) {
211
+ this.missingPackages++;
212
+ ux.action.stop(`${chalk.red('yarn is missing')}`);
213
+ if (fix) {
214
+ yield this.yarnInstall();
215
+ }
191
216
  }
192
- }
217
+ });
193
218
  }
194
219
  /**
195
220
  * Check which yarn is installed
221
+ * @returns {void}
196
222
  */
197
- async yarnInstall() {
198
- cli_ux_1.default.action.start('Install yarn', undefined, { stdout: true });
199
- try {
200
- let output = await this.cp.runCommand(['npm', '-g', 'install', 'yarn']);
201
- if (output.error) {
202
- cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
223
+ yarnInstall() {
224
+ return __awaiter(this, void 0, void 0, function* () {
225
+ ux.action.start('Install yarn', undefined, { stdout: true });
226
+ try {
227
+ const output = yield this.cp.runCommand(['npm', '-g', 'install', 'yarn']);
228
+ if (output.error) {
229
+ ux.action.stop(`${chalk.red(output.error)}`);
230
+ }
231
+ else {
232
+ this.yarn = true;
233
+ ux.action.stop(`${chalk.green('yarn installed')}`);
234
+ }
203
235
  }
204
- else {
205
- this.yarn = true;
206
- cli_ux_1.default.action.stop(`${chalk_1.default.green('yarn installed')}`);
236
+ catch (_a) {
237
+ this.missingPackages++;
238
+ ux.action.stop(`${chalk.red('yarn failed to install')}`);
207
239
  }
208
- }
209
- catch (_a) {
210
- this.missing_packages++;
211
- cli_ux_1.default.action.stop(`${chalk_1.default.red('yarn failed to install')}`);
212
- }
240
+ });
213
241
  }
214
242
  /**
215
243
  * Check which VSCode is installed
244
+ * @returns {void}
216
245
  */
217
- async vscodeCheck() {
218
- cli_ux_1.default.action.start('Checking vscode', undefined, { stdout: true });
219
- try {
220
- let output = await this.cp.runCommand(['code', '--version']);
221
- if (output.error) {
222
- cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
246
+ vscodeCheck() {
247
+ return __awaiter(this, void 0, void 0, function* () {
248
+ ux.action.start('Checking vscode', undefined, { stdout: true });
249
+ try {
250
+ const output = yield this.cp.runCommand(['code', '--version']);
251
+ if (output.error) {
252
+ ux.action.stop(`${chalk.red(output.error)}`);
253
+ }
254
+ else {
255
+ const version = output.data.split('\n')[0];
256
+ ux.action.stop(`${chalk.green(version)}`);
257
+ }
223
258
  }
224
- else {
225
- let version = output.data.split('\n')[0];
226
- cli_ux_1.default.action.stop(`${chalk_1.default.green(version)}`);
259
+ catch (_a) {
260
+ this.missingPackages++;
261
+ ux.action.stop(`${chalk.red('VSCode not installed')}`);
227
262
  }
228
- }
229
- catch (_a) {
230
- this.missing_packages++;
231
- cli_ux_1.default.action.stop(`${chalk_1.default.red('VSCode not installed')}`);
232
- }
263
+ });
233
264
  }
234
- async run() {
235
- const { flags } = this.parse(Doctor);
236
- await this.gitCheck(flags.fix);
237
- await this.nvmCheck();
238
- await this.nodeCheck(flags.fix);
239
- await this.vscodeCheck();
240
- if (this.missing_packages > 0) {
241
- this.warn(`${chalk_1.default.yellow('Some packages are missing. Try --fix to automatically install.')}`);
242
- }
265
+ run() {
266
+ return __awaiter(this, void 0, void 0, function* () {
267
+ const { flags } = yield this.parse(Doctor);
268
+ yield this.gitCheck(flags.fix);
269
+ yield this.nvmCheck();
270
+ yield this.nodeCheck(flags.fix);
271
+ yield this.vscodeCheck();
272
+ if (this.missingPackages > 0) {
273
+ this.warn(`${chalk.yellow('Some packages are missing. Try --fix to automatically install.')}`);
274
+ }
275
+ });
243
276
  }
244
277
  }
245
- exports.default = Doctor;
246
278
  Doctor.description = 'check if everything is installed';
247
279
  Doctor.usage = 'doctor';
248
280
  Doctor.examples = [
249
- `$ ops doctor`
281
+ `$ ops doctor`,
250
282
  ];
251
283
  Doctor.flags = {
252
- fix: command_1.flags.boolean({
284
+ fix: Flags.boolean({
253
285
  char: 'p',
254
286
  description: 'try to install missing packages',
255
- default: false
256
- })
287
+ default: false,
288
+ }),
257
289
  };
290
+ export default Doctor;
@@ -1,17 +1,20 @@
1
- import { flags } from '@oclif/command';
2
- import CommandBase from '../../command.base';
3
- export default class DownloadClient extends CommandBase {
1
+ import { AxiosResponse } from 'axios';
2
+ import CommandBase from '../../command.base.js';
3
+ export default class DownloadClient extends CommandBase<typeof DownloadClient> {
4
+ static aliases: string[];
4
5
  static description: string;
5
6
  static usage: string;
6
7
  static examples: string[];
7
8
  static flags: {
8
- version: flags.IOptionFlag<string>;
9
- output: flags.IOptionFlag<string>;
9
+ version: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
+ output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
11
  };
11
12
  private readonly url;
12
13
  /**
13
- * Get unique scriptID by specified version
14
+ * Get unique AdInsure Client zip by specified version
15
+ * @param {string} version The version of AdInsure Client
16
+ * @returns {Promise<AxiosResponse<any, any>>}
14
17
  */
15
- downloadFile(version: string): Promise<string>;
18
+ downloadFile(version: string): Promise<AxiosResponse<any, any>>;
16
19
  run(): Promise<void>;
17
20
  }
@@ -1,74 +1,82 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const chalk_1 = require("chalk");
5
- const cli_ux_1 = require("cli-ux");
6
- const fs = require("fs-extra");
7
- const path = require("path");
8
- const request = require("request-promise");
9
- const command_base_1 = require("../../command.base");
10
- class DownloadClient extends command_base_1.default {
1
+ import { __awaiter } from "tslib";
2
+ import { Flags, ux } from '@oclif/core';
3
+ import axios from 'axios';
4
+ import chalk from 'chalk';
5
+ import fs from 'fs-extra';
6
+ import path from 'path';
7
+ import CommandBase from '../../command.base.js';
8
+ class DownloadClient extends CommandBase {
11
9
  constructor() {
12
10
  super(...arguments);
13
11
  this.url = 'https://ops.adinsure.com/api/storage/binaries/';
14
12
  }
15
13
  /**
16
- * Get unique scriptID by specified version
14
+ * Get unique AdInsure Client zip by specified version
15
+ * @param {string} version The version of AdInsure Client
16
+ * @returns {Promise<AxiosResponse<any, any>>}
17
17
  */
18
- async downloadFile(version) {
19
- let options = {
20
- uri: `${this.url}/AdInsure-client-${version}.zip`,
21
- encoding: 'binary',
22
- headers: {
23
- Authorization: 'Bearer ' + await this.security.getToken()
24
- }
25
- };
26
- return request.get(options);
27
- }
28
- async run() {
29
- const { flags } = this.parse(DownloadClient);
30
- let basePath = flags.output;
31
- const filename = `AdInsure-client-${flags.version}.zip`;
32
- let filePath = path.resolve(basePath, filename);
33
- cli_ux_1.default.action.start(`Downloading AdInsure Client version ${flags.version} to ${filePath}`, undefined, { stdout: true });
34
- try {
35
- let file = await this.downloadFile(flags.version);
36
- let writeStream = fs.createWriteStream(filePath);
37
- writeStream.write(file, 'binary');
38
- writeStream.on('finish', () => {
39
- cli_ux_1.default.action.stop(`${chalk_1.default.green('OK')}`);
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ downloadFile(version) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ return axios.get(`${this.url}/AdInsure-client-${version}.zip`, {
22
+ headers: {
23
+ Authorization: 'Bearer ' + (yield this.security.getToken()),
24
+ 'Content-Type': 'application/octet-stream',
25
+ },
40
26
  });
41
- writeStream.end();
42
- }
43
- catch (err) {
44
- switch (err.statusCode) {
45
- case 404:
46
- this.error('Does not exists.', { exit: 1 });
47
- break;
48
- case 400:
49
- this.error('Try refreshing your login credentials with "ops login".', { exit: 1 });
50
- break;
51
- default:
52
- this.error(err.message);
27
+ });
28
+ }
29
+ run() {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const { flags } = yield this.parse(DownloadClient);
32
+ const basePath = flags.output;
33
+ const filename = `AdInsure-client-${flags.version}.zip`;
34
+ const filePath = path.resolve(basePath, filename);
35
+ ux.action.start(`Downloading AdInsure Client version ${flags.version} to ${filePath}`, undefined, { stdout: true });
36
+ try {
37
+ const file = yield this.downloadFile(flags.version);
38
+ const writeStream = fs.createWriteStream(filePath);
39
+ writeStream.write(file.data, 'binary');
40
+ writeStream.on('finish', () => {
41
+ ux.action.stop(`${chalk.green('OK')}`);
42
+ });
43
+ writeStream.end();
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
+ }
46
+ catch (error) {
47
+ switch (error.statusCode) {
48
+ case 404: {
49
+ this.error('Does not exists.', { exit: 1 });
50
+ break;
51
+ }
52
+ case 400: {
53
+ this.error('Try refreshing your login credentials with "ops login".', { exit: 1 });
54
+ break;
55
+ }
56
+ default: {
57
+ this.error(error.message);
58
+ }
59
+ }
53
60
  }
54
- }
61
+ });
55
62
  }
56
63
  }
57
- exports.default = DownloadClient;
64
+ DownloadClient.aliases = ['download:client'];
58
65
  DownloadClient.description = 'download AdInsure Client zip from Azure storage';
59
66
  DownloadClient.usage = 'download:client <flags>';
60
67
  DownloadClient.examples = [
61
- `$ ops download:client -v 3.2.0 -o ~/Downloads`
68
+ `$ ops download:client -v 3.2.0 -o ~/Downloads`,
62
69
  ];
63
70
  DownloadClient.flags = {
64
- version: command_1.flags.string({
71
+ version: Flags.string({
65
72
  char: 'v',
66
73
  description: 'version we want to download',
67
- required: true
74
+ required: true,
68
75
  }),
69
- output: command_1.flags.string({
76
+ output: Flags.string({
70
77
  char: 'o',
71
78
  description: 'output directory',
72
- default: './'
79
+ default: './',
73
80
  }),
74
81
  };
82
+ export default DownloadClient;