@serenity-js/serenity-bdd 3.10.4 → 3.11.1
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/CHANGELOG.md +19 -0
- package/lib/cli/commands/update.d.ts.map +1 -1
- package/lib/cli/commands/update.js +32 -2
- package/lib/cli/commands/update.js.map +1 -1
- package/lib/cli/io/index.d.ts +0 -1
- package/lib/cli/io/index.d.ts.map +1 -1
- package/lib/cli/io/index.js +0 -1
- package/lib/cli/io/index.js.map +1 -1
- package/lib/cli/stage/UpdateCommandActors.d.ts +3 -3
- package/lib/cli/stage/UpdateCommandActors.d.ts.map +1 -1
- package/lib/cli/stage/UpdateCommandActors.js +3 -3
- package/lib/cli/stage/UpdateCommandActors.js.map +1 -1
- package/package.json +8 -8
- package/src/cli/commands/update.ts +11 -3
- package/src/cli/io/index.ts +0 -1
- package/src/cli/stage/UpdateCommandActors.ts +4 -4
- package/lib/cli/io/axiosClient.d.ts +0 -20
- package/lib/cli/io/axiosClient.d.ts.map +0 -1
- package/lib/cli/io/axiosClient.js +0 -153
- package/lib/cli/io/axiosClient.js.map +0 -1
- package/src/cli/io/axiosClient.ts +0 -162
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.11.1](https://github.com/serenity-js/serenity-js/compare/v3.11.0...v3.11.1) (2023-10-04)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @serenity-js/serenity-bdd
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.11.0](https://github.com/serenity-js/serenity-js/compare/v3.10.4...v3.11.0) (2023-10-03)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **serenity-bdd:** serenity-bdd downloader will now automatically detect proxy server configuration ([c221210](https://github.com/serenity-js/serenity-js/commit/c221210c95753a518621b5e97f6e037fa9383be1)), closes [#1949](https://github.com/serenity-js/serenity-js/issues/1949)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [3.10.4](https://github.com/serenity-js/serenity-js/compare/v3.10.3...v3.10.4) (2023-09-22)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @serenity-js/serenity-bdd
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;oBAmCV,IAAI,KAAG,QAAQ,IAAI,CAAC;;AAzB9C,kBAyEE"}
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
const assertions_1 = require("@serenity-js/assertions");
|
|
3
26
|
const core_1 = require("@serenity-js/core");
|
|
4
27
|
const io_1 = require("@serenity-js/core/lib/io");
|
|
28
|
+
const https = __importStar(require("https"));
|
|
5
29
|
const url_1 = require("url");
|
|
6
30
|
const defaults_1 = require("../defaults");
|
|
7
31
|
const io_2 = require("../io");
|
|
@@ -36,9 +60,15 @@ module.exports = {
|
|
|
36
60
|
},
|
|
37
61
|
},
|
|
38
62
|
handler: async (argv) => {
|
|
39
|
-
const printer = new Printer_1.Printer(process.stdout, process.stderr), artifactGAV = model_1.GAV.fromString(argv.artifact), pathToArtifact = new io_1.Path(argv.cacheDir).join(artifactGAV.toPath()), repository = new url_1.URL(argv.repository);
|
|
63
|
+
const printer = new Printer_1.Printer(process.stdout, process.stderr), artifactGAV = model_1.GAV.fromString(argv.artifact), pathToArtifact = new io_1.Path(argv.cacheDir).join(artifactGAV.toPath()), repository = new url_1.URL(argv.repository), ignoreSSL = Boolean(argv.ignoreSSL);
|
|
40
64
|
(0, core_1.configure)({
|
|
41
|
-
actors: new stage_1.UpdateCommandActors(new io_1.Path(process.cwd()),
|
|
65
|
+
actors: new stage_1.UpdateCommandActors(new io_1.Path(process.cwd()), {
|
|
66
|
+
baseURL: repository.toString(),
|
|
67
|
+
auth: model_1.Credentials.fromString(argv.auth).toJSON(),
|
|
68
|
+
httpsAgent: ignoreSSL
|
|
69
|
+
? new https.Agent({ rejectUnauthorized: !ignoreSSL })
|
|
70
|
+
: undefined,
|
|
71
|
+
}),
|
|
42
72
|
crew: [
|
|
43
73
|
new stage_1.NotificationReporter(printer),
|
|
44
74
|
new stage_1.ProgressReporter(printer),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAiD;AACjD,4CAAkE;AAClE,iDAAgD;AAChD,6CAA+B;AAC/B,6BAA0B;AAG1B,0CAAuC;AACvC,8BAAoC;AACpC,oCAA4C;AAC5C,wCAAqC;AACrC,8CAAqE;AACrE,oCAAuF;AAEvF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,yDAAyD;AAEzF,iBAAS;IACL,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,sEAAsE;IAC5E,OAAO,EAAE;QACL,QAAQ,EAAE;YACN,OAAO,EAAI,mBAAQ,CAAC,QAAQ;YAC5B,QAAQ,EAAE,yEAAyE;SACtF;QACD,SAAS,EAAE;YACP,OAAO,EAAI,KAAK;YAChB,IAAI,EAAM,SAAS;YACnB,QAAQ,EAAE,yBAAyB;SACtC;QACD,UAAU,EAAE;YACR,OAAO,EAAI,mBAAQ,CAAC,UAAU;YAC9B,QAAQ,EAAE,6EAA6E;SAC1F;QACD,IAAI,EAAE;YACF,QAAQ,EAAE,4EAA4E;SACzF;QACD,QAAQ,EAAE;YACN,OAAO,EAAI,mBAAQ,CAAC,QAAQ;YAC5B,QAAQ,EAAE,oIAAoI;SACjJ;KACJ;IACD,OAAO,EAAE,KAAK,EAAE,IAAU,EAAiB,EAAE;QAEzC,MACI,OAAO,GAAG,IAAI,iBAAO,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,EACrD,WAAW,GAAG,WAAG,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAC3C,cAA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KAAK,CAAC,OAAO,EAAE,CAAC;SACzB;QACD,OAAO,KAAK,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,IAAA,gBAAW,EAAC,KAAK,CAAC,CAAC,CAAC;YAClC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;SAChC;IACL,CAAC;CACJ,CAAC"}
|
package/lib/cli/io/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/io/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/io/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
package/lib/cli/io/index.js
CHANGED
|
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./axiosClient"), exports);
|
|
18
17
|
__exportStar(require("./formatError"), exports);
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
package/lib/cli/io/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/io/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/io/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Actor, Cast } from '@serenity-js/core';
|
|
2
2
|
import type { Path } from '@serenity-js/core/lib/io';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AxiosRequestConfigDefaults } from '@serenity-js/rest';
|
|
4
4
|
/**
|
|
5
5
|
* @package
|
|
6
6
|
*/
|
|
7
7
|
export declare class UpdateCommandActors implements Cast {
|
|
8
8
|
private readonly cwd;
|
|
9
|
-
private readonly
|
|
10
|
-
constructor(cwd: Path,
|
|
9
|
+
private readonly axiosConfigDefaults;
|
|
10
|
+
constructor(cwd: Path, axiosConfigDefaults: AxiosRequestConfigDefaults);
|
|
11
11
|
prepare(actor: Actor): Actor;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=UpdateCommandActors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateCommandActors.d.ts","sourceRoot":"","sources":["../../../src/cli/stage/UpdateCommandActors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"UpdateCommandActors.d.ts","sourceRoot":"","sources":["../../../src/cli/stage/UpdateCommandActors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,0BAA0B,EAAC,MAAM,mBAAmB,CAAC;AAKnE;;GAEG;AACH,qBAAa,mBAAoB,YAAW,IAAI;IAExC,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,mBAAmB;gBADnB,GAAG,EAAE,IAAI,EACT,mBAAmB,EAAE,0BAA0B;IAIpE,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;CAO/B"}
|
|
@@ -8,12 +8,12 @@ const screenplay_1 = require("../screenplay");
|
|
|
8
8
|
* @package
|
|
9
9
|
*/
|
|
10
10
|
class UpdateCommandActors {
|
|
11
|
-
constructor(cwd,
|
|
11
|
+
constructor(cwd, axiosConfigDefaults) {
|
|
12
12
|
this.cwd = cwd;
|
|
13
|
-
this.
|
|
13
|
+
this.axiosConfigDefaults = axiosConfigDefaults;
|
|
14
14
|
}
|
|
15
15
|
prepare(actor) {
|
|
16
|
-
return actor.whoCan(rest_1.CallAnApi.using(this.
|
|
16
|
+
return actor.whoCan(rest_1.CallAnApi.using(this.axiosConfigDefaults), screenplay_1.UseFileSystem.at(this.cwd), core_1.TakeNotes.usingAnEmptyNotepad());
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.UpdateCommandActors = UpdateCommandActors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateCommandActors.js","sourceRoot":"","sources":["../../../src/cli/stage/UpdateCommandActors.ts"],"names":[],"mappings":";;;AACA,4CAA8C;
|
|
1
|
+
{"version":3,"file":"UpdateCommandActors.js","sourceRoot":"","sources":["../../../src/cli/stage/UpdateCommandActors.ts"],"names":[],"mappings":";;;AACA,4CAA8C;AAG9C,4CAA8C;AAE9C,8CAA8C;AAE9C;;GAEG;AACH,MAAa,mBAAmB;IAC5B,YACqB,GAAS,EACT,mBAA+C;QAD/C,QAAG,GAAH,GAAG,CAAM;QACT,wBAAmB,GAAnB,mBAAmB,CAA4B;IAEpE,CAAC;IAED,OAAO,CAAC,KAAY;QAChB,OAAO,KAAK,CAAC,MAAM,CACf,gBAAS,CAAC,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,EACzC,0BAAa,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAC1B,gBAAS,CAAC,mBAAmB,EAAE,CAClC,CAAC;IACN,CAAC;CACJ;AAdD,kDAcC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/serenity-bdd",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "Serenity BDD reporter for Serenity/JS",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"node": "^16.13 || ^18.12 || ^20"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@serenity-js/assertions": "3.
|
|
49
|
-
"@serenity-js/core": "3.
|
|
50
|
-
"@serenity-js/rest": "3.
|
|
48
|
+
"@serenity-js/assertions": "3.11.1",
|
|
49
|
+
"@serenity-js/core": "3.11.1",
|
|
50
|
+
"@serenity-js/rest": "3.11.1",
|
|
51
51
|
"ansi-regex": "^5.0.1",
|
|
52
|
-
"axios": "^1.5.
|
|
52
|
+
"axios": "^1.5.1",
|
|
53
53
|
"chalk": "^4.1.2",
|
|
54
54
|
"find-java-home": "^2.0.0",
|
|
55
55
|
"https-proxy-agent": "^7.0.2",
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@integration/testing-tools": "3.0.0",
|
|
63
63
|
"@types/chai": "^4.3.6",
|
|
64
|
-
"@types/mocha": "^10.0.
|
|
64
|
+
"@types/mocha": "^10.0.2",
|
|
65
65
|
"@types/progress": "^2.0.5",
|
|
66
66
|
"c8": "8.0.1",
|
|
67
67
|
"if-env": "^1.0.4",
|
|
68
|
-
"memfs": "^4.
|
|
68
|
+
"memfs": "^4.5.0",
|
|
69
69
|
"mocha": "^10.2.0",
|
|
70
70
|
"mocha-multi": "^1.1.7",
|
|
71
71
|
"ts-node": "^10.9.1",
|
|
72
72
|
"typescript": "5.1.6"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "b3e36f6e42eb2c545afa961946469fb6dd93f4df"
|
|
75
75
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { isTrue } from '@serenity-js/assertions';
|
|
2
2
|
import { actorCalled, Check, configure } from '@serenity-js/core';
|
|
3
3
|
import { Path } from '@serenity-js/core/lib/io';
|
|
4
|
+
import * as https from 'https';
|
|
4
5
|
import { URL } from 'url';
|
|
5
6
|
|
|
6
7
|
import type { Argv } from '../Argv';
|
|
7
8
|
import { defaults } from '../defaults';
|
|
8
|
-
import {
|
|
9
|
+
import { formatError } from '../io';
|
|
9
10
|
import { Credentials, GAV } from '../model';
|
|
10
11
|
import { Printer } from '../Printer';
|
|
11
12
|
import { DownloadArtifact, FileExists, Notify } from '../screenplay';
|
|
@@ -44,12 +45,19 @@ export = {
|
|
|
44
45
|
printer = new Printer(process.stdout, process.stderr),
|
|
45
46
|
artifactGAV = GAV.fromString(argv.artifact),
|
|
46
47
|
pathToArtifact = new Path(argv.cacheDir).join(artifactGAV.toPath()),
|
|
47
|
-
repository = new URL(argv.repository)
|
|
48
|
+
repository = new URL(argv.repository),
|
|
49
|
+
ignoreSSL = Boolean(argv.ignoreSSL);
|
|
48
50
|
|
|
49
51
|
configure({
|
|
50
52
|
actors: new UpdateCommandActors(
|
|
51
53
|
new Path(process.cwd()),
|
|
52
|
-
|
|
54
|
+
{
|
|
55
|
+
baseURL: repository.toString(),
|
|
56
|
+
auth: Credentials.fromString(argv.auth).toJSON() as { username: string, password: string } | undefined,
|
|
57
|
+
httpsAgent: ignoreSSL
|
|
58
|
+
? new https.Agent({ rejectUnauthorized: ! ignoreSSL })
|
|
59
|
+
: undefined,
|
|
60
|
+
}
|
|
53
61
|
),
|
|
54
62
|
crew: [
|
|
55
63
|
new NotificationReporter(printer),
|
package/src/cli/io/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Actor, Cast} from '@serenity-js/core';
|
|
1
|
+
import type { Actor, Cast } from '@serenity-js/core';
|
|
2
2
|
import { TakeNotes } from '@serenity-js/core';
|
|
3
3
|
import type { Path } from '@serenity-js/core/lib/io';
|
|
4
|
+
import type { AxiosRequestConfigDefaults} from '@serenity-js/rest';
|
|
4
5
|
import { CallAnApi } from '@serenity-js/rest';
|
|
5
|
-
import type { AxiosInstance } from 'axios';
|
|
6
6
|
|
|
7
7
|
import { UseFileSystem } from '../screenplay';
|
|
8
8
|
|
|
@@ -12,13 +12,13 @@ import { UseFileSystem } from '../screenplay';
|
|
|
12
12
|
export class UpdateCommandActors implements Cast {
|
|
13
13
|
constructor(
|
|
14
14
|
private readonly cwd: Path,
|
|
15
|
-
private readonly
|
|
15
|
+
private readonly axiosConfigDefaults: AxiosRequestConfigDefaults,
|
|
16
16
|
){
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
prepare(actor: Actor): Actor {
|
|
20
20
|
return actor.whoCan(
|
|
21
|
-
CallAnApi.using(this.
|
|
21
|
+
CallAnApi.using(this.axiosConfigDefaults),
|
|
22
22
|
UseFileSystem.at(this.cwd),
|
|
23
23
|
TakeNotes.usingAnEmptyNotepad(),
|
|
24
24
|
);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { AxiosInstance } from 'axios';
|
|
3
|
-
import { URL } from 'url';
|
|
4
|
-
import type { Credentials } from '../model';
|
|
5
|
-
/**
|
|
6
|
-
* @package
|
|
7
|
-
*/
|
|
8
|
-
export declare function axiosClient(repository: URL, ignoreSsl: boolean, env: {
|
|
9
|
-
[key: string]: string;
|
|
10
|
-
}, repositoryAuth?: Credentials): AxiosInstance;
|
|
11
|
-
/**
|
|
12
|
-
* @package
|
|
13
|
-
*/
|
|
14
|
-
export declare function shouldProxy(url: URL, configuredProxy: EnvVar, configuredNoProxy: EnvVar): boolean;
|
|
15
|
-
type EnvVar = {
|
|
16
|
-
name?: string;
|
|
17
|
-
value?: string;
|
|
18
|
-
};
|
|
19
|
-
export {};
|
|
20
|
-
//# sourceMappingURL=axiosClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axiosClient.d.ts","sourceRoot":"","sources":["../../../src/cli/io/axiosClient.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,aAAa,EAAwC,MAAM,OAAO,CAAC;AAKjF,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;GAEG;AACH,wBAAgB,WAAW,CACvB,UAAU,EAAE,GAAG,EACf,SAAS,EAAE,OAAO,EAClB,GAAG,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EAC9B,cAAc,CAAC,EAAE,WAAW,GAC7B,aAAa,CAmCf;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAuBjG;AA8DD,KAAK,MAAM,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.shouldProxy = exports.axiosClient = void 0;
|
|
30
|
-
const core_1 = require("@serenity-js/core");
|
|
31
|
-
const axios_1 = __importDefault(require("axios"));
|
|
32
|
-
const fs = __importStar(require("fs"));
|
|
33
|
-
const https = __importStar(require("https"));
|
|
34
|
-
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
35
|
-
const url_1 = require("url");
|
|
36
|
-
/**
|
|
37
|
-
* @package
|
|
38
|
-
*/
|
|
39
|
-
function axiosClient(repository, ignoreSsl, env, repositoryAuth) {
|
|
40
|
-
const configuredProxy = isHttps(repository.protocol)
|
|
41
|
-
? firstNonEmpty(env, 'npm_config_https_proxy', 'https_proxy', 'HTTPS_PROXY')
|
|
42
|
-
: firstNonEmpty(env, 'npm_config_proxy', 'npm_config_http_proxy', 'http_proxy', 'HTTP_PROXY');
|
|
43
|
-
const configuredNoProxy = firstNonEmpty(env, 'npm_config_noproxy', 'no_proxy', 'NO_PROXY');
|
|
44
|
-
const configuredCa = certificationAuthority(env);
|
|
45
|
-
const rejectUnauthorized = shouldRejectUnauthorizedCertificates(env, ignoreSsl);
|
|
46
|
-
const options = {
|
|
47
|
-
baseURL: repository.toString(),
|
|
48
|
-
adapter: ['http'],
|
|
49
|
-
auth: repositoryAuth.toJSON(),
|
|
50
|
-
};
|
|
51
|
-
if (isHttps(repository.protocol)) {
|
|
52
|
-
options.proxy = false;
|
|
53
|
-
options.httpsAgent = shouldProxy(repository, configuredProxy, configuredNoProxy)
|
|
54
|
-
? proxiedHttpsAgent(configuredProxy.value, configuredCa, rejectUnauthorized)
|
|
55
|
-
: httpsAgent(configuredCa, rejectUnauthorized);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
options.proxy = shouldProxy(repository, configuredProxy, configuredNoProxy)
|
|
59
|
-
? proxyConfigFrom(configuredProxy)
|
|
60
|
-
: undefined;
|
|
61
|
-
}
|
|
62
|
-
if (env.npm_config_user_agent) {
|
|
63
|
-
options.headers = { 'User-Agent': env.npm_config_user_agent };
|
|
64
|
-
}
|
|
65
|
-
return axios_1.default.create(options);
|
|
66
|
-
}
|
|
67
|
-
exports.axiosClient = axiosClient;
|
|
68
|
-
/**
|
|
69
|
-
* @package
|
|
70
|
-
*/
|
|
71
|
-
function shouldProxy(url, configuredProxy, configuredNoProxy) {
|
|
72
|
-
// there's no proxy configured so don't proxy...
|
|
73
|
-
if (!configuredProxy.value) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
const noProxyDomains = (configuredNoProxy.value || '').split(',').map(_ => _.trim());
|
|
77
|
-
return !noProxyDomains.some(noProxyDomain => {
|
|
78
|
-
if (!noProxyDomain) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
if (noProxyDomain === '*') {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
if (noProxyDomain[0] === '.' && url.hostname.slice(url.hostname.length - noProxyDomain.length) === noProxyDomain) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
return url.hostname === noProxyDomain;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
exports.shouldProxy = shouldProxy;
|
|
91
|
-
function proxyConfigFrom(proxyUrl) {
|
|
92
|
-
let parsed;
|
|
93
|
-
try {
|
|
94
|
-
parsed = new url_1.URL(proxyUrl.value);
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
throw new core_1.ConfigurationError(`Env variable ${proxyUrl.name}=${proxyUrl.value} should specify a valid URL`, error);
|
|
98
|
-
}
|
|
99
|
-
if (!isSupportedProtocol(parsed.protocol)) {
|
|
100
|
-
throw new core_1.ConfigurationError(`Env variable ${proxyUrl.name}=${proxyUrl.value} should specify protocol to be used, i.e. http:// or https://`);
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
protocol: parsed.protocol,
|
|
104
|
-
host: parsed.hostname,
|
|
105
|
-
port: parsed.port
|
|
106
|
-
? Number.parseInt(parsed.port, 10)
|
|
107
|
-
: (isHttps(parsed.protocol) ? 443 : 80),
|
|
108
|
-
auth: (parsed.password || parsed.username) ? {
|
|
109
|
-
password: parsed.password,
|
|
110
|
-
username: parsed.username,
|
|
111
|
-
} : undefined,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
function shouldRejectUnauthorizedCertificates(env, ignoreSsl) {
|
|
115
|
-
return !ignoreSsl
|
|
116
|
-
|| env.npm_config_strict_ssl === 'true';
|
|
117
|
-
}
|
|
118
|
-
function proxiedHttpsAgent(configuredProxy, ca, rejectUnauthorized) {
|
|
119
|
-
return new https_proxy_agent_1.HttpsProxyAgent(configuredProxy, { ca, rejectUnauthorized });
|
|
120
|
-
}
|
|
121
|
-
function httpsAgent(ca, rejectUnauthorized) {
|
|
122
|
-
return new https.Agent({ ca, rejectUnauthorized, });
|
|
123
|
-
}
|
|
124
|
-
function certificationAuthority(env) {
|
|
125
|
-
// old school, the value is specified in the env var itself
|
|
126
|
-
if (env.npm_config_ca) {
|
|
127
|
-
return env.npm_config_ca;
|
|
128
|
-
}
|
|
129
|
-
if (env.npm_config_cafile) {
|
|
130
|
-
try {
|
|
131
|
-
return fs.readFileSync(env.npm_config_cafile, { encoding: 'utf8' });
|
|
132
|
-
}
|
|
133
|
-
catch (error) {
|
|
134
|
-
throw new core_1.ConfigurationError(`Could not read npm_config_cafile at ${env.npm_config_cafile}`, error);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return undefined;
|
|
138
|
-
}
|
|
139
|
-
function firstNonEmpty(env, ...candidateVariables) {
|
|
140
|
-
const found = candidateVariables.find(value => !!env[value]);
|
|
141
|
-
return found
|
|
142
|
-
? { name: found, value: env[found] }
|
|
143
|
-
: {};
|
|
144
|
-
}
|
|
145
|
-
function isSupportedProtocol(protocol) {
|
|
146
|
-
return ['http:', 'https:', 'socks4:', 'socks5:']
|
|
147
|
-
.find(supported => supported === protocol);
|
|
148
|
-
}
|
|
149
|
-
function isHttps(urlOrProtocol) {
|
|
150
|
-
return urlOrProtocol
|
|
151
|
-
&& urlOrProtocol.startsWith('https:');
|
|
152
|
-
}
|
|
153
|
-
//# sourceMappingURL=axiosClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axiosClient.js","sourceRoot":"","sources":["../../../src/cli/io/axiosClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAuD;AAEvD,kDAA0B;AAC1B,uCAAyB;AACzB,6CAA+B;AAC/B,yDAAoD;AACpD,6BAA0B;AAI1B;;GAEG;AACH,SAAgB,WAAW,CACvB,UAAe,EACf,SAAkB,EAClB,GAA8B,EAC9B,cAA4B;IAG5B,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;QAChD,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,wBAAwB,EAAE,aAAa,EAAE,aAAa,CAAC;QAC5E,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAElG,MAAM,iBAAiB,GAAG,aAAa,CAAC,GAAG,EAAE,oBAAoB,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAE3F,MAAM,YAAY,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAEjD,MAAM,kBAAkB,GAAG,oCAAoC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAEhF,MAAM,OAAO,GAAuB;QAChC,OAAO,EAAK,UAAU,CAAC,QAAQ,EAAE;QACjC,OAAO,EAAK,CAAE,MAAM,CAAE;QACtB,IAAI,EAAQ,cAAc,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,KAAK,CAAC,EAAE;QACpC,CAAC,CAAC,EAAE,CAAC;AACb,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB;IACzC,OAAO,CAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAE;SAC7C,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,OAAO,CAAC,aAAqB;IAClC,OAAO,aAAa;WACb,aAAa,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { ConfigurationError } from '@serenity-js/core';
|
|
2
|
-
import type { AxiosInstance, AxiosProxyConfig, AxiosRequestConfig } from 'axios';
|
|
3
|
-
import axios from 'axios';
|
|
4
|
-
import * as fs from 'fs';
|
|
5
|
-
import * as https from 'https';
|
|
6
|
-
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
7
|
-
import { URL } from 'url';
|
|
8
|
-
|
|
9
|
-
import type { Credentials } from '../model';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @package
|
|
13
|
-
*/
|
|
14
|
-
export function axiosClient(
|
|
15
|
-
repository: URL,
|
|
16
|
-
ignoreSsl: boolean,
|
|
17
|
-
env: { [key: string]: string },
|
|
18
|
-
repositoryAuth?: Credentials
|
|
19
|
-
): AxiosInstance {
|
|
20
|
-
|
|
21
|
-
const configuredProxy = isHttps(repository.protocol)
|
|
22
|
-
? firstNonEmpty(env, 'npm_config_https_proxy', 'https_proxy', 'HTTPS_PROXY')
|
|
23
|
-
: firstNonEmpty(env, 'npm_config_proxy', 'npm_config_http_proxy', 'http_proxy', 'HTTP_PROXY');
|
|
24
|
-
|
|
25
|
-
const configuredNoProxy = firstNonEmpty(env, 'npm_config_noproxy', 'no_proxy', 'NO_PROXY');
|
|
26
|
-
|
|
27
|
-
const configuredCa = certificationAuthority(env);
|
|
28
|
-
|
|
29
|
-
const rejectUnauthorized = shouldRejectUnauthorizedCertificates(env, ignoreSsl);
|
|
30
|
-
|
|
31
|
-
const options: AxiosRequestConfig = {
|
|
32
|
-
baseURL: repository.toString(),
|
|
33
|
-
adapter: [ 'http' ],
|
|
34
|
-
auth: repositoryAuth.toJSON() as { username: string, password: string },
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
if (isHttps(repository.protocol)) {
|
|
38
|
-
options.proxy = false;
|
|
39
|
-
options.httpsAgent = shouldProxy(repository, configuredProxy, configuredNoProxy)
|
|
40
|
-
? proxiedHttpsAgent(configuredProxy.value, configuredCa, rejectUnauthorized)
|
|
41
|
-
: httpsAgent(configuredCa, rejectUnauthorized);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
options.proxy = shouldProxy(repository, configuredProxy, configuredNoProxy)
|
|
45
|
-
? proxyConfigFrom(configuredProxy)
|
|
46
|
-
: undefined;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (env.npm_config_user_agent) {
|
|
50
|
-
options.headers = { 'User-Agent': env.npm_config_user_agent };
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return axios.create(options);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @package
|
|
58
|
-
*/
|
|
59
|
-
export function shouldProxy(url: URL, configuredProxy: EnvVar, configuredNoProxy: EnvVar): boolean {
|
|
60
|
-
// there's no proxy configured so don't proxy...
|
|
61
|
-
if (! configuredProxy.value) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const noProxyDomains = (configuredNoProxy.value || '').split(',').map(_ => _.trim());
|
|
66
|
-
|
|
67
|
-
return ! noProxyDomains.some(noProxyDomain => {
|
|
68
|
-
if (! noProxyDomain) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (noProxyDomain === '*') {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (noProxyDomain[0] === '.' && url.hostname.slice(url.hostname.length - noProxyDomain.length) === noProxyDomain) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return url.hostname === noProxyDomain;
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function proxyConfigFrom(proxyUrl: EnvVar): AxiosProxyConfig | undefined {
|
|
85
|
-
|
|
86
|
-
let parsed: URL;
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
parsed = new URL(proxyUrl.value);
|
|
90
|
-
} catch (error) {
|
|
91
|
-
throw new ConfigurationError(`Env variable ${ proxyUrl.name }=${ proxyUrl.value } should specify a valid URL`, error);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (! isSupportedProtocol(parsed.protocol)) {
|
|
95
|
-
throw new ConfigurationError(`Env variable ${ proxyUrl.name }=${ proxyUrl.value } should specify protocol to be used, i.e. http:// or https://`);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
protocol: parsed.protocol,
|
|
100
|
-
host: parsed.hostname,
|
|
101
|
-
|
|
102
|
-
port: parsed.port
|
|
103
|
-
? Number.parseInt(parsed.port, 10)
|
|
104
|
-
: (isHttps(parsed.protocol) ? 443 : 80),
|
|
105
|
-
|
|
106
|
-
auth: (parsed.password || parsed.username) ? {
|
|
107
|
-
password: parsed.password,
|
|
108
|
-
username: parsed.username,
|
|
109
|
-
} : undefined,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function shouldRejectUnauthorizedCertificates(env: { [key: string]: string }, ignoreSsl: boolean): boolean {
|
|
114
|
-
return ! ignoreSsl
|
|
115
|
-
|| env.npm_config_strict_ssl === 'true'
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function proxiedHttpsAgent(configuredProxy: string, ca: string, rejectUnauthorized: boolean) {
|
|
119
|
-
return new HttpsProxyAgent(configuredProxy, { ca, rejectUnauthorized });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function httpsAgent(ca: string, rejectUnauthorized: boolean): https.Agent {
|
|
123
|
-
return new https.Agent({ ca, rejectUnauthorized, });
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function certificationAuthority(env: { [key: string]: string }): string | undefined {
|
|
127
|
-
|
|
128
|
-
// old school, the value is specified in the env var itself
|
|
129
|
-
if (env.npm_config_ca) {
|
|
130
|
-
return env.npm_config_ca;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (env.npm_config_cafile) {
|
|
134
|
-
try {
|
|
135
|
-
return fs.readFileSync(env.npm_config_cafile, { encoding: 'utf8' });
|
|
136
|
-
} catch (error) {
|
|
137
|
-
throw new ConfigurationError(`Could not read npm_config_cafile at ${ env.npm_config_cafile }`, error);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return undefined;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
type EnvVar = { name?: string, value?: string }; // eslint-disable-line unicorn/prevent-abbreviations
|
|
145
|
-
|
|
146
|
-
function firstNonEmpty(env: { [key: string]: string }, ...candidateVariables: string[]): EnvVar {
|
|
147
|
-
const found = candidateVariables.find(value => !! env[value]);
|
|
148
|
-
|
|
149
|
-
return found
|
|
150
|
-
? { name: found, value: env[found] }
|
|
151
|
-
: {};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function isSupportedProtocol(protocol: string) {
|
|
155
|
-
return [ 'http:', 'https:', 'socks4:', 'socks5:' ]
|
|
156
|
-
.find(supported => supported === protocol);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function isHttps(urlOrProtocol: string) {
|
|
160
|
-
return urlOrProtocol
|
|
161
|
-
&& urlOrProtocol.startsWith('https:');
|
|
162
|
-
}
|