@soft-artel/ci 2.3.87 → 2.3.90
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/Project.d.ts +57 -0
- package/Project.d.ts.map +1 -0
- package/Project.js +173 -0
- package/Project.js.map +1 -0
- package/commands/incrementBuild.d.ts +3 -0
- package/commands/incrementBuild.d.ts.map +1 -0
- package/commands/incrementBuild.js +34 -0
- package/commands/incrementBuild.js.map +1 -0
- package/commands/k8s-build.d.ts +30 -0
- package/commands/k8s-build.d.ts.map +1 -0
- package/commands/k8s-build.js +291 -0
- package/commands/k8s-build.js.map +1 -0
- package/commands/k8s-deploy.d.ts +11 -0
- package/commands/k8s-deploy.d.ts.map +1 -0
- package/commands/k8s-deploy.js +145 -0
- package/commands/k8s-deploy.js.map +1 -0
- package/commands/xcode.d.ts +3 -0
- package/commands/xcode.d.ts.map +1 -0
- package/commands/xcode.js +128 -0
- package/commands/xcode.js.map +1 -0
- package/package.json +4 -4
- package/services/Git.d.ts +46 -0
- package/services/Git.d.ts.map +1 -0
- package/services/Git.js +138 -0
- package/services/Git.js.map +1 -0
- package/services/Gitlab.d.ts +14 -0
- package/services/Gitlab.d.ts.map +1 -0
- package/services/Gitlab.js +101 -0
- package/services/Gitlab.js.map +1 -0
- package/services/Jira.d.ts +32 -0
- package/services/Jira.d.ts.map +1 -0
- package/services/Jira.js +136 -0
- package/services/Jira.js.map +1 -0
- package/services/Reporter.d.ts +43 -0
- package/services/Reporter.d.ts.map +1 -0
- package/services/Reporter.js +134 -0
- package/services/Reporter.js.map +1 -0
- package/utils/Exception.d.ts +5 -0
- package/utils/Exception.d.ts.map +1 -0
- package/utils/Exception.js +14 -0
- package/utils/Exception.js.map +1 -0
- package/utils/Logger.d.ts +11 -0
- package/utils/Logger.d.ts.map +1 -0
- package/utils/Logger.js +62 -0
- package/utils/Logger.js.map +1 -0
- package/utils/Shell.d.ts +39 -0
- package/utils/Shell.d.ts.map +1 -0
- package/utils/Shell.js +89 -0
- package/utils/Shell.js.map +1 -0
- package/utils/helpers.d.ts +16 -0
- package/utils/helpers.d.ts.map +1 -0
- package/utils/helpers.js +109 -0
- package/utils/helpers.js.map +1 -0
- package/utils/prototype.d.ts +9 -0
- package/utils/prototype.d.ts.map +1 -0
- package/utils/prototype.js +186 -0
- package/utils/prototype.js.map +1 -0
- package/.env +0 -21
- package/.eslintcache +0 -1
- package/.eslintignore +0 -4
- package/.eslintrc +0 -246
- package/.gitlab-ci.yml +0 -12
- package/README.md +0 -33
- package/_publish.sh +0 -11
- package/src/Project.ts +0 -286
- package/src/commands/incrementBuild.ts +0 -46
- package/src/commands/k8s-build.ts +0 -441
- package/src/commands/k8s-deploy.ts +0 -215
- package/src/commands/xcode.ts +0 -192
- package/src/services/Git.ts +0 -203
- package/src/services/Gitlab.ts +0 -129
- package/src/services/Jira.ts +0 -228
- package/src/services/Reporter.ts +0 -230
- package/src/utils/Exception.ts +0 -19
- package/src/utils/Logger.ts +0 -85
- package/src/utils/Shell.ts +0 -120
- package/src/utils/helpers.ts +0 -126
- package/src/utils/prototype.ts +0 -313
- package/test.ts +0 -0
- package/tsconfig.json +0 -25
package/.eslintrc
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": { "es6": true, "node": true, "mocha": true, "browser": false },
|
|
3
|
-
"parser": "@typescript-eslint/parser",
|
|
4
|
-
"plugins": ["@typescript-eslint", "prettier", "import"],
|
|
5
|
-
"extends": ["plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
|
|
6
|
-
"ignorePatterns": ["node_modules/", "dist/"],
|
|
7
|
-
"parserOptions": {
|
|
8
|
-
"project": "tsconfig.json",
|
|
9
|
-
"sourceType": "module"
|
|
10
|
-
},
|
|
11
|
-
"rules": {
|
|
12
|
-
// @typescript-eslint
|
|
13
|
-
"@typescript-eslint/member-delimiter-style": [
|
|
14
|
-
"error",
|
|
15
|
-
{
|
|
16
|
-
"multiline": { "delimiter": "semi", "requireLast": true },
|
|
17
|
-
"singleline": { "delimiter": "semi", "requireLast": false }
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
21
|
-
"@typescript-eslint/array-type": "error",
|
|
22
|
-
"@typescript-eslint/ban-types": "error",
|
|
23
|
-
"@typescript-eslint/brace-style": "error",
|
|
24
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
25
|
-
// "@typescript-eslint/camelcase": ["error", { "properties": "never", "allow": ["^[A-Za-z][a-zA-Za-z]+_[A-Za-z]+$"] }],
|
|
26
|
-
// "@typescript-eslint/class-name-casing": "error",
|
|
27
|
-
"@typescript-eslint/comma-spacing": "error",
|
|
28
|
-
"@typescript-eslint/consistent-type-assertions": "error",
|
|
29
|
-
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
|
30
|
-
"@typescript-eslint/default-param-last": "error",
|
|
31
|
-
"@typescript-eslint/func-call-spacing": "error",
|
|
32
|
-
// "@typescript-eslint/interface-name-prefix": ["error", { "prefixWithI": "never" }],
|
|
33
|
-
// "@typescript-eslint/member-naming": "error",
|
|
34
|
-
// "@typescript-eslint/naming-convention": "error",
|
|
35
|
-
"@typescript-eslint/no-array-constructor": "error",
|
|
36
|
-
"@typescript-eslint/no-dupe-class-members": "error",
|
|
37
|
-
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
|
38
|
-
"@typescript-eslint/no-extra-semi": "error",
|
|
39
|
-
"@typescript-eslint/no-for-in-array": "error",
|
|
40
|
-
"@typescript-eslint/no-misused-new": "error",
|
|
41
|
-
"@typescript-eslint/no-namespace": "error",
|
|
42
|
-
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
43
|
-
"@typescript-eslint/no-require-imports": "error",
|
|
44
|
-
"@typescript-eslint/no-this-alias": "error",
|
|
45
|
-
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
46
|
-
"@typescript-eslint/no-unused-expressions": ["error", { "allowTernary": true }],
|
|
47
|
-
"@typescript-eslint/no-use-before-define": "off",
|
|
48
|
-
"@typescript-eslint/no-var-requires": "error",
|
|
49
|
-
"@typescript-eslint/prefer-as-const": "error",
|
|
50
|
-
"@typescript-eslint/prefer-for-of": "error",
|
|
51
|
-
"@typescript-eslint/prefer-function-type": "error",
|
|
52
|
-
"@typescript-eslint/prefer-includes": "error",
|
|
53
|
-
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
54
|
-
"@typescript-eslint/prefer-optional-chain": "error",
|
|
55
|
-
"@typescript-eslint/prefer-regexp-exec": "error",
|
|
56
|
-
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
|
57
|
-
"@typescript-eslint/quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
|
|
58
|
-
"@typescript-eslint/require-await": "error",
|
|
59
|
-
"@typescript-eslint/semi": ["error", "always"],
|
|
60
|
-
"@typescript-eslint/space-before-function-paren": ["error", { "asyncArrow": "always", "anonymous": "never", "named": "never" }],
|
|
61
|
-
"@typescript-eslint/triple-slash-reference": "error",
|
|
62
|
-
"@typescript-eslint/type-annotation-spacing": "error",
|
|
63
|
-
|
|
64
|
-
// @typescript-eslint:warn
|
|
65
|
-
"@typescript-eslint/indent": [
|
|
66
|
-
"warn",
|
|
67
|
-
"tab",
|
|
68
|
-
{
|
|
69
|
-
"SwitchCase": 1,
|
|
70
|
-
"FunctionDeclaration": { "parameters": "first" },
|
|
71
|
-
"FunctionExpression": { "parameters": "first" }
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
|
-
"@typescript-eslint/member-ordering": [
|
|
75
|
-
"warn",
|
|
76
|
-
{
|
|
77
|
-
"default": [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"abstract-field",
|
|
82
|
-
"static-field",
|
|
83
|
-
"instance-field",
|
|
84
|
-
"abstract-method",
|
|
85
|
-
"static-method",
|
|
86
|
-
"constructor",
|
|
87
|
-
"instance-method"
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
],
|
|
91
|
-
|
|
92
|
-
// @typescript-eslint:off
|
|
93
|
-
"@typescript-eslint/await-thenable": "off",
|
|
94
|
-
"@typescript-eslint/ban-ts-ignore": "off",
|
|
95
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
96
|
-
"@typescript-eslint/explicit-member-accessibility": ["off", { "accessibility": "explicit" }],
|
|
97
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
98
|
-
"@typescript-eslint/no-empty-interface": "off",
|
|
99
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
100
|
-
"@typescript-eslint/no-inferrable-types": ["off", { "ignoreProperties": true }],
|
|
101
|
-
"@typescript-eslint/no-misused-promises": "off",
|
|
102
|
-
"@typescript-eslint/no-unused-vars": "error",
|
|
103
|
-
"@typescript-eslint/unbound-method": "off",
|
|
104
|
-
"@typescript-eslint/unified-signatures": "off",
|
|
105
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
106
|
-
|
|
107
|
-
// import
|
|
108
|
-
"import/no-deprecated": "error",
|
|
109
|
-
"import/no-extraneous-dependencies": "error",
|
|
110
|
-
"import/order": [
|
|
111
|
-
"error",
|
|
112
|
-
{
|
|
113
|
-
"groups": [
|
|
114
|
-
["builtin", "external", "internal", "unknown"],
|
|
115
|
-
["parent", "sibling", "index"]
|
|
116
|
-
],
|
|
117
|
-
"newlines-between": "always"
|
|
118
|
-
}
|
|
119
|
-
],
|
|
120
|
-
|
|
121
|
-
// prefer-arrow
|
|
122
|
-
"prefer-arrow/prefer-arrow-functions": "off",
|
|
123
|
-
|
|
124
|
-
// eslint
|
|
125
|
-
"arrow-body-style": "error",
|
|
126
|
-
"comma-dangle": ["error", "always-multiline"],
|
|
127
|
-
"constructor-super": "error",
|
|
128
|
-
"curly": ["error", "multi-line"],
|
|
129
|
-
"dot-notation": "error",
|
|
130
|
-
"eol-last": "error",
|
|
131
|
-
"eqeqeq": "error",
|
|
132
|
-
"guard-for-in": "error",
|
|
133
|
-
"linebreak-style": ["error", "unix"],
|
|
134
|
-
"max-len": [
|
|
135
|
-
"error",
|
|
136
|
-
{
|
|
137
|
-
"code": 200,
|
|
138
|
-
"comments": 160,
|
|
139
|
-
"tabWidth": 2,
|
|
140
|
-
"ignoreComments": true,
|
|
141
|
-
"ignoreStrings": true,
|
|
142
|
-
"ignoreRegExpLiterals": true,
|
|
143
|
-
"ignoreTrailingComments": true,
|
|
144
|
-
"ignoreTemplateLiterals": true
|
|
145
|
-
}
|
|
146
|
-
],
|
|
147
|
-
"new-parens": "error",
|
|
148
|
-
"no-caller": "error",
|
|
149
|
-
"no-cond-assign": "error",
|
|
150
|
-
"no-debugger": "error",
|
|
151
|
-
"no-duplicate-case": "error",
|
|
152
|
-
"no-duplicate-imports": "error",
|
|
153
|
-
"no-eval": "error",
|
|
154
|
-
"no-extra-bind": "error",
|
|
155
|
-
"no-fallthrough": "error",
|
|
156
|
-
"no-multiple-empty-lines": "error",
|
|
157
|
-
"no-new-func": "error",
|
|
158
|
-
"no-new-wrappers": "error",
|
|
159
|
-
"no-restricted-imports": ["error", "rxjs/Rx"],
|
|
160
|
-
"no-return-await": "error",
|
|
161
|
-
"no-sparse-arrays": "error",
|
|
162
|
-
"no-throw-literal": "error",
|
|
163
|
-
"no-trailing-spaces": [
|
|
164
|
-
"error",{
|
|
165
|
-
"skipBlankLines": true
|
|
166
|
-
}
|
|
167
|
-
],
|
|
168
|
-
"no-undef-init": "error",
|
|
169
|
-
"no-unsafe-finally": "error",
|
|
170
|
-
"no-unused-expressions": "error",
|
|
171
|
-
"no-unused-labels": "error",
|
|
172
|
-
"no-var": "error",
|
|
173
|
-
"object-shorthand": "error",
|
|
174
|
-
"prefer-const": "error",
|
|
175
|
-
"prefer-object-spread": "error",
|
|
176
|
-
"prefer-rest-params": "error",
|
|
177
|
-
"prefer-spread": "error",
|
|
178
|
-
"quote-props": ["error", "consistent-as-needed"],
|
|
179
|
-
"radix": "error",
|
|
180
|
-
"space-in-parens": "error",
|
|
181
|
-
"spaced-comment": "error",
|
|
182
|
-
"unicode-bom": ["error", "never"],
|
|
183
|
-
"use-isnan": "error",
|
|
184
|
-
|
|
185
|
-
// eslint:warn
|
|
186
|
-
"no-restricted-globals": "warn",
|
|
187
|
-
"object-curly-newline": [
|
|
188
|
-
"warn",
|
|
189
|
-
{
|
|
190
|
-
"ObjectExpression": { "multiline": true, "minProperties": 4, "consistent": true },
|
|
191
|
-
"ImportDeclaration": { "multiline": true, "consistent": true },
|
|
192
|
-
"ExportDeclaration": { "multiline": true, "minProperties": 2, "consistent": true }
|
|
193
|
-
}
|
|
194
|
-
],
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
// prettier
|
|
198
|
-
"prettier/prettier": "off",
|
|
199
|
-
"semi": "off",
|
|
200
|
-
// "prettier/prettier": [
|
|
201
|
-
// "warn",
|
|
202
|
-
// {
|
|
203
|
-
// "endOfLine": "lf",
|
|
204
|
-
// "printWidth": 140,
|
|
205
|
-
// "semi": true,
|
|
206
|
-
// "singleQuote": true,
|
|
207
|
-
// "tabWidth": 2,
|
|
208
|
-
// "trailingComma": "all",
|
|
209
|
-
// "useTabs": true,
|
|
210
|
-
// "bracketSpacing": true,
|
|
211
|
-
// "proseWrap": "never"
|
|
212
|
-
// }
|
|
213
|
-
// ],
|
|
214
|
-
|
|
215
|
-
// eslint:off
|
|
216
|
-
"array-element-newline": ["off", { "multiline": true, "minItems": 1 }],
|
|
217
|
-
"arrow-parens": ["off", "as-needed"],
|
|
218
|
-
"camelcase": "off",
|
|
219
|
-
"complexity": "off",
|
|
220
|
-
"id-blacklist": "off",
|
|
221
|
-
"id-match": "off",
|
|
222
|
-
"max-classes-per-file": "off",
|
|
223
|
-
"no-array-constructor": "off",
|
|
224
|
-
"no-bitwise": "off",
|
|
225
|
-
"no-console": "error",
|
|
226
|
-
"no-empty-function": "off",
|
|
227
|
-
"no-empty": "error",
|
|
228
|
-
"no-invalid-this": "off",
|
|
229
|
-
"no-shadow": ["off", { "hoist": "all" }],
|
|
230
|
-
"no-underscore-dangle": "off",
|
|
231
|
-
"no-unused-vars": "off",
|
|
232
|
-
"no-use-before-define": "off",
|
|
233
|
-
"one-var": ["off", "never"],
|
|
234
|
-
"require-await": "off",
|
|
235
|
-
"space-before-function-paren": [
|
|
236
|
-
"off",
|
|
237
|
-
{
|
|
238
|
-
"anonymous": "never",
|
|
239
|
-
"asyncArrow": "always",
|
|
240
|
-
"named": "never"
|
|
241
|
-
}
|
|
242
|
-
],
|
|
243
|
-
"valid-typeof": "off",
|
|
244
|
-
"no-implicit-coercion": "error"
|
|
245
|
-
}
|
|
246
|
-
}
|
package/.gitlab-ci.yml
DELETED
package/README.md
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# CI/CD System
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
#GitLab CI Variables in Group:
|
|
6
|
-
|
|
7
|
-
#GitLab CI Variables in Project:
|
|
8
|
-
- `STAGES_STATE` = {
|
|
9
|
-
"alpha": "1.0.0",
|
|
10
|
-
"prod": "1.0.0"
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
- `LAST_BUILD` = 0
|
|
14
|
-
|
|
15
|
-
const k8s_tpl_fileName = 'app.k8s.yaml';
|
|
16
|
-
const k8s_spec_fileName = 'app.k8s.json';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export interface Config {
|
|
20
|
-
|
|
21
|
-
group?: string
|
|
22
|
-
name?: string
|
|
23
|
-
|
|
24
|
-
rootPath?: string
|
|
25
|
-
|
|
26
|
-
appsPath?: string
|
|
27
|
-
|
|
28
|
-
sharedPaths?: string[];
|
|
29
|
-
ignorePaths?: string[];
|
|
30
|
-
|
|
31
|
-
appFile?: string
|
|
32
|
-
|
|
33
|
-
}
|
package/_publish.sh
DELETED
package/src/Project.ts
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import { promises as fsAsync } from 'fs';
|
|
2
|
-
import { OptionValues} from 'commander';
|
|
3
|
-
|
|
4
|
-
import { log } from './utils/Logger'
|
|
5
|
-
import Shell from './utils/Shell';
|
|
6
|
-
|
|
7
|
-
import { capitalizeFirstLetter, checkEnvVars, htmlToMd, resolvePath } from './utils/helpers';
|
|
8
|
-
|
|
9
|
-
import Gitlab from './services/Gitlab';
|
|
10
|
-
import { Reporter } from './services/Reporter';
|
|
11
|
-
import { Exception } from './utils/Exception';
|
|
12
|
-
|
|
13
|
-
const ENV = process.env;
|
|
14
|
-
|
|
15
|
-
export type RunCommandHandler = ( prj: Project, reporter: Reporter, opts: OptionValues, config: Config ) => Promise<any>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export interface Config {
|
|
19
|
-
|
|
20
|
-
group?: string
|
|
21
|
-
name?: string
|
|
22
|
-
|
|
23
|
-
rootPath?: string
|
|
24
|
-
|
|
25
|
-
appsPath?: string
|
|
26
|
-
|
|
27
|
-
sharedPaths?: string[];
|
|
28
|
-
ignorePaths?: string[];
|
|
29
|
-
|
|
30
|
-
appFile?: string
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export class Project {
|
|
36
|
-
|
|
37
|
-
// ENV FROM GitLab Runner ---------------
|
|
38
|
-
isRunner = ENV.CI_JOB_ID !== undefined;
|
|
39
|
-
|
|
40
|
-
id = (Number(ENV.CI_PROJECT_ID as unknown as number || 0));
|
|
41
|
-
path = ENV.CI_PROJECT_PATH || ''; // <group>/<project>
|
|
42
|
-
url = ENV.CI_PROJECT_URL || ''; // http://<gitlab>/<group>/<project>
|
|
43
|
-
|
|
44
|
-
name = ENV.CI_PROJECT_NAME || '';
|
|
45
|
-
group = ENV.CI_PROJECT_NAMESPACE || '';
|
|
46
|
-
|
|
47
|
-
// Common proporties ---------------
|
|
48
|
-
rootPath: string = '';
|
|
49
|
-
|
|
50
|
-
build = 0;
|
|
51
|
-
version = '0.0.0';
|
|
52
|
-
stage: string = ENV.CI_COMMIT_REF_NAME || 'dev';
|
|
53
|
-
|
|
54
|
-
$stagesState: Record<string, string> = {};
|
|
55
|
-
|
|
56
|
-
job = {
|
|
57
|
-
|
|
58
|
-
id: ENV.CI_JOB_ID,
|
|
59
|
-
name: ENV.CI_JOB_NAME || 'No Job',
|
|
60
|
-
step: ENV.CI_JOB_STAGE || 'build',
|
|
61
|
-
branch: ENV.CI_COMMIT_REF_NAME || 'dev',
|
|
62
|
-
|
|
63
|
-
url: ENV.CI_JOB_URL || '',
|
|
64
|
-
pipline: ENV.CI_PIPELINE_URL || '',
|
|
65
|
-
|
|
66
|
-
user: {
|
|
67
|
-
ID: ENV.GITLAB_USER_ID || '',
|
|
68
|
-
login: ENV.GITLAB_USER_LOGIN || '',
|
|
69
|
-
name: ENV.GITLAB_USER_NAME || '',
|
|
70
|
-
email: ENV.GITLAB_USER_EMAIL || '',
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
commit:{
|
|
74
|
-
title: ENV.CI_COMMIT_TITLE || '',
|
|
75
|
-
author: {
|
|
76
|
-
name: (ENV.CI_COMMIT_AUTHOR || ' < ').split('<')[0],
|
|
77
|
-
email: ((ENV.CI_COMMIT_AUTHOR || ' < ').split('<')[1] || ' ').replace('>', ''),
|
|
78
|
-
},
|
|
79
|
-
hash: '',
|
|
80
|
-
url: `${ ENV.CI_PROJECT_URL }/-/commit/${ ENV.CI_COMMIT_SHA }`,
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// --------------
|
|
86
|
-
|
|
87
|
-
static async run( opts: OptionValues, runHandler: RunCommandHandler, chekEnv?: string[] ){
|
|
88
|
-
|
|
89
|
-
const ciPkg = JSON.parse( await Shell.cat( __dirname +'/package.json' ) || "{}" );
|
|
90
|
-
log.info( 'Soft-Artel CI v' + ciPkg?.version || 'undefined')
|
|
91
|
-
|
|
92
|
-
let reporter: Reporter | undefined;
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
|
|
96
|
-
// ------------------
|
|
97
|
-
// Проверяем установленыли переменные!
|
|
98
|
-
|
|
99
|
-
checkEnvVars( ['STAGES_STATE', 'REPORTER', 'LAST_BUILD'] );
|
|
100
|
-
|
|
101
|
-
if( chekEnv ){
|
|
102
|
-
checkEnvVars( chekEnv )
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// ------------------
|
|
106
|
-
// Инициализируемся
|
|
107
|
-
log.dbg( 'Command run opts', opts )
|
|
108
|
-
|
|
109
|
-
const prj = new Project(opts.path, opts.stage);
|
|
110
|
-
|
|
111
|
-
const reporterOpts = JSON.parse( ENV.REPORTER! );
|
|
112
|
-
reporterOpts.postTitle = opts.scheme;
|
|
113
|
-
|
|
114
|
-
// Get current version of project
|
|
115
|
-
// 1. JS and TS projects - package.json
|
|
116
|
-
// 2. XCode ?
|
|
117
|
-
|
|
118
|
-
if( await Shell.test('-e', prj.rootPath +'/package.json' ) ){
|
|
119
|
-
|
|
120
|
-
const pkg = JSON.parse(await Shell.cat( prj.rootPath +'/package.json' ) || 'no package.json file!');
|
|
121
|
-
const pkgBuild = Number(pkg.version.split('.')[2]);
|
|
122
|
-
|
|
123
|
-
prj.build = prj.build < pkgBuild ? pkgBuild : prj.build;
|
|
124
|
-
prj.version = `${ pkg.version.split('.').splice(0, 2).join('.') }.${ prj.build }`;
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
else if( await Shell.test('-e', 'XCODE PROJECT PAH' ) ){
|
|
128
|
-
|
|
129
|
-
const scheme = opts.scheme || 'iOS';
|
|
130
|
-
|
|
131
|
-
const xcodeVersion = await Shell.exec(`xcodebuild -showBuildSettings -scheme ${ scheme } | grep MARKETING_VERSION | tr -d 'MARKETING_VERSION = '`, { silent: true });
|
|
132
|
-
const xcodeBuild = Number(await Shell.exec(`xcodebuild -showBuildSettings -scheme ${ scheme } | grep CURRENT_PROJECT_VERSION | tr -d 'CURRENT_PROJECT_VERSION = '`, { silent: true }));
|
|
133
|
-
|
|
134
|
-
prj.build = prj.build < xcodeBuild ? xcodeBuild : prj.build;
|
|
135
|
-
prj.version = `${ xcodeVersion }.${ prj.build }`;
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
else{
|
|
139
|
-
|
|
140
|
-
// Not found any allowed platform
|
|
141
|
-
throw new Exception( 'package.json or xcode project not found on path:' + prj.rootPath )
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
reporter = new Reporter(prj, reporterOpts);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if( await Shell.test('-e', prj.rootPath +'/ci-config.json' ) ){
|
|
149
|
-
|
|
150
|
-
const config = JSON.parse(await Shell.cat( prj.rootPath +'/ci-config.json' ) || 'no ci-config.json file!');
|
|
151
|
-
|
|
152
|
-
prj.rootPath = config.rootPath || prj.rootPath
|
|
153
|
-
prj.group = config.group || prj.group
|
|
154
|
-
prj.name = config.name || prj.name
|
|
155
|
-
|
|
156
|
-
// Запускаем команду
|
|
157
|
-
return await runHandler(prj, reporter, opts, config as Config);
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
else{
|
|
161
|
-
// Not found any allowed platform
|
|
162
|
-
throw new Exception( 'ci-config.json not found on path:' + prj.rootPath )
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
} catch(e){
|
|
169
|
-
|
|
170
|
-
log.error(e);
|
|
171
|
-
|
|
172
|
-
if(reporter){
|
|
173
|
-
try {
|
|
174
|
-
await reporter.fail(e);
|
|
175
|
-
} catch(e2){
|
|
176
|
-
log.error(e2);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
process.exit(1);
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// --------------
|
|
188
|
-
|
|
189
|
-
constructor(workdir: string | undefined, stage?: string){
|
|
190
|
-
this.rootPath = resolvePath(workdir || ENV.CI_PROJECT_DIR || Shell.pwd().toString());
|
|
191
|
-
this.stage = stage || this.stage
|
|
192
|
-
|
|
193
|
-
this.$stagesState = JSON.parse( ENV.STAGES_STATE! );
|
|
194
|
-
|
|
195
|
-
log.dbg('STAGES STATE', this.$stagesState );
|
|
196
|
-
|
|
197
|
-
this.build = Number(ENV.LAST_BUILD) || 0;
|
|
198
|
-
|
|
199
|
-
this.version = '0.0.' + this.build; // Mast init later! [depends fom platform]
|
|
200
|
-
|
|
201
|
-
Shell.cd(this.rootPath);
|
|
202
|
-
log.dbg(`[${this.stage}, ${this.version}] `+this.rootPath);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// --------------
|
|
206
|
-
|
|
207
|
-
get shortVersion(){
|
|
208
|
-
return this.version.split('.').splice(0, 2).join('.');
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
get prevVersion(){
|
|
212
|
-
const pV = this.$stagesState[ this.stage ];
|
|
213
|
-
return pV !== '0.0.0' ? pV : undefined;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// --------------
|
|
217
|
-
|
|
218
|
-
incrementBuild(newBuild?: number){
|
|
219
|
-
if (newBuild) {
|
|
220
|
-
this.build = newBuild;
|
|
221
|
-
} else {
|
|
222
|
-
this.build += 1;
|
|
223
|
-
}
|
|
224
|
-
this.version = `${ this.shortVersion }.${ this.build}`;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// --------------
|
|
228
|
-
|
|
229
|
-
async saveGitLabBuild(){
|
|
230
|
-
await Gitlab.saveVariable(this, 'LAST_BUILD', this.build);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// ----------------
|
|
234
|
-
|
|
235
|
-
async saveGitLabStagesVersions(){
|
|
236
|
-
this.$stagesState[ this.stage ] = this.version;
|
|
237
|
-
await Gitlab.saveVariable(this, 'STAGES_STATE', JSON.stringify(this.$stagesState, null, 3));
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// --------------
|
|
241
|
-
|
|
242
|
-
async updateChangeLog(whatsNewHtml: string, filename = 'CHANGELOG.md') {
|
|
243
|
-
|
|
244
|
-
const filePath = `${ this.rootPath}/${ filename }`;
|
|
245
|
-
|
|
246
|
-
let title = `# ${ capitalizeFirstLetter(this.group) }: **${ this.name.toUpperCase() }**`;
|
|
247
|
-
|
|
248
|
-
log.info(`Update ${filename}:\n${title}`);
|
|
249
|
-
|
|
250
|
-
let changeLog = await Shell.cat(filePath, {silent:true, ignoreError:true}) || '';
|
|
251
|
-
const lines = changeLog.split('\n');
|
|
252
|
-
|
|
253
|
-
if(Array.isArray(lines) && lines.length > 1){
|
|
254
|
-
title = lines.shift() || title;
|
|
255
|
-
changeLog = lines.join('\n');
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const dateTime = new Date().toLocaleString('ru-RU', {
|
|
259
|
-
weekday: 'long',
|
|
260
|
-
year: 'numeric',
|
|
261
|
-
month: 'short',
|
|
262
|
-
day: 'numeric',
|
|
263
|
-
timeZone: 'Europe/Moscow',
|
|
264
|
-
hour12: false,
|
|
265
|
-
hour: 'numeric',
|
|
266
|
-
minute: 'numeric',
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
const whatsNewMd = htmlToMd(whatsNewHtml);
|
|
270
|
-
|
|
271
|
-
changeLog = `${ title }
|
|
272
|
-
## **${ this.version }**
|
|
273
|
-
${ capitalizeFirstLetter(dateTime) }
|
|
274
|
-
|
|
275
|
-
${ whatsNewMd }
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
${ changeLog }
|
|
281
|
-
`;
|
|
282
|
-
|
|
283
|
-
await fsAsync.writeFile(filePath, changeLog, { encoding: 'utf8', flag: 'w+'});
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ts-node
|
|
2
|
-
import { promises as asyncFs } from 'fs';
|
|
3
|
-
import {program} from 'commander';
|
|
4
|
-
|
|
5
|
-
import { resolvePath } from '../utils/helpers';
|
|
6
|
-
import { log } from '../utils/Logger';
|
|
7
|
-
|
|
8
|
-
// ========================================================
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
|
|
12
|
-
program
|
|
13
|
-
.option('--path <path>', 'Path to package.json')
|
|
14
|
-
.option('--build <build>', 'Set <build> number')
|
|
15
|
-
.option('--no-save', 'Print next version only')
|
|
16
|
-
.action(
|
|
17
|
-
async () => {
|
|
18
|
-
try {
|
|
19
|
-
const opts = program.opts() || {};
|
|
20
|
-
|
|
21
|
-
const pkgPath = resolvePath(`${ opts.path ? opts.path : '.' }/package.json`);
|
|
22
|
-
|
|
23
|
-
const pkg = JSON.parse(await asyncFs.readFile(pkgPath, 'utf-8'));
|
|
24
|
-
|
|
25
|
-
const versionArr: string[] = pkg.version.split('.');
|
|
26
|
-
|
|
27
|
-
const major = Number(versionArr[0] || 0);
|
|
28
|
-
const patch = Number(versionArr[1] || 0);
|
|
29
|
-
const build = opts.build || Number(versionArr[2] || 0) + 1;
|
|
30
|
-
|
|
31
|
-
pkg.version = `${major}.${patch}.${build}`;
|
|
32
|
-
|
|
33
|
-
await asyncFs.writeFile(pkgPath, JSON.stringify(pkg, null, 3));
|
|
34
|
-
|
|
35
|
-
process.env.PUBLISH_VERSION = pkg.version;
|
|
36
|
-
|
|
37
|
-
} catch(e){
|
|
38
|
-
log.error(e);
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
await program.parseAsync(process.argv);
|
|
45
|
-
}
|
|
46
|
-
main();
|