@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.
- package/CHANGELOGS.md +55 -0
- package/LICENSE +1 -0
- package/README.md +576 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/lib/command.base.d.ts +17 -0
- package/lib/command.base.jira.d.ts +11 -0
- package/lib/command.base.jira.js +37 -0
- package/lib/command.base.js +73 -0
- package/lib/commands/doctor.d.ts +54 -0
- package/lib/commands/doctor.js +311 -0
- package/lib/commands/download/client.d.ts +18 -0
- package/lib/commands/download/client.js +72 -0
- package/lib/commands/download/identity-server.d.ts +18 -0
- package/lib/commands/download/identity-server.js +72 -0
- package/lib/commands/download/platform.d.ts +18 -0
- package/lib/commands/download/platform.js +72 -0
- package/lib/commands/download/scheduler.d.ts +18 -0
- package/lib/commands/download/scheduler.js +72 -0
- package/lib/commands/download/server.d.ts +18 -0
- package/lib/commands/download/server.js +72 -0
- package/lib/commands/download/studio.d.ts +20 -0
- package/lib/commands/download/studio.js +89 -0
- package/lib/commands/gitlab/next-nightly-tag.d.ts +30 -0
- package/lib/commands/gitlab/next-nightly-tag.js +171 -0
- package/lib/commands/jira/issue.d.ts +17 -0
- package/lib/commands/jira/issue.js +31 -0
- package/lib/commands/jira/labels.d.ts +22 -0
- package/lib/commands/jira/labels.js +70 -0
- package/lib/commands/log/add.d.ts +17 -0
- package/lib/commands/log/add.js +107 -0
- package/lib/commands/log/generate.d.ts +22 -0
- package/lib/commands/log/generate.js +155 -0
- package/lib/commands/log/validate.d.ts +11 -0
- package/lib/commands/log/validate.js +58 -0
- package/lib/commands/login.d.ts +23 -0
- package/lib/commands/login.js +144 -0
- package/lib/commands/npm/check.publish.d.ts +17 -0
- package/lib/commands/npm/check.publish.js +78 -0
- package/lib/commands/npm/publish.d.ts +23 -0
- package/lib/commands/npm/publish.js +163 -0
- package/lib/commands/prepare-content.d.ts +29 -0
- package/lib/commands/prepare-content.js +386 -0
- package/lib/commands/sql.d.ts +24 -0
- package/lib/commands/sql.js +147 -0
- package/lib/commands/translate.d.ts +37 -0
- package/lib/commands/translate.js +149 -0
- package/lib/commands/version.d.ts +48 -0
- package/lib/commands/version.js +267 -0
- package/lib/config.d.ts +7 -0
- package/lib/config.js +9 -0
- package/lib/hooks/init/version-override.d.ts +2 -0
- package/lib/hooks/init/version-override.js +15 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -0
- package/lib/lib/command.d.ts +9 -0
- package/lib/lib/command.js +71 -0
- package/lib/lib/npm.d.ts +15 -0
- package/lib/lib/npm.js +79 -0
- package/lib/lib/npmrc.d.ts +17 -0
- package/lib/lib/npmrc.js +44 -0
- package/lib/security/cache.d.ts +7 -0
- package/lib/security/cache.js +33 -0
- package/lib/security/context.d.ts +58 -0
- package/lib/security/context.js +224 -0
- package/lib/types/changelog.types.d.ts +6 -0
- package/lib/types/changelog.types.js +2 -0
- package/lib/types/npm.types.d.ts +34 -0
- package/lib/types/npm.types.js +2 -0
- package/oclif.manifest.json +1 -0
- package/package.json +118 -0
|
@@ -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 DownloadPlatform 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-${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(DownloadPlatform);
|
|
30
|
+
let basePath = flags.output;
|
|
31
|
+
const filename = `AdInsure-${flags.version}.zip`;
|
|
32
|
+
let filePath = path.resolve(basePath, filename);
|
|
33
|
+
cli_ux_1.default.action.start(`Downloading AdInsure Platform 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 = DownloadPlatform;
|
|
55
|
+
DownloadPlatform.aliases = ['download', 'download:platform'];
|
|
56
|
+
DownloadPlatform.description = 'download platform from azure storage';
|
|
57
|
+
DownloadPlatform.usage = 'download <flags>';
|
|
58
|
+
DownloadPlatform.examples = [
|
|
59
|
+
`$ ops download -v 6.0.0 -o ~/Downloads`
|
|
60
|
+
];
|
|
61
|
+
DownloadPlatform.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 DownloadScheduler 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 DownloadScheduler 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}/AdInsureScheduler-${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(DownloadScheduler);
|
|
30
|
+
let basePath = flags.output;
|
|
31
|
+
const filename = `AdInsureScheduler-${flags.version}.zip`;
|
|
32
|
+
let filePath = path.resolve(basePath, filename);
|
|
33
|
+
cli_ux_1.default.action.start(`Downloading AdInsure Scheduler 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 = DownloadScheduler;
|
|
55
|
+
DownloadScheduler.aliases = ['download:scheduler'];
|
|
56
|
+
DownloadScheduler.description = 'download scheduler from azure storage';
|
|
57
|
+
DownloadScheduler.usage = 'download:scheduler <flags>';
|
|
58
|
+
DownloadScheduler.examples = [
|
|
59
|
+
`$ ops download:scheduler -v 3.2.0 -o ~/Downloads`
|
|
60
|
+
];
|
|
61
|
+
DownloadScheduler.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 DownloadServer 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 DownloadServer 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-server-${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(DownloadServer);
|
|
30
|
+
let basePath = flags.output;
|
|
31
|
+
const filename = `AdInsure-server-${flags.version}.zip`;
|
|
32
|
+
let filePath = path.resolve(basePath, filename);
|
|
33
|
+
cli_ux_1.default.action.start(`Downloading AdInsure 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 = DownloadServer;
|
|
55
|
+
DownloadServer.aliases = ['download:server'];
|
|
56
|
+
DownloadServer.description = 'download AdInsure Server from Azure storage';
|
|
57
|
+
DownloadServer.usage = 'download:server <flags>';
|
|
58
|
+
DownloadServer.examples = [
|
|
59
|
+
`$ ops download:server -v 3.2.0 -o ~/Downloads`
|
|
60
|
+
];
|
|
61
|
+
DownloadServer.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,20 @@
|
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import CommandBase from '../../command.base';
|
|
3
|
+
export default class DownloadStudio 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
|
+
install: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
private readonly url;
|
|
14
|
+
/**
|
|
15
|
+
* Get unique scriptID by specified version
|
|
16
|
+
*/
|
|
17
|
+
downloadFile(version: string): Promise<string>;
|
|
18
|
+
installExtension(extensionPath: string): Promise<void>;
|
|
19
|
+
run(): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
const command_2 = require("../../lib/command");
|
|
11
|
+
class DownloadStudio extends command_base_1.default {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.url = 'https://ops.adinsure.com/api/storage/extensions/';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get unique scriptID by specified version
|
|
18
|
+
*/
|
|
19
|
+
async downloadFile(version) {
|
|
20
|
+
let options = {
|
|
21
|
+
uri: `${this.url}/adinsure-studio-${version}.vsix`,
|
|
22
|
+
encoding: 'binary',
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: 'Bearer ' + await this.security.getToken()
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return request.get(options);
|
|
28
|
+
}
|
|
29
|
+
async installExtension(extensionPath) {
|
|
30
|
+
let cp = new command_2.default();
|
|
31
|
+
await cp.runCommand(['code', '--install-extension', extensionPath, '--force']);
|
|
32
|
+
}
|
|
33
|
+
async run() {
|
|
34
|
+
const { flags } = this.parse(DownloadStudio);
|
|
35
|
+
let basePath = flags.output;
|
|
36
|
+
const filename = `adinsure-studio-${flags.version}.vsix`;
|
|
37
|
+
let filePath = path.resolve(basePath, filename);
|
|
38
|
+
cli_ux_1.default.action.start(`Downloading AdInsure Studio version ${flags.version} to ${filePath}`, undefined, { stdout: true });
|
|
39
|
+
try {
|
|
40
|
+
let file = await this.downloadFile(flags.version);
|
|
41
|
+
let writeStream = fs.createWriteStream(filePath);
|
|
42
|
+
writeStream.write(file, 'binary');
|
|
43
|
+
writeStream.on('finish', async () => {
|
|
44
|
+
cli_ux_1.default.action.stop(`${chalk_1.default.green('OK')}`);
|
|
45
|
+
if (flags.install) {
|
|
46
|
+
cli_ux_1.default.action.start(`Installing into VSCode`, undefined, { stdout: true });
|
|
47
|
+
await this.installExtension(filePath);
|
|
48
|
+
cli_ux_1.default.action.stop(`${chalk_1.default.green('Done')}`);
|
|
49
|
+
this.log(`${chalk_1.default.yellow('Use \'CRTL + SHIFT + P\' and select reload windows to apply this studio version.')}`);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
writeStream.end();
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
if (err.statusCode === 404) {
|
|
56
|
+
// cli.action.stop(`${chalk.red('Does not exists.')}`);
|
|
57
|
+
this.error('Does not exists.', { exit: 1 });
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.error(err.message);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.default = DownloadStudio;
|
|
66
|
+
DownloadStudio.aliases = ['download:studio'];
|
|
67
|
+
DownloadStudio.description = 'download studio vsix from azure storage';
|
|
68
|
+
DownloadStudio.usage = 'download:studio <flags>';
|
|
69
|
+
DownloadStudio.examples = [
|
|
70
|
+
`$ ops download:studio -v 15.0.0 -o ~/Downloads`,
|
|
71
|
+
`$ ops download:studio -v 15.0.0 -i`
|
|
72
|
+
];
|
|
73
|
+
DownloadStudio.flags = {
|
|
74
|
+
version: command_1.flags.string({
|
|
75
|
+
char: 'v',
|
|
76
|
+
description: 'version we want to download',
|
|
77
|
+
required: true
|
|
78
|
+
}),
|
|
79
|
+
output: command_1.flags.string({
|
|
80
|
+
char: 'o',
|
|
81
|
+
description: 'output directory',
|
|
82
|
+
default: './'
|
|
83
|
+
}),
|
|
84
|
+
install: command_1.flags.boolean({
|
|
85
|
+
char: 'i',
|
|
86
|
+
description: 'install plugin to vscode. save to temp folder and remove vsix after.',
|
|
87
|
+
default: false
|
|
88
|
+
}),
|
|
89
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import * as semver from 'semver';
|
|
3
|
+
import CommandBase from '../../command.base';
|
|
4
|
+
export default class GitlabNextNightlyTag extends CommandBase {
|
|
5
|
+
static aliases: string[];
|
|
6
|
+
static description: string;
|
|
7
|
+
static usage: string;
|
|
8
|
+
static examples: string[];
|
|
9
|
+
static args: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
}[];
|
|
13
|
+
static flags: {
|
|
14
|
+
pat: flags.IOptionFlag<string>;
|
|
15
|
+
host: flags.IOptionFlag<string>;
|
|
16
|
+
project: flags.IOptionFlag<string>;
|
|
17
|
+
reference: flags.IOptionFlag<string>;
|
|
18
|
+
dryRun: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
19
|
+
};
|
|
20
|
+
private readonly apiBase;
|
|
21
|
+
/**
|
|
22
|
+
* Try to figure out latest available version already created
|
|
23
|
+
*/
|
|
24
|
+
createNewTag(url: string, pat: string, tag_name: string, ref: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Try to figure out latest available version already created
|
|
27
|
+
*/
|
|
28
|
+
getLatestVersion(url: string, pat: string, searchVersion: string, prefix?: string): Promise<semver.SemVer>;
|
|
29
|
+
run(): Promise<undefined>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
|
+
const axios_1 = require("axios");
|
|
5
|
+
const chalk_1 = require("chalk");
|
|
6
|
+
const cli_ux_1 = require("cli-ux");
|
|
7
|
+
const semver = require("semver");
|
|
8
|
+
const command_base_1 = require("../../command.base");
|
|
9
|
+
class GitlabNextNightlyTag extends command_base_1.default {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.apiBase = '/api/v4/projects';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Try to figure out latest available version already created
|
|
16
|
+
*/
|
|
17
|
+
async createNewTag(url, pat, tag_name, ref) {
|
|
18
|
+
try {
|
|
19
|
+
await axios_1.default.post(`${url}`, {
|
|
20
|
+
tag_name,
|
|
21
|
+
ref
|
|
22
|
+
}, {
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: `Bearer ${pat}`,
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new Error(err);
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Try to figure out latest available version already created
|
|
35
|
+
*/
|
|
36
|
+
async getLatestVersion(url, pat, searchVersion, prefix = '') {
|
|
37
|
+
let versions = [];
|
|
38
|
+
try {
|
|
39
|
+
let page = 1;
|
|
40
|
+
let totalPages = 1;
|
|
41
|
+
do {
|
|
42
|
+
let response = await axios_1.default.get(`${url}`, {
|
|
43
|
+
headers: {
|
|
44
|
+
Authorization: `Bearer ${pat}`,
|
|
45
|
+
},
|
|
46
|
+
params: {
|
|
47
|
+
search: `^${prefix}v${searchVersion}`,
|
|
48
|
+
per_page: 100,
|
|
49
|
+
page
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
response.data.forEach((tag) => {
|
|
53
|
+
const regex = new RegExp(`${prefix}(.*)`);
|
|
54
|
+
let searchTag = tag;
|
|
55
|
+
let match = tag.name.match(regex);
|
|
56
|
+
if (match[1]) {
|
|
57
|
+
searchTag = match[1];
|
|
58
|
+
}
|
|
59
|
+
let semanticVersion = semver.parse(searchTag, { includePrerelease: true });
|
|
60
|
+
if (semanticVersion && semanticVersion.prerelease.length === 0) {
|
|
61
|
+
versions.push(semanticVersion);
|
|
62
|
+
// ignore versions that that doesn't have number for prerelease identifier (skip qa and test prereleases)
|
|
63
|
+
}
|
|
64
|
+
else if (semanticVersion && semanticVersion.prerelease.length === 2 && /^[0-9]+$/.test(semanticVersion.prerelease[1].toString())) {
|
|
65
|
+
versions.push(semanticVersion);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
totalPages = parseInt(response.headers['x-total-pages'], 10);
|
|
69
|
+
page++;
|
|
70
|
+
} while (page <= totalPages);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
this.error(err.message);
|
|
74
|
+
}
|
|
75
|
+
return semver.rsort(versions)[0];
|
|
76
|
+
}
|
|
77
|
+
async run() {
|
|
78
|
+
const { args, flags } = this.parse(GitlabNextNightlyTag);
|
|
79
|
+
const re = /^release\/(\w+\-)?((\d+)(\.\d+)?)$/;
|
|
80
|
+
let prefix = '';
|
|
81
|
+
let inputVersion = args.version;
|
|
82
|
+
const match = args.version.match(re);
|
|
83
|
+
if (match) {
|
|
84
|
+
if (match[1] !== 'adinsure-') {
|
|
85
|
+
prefix = match[1];
|
|
86
|
+
}
|
|
87
|
+
inputVersion = match[2];
|
|
88
|
+
}
|
|
89
|
+
const urlPath = `${this.apiBase}/${flags.project}/repository/tags`;
|
|
90
|
+
let version = semver.parse(inputVersion);
|
|
91
|
+
let nextVersion = null;
|
|
92
|
+
// if version is not parsable try to find something that starts with this version
|
|
93
|
+
if (!version) {
|
|
94
|
+
version = await this.getLatestVersion(`${flags.host}${urlPath}`, flags.pat, inputVersion, prefix);
|
|
95
|
+
}
|
|
96
|
+
// still version does not exists we will try to parse it with additional 0 as patch version
|
|
97
|
+
if (!version) {
|
|
98
|
+
version = semver.parse(`${inputVersion}.0`);
|
|
99
|
+
}
|
|
100
|
+
// last option trying to add 0 for minor and patch version
|
|
101
|
+
if (!version) {
|
|
102
|
+
version = semver.parse(`${inputVersion}.0.0`);
|
|
103
|
+
}
|
|
104
|
+
// fail because we were not able to parse this version
|
|
105
|
+
if (!version) {
|
|
106
|
+
return this.error(`${chalk_1.default.red('Version in incorrect format')}`);
|
|
107
|
+
}
|
|
108
|
+
cli_ux_1.default.action.start('Calculating next prerelease test version', undefined, { stdout: true });
|
|
109
|
+
const date = new Date();
|
|
110
|
+
const prereleaseDate = `${date.getFullYear()}${('0' + (date.getMonth() + 1)).slice(-2)}`;
|
|
111
|
+
let lastVersion = await this.getLatestVersion(`${flags.host}${urlPath}`, flags.pat, version.version, prefix);
|
|
112
|
+
if (lastVersion) {
|
|
113
|
+
nextVersion = `v${semver.inc(lastVersion, 'prerelease', prereleaseDate)}`;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
nextVersion = `v${semver.inc(`${version.version}-${prereleaseDate}.0`, 'prerelease', prereleaseDate)}`;
|
|
117
|
+
}
|
|
118
|
+
if (prefix) {
|
|
119
|
+
nextVersion = `${prefix}${nextVersion}`;
|
|
120
|
+
}
|
|
121
|
+
cli_ux_1.default.action.stop(`${chalk_1.default.green(nextVersion)}`);
|
|
122
|
+
if (!flags.dryRun) {
|
|
123
|
+
await this.createNewTag(`${flags.host}${urlPath}`, flags.pat, nextVersion, flags.reference);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
this.warn(`This is only dry run. no new tag will was created!`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.default = GitlabNextNightlyTag;
|
|
131
|
+
GitlabNextNightlyTag.aliases = ['gitlab:next-nightly-tag'];
|
|
132
|
+
GitlabNextNightlyTag.description = 'creates new gitlab tag';
|
|
133
|
+
GitlabNextNightlyTag.usage = 'gitlab:next-nightly-tag <version> -n';
|
|
134
|
+
GitlabNextNightlyTag.examples = [
|
|
135
|
+
`$ ops gitlab:tag 17.0.0`,
|
|
136
|
+
`$ ops gitlab:tag 17.0.0 -n`
|
|
137
|
+
];
|
|
138
|
+
GitlabNextNightlyTag.args = [
|
|
139
|
+
{
|
|
140
|
+
name: 'version',
|
|
141
|
+
description: 'Tag version'
|
|
142
|
+
}
|
|
143
|
+
];
|
|
144
|
+
GitlabNextNightlyTag.flags = {
|
|
145
|
+
pat: command_1.flags.string({
|
|
146
|
+
required: true,
|
|
147
|
+
env: 'PRIVATE_TOKEN',
|
|
148
|
+
description: 'Token from user that has permissions to list and create tags'
|
|
149
|
+
}),
|
|
150
|
+
host: command_1.flags.string({
|
|
151
|
+
required: true,
|
|
152
|
+
default: 'https://git.adacta-fintech.com',
|
|
153
|
+
env: 'CI_SERVER_URL',
|
|
154
|
+
description: 'Server hostname'
|
|
155
|
+
}),
|
|
156
|
+
project: command_1.flags.string({
|
|
157
|
+
required: true,
|
|
158
|
+
default: '413',
|
|
159
|
+
env: 'CI_PROJECT_ID',
|
|
160
|
+
description: 'Project ID'
|
|
161
|
+
}),
|
|
162
|
+
reference: command_1.flags.string({
|
|
163
|
+
required: true,
|
|
164
|
+
env: 'CI_COMMIT_REF_NAME',
|
|
165
|
+
description: 'Reference to create tag on (branch, commit, tag)'
|
|
166
|
+
}),
|
|
167
|
+
dryRun: command_1.flags.boolean({
|
|
168
|
+
description: `Only printout version and don't create it`,
|
|
169
|
+
default: false
|
|
170
|
+
})
|
|
171
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import CommandBaseJira from '../../command.base.jira';
|
|
2
|
+
export default class JiraLabels extends CommandBaseJira {
|
|
3
|
+
static description: string;
|
|
4
|
+
static usage: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static args: {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
}[];
|
|
11
|
+
static flags: {
|
|
12
|
+
username: import("@oclif/command/lib/flags").IOptionFlag<string>;
|
|
13
|
+
password: import("@oclif/command/lib/flags").IOptionFlag<string>;
|
|
14
|
+
hostname: import("@oclif/command/lib/flags").IOptionFlag<string>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_base_jira_1 = require("../../command.base.jira");
|
|
4
|
+
class JiraLabels extends command_base_jira_1.default {
|
|
5
|
+
async run() {
|
|
6
|
+
const { args, flags } = this.parse(JiraLabels);
|
|
7
|
+
const jira = await this.jiraInit(flags.hostname, flags.username, flags.password);
|
|
8
|
+
try {
|
|
9
|
+
let issue = await jira.findIssue(args.issue);
|
|
10
|
+
this.log(JSON.stringify(issue));
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
this.error(err);
|
|
14
|
+
this.exit(1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.default = JiraLabels;
|
|
19
|
+
JiraLabels.description = 'get Jira issue';
|
|
20
|
+
JiraLabels.usage = 'jira:issue <issue>';
|
|
21
|
+
JiraLabels.examples = [
|
|
22
|
+
`$ ops jira:issue LJADIRD-1337`,
|
|
23
|
+
];
|
|
24
|
+
JiraLabels.args = [
|
|
25
|
+
{
|
|
26
|
+
name: 'issue',
|
|
27
|
+
description: 'Jira issue number',
|
|
28
|
+
required: true
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
JiraLabels.flags = Object.assign({}, command_base_jira_1.default.flags);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import JiraApi = require('jira-client');
|
|
3
|
+
import CommandBaseJira from '../../command.base.jira';
|
|
4
|
+
export default class JiraLabels extends CommandBaseJira {
|
|
5
|
+
static description: string;
|
|
6
|
+
static usage: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static args: {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
static flags: {
|
|
14
|
+
add: flags.IOptionFlag<string[]>;
|
|
15
|
+
remove: flags.IOptionFlag<string[]>;
|
|
16
|
+
username: flags.IOptionFlag<string>;
|
|
17
|
+
password: flags.IOptionFlag<string>;
|
|
18
|
+
hostname: flags.IOptionFlag<string>;
|
|
19
|
+
};
|
|
20
|
+
setLabels(jira: JiraApi, issue: string, add?: string[], remove?: string[]): Promise<JiraApi.JsonResponse>;
|
|
21
|
+
run(): Promise<void>;
|
|
22
|
+
}
|