@adinsure-ops/ops-cli 4.8.2 → 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 +246 -225
  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 -79
  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 +52 -47
  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,309 +1,330 @@
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 fs = require("fs-extra");
6
- const inquirer = require("inquirer");
7
- const _ = require("lodash");
8
- const path = require("path");
9
- const request = require("request-promise");
10
- const semver = require("semver");
11
- const command_base_1 = require("../command.base");
12
- class Sql extends command_base_1.default {
1
+ import { __awaiter } from "tslib";
2
+ import { Args, Flags } from '@oclif/core';
3
+ import axios from 'axios';
4
+ import chalk from 'chalk';
5
+ import fs from 'fs-extra';
6
+ import inquirer from 'inquirer';
7
+ import _ from 'lodash-es';
8
+ import path from 'path';
9
+ import semver from 'semver';
10
+ import CommandBase from '../command.base.js';
11
+ class Sql extends CommandBase {
13
12
  constructor() {
14
13
  super(...arguments);
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
15
  this._moduleTypes = {
16
16
  acc: 'Accounting',
17
17
  claims: 'Claims',
18
18
  core: 'Core',
19
19
  pas: 'PAS',
20
20
  reins: 'Reinsurance',
21
- shared: 'Shared'
21
+ shared: 'Shared',
22
22
  };
23
23
  this._dbmsType = ['sql', 'oradc'];
24
24
  }
25
25
  /**
26
- * Get unique scriptID by specified version
26
+ * Get unique Script ID zip by specified version
27
+ * @param {string} version The version of Identity Server
28
+ * @returns {Promise<AxiosResponse<any, any>>}
27
29
  */
28
- async getScriptId(version) {
29
- let options = {
30
- uri: `https://ops.adinsure.com/api/script/next?version=${version}`,
31
- headers: {
32
- Authorization: 'Bearer ' + await this.security.getToken()
33
- }
34
- };
35
- return request.get(options);
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ getScriptId(version) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ return axios.get(`https://ops.adinsure.com/api/script/next?version=${version}`, {
34
+ headers: {
35
+ Authorization: 'Bearer ' + (yield this.security.getToken()),
36
+ },
37
+ });
38
+ });
36
39
  }
37
40
  /**
38
41
  * Get unique scriptID by specified version
42
+ * @param {string} version Specified version
43
+ * @param {string} description Description
44
+ * @returns {Promise<string>} Promise to scriptID
39
45
  */
40
- async getOfflineScriptId(version, description) {
41
- let prefix = '8.50';
42
- const date = new Date();
43
- let timestamp = date.getUTCFullYear() +
44
- ('0' + (date.getUTCMonth() + 1)).slice(-2) +
45
- ('0' + (date.getUTCDate())).slice(-2) +
46
- ('0' + (date.getUTCHours())).slice(-2) +
47
- ('0' + (date.getUTCMinutes())).slice(-2) +
48
- ('0' + (date.getUTCSeconds())).slice(-2);
49
- let versionSplit = version.split('.');
50
- let scriptId = prefix
51
- + '_' +
52
- ('00' + versionSplit[0]).slice(-3)
53
- + '.' +
54
- ('00' + versionSplit[1]).slice(-3)
55
- + '.' +
56
- ('00' + versionSplit[2]).slice(-3)
57
- + '_' + timestamp;
58
- if (description) {
59
- scriptId = scriptId + '_' + _.snakeCase(description).substring(0, 100);
60
- }
61
- return scriptId;
46
+ getOfflineScriptId(version, description) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const prefix = '8.50';
49
+ const date = new Date();
50
+ const timestamp = date.getUTCFullYear() +
51
+ ('0' + (date.getUTCMonth() + 1)).slice(-2) +
52
+ ('0' + (date.getUTCDate())).slice(-2) +
53
+ ('0' + (date.getUTCHours())).slice(-2) +
54
+ ('0' + (date.getUTCMinutes())).slice(-2) +
55
+ ('0' + (date.getUTCSeconds())).slice(-2);
56
+ const versionSplit = version.split('.');
57
+ let scriptId = prefix +
58
+ '_' +
59
+ ('00' + versionSplit[0]).slice(-3) +
60
+ '.' +
61
+ ('00' + versionSplit[1]).slice(-3) +
62
+ '.' +
63
+ ('00' + versionSplit[2]).slice(-3) +
64
+ '_' + timestamp;
65
+ if (description) {
66
+ scriptId = scriptId + '_' + _.snakeCase(description).slice(0, 100);
67
+ }
68
+ return scriptId;
69
+ });
62
70
  }
