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

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 (88) hide show
  1. package/CHANGELOGS.md +12 -0
  2. package/README.md +0 -211
  3. package/bin/dev.cmd +3 -0
  4. package/bin/dev.js +6 -0
  5. package/bin/run.cmd +1 -1
  6. package/bin/run.js +8 -0
  7. package/lib/command.base.d.ts +9 -5
  8. package/lib/command.base.jira.d.ts +7 -8
  9. package/lib/command.base.jira.js +26 -24
  10. package/lib/command.base.js +69 -57
  11. package/lib/commands/docker/update-image-version.d.ts +6 -9
  12. package/lib/commands/docker/update-image-version.js +35 -34
  13. package/lib/commands/doctor.d.ts +15 -5
  14. package/lib/commands/doctor.js +219 -186
  15. package/lib/commands/download/client.d.ts +10 -7
  16. package/lib/commands/download/client.js +60 -52
  17. package/lib/commands/download/identity-server.d.ts +9 -7
  18. package/lib/commands/download/identity-server.js +59 -53
  19. package/lib/commands/download/jmeter.d.ts +5 -5
  20. package/lib/commands/download/jmeter.js +54 -49
  21. package/lib/commands/download/keycloak-scim.d.ts +6 -6
  22. package/lib/commands/download/keycloak-scim.js +56 -51
  23. package/lib/commands/download/platform.d.ts +9 -7
  24. package/lib/commands/download/platform.js +59 -53
  25. package/lib/commands/download/scheduler.d.ts +9 -7
  26. package/lib/commands/download/scheduler.js +59 -53
  27. package/lib/commands/download/server.d.ts +9 -7
  28. package/lib/commands/download/server.js +59 -53
  29. package/lib/commands/download/signalr.d.ts +9 -7
  30. package/lib/commands/download/signalr.js +59 -53
  31. package/lib/commands/download/studio.d.ts +11 -9
  32. package/lib/commands/download/studio.js +92 -82
  33. package/lib/commands/gitlab/get-tag-pipeline.d.ts +11 -14
  34. package/lib/commands/gitlab/get-tag-pipeline.js +95 -92
  35. package/lib/commands/gitlab/next-nightly-tag.d.ts +10 -12
  36. package/lib/commands/gitlab/next-nightly-tag.js +96 -98
  37. package/lib/commands/jira/issue.d.ts +6 -8
  38. package/lib/commands/jira/issue.js +25 -23
  39. package/lib/commands/jira/labels.d.ts +9 -12
  40. package/lib/commands/jira/labels.js +52 -51
  41. package/lib/commands/log/add.d.ts +6 -8
  42. package/lib/commands/log/add.js +92 -87
  43. package/lib/commands/log/generate.d.ts +9 -10
  44. package/lib/commands/log/generate.js +112 -107
  45. package/lib/commands/log/validate.d.ts +2 -2
  46. package/lib/commands/log/validate.js +47 -43
  47. package/lib/commands/login.d.ts +9 -10
  48. package/lib/commands/login.js +101 -97
  49. package/lib/commands/npm/check-publish.d.ts +7 -8
  50. package/lib/commands/npm/check-publish.js +59 -54
  51. package/lib/commands/npm/dependency-update.d.ts +14 -12
  52. package/lib/commands/npm/dependency-update.js +94 -86
  53. package/lib/commands/npm/publish.d.ts +8 -9
  54. package/lib/commands/npm/publish.js +154 -140
  55. package/lib/commands/nuget/dependency-update.d.ts +15 -10
  56. package/lib/commands/nuget/dependency-update.js +60 -49
  57. package/lib/commands/sql.d.ts +24 -20
  58. package/lib/commands/sql.js +245 -226
  59. package/lib/commands/translate.d.ts +15 -16
  60. package/lib/commands/translate.js +109 -104
  61. package/lib/commands/version.d.ts +29 -19
  62. package/lib/commands/version.js +215 -190
  63. package/lib/config.js +3 -6
  64. package/lib/hooks/init/version-override.d.ts +2 -2
  65. package/lib/hooks/init/version-override.js +15 -13
  66. package/lib/index.d.ts +1 -1
  67. package/lib/index.js +1 -4
  68. package/lib/lib/command.d.ts +2 -0
  69. package/lib/lib/command.js +65 -58
  70. package/lib/lib/gitlab.d.ts +8 -2
  71. package/lib/lib/gitlab.js +94 -82
  72. package/lib/lib/npm.d.ts +7 -3
  73. package/lib/lib/npm.js +72 -60
  74. package/lib/lib/npmrc.d.ts +5 -0
  75. package/lib/lib/npmrc.js +20 -13
  76. package/lib/lib/nuget.d.ts +2 -0
  77. package/lib/lib/nuget.js +20 -17
  78. package/lib/security/cache.js +31 -27
  79. package/lib/security/context.d.ts +2 -1
  80. package/lib/security/context.js +106 -103
  81. package/lib/types/changelog.types.js +1 -2
  82. package/lib/types/npm.types.d.ts +5 -5
  83. package/lib/types/npm.types.js +1 -2
  84. package/oclif.manifest.json +1212 -1
  85. package/package.json +50 -46
  86. package/bin/run +0 -5
  87. package/lib/commands/prepare-content.d.ts +0 -29
  88. package/lib/commands/prepare-content.js +0 -386
