Добавлена конфига status-changes
This commit is contained in:
parent
9174042971
commit
1a65ab7fca
6 changed files with 66 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -37,3 +37,4 @@ configs/main-config.jsonc
|
|||
configs/issue-event-emitter-config.jsonc
|
||||
tmp/*
|
||||
configs/redmine-statuses-config.jsonc
|
||||
configs/redmine-status-changes-config.jsonc
|
||||
|
|
|
|||
17
configs/redmine-status-changes-config.jsonc.dist
Normal file
17
configs/redmine-status-changes-config.jsonc.dist
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[
|
||||
{
|
||||
"default": false,
|
||||
"from": "New",
|
||||
"to": "In Progress",
|
||||
"messages": [
|
||||
{
|
||||
"recipient": "<field_name>",
|
||||
// Handlebars - template engine
|
||||
"changes_message": "{{qa.name}} got issue #{{issue_id}} after development {{dev.name}}",
|
||||
"notification_message": "<a href=\"{{ issue_url }}\">{{ issue_tracker }} #{{ issue_id }}</a> {{ issue_subject }}:\n{{dev.name}} finished development. You can test issue.\n\n{{journal_note}}"
|
||||
}
|
||||
// ...
|
||||
]
|
||||
}
|
||||
// ...
|
||||
]
|
||||
|
|
@ -4,9 +4,11 @@ import { join } from 'path';
|
|||
import { parse } from 'jsonc-parser';
|
||||
import { AppConfig } from 'src/models/app-config.model';
|
||||
import RedmineStatusesConfigLoader from './statuses.config';
|
||||
import RedmineStatusChangesConfigLoader from './status-changes.config';
|
||||
|
||||
const redmineIssueEventEmitterConfig = RedmineIssueEventEmitterConfigLoader();
|
||||
const redmineStatusesConfig = RedmineStatusesConfigLoader();
|
||||
const redmineStatusChanges = RedmineStatusChangesConfigLoader();
|
||||
|
||||
let appConfig: AppConfig;
|
||||
|
||||
|
|
@ -27,6 +29,7 @@ export default (): AppConfig => {
|
|||
...data,
|
||||
redmineStatuses: redmineStatusesConfig,
|
||||
redmineIssueEventEmitterConfig: redmineIssueEventEmitterConfig,
|
||||
redmineStatusChanges: redmineStatusChanges,
|
||||
};
|
||||
|
||||
return appConfig;
|
||||
|
|
|
|||
26
src/configs/status-changes.config.ts
Normal file
26
src/configs/status-changes.config.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { StatusChangesConfig } from 'src/models/status-changes-config.model';
|
||||
import { parse } from 'jsonc-parser';
|
||||
|
||||
let statusChanges: StatusChangesConfig.Config;
|
||||
|
||||
export default (): StatusChangesConfig.Config => {
|
||||
if (statusChanges) {
|
||||
return statusChanges;
|
||||
}
|
||||
|
||||
const userDefinedConfigPath =
|
||||
process.env['ELTEX_REDMINE_HELPER_STATUS_CHANGES_CONFIG_PATH'];
|
||||
const defaultConfigPath = join(
|
||||
'configs',
|
||||
'redmine-status-changes-config.jsonc',
|
||||
);
|
||||
const configPath = userDefinedConfigPath || defaultConfigPath;
|
||||
|
||||
const rawData = readFileSync(configPath, { encoding: 'utf-8' });
|
||||
|
||||
statusChanges = parse(rawData);
|
||||
|
||||
return statusChanges;
|
||||
};
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
import { MainConfigModel } from '@app/event-emitter/models/main-config-model';
|
||||
import { StatusChangesConfig } from './status-changes-config.model';
|
||||
import { StatusesConfig } from './statuses-config.model';
|
||||
|
||||
export type AppConfig = {
|
||||
redmineIssueEventEmitterConfig: MainConfigModel;
|
||||
redmineStatuses: StatusesConfig.Config;
|
||||
redmineStatusChanges: StatusChangesConfig.Config;
|
||||
couchDb: {
|
||||
dbs: {
|
||||
changes: string;
|
||||
|
|
|
|||
17
src/models/status-changes-config.model.ts
Normal file
17
src/models/status-changes-config.model.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
export namespace StatusChangesConfig {
|
||||
export type Message = {
|
||||
recipient: string;
|
||||
changes_message: string;
|
||||
notification_message: string;
|
||||
};
|
||||
|
||||
export type Item = {
|
||||
default: boolean;
|
||||
from: string;
|
||||
to: string;
|
||||
messages: Message[];
|
||||
};
|
||||
|
||||
export type Config = Item[];
|
||||
}
|
||||
Loading…
Reference in a new issue