@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.
- package/CHANGELOGS.md +12 -0
- package/README.md +0 -211
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +6 -0
- package/bin/run.cmd +1 -1
- package/bin/run.js +8 -0
- package/lib/command.base.d.ts +9 -5
- package/lib/command.base.jira.d.ts +7 -8
- package/lib/command.base.jira.js +26 -24
- package/lib/command.base.js +69 -57
- package/lib/commands/docker/update-image-version.d.ts +6 -9
- package/lib/commands/docker/update-image-version.js +35 -34
- package/lib/commands/doctor.d.ts +15 -5
- package/lib/commands/doctor.js +219 -186
- package/lib/commands/download/client.d.ts +10 -7
- package/lib/commands/download/client.js +60 -52
- package/lib/commands/download/identity-server.d.ts +9 -7
- package/lib/commands/download/identity-server.js +59 -53
- package/lib/commands/download/jmeter.d.ts +5 -5
- package/lib/commands/download/jmeter.js +54 -49
- package/lib/commands/download/keycloak-scim.d.ts +6 -6
- package/lib/commands/download/keycloak-scim.js +56 -51
- package/lib/commands/download/platform.d.ts +9 -7
- package/lib/commands/download/platform.js +59 -53
- package/lib/commands/download/scheduler.d.ts +9 -7
- package/lib/commands/download/scheduler.js +59 -53
- package/lib/commands/download/server.d.ts +9 -7
- package/lib/commands/download/server.js +59 -53
- package/lib/commands/download/signalr.d.ts +9 -7
- package/lib/commands/download/signalr.js +59 -53
- package/lib/commands/download/studio.d.ts +11 -9
- package/lib/commands/download/studio.js +92 -82
- package/lib/commands/gitlab/get-tag-pipeline.d.ts +11 -14
- package/lib/commands/gitlab/get-tag-pipeline.js +95 -92
- package/lib/commands/gitlab/next-nightly-tag.d.ts +10 -12
- package/lib/commands/gitlab/next-nightly-tag.js +96 -98
- package/lib/commands/jira/issue.d.ts +6 -8
- package/lib/commands/jira/issue.js +25 -23
- package/lib/commands/jira/labels.d.ts +9 -12
- package/lib/commands/jira/labels.js +52 -51
- package/lib/commands/log/add.d.ts +6 -8
- package/lib/commands/log/add.js +92 -87
- package/lib/commands/log/generate.d.ts +9 -10
- package/lib/commands/log/generate.js +112 -107
- package/lib/commands/log/validate.d.ts +2 -2
- package/lib/commands/log/validate.js +47 -43
- package/lib/commands/login.d.ts +9 -10
- package/lib/commands/login.js +101 -97
- package/lib/commands/npm/check-publish.d.ts +7 -8
- package/lib/commands/npm/check-publish.js +59 -54
- package/lib/commands/npm/dependency-update.d.ts +14 -12
- package/lib/commands/npm/dependency-update.js +94 -86
- package/lib/commands/npm/publish.d.ts +8 -9
- package/lib/commands/npm/publish.js +154 -140
- package/lib/commands/nuget/dependency-update.d.ts +15 -10
- package/lib/commands/nuget/dependency-update.js +60 -49
- package/lib/commands/sql.d.ts +24 -20
- package/lib/commands/sql.js +245 -226
- package/lib/commands/translate.d.ts +15 -16
- package/lib/commands/translate.js +109 -104
- package/lib/commands/version.d.ts +29 -19
- package/lib/commands/version.js +215 -190
- package/lib/config.js +3 -6
- package/lib/hooks/init/version-override.d.ts +2 -2
- package/lib/hooks/init/version-override.js +15 -13
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -4
- package/lib/lib/command.d.ts +2 -0
- package/lib/lib/command.js +65 -58
- package/lib/lib/gitlab.d.ts +8 -2
- package/lib/lib/gitlab.js +94 -82
- package/lib/lib/npm.d.ts +7 -3
- package/lib/lib/npm.js +72 -60
- package/lib/lib/npmrc.d.ts +5 -0
- package/lib/lib/npmrc.js +20 -13
- package/lib/lib/nuget.d.ts +2 -0
- package/lib/lib/nuget.js +20 -17
- package/lib/security/cache.js +31 -27
- package/lib/security/context.d.ts +2 -1
- package/lib/security/context.js +106 -103
- package/lib/types/changelog.types.js +1 -2
- package/lib/types/npm.types.d.ts +5 -5
- package/lib/types/npm.types.js +1 -2
- package/oclif.manifest.json +1212 -1
- package/package.json +50 -46
- package/bin/run +0 -5
- package/lib/commands/prepare-content.d.ts +0 -29
- package/lib/commands/prepare-content.js +0 -386
package/lib/commands/sql.js
CHANGED
|
@@ -1,311 +1,330 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
75
|
-
|
|
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
|
-
|
|
84
|
-
return
|
|
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 = '${
|
|
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 ${
|
|
99
|
+
alter table ${tableSchema}.${tableName} add ${columnName} ${columnType};
|
|
89
100
|
end
|
|
90
101
|
end`;
|
|
102
|
+
});
|
|
91
103
|
}
|
|
92
|
-
|
|
93
|
-
return
|
|
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) = '${
|
|
100
|
-
and upper(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) = ${
|
|
105
|
-
and upper(table_name) = '${
|
|
106
|
-
and upper(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 ${
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
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
|
|
157
|
-
|
|
158
|
-
|
|
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
|
}
|
|
174
|
+
else {
|
|
175
|
+
version = semver.parse(responses.version);
|
|
176
|
+
if (!version) {
|
|
177
|
+
this.error(`Version in incorrect format. Got version: '${responses.version}'`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
this.warn(`${version === null || version === void 0 ? void 0 : version.version} version will be used.`);
|
|
160
181
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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 for extending the db columns
|
|
185
|
-
if (scriptType === 'Extend') {
|
|
186
|
-
const arrayOfMissingParameters = await this.checkExtendParameters();
|
|
187
|
-
if (arrayOfMissingParameters.length !== 0) {
|
|
188
|
-
this.error(`The script type Extend requires the following parameters to be specified: ${arrayOfMissingParameters.join(', ')}`);
|
|
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;
|
|
189
193
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
scriptFolder = path.resolve(scriptFolder, this._moduleTypes[scriptModule]);
|
|
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(', ')}`);
|
|
207
210
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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);
|
|
211
234
|
}
|
|
212
|
-
scriptFolderLocations.push(scriptFolder);
|
|
213
235
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
this.log(`${chalk_1.default.yellow(scriptsFilePath)}`);
|
|
241
|
-
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
|
+
}
|
|
242
262
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
+
}
|
|
249
269
|
}
|
|
250
|
-
}
|
|
270
|
+
});
|
|
251
271
|
}
|
|
252
272
|
}
|
|
253
|
-
exports.default = Sql;
|
|
254
273
|
Sql.description = 'creates a new database script';
|
|
255
274
|
Sql.usage = 'sql <type> <module> [flags]';
|
|
256
275
|
Sql.examples = [
|
|
257
276
|
`$ ops sql schema `,
|
|
258
277
|
`$ ops sql data shared --layer basic`,
|
|
259
278
|
`$ ops sql data shared --major`,
|
|
260
|
-
`$ ops sql data shared --offline --description "this is script description"
|
|
279
|
+
`$ ops sql data shared --offline --description "this is script description"`,
|
|
261
280
|
];
|
|
262
|
-
Sql.args =
|
|
263
|
-
{
|
|
264
|
-
name: 'type',
|
|
281
|
+
Sql.args = {
|
|
282
|
+
type: Args.string({
|
|
265
283
|
description: 'Type of database scripts',
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
284
|
+
required: true,
|
|
285
|
+
options: ['Schema', 'Data', 'Migration', 'Extend'],
|
|
286
|
+
}),
|
|
287
|
+
module: Args.string({
|
|
270
288
|
description: 'Module of data database scripts',
|
|
271
|
-
options: ['acc', 'claims', 'core', 'pas', 'reins', 'shared']
|
|
272
|
-
}
|
|
273
|
-
|
|
289
|
+
options: ['acc', 'claims', 'core', 'pas', 'reins', 'shared'],
|
|
290
|
+
}),
|
|
291
|
+
};
|
|
274
292
|
Sql.flags = {
|
|
275
|
-
version:
|
|
293
|
+
version: Flags.string({
|
|
276
294
|
char: 'v',
|
|
277
|
-
description: 'version for which you\'re generating database script'
|
|
295
|
+
description: 'version for which you\'re generating database script',
|
|
278
296
|
}),
|
|
279
|
-
layer:
|
|
297
|
+
layer: Flags.string({
|
|
280
298
|
char: 'l',
|
|
281
|
-
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',
|
|
282
300
|
}),
|
|
283
|
-
offline:
|
|
301
|
+
offline: Flags.boolean({
|
|
284
302
|
char: 'o',
|
|
285
303
|
description: 'generate database script with timestamp',
|
|
286
|
-
default: false
|
|
304
|
+
default: false,
|
|
287
305
|
}),
|
|
288
|
-
description:
|
|
306
|
+
description: Flags.string({
|
|
289
307
|
char: 'd',
|
|
290
308
|
description: 'description of script to be used in filename for offline',
|
|
291
|
-
dependsOn: ['offline']
|
|
309
|
+
dependsOn: ['offline'],
|
|
292
310
|
}),
|
|
293
|
-
major:
|
|
311
|
+
major: Flags.boolean({
|
|
294
312
|
char: 'm',
|
|
295
313
|
description: 'generate script for major version',
|
|
296
|
-
default: false
|
|
314
|
+
default: false,
|
|
297
315
|
}),
|
|
298
316
|
// Used only for generating scripts to extend existing db tables with new column
|
|
299
|
-
'table-schema':
|
|
317
|
+
'table-schema': Flags.string({
|
|
300
318
|
description: 'name of the existing table schema',
|
|
301
319
|
}),
|
|
302
|
-
'table-name':
|
|
320
|
+
'table-name': Flags.string({
|
|
303
321
|
description: 'name of the existing table',
|
|
304
322
|
}),
|
|
305
|
-
'column-name':
|
|
323
|
+
'column-name': Flags.string({
|
|
306
324
|
description: 'name the new column to be added',
|
|
307
325
|
}),
|
|
308
|
-
'column-type':
|
|
326
|
+
'column-type': Flags.string({
|
|
309
327
|
description: 'type of the new column to be added',
|
|
310
328
|
}),
|
|
311
329
|
};
|
|
330
|
+
export default Sql;
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
9
|
-
|
|
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:
|
|
14
|
-
module:
|
|
15
|
-
output:
|
|
16
|
-
filename:
|
|
17
|
-
respectServerFilename: import("@oclif/
|
|
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
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
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>;
|