63
- async handleLayer(scriptDbmsFolder, scriptLayer, scriptType, dbmsFormat) {
64
- let scriptFolder = path.resolve(scriptDbmsFolder, scriptLayer, scriptType);
65
- let layerFolder = path.resolve(scriptDbmsFolder, scriptLayer);
66
- if (!await fs.pathExists(layerFolder)) {
67
- let layers = '';
68
- // printout only layer folders
69
- for (let layer of fs.readdirSync(scriptDbmsFolder)) {
70
- if (layer.toLowerCase() !== 'schema' && layer.toLowerCase() !== 'data') {
71
- layers = layers + '\n' + layer;
71
+ handleLayer(scriptDbmsFolder, scriptLayer, scriptType, dbmsFormat) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ const scriptFolder = path.resolve(scriptDbmsFolder, scriptLayer, scriptType);
74
+ const layerFolder = path.resolve(scriptDbmsFolder, scriptLayer);
75
+ if (!(yield fs.pathExists(layerFolder))) {
76
+ let layers = '';
77
+ // printout only layer folders
78
+ for (const layer of fs.readdirSync(scriptDbmsFolder)) {
79
+ if (layer.toLowerCase() !== 'schema' && layer.toLowerCase() !== 'data') {
80
+ layers = layers + '\n' + layer;
81
+ }
82
+ }
83
+ if (layers.length > 0) {
84
+ this.log(`Layer ${scriptLayer} for ${dbmsFormat} does not exist, did you mean: ${layers}`);
85
+ }
86
+ else {
87
+ this.log(`Layer ${scriptLayer} for ${dbmsFormat} does not exist.`);
72
88
  }
73
89
  }
74
- if (layers.length > 0) {
75
- this.log(`Layer ${scriptLayer} for ${dbmsFormat} does not exist, did you mean: ${layers}`);
76
- }
77
- else {
78
- this.log(`Layer ${scriptLayer} for ${dbmsFormat} does not exist.`);
79
- }
80
- }
81
- return scriptFolder;
90
+ return scriptFolder;
91
+ });
82
92
  }
83
- async sqlExtendScriptGeneration(table_schema, table_name, column_name, column_type) {
84
- return `if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = '${table_schema}' and TABLE_NAME = '${table_name}')
93
+ sqlExtendScriptGeneration(tableSchema, tableName, columnName, columnType) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ return `if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = '${tableSchema}' and TABLE_NAME = '${tableName}')
85
96
  begin
86
- if not exists (select * from INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA = '${table_schema}' and TABLE_NAME = '${table_name}' and COLUMN_NAME = '${column_name}')
97
+ if not exists (select * from INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA = '${tableSchema}' and TABLE_NAME = '${tableName}' and COLUMN_NAME = '${columnName}')
87
98
  begin
88
- alter table ${table_schema}.${table_name} add ${column_name} ${column_type};
99
+ alter table ${tableSchema}.${tableName} add ${columnName} ${columnType};
89
100
  end
90
101
  end`;
102
+ });
91
103
  }
92
- async oradcExtendScriptGeneration(table_schema, table_name, column_name, column_type) {
93
- return `DECLARE
104
+ oradcExtendScriptGeneration(tableSchema, tableName, columnName, columnType) {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ return `DECLARE
94
107
  v_column_exists number := 0;
95
108
  v_table_exists number := 0;
96
109
  BEGIN
97
110
  Select count(*) into v_table_exists
98
111
  from ALL_TAB_COLS
99
- where upper(OWNER) = '${table_schema}'
100
- and upper(table_name) = '${table_name}';
112
+ where upper(OWNER) = '${tableSchema}'
113
+ and upper(table_name) = '${tableName}';
101
114
  if (v_table_exists > 0) then
102
115
  select count(*) into v_column_exists
103
116
  from ALL_TAB_COLS
104
- where upper(OWNER) = ${table_schema}
105
- and upper(table_name) = '${table_name}';
106
- and upper(column_name) = '${column_name}'
117
+ where upper(OWNER) = ${tableSchema}
118
+ and upper(table_name) = '${tableName}';
119
+ and upper(column_name) = '${columnName}'
107
120
  if (v_column_exists = 0) then
108
- execute immediate alter table ${table_schema}.${table_name} add ${column_name} ${column_type};
121
+ execute immediate alter table ${tableSchema}.${tableName} add ${columnName} ${columnType};
109
122
  end if;
110
123
  end if;
111
124
  end;`;
125
+ });
112
126
  }
