@beseif-solutions/prow-core 0.0.31 → 0.0.32
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.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Provider } from "../entities/provider";
|
|
2
2
|
export declare class Protocol {
|
|
3
3
|
private readonly provider;
|
|
4
|
-
|
|
4
|
+
private readonly path;
|
|
5
|
+
constructor(provider: Provider, path: string);
|
|
5
6
|
evaluate: (req: Protocol.Command) => Promise<any>;
|
|
6
7
|
}
|
|
7
8
|
export declare namespace Protocol {
|
|
@@ -42,7 +42,7 @@ const localeListSchema = joi_1.default.object({
|
|
|
42
42
|
}).required();
|
|
43
43
|
const commandSchema = joi_1.default.alternatives(invokeSchema, credentialListSchema, actionListSchema, triggerListSchema, sourceListSchema, localeListSchema);
|
|
44
44
|
class Protocol {
|
|
45
|
-
constructor(provider) {
|
|
45
|
+
constructor(provider, path) {
|
|
46
46
|
this.evaluate = async (req) => {
|
|
47
47
|
try {
|
|
48
48
|
const validation = commandSchema.validate(req);
|
|
@@ -64,7 +64,7 @@ class Protocol {
|
|
|
64
64
|
response = Object.values(this.provider.sources || {});
|
|
65
65
|
break;
|
|
66
66
|
case `list:locales`:
|
|
67
|
-
const i18nInstance = (0, locales_1.i18n)({ directory:
|
|
67
|
+
const i18nInstance = (0, locales_1.i18n)({ directory: `${this.path}/locales` });
|
|
68
68
|
response = i18nInstance.i18n.getLocales().map((l) => {
|
|
69
69
|
i18nInstance.i18n.setLocale(l);
|
|
70
70
|
return {
|
|
@@ -105,6 +105,7 @@ class Protocol {
|
|
|
105
105
|
throw new Error(`Invalid provider for protocol`);
|
|
106
106
|
}
|
|
107
107
|
this.provider = provider;
|
|
108
|
+
this.path = path;
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
exports.Protocol = Protocol;
|
package/package.json
CHANGED
|
@@ -53,11 +53,13 @@ const commandSchema = Joi.alternatives(
|
|
|
53
53
|
export class Protocol {
|
|
54
54
|
|
|
55
55
|
private readonly provider: Provider;
|
|
56
|
+
private readonly path: string;
|
|
56
57
|
|
|
57
|
-
constructor(provider: Provider) {
|
|
58
|
+
constructor(provider: Provider, path: string) {
|
|
58
59
|
const providerValidation = providerSchema().validate(provider);
|
|
59
60
|
if (providerValidation.error) { throw new Error(`Invalid provider for protocol`); }
|
|
60
61
|
this.provider = provider;
|
|
62
|
+
this.path = path;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
public evaluate = async (req: Protocol.Command): Promise<any> => {
|
|
@@ -80,7 +82,7 @@ export class Protocol {
|
|
|
80
82
|
response = Object.values(this.provider.sources || {});
|
|
81
83
|
break;
|
|
82
84
|
case `list:locales`:
|
|
83
|
-
const i18nInstance = i18n({ directory:
|
|
85
|
+
const i18nInstance = i18n({ directory: `${this.path}/locales` });
|
|
84
86
|
response = i18nInstance.i18n.getLocales().map((l) => {
|
|
85
87
|
i18nInstance.i18n.setLocale(l);
|
|
86
88
|
return {
|