@soft-artel/ci 2.3.86 → 2.3.87
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/.env +21 -0
- package/.eslintcache +1 -0
- package/.eslintignore +4 -0
- package/.eslintrc +246 -0
- package/.gitlab-ci.yml +12 -0
- package/README.md +33 -0
- package/_publish.sh +11 -0
- package/package.json +2 -2
- package/src/Project.ts +286 -0
- package/src/commands/incrementBuild.ts +46 -0
- package/src/commands/k8s-build.ts +441 -0
- package/src/commands/k8s-deploy.ts +215 -0
- package/src/commands/xcode.ts +192 -0
- package/src/services/Git.ts +203 -0
- package/src/services/Gitlab.ts +129 -0
- package/src/services/Jira.ts +228 -0
- package/src/services/Reporter.ts +230 -0
- package/src/utils/Exception.ts +19 -0
- package/src/utils/Logger.ts +85 -0
- package/src/utils/Shell.ts +120 -0
- package/src/utils/helpers.ts +126 -0
- package/src/utils/prototype.ts +313 -0
- package/test.ts +0 -0
- package/tsconfig.json +25 -0
- package/Project.d.ts +0 -57
- package/Project.d.ts.map +0 -1
- package/Project.js +0 -173
- package/Project.js.map +0 -1
- package/commands/incrementBuild.d.ts +0 -3
- package/commands/incrementBuild.d.ts.map +0 -1
- package/commands/incrementBuild.js +0 -34
- package/commands/incrementBuild.js.map +0 -1
- package/commands/k8s-build.d.ts +0 -30
- package/commands/k8s-build.d.ts.map +0 -1
- package/commands/k8s-build.js +0 -291
- package/commands/k8s-build.js.map +0 -1
- package/commands/k8s-deploy.d.ts +0 -11
- package/commands/k8s-deploy.d.ts.map +0 -1
- package/commands/k8s-deploy.js +0 -145
- package/commands/k8s-deploy.js.map +0 -1
- package/commands/xcode.d.ts +0 -3
- package/commands/xcode.d.ts.map +0 -1
- package/commands/xcode.js +0 -128
- package/commands/xcode.js.map +0 -1
- package/services/Git.d.ts +0 -46
- package/services/Git.d.ts.map +0 -1
- package/services/Git.js +0 -138
- package/services/Git.js.map +0 -1
- package/services/Gitlab.d.ts +0 -14
- package/services/Gitlab.d.ts.map +0 -1
- package/services/Gitlab.js +0 -101
- package/services/Gitlab.js.map +0 -1
- package/services/Jira.d.ts +0 -32
- package/services/Jira.d.ts.map +0 -1
- package/services/Jira.js +0 -136
- package/services/Jira.js.map +0 -1
- package/services/Reporter.d.ts +0 -43
- package/services/Reporter.d.ts.map +0 -1
- package/services/Reporter.js +0 -134
- package/services/Reporter.js.map +0 -1
- package/utils/Exception.d.ts +0 -5
- package/utils/Exception.d.ts.map +0 -1
- package/utils/Exception.js +0 -14
- package/utils/Exception.js.map +0 -1
- package/utils/Logger.d.ts +0 -11
- package/utils/Logger.d.ts.map +0 -1
- package/utils/Logger.js +0 -62
- package/utils/Logger.js.map +0 -1
- package/utils/Shell.d.ts +0 -39
- package/utils/Shell.d.ts.map +0 -1
- package/utils/Shell.js +0 -89
- package/utils/Shell.js.map +0 -1
- package/utils/helpers.d.ts +0 -16
- package/utils/helpers.d.ts.map +0 -1
- package/utils/helpers.js +0 -109
- package/utils/helpers.js.map +0 -1
- package/utils/prototype.d.ts +0 -9
- package/utils/prototype.d.ts.map +0 -1
- package/utils/prototype.js +0 -186
- package/utils/prototype.js.map +0 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { NodeHtmlMarkdown } from 'node-html-markdown';
|
|
2
|
+
import { promises as asyncFs } from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import crypto from 'crypto';
|
|
5
|
+
|
|
6
|
+
const ENV = process.env;
|
|
7
|
+
|
|
8
|
+
// ------------------
|
|
9
|
+
|
|
10
|
+
export function checkVarsExisting(variables: { field: any; exceptionMessage: string }[]) {
|
|
11
|
+
for (const { field, exceptionMessage } of variables) {
|
|
12
|
+
if (field === undefined) {
|
|
13
|
+
throw new Error(exceptionMessage);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ------------------
|
|
19
|
+
|
|
20
|
+
export function checkEnvVars(variables: string[]) {
|
|
21
|
+
for (const key of variables) {
|
|
22
|
+
if (ENV[ key ] === undefined) {
|
|
23
|
+
throw new Error(`Missed variable in ENV: ${ key }`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ------------------
|
|
29
|
+
|
|
30
|
+
export function capitalizeFirstLetter(str: string) {
|
|
31
|
+
if(str.length < 2){ return str}
|
|
32
|
+
return str.replace(/^\w/, (c) => c.toUpperCase());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ------------------
|
|
36
|
+
|
|
37
|
+
function nlToBr(str: string) {
|
|
38
|
+
return str.replace(/\n/g, '<br>\n');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function htmlToMd(html: string) {
|
|
42
|
+
return NodeHtmlMarkdown.translate(nlToBr(html));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ------------------
|
|
46
|
+
|
|
47
|
+
export function resolvePath(filepath: string) {
|
|
48
|
+
if (filepath.startsWith('~')) {
|
|
49
|
+
filepath = path.join(process.env.HOME!, filepath.slice(1));
|
|
50
|
+
}
|
|
51
|
+
return path.resolve(filepath);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ------------------
|
|
55
|
+
|
|
56
|
+
export function asyncSleep(sec: number, fn?: (id: NodeJS.Timeout) => void){
|
|
57
|
+
return new Promise((resolve) => {
|
|
58
|
+
const id = setTimeout(resolve, sec * 1000);
|
|
59
|
+
if (fn) {
|
|
60
|
+
fn(id);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ------------------
|
|
66
|
+
|
|
67
|
+
export function stripTags(html: string){
|
|
68
|
+
return nlToBr(html)
|
|
69
|
+
.replace(/&#(\d+);/g, (match, i) => String.fromCharCode(parseInt(i, 10)))
|
|
70
|
+
.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>?/gi, '').replace(/\s{2,}/g, ' ')
|
|
71
|
+
.trim()
|
|
72
|
+
.replace(/🛠/g, '')
|
|
73
|
+
.replace(/🐞/g, '');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ------------------
|
|
77
|
+
|
|
78
|
+
export const md5 = (contents: string) => crypto.createHash('md5').update(contents).digest('hex');
|
|
79
|
+
|
|
80
|
+
// ------------------
|
|
81
|
+
|
|
82
|
+
export async function objectFromIniFile(path: string): Promise<Record<string, any> | undefined>{
|
|
83
|
+
const file = await asyncFs.readFile(path, 'utf8');
|
|
84
|
+
if(!file || file === ''){
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const rows = file.split('\n');
|
|
89
|
+
if(!rows || rows.length < 1){
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const obj: Record<string, any> = {};
|
|
94
|
+
|
|
95
|
+
for (const row of rows) {
|
|
96
|
+
const match = /^([^=:#]+?)[=:](.*)/.exec(row);
|
|
97
|
+
if (match) {
|
|
98
|
+
const key = match[1].trim();
|
|
99
|
+
const value = match[2].trim();
|
|
100
|
+
obj[ key ] = value;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return obj;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export async function fillEnvVarsFromFile(path: string){
|
|
108
|
+
const fileEnv = await objectFromIniFile(path);
|
|
109
|
+
|
|
110
|
+
if(!fileEnv){
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
for (const key in fileEnv) {
|
|
115
|
+
if (Object.prototype.hasOwnProperty.call(fileEnv, key)) {
|
|
116
|
+
const value = fileEnv[key];
|
|
117
|
+
process.env[ key ] = value;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function htmlEntities(rawStr: string){
|
|
123
|
+
return rawStr.replace(/[\u00A0-\u9999<>\&]/g, function(i) {
|
|
124
|
+
return '&#'+i.charCodeAt(0)+';';
|
|
125
|
+
});
|
|
126
|
+
}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
// ===========================================
|
|
5
|
+
// String
|
|
6
|
+
|
|
7
|
+
export interface String {
|
|
8
|
+
replaceAll(search: string, replacement: string): string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Object.defineProperties(String.prototype, {
|
|
12
|
+
|
|
13
|
+
replaceAll: {
|
|
14
|
+
value(search: string, replacement: string): any {
|
|
15
|
+
const escapedSearch = search.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
16
|
+
return this.replace(new RegExp(escapedSearch, 'g'), replacement);
|
|
17
|
+
},
|
|
18
|
+
enumerable : false,
|
|
19
|
+
writable : true,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
// ===========================================
|
|
26
|
+
// Array
|
|
27
|
+
|
|
28
|
+
export interface Array<T> {
|
|
29
|
+
randomElement: T;
|
|
30
|
+
delete(elm: T): T[];
|
|
31
|
+
match(str: string): boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Object.defineProperties(Array.prototype, {
|
|
35
|
+
|
|
36
|
+
randomElement: {
|
|
37
|
+
value(): any {
|
|
38
|
+
return this[ Math.round(Math.random() * (this.length - 1)) ];
|
|
39
|
+
},
|
|
40
|
+
enumerable : false,
|
|
41
|
+
writable : true,
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
// ----------------------------
|
|
45
|
+
|
|
46
|
+
delete: {
|
|
47
|
+
value(elm: any): any {
|
|
48
|
+
const index = this.indexOf(elm);
|
|
49
|
+
if(index === -1){
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.splice(index, 1);
|
|
54
|
+
|
|
55
|
+
return this;
|
|
56
|
+
},
|
|
57
|
+
enumerable : false,
|
|
58
|
+
writable : true,
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
// ----------------------------
|
|
62
|
+
|
|
63
|
+
match: {
|
|
64
|
+
value(str: string): boolean {
|
|
65
|
+
for (const item of this) {
|
|
66
|
+
if(typeof item === 'string' && (RegExp(item).exec(str))){
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
},
|
|
72
|
+
enumerable : false,
|
|
73
|
+
writable : true,
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// ===========================================
|
|
80
|
+
// Object
|
|
81
|
+
|
|
82
|
+
function isObjectDefined(obj: any): boolean {
|
|
83
|
+
return obj !== undefined && typeof(obj) === 'object' && obj !== null && (obj instanceof Date) === false && Array.isArray(obj) === false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
|
+
interface Object {
|
|
88
|
+
copy(maxDepth?: number, excludeKeysStart?: string[]): any;
|
|
89
|
+
diff(toObj: any, excludeKeysStart?: string[]): {from?: any; to?: any} | undefined;
|
|
90
|
+
pickKeys<O>(keys: keyof O[]): Partial<O>;
|
|
91
|
+
mergeFrom(fromObj: Record<string, any>, addFromObjKeys: boolean): void;
|
|
92
|
+
isEqual(toObj: Record<string, any>): boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Object.defineProperties(Object.prototype, {
|
|
96
|
+
|
|
97
|
+
copy: {
|
|
98
|
+
value(maxDepth?: number, excludeKeysStart?: string[]): any {
|
|
99
|
+
const maxDeep = maxDepth === undefined ? 5 : maxDepth - 1;
|
|
100
|
+
const excludeKeys = excludeKeysStart === undefined ? ['_', '$'] : excludeKeysStart;
|
|
101
|
+
|
|
102
|
+
const objCopy: Record<any, any> = {};
|
|
103
|
+
for(const key of Object.keys(this)){
|
|
104
|
+
if(excludeKeys.includes(key[0])){
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const value = (this)[key];
|
|
109
|
+
|
|
110
|
+
if (isObjectDefined(value)) {
|
|
111
|
+
objCopy[key] = (maxDeep >= 0) ? value.copy(maxDeep, excludeKeys) : {};
|
|
112
|
+
} else {
|
|
113
|
+
objCopy[key] = value;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return objCopy;
|
|
117
|
+
},
|
|
118
|
+
enumerable : false,
|
|
119
|
+
writable : true,
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
// ----------------------------
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
diff: {
|
|
127
|
+
value(toObj: any, excludeKeysStart?: string[]): {from?: any; to?: any} | undefined{
|
|
128
|
+
if(isObjectDefined(toObj) === false){
|
|
129
|
+
return { from: this.copy(), to: toObj};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const excludeKeys = excludeKeysStart === undefined ? ['_', '$'] : excludeKeysStart;
|
|
133
|
+
|
|
134
|
+
const result: Record<any, any> = {};
|
|
135
|
+
|
|
136
|
+
const fromKeys = Object.keys(this);
|
|
137
|
+
const toKeys = Object.keys(toObj);
|
|
138
|
+
|
|
139
|
+
if(fromKeys.length === toKeys.length && toKeys.length === 0){
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
for (const key of toKeys) {
|
|
144
|
+
|
|
145
|
+
const i = fromKeys.indexOf(key);
|
|
146
|
+
if(i !== -1){
|
|
147
|
+
fromKeys.splice(i, 1);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if(excludeKeys.includes(key[0])){
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const oldVal = (this)[ key ];
|
|
155
|
+
const newVal = toObj[ key ];
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
if(oldVal === newVal
|
|
159
|
+
|| (isObjectDefined(oldVal) && isObjectDefined(newVal) && Object.keys(oldVal).length === 0 && Object.keys(newVal).length === 0)
|
|
160
|
+
|| (oldVal instanceof Date && newVal instanceof Date && oldVal.getTime() === newVal.getTime())
|
|
161
|
+
){
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if(oldVal === undefined || oldVal === null || oldVal === '' || isObjectDefined(oldVal) && Object.keys(oldVal).length === 0){
|
|
166
|
+
result[ key ] = { to : newVal };
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if(isObjectDefined(oldVal) && isObjectDefined(newVal)){
|
|
172
|
+
const nestedResult = oldVal.diff(newVal);
|
|
173
|
+
|
|
174
|
+
if(nestedResult && Object.keys(nestedResult).length > 0){
|
|
175
|
+
result[ key ] = nestedResult;
|
|
176
|
+
}
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
result[ key ] = {
|
|
181
|
+
from : oldVal,
|
|
182
|
+
to : newVal,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
for (const key of fromKeys) {
|
|
189
|
+
|
|
190
|
+
if(excludeKeys.includes(key[0])){
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const oldVal = (this)[ key ];
|
|
195
|
+
|
|
196
|
+
if(oldVal !== undefined || oldVal !== null){
|
|
197
|
+
result[ key ] = {
|
|
198
|
+
from : oldVal,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return result;
|
|
205
|
+
},
|
|
206
|
+
enumerable : false,
|
|
207
|
+
writable : true,
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
// ----------------------------
|
|
211
|
+
|
|
212
|
+
pickKeys: {
|
|
213
|
+
value<O>(keys: keyof O[]): Partial<O> {
|
|
214
|
+
if(!Array.isArray(keys) || keys.length === 0) return {};
|
|
215
|
+
|
|
216
|
+
const obj: Partial<O> = {};
|
|
217
|
+
|
|
218
|
+
for (const key of keys) {
|
|
219
|
+
obj[ key as keyof O ] = (this)[ key ];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return obj;
|
|
223
|
+
},
|
|
224
|
+
enumerable : false,
|
|
225
|
+
writable : true,
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
// // ----------------------------
|
|
229
|
+
|
|
230
|
+
// applayObject: {
|
|
231
|
+
// value(fromObj: { [x: string]: any }, exeptKeys: string | string[]) {
|
|
232
|
+
// if(!fromObj || typeof fromObj !== 'object') return this;
|
|
233
|
+
|
|
234
|
+
// Object.keys(fromObj).forEach(key => {
|
|
235
|
+
|
|
236
|
+
// if(!exeptKeys || !Array.isArray(exeptKeys) || !exeptKeys.includes(key)){
|
|
237
|
+
// this[ key ] = fromObj[ key ];
|
|
238
|
+
// }
|
|
239
|
+
|
|
240
|
+
// });
|
|
241
|
+
|
|
242
|
+
// return this;
|
|
243
|
+
|
|
244
|
+
// },
|
|
245
|
+
// enumerable : false,
|
|
246
|
+
// writable : true,
|
|
247
|
+
// },
|
|
248
|
+
|
|
249
|
+
// ----------------------------
|
|
250
|
+
|
|
251
|
+
mergeFrom: {
|
|
252
|
+
value(fromObj: { [x: string]: any }, addFromObjKeys = true) {
|
|
253
|
+
|
|
254
|
+
if(!fromObj || typeof fromObj !== 'object') return this;
|
|
255
|
+
|
|
256
|
+
const keys = Object.keys(this);
|
|
257
|
+
|
|
258
|
+
const fromKeys = Object.keys(fromObj);
|
|
259
|
+
|
|
260
|
+
// Обходим те кулючи что у нас уже есть!
|
|
261
|
+
keys.forEach(key => {
|
|
262
|
+
|
|
263
|
+
const i = fromKeys.indexOf(key);
|
|
264
|
+
if(i !== -1){
|
|
265
|
+
fromKeys.splice(i, 1);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const fromValue = fromObj[ key ];
|
|
269
|
+
if(fromValue === undefined || fromValue === null){
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if(typeof this[ key ] !== 'object' ||
|
|
274
|
+
typeof this[ key ] !== typeof fromValue ||
|
|
275
|
+
Array.isArray(this[ key ])){
|
|
276
|
+
this[ key ] = fromValue;
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
this[ key ].mergeFrom(fromValue);
|
|
281
|
+
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// Добавляем те что есть только у fromObj
|
|
285
|
+
if(addFromObjKeys && fromKeys.length >0){
|
|
286
|
+
|
|
287
|
+
fromKeys.forEach(key => {
|
|
288
|
+
this[ key ] = fromObj[ key ];
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return this;
|
|
294
|
+
|
|
295
|
+
},
|
|
296
|
+
enumerable : false,
|
|
297
|
+
writable : true,
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
// ----------------------------
|
|
301
|
+
|
|
302
|
+
isEqual: {
|
|
303
|
+
value(toObj: Record<string, any>): boolean{
|
|
304
|
+
const diff = this.diff(toObj);
|
|
305
|
+
|
|
306
|
+
return diff ? Object.keys(diff).length === 0 : true;
|
|
307
|
+
},
|
|
308
|
+
enumerable : false,
|
|
309
|
+
writable : true,
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
});
|
package/test.ts
ADDED
|
File without changes
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNEXT", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
|
4
|
+
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
|
5
|
+
"lib": ["esnext"], /* Specify library files to be included in the compilation. */
|
|
6
|
+
"allowJs": true, /* Allow javascript files to be compiled. */
|
|
7
|
+
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
8
|
+
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
9
|
+
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
10
|
+
"outDir": "_dist", /* Redirect output structure to the directory. */
|
|
11
|
+
"removeComments": true, /* Do not emit comments to output. */
|
|
12
|
+
"preserveConstEnums": true,
|
|
13
|
+
"noEmitOnError": true, /* Do not emit outputs if any errors were reported. */
|
|
14
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
17
|
+
"typeRoots": ["node_modules/@types", "../node_modules/@types"], /* List of folders to include type definitions from. */
|
|
18
|
+
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
19
|
+
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
20
|
+
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
|
21
|
+
"useUnknownInCatchVariables": false
|
|
22
|
+
},
|
|
23
|
+
"include": ["src/**/*", "k8s"],
|
|
24
|
+
"exclude": ["node_modules.", "_dist", "*.sh"]
|
|
25
|
+
}
|
package/Project.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { OptionValues } from 'commander';
|
|
2
|
-
import { Reporter } from './services/Reporter';
|
|
3
|
-
export type RunCommandHandler = (prj: Project, reporter: Reporter, opts: OptionValues, config: Config) => Promise<any>;
|
|
4
|
-
export interface Config {
|
|
5
|
-
group?: string;
|
|
6
|
-
name?: string;
|
|
7
|
-
rootPath?: string;
|
|
8
|
-
appsPath?: string;
|
|
9
|
-
sharedPaths?: string[];
|
|
10
|
-
ignorePaths?: string[];
|
|
11
|
-
appFile?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare class Project {
|
|
14
|
-
isRunner: boolean;
|
|
15
|
-
id: number;
|
|
16
|
-
path: string;
|
|
17
|
-
url: string;
|
|
18
|
-
name: string;
|
|
19
|
-
group: string;
|
|
20
|
-
rootPath: string;
|
|
21
|
-
build: number;
|
|
22
|
-
version: string;
|
|
23
|
-
stage: string;
|
|
24
|
-
$stagesState: Record<string, string>;
|
|
25
|
-
job: {
|
|
26
|
-
id: string | undefined;
|
|
27
|
-
name: string;
|
|
28
|
-
step: string;
|
|
29
|
-
branch: string;
|
|
30
|
-
url: string;
|
|
31
|
-
pipline: string;
|
|
32
|
-
user: {
|
|
33
|
-
ID: string;
|
|
34
|
-
login: string;
|
|
35
|
-
name: string;
|
|
36
|
-
email: string;
|
|
37
|
-
};
|
|
38
|
-
commit: {
|
|
39
|
-
title: string;
|
|
40
|
-
author: {
|
|
41
|
-
name: string;
|
|
42
|
-
email: string;
|
|
43
|
-
};
|
|
44
|
-
hash: string;
|
|
45
|
-
url: string;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
static run(opts: OptionValues, runHandler: RunCommandHandler, chekEnv?: string[]): Promise<any>;
|
|
49
|
-
constructor(workdir: string | undefined, stage?: string);
|
|
50
|
-
get shortVersion(): string;
|
|
51
|
-
get prevVersion(): string | undefined;
|
|
52
|
-
incrementBuild(newBuild?: number): void;
|
|
53
|
-
saveGitLabBuild(): Promise<void>;
|
|
54
|
-
saveGitLabStagesVersions(): Promise<void>;
|
|
55
|
-
updateChangeLog(whatsNewHtml: string, filename?: string): Promise<void>;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=Project.d.ts.map
|
package/Project.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Project.d.ts","sourceRoot":"","sources":["../src/Project.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAC,MAAM,WAAW,CAAC;AAQxC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAK/C,MAAM,MAAM,iBAAiB,GAAG,CAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,KAAM,OAAO,CAAC,GAAG,CAAC,CAAA;AAGxH,MAAM,WAAW,MAAM;IAEtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAG,MAAM,CAAA;IAEd,QAAQ,CAAC,EAAG,MAAM,CAAA;IAElB,QAAQ,CAAC,EAAG,MAAM,CAAA;IAElB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAEvB,OAAO,CAAC,EAAE,MAAM,CAAA;CAEhB;AAGD,qBAAa,OAAO;IAGnB,QAAQ,UAA+B;IAEvC,EAAE,SAAyD;IAC3D,IAAI,SAA6B;IACjC,GAAG,SAA6B;IAEhC,IAAI,SAA6B;IACjC,KAAK,SAAkC;IAGvC,QAAQ,EAAE,MAAM,CAAM;IAEtB,KAAK,SAAK;IACV,OAAO,SAAW;IAClB,KAAK,EAAE,MAAM,CAAmC;IAEhD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAE1C,GAAG;;;;;;;;;;;;;;;;;;;;;;MA2BD;WAIW,GAAG,CAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE;gBAsG3E,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM;IAkBvD,IAAI,YAAY,WAEf;IAED,IAAI,WAAW,uBAGd;IAID,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM;IAW1B,eAAe;IAMf,wBAAwB;IAOxB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,SAAiB;CA4CrE"}
|
package/Project.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Project = void 0;
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const Logger_1 = require("./utils/Logger");
|
|
9
|
-
const Shell_1 = __importDefault(require("./utils/Shell"));
|
|
10
|
-
const helpers_1 = require("./utils/helpers");
|
|
11
|
-
const Gitlab_1 = __importDefault(require("./services/Gitlab"));
|
|
12
|
-
const Reporter_1 = require("./services/Reporter");
|
|
13
|
-
const Exception_1 = require("./utils/Exception");
|
|
14
|
-
const ENV = process.env;
|
|
15
|
-
class Project {
|
|
16
|
-
isRunner = ENV.CI_JOB_ID !== undefined;
|
|
17
|
-
id = (Number(ENV.CI_PROJECT_ID || 0));
|
|
18
|
-
path = ENV.CI_PROJECT_PATH || '';
|
|
19
|
-
url = ENV.CI_PROJECT_URL || '';
|
|
20
|
-
name = ENV.CI_PROJECT_NAME || '';
|
|
21
|
-
group = ENV.CI_PROJECT_NAMESPACE || '';
|
|
22
|
-
rootPath = '';
|
|
23
|
-
build = 0;
|
|
24
|
-
version = '0.0.0';
|
|
25
|
-
stage = ENV.CI_COMMIT_REF_NAME || 'dev';
|
|
26
|
-
$stagesState = {};
|
|
27
|
-
job = {
|
|
28
|
-
id: ENV.CI_JOB_ID,
|
|
29
|
-
name: ENV.CI_JOB_NAME || 'No Job',
|
|
30
|
-
step: ENV.CI_JOB_STAGE || 'build',
|
|
31
|
-
branch: ENV.CI_COMMIT_REF_NAME || 'dev',
|
|
32
|
-
url: ENV.CI_JOB_URL || '',
|
|
33
|
-
pipline: ENV.CI_PIPELINE_URL || '',
|
|
34
|
-
user: {
|
|
35
|
-
ID: ENV.GITLAB_USER_ID || '',
|
|
36
|
-
login: ENV.GITLAB_USER_LOGIN || '',
|
|
37
|
-
name: ENV.GITLAB_USER_NAME || '',
|
|
38
|
-
email: ENV.GITLAB_USER_EMAIL || '',
|
|
39
|
-
},
|
|
40
|
-
commit: {
|
|
41
|
-
title: ENV.CI_COMMIT_TITLE || '',
|
|
42
|
-
author: {
|
|
43
|
-
name: (ENV.CI_COMMIT_AUTHOR || ' < ').split('<')[0],
|
|
44
|
-
email: ((ENV.CI_COMMIT_AUTHOR || ' < ').split('<')[1] || ' ').replace('>', ''),
|
|
45
|
-
},
|
|
46
|
-
hash: '',
|
|
47
|
-
url: `${ENV.CI_PROJECT_URL}/-/commit/${ENV.CI_COMMIT_SHA}`,
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
static async run(opts, runHandler, chekEnv) {
|
|
51
|
-
const ciPkg = JSON.parse(await Shell_1.default.cat(__dirname + '/package.json') || "{}");
|
|
52
|
-
Logger_1.log.info('Soft-Artel CI v' + ciPkg?.version || 'undefined');
|
|
53
|
-
let reporter;
|
|
54
|
-
try {
|
|
55
|
-
(0, helpers_1.checkEnvVars)(['STAGES_STATE', 'REPORTER', 'LAST_BUILD']);
|
|
56
|
-
if (chekEnv) {
|
|
57
|
-
(0, helpers_1.checkEnvVars)(chekEnv);
|
|
58
|
-
}
|
|
59
|
-
Logger_1.log.dbg('Command run opts', opts);
|
|
60
|
-
const prj = new Project(opts.path, opts.stage);
|
|
61
|
-
const reporterOpts = JSON.parse(ENV.REPORTER);
|
|
62
|
-
reporterOpts.postTitle = opts.scheme;
|
|
63
|
-
if (await Shell_1.default.test('-e', prj.rootPath + '/package.json')) {
|
|
64
|
-
const pkg = JSON.parse(await Shell_1.default.cat(prj.rootPath + '/package.json') || 'no package.json file!');
|
|
65
|
-
const pkgBuild = Number(pkg.version.split('.')[2]);
|
|
66
|
-
prj.build = prj.build < pkgBuild ? pkgBuild : prj.build;
|
|
67
|
-
prj.version = `${pkg.version.split('.').splice(0, 2).join('.')}.${prj.build}`;
|
|
68
|
-
}
|
|
69
|
-
else if (await Shell_1.default.test('-e', 'XCODE PROJECT PAH')) {
|
|
70
|
-
const scheme = opts.scheme || 'iOS';
|
|
71
|
-
const xcodeVersion = await Shell_1.default.exec(`xcodebuild -showBuildSettings -scheme ${scheme} | grep MARKETING_VERSION | tr -d 'MARKETING_VERSION = '`, { silent: true });
|
|
72
|
-
const xcodeBuild = Number(await Shell_1.default.exec(`xcodebuild -showBuildSettings -scheme ${scheme} | grep CURRENT_PROJECT_VERSION | tr -d 'CURRENT_PROJECT_VERSION = '`, { silent: true }));
|
|
73
|
-
prj.build = prj.build < xcodeBuild ? xcodeBuild : prj.build;
|
|
74
|
-
prj.version = `${xcodeVersion}.${prj.build}`;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
throw new Exception_1.Exception('package.json or xcode project not found on path:' + prj.rootPath);
|
|
78
|
-
}
|
|
79
|
-
reporter = new Reporter_1.Reporter(prj, reporterOpts);
|
|
80
|
-
if (await Shell_1.default.test('-e', prj.rootPath + '/ci-config.json')) {
|
|
81
|
-
const config = JSON.parse(await Shell_1.default.cat(prj.rootPath + '/ci-config.json') || 'no ci-config.json file!');
|
|
82
|
-
prj.rootPath = config.rootPath || prj.rootPath;
|
|
83
|
-
prj.group = config.group || prj.group;
|
|
84
|
-
prj.name = config.name || prj.name;
|
|
85
|
-
return await runHandler(prj, reporter, opts, config);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
throw new Exception_1.Exception('ci-config.json not found on path:' + prj.rootPath);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
Logger_1.log.error(e);
|
|
93
|
-
if (reporter) {
|
|
94
|
-
try {
|
|
95
|
-
await reporter.fail(e);
|
|
96
|
-
}
|
|
97
|
-
catch (e2) {
|
|
98
|
-
Logger_1.log.error(e2);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
process.exit(1);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
constructor(workdir, stage) {
|
|
105
|
-
this.rootPath = (0, helpers_1.resolvePath)(workdir || ENV.CI_PROJECT_DIR || Shell_1.default.pwd().toString());
|
|
106
|
-
this.stage = stage || this.stage;
|
|
107
|
-
this.$stagesState = JSON.parse(ENV.STAGES_STATE);
|
|
108
|
-
Logger_1.log.dbg('STAGES STATE', this.$stagesState);
|
|
109
|
-
this.build = Number(ENV.LAST_BUILD) || 0;
|
|
110
|
-
this.version = '0.0.' + this.build;
|
|
111
|
-
Shell_1.default.cd(this.rootPath);
|
|
112
|
-
Logger_1.log.dbg(`[${this.stage}, ${this.version}] ` + this.rootPath);
|
|
113
|
-
}
|
|
114
|
-
get shortVersion() {
|
|
115
|
-
return this.version.split('.').splice(0, 2).join('.');
|
|
116
|
-
}
|
|
117
|
-
get prevVersion() {
|
|
118
|
-
const pV = this.$stagesState[this.stage];
|
|
119
|
-
return pV !== '0.0.0' ? pV : undefined;
|
|
120
|
-
}
|
|
121
|
-
incrementBuild(newBuild) {
|
|
122
|
-
if (newBuild) {
|
|
123
|
-
this.build = newBuild;
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
this.build += 1;
|
|
127
|
-
}
|
|
128
|
-
this.version = `${this.shortVersion}.${this.build}`;
|
|
129
|
-
}
|
|
130
|
-
async saveGitLabBuild() {
|
|
131
|
-
await Gitlab_1.default.saveVariable(this, 'LAST_BUILD', this.build);
|
|
132
|
-
}
|
|
133
|
-
async saveGitLabStagesVersions() {
|
|
134
|
-
this.$stagesState[this.stage] = this.version;
|
|
135
|
-
await Gitlab_1.default.saveVariable(this, 'STAGES_STATE', JSON.stringify(this.$stagesState, null, 3));
|
|
136
|
-
}
|
|
137
|
-
async updateChangeLog(whatsNewHtml, filename = 'CHANGELOG.md') {
|
|
138
|
-
const filePath = `${this.rootPath}/${filename}`;
|
|
139
|
-
let title = `# ${(0, helpers_1.capitalizeFirstLetter)(this.group)}: **${this.name.toUpperCase()}**`;
|
|
140
|
-
Logger_1.log.info(`Update ${filename}:\n${title}`);
|
|
141
|
-
let changeLog = await Shell_1.default.cat(filePath, { silent: true, ignoreError: true }) || '';
|
|
142
|
-
const lines = changeLog.split('\n');
|
|
143
|
-
if (Array.isArray(lines) && lines.length > 1) {
|
|
144
|
-
title = lines.shift() || title;
|
|
145
|
-
changeLog = lines.join('\n');
|
|
146
|
-
}
|
|
147
|
-
const dateTime = new Date().toLocaleString('ru-RU', {
|
|
148
|
-
weekday: 'long',
|
|
149
|
-
year: 'numeric',
|
|
150
|
-
month: 'short',
|
|
151
|
-
day: 'numeric',
|
|
152
|
-
timeZone: 'Europe/Moscow',
|
|
153
|
-
hour12: false,
|
|
154
|
-
hour: 'numeric',
|
|
155
|
-
minute: 'numeric',
|
|
156
|
-
});
|
|
157
|
-
const whatsNewMd = (0, helpers_1.htmlToMd)(whatsNewHtml);
|
|
158
|
-
changeLog = `${title}
|
|
159
|
-
## **${this.version}**
|
|
160
|
-
${(0, helpers_1.capitalizeFirstLetter)(dateTime)}
|
|
161
|
-
|
|
162
|
-
${whatsNewMd}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
${changeLog}
|
|
168
|
-
`;
|
|
169
|
-
await fs_1.promises.writeFile(filePath, changeLog, { encoding: 'utf8', flag: 'w+' });
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
exports.Project = Project;
|
|
173
|
-
//# sourceMappingURL=Project.js.map
|