113
- async checkExtendParameters() {
114
- const { flags } = this.parse(Sql);
115
- const arrayOfParameters = [];
116
- if (flags['table-schema'] === undefined) {
117
- arrayOfParameters.push('table-scehma');
118
- }
119
- if (flags['table-name'] === undefined) {
120
- arrayOfParameters.push('table-name');
121
- }
122
- if (flags['column-name'] === undefined) {
123
- arrayOfParameters.push('column-name');
124
- }
125
- if (flags['column-type'] === undefined) {
126
- arrayOfParameters.push('column-type');
127
- }
128
- return arrayOfParameters;
127
+ checkExtendParameters() {
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ const { flags } = yield this.parse(Sql);
130
+ const arrayOfParameters = [];
131
+ if (flags['table-schema'] === undefined) {
132
+ arrayOfParameters.push('table-scehma');
133
+ }
134
+ if (flags['table-name'] === undefined) {
135
+ arrayOfParameters.push('table-name');
136
+ }
137
+ if (flags['column-name'] === undefined) {
138
+ arrayOfParameters.push('column-name');
139
+ }
140
+ if (flags['column-type'] === undefined) {
141
+ arrayOfParameters.push('column-type');
142
+ }
143
+ return arrayOfParameters;
144
+ });
129
145
  }
