@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/log/add.js
CHANGED
|
@@ -1,83 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { Args, Flags } from '@oclif/core';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import matter from 'gray-matter';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import CommandBase from '../../command.base.js';
|
|
8
|
+
class Changelog extends CommandBase {
|
|
9
|
+
run() {
|
|
10
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const { args, flags } = yield this.parse(Changelog);
|
|
12
|
+
// Validation of input parameters
|
|
13
|
+
const changelogFolderBase = yield this.getChangelogsRoot();
|
|
14
|
+
const possibleComponents = [];
|
|
15
|
+
for (const file of fs.readdirSync(changelogFolderBase)) {
|
|
16
|
+
if (fs.statSync(path.resolve(changelogFolderBase, file)).isDirectory()) {
|
|
17
|
+
possibleComponents.push(file);
|
|
18
|
+
}
|
|
18
19
|
}
|
|
20
|
+
// Validate JIRA ticket
|
|
21
|
+
const issueRegex = /\w+-\d+/;
|
|
22
|
+
let changelogIssue = args.issue;
|
|
23
|
+
if (!issueRegex.test(changelogIssue)) {
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
const responses = yield inquirer.prompt([{
|
|
26
|
+
name: 'issue',
|
|
27
|
+
message: 'select a JIRA issue',
|
|
28
|
+
type: 'input',
|
|
29
|
+
validate(value) {
|
|
30
|
+
if (issueRegex.test(value)) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return 'Please enter a valid JIRA ticket';
|
|
34
|
+
},
|
|
35
|
+
}]);
|
|
36
|
+
changelogIssue = responses.issue;
|
|
37
|
+
}
|
|
38
|
+
// Validate changelog type
|
|
39
|
+
let changelogType = flags.type;
|
|
40
|
+
if (!changelogType) {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
const responses = yield inquirer.prompt([{
|
|
43
|
+
name: 'type',
|
|
44
|
+
message: 'select a changelog type',
|
|
45
|
+
type: 'list',
|
|
46
|
+
choices: [{ name: 'feature' }, { name: 'fixed' }, { name: 'improve' }, { name: 'breaking' }],
|
|
47
|
+
}]);
|
|
48
|
+
changelogType = responses.type;
|
|
49
|
+
}
|
|
50
|
+
// Validate changelog component
|
|
51
|
+
let changelogComponent = flags.component;
|
|
52
|
+
let changelogFolder = path.resolve(changelogFolderBase, changelogComponent);
|
|
53
|
+
if ((possibleComponents.length > 0 && !changelogComponent) || !fs.pathExistsSync(path.resolve(changelogFolderBase, changelogComponent))) {
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
const responses = yield inquirer.prompt([{
|
|
56
|
+
name: 'component',
|
|
57
|
+
message: 'Multiple components found. Select a changelog componet',
|
|
58
|
+
type: 'list',
|
|
59
|
+
choices: possibleComponents,
|
|
60
|
+
}]);
|
|
61
|
+
changelogComponent = responses.component;
|
|
62
|
+
changelogFolder = path.resolve(changelogFolderBase, changelogComponent);
|
|
63
|
+
}
|
|
64
|
+
const fileName = `${changelogIssue.toUpperCase()}.md`;
|
|
65
|
+
const changelogPath = path.resolve(changelogFolder, fileName);
|
|
66
|
+
if (!(yield fs.pathExists(changelogFolder))) {
|
|
67
|
+
yield fs.mkdirp(changelogFolder);
|
|
68
|
+
}
|
|
69
|
+
if (yield fs.pathExists(changelogPath)) {
|
|
70
|
+
this.error(`Changelog for '${changelogIssue}' in '${changelogComponent}' already exists`);
|
|
71
|
+
}
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
+
const entry = {
|
|
74
|
+
meta: {
|
|
75
|
+
issue: changelogIssue,
|
|
76
|
+
type: changelogType,
|
|
77
|
+
},
|
|
78
|
+
content: 'Explain your changes here',
|
|
79
|
+
};
|
|
80
|
+
yield fs.writeFile(changelogPath, matter.stringify(entry.content, entry.meta));
|
|
81
|
+
this.log(`Created changelog for ${changelogIssue} in '${changelogPath}'`);
|
|
19
82
|
});
|
|
20
|
-
// Validate JIRA ticket
|
|
21
|
-
const issueRegex = /\w+-\d+/;
|
|
22
|
-
let changelogIssue = args.issue;
|
|
23
|
-
if (!issueRegex.test(changelogIssue)) {
|
|
24
|
-
let responses = await inquirer.prompt([{
|
|
25
|
-
name: 'issue',
|
|
26
|
-
message: 'select a JIRA issue',
|
|
27
|
-
type: 'input',
|
|
28
|
-
validate(value) {
|
|
29
|
-
if (issueRegex.test(value)) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
return 'Please enter a valid JIRA ticket';
|
|
33
|
-
}
|
|
34
|
-
}]);
|
|
35
|
-
changelogIssue = responses.issue;
|
|
36
|
-
}
|
|
37
|
-
// Validate changelog type
|
|
38
|
-
let changelogType = flags.type;
|
|
39
|
-
if (!changelogType) {
|
|
40
|
-
let responses = await inquirer.prompt([{
|
|
41
|
-
name: 'type',
|
|
42
|
-
message: 'select a changelog type',
|
|
43
|
-
type: 'list',
|
|
44
|
-
choices: [{ name: 'feature' }, { name: 'fixed' }, { name: 'improve' }, { name: 'breaking' }],
|
|
45
|
-
}]);
|
|
46
|
-
changelogType = responses.type;
|
|
47
|
-
}
|
|
48
|
-
// Validate changelog component
|
|
49
|
-
let changelogComponent = flags.component;
|
|
50
|
-
let changelogFolder = path.resolve(changelogFolderBase, changelogComponent);
|
|
51
|
-
if ((possibleComponents.length !== 0 && !changelogComponent) || !fs.pathExistsSync(path.resolve(changelogFolderBase, changelogComponent))) {
|
|
52
|
-
let responses = await inquirer.prompt([{
|
|
53
|
-
name: 'component',
|
|
54
|
-
message: 'Multiple components found. Select a changelog componet',
|
|
55
|
-
type: 'list',
|
|
56
|
-
choices: possibleComponents
|
|
57
|
-
}]);
|
|
58
|
-
changelogComponent = responses.component;
|
|
59
|
-
changelogFolder = path.resolve(changelogFolderBase, changelogComponent);
|
|
60
|
-
}
|
|
61
|
-
let fileName = `${changelogIssue.toUpperCase()}.md`;
|
|
62
|
-
let changelogPath = path.resolve(changelogFolder, fileName);
|
|
63
|
-
if (!(await fs.pathExists(changelogFolder))) {
|
|
64
|
-
await fs.mkdirp(changelogFolder);
|
|
65
|
-
}
|
|
66
|
-
if (await fs.pathExists(changelogPath)) {
|
|
67
|
-
this.error(`Changelog for '${changelogIssue}' in '${changelogComponent}' already exists`);
|
|
68
|
-
}
|
|
69
|
-
let entry = {
|
|
70
|
-
meta: {
|
|
71
|
-
issue: changelogIssue,
|
|
72
|
-
type: changelogType,
|
|
73
|
-
},
|
|
74
|
-
content: 'Explain your changes here'
|
|
75
|
-
};
|
|
76
|
-
await fs.writeFile(changelogPath, matter.stringify(entry.content, entry.meta));
|
|
77
|
-
this.log(`Created changelog for ${changelogIssue} in '${changelogPath}'`);
|
|
78
83
|
}
|
|
79
84
|
}
|
|
80
|
-
exports.default = Changelog;
|
|
81
85
|
Changelog.aliases = ['log', 'log:add'];
|
|
82
86
|
Changelog.description = 'creates a new changelog entry';
|
|
83
87
|
Changelog.usage = 'log <issue> -t [type] -c [options]';
|
|
@@ -85,23 +89,24 @@ Changelog.examples = [
|
|
|
85
89
|
`$ ops log LJADIRD-1234 -t feature`,
|
|
86
90
|
`$ ops log LJADIRD-5678 -t fixed`,
|
|
87
91
|
`$ ops log LJADIRD-8765 -t breaking -c Platform`,
|
|
88
|
-
`$ ops log LJADIRD-4321 -t improve -c Configuration
|
|
89
|
-
];
|
|
90
|
-
Changelog.args = [
|
|
91
|
-
{
|
|
92
|
-
name: 'issue',
|
|
93
|
-
description: 'Jira issue number'
|
|
94
|
-
}
|
|
92
|
+
`$ ops log LJADIRD-4321 -t improve -c Configuration`,
|
|
95
93
|
];
|
|
94
|
+
Changelog.args = {
|
|
95
|
+
issue: Args.string({
|
|
96
|
+
required: true,
|
|
97
|
+
description: 'Jira issue number',
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
96
100
|
Changelog.flags = {
|
|
97
|
-
type:
|
|
101
|
+
type: Flags.string({
|
|
98
102
|
char: 't',
|
|
99
103
|
description: 'type of changelog',
|
|
100
104
|
options: ['feature', 'fixed', 'improve', 'breaking'],
|
|
101
105
|
}),
|
|
102
|
-
component:
|
|
106
|
+
component: Flags.string({
|
|
103
107
|
char: 'c',
|
|
104
108
|
description: 'Component for which new changelog should be generated',
|
|
105
|
-
default: ''
|
|
106
|
-
})
|
|
109
|
+
default: '',
|
|
110
|
+
}),
|
|
107
111
|
};
|
|
112
|
+
export default Changelog;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export default class Generate extends CommandBase {
|
|
1
|
+
import CommandBase from '../../command.base.js';
|
|
2
|
+
import { ChangelogEntry } from '../../types/changelog.types.js';
|
|
3
|
+
export default class Generate extends CommandBase<typeof Generate> {
|
|
5
4
|
static aliases: string[];
|
|
6
5
|
static description: string;
|
|
7
6
|
static usage: string;
|
|
8
7
|
static examples: string[];
|
|
9
8
|
static flags: {
|
|
10
|
-
components:
|
|
11
|
-
file:
|
|
12
|
-
force: import("@oclif/
|
|
13
|
-
preview: import("@oclif/
|
|
14
|
-
version:
|
|
15
|
-
'ignore-no-changelogs': import("@oclif/
|
|
9
|
+
components: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
+
file: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
|
+
preview: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
|
+
version: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
|
+
'ignore-no-changelogs': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
16
15
|
};
|
|
17
16
|
private readonly _entryTypes;
|
|
18
17
|
private readonly _mdFileTypeRegex;
|
|
@@ -1,119 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const command_base_1 = require("../../command.base");
|
|
12
|
-
class Generate extends command_base_1.default {
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { Flags, ux } from '@oclif/core';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import matter from 'gray-matter';
|
|
5
|
+
import _ from 'lodash-es';
|
|
6
|
+
import moment from 'moment';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { rimraf } from 'rimraf';
|
|
9
|
+
import CommandBase from '../../command.base.js';
|
|
10
|
+
class Generate extends CommandBase {
|
|
13
11
|
constructor() {
|
|
14
12
|
super(...arguments);
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
14
|
this._entryTypes = [
|
|
16
15
|
{ types: ['BreakingChange', 'breaking'], text: 'Breaking Changes' },
|
|
17
16
|
{ types: ['Feature', 'feature'], text: 'New Features' },
|
|
18
17
|
{ types: ['Improvement', 'improve'], text: 'Improvements' },
|
|
19
|
-
{ types: ['Fixed', 'fixed'], text: 'Fixed' }
|
|
18
|
+
{ types: ['Fixed', 'fixed'], text: 'Fixed' },
|
|
20
19
|
];
|
|
21
20
|
this._mdFileTypeRegex = /\.md$/i;
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
async generateLog(entries, components) {
|
|
41
|
-
let content = '';
|
|
42
|
-
// First group by component, then re-sort the components to get the desired output ordering
|
|
43
|
-
let componentGroups = _.groupBy(entries, 'component');
|
|
44
|
-
for (let group of components) {
|
|
45
|
-
if (group !== '') {
|
|
46
|
-
content += `## ${_.capitalize(group)}\r\n\r\n`;
|
|
47
|
-
}
|
|
48
|
-
// tslint:disable-next-line: strict-type-predicates
|
|
49
|
-
if (componentGroups[group] === undefined || componentGroups[group].length === 0) {
|
|
50
|
-
content += `No changes were introduced in this version.\r\n\r\n`;
|
|
51
|
-
continue;
|
|
22
|
+
readChangelogs(dir) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const result = [];
|
|
25
|
+
const files = yield this.getFilesRecursive(dir, dir, this._mdFileTypeRegex);
|
|
26
|
+
for (const fileName of files) {
|
|
27
|
+
const filePath = path.resolve(dir, fileName);
|
|
28
|
+
let fileComponent = path.basename(path.dirname(filePath));
|
|
29
|
+
fileComponent = fileComponent === 'unreleased' ? '' : fileComponent;
|
|
30
|
+
const contents = matter.read(filePath);
|
|
31
|
+
result.push({
|
|
32
|
+
type: contents.data.type,
|
|
33
|
+
issue: contents.data.issue,
|
|
34
|
+
component: fileComponent,
|
|
35
|
+
content: contents.content.trim(),
|
|
36
|
+
});
|
|
52
37
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
return result;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
generateLog(entries, components) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
let content = '';
|
|
44
|
+
// First group by component, then re-sort the components to get the desired output ordering
|
|
45
|
+
const componentGroups = _.groupBy(entries, 'component');
|
|
46
|
+
for (const group of components) {
|
|
47
|
+
if (group !== '') {
|
|
48
|
+
content += `## ${_.capitalize(group)}\r\n\r\n`;
|
|
49
|
+
}
|
|
50
|
+
if (componentGroups[group] === undefined || componentGroups[group].length === 0) {
|
|
51
|
+
content += `No changes were introduced in this version.\r\n\r\n`;
|
|
56
52
|
continue;
|
|
57
53
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
content += ' ' + log.content.replace(/\n/g, '\n ');
|
|
54
|
+
for (const type of this._entryTypes) {
|
|
55
|
+
const batch = _.remove(componentGroups[group], e => _.indexOf(type.types, e.type) > -1);
|
|
56
|
+
if (batch.length === 0) {
|
|
57
|
+
continue;
|
|
63
58
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
content += `### ${type.text} (${batch.length} changes)\r\n\r\n`;
|
|
60
|
+
for (const log of batch) {
|
|
61
|
+
if (log.content.startsWith('-') || log.content.startsWith('* ')) {
|
|
62
|
+
content += `- [${log.issue}](https://jira.adacta-fintech.com/browse/${log.issue}):\r\n`;
|
|
63
|
+
content += ' ' + log.content.replaceAll('\n', '\n ');
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
content += `- [${log.issue}](https://jira.adacta-fintech.com/browse/${log.issue}): `;
|
|
67
|
+
content += log.content.replaceAll('\n', '\n ') + '\r\n';
|
|
68
|
+
}
|
|
69
|
+
content += '\r\n';
|
|
67
70
|
}
|
|
68
71
|
content += '\r\n';
|
|
69
72
|
}
|
|
70
|
-
content += '\r\n';
|
|
71
73
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
// We only want 1 new line at the end of this changelog
|
|
75
|
+
return content.trimEnd() + '\r\n\r\n';
|
|
76
|
+
});
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
78
|
+
run() {
|
|
79
|
+
var _a;
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const { flags } = yield this.parse(Generate);
|
|
82
|
+
const root = path.resolve(process.cwd());
|
|
83
|
+
const changelogFolder = yield this.getChangelogsRoot();
|
|
84
|
+
const version = (_a = flags.version) !== null && _a !== void 0 ? _a : yield this.getVersion();
|
|
85
|
+
const components = flags.components.split(',');
|
|
86
|
+
this.log(`Inspecting ${changelogFolder} ...`);
|
|
87
|
+
ux.action.start(`generating for ${version}`, undefined, { stdout: true });
|
|
88
|
+
const changelogs = yield this.readChangelogs(changelogFolder);
|
|
89
|
+
if (!flags['ignore-no-changelogs'] && changelogs.length === 0) {
|
|
90
|
+
ux.action.stop('done, no changelogs found.');
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const content = `# ${version} (${moment().format('YYYY-MM-DD')})\r\n\r\n${yield this.generateLog(changelogs, components)}`;
|
|
94
|
+
if (flags.preview) {
|
|
95
|
+
fs.writeFileSync(path.resolve(root, 'preview.md'), content, 'utf8');
|
|
96
|
+
ux.action.stop('generated preview.md');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.warn(`The following action will update ${flags.file} and remove all unreleased changelogs in '${changelogFolder}'`);
|
|
100
|
+
const confirm = flags.force || (yield ux.confirm(`Do you want to continue? [y/n/yes/no]`));
|
|
101
|
+
if (confirm) {
|
|
102
|
+
const changelogFile = path.resolve(root, flags.file);
|
|
103
|
+
const currentContents = fs.readFileSync(changelogFile, { encoding: 'utf8', flag: 'a+' });
|
|
104
|
+
fs.writeFileSync(changelogFile, content + currentContents, { encoding: 'utf8', flag: 'w' });
|
|
105
|
+
// delete unreleased changelogs
|
|
106
|
+
for (const group of components) {
|
|
107
|
+
const componentChangelogFolder = path.join(changelogFolder, group);
|
|
108
|
+
this.log(`Removing unreleased changelogs from ${componentChangelogFolder}`);
|
|
109
|
+
const changelogFiles = yield fs.readdir(componentChangelogFolder);
|
|
110
|
+
for (const file of changelogFiles) {
|
|
111
|
+
if (this._mdFileTypeRegex.test(file)) {
|
|
112
|
+
rimraf.sync(path.resolve(componentChangelogFolder, file));
|
|
113
|
+
}
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
ux.action.stop('done');
|
|
118
|
+
});
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
|
-
exports.default = Generate;
|
|
117
121
|
Generate.aliases = ['log:gen'];
|
|
118
122
|
Generate.description = 'generates final changelog from unreleased notes';
|
|
119
123
|
Generate.usage = 'log:gen [options]';
|
|
@@ -122,34 +126,35 @@ Generate.examples = [
|
|
|
122
126
|
`$ ops log:gen -p`,
|
|
123
127
|
`$ ops log:gen -c Platform`,
|
|
124
128
|
`$ ops log:gen -c Platform,Configuration`,
|
|
125
|
-
`$ ops log:gen -c Implementation -f CHANGELOG.Implementation.md
|
|
129
|
+
`$ ops log:gen -c Implementation -f CHANGELOG.Implementation.md`,
|
|
126
130
|
];
|
|
127
131
|
Generate.flags = {
|
|
128
|
-
components:
|
|
132
|
+
components: Flags.string({
|
|
129
133
|
char: 'c',
|
|
130
134
|
description: 'components separated by comma (,) to process for final changelog',
|
|
131
|
-
default: ''
|
|
135
|
+
default: '',
|
|
132
136
|
}),
|
|
133
|
-
file:
|
|
137
|
+
file: Flags.string({
|
|
134
138
|
char: 'f',
|
|
135
139
|
description: 'file to update with new changelogs',
|
|
136
|
-
default: 'CHANGELOG.md'
|
|
140
|
+
default: 'CHANGELOG.md',
|
|
137
141
|
}),
|
|
138
|
-
force:
|
|
142
|
+
force: Flags.boolean({
|
|
139
143
|
description: 'update target file without prompting for confirmation',
|
|
140
|
-
default: false
|
|
144
|
+
default: false,
|
|
141
145
|
}),
|
|
142
|
-
preview:
|
|
146
|
+
preview: Flags.boolean({
|
|
143
147
|
char: 'p',
|
|
144
148
|
description: 'generates a preview markdown of current unreleased changelogs',
|
|
145
|
-
default: false
|
|
149
|
+
default: false,
|
|
146
150
|
}),
|
|
147
|
-
version:
|
|
151
|
+
version: Flags.string({
|
|
148
152
|
char: 'v',
|
|
149
|
-
description: 'version for which you\'re generating changelogs'
|
|
153
|
+
description: 'version for which you\'re generating changelogs',
|
|
150
154
|
}),
|
|
151
|
-
'ignore-no-changelogs':
|
|
155
|
+
'ignore-no-changelogs': Flags.boolean({
|
|
152
156
|
description: 'generate final changelog even if no unreleased changelogs exist',
|
|
153
|
-
default: false
|
|
154
|
-
})
|
|
157
|
+
default: false,
|
|
158
|
+
}),
|
|
155
159
|
};
|
|
160
|
+
export default Generate;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import CommandBase from '../../command.base';
|
|
2
|
-
export default class Validate extends CommandBase {
|
|
1
|
+
import CommandBase from '../../command.base.js';
|
|
2
|
+
export default class Validate extends CommandBase<typeof Validate> {
|
|
3
3
|
static aliases: string[];
|
|
4
4
|
static description: string;
|
|
5
5
|
static usage: string;
|
|
@@ -1,58 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class Validate extends command_base_1.default {
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { ux } from '@oclif/core';
|
|
3
|
+
import matter from 'gray-matter';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import CommandBase from '../../command.base.js';
|
|
6
|
+
class Validate extends CommandBase {
|
|
8
7
|
constructor() {
|
|
9
8
|
super(...arguments);
|
|
10
9
|
// Added capitalized types for compatibility with current scripts until we migrate away
|
|
11
10
|
this._typeRegex = /^(feature|fixed|improve|breaking|Fixed|BreakingChange|Improvement|Feature)$/;
|
|
12
11
|
this._issueRegex = /\w+-\d+/;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
getProblems(path) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const problems = [];
|
|
16
|
+
const contents = matter.read(path);
|
|
17
|
+
if (contents.data.issue === undefined) {
|
|
18
|
+
problems.push('Missing \'issue\' in front-matter');
|
|
19
|
+
}
|
|
20
|
+
else if (!this._issueRegex.test(contents.data.issue)) {
|
|
21
|
+
problems.push(`'issue' is not a valid Jira issue number (got: ${contents.data.issue})`);
|
|
22
|
+
}
|
|
23
|
+
if (contents.data.type === undefined) {
|
|
24
|
+
problems.push('Missing \'type\' in front-matter');
|
|
25
|
+
}
|
|
26
|
+
else if (!this._typeRegex.test(contents.data.type)) {
|
|
27
|
+
problems.push(`Invalid 'type' used (got: ${contents.data.type})`);
|
|
28
|
+
}
|
|
29
|
+
return problems;
|
|
30
|
+
});
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
run() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const directory = yield this.getChangelogsRoot();
|
|
35
|
+
const files = yield this.getFilesRecursive(directory, directory, /\.md$/i);
|
|
36
|
+
ux.action.start('validating changelogs', undefined, { stdout: true });
|
|
37
|
+
let problemsFound = 0;
|
|
38
|
+
for (const fileName of files) {
|
|
39
|
+
const filePath = path.resolve(directory, fileName);
|
|
40
|
+
const problems = yield this.getProblems(filePath);
|
|
41
|
+
if (problems.length > 0) {
|
|
42
|
+
this.log(filePath);
|
|
43
|
+
for (const val of problems)
|
|
44
|
+
this.warn(val);
|
|
45
|
+
problemsFound += problems.length;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (problemsFound > 0) {
|
|
49
|
+
ux.action.stop('failed');
|
|
50
|
+
this.error(`Found ${problemsFound} problem(s), please correct and re-run`, { exit: 1 });
|
|
43
51
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
cli_ux_1.default.action.stop('failed');
|
|
47
|
-
this.error(`Found ${problemsFound} problem(s), please correct and re-run`, { exit: 1 });
|
|
48
|
-
}
|
|
49
|
-
cli_ux_1.default.action.stop('success');
|
|
52
|
+
ux.action.stop('success');
|
|
53
|
+
});
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
|
-
exports.default = Validate;
|
|
53
56
|
Validate.aliases = ['log:validate'];
|
|
54
57
|
Validate.description = 'validates formatting of all unreleased changelogs';
|
|
55
58
|
Validate.usage = 'log:validate [options]';
|
|
56
59
|
Validate.examples = [
|
|
57
|
-
'$ ops log:validate'
|
|
60
|
+
'$ ops log:validate',
|
|
58
61
|
];
|
|
62
|
+
export default Validate;
|