@adinsure-ops/ops-cli 5.4.2-rc1 → 5.5.0-rc1
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/README.md +140 -2
- package/bin/run.js +2 -6
- package/lib/command.base.d.ts +7 -1
- package/lib/command.base.jira.d.ts +23 -5
- package/lib/command.base.jira.js +47 -12
- package/lib/command.base.js +37 -8
- package/lib/command.download.d.ts +11 -0
- package/lib/command.download.js +27 -0
- package/lib/commands/config/get.d.ts +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.d.ts +2 -2
- package/lib/commands/config/set.js +2 -2
- package/lib/commands/config/unset.d.ts +1 -1
- package/lib/commands/docker/update-image-version.d.ts +31 -3
- package/lib/commands/docker/update-image-version.js +112 -6
- package/lib/commands/doctor.d.ts +1 -1
- package/lib/commands/download/client.d.ts +7 -20
- package/lib/commands/download/client.js +12 -47
- package/lib/commands/download/identity-server.d.ts +7 -20
- package/lib/commands/download/identity-server.js +12 -47
- package/lib/commands/download/jmeter.d.ts +3 -3
- package/lib/commands/download/jmeter.js +9 -11
- package/lib/commands/download/keycloak-scim.d.ts +4 -4
- package/lib/commands/download/keycloak-scim.js +9 -11
- package/lib/commands/download/platform.d.ts +7 -20
- package/lib/commands/download/platform.js +12 -47
- package/lib/commands/download/scheduler.d.ts +7 -20
- package/lib/commands/download/scheduler.js +12 -47
- package/lib/commands/download/server.d.ts +7 -20
- package/lib/commands/download/server.js +12 -47
- package/lib/commands/download/signalr.d.ts +7 -20
- package/lib/commands/download/signalr.js +12 -47
- package/lib/commands/download/studio.d.ts +12 -24
- package/lib/commands/download/studio.js +14 -48
- package/lib/commands/gitlab/get-tag-pipeline.d.ts +7 -7
- package/lib/commands/gitlab/get-tag-pipeline.js +5 -5
- package/lib/commands/gitlab/next-nightly-tag.d.ts +7 -7
- package/lib/commands/gitlab/next-nightly-tag.js +6 -6
- package/lib/commands/jira/issue.d.ts +4 -4
- package/lib/commands/jira/issue.js +2 -2
- package/lib/commands/jira/labels.d.ts +8 -9
- package/lib/commands/jira/labels.js +11 -10
- package/lib/commands/log/add.d.ts +10 -5
- package/lib/commands/log/add.js +42 -13
- package/lib/commands/log/generate.d.ts +6 -6
- package/lib/commands/log/generate.js +16 -8
- package/lib/commands/log/validate.js +2 -2
- package/lib/commands/login.d.ts +25 -5
- package/lib/commands/login.js +162 -40
- package/lib/commands/login.ru.d.ts +2 -2
- package/lib/commands/login.ru.js +1 -1
- package/lib/commands/npm/check-publish.d.ts +4 -4
- package/lib/commands/npm/check-publish.js +1 -1
- package/lib/commands/npm/dependency-update.d.ts +17 -4
- package/lib/commands/npm/dependency-update.js +64 -41
- package/lib/commands/npm/publish.d.ts +5 -5
- package/lib/commands/npm/publish.js +2 -2
- package/lib/commands/nuget/dependency-update.d.ts +3 -3
- package/lib/commands/prepare-content.d.ts +3 -3
- package/lib/commands/prepare-content.js +24 -41
- package/lib/commands/sql.d.ts +17 -17
- package/lib/commands/sql.js +23 -27
- package/lib/commands/translate.d.ts +8 -8
- package/lib/commands/translate.js +10 -8
- package/lib/commands/version.d.ts +10 -10
- package/lib/commands/version.js +6 -7
- package/lib/lib/command.d.ts +5 -3
- package/lib/lib/command.js +44 -44
- package/lib/lib/config.js +1 -1
- package/lib/lib/gitlab.d.ts +3 -1
- package/lib/lib/gitlab.js +13 -7
- package/lib/lib/http.d.ts +37 -0
- package/lib/lib/http.js +278 -0
- package/lib/lib/npm.d.ts +7 -4
- package/lib/lib/npm.js +15 -6
- package/lib/lib/npmrc.js +3 -3
- package/lib/lib/yarnrc.js +3 -3
- package/lib/security/cache.js +1 -1
- package/lib/security/context.d.ts +10 -8
- package/lib/security/context.js +49 -64
- package/oclif.manifest.json +533 -532
- package/package.json +71 -62
|
@@ -2,7 +2,8 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
import { Flags, ux } from '@oclif/core';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
|
-
import path from 'path';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { pathToFileURL } from 'node:url';
|
|
6
7
|
import CommandBase from '../command.base.js';
|
|
7
8
|
class CopyTransformation {
|
|
8
9
|
constructor(srcPath, dstPath) {
|
|
@@ -19,13 +20,13 @@ class CopyTransformation {
|
|
|
19
20
|
const error = error_.code === 'ENOENT' ? new Error(`${this.name}: source file does not exist <${this.srcPath}>`) : new Error(`${this.name}: ${error_} <${this.srcPath}>`);
|
|
20
21
|
throw error;
|
|
21
22
|
}
|
|
22
|
-
ux.
|
|
23
|
+
ux.stdout(`Copying from ${this.srcPath} to ${this.dstPath}`);
|
|
23
24
|
try {
|
|
24
25
|
fs.copySync(this.srcPath, this.dstPath, { overwrite: true });
|
|
25
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
27
|
}
|
|
27
28
|
catch (error) {
|
|
28
|
-
throw new Error(`${this.name}: ${error} <${this.srcPath}
|
|
29
|
+
throw new Error(`${this.name}: ${error} <${this.srcPath}>`, { cause: error });
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -45,12 +46,12 @@ class JavascriptTransformation {
|
|
|
45
46
|
}
|
|
46
47
|
catch (error) {
|
|
47
48
|
if (error.code === 'ERR_MODULE_NOT_FOUND') {
|
|
48
|
-
throw new Error(`${this.name}: module file ${this.jsFile} not found <${this.srcPath}
|
|
49
|
+
throw new Error(`${this.name}: module file ${this.jsFile} not found <${this.srcPath}>`, { cause: error });
|
|
49
50
|
}
|
|
50
51
|
else if (error instanceof SyntaxError) {
|
|
51
|
-
throw new SyntaxError(`${this.name}: ${error.message} in '${this.jsFile}' <${this.srcPath}
|
|
52
|
+
throw new SyntaxError(`${this.name}: ${error.message} in '${this.jsFile}' <${this.srcPath}>`, { cause: error });
|
|
52
53
|
}
|
|
53
|
-
throw new Error(`${this.name}: ${error} <${this.srcPath}
|
|
54
|
+
throw new Error(`${this.name}: ${error} <${this.srcPath}>`, { cause: error });
|
|
54
55
|
}
|
|
55
56
|
});
|
|
56
57
|
}
|
|
@@ -68,7 +69,7 @@ class JavascriptTransformation {
|
|
|
68
69
|
catch (error) {
|
|
69
70
|
if (error instanceof TypeError && error.message.search(`/.*must return.*/`) !== -1) {
|
|
70
71
|
console.log(error.message.search(`/.*must return.*/`));
|
|
71
|
-
throw new Error(`${this.name}: invalid function in ${this.jsFile} <${this.srcPath}
|
|
72
|
+
throw new Error(`${this.name}: invalid function in ${this.jsFile} <${this.srcPath}>`, { cause: error });
|
|
72
73
|
}
|
|
73
74
|
/*
|
|
74
75
|
Rethrow anything errors that were thrown in the above try block
|
|
@@ -76,7 +77,7 @@ class JavascriptTransformation {
|
|
|
76
77
|
if (error.message && error.message.search(`${this.name}`.length > 0)) {
|
|
77
78
|
throw error;
|
|
78
79
|
}
|
|
79
|
-
throw new Error(`${this.name}: ${error} <${this.srcPath}
|
|
80
|
+
throw new Error(`${this.name}: ${error} <${this.srcPath}>`, { cause: error });
|
|
80
81
|
}
|
|
81
82
|
});
|
|
82
83
|
}
|
|
@@ -90,14 +91,14 @@ class JavascriptTransformation {
|
|
|
90
91
|
catch (error) {
|
|
91
92
|
if (error.code === 'ENOENT') {
|
|
92
93
|
const errMsg = `${this.name}: source does not exist, relying on transformation to find proper source file <${this.srcPath}>`;
|
|
93
|
-
ux.
|
|
94
|
+
ux.stdout(`${chalk.yellow(errMsg)}`);
|
|
94
95
|
}
|
|
95
96
|
else {
|
|
96
|
-
throw new Error(`${this.name}: ${error} <${this.srcPath}
|
|
97
|
+
throw new Error(`${this.name}: ${error} <${this.srcPath}>`, { cause: error });
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
const msg = `Transforming from ${this.srcPath} to ${this.dstPath} using ${this.jsFile}`;
|
|
100
|
-
ux.
|
|
101
|
+
ux.stdout(`${chalk.yellow(msg)}`);
|
|
101
102
|
// eslint-disable-next-line no-useless-catch
|
|
102
103
|
try {
|
|
103
104
|
// Import transformation function
|
|
@@ -121,17 +122,17 @@ class RemovalTransformation {
|
|
|
121
122
|
transform() {
|
|
122
123
|
try {
|
|
123
124
|
fs.accessSync(this.srcPath, fs.constants.W_OK);
|
|
124
|
-
ux.
|
|
125
|
+
ux.stdout(`Removing ${this.srcPath}.`);
|
|
125
126
|
fs.removeSync(this.srcPath);
|
|
126
127
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
127
128
|
}
|
|
128
129
|
catch (error) {
|
|
129
130
|
if (error.code === 'ENOENT') {
|
|
130
131
|
const errMsg = `${this.name}: target does not exist, skipping removal <${this.srcPath}>`;
|
|
131
|
-
ux.
|
|
132
|
+
ux.stdout(`${chalk.yellow(errMsg)}`);
|
|
132
133
|
}
|
|
133
134
|
else {
|
|
134
|
-
throw new Error(`${this.name}: ${error} <${this.srcPath}
|
|
135
|
+
throw new Error(`${this.name}: ${error} <${this.srcPath}>`, { cause: error });
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
}
|
|
@@ -165,9 +166,9 @@ class PrepareContent extends CommandBase {
|
|
|
165
166
|
catch (error) {
|
|
166
167
|
if (error.code === 'ENOENT') {
|
|
167
168
|
const errMsg = `.opsprepare file not found in ${path.resolve(sourceDirectory)}`;
|
|
168
|
-
throw new Error(errMsg);
|
|
169
|
+
throw new Error(errMsg, { cause: error });
|
|
169
170
|
}
|
|
170
|
-
throw new Error(error.message);
|
|
171
|
+
throw new Error(error.message, { cause: error });
|
|
171
172
|
}
|
|
172
173
|
const lines = fileContent.split(/\r?\n/).filter(line => line.length > 0);
|
|
173
174
|
const lineParse = lines.map(line => this.parseDotfileLine(line.trim(), sourceDirectory));
|
|
@@ -199,15 +200,11 @@ class PrepareContent extends CommandBase {
|
|
|
199
200
|
return new CopyTransformation(lineData.source, tPath);
|
|
200
201
|
}
|
|
201
202
|
case 'js': {
|
|
202
|
-
|
|
203
|
-
to make sure everything was matched and is defined
|
|
204
|
-
*/
|
|
205
|
-
// Parse transformation data
|
|
206
|
-
const mData = lineData.transformData.match('^{js:(.+?).js}$');
|
|
203
|
+
const mData = lineData.transformData.match(/^\{js:(.+\.m?js)\}$/);
|
|
207
204
|
if (!mData) {
|
|
208
205
|
throw new SyntaxError(`<${PrepareContent.dotfile}> syntax '${lineData.transformData}' is invalid for 'js' transformation type`);
|
|
209
206
|
}
|
|
210
|
-
const jsFile =
|
|
207
|
+
const jsFile = pathToFileURL(path.resolve(path.join(baseSourcedir, mData[1]))).href;
|
|
211
208
|
// File path absolute
|
|
212
209
|
const filePath = path.resolve(lineData.source);
|
|
213
210
|
return new JavascriptTransformation(filePath, targetPath, jsFile);
|
|
@@ -239,7 +236,7 @@ class PrepareContent extends CommandBase {
|
|
|
239
236
|
runTransformations(transformations) {
|
|
240
237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
241
238
|
const copyTransformList = [];
|
|
242
|
-
const
|
|
239
|
+
const moduleTransformList = [];
|
|
243
240
|
const excludeList = [];
|
|
244
241
|
// Sort transformation into two lists
|
|
245
242
|
for (const t of transformations) {
|
|
@@ -250,31 +247,17 @@ class PrepareContent extends CommandBase {
|
|
|
250
247
|
excludeList.push(t);
|
|
251
248
|
}
|
|
252
249
|
else {
|
|
253
|
-
|
|
250
|
+
moduleTransformList.push(t);
|
|
254
251
|
}
|
|
255
252
|
}
|
|
256
|
-
const t = (transformation) => __awaiter(this, void 0, void 0, function* () {
|
|
257
|
-
try {
|
|
258
|
-
transformation.transform();
|
|
259
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
260
|
-
}
|
|
261
|
-
catch (error) {
|
|
262
|
-
throw Promise.reject(error.message).catch(error_ => {
|
|
263
|
-
this.log(`${chalk.redBright('ERROR: ' + error_)}`);
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
const doCopyTransform = copyTransformList.map(t);
|
|
268
|
-
const doModuleTransform = modlueTransformList.map(t);
|
|
269
|
-
const doExclude = excludeList.map(t);
|
|
270
253
|
/* Copy first, then transform and finally remove files. This should
|
|
271
254
|
ensure that transformations can overwrite previous copies. Removals
|
|
272
255
|
can still erase transformations though. If needed, we can remove
|
|
273
256
|
before transforming.
|
|
274
257
|
*/
|
|
275
|
-
yield Promise.all(
|
|
276
|
-
yield Promise.all(
|
|
277
|
-
yield Promise.all(
|
|
258
|
+
yield Promise.all(copyTransformList.map(transformation => transformation.transform()));
|
|
259
|
+
yield Promise.all(moduleTransformList.map(transformation => transformation.transform()));
|
|
260
|
+
yield Promise.all(excludeList.map(transformation => transformation.transform()));
|
|
278
261
|
});
|
|
279
262
|
}
|
|
280
263
|
/*
|
package/lib/commands/sql.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse } from '../lib/http.js';
|
|
2
2
|
import CommandBase from '../command.base.js';
|
|
3
3
|
export default class Sql extends CommandBase<typeof Sql> {
|
|
4
4
|
static description: string;
|
|
5
5
|
static usage: string;
|
|
6
6
|
static examples: string[];
|
|
7
7
|
static args: {
|
|
8
|
-
type: import("@oclif/core/
|
|
9
|
-
module: import("@oclif/core/
|
|
8
|
+
type: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
9
|
+
module: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
10
10
|
};
|
|
11
11
|
static flags: {
|
|
12
|
-
version: import("@oclif/core/
|
|
13
|
-
layer: import("@oclif/core/
|
|
14
|
-
offline: import("@oclif/core/
|
|
15
|
-
description: import("@oclif/core/
|
|
16
|
-
major: import("@oclif/core/
|
|
17
|
-
'table-schema': import("@oclif/core/
|
|
18
|
-
'table-name': import("@oclif/core/
|
|
19
|
-
'column-name': import("@oclif/core/
|
|
20
|
-
'column-type': import("@oclif/core/
|
|
21
|
-
dwh: import("@oclif/core/
|
|
12
|
+
version: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
layer: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
offline: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
major: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
'table-schema': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'table-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'column-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
'column-type': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
dwh: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
22
22
|
};
|
|
23
23
|
private readonly _moduleTypes;
|
|
24
24
|
private _dbmsTypes;
|
|
25
25
|
/**
|
|
26
|
-
* Get unique
|
|
27
|
-
* @param {string} version The version
|
|
28
|
-
* @returns {Promise<
|
|
26
|
+
* Get the next unique script ID for the specified version
|
|
27
|
+
* @param {string} version The AdInsure version the script belongs to
|
|
28
|
+
* @returns {Promise<HttpResponse<string>>}
|
|
29
29
|
*/
|
|
30
|
-
getScriptId(version: string): Promise<
|
|
30
|
+
getScriptId(version: string): Promise<HttpResponse<string>>;
|
|
31
31
|
/**
|
|
32
32
|
* Get unique scriptID by specified version
|
|
33
33
|
* @param {string} version Specified version
|
package/lib/commands/sql.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { Args, Flags } from '@oclif/core';
|
|
3
|
-
import axios from 'axios';
|
|
4
3
|
import chalk from 'chalk';
|
|
5
4
|
import fs from 'fs-extra';
|
|
6
5
|
import inquirer from 'inquirer';
|
|
7
|
-
import
|
|
8
|
-
import path from 'path';
|
|
6
|
+
import { snakeCase } from 'lodash-es';
|
|
7
|
+
import path from 'node:path';
|
|
9
8
|
import semver from 'semver';
|
|
10
9
|
import CommandBase from '../command.base.js';
|
|
11
10
|
import { capitalizeFirstLetter } from '../lib/helper.js';
|
|
@@ -40,14 +39,14 @@ class Sql extends CommandBase {
|
|
|
40
39
|
];
|
|
41
40
|
}
|
|
42
41
|
/**
|
|
43
|
-
* Get unique
|
|
44
|
-
* @param {string} version The version
|
|
45
|
-
* @returns {Promise<
|
|
42
|
+
* Get the next unique script ID for the specified version
|
|
43
|
+
* @param {string} version The AdInsure version the script belongs to
|
|
44
|
+
* @returns {Promise<HttpResponse<string>>}
|
|
46
45
|
*/
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
46
|
getScriptId(version) {
|
|
49
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
return
|
|
48
|
+
return this.http.getJson(`https://ops.adinsure.com/api/script/next`, {
|
|
49
|
+
params: { version },
|
|
51
50
|
headers: {
|
|
52
51
|
Authorization: 'Bearer ' + (yield this.security.getToken()),
|
|
53
52
|
},
|
|
@@ -77,7 +76,7 @@ class Sql extends CommandBase {
|
|
|
77
76
|
'.' + ('00' + versionSplit[2]).slice(-3) +
|
|
78
77
|
'_' + timestamp;
|
|
79
78
|
if (description) {
|
|
80
|
-
scriptId = scriptId + '_' +
|
|
79
|
+
scriptId = scriptId + '_' + snakeCase(description).slice(0, 100);
|
|
81
80
|
}
|
|
82
81
|
return scriptId;
|
|
83
82
|
});
|
|
@@ -121,18 +120,18 @@ end`;
|
|
|
121
120
|
v_column_exists number := 0;
|
|
122
121
|
v_table_exists number := 0;
|
|
123
122
|
BEGIN
|
|
124
|
-
|
|
125
|
-
from
|
|
126
|
-
where upper(OWNER) = '${tableSchema}'
|
|
127
|
-
and upper(
|
|
123
|
+
select count(*) into v_table_exists
|
|
124
|
+
from ALL_TABLES
|
|
125
|
+
where upper(OWNER) = upper('${tableSchema}')
|
|
126
|
+
and upper(TABLE_NAME) = upper('${tableName}');
|
|
128
127
|
if (v_table_exists > 0) then
|
|
129
128
|
select count(*) into v_column_exists
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
and upper(
|
|
133
|
-
and upper(
|
|
129
|
+
from ALL_TAB_COLS
|
|
130
|
+
where upper(OWNER) = upper('${tableSchema}')
|
|
131
|
+
and upper(TABLE_NAME) = upper('${tableName}')
|
|
132
|
+
and upper(COLUMN_NAME) = upper('${columnName}');
|
|
134
133
|
if (v_column_exists = 0) then
|
|
135
|
-
|
|
134
|
+
execute immediate 'alter table ${tableSchema}.${tableName} add ${columnName} ${columnType}';
|
|
136
135
|
end if;
|
|
137
136
|
end if;
|
|
138
137
|
end;`;
|
|
@@ -179,12 +178,11 @@ ADD COLUMN IF NOT EXISTS ${columnName} ${columnType};
|
|
|
179
178
|
this.error(`Version in incorrect format. Got version: '${fullVersion}'`);
|
|
180
179
|
}
|
|
181
180
|
else if (flags.major) {
|
|
182
|
-
version = semver.
|
|
183
|
-
this.
|
|
181
|
+
version = new semver.SemVer(`${version.major}.0.0`);
|
|
182
|
+
this.warn(`--major flag used. Generating script for version '${version.version}'.`);
|
|
184
183
|
}
|
|
185
184
|
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) {
|
|
186
185
|
this.warn(`Using prerelease version is not allowed. Got version: '${fullVersion}'.`);
|
|
187
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
188
186
|
const responses = yield inquirer.prompt([{
|
|
189
187
|
name: 'version',
|
|
190
188
|
message: 'write version you want to use or write "yes" to revert to latest latest patch.',
|
|
@@ -207,23 +205,21 @@ ADD COLUMN IF NOT EXISTS ${columnName} ${columnType};
|
|
|
207
205
|
// Validation of input parameters
|
|
208
206
|
let scriptType = args.type;
|
|
209
207
|
if (!scriptType) {
|
|
210
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
211
208
|
const responses = yield inquirer.prompt([{
|
|
212
209
|
name: 'type',
|
|
213
210
|
message: 'select a sql type',
|
|
214
|
-
type: '
|
|
211
|
+
type: 'select',
|
|
215
212
|
choices: [{ name: 'Schema' }, { name: 'Data' }, { name: 'Migration' }, { name: 'Extend' }],
|
|
216
213
|
}]);
|
|
217
214
|
scriptType = responses.type;
|
|
218
215
|
}
|
|
219
216
|
scriptType = scriptType === 'Migration' ? scriptType.toLowerCase() : capitalizeFirstLetter(scriptType);
|
|
220
217
|
let scriptModule = args.module;
|
|
221
|
-
if (!scriptModule && scriptType === '
|
|
222
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
218
|
+
if (!scriptModule && scriptType === 'Data') {
|
|
223
219
|
const responses = yield inquirer.prompt([{
|
|
224
220
|
name: 'module',
|
|
225
221
|
message: 'select a sql module for data type',
|
|
226
|
-
type: '
|
|
222
|
+
type: 'select',
|
|
227
223
|
choices: [{ name: 'acc' }, { name: 'claims' }, { name: 'core' }, { name: 'pas' }, { name: 'reins' }, { name: 'shared' }],
|
|
228
224
|
}]);
|
|
229
225
|
scriptModule = responses.module;
|
|
@@ -261,7 +257,7 @@ ADD COLUMN IF NOT EXISTS ${columnName} ${columnType};
|
|
|
261
257
|
}
|
|
262
258
|
// Validation of parameters succeed. Requesting new SQL script ID and creating file.
|
|
263
259
|
this.log(`Requesting new id for '${version}'`);
|
|
264
|
-
let scriptId
|
|
260
|
+
let scriptId;
|
|
265
261
|
if (flags.offline) {
|
|
266
262
|
scriptId = yield this.getOfflineScriptId(version.version, flags.description);
|
|
267
263
|
this.log(`Generation script: '${chalk.green(scriptId + '.sql')}'`);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse } from '../lib/http.js';
|
|
2
2
|
import CommandBase from '../command.base.js';
|
|
3
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
|
-
language: import("@oclif/core/
|
|
8
|
+
language: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
9
9
|
};
|
|
10
10
|
static flags: {
|
|
11
|
-
format: import("@oclif/core/
|
|
12
|
-
module: import("@oclif/core/
|
|
13
|
-
output: import("@oclif/core/
|
|
14
|
-
filename: import("@oclif/core/
|
|
15
|
-
respectServerFilename: import("@oclif/core/
|
|
11
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
module: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
filename: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
respectServerFilename: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
16
|
};
|
|
17
17
|
getFormat(format: string): string;
|
|
18
18
|
/**
|
|
@@ -22,7 +22,7 @@ export default class Translate extends CommandBase<typeof Translate> {
|
|
|
22
22
|
* @param modules list of modules to download
|
|
23
23
|
* @returns arhive as an byte array response stream
|
|
24
24
|
*/
|
|
25
|
-
getTranslations(languages: string, format: string, modules: string | undefined): Promise<
|
|
25
|
+
getTranslations(languages: string, format: string, modules: string | undefined): Promise<HttpResponse<Buffer>>;
|
|
26
26
|
/**
|
|
27
27
|
* Read from response stream and extract files into output directory.
|
|
28
28
|
* @param content zip file or a stream
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { Args, Flags, ux } from '@oclif/core';
|
|
3
|
-
import axios from 'axios';
|
|
4
3
|
import chalk from 'chalk';
|
|
5
4
|
import fs from 'fs-extra';
|
|
6
5
|
import JSZip from 'jszip';
|
|
7
|
-
import path from 'path';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { HttpError } from '../lib/http.js';
|
|
8
8
|
import CommandBase from '../command.base.js';
|
|
9
9
|
class Translate extends CommandBase {
|
|
10
10
|
getFormat(format) {
|
|
@@ -23,28 +23,30 @@ class Translate extends CommandBase {
|
|
|
23
23
|
* @param modules list of modules to download
|
|
24
24
|
* @returns arhive as an byte array response stream
|
|
25
25
|
*/
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
26
|
getTranslations(languages, format, modules) {
|
|
28
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
var _a;
|
|
29
29
|
const requestOptions = {
|
|
30
30
|
headers: {
|
|
31
31
|
Authorization: 'Bearer ' + (yield this.security.getToken()),
|
|
32
32
|
'Content-Type': this.getFormat(format),
|
|
33
33
|
},
|
|
34
|
-
responseType: 'arraybuffer',
|
|
35
34
|
params: Object.assign({ languages }, (modules && { modules })),
|
|
36
35
|
};
|
|
37
36
|
try {
|
|
38
|
-
return (yield
|
|
37
|
+
return (yield this.http.getBuffer(`https://dictionary.adinsure.com/api/Translations`, requestOptions));
|
|
39
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
39
|
}
|
|
41
40
|
catch (error) {
|
|
42
41
|
let errorMessage;
|
|
43
42
|
try {
|
|
44
|
-
const
|
|
45
|
-
|
|
43
|
+
const body = error instanceof HttpError ? error.data : undefined;
|
|
44
|
+
const exceptionMessage = (_a = (typeof body === 'string' ? JSON.parse(body) : body)) === null || _a === void 0 ? void 0 : _a.ExceptionMessage;
|
|
45
|
+
if (!exceptionMessage)
|
|
46
|
+
throw error;
|
|
47
|
+
errorMessage = `An error has occurred: ${exceptionMessage}`;
|
|
46
48
|
}
|
|
47
|
-
catch (
|
|
49
|
+
catch (_b) {
|
|
48
50
|
errorMessage = error.message;
|
|
49
51
|
}
|
|
50
52
|
this.log(chalk.red(errorMessage));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios';
|
|
2
1
|
import semver from 'semver';
|
|
2
|
+
import { HttpResponse } from '../lib/http.js';
|
|
3
3
|
import CommandBase from '../command.base.js';
|
|
4
4
|
type ReleaseType = semver.ReleaseType | 'new';
|
|
5
5
|
export default class Version extends CommandBase<typeof Version> {
|
|
@@ -7,16 +7,16 @@ export default class Version extends CommandBase<typeof Version> {
|
|
|
7
7
|
static usage: string;
|
|
8
8
|
static examples: string[];
|
|
9
9
|
static args: {
|
|
10
|
-
type: import("@oclif/core/
|
|
10
|
+
type: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
11
11
|
};
|
|
12
12
|
static flags: {
|
|
13
|
-
independent: import("@oclif/core/
|
|
14
|
-
version: import("@oclif/core/
|
|
15
|
-
'script-prefix': import("@oclif/core/
|
|
16
|
-
'no-deps': import("@oclif/core/
|
|
17
|
-
'no-script': import("@oclif/core/
|
|
18
|
-
'only-npm-packages': import("@oclif/core/
|
|
19
|
-
'exclude-dir': import("@oclif/core/
|
|
13
|
+
independent: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
version: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'script-prefix': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'no-deps': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
'no-script': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
'only-npm-packages': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'exclude-dir': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
22
|
* Update NPM packages with wsrun
|
|
@@ -38,7 +38,7 @@ export default class Version extends CommandBase<typeof Version> {
|
|
|
38
38
|
* @returns {void}
|
|
39
39
|
*/
|
|
40
40
|
updateDependencies(version: string, updatedPackages: Array<string>): Promise<void>;
|
|
41
|
-
insertScriptRequest(token: string, version: string, prefix: string): Promise<
|
|
41
|
+
insertScriptRequest(token: string, version: string, prefix: string): Promise<HttpResponse<unknown>>;
|
|
42
42
|
insertScript(token: string, version: string, prefix: string, skip?: boolean): Promise<void>;
|
|
43
43
|
/**
|
|
44
44
|
* Check if version has valid prerelease as 'rc' or '201910' (year month)
|
package/lib/commands/version.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { Args, Flags, ux } from '@oclif/core';
|
|
3
|
-
import axios from 'axios';
|
|
4
3
|
import chalk from 'chalk';
|
|
5
4
|
import fs from 'fs-extra';
|
|
6
5
|
import { globby } from 'globby';
|
|
7
6
|
import moment from 'moment';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import replaceInFile from 'replace-in-file';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { replaceInFile } from 'replace-in-file';
|
|
10
9
|
import semver from 'semver';
|
|
10
|
+
import { HttpError } from '../lib/http.js';
|
|
11
11
|
import CommandBase from '../command.base.js';
|
|
12
12
|
class Version extends CommandBase {
|
|
13
13
|
/**
|
|
@@ -107,10 +107,9 @@ class Version extends CommandBase {
|
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
110
|
insertScriptRequest(token, version, prefix) {
|
|
112
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
return
|
|
112
|
+
return this.http.postJson(`https://ops.adinsure.com/api/script`, { version, prefix }, {
|
|
114
113
|
headers: {
|
|
115
114
|
Authorization: 'Bearer ' + token,
|
|
116
115
|
'Content-Type': 'application/json',
|
|
@@ -127,7 +126,7 @@ class Version extends CommandBase {
|
|
|
127
126
|
else if (token) {
|
|
128
127
|
yield this.insertScriptRequest(token, version, prefix)
|
|
129
128
|
.catch((error) => {
|
|
130
|
-
switch (error.
|
|
129
|
+
switch (error instanceof HttpError ? error.status : undefined) {
|
|
131
130
|
case 401: {
|
|
132
131
|
this.error(`${chalk.red('You don\'t have permissions. If this was intentional command, please contact Operations for permissions, do git reset and rerun command.')}`);
|
|
133
132
|
}
|
|
@@ -190,7 +189,7 @@ class Version extends CommandBase {
|
|
|
190
189
|
if (!this.validateOptions(args, flags)) {
|
|
191
190
|
return;
|
|
192
191
|
}
|
|
193
|
-
let newVersion
|
|
192
|
+
let newVersion;
|
|
194
193
|
if (args.type === 'new' && flags.version) {
|
|
195
194
|
this.log(`Using 'new' command. VERSION file ignored.`);
|
|
196
195
|
newVersion = semver.valid(flags.version);
|
package/lib/lib/command.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export default class ChildProcessCommand {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
3
|
+
* Run a command without a shell and collect its output.
|
|
4
|
+
* On Windows the command is started through `cmd /c` so that `.cmd` shims such as `yarn` and `code` are found.
|
|
5
|
+
* @param cmd Command and its arguments
|
|
6
|
+
* @returns {Promise<{ data: string, error: string }>} stdout and stderr of the command
|
|
6
7
|
*/
|
|
7
8
|
runCommand(cmd: string[]): Promise<{
|
|
8
9
|
data: string;
|
|
9
10
|
error: string;
|
|
10
11
|
}>;
|
|
12
|
+
private readStream;
|
|
11
13
|
}
|