130
- async run() {
131
- var _a, _b;
132
- const { args, flags } = this.parse(Sql);
133
- const fullVersion = flags.version || await this.getVersion('SQL_SCRIPTS_VERSION', 'PLATFORM_VERSION', 'VERSION');
134
- let version = semver.parse(fullVersion);
135
- if (!version) {
136
- this.error(`Version in incorrect format. Got version: '${fullVersion}'`);
137
- }
138
- else if (flags.major) {
139
- version = semver.parse(`${version.major}.0.0`);
140
- this.error(`--major flag used. Got version: '${version === null || version === void 0 ? void 0 : version.version}'`);
141
- }
142
- else if (((_a = version === null || version === void 0 ? void 0 : version.prerelease) === null || _a === void 0 ? void 0 : _a.length) && ((_b = version === null || version === void 0 ? void 0 : version.prerelease) === null || _b === void 0 ? void 0 : _b.length) > 0) {
143
- this.warn(`Using prerelease version is not allowed. Got version: '${fullVersion}'.`);
144
- let responses = await inquirer.prompt([{
145
- name: 'version',
146
- message: 'write version you want to use or write "yes" to revert to latest latest patch.',
147
- type: 'input',
148
- }]);
149
- if (responses.version === 'yes' || responses.version === '') {
146
+ // eslint-disable-next-line complexity
147
+ run() {
148
+ var _a, _b, _c;
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ const { args, flags } = yield this.parse(Sql);
151
+ const fullVersion = (_a = flags.version) !== null && _a !== void 0 ? _a : yield this.getVersion('SQL_SCRIPTS_VERSION', 'PLATFORM_VERSION', 'VERSION');
152
+ let version = semver.parse(fullVersion);
153
+ if (!version) {
154
+ this.error(`Version in incorrect format. Got version: '${fullVersion}'`);
155
+ }
156
+ else if (flags.major) {
150
157
  version = semver.parse(`${version.major}.0.0`);
151
- if (!version) {
152
- this.error(`Version in incorrect format. Got version: '${responses.version}'`);
153
- }
158
+ this.error(`--major flag used. Got version: '${version === null || version === void 0 ? void 0 : version.version}'`);
154
159
  }
155
- else {
156
- version = semver.parse(responses.version);
157
- if (!version) {
158
- this.error(`Version in incorrect format. Got version: '${responses.version}'`);
160
+ else if (((_b = version === null || version === void 0 ? void 0 : version.prerelease) === null || _b === void 0 ? void 0 : _b.length) && ((_c = version === null || version === void 0 ? void 0 : version.prerelease) === null || _c === void 0 ? void 0 : _c.length) > 0) {
161
+ this.warn(`Using prerelease version is not allowed. Got version: '${fullVersion}'.`);
162
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
163
+ const responses = yield inquirer.prompt([{
164
+ name: 'version',
165
+ message: 'write version you want to use or write "yes" to revert to latest latest patch.',
166
+ type: 'input',
167
+ }]);
168
+ if (responses.version === 'yes' || responses.version === '') {
169
+ version = semver.parse(`${version.major}.0.0`);
170
+ if (!version) {
171
+ this.error(`Version in incorrect format. Got version: '${responses.version}'`);
172
+ }
159
173
  }
160
- }
161
- this.warn(`${version === null || version === void 0 ? void 0 : version.version} version will be used.`);
162
- }
163
- // Validation of input parameters
164
- let scriptType = args.type;
165
- if (!scriptType) {
166
- let responses = await inquirer.prompt([{
167
- name: 'type',
168
- message: 'select a sql type',
169
- type: 'list',
170
- choices: [{ name: 'Schema' }, { name: 'Data' }, { name: 'Migration' }, { name: 'Extend' }],
171
- }]);
172
- scriptType = responses.type;
173
- }
174
- let scriptModule = args.module;
175
- if (!scriptModule && scriptType === 'data') {
176
- let responses = await inquirer.prompt([{
177
- name: 'module',
178
- message: 'select a sql module for data type',
179
- type: 'list',
180
- choices: [{ name: 'acc' }, { name: 'claims' }, { name: 'core' }, { name: 'pas' }, { name: 'reins' }, { name: 'shared' }],
181
- }]);
182
- scriptModule = responses.module;
183
- }
184
- // If scriptType is Extend, then check input parameters
185
- const arrayOfMissingParameters = await this.checkExtendParameters();
186
- if (arrayOfMissingParameters.length !== 0) {
187
- this.error(`The script type Extend requires the following parameters to be specified: ${arrayOfMissingParameters.join(', ')}`);
188
- }
189
- let scriptLayer = flags.layer;
190
- this.log(`Generating on SQL script layer:'${scriptLayer}'`);
191
- let scriptsRootFolder = path.resolve(await this.getGitRoot(), 'database');
192
- if (!await fs.pathExists(scriptsRootFolder)) {
193
- this.error(`Could not resolve database scripts folder: ${scriptsRootFolder}`);
194
- }
195
- let scriptFolderLocations = [];
196
- for (let dbmsFormat of this._dbmsType) {
197
- let scriptDbmsFolder = path.resolve(scriptsRootFolder, dbmsFormat);
198
- if (await fs.pathExists(scriptDbmsFolder)) {
199
- let scriptFolder = path.resolve(scriptDbmsFolder, scriptType);
200
- if (scriptLayer !== undefined) {
201
- scriptFolder = await this.handleLayer(scriptDbmsFolder, scriptLayer, scriptType, dbmsFormat);
174
+ else {
175
+ version = semver.parse(responses.version);
176
+ if (!version) {
177
+ this.error(`Version in incorrect format. Got version: '${responses.version}'`);
178
+ }
202
179
  }
203
- if (scriptModule !== undefined) {
204
- scriptFolder = path.resolve(scriptFolder, this._moduleTypes[scriptModule]);
180
+ this.warn(`${version === null || version === void 0 ? void 0 : version.version} version will be used.`);
181
+ }
182
+ // Validation of input parameters
183
+ let scriptType = args.type;
184
+ if (!scriptType) {
185
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
186
+ const responses = yield inquirer.prompt([{
187
+ name: 'type',
188
+ message: 'select a sql type',
189
+ type: 'list',
190
+ choices: [{ name: 'Schema' }, { name: 'Data' }, { name: 'Migration' }, { name: 'Extend' }],
191
+ }]);
192
+ scriptType = responses.type;
193
+ }
194
+ let scriptModule = args.module;
195
+ if (!scriptModule && scriptType === 'data') {
196
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
197
+ const responses = yield inquirer.prompt([{
198
+ name: 'module',
199
+ message: 'select a sql module for data type',
200
+ type: 'list',
201
+ choices: [{ name: 'acc' }, { name: 'claims' }, { name: 'core' }, { name: 'pas' }, { name: 'reins' }, { name: 'shared' }],
202
+ }]);
203
+ scriptModule = responses.module;
204
+ }
205
+ // If scriptType is Extend, then check input parameters for extending the db columns
206
+ if (scriptType === 'Extend') {
207
+ const arrayOfMissingParameters = yield this.checkExtendParameters();
208
+ if (arrayOfMissingParameters.length > 0) {
209
+ this.error(`The script type Extend requires the following parameters to be specified: ${arrayOfMissingParameters.join(', ')}`);
205
210
  }
206
- if (!await fs.pathExists(scriptFolder)) {
207
- this.warn(`Could not resolve existing database scripts folder. Creating folder: ${scriptFolder}`);
208
- await fs.mkdir(scriptFolder);
211
+ }
212
+ const scriptLayer = flags.layer;
213
+ this.log(`Generating on SQL script layer:'${scriptLayer}'`);
214
+ const scriptsRootFolder = path.resolve(yield this.getGitRoot(), 'database');
215
+ if (!(yield fs.pathExists(scriptsRootFolder))) {
216
+ this.error(`Could not resolve database scripts folder: ${scriptsRootFolder}`);
217
+ }
218
+ const scriptFolderLocations = [];
219
+ for (const dbmsFormat of this._dbmsType) {
220
+ const scriptDbmsFolder = path.resolve(scriptsRootFolder, dbmsFormat);
221
+ if (yield fs.pathExists(scriptDbmsFolder)) {
222
+ let scriptFolder = path.resolve(scriptDbmsFolder, scriptType);
223
+ if (scriptLayer !== undefined) {
224
+ scriptFolder = yield this.handleLayer(scriptDbmsFolder, scriptLayer, scriptType, dbmsFormat);
225
+ }
226
+ if (scriptModule !== undefined) {
227
+ scriptFolder = path.resolve(scriptFolder, this._moduleTypes[scriptModule]);
228
+ }
229
+ if (!(yield fs.pathExists(scriptFolder))) {
230
+ this.warn(`Could not resolve existing database scripts folder. Creating folder: ${scriptFolder}`);
231
+ yield fs.mkdir(scriptFolder);
232
+ }
233
+ scriptFolderLocations.push(scriptFolder);
209
234
  }
210
- scriptFolderLocations.push(scriptFolder);
211
235
  }
212
- }
213
- // Validation of parameters succeed. Requesting new SQL script ID and creating file.
214
- this.log(`Requesting new id for '${version}'`);
215
- let scriptId = '';
216
- if (flags.offline) {
217
- scriptId = await this.getOfflineScriptId(version.version, flags.description);
218
- this.log(`Generation script: '${chalk_1.default.green(scriptId + '.sql')}'`);
219
- }
220
- else {
221
- scriptId = await this.getScriptId(version.version);
222
- this.log(`Got: '${chalk_1.default.green(scriptId)}'`);
223
- }
224
- // Check if the operation is Extend
225
- if (scriptType === 'Extend') {
226
- // The first file will always be in \sql\ folder for mssql
227
- // and the second one will always be in \oradc\ for oracle db
228
- let sql_or_oradc = 0;
229
- for (let scriptFolder of scriptFolderLocations) {
230
- let scriptsFilePath = path.resolve(scriptFolder, `${scriptId}.sql`);
231
- // The values in flags such as table-schema, which are passed into the sql generation function can never be undefined as they
232
- // are checked prior to executing this code, so the functions are defined in a way where they can intake an undefined parameter
233
- // only due to typescript.
234
- if (!sql_or_oradc)
235
- await fs.writeFile(scriptsFilePath, await this.sqlExtendScriptGeneration(flags['table-schema'], flags['table-name'], flags['column-name'], flags['column-type']));
236
- else
237
- await fs.writeFile(scriptsFilePath, await this.oradcExtendScriptGeneration(flags['table-schema'], flags['table-name'], flags['column-name'], flags['column-type']));
238
- this.log(`${chalk_1.default.yellow(scriptsFilePath)}`);
239
- sql_or_oradc++;
236
+ // Validation of parameters succeed. Requesting new SQL script ID and creating file.
237
+ this.log(`Requesting new id for '${version}'`);
238
+ let scriptId = '';
239
+ if (flags.offline) {
240
+ scriptId = yield this.getOfflineScriptId(version.version, flags.description);
241
+ this.log(`Generation script: '${chalk.green(scriptId + '.sql')}'`);
242
+ }
243
+ else {
244
+ // eslint-disable-next-line unicorn/no-await-expression-member
245
+ scriptId = (yield this.getScriptId(version.version)).data;
246
+ this.log(`Got: '${chalk.green(scriptId)}'`);
247
+ }
248
+ // Check if the operation is Extend
249
+ if (scriptType === 'Extend') {
250
+ // The first file will always be in \sql\ folder for mssql
251
+ // and the second one will always be in \oradc\ for oracle db
252
+ let sqlOrOradc = 0;
253
+ for (const scriptFolder of scriptFolderLocations) {
254
+ const scriptsFilePath = path.resolve(scriptFolder, `${scriptId}.sql`);
255
+ // The values in flags such as table-schema, which are passed into the sql generation function can never be undefined as they
256
+ // are checked prior to executing this code, so the functions are defined in a way where they can intake an undefined parameter
257
+ // only due to typescript.
258
+ yield (sqlOrOradc ? fs.writeFile(scriptsFilePath, yield this.oradcExtendScriptGeneration(flags['table-schema'], flags['table-name'], flags['column-name'], flags['column-type'])) : fs.writeFile(scriptsFilePath, yield this.sqlExtendScriptGeneration(flags['table-schema'], flags['table-name'], flags['column-name'], flags['column-type'])));
259
+ this.log(`${chalk.yellow(scriptsFilePath)}`);
260
+ sqlOrOradc++;
261
+ }
240
262
  }
241
- }
242
- else {
243
- for (let scriptFolder of scriptFolderLocations) {
244
- let scriptsFilePath = path.resolve(scriptFolder, `${scriptId}.sql`);
245
- await fs.writeFile(scriptsFilePath, '');
246
- this.log(`${chalk_1.default.yellow(scriptsFilePath)}`);
263
+ else {
264
+ for (const scriptFolder of scriptFolderLocations) {
265
+ const scriptsFilePath = path.resolve(scriptFolder, `${scriptId}.sql`);
266
+ yield fs.writeFile(scriptsFilePath, '');
267
+ this.log(`${chalk.yellow(scriptsFilePath)}`);
268
+ }
247
269
  }
248
- }
270
+ });
249
271
  }
250
272
  }
251
- exports.default = Sql;
252
273
  Sql.description = 'creates a new database script';
253
274
  Sql.usage = 'sql <type> <module> [flags]';
254
275
  Sql.examples = [
255
276
  `$ ops sql schema `,
256
277
  `$ ops sql data shared --layer basic`,
257
278
  `$ ops sql data shared --major`,
258
- `$ ops sql data shared --offline --description "this is script description"`
279
+ `$ ops sql data shared --offline --description "this is script description"`,
259
280
  ];
260
- Sql.args = [
261
- {
262
- name: 'type',
281
+ Sql.args = {
282
+ type: Args.string({
263
283
  description: 'Type of database scripts',
264
- options: ['Schema', 'Data', 'Migration', 'Extend']
265
- },
266
- {
267
- name: 'module',
284
+ required: true,
285
+ options: ['Schema', 'Data', 'Migration', 'Extend'],
286
+ }),
287
+ module: Args.string({
268
288
  description: 'Module of data database scripts',
269
- options: ['acc', 'claims', 'core', 'pas', 'reins', 'shared']
270
- }
271
- ];
289
+ options: ['acc', 'claims', 'core', 'pas', 'reins', 'shared'],
290
+ }),
291
+ };
272
292
  Sql.flags = {
273
- version: command_1.flags.string({
293
+ version: Flags.string({
274
294
  char: 'v',
275
- description: 'version for which you\'re generating database script'
295
+ description: 'version for which you\'re generating database script',
276
296
  }),
277
- layer: command_1.flags.string({
297
+ layer: Flags.string({
278
298
  char: 'l',
279
- description: 'name of the configuration layer for which you are generating database script'
299
+ description: 'name of the configuration layer for which you are generating database script',
280
300
  }),
281
- offline: command_1.flags.boolean({
301
+ offline: Flags.boolean({
282
302
  char: 'o',
283
303
  description: 'generate database script with timestamp',
284
- default: false
304
+ default: false,
285
305
  }),
286
- description: command_1.flags.string({
306
+ description: Flags.string({
287
307
  char: 'd',
288
308
  description: 'description of script to be used in filename for offline',
289
- dependsOn: ['offline']
309
+ dependsOn: ['offline'],
290
310
  }),
291
- major: command_1.flags.boolean({
311
+ major: Flags.boolean({
292
312
  char: 'm',
293
313
  description: 'generate script for major version',
294
- default: false
314
+ default: false,
295
315
  }),
296
316
  // Used only for generating scripts to extend existing db tables with new column
297
- 'table-schema': command_1.flags.string({
317
+ 'table-schema': Flags.string({
298
318
  description: 'name of the existing table schema',
299
319
  }),
300
- 'table-name': command_1.flags.string({
320
+ 'table-name': Flags.string({
301
321
  description: 'name of the existing table',
302
322
  }),
303
- 'column-name': command_1.flags.string({
323
+ 'column-name': Flags.string({
304
324
  description: 'name the new column to be added',
305
325
  }),
306
- 'column-type': command_1.flags.string({
326
+ 'column-type': Flags.string({
307
327
  description: 'type of the new column to be added',
308
328
  }),
309
329
  };
330
+ export default Sql;
@@ -1,20 +1,18 @@
1
- import { flags } from '@oclif/command';
2
- import CommandBase from '../command.base';
3
- export default class Translate extends CommandBase {
1
+ import { AxiosResponse } from 'axios';
2
+ import CommandBase from '../command.base.js';
3
+ export default class Translate extends CommandBase<typeof Translate> {
4
4
  static description: string;
5
5
  static usage: string;
6
6
  static examples: string[];
7
7
  static args: {
8
- name: string;
9
- required: boolean;
10
- description: string;
11
- }[];
8
+ language: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
9
+ };
12
10
  static flags: {
13
- format: flags.IOptionFlag<string>;
14
- module: flags.IOptionFlag<string | undefined>;
15
- output: flags.IOptionFlag<string>;
16
- filename: flags.IOptionFlag<string | undefined>;
17
- respectServerFilename: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
11
+ format: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
+ module: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
13
+ output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
14
+ filename: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
15
+ respectServerFilename: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
18
16
  };
19
17
  getFormat(format: string): string;
20
18
  /**
@@ -24,13 +22,14 @@ export default class Translate extends CommandBase {
24
22
  * @param modules list of modules to download
25
23
  * @returns arhive as an byte array response stream
26
24
  */
27
- getTranslations(languages: string, format: string, modules: string | undefined): Promise<any>;
25
+ getTranslations(languages: string, format: string, modules: string | undefined): Promise<AxiosResponse<any, any>>;
28
26
  /**
29
27
  * Read from response stream and extract files into output directory.
30
28
  * @param content zip file or a stream
31
- * @param dest final destination to extract files
32
- * @returns void
33
- * @throws error message
29
+ * @param destinationDir final destination to extract files
30
+ * @param {string} [xmlFilename=false] XML filename
31
+ * @returns {Promise<void>} Void
32
+ * @throws Error message
34
33
  */
35
34
  extractFiles(content: any, destinationDir: string, xmlFilename?: string): Promise<any>;
36
35
  run(): Promise<void>;