@@ -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;
@@ -1,17 +1,19 @@
1
- import { flags } from '@oclif/command';
2
- import CommandBase from '../../command.base';
3
- export default class DownloadIdentityServer extends CommandBase {
1
+ import { AxiosResponse } from 'axios';
2
+ import CommandBase from '../../command.base.js';
3
+ export default class DownloadIdentityServer extends CommandBase<typeof DownloadIdentityServer> {
4
4
  static description: string;
5
5
  static usage: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
- version: flags.IOptionFlag<string>;
9
- output: flags.IOptionFlag<string>;
8
+ version: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
+ output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
10
  };
11
11
  private readonly url;
12
12
  /**
13
- * Get unique scriptID by specified version
13
+ * Get unique Identity Server zip by specified version
14
+ * @param {string} version The version of Identity Server
15
+ * @returns {Promise<AxiosResponse<any, any>>}
14
16
  */
15
- downloadFile(version: string): Promise<string>;
17
+ downloadFile(version: string): Promise<AxiosResponse<any, any>>;
16
18
  run(): Promise<void>;
17
19
  }
@@ -1,75 +1,81 @@
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 DownloadIdentityServer 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 DownloadIdentityServer 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 Identity Server zip by specified version
15
+ * @param {string} version The version of Identity Server
16
+ * @returns {Promise<AxiosResponse<any, any>>}
17
17
  */
