@adinsure-ops/ops-cli 4.0.0-rc6

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 (71) hide show
  1. package/CHANGELOGS.md +55 -0
  2. package/LICENSE +1 -0
  3. package/README.md +576 -0
  4. package/bin/run +5 -0
  5. package/bin/run.cmd +3 -0
  6. package/lib/command.base.d.ts +17 -0
  7. package/lib/command.base.jira.d.ts +11 -0
  8. package/lib/command.base.jira.js +37 -0
  9. package/lib/command.base.js +73 -0
  10. package/lib/commands/doctor.d.ts +54 -0
  11. package/lib/commands/doctor.js +311 -0
  12. package/lib/commands/download/client.d.ts +18 -0
  13. package/lib/commands/download/client.js +72 -0
  14. package/lib/commands/download/identity-server.d.ts +18 -0
  15. package/lib/commands/download/identity-server.js +72 -0
  16. package/lib/commands/download/platform.d.ts +18 -0
  17. package/lib/commands/download/platform.js +72 -0
  18. package/lib/commands/download/scheduler.d.ts +18 -0
  19. package/lib/commands/download/scheduler.js +72 -0
  20. package/lib/commands/download/server.d.ts +18 -0
  21. package/lib/commands/download/server.js +72 -0
  22. package/lib/commands/download/studio.d.ts +20 -0
  23. package/lib/commands/download/studio.js +89 -0
  24. package/lib/commands/gitlab/next-nightly-tag.d.ts +30 -0
  25. package/lib/commands/gitlab/next-nightly-tag.js +171 -0
  26. package/lib/commands/jira/issue.d.ts +17 -0
  27. package/lib/commands/jira/issue.js +31 -0
  28. package/lib/commands/jira/labels.d.ts +22 -0
  29. package/lib/commands/jira/labels.js +70 -0
  30. package/lib/commands/log/add.d.ts +17 -0
  31. package/lib/commands/log/add.js +107 -0
  32. package/lib/commands/log/generate.d.ts +22 -0
  33. package/lib/commands/log/generate.js +155 -0
  34. package/lib/commands/log/validate.d.ts +11 -0
  35. package/lib/commands/log/validate.js +58 -0
  36. package/lib/commands/login.d.ts +23 -0
  37. package/lib/commands/login.js +144 -0
  38. package/lib/commands/npm/check.publish.d.ts +17 -0
  39. package/lib/commands/npm/check.publish.js +78 -0
  40. package/lib/commands/npm/publish.d.ts +23 -0
  41. package/lib/commands/npm/publish.js +163 -0
  42. package/lib/commands/prepare-content.d.ts +29 -0
  43. package/lib/commands/prepare-content.js +386 -0
  44. package/lib/commands/sql.d.ts +24 -0
  45. package/lib/commands/sql.js +147 -0
  46. package/lib/commands/translate.d.ts +37 -0
  47. package/lib/commands/translate.js +149 -0
  48. package/lib/commands/version.d.ts +48 -0
  49. package/lib/commands/version.js +267 -0
  50. package/lib/config.d.ts +7 -0
  51. package/lib/config.js +9 -0
  52. package/lib/hooks/init/version-override.d.ts +2 -0
  53. package/lib/hooks/init/version-override.js +15 -0
  54. package/lib/index.d.ts +1 -0
  55. package/lib/index.js +4 -0
  56. package/lib/lib/command.d.ts +9 -0
  57. package/lib/lib/command.js +71 -0
  58. package/lib/lib/npm.d.ts +15 -0
  59. package/lib/lib/npm.js +79 -0
  60. package/lib/lib/npmrc.d.ts +17 -0
  61. package/lib/lib/npmrc.js +44 -0
  62. package/lib/security/cache.d.ts +7 -0
  63. package/lib/security/cache.js +33 -0
  64. package/lib/security/context.d.ts +58 -0
  65. package/lib/security/context.js +224 -0
  66. package/lib/types/changelog.types.d.ts +6 -0
  67. package/lib/types/changelog.types.js +2 -0
  68. package/lib/types/npm.types.d.ts +34 -0
  69. package/lib/types/npm.types.js +2 -0
  70. package/oclif.manifest.json +1 -0
  71. package/package.json +118 -0
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("@oclif/command");
4
+ const JiraApi = require("jira-client");
5
+ const command_base_1 = require("./command.base");
6
+ class CommandBaseJira extends command_base_1.default {
7
+ async jiraInit(url, username, password) {
8
+ const jiraUrl = new URL(url);
9
+ const jira = new JiraApi({
10
+ protocol: jiraUrl.protocol,
11
+ host: jiraUrl.hostname,
12
+ username,
13
+ password,
14
+ apiVersion: '2',
15
+ strictSSL: true
16
+ });
17
+ return jira;
18
+ }
19
+ }
20
+ exports.default = CommandBaseJira;
21
+ CommandBaseJira.flags = {
22
+ username: command_1.flags.string({
23
+ description: 'jira username',
24
+ env: 'JIRA_USERNAME',
25
+ required: true
26
+ }),
27
+ password: command_1.flags.string({
28
+ description: 'jira password',
29
+ env: 'JIRA_PASSWORD',
30
+ required: true
31
+ }),
32
+ hostname: command_1.flags.string({
33
+ description: 'jira hostname',
34
+ default: 'https://jira.adacta-fintech.com',
35
+ env: 'JIRA_HOSTNAME'
36
+ })
37
+ };
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("@oclif/command");
4
+ const fs = require("fs-extra");
5
+ const path = require("path");
6
+ const context_1 = require("./security/context");
7
+ class CommandBase extends command_1.Command {
8
+ constructor(argv, config) {
9
+ super(argv, config);
10
+ this.security = new context_1.default(this.config.configDir);
11
+ }
12
+ async getGitRoot(startDir) {
13
+ let currentPath = path.resolve(startDir || process.cwd());
14
+ // tslint:disable-next-line: no-constant-condition
15
+ while (true) {
16
+ // We've reached the root and didn't find .git
17
+ if (currentPath === path.parse(currentPath).root) {
18
+ throw new Error('Not a git repository (or any of the parent directories)');
19
+ }
20
+ if (await fs.pathExists(path.resolve(currentPath, '.git'))) {
21
+ // toLowerCase because of different behaviour when executing tests with yarn or with Test Explorer in VS Code
22
+ return currentPath.toLowerCase();
23
+ }
24
+ currentPath = path.dirname(currentPath);
25
+ }
26
+ }
27
+ async getVersion(versionFile = 'VERSION', ...filesToCheck) {
28
+ filesToCheck.unshift(versionFile);
29
+ const gitRoot = await this.getGitRoot();
30
+ for (const file of filesToCheck) {
31
+ const versionPath = path.resolve(gitRoot, file);
32
+ if (await fs.pathExists(versionPath)) {
33
+ return fs.readFileSync(versionPath, 'utf-8');
34
+ }
35
+ }
36
+ return this.error(`${filesToCheck} file was not found`, { exit: 2 });
37
+ }
38
+ /**
39
+ * Resolve path to Changelog folder from current execution directory
40
+ */
41
+ async getChangelogsRoot() {
42
+ let currentPath = path.resolve(process.cwd());
43
+ if (!await fs.pathExists(currentPath)) {
44
+ this.log(`Directory '${currentPath}' doesn't exist ... nothing to do here.`);
45
+ this.exit(0);
46
+ }
47
+ return path.resolve(currentPath, 'changelogs', 'unreleased');
48
+ }
49
+ /**
50
+ * Get all files inside directory and normalize it against {baseRelativePath}.
51
+ */
52
+ async getFilesRecursive(dir, baseRelativePath, filter) {
53
+ if (!await fs.pathExists(dir)) {
54
+ this.warn(`Directory '${dir}' doesn't exist ... nothing to do here.`);
55
+ return [];
56
+ }
57
+ let relativePath = path.relative(baseRelativePath, dir);
58
+ relativePath = relativePath === '' ? '.' : relativePath;
59
+ const entries = await fs.readdir(dir);
60
+ // Get files within the current directory and add a relative path to the file objects
61
+ const files = entries
62
+ .filter(file => !fs.statSync(path.resolve(dir, file)).isDirectory())
63
+ .filter(file => filter.test(path.resolve(dir, file)))
64
+ .map(file => `${relativePath}/${file}`);
65
+ // Get folders within the current directory
66
+ const folders = entries.filter(filetype => fs.statSync(path.resolve(dir, filetype)).isDirectory());
67
+ for (const folder of folders)
68
+ // Recursivly call this function and get relative paths of files inside directory
69
+ files.push(...await this.getFilesRecursive(path.join(dir, folder), baseRelativePath, filter));
70
+ return files;
71
+ }
72
+ }
73
+ exports.default = CommandBase;
@@ -0,0 +1,54 @@
1
+ import CommandBase from '../command.base';
2
+ export default class Doctor extends CommandBase {
3
+ static description: string;
4
+ static usage: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ fix: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
8
+ };
9
+ private readonly cp;
10
+ private nvm;
11
+ private yarn;
12
+ private node;
13
+ private missing_packages;
14
+ /**
15
+ * Check if nvm is installed
16
+ */
17
+ gitCheck(fix: boolean): Promise<void>;
18
+ gitInstall(): Promise<void>;
19
+ gitLinuxInstall(): Promise<void>;
20
+ gitWindowsInstall(): Promise<void>;
21
+ /**
22
+ * Check if nvm is installed
23
+ */
24
+ nvmCheck(): Promise<void>;
25
+ /**
26
+ * Check which node is installed
27
+ */
28
+ nodeCheck(fix: boolean): Promise<void>;
29
+ /**
30
+ * Check which node is installed
31
+ */
32
+ nodeInstall(): Promise<void>;
33
+ /**
34
+ * Check which yarn is installed
35
+ */
36
+ yarnCheck(fix: boolean): Promise<void>;
37
+ /**
38
+ * Check which yarn is installed
39
+ */
40
+ yarnInstall(): Promise<void>;
41
+ /**
42
+ * Check which vsts-npm-auth is installed
43
+ */
44
+ vstsCheck(fix: boolean): Promise<void>;
45
+ /**
46
+ * Check which yarn is installed
47
+ */
48
+ vstsInstall(): Promise<void>;
49
+ /**
50
+ * Check which VSCode is installed
51
+ */
52
+ vscodeCheck(): Promise<void>;
53
+ run(): Promise<void>;
54
+ }
@@ -0,0 +1,311 @@
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 {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.cp = new command_2.default();
13
+ this.nvm = false;
14
+ this.yarn = false;
15
+ this.node = false;
16
+ this.missing_packages = 0;
17
+ }
18
+ /**
19
+ * Check if nvm is installed
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();
37
+ }
38
+ else {
39
+ this.missing_packages++;
40
+ this.warn(`Looks like git is missing.
41
+ Official documentation on how to install git can be found here: (https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)`);
42
+ }
43
+ }
44
+ }
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
+ }
55
+ }
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
+ }
66
+ }
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
70
+ }
71
+ /**
72
+ * Check if nvm is installed
73
+ */
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;
82
+ }
83
+ catch (_a) {
84
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('not installed')}`);
85
+ }
86
+ }
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)}`);
96
+ }
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)}`);
101
+ }
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
+ }
106
+ }
107
+ /**
108
+ * Check which node is installed
109
+ */
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 and vsts if node is installed
123
+ await this.yarnCheck(fix);
124
+ await this.vstsCheck(fix);
125
+ }
126
+ else {
127
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('failed getting version')}`);
128
+ }
129
+ }
130
+ }
131
+ catch (_a) {
132
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('node is missing')}`);
133
+ if (fix && this.nvm) {
134
+ await this.nodeInstall();
135
+ }
136
+ else {
137
+ this.missing_packages++;
138
+ }
139
+ }
140
+ }
141
+ /**
142
+ * Check which node is installed
143
+ */
144
+ async nodeInstall() {
145
+ cli_ux_1.default.action.start('installing node 15.6.0', undefined, { stdout: true });
146
+ if (!this.nvm) {
147
+ return cli_ux_1.default.action.stop(`${chalk_1.default.red('only works with nvm isntalled')}`);
148
+ }
149
+ try {
150
+ let output = await this.cp.runCommand(['nvm', 'install', '15.6.0']);
151
+ if (output.error) {
152
+ cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
153
+ }
154
+ else {
155
+ let nvmUserOutput = await this.cp.runCommand(['nvm', 'use', '15.6.0']);
156
+ if (nvmUserOutput.error) {
157
+ cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
158
+ }
159
+ cli_ux_1.default.action.stop(`${chalk_1.default.green('Done')}`);
160
+ }
161
+ }
162
+ catch (_a) {
163
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('failed')}`);
164
+ }
165
+ }
166
+ /**
167
+ * Check which yarn is installed
168
+ */
169
+ async yarnCheck(fix) {
170
+ cli_ux_1.default.action.start('Checking yarn', undefined, { stdout: true });
171
+ try {
172
+ let output = await this.cp.runCommand(['yarn', '--version']);
173
+ if (output.error) {
174
+ cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
175
+ }
176
+ else {
177
+ let version = output.data.split('\n')[0];
178
+ if (version) {
179
+ this.yarn = true;
180
+ cli_ux_1.default.action.stop(`${chalk_1.default.green(version)}`);
181
+ }
182
+ else {
183
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('yarn is missing')}`);
184
+ }
185
+ }
186
+ }
187
+ catch (_a) {
188
+ this.missing_packages++;
189
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('yarn is missing')}`);
190
+ if (fix) {
191
+ await this.yarnInstall();
192
+ }
193
+ }
194
+ }
195
+ /**
196
+ * Check which yarn is installed
197
+ */
198
+ async yarnInstall() {
199
+ cli_ux_1.default.action.start('Install yarn', undefined, { stdout: true });
200
+ try {
201
+ let output = await this.cp.runCommand(['npm', '-g', 'install', 'yarn']);
202
+ if (output.error) {
203
+ cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
204
+ }
205
+ else {
206
+ this.yarn = true;
207
+ cli_ux_1.default.action.stop(`${chalk_1.default.green('yarn installed')}`);
208
+ }
209
+ }
210
+ catch (_a) {
211
+ this.missing_packages++;
212
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('yarn failed to install')}`);
213
+ }
214
+ }
215
+ /**
216
+ * Check which vsts-npm-auth is installed
217
+ */
218
+ async vstsCheck(fix) {
219
+ cli_ux_1.default.action.start('Checking vsts-npm-auth', undefined, { stdout: true });
220
+ if (process.platform !== 'win32') {
221
+ cli_ux_1.default.action.stop(`${chalk_1.default.blue('not Windows, skipping')}`);
222
+ return;
223
+ }
224
+ try {
225
+ let output = await this.cp.runCommand(['yarn', 'global', 'list']);
226
+ if (output.error) {
227
+ cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
228
+ }
229
+ else {
230
+ let version = output.data.match(/\"vsts-npm-auth\@(.*)\"/);
231
+ if (version && version.length > 1) {
232
+ cli_ux_1.default.action.stop(`${chalk_1.default.green(version[1])}`);
233
+ }
234
+ else {
235
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('vsts-npm-auth is missing')}`);
236
+ if (fix && this.yarn) {
237
+ await this.vstsInstall();
238
+ }
239
+ else {
240
+ this.missing_packages++;
241
+ }
242
+ }
243
+ }
244
+ }
245
+ catch (err) {
246
+ cli_ux_1.default.action.stop(`${chalk_1.default.red(err.message)}`);
247
+ }
248
+ }
249
+ /**
250
+ * Check which yarn is installed
251
+ */
252
+ async vstsInstall() {
253
+ cli_ux_1.default.action.start('Install vsts-npm-auth', undefined, { stdout: true });
254
+ try {
255
+ let output = await this.cp.runCommand(['yarn', 'global', 'add', 'vsts-npm-auth']);
256
+ if (output.error) {
257
+ cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
258
+ }
259
+ else {
260
+ cli_ux_1.default.action.stop(`${chalk_1.default.green('vsts-npm-auth installed')}`);
261
+ }
262
+ }
263
+ catch (_a) {
264
+ this.missing_packages++;
265
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('vsts-npm-auth failed to install')}`);
266
+ }
267
+ }
268
+ /**
269
+ * Check which VSCode is installed
270
+ */
271
+ async vscodeCheck() {
272
+ cli_ux_1.default.action.start('Checking vscode', undefined, { stdout: true });
273
+ try {
274
+ let output = await this.cp.runCommand(['code', '--version']);
275
+ if (output.error) {
276
+ cli_ux_1.default.action.stop(`${chalk_1.default.red(output.error)}`);
277
+ }
278
+ else {
279
+ let version = output.data.split('\n')[0];
280
+ cli_ux_1.default.action.stop(`${chalk_1.default.green(version)}`);
281
+ }
282
+ }
283
+ catch (_a) {
284
+ this.missing_packages++;
285
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('VSCode not installed')}`);
286
+ }
287
+ }
288
+ async run() {
289
+ const { flags } = this.parse(Doctor);
290
+ await this.gitCheck(flags.fix);
291
+ await this.nvmCheck();
292
+ await this.nodeCheck(flags.fix);
293
+ await this.vscodeCheck();
294
+ if (this.missing_packages > 0) {
295
+ this.warn(`${chalk_1.default.yellow('Some packages are missing. try --fix to automaticaly install.')}`);
296
+ }
297
+ }
298
+ }
299
+ exports.default = Doctor;
300
+ Doctor.description = 'check if everyting is installed';
301
+ Doctor.usage = 'doctor';
302
+ Doctor.examples = [
303
+ `$ ops doctor`
304
+ ];
305
+ Doctor.flags = {
306
+ fix: command_1.flags.boolean({
307
+ char: 'p',
308
+ description: 'try to install missing packages',
309
+ default: false
310
+ })
311
+ };
@@ -0,0 +1,18 @@
1
+ import { flags } from '@oclif/command';
2
+ import CommandBase from '../../command.base';
3
+ export default class DownloadClient extends CommandBase {
4
+ static aliases: string[];
5
+ static description: string;
6
+ static usage: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ version: flags.IOptionFlag<string>;
10
+ output: flags.IOptionFlag<string>;
11
+ };
12
+ private readonly url;
13
+ /**
14
+ * Get unique scriptID by specified version
15
+ */
16
+ downloadFile(version: string): Promise<string>;
17
+ run(): Promise<void>;
18
+ }
@@ -0,0 +1,72 @@
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 {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.url = 'https://ops.adinsure.com/api/storage/binaries/';
14
+ }
15
+ /**
16
+ * Get unique scriptID by specified version
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')}`);
40
+ });
41
+ writeStream.end();
42
+ }
43
+ catch (err) {
44
+ if (err.statusCode === 404) {
45
+ // cli.action.stop(`${chalk.red('Does not exists.')}`);
46
+ this.error('Does not exists.', { exit: 1 });
47
+ }
48
+ else {
49
+ this.error(err.message);
50
+ }
51
+ }
52
+ }
53
+ }
54
+ exports.default = DownloadClient;
55
+ DownloadClient.aliases = ['download:client'];
56
+ DownloadClient.description = 'download AdInsure Client from Azure storage';
57
+ DownloadClient.usage = 'download:client <flags>';
58
+ DownloadClient.examples = [
59
+ `$ ops download:client -v 3.2.0 -o ~/Downloads`
60
+ ];
61
+ DownloadClient.flags = {
62
+ version: command_1.flags.string({
63
+ char: 'v',
64
+ description: 'version we want to download',
65
+ required: true
66
+ }),
67
+ output: command_1.flags.string({
68
+ char: 'o',
69
+ description: 'output directory',
70
+ default: './'
71
+ }),
72
+ };
@@ -0,0 +1,18 @@
1
+ import { flags } from '@oclif/command';
2
+ import CommandBase from '../../command.base';
3
+ export default class DownloadIdentityServer extends CommandBase {
4
+ static aliases: string[];
5
+ static description: string;
6
+ static usage: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ version: flags.IOptionFlag<string>;
10
+ output: flags.IOptionFlag<string>;
11
+ };
12
+ private readonly url;
13
+ /**
14
+ * Get unique scriptID by specified version
15
+ */
16
+ downloadFile(version: string): Promise<string>;
17
+ run(): Promise<void>;
18
+ }
@@ -0,0 +1,72 @@
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 {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.url = 'https://ops.adinsure.com/api/storage/binaries/';
14
+ }
15
+ /**
16
+ * Get unique scriptID by specified version
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')}`);
40
+ });
41
+ writeStream.end();
42
+ }
43
+ catch (err) {
44
+ if (err.statusCode === 404) {
45
+ // cli.action.stop(`${chalk.red('Does not exists.')}`);
46
+ this.error('Does not exists.', { exit: 1 });
47
+ }
48
+ else {
49
+ this.error(err.message);
50
+ }
51
+ }
52
+ }
53
+ }
54
+ exports.default = DownloadIdentityServer;
55
+ DownloadIdentityServer.aliases = ['download:identity-server'];
56
+ DownloadIdentityServer.description = 'download AdInsure Identity Server from Azure storage';
57
+ DownloadIdentityServer.usage = 'download:identity-server <flags>';
58
+ DownloadIdentityServer.examples = [
59
+ `$ ops download:identity-server -v 3.0.3 -o ~/Downloads`
60
+ ];
61
+ DownloadIdentityServer.flags = {
62
+ version: command_1.flags.string({
63
+ char: 'v',
64
+ description: 'version we want to download',
65
+ required: true
66
+ }),
67
+ output: command_1.flags.string({
68
+ char: 'o',
69
+ description: 'output directory',
70
+ default: './'
71
+ }),
72
+ };
@@ -0,0 +1,18 @@
1
+ import { flags } from '@oclif/command';
2
+ import CommandBase from '../../command.base';
3
+ export default class DownloadPlatform extends CommandBase {
4
+ static aliases: string[];
5
+ static description: string;
6
+ static usage: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ version: flags.IOptionFlag<string>;
10
+ output: flags.IOptionFlag<string>;
11
+ };
12
+ private readonly url;
13
+ /**
14
+ * Get unique scriptID by specified version
15
+ */
16
+ downloadFile(version: string): Promise<string>;
17
+ run(): Promise<void>;
18
+ }