@percy/env 1.0.0-beta.9 → 1.0.0
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/package.json +22 -17
- package/dist/dotenv.js +0 -27
- package/dist/environment.js +0 -384
- package/dist/git.js +0 -52
- package/dist/index.js +0 -17
package/package.json
CHANGED
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/env",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "babel --root-mode upward src --out-dir dist",
|
|
11
|
-
"lint": "eslint --ignore-path ../../.gitignore .",
|
|
12
|
-
"test": "cross-env NODE_ENV=test mocha",
|
|
13
|
-
"test:coverage": "nyc yarn test"
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/percy/cli",
|
|
8
|
+
"directory": "packages/env"
|
|
14
9
|
},
|
|
15
10
|
"publishConfig": {
|
|
16
11
|
"access": "public"
|
|
17
12
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=14"
|
|
20
15
|
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
16
|
+
"files": [
|
|
17
|
+
"./dist"
|
|
18
|
+
],
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./dist/index.js",
|
|
23
|
+
"./utils": "./dist/utils.js",
|
|
24
|
+
"./test/helpers": "./test/helpers.js"
|
|
23
25
|
},
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "node ../../scripts/build",
|
|
28
|
+
"lint": "eslint --ignore-path ../../.gitignore .",
|
|
29
|
+
"test": "node ../../scripts/test",
|
|
30
|
+
"test:coverage": "yarn test --coverage"
|
|
26
31
|
},
|
|
27
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "6df509421a60144e4f9f5d59dc57a5675372a0b2"
|
|
28
33
|
}
|
package/dist/dotenv.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.config = config;
|
|
7
|
-
|
|
8
|
-
const dotenv = require('dotenv'); // mimic dotenv-rails file hierarchy
|
|
9
|
-
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function config() {
|
|
13
|
-
let {
|
|
14
|
-
NODE_ENV: env,
|
|
15
|
-
PERCY_DISABLE_DOTENV: disable
|
|
16
|
-
} = process.env; // don't load dotenv files when disabled
|
|
17
|
-
|
|
18
|
-
if (disable) return;
|
|
19
|
-
let paths = [env && `.env.${env}.local`, // .env.local is not loaded in test environments
|
|
20
|
-
env === 'test' ? null : '.env.local', env && `.env.${env}`, '.env'].filter(Boolean);
|
|
21
|
-
|
|
22
|
-
for (let path of paths) {
|
|
23
|
-
dotenv.config({
|
|
24
|
-
path
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
package/dist/environment.js
DELETED
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _git = require("./git");
|
|
9
|
-
|
|
10
|
-
class PercyEnvironment {
|
|
11
|
-
constructor(vars = process.env) {
|
|
12
|
-
this.vars = vars;
|
|
13
|
-
} // used for getter switch statements
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
get ci() {
|
|
17
|
-
if (this.vars.TRAVIS_BUILD_ID) {
|
|
18
|
-
return 'travis';
|
|
19
|
-
} else if (this.vars.JENKINS_URL && this.vars.ghprbPullId) {
|
|
20
|
-
return 'jenkins-prb';
|
|
21
|
-
} else if (this.vars.JENKINS_URL) {
|
|
22
|
-
return 'jenkins';
|
|
23
|
-
} else if (this.vars.CIRCLECI) {
|
|
24
|
-
return 'circle';
|
|
25
|
-
} else if (this.vars.CI_NAME === 'codeship') {
|
|
26
|
-
return 'codeship';
|
|
27
|
-
} else if (this.vars.DRONE === 'true') {
|
|
28
|
-
return 'drone';
|
|
29
|
-
} else if (this.vars.SEMAPHORE === 'true') {
|
|
30
|
-
return 'semaphore';
|
|
31
|
-
} else if (this.vars.BUILDKITE === 'true') {
|
|
32
|
-
return 'buildkite';
|
|
33
|
-
} else if (this.vars.HEROKU_TEST_RUN_ID) {
|
|
34
|
-
return 'heroku';
|
|
35
|
-
} else if (this.vars.GITLAB_CI === 'true') {
|
|
36
|
-
return 'gitlab';
|
|
37
|
-
} else if (this.vars.TF_BUILD === 'True') {
|
|
38
|
-
return 'azure';
|
|
39
|
-
} else if (this.vars.APPVEYOR === 'True' || this.vars.APPVEYOR === 'true') {
|
|
40
|
-
return 'appveyor';
|
|
41
|
-
} else if (this.vars.PROBO_ENVIRONMENT === 'TRUE') {
|
|
42
|
-
return 'probo';
|
|
43
|
-
} else if (this.vars.BITBUCKET_BUILD_NUMBER) {
|
|
44
|
-
return 'bitbucket';
|
|
45
|
-
} else if (this.vars.GITHUB_ACTIONS === 'true') {
|
|
46
|
-
return 'github';
|
|
47
|
-
} else if (this.vars.NETLIFY === 'true') {
|
|
48
|
-
return 'netlify';
|
|
49
|
-
} else if (this.vars.CI) {
|
|
50
|
-
return 'CI/unknown';
|
|
51
|
-
} else {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
} // environment info reported in user-agents
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
get info() {
|
|
58
|
-
var _this$vars$PERCY_GITH;
|
|
59
|
-
|
|
60
|
-
switch (this.ci) {
|
|
61
|
-
case 'github':
|
|
62
|
-
return `github/${(_this$vars$PERCY_GITH = this.vars.PERCY_GITHUB_ACTION) !== null && _this$vars$PERCY_GITH !== void 0 ? _this$vars$PERCY_GITH : 'unknown'}`;
|
|
63
|
-
|
|
64
|
-
case 'gitlab':
|
|
65
|
-
return `gitlab/${this.vars.CI_SERVER_VERSION}`;
|
|
66
|
-
|
|
67
|
-
case 'semaphore':
|
|
68
|
-
return this.vars.SEMAPHORE_GIT_SHA ? 'semaphore/2.0' : 'semaphore';
|
|
69
|
-
|
|
70
|
-
default:
|
|
71
|
-
return this.ci;
|
|
72
|
-
}
|
|
73
|
-
} // current commit sha
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
get commit() {
|
|
77
|
-
if (this.vars.PERCY_COMMIT) {
|
|
78
|
-
return this.vars.PERCY_COMMIT;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
let commit = (() => {
|
|
82
|
-
switch (this.ci) {
|
|
83
|
-
case 'travis':
|
|
84
|
-
return this.vars.TRAVIS_COMMIT;
|
|
85
|
-
|
|
86
|
-
case 'jenkins-prb':
|
|
87
|
-
return this.vars.ghprbActualCommit || this.vars.GIT_COMMIT;
|
|
88
|
-
|
|
89
|
-
case 'jenkins':
|
|
90
|
-
return (0, _git.getJenkinsSha)() || this.vars.GIT_COMMIT;
|
|
91
|
-
|
|
92
|
-
case 'circle':
|
|
93
|
-
return this.vars.CIRCLE_SHA1;
|
|
94
|
-
|
|
95
|
-
case 'codeship':
|
|
96
|
-
return this.vars.CI_COMMIT_ID;
|
|
97
|
-
|
|
98
|
-
case 'drone':
|
|
99
|
-
return this.vars.DRONE_COMMIT;
|
|
100
|
-
|
|
101
|
-
case 'semaphore':
|
|
102
|
-
return this.vars.REVISION || this.vars.SEMAPHORE_GIT_PR_SHA || this.vars.SEMAPHORE_GIT_SHA;
|
|
103
|
-
|
|
104
|
-
case 'buildkite':
|
|
105
|
-
return this.vars.BUILDKITE_COMMIT !== 'HEAD' && this.vars.BUILDKITE_COMMIT;
|
|
106
|
-
|
|
107
|
-
case 'heroku':
|
|
108
|
-
return this.vars.HEROKU_TEST_RUN_COMMIT_VERSION;
|
|
109
|
-
|
|
110
|
-
case 'gitlab':
|
|
111
|
-
return this.vars.CI_COMMIT_SHA;
|
|
112
|
-
|
|
113
|
-
case 'azure':
|
|
114
|
-
return this.vars.SYSTEM_PULLREQUEST_SOURCECOMMITID || this.vars.BUILD_SOURCEVERSION;
|
|
115
|
-
|
|
116
|
-
case 'appveyor':
|
|
117
|
-
return this.vars.APPVEYOR_PULL_REQUEST_HEAD_COMMIT || this.vars.APPVEYOR_REPO_COMMIT;
|
|
118
|
-
|
|
119
|
-
case 'probo':
|
|
120
|
-
case 'netlify':
|
|
121
|
-
return this.vars.COMMIT_REF;
|
|
122
|
-
|
|
123
|
-
case 'bitbucket':
|
|
124
|
-
return this.vars.BITBUCKET_COMMIT;
|
|
125
|
-
|
|
126
|
-
case 'github':
|
|
127
|
-
return this.vars.GITHUB_SHA;
|
|
128
|
-
}
|
|
129
|
-
})();
|
|
130
|
-
|
|
131
|
-
return commit || null;
|
|
132
|
-
} // current branch name
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
get branch() {
|
|
136
|
-
if (this.vars.PERCY_BRANCH) {
|
|
137
|
-
return this.vars.PERCY_BRANCH;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
let branch = (() => {
|
|
141
|
-
var _this$vars$GITHUB_REF;
|
|
142
|
-
|
|
143
|
-
switch (this.ci) {
|
|
144
|
-
case 'travis':
|
|
145
|
-
return this.pullRequest && this.vars.TRAVIS_PULL_REQUEST_BRANCH || this.vars.TRAVIS_BRANCH;
|
|
146
|
-
|
|
147
|
-
case 'jenkins-prb':
|
|
148
|
-
return this.vars.ghprbSourceBranch;
|
|
149
|
-
|
|
150
|
-
case 'jenkins':
|
|
151
|
-
return this.vars.CHANGE_BRANCH || this.vars.GIT_BRANCH;
|
|
152
|
-
|
|
153
|
-
case 'circle':
|
|
154
|
-
return this.vars.CIRCLE_BRANCH;
|
|
155
|
-
|
|
156
|
-
case 'codeship':
|
|
157
|
-
return this.vars.CI_BRANCH;
|
|
158
|
-
|
|
159
|
-
case 'drone':
|
|
160
|
-
return this.vars.DRONE_BRANCH;
|
|
161
|
-
|
|
162
|
-
case 'semaphore':
|
|
163
|
-
return this.vars.BRANCH_NAME || this.vars.SEMAPHORE_GIT_PR_BRANCH || this.vars.SEMAPHORE_GIT_BRANCH;
|
|
164
|
-
|
|
165
|
-
case 'buildkite':
|
|
166
|
-
return this.vars.BUILDKITE_BRANCH;
|
|
167
|
-
|
|
168
|
-
case 'heroku':
|
|
169
|
-
return this.vars.HEROKU_TEST_RUN_BRANCH;
|
|
170
|
-
|
|
171
|
-
case 'gitlab':
|
|
172
|
-
return this.vars.CI_COMMIT_REF_NAME;
|
|
173
|
-
|
|
174
|
-
case 'azure':
|
|
175
|
-
return this.vars.SYSTEM_PULLREQUEST_SOURCEBRANCH || this.vars.BUILD_SOURCEBRANCHNAME;
|
|
176
|
-
|
|
177
|
-
case 'appveyor':
|
|
178
|
-
return this.vars.APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH || this.vars.APPVEYOR_REPO_BRANCH;
|
|
179
|
-
|
|
180
|
-
case 'probo':
|
|
181
|
-
return this.vars.BRANCH_NAME;
|
|
182
|
-
|
|
183
|
-
case 'bitbucket':
|
|
184
|
-
return this.vars.BITBUCKET_BRANCH;
|
|
185
|
-
|
|
186
|
-
case 'github':
|
|
187
|
-
return ((_this$vars$GITHUB_REF = this.vars.GITHUB_REF) === null || _this$vars$GITHUB_REF === void 0 ? void 0 : _this$vars$GITHUB_REF.match(/^refs\//)) ? this.vars.GITHUB_REF.replace(/^refs\/\w+?\//, '') : this.vars.GITHUB_REF;
|
|
188
|
-
|
|
189
|
-
case 'netlify':
|
|
190
|
-
return this.vars.HEAD;
|
|
191
|
-
}
|
|
192
|
-
})();
|
|
193
|
-
|
|
194
|
-
return branch || null;
|
|
195
|
-
} // pull request number
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
get pullRequest() {
|
|
199
|
-
if (this.vars.PERCY_PULL_REQUEST) {
|
|
200
|
-
return this.vars.PERCY_PULL_REQUEST;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
let pr = (() => {
|
|
204
|
-
var _this$vars$CI_PULL_RE, _this$vars$PULL_REQUE;
|
|
205
|
-
|
|
206
|
-
switch (this.ci) {
|
|
207
|
-
case 'travis':
|
|
208
|
-
return this.vars.TRAVIS_PULL_REQUEST !== 'false' && this.vars.TRAVIS_PULL_REQUEST;
|
|
209
|
-
|
|
210
|
-
case 'jenkins-prb':
|
|
211
|
-
return this.vars.ghprbPullId;
|
|
212
|
-
|
|
213
|
-
case 'jenkins':
|
|
214
|
-
return this.vars.CHANGE_ID;
|
|
215
|
-
|
|
216
|
-
case 'circle':
|
|
217
|
-
return (_this$vars$CI_PULL_RE = this.vars.CI_PULL_REQUESTS) === null || _this$vars$CI_PULL_RE === void 0 ? void 0 : _this$vars$CI_PULL_RE.split('/').slice(-1)[0];
|
|
218
|
-
|
|
219
|
-
case 'drone':
|
|
220
|
-
return this.vars.CI_PULL_REQUEST;
|
|
221
|
-
|
|
222
|
-
case 'semaphore':
|
|
223
|
-
return this.vars.PULL_REQUEST_NUMBER || this.vars.SEMAPHORE_GIT_PR_NUMBER;
|
|
224
|
-
|
|
225
|
-
case 'buildkite':
|
|
226
|
-
return this.vars.BUILDKITE_PULL_REQUEST !== 'false' && this.vars.BUILDKITE_PULL_REQUEST;
|
|
227
|
-
|
|
228
|
-
case 'gitlab':
|
|
229
|
-
return this.vars.CI_MERGE_REQUEST_IID;
|
|
230
|
-
|
|
231
|
-
case 'azure':
|
|
232
|
-
return this.vars.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER;
|
|
233
|
-
|
|
234
|
-
case 'appveyor':
|
|
235
|
-
return this.vars.APPVEYOR_PULL_REQUEST_NUMBER;
|
|
236
|
-
|
|
237
|
-
case 'probo':
|
|
238
|
-
return (_this$vars$PULL_REQUE = this.vars.PULL_REQUEST_LINK) === null || _this$vars$PULL_REQUE === void 0 ? void 0 : _this$vars$PULL_REQUE.split('/').slice(-1)[0];
|
|
239
|
-
|
|
240
|
-
case 'bitbucket':
|
|
241
|
-
return this.vars.BITBUCKET_PR_ID;
|
|
242
|
-
|
|
243
|
-
case 'netlify':
|
|
244
|
-
return this.vars.PULL_REQUEST !== 'false' && this.vars.REVIEW_ID;
|
|
245
|
-
}
|
|
246
|
-
})();
|
|
247
|
-
|
|
248
|
-
return pr || null;
|
|
249
|
-
} // parallel nonce & total
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
get parallel() {
|
|
253
|
-
let nonce = (() => {
|
|
254
|
-
var _this$vars$BUILD_TAG;
|
|
255
|
-
|
|
256
|
-
if (this.vars.PERCY_PARALLEL_NONCE) {
|
|
257
|
-
return this.vars.PERCY_PARALLEL_NONCE;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
switch (this.ci) {
|
|
261
|
-
case 'travis':
|
|
262
|
-
return this.vars.TRAVIS_BUILD_NUMBER;
|
|
263
|
-
|
|
264
|
-
case 'jenkins-prb':
|
|
265
|
-
return this.vars.BUILD_NUMBER;
|
|
266
|
-
|
|
267
|
-
case 'jenkins':
|
|
268
|
-
return (_this$vars$BUILD_TAG = this.vars.BUILD_TAG) === null || _this$vars$BUILD_TAG === void 0 ? void 0 : _this$vars$BUILD_TAG.split('').reverse().join('').substring(0, 60);
|
|
269
|
-
|
|
270
|
-
case 'circle':
|
|
271
|
-
return this.vars.CIRCLE_WORKFLOW_ID || this.vars.CIRCLE_BUILD_NUM;
|
|
272
|
-
|
|
273
|
-
case 'codeship':
|
|
274
|
-
return this.vars.CI_BUILD_NUMBER || this.vars.CI_BUILD_ID;
|
|
275
|
-
|
|
276
|
-
case 'drone':
|
|
277
|
-
return this.vars.DRONE_BUILD_NUMBER;
|
|
278
|
-
|
|
279
|
-
case 'semaphore':
|
|
280
|
-
return this.vars.SEMAPHORE_WORKFLOW_ID || `${this.vars.SEMAPHORE_BRANCH_ID}/${this.vars.SEMAPHORE_BUILD_NUMBER}`;
|
|
281
|
-
|
|
282
|
-
case 'buildkite':
|
|
283
|
-
return this.vars.BUILDKITE_BUILD_ID;
|
|
284
|
-
|
|
285
|
-
case 'heroku':
|
|
286
|
-
return this.vars.HEROKU_TEST_RUN_ID;
|
|
287
|
-
|
|
288
|
-
case 'gitlab':
|
|
289
|
-
return this.vars.CI_PIPELINE_ID;
|
|
290
|
-
|
|
291
|
-
case 'azure':
|
|
292
|
-
return this.vars.BUILD_BUILDID;
|
|
293
|
-
|
|
294
|
-
case 'appveyor':
|
|
295
|
-
return this.vars.APPVEYOR_BUILD_ID;
|
|
296
|
-
|
|
297
|
-
case 'probo':
|
|
298
|
-
return this.vars.BUILD_ID;
|
|
299
|
-
|
|
300
|
-
case 'bitbucket':
|
|
301
|
-
return this.vars.BITBUCKET_BUILD_NUMBER;
|
|
302
|
-
}
|
|
303
|
-
})();
|
|
304
|
-
|
|
305
|
-
let total = (() => {
|
|
306
|
-
if (this.vars.PERCY_PARALLEL_TOTAL) {
|
|
307
|
-
return this.vars.PERCY_PARALLEL_TOTAL;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
switch (this.ci) {
|
|
311
|
-
case 'travis':
|
|
312
|
-
return this.vars.CI_NODE_TOTAL;
|
|
313
|
-
|
|
314
|
-
case 'circle':
|
|
315
|
-
return this.vars.CIRCLE_NODE_TOTAL;
|
|
316
|
-
|
|
317
|
-
case 'codeship':
|
|
318
|
-
return this.vars.CI_NODE_TOTAL;
|
|
319
|
-
|
|
320
|
-
case 'semaphore':
|
|
321
|
-
return this.vars.SEMAPHORE_THREAD_COUNT;
|
|
322
|
-
|
|
323
|
-
case 'buildkite':
|
|
324
|
-
return this.vars.BUILDKITE_PARALLEL_JOB_COUNT;
|
|
325
|
-
|
|
326
|
-
case 'heroku':
|
|
327
|
-
return this.vars.CI_NODE_TOTAL;
|
|
328
|
-
|
|
329
|
-
case 'azure':
|
|
330
|
-
// SYSTEM_TOTALJOBSINPHASE is set for parallel builds and non-parallel matrix builds, so
|
|
331
|
-
// check build strategy is parallel by ensuring SYSTEM_PARALLELEXECUTIONTYPE == MultiMachine
|
|
332
|
-
return this.vars.SYSTEM_PARALLELEXECUTIONTYPE === 'MultiMachine' && this.vars.SYSTEM_TOTALJOBSINPHASE;
|
|
333
|
-
}
|
|
334
|
-
})();
|
|
335
|
-
|
|
336
|
-
return {
|
|
337
|
-
nonce: nonce || null,
|
|
338
|
-
total: total ? parseInt(total) : null
|
|
339
|
-
};
|
|
340
|
-
} // git information for the current commit
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
get git() {
|
|
344
|
-
return (0, _git.getCommitData)(this.commit, this.branch, this.vars);
|
|
345
|
-
} // manually set build commit and branch targets
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
get target() {
|
|
349
|
-
return {
|
|
350
|
-
commit: this.vars.PERCY_TARGET_COMMIT || null,
|
|
351
|
-
branch: this.vars.PERCY_TARGET_BRANCH || null
|
|
352
|
-
};
|
|
353
|
-
} // build marked as partial
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
get partial() {
|
|
357
|
-
let partial = this.vars.PERCY_PARTIAL_BUILD;
|
|
358
|
-
return !!partial && partial !== '0';
|
|
359
|
-
} // percy token
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
get token() {
|
|
363
|
-
return this.vars.PERCY_TOKEN || null;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
} // cache getters on initial call so subsequent calls are not re-computed
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
exports.default = PercyEnvironment;
|
|
370
|
-
Object.defineProperties(PercyEnvironment.prototype, Object.entries(Object.getOwnPropertyDescriptors(PercyEnvironment.prototype)).reduce((proto, [key, {
|
|
371
|
-
get,
|
|
372
|
-
...descr
|
|
373
|
-
}]) => !get ? proto : Object.assign(proto, {
|
|
374
|
-
[key]: Object.assign(descr, {
|
|
375
|
-
get() {
|
|
376
|
-
let value = get.call(this);
|
|
377
|
-
Object.defineProperty(this, key, {
|
|
378
|
-
value
|
|
379
|
-
});
|
|
380
|
-
return value;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
})
|
|
384
|
-
}), {}));
|
package/dist/git.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.git = git;
|
|
7
|
-
exports.getCommitData = getCommitData;
|
|
8
|
-
exports.getJenkinsSha = getJenkinsSha;
|
|
9
|
-
|
|
10
|
-
var _child_process = require("child_process");
|
|
11
|
-
|
|
12
|
-
const GIT_COMMIT_FORMAT = ['COMMIT_SHA:%H', 'AUTHOR_NAME:%an', 'AUTHOR_EMAIL:%ae', 'COMMITTER_NAME:%cn', 'COMMITTER_EMAIL:%ce', 'COMMITTED_DATE:%ai', // order is important, this must come last because the regex is a multiline match.
|
|
13
|
-
'COMMIT_MESSAGE:%B'].join('%n'); // git show format uses %n for newlines.
|
|
14
|
-
|
|
15
|
-
function git(args) {
|
|
16
|
-
try {
|
|
17
|
-
return (0, _child_process.execSync)(`git ${args}`, {
|
|
18
|
-
encoding: 'utf-8'
|
|
19
|
-
});
|
|
20
|
-
} catch (e) {// do something?
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return '';
|
|
24
|
-
} // get raw commit data
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function getCommitData(sha, branch, vars = {}) {
|
|
28
|
-
let raw = git(`show ${sha || 'HEAD'} --quiet --format=${GIT_COMMIT_FORMAT}`); // prioritize PERCY_GIT_* vars and fallback to GIT_* vars
|
|
29
|
-
|
|
30
|
-
let get = key => {
|
|
31
|
-
var _raw$match;
|
|
32
|
-
|
|
33
|
-
return vars[`PERCY_GIT_${key}`] || ((_raw$match = raw.match(new RegExp(`${key}:(.*)`, 'm'))) === null || _raw$match === void 0 ? void 0 : _raw$match[1]) || vars[`GIT_${key}`] || null;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
sha: (sha === null || sha === void 0 ? void 0 : sha.length) === 40 ? sha : get('COMMIT_SHA'),
|
|
38
|
-
branch: branch || git('rev-parse --abbrev-ref HEAD') || null,
|
|
39
|
-
message: get('COMMIT_MESSAGE'),
|
|
40
|
-
authorName: get('AUTHOR_NAME'),
|
|
41
|
-
authorEmail: get('AUTHOR_EMAIL'),
|
|
42
|
-
committedAt: get('COMMITTED_DATE'),
|
|
43
|
-
committerName: get('COMMITTER_NAME'),
|
|
44
|
-
committerEmail: get('COMMITTER_EMAIL')
|
|
45
|
-
};
|
|
46
|
-
} // the sha needed from Jenkins merge commits is the parent sha
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function getJenkinsSha() {
|
|
50
|
-
let data = getCommitData();
|
|
51
|
-
return data.authorName === 'Jenkins' && data.authorEmail === 'nobody@nowhere' && data.message.match(/^Merge commit [^\s]+ into HEAD$/) && git('rev-parse HEAD^');
|
|
52
|
-
}
|
package/dist/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _environment.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
var _environment = _interopRequireDefault(require("./environment"));
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
require('./dotenv').config();
|