18
- async downloadFile(version) {
19
- let options = {
20
- uri: `${this.url}/AdInsure-identityServer-${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(DownloadIdentityServer);
30
- let basePath = flags.output;
31
- const filename = `AdInsure-identityServer-${flags.version}.zip`;
32
- let filePath = path.resolve(basePath, filename);
33
- cli_ux_1.default.action.start(`Downloading AdInsure Identity Server 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-identityServer-${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
- // cli.action.stop(`${chalk.red('Does not exists.')}`);
47
- this.error('Does not exists.', { exit: 1 });
48
- break;
49
- case 400:
50
- this.error('Try refreshing your login credentials with "ops login".', { exit: 1 });
51
- break;
52
- default:
53
- this.error(err.message);
27
+ });
28
+ }
29
+ run() {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const { flags } = yield this.parse(DownloadIdentityServer);
32
+ const basePath = flags.output;
33
+ const filename = `AdInsure-identityServer-${flags.version}.zip`;
34
+ const filePath = path.resolve(basePath, filename);
35
+ ux.action.start(`Downloading AdInsure Identity Server 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
+ }
54
60
  }
55
- }
61
+ });
56
62
  }
57
63
  }
58
- exports.default = DownloadIdentityServer;
59
64
  DownloadIdentityServer.description = 'download AdInsure Identity Server zip from Azure storage';
60
65
  DownloadIdentityServer.usage = 'download:identity-server <flags>';
61
66
  DownloadIdentityServer.examples = [
62
- `$ ops download:identity-server -v 3.0.3 -o ~/Downloads`
67
+ `$ ops download:identity-server -v 3.0.3 -o ~/Downloads`,
63
68
  ];
64
69
  DownloadIdentityServer.flags = {
65
- version: command_1.flags.string({
70
+ version: Flags.string({
66
71
  char: 'v',
67
72
  description: 'version we want to download',
68
- required: true
73
+ required: true,
69
74
  }),
70
- output: command_1.flags.string({
75
+ output: Flags.string({
71
76
  char: 'o',
72
77
  description: 'output directory',
73
- default: './'
78
+ default: './',
74
79
  }),
75
80
  };
81
+ export default DownloadIdentityServer;
@@ -1,13 +1,13 @@
1
- import { flags } from '@oclif/command';
2
- import CommandBase from '../../command.base';
3
- export default class DownloadJmeter extends CommandBase {
1
+ import { AxiosResponse } from 'axios';
2
+ import CommandBase from '../../command.base.js';
3
+ export default class DownloadJmeter extends CommandBase<typeof DownloadJmeter> {
4
4
  static description: string;
5
5
  static usage: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
- output: flags.IOptionFlag<string>;
8
+ output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
9
  };
10
10
  private readonly url;
11
- downloadFile(): Promise<string>;
11
+ downloadFile(): Promise<AxiosResponse<any, any>>;
12
12
  run(): Promise<void>;
13
13
  }
@@ -1,66 +1,71 @@
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 DownloadJmeter 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 DownloadJmeter extends CommandBase {
11
9
  constructor() {
12
10
  super(...arguments);
13
11
  this.url = 'https://ops.adinsure.com/api/storage/jmeter/';
14
12
  }
15
- async downloadFile() {
16
- let options = {
17
- uri: `${this.url}/jmeter-artifacts.zip`,
18
- encoding: 'binary',
19
- headers: {
20
- Authorization: 'Bearer ' + await this.security.getToken()
21
- }
22
- };
23
- return request.get(options);
24
- }
25
- async run() {
26
- const { flags } = this.parse(DownloadJmeter);
27
- let basePath = flags.output;
28
- const filename = `jmeter-artifacts.zip`;
29
- let filePath = path.resolve(basePath, filename);
30
- cli_ux_1.default.action.start(`Downloading jmeter examples to ${filePath}`, undefined, { stdout: true });
31
- try {
32
- let file = await this.downloadFile();
33
- let writeStream = fs.createWriteStream(filePath);
34
- writeStream.write(file, 'binary');
35
- writeStream.on('finish', () => {
36
- cli_ux_1.default.action.stop(`${chalk_1.default.green('OK')}`);
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ downloadFile() {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ return axios.get(`${this.url}/jmeter-artifacts.zip`, {
17
+ headers: {
18
+ Authorization: 'Bearer ' + (yield this.security.getToken()),
19
+ 'Content-Type': 'application/octet-stream',
20
+ },
37
21
  });
38
- writeStream.end();
39
- }
40
- catch (err) {
41
- switch (err.statusCode) {
42
- case 404:
43
- this.error('Does not exists.', { exit: 1 });
44
- break;
45
- case 400:
46
- this.error('Try refreshing your login credentials with "ops login".', { exit: 1 });
47
- break;
48
- default:
49
- this.error(err.message);
22
+ });
23
+ }
24
+ run() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const { flags } = yield this.parse(DownloadJmeter);
27
+ const basePath = flags.output;
28
+ const filename = `jmeter-artifacts.zip`;
29
+ const filePath = path.resolve(basePath, filename);
30
+ ux.action.start(`Downloading jmeter examples to ${filePath}`, undefined, { stdout: true });
31
+ try {
32
+ const file = yield this.downloadFile();
33
+ const writeStream = fs.createWriteStream(filePath);
34
+ writeStream.write(file.data, 'binary');
35
+ writeStream.on('finish', () => {
36
+ ux.action.stop(`${chalk.green('OK')}`);
37
+ });
38
+ writeStream.end();
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ }
41
+ catch (error) {
42
+ switch (error.statusCode) {
43
+ case 404: {
44
+ this.error('Does not exists.', { exit: 1 });
45
+ break;
46
+ }
47
+ case 400: {
48
+ this.error('Try refreshing your login credentials with "ops login".', { exit: 1 });
49
+ break;
50
+ }
51
+ default: {
52
+ this.error(error.message);
53
+ }
54
+ }
50
55
  }
51
- }
56
+ });
52
57
  }
53
58
  }
54
- exports.default = DownloadJmeter;
55
59
  DownloadJmeter.description = 'download jmeter examples from Azure storage';
56
60
  DownloadJmeter.usage = 'download:jmeter-examples <flags>';
57
61
  DownloadJmeter.examples = [
58
- `$ ops download:jmeter-examples -o ~/Downloads`
62
+ `$ ops download:jmeter-examples -o ~/Downloads`,
59
63
  ];
60
64
  DownloadJmeter.flags = {
61
- output: command_1.flags.string({
65
+ output: Flags.string({
62
66
  char: 'o',
63
67
  description: 'output directory',
64
- default: './'
68
+ default: './',
65
69
  }),
66
70
  };
71
+ export default DownloadJmeter;
@@ -1,14 +1,14 @@
1
- import { flags } from '@oclif/command';
2
- import CommandBase from '../../command.base';
3
- export default class DownloadKeycloak extends CommandBase {
1
+ import { AxiosResponse } from 'axios';
2
+ import CommandBase from '../../command.base.js';
3
+ export default class DownloadKeycloak extends CommandBase<typeof DownloadKeycloak> {
4
4
  static description: string;
5
5
  static usage: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
- version: flags.IOptionFlag<string>;
9
- output: flags.IOptionFlag<string>;
8
+ version: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
+ output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
10
  };
11
11
  private readonly url;
12
- downloadFile(version: string): Promise<string>;
12
+ downloadFile(version: string): Promise<AxiosResponse<any, any>>;
13
13
  run(): Promise<void>;
14
14
  }
@@ -1,71 +1,76 @@
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 DownloadKeycloak 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 DownloadKeycloak extends CommandBase {
11
9
  constructor() {
12
10
  super(...arguments);
13
11
  this.url = 'https://ops.adinsure.com/api/storage/extensions/';
14
12
  }
15
- async downloadFile(version) {
16
- let options = {
17
- uri: `${this.url}/keycloak-scim2-outbound-provisioning-${version}.zip`,
18
- encoding: 'binary',
19
- headers: {
20
- Authorization: 'Bearer ' + await this.security.getToken()
21
- }
22
- };
23
- return request.get(options);
24
- }
25
- async run() {
26
- const { flags } = this.parse(DownloadKeycloak);
27
- let basePath = flags.output;
28
- const filename = `Keycloak-scim-${flags.version}.zip`;
29
- let filePath = path.resolve(basePath, filename);
30
- cli_ux_1.default.action.start(`Downloading Keycloack version ${flags.version} to ${filePath}`, undefined, { stdout: true });
31
- try {
32
- let file = await this.downloadFile(flags.version);
33
- let writeStream = fs.createWriteStream(filePath);
34
- writeStream.write(file, 'binary');
35
- writeStream.on('finish', () => {
36
- cli_ux_1.default.action.stop(`${chalk_1.default.green('OK')}`);
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ downloadFile(version) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ return axios.get(`${this.url}/keycloak-scim2-outbound-provisioning-${version}.zip`, {
17
+ headers: {
18
+ Authorization: 'Bearer ' + (yield this.security.getToken()),
19
+ 'Content-Type': 'application/octet-stream',
20
+ },
37
21
  });
38
- writeStream.end();
39
- }
40
- catch (err) {
41
- switch (err.statusCode) {
42
- case 404:
43
- this.error('Does not exists.', { exit: 1 });
44
- break;
45
- case 400:
46
- this.error('Try refreshing your login credentials with "ops login".', { exit: 1 });
47
- break;
48
- default:
49
- this.error(err.message);
22
+ });
23
+ }
24
+ run() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const { flags } = yield this.parse(DownloadKeycloak);
27
+ const basePath = flags.output;
28
+ const filename = `Keycloak-scim-${flags.version}.zip`;
29
+ const filePath = path.resolve(basePath, filename);
30
+ ux.action.start(`Downloading Keycloack version ${flags.version} to ${filePath}`, undefined, { stdout: true });
31
+ try {
32
+ const file = yield this.downloadFile(flags.version);
33
+ const writeStream = fs.createWriteStream(filePath);
34
+ writeStream.write(file.data, 'binary');
35
+ writeStream.on('finish', () => {
36
+ ux.action.stop(`${chalk.green('OK')}`);
37
+ });
38
+ writeStream.end();
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ }
41
+ catch (error) {
42
+ switch (error.statusCode) {
43
+ case 404: {
44
+ this.error('Does not exists.', { exit: 1 });
45
+ break;
46
+ }
47
+ case 400: {
48
+ this.error('Try refreshing your login credentials with "ops login".', { exit: 1 });
49
+ break;
50
+ }
51
+ default: {
52
+ this.error(error.message);
53
+ }
54
+ }
50
55
  }
51
- }
56
+ });
52
57
  }
53
58
  }
54
- exports.default = DownloadKeycloak;
55
59
  DownloadKeycloak.description = 'download Keycloak-scim from Azure storage';
56
60
  DownloadKeycloak.usage = 'download:keycloak-scim <flags>';
57
61
  DownloadKeycloak.examples = [
58
- `$ ops download:keycloak-scim -v 3.2.0 -o ~/Downloads`
62
+ `$ ops download:keycloak-scim -v 3.2.0 -o ~/Downloads`,
59
63
  ];
60
64
  DownloadKeycloak.flags = {
61
- version: command_1.flags.string({
65
+ version: Flags.string({
62
66
  char: 'v',
63
67
  description: 'version we want to download',
64
- required: true
68
+ required: true,
65
69
  }),
66
- output: command_1.flags.string({
70
+ output: Flags.string({
67
71
  char: 'o',
68
72
  description: 'output directory',
69
- default: './'
73
+ default: './',
70
74
  }),
71
75
  };
76
+ export default DownloadKeycloak;
@@ -1,18 +1,20 @@
1
- import { flags } from '@oclif/command';
2
- import CommandBase from '../../command.base';
3
- export default class DownloadPlatform extends CommandBase {
1
+ import { AxiosResponse } from 'axios';
2
+ import CommandBase from '../../command.base.js';
3
+ export default class DownloadPlatform extends CommandBase<typeof DownloadPlatform> {
4
4
  static aliases: string[];
5
5
  static description: string;
6
6
  static usage: string;
7
7
  static examples: string[];
8
8
  static flags: {
9
- version: flags.IOptionFlag<string>;
10
- 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>;
11
11
  };
12
12
  private readonly url;
13
13
  /**
14
- * Get unique scriptID by specified version
14
+ * Get unique AdInsure Platform zip by specified version
15
+ * @param {string} version The version of AdInsure Platform
16
+ * @returns {Promise<AxiosResponse<any, any>>}
15
17
  */
16
- downloadFile(version: string): Promise<string>;
18
+ downloadFile(version: string): Promise<AxiosResponse<any, any>>;
17
19
  run(): Promise<void>;
18
20
  }