pro-xy-ui 0.5.8 → 0.6.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/.esformatter +28 -28
- package/.eslintrc +15 -15
- package/bin/pro-xy-ui +25 -27
- package/index.html +38 -38
- package/lib/app/_common/app-menu.js +42 -42
- package/lib/app/_common/app-menu.ts +41 -41
- package/lib/app/_common/patchResize.js +33 -33
- package/lib/app/_common/patchResize.ts +32 -32
- package/lib/app/_common/pipes.js +33 -33
- package/lib/app/_common/pipes.ts +21 -21
- package/lib/app/_common/rxjs-extensions.js +20 -20
- package/lib/app/_common/rxjs-extensions.ts +21 -21
- package/lib/app/app.component.css +39 -39
- package/lib/app/app.component.html +35 -35
- package/lib/app/app.module.js +92 -92
- package/lib/app/app.module.ts +89 -89
- package/lib/app/main.js +11 -11
- package/lib/app/main.ts +11 -11
- package/lib/app/model/config.js +69 -69
- package/lib/app/model/config.ts +79 -79
- package/lib/app/model/http.js +116 -116
- package/lib/app/service/config.defaultConfig.js +74 -74
- package/lib/app/service/config.defaultConfig.ts +72 -72
- package/lib/app/service/config.service.js +44 -44
- package/lib/app/service/config.service.ts +39 -39
- package/lib/app/service/socket.service.js +109 -109
- package/lib/app/service/socket.service.ts +131 -131
- package/lib/app/service/traffic.service.js +98 -98
- package/lib/app/views/auto-responder/auto-responder.component.css +37 -37
- package/lib/app/views/auto-responder/auto-responder.component.html +41 -41
- package/lib/app/views/auto-responder/auto-responder.component.js +102 -102
- package/lib/app/views/auto-responder/auto-responder.component.ts +110 -110
- package/lib/app/views/composer/composer.component.css +7 -7
- package/lib/app/views/composer/composer.component.html +9 -9
- package/lib/app/views/composer/composer.component.js +147 -147
- package/lib/app/views/composer/composer.component.ts +148 -148
- package/lib/app/views/config/config.component.css +13 -13
- package/lib/app/views/config/config.component.html +14 -14
- package/lib/app/views/config/config.component.js +163 -163
- package/lib/app/views/config/diff.dialog.html +3 -3
- package/lib/app/views/config/diff.dialog.js +29 -29
- package/lib/app/views/config/diff.dialog.ts +17 -17
- package/lib/app/views/config/plugins.dialog.html +17 -17
- package/lib/app/views/config/plugins.dialog.js +29 -29
- package/lib/app/views/config/plugins.dialog.ts +17 -17
- package/lib/app/views/config-list-base.js +44 -44
- package/lib/app/views/config-list-base.ts +66 -66
- package/lib/app/views/connection/connection.component.html +9 -9
- package/lib/app/views/connection/connection.component.js +87 -89
- package/lib/app/views/connection/connection.component.ts +83 -85
- package/lib/app/views/delay/delay.component.css +23 -23
- package/lib/app/views/delay/delay.component.html +35 -35
- package/lib/app/views/delay/delay.component.js +34 -34
- package/lib/app/views/find/find.component.css +30 -30
- package/lib/app/views/find/find.component.html +10 -10
- package/lib/app/views/find/find.component.js +113 -113
- package/lib/app/views/find/find.component.ts +111 -111
- package/lib/app/views/inspector/inspector.component.css +14 -14
- package/lib/app/views/inspector/inspector.component.html +17 -17
- package/lib/app/views/inspector/inspector.component.js +64 -64
- package/lib/app/views/inspector/inspector.component.ts +54 -54
- package/lib/app/views/logs/logs.component.css +7 -7
- package/lib/app/views/logs/logs.component.html +13 -13
- package/lib/app/views/logs/logs.component.js +56 -56
- package/lib/app/views/logs/logs.component.ts +46 -46
- package/lib/app/views/requests/request-row.component.css +15 -15
- package/lib/app/views/requests/request-row.component.html +7 -7
- package/lib/app/views/requests/request-row.component.js +68 -68
- package/lib/app/views/requests/request.bodyMenu.js +41 -41
- package/lib/app/views/requests/request.bodyMenu.ts +61 -61
- package/lib/app/views/requests/request.headMenu.js +25 -25
- package/lib/app/views/requests/requests.component.css +49 -49
- package/lib/app/views/requests/requests.component.html +33 -33
- package/lib/app/views/requests/requests.component.js +127 -127
- package/lib/app/views/status/status.component.css +18 -18
- package/lib/app/views/status/status.component.html +8 -8
- package/lib/app/views/status/status.component.js +49 -49
- package/lib/app/views/status/status.component.ts +45 -45
- package/lib/app/views/url-replace/url-replace.component.css +32 -32
- package/lib/app/views/url-replace/url-replace.component.html +36 -36
- package/lib/app/views/url-replace/url-replace.component.js +34 -34
- package/lib/index.js +23 -23
- package/lib/lib.d.ts +2 -2
- package/lib/style.css +100 -100
- package/lib/systemjs.config.js +75 -75
- package/package.json +64 -64
- package/readme.md +5 -5
- package/tsconfig.json +23 -23
- package/typings.json +11 -11
- package/npm-shrinkwrap.json +0 -2568
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = {
|
|
4
|
-
"port": 8000,
|
|
5
|
-
"logLevel": "DEBUG",
|
|
6
|
-
"plugins": [
|
|
7
|
-
"pro-xy-header-replace",
|
|
8
|
-
"pro-xy-cookie-replace",
|
|
9
|
-
"pro-xy-url-replace",
|
|
10
|
-
"pro-xy-ws-api",
|
|
11
|
-
"pro-xy-delay",
|
|
12
|
-
"pro-xy-auto-responder"
|
|
13
|
-
],
|
|
14
|
-
"pro-xy-url-replace": {
|
|
15
|
-
"disabled": false,
|
|
16
|
-
"replaces": [
|
|
17
|
-
{
|
|
18
|
-
"name": "my-repalce",
|
|
19
|
-
"pattern": "//localhost:..../something/svc/",
|
|
20
|
-
"replacement": "//some.server.com:8080/something/svc/",
|
|
21
|
-
"disabled": false
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
"replaceBackHeaders": [
|
|
25
|
-
"location",
|
|
26
|
-
"link"
|
|
27
|
-
]
|
|
28
|
-
},
|
|
29
|
-
"pro-xy-auto-responder": {
|
|
30
|
-
"disabled": true,
|
|
31
|
-
"responses": [
|
|
32
|
-
{
|
|
33
|
-
"disabled": false,
|
|
34
|
-
"urlPattern": "ADD SOME PATTERN",
|
|
35
|
-
"status": 200,
|
|
36
|
-
"contentType": "text/plain",
|
|
37
|
-
"target": "/absolute/path/or/relative/to/HOME/.auto-respond/"
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
"pro-xy-cookie-replace": {
|
|
42
|
-
"disabled": true,
|
|
43
|
-
"replaces": [
|
|
44
|
-
{
|
|
45
|
-
"urlPattern": "ADD SOME PATTERN",
|
|
46
|
-
"pattern": "foo",
|
|
47
|
-
"replacement": "bar"
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
},
|
|
51
|
-
"pro-xy-header-replace": {
|
|
52
|
-
"disabled": true,
|
|
53
|
-
"replaces": [
|
|
54
|
-
{
|
|
55
|
-
"urlPattern": "ADD SOME PATTERN",
|
|
56
|
-
"request": false,
|
|
57
|
-
"response": true,
|
|
58
|
-
"header": "Content-Type",
|
|
59
|
-
"pattern": "text/html",
|
|
60
|
-
"replacement": "text/plain"
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
"pro-xy-delay": {
|
|
65
|
-
"disabled": true,
|
|
66
|
-
"rules": [
|
|
67
|
-
{
|
|
68
|
-
"urlPattern": ".*",
|
|
69
|
-
"delay": 2000,
|
|
70
|
-
"disabled": false
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
}
|
|
74
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
"port": 8000,
|
|
5
|
+
"logLevel": "DEBUG",
|
|
6
|
+
"plugins": [
|
|
7
|
+
"pro-xy-header-replace",
|
|
8
|
+
"pro-xy-cookie-replace",
|
|
9
|
+
"pro-xy-url-replace",
|
|
10
|
+
"pro-xy-ws-api",
|
|
11
|
+
"pro-xy-delay",
|
|
12
|
+
"pro-xy-auto-responder"
|
|
13
|
+
],
|
|
14
|
+
"pro-xy-url-replace": {
|
|
15
|
+
"disabled": false,
|
|
16
|
+
"replaces": [
|
|
17
|
+
{
|
|
18
|
+
"name": "my-repalce",
|
|
19
|
+
"pattern": "//localhost:..../something/svc/",
|
|
20
|
+
"replacement": "//some.server.com:8080/something/svc/",
|
|
21
|
+
"disabled": false
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"replaceBackHeaders": [
|
|
25
|
+
"location",
|
|
26
|
+
"link"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"pro-xy-auto-responder": {
|
|
30
|
+
"disabled": true,
|
|
31
|
+
"responses": [
|
|
32
|
+
{
|
|
33
|
+
"disabled": false,
|
|
34
|
+
"urlPattern": "ADD SOME PATTERN",
|
|
35
|
+
"status": 200,
|
|
36
|
+
"contentType": "text/plain",
|
|
37
|
+
"target": "/absolute/path/or/relative/to/HOME/.auto-respond/"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"pro-xy-cookie-replace": {
|
|
42
|
+
"disabled": true,
|
|
43
|
+
"replaces": [
|
|
44
|
+
{
|
|
45
|
+
"urlPattern": "ADD SOME PATTERN",
|
|
46
|
+
"pattern": "foo",
|
|
47
|
+
"replacement": "bar"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
"pro-xy-header-replace": {
|
|
52
|
+
"disabled": true,
|
|
53
|
+
"replaces": [
|
|
54
|
+
{
|
|
55
|
+
"urlPattern": "ADD SOME PATTERN",
|
|
56
|
+
"request": false,
|
|
57
|
+
"response": true,
|
|
58
|
+
"header": "Content-Type",
|
|
59
|
+
"pattern": "text/html",
|
|
60
|
+
"replacement": "text/plain"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"pro-xy-delay": {
|
|
65
|
+
"disabled": true,
|
|
66
|
+
"rules": [
|
|
67
|
+
{
|
|
68
|
+
"urlPattern": ".*",
|
|
69
|
+
"delay": 2000,
|
|
70
|
+
"disabled": false
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
};
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
"port": 8000,
|
|
3
|
-
"logLevel": "DEBUG",
|
|
4
|
-
"plugins": [
|
|
5
|
-
"pro-xy-header-replace",
|
|
6
|
-
"pro-xy-cookie-replace",
|
|
7
|
-
"pro-xy-url-replace",
|
|
8
|
-
"pro-xy-ws-api",
|
|
9
|
-
"pro-xy-delay",
|
|
10
|
-
"pro-xy-auto-responder"
|
|
11
|
-
],
|
|
12
|
-
"pro-xy-url-replace": {
|
|
13
|
-
"disabled": false,
|
|
14
|
-
"replaces": [
|
|
15
|
-
{
|
|
16
|
-
"name": "my-repalce",
|
|
17
|
-
"pattern": "//localhost:..../something/svc/",
|
|
18
|
-
"replacement": "//some.server.com:8080/something/svc/",
|
|
19
|
-
"disabled": false
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
"replaceBackHeaders": [
|
|
23
|
-
"location",
|
|
24
|
-
"link"
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
"pro-xy-auto-responder": {
|
|
28
|
-
"disabled": true,
|
|
29
|
-
"responses": [
|
|
30
|
-
{
|
|
31
|
-
"disabled": false,
|
|
32
|
-
"urlPattern": "ADD SOME PATTERN",
|
|
33
|
-
"status": 200,
|
|
34
|
-
"contentType": "text/plain",
|
|
35
|
-
"target": "/absolute/path/or/relative/to/HOME/.auto-respond/"
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
},
|
|
39
|
-
"pro-xy-cookie-replace": {
|
|
40
|
-
"disabled": true,
|
|
41
|
-
"replaces": [
|
|
42
|
-
{
|
|
43
|
-
"urlPattern": "ADD SOME PATTERN",
|
|
44
|
-
"pattern": "foo",
|
|
45
|
-
"replacement": "bar"
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
},
|
|
49
|
-
"pro-xy-header-replace": {
|
|
50
|
-
"disabled": true,
|
|
51
|
-
"replaces": [
|
|
52
|
-
{
|
|
53
|
-
"urlPattern": "ADD SOME PATTERN",
|
|
54
|
-
"request": false,
|
|
55
|
-
"response": true,
|
|
56
|
-
"header": "Content-Type",
|
|
57
|
-
"pattern": "text/html",
|
|
58
|
-
"replacement": "text/plain"
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
"pro-xy-delay": {
|
|
63
|
-
"disabled": true,
|
|
64
|
-
"rules": [
|
|
65
|
-
{
|
|
66
|
-
"urlPattern": ".*",
|
|
67
|
-
"delay": 2000,
|
|
68
|
-
"disabled": false
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
};
|
|
1
|
+
export default {
|
|
2
|
+
"port": 8000,
|
|
3
|
+
"logLevel": "DEBUG",
|
|
4
|
+
"plugins": [
|
|
5
|
+
"pro-xy-header-replace",
|
|
6
|
+
"pro-xy-cookie-replace",
|
|
7
|
+
"pro-xy-url-replace",
|
|
8
|
+
"pro-xy-ws-api",
|
|
9
|
+
"pro-xy-delay",
|
|
10
|
+
"pro-xy-auto-responder"
|
|
11
|
+
],
|
|
12
|
+
"pro-xy-url-replace": {
|
|
13
|
+
"disabled": false,
|
|
14
|
+
"replaces": [
|
|
15
|
+
{
|
|
16
|
+
"name": "my-repalce",
|
|
17
|
+
"pattern": "//localhost:..../something/svc/",
|
|
18
|
+
"replacement": "//some.server.com:8080/something/svc/",
|
|
19
|
+
"disabled": false
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"replaceBackHeaders": [
|
|
23
|
+
"location",
|
|
24
|
+
"link"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"pro-xy-auto-responder": {
|
|
28
|
+
"disabled": true,
|
|
29
|
+
"responses": [
|
|
30
|
+
{
|
|
31
|
+
"disabled": false,
|
|
32
|
+
"urlPattern": "ADD SOME PATTERN",
|
|
33
|
+
"status": 200,
|
|
34
|
+
"contentType": "text/plain",
|
|
35
|
+
"target": "/absolute/path/or/relative/to/HOME/.auto-respond/"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"pro-xy-cookie-replace": {
|
|
40
|
+
"disabled": true,
|
|
41
|
+
"replaces": [
|
|
42
|
+
{
|
|
43
|
+
"urlPattern": "ADD SOME PATTERN",
|
|
44
|
+
"pattern": "foo",
|
|
45
|
+
"replacement": "bar"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
"pro-xy-header-replace": {
|
|
50
|
+
"disabled": true,
|
|
51
|
+
"replaces": [
|
|
52
|
+
{
|
|
53
|
+
"urlPattern": "ADD SOME PATTERN",
|
|
54
|
+
"request": false,
|
|
55
|
+
"response": true,
|
|
56
|
+
"header": "Content-Type",
|
|
57
|
+
"pattern": "text/html",
|
|
58
|
+
"replacement": "text/plain"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"pro-xy-delay": {
|
|
63
|
+
"disabled": true,
|
|
64
|
+
"rules": [
|
|
65
|
+
{
|
|
66
|
+
"urlPattern": ".*",
|
|
67
|
+
"delay": 2000,
|
|
68
|
+
"disabled": false
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
};
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const core_1 = require("@angular/core");
|
|
10
|
-
const config_defaultConfig_1 = require("./config.defaultConfig");
|
|
11
|
-
var path = nw.require("path");
|
|
12
|
-
var fs = nw.require("fs");
|
|
13
|
-
let ConfigService = class ConfigService {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.DEFAULT_PORT = 8000;
|
|
16
|
-
this.CONFIG_LOCATION = path.join(process.env.HOME, ".pro-xyrc.json");
|
|
17
|
-
}
|
|
18
|
-
configExists() {
|
|
19
|
-
return fs.existsSync(this.CONFIG_LOCATION);
|
|
20
|
-
}
|
|
21
|
-
getConfig() {
|
|
22
|
-
if (!this.configExists()) {
|
|
23
|
-
throw new Error(`Config file not found: ${this.CONFIG_LOCATION}`);
|
|
24
|
-
}
|
|
25
|
-
//not using require because JSON may have changed (and we need to read is again)
|
|
26
|
-
var configJson = fs.readFileSync(this.CONFIG_LOCATION, "utf8");
|
|
27
|
-
try {
|
|
28
|
-
return JSON.parse(configJson);
|
|
29
|
-
}
|
|
30
|
-
catch (err) {
|
|
31
|
-
throw new Error(`File '${this.CONFIG_LOCATION}' is corrupted: '${err.message}'`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
getDefaultConfig() {
|
|
35
|
-
return config_defaultConfig_1.default;
|
|
36
|
-
}
|
|
37
|
-
createDefaultConfig() {
|
|
38
|
-
return fs.writeFileSync(this.CONFIG_LOCATION, JSON.stringify(this.getDefaultConfig(), null, "\t"));
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
ConfigService = __decorate([
|
|
42
|
-
core_1.Injectable()
|
|
43
|
-
], ConfigService);
|
|
44
|
-
exports.ConfigService = ConfigService;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const core_1 = require("@angular/core");
|
|
10
|
+
const config_defaultConfig_1 = require("./config.defaultConfig");
|
|
11
|
+
var path = nw.require("path");
|
|
12
|
+
var fs = nw.require("fs");
|
|
13
|
+
let ConfigService = class ConfigService {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.DEFAULT_PORT = 8000;
|
|
16
|
+
this.CONFIG_LOCATION = path.join(process.env.HOME, ".pro-xyrc.json");
|
|
17
|
+
}
|
|
18
|
+
configExists() {
|
|
19
|
+
return fs.existsSync(this.CONFIG_LOCATION);
|
|
20
|
+
}
|
|
21
|
+
getConfig() {
|
|
22
|
+
if (!this.configExists()) {
|
|
23
|
+
throw new Error(`Config file not found: ${this.CONFIG_LOCATION}`);
|
|
24
|
+
}
|
|
25
|
+
//not using require because JSON may have changed (and we need to read is again)
|
|
26
|
+
var configJson = fs.readFileSync(this.CONFIG_LOCATION, "utf8");
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(configJson);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
throw new Error(`File '${this.CONFIG_LOCATION}' is corrupted: '${err.message}'`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
getDefaultConfig() {
|
|
35
|
+
return config_defaultConfig_1.default;
|
|
36
|
+
}
|
|
37
|
+
createDefaultConfig() {
|
|
38
|
+
return fs.writeFileSync(this.CONFIG_LOCATION, JSON.stringify(this.getDefaultConfig(), null, "\t"));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
ConfigService = __decorate([
|
|
42
|
+
core_1.Injectable()
|
|
43
|
+
], ConfigService);
|
|
44
|
+
exports.ConfigService = ConfigService;
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { Injectable } from "@angular/core";
|
|
2
|
-
import defaultConfig from "./config.defaultConfig";
|
|
3
|
-
|
|
4
|
-
var path = nw.require("path");
|
|
5
|
-
var fs = nw.require("fs");
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class ConfigService {
|
|
9
|
-
|
|
10
|
-
DEFAULT_PORT = 8000
|
|
11
|
-
CONFIG_LOCATION = path.join(process.env.HOME, ".pro-xyrc.json");
|
|
12
|
-
|
|
13
|
-
configExists() {
|
|
14
|
-
return fs.existsSync(this.CONFIG_LOCATION);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getConfig() {
|
|
18
|
-
if (!this.configExists()) {
|
|
19
|
-
throw new Error(`Config file not found: ${this.CONFIG_LOCATION}`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//not using require because JSON may have changed (and we need to read is again)
|
|
23
|
-
var configJson = fs.readFileSync(this.CONFIG_LOCATION, "utf8")
|
|
24
|
-
try {
|
|
25
|
-
return JSON.parse(configJson);
|
|
26
|
-
} catch (err) {
|
|
27
|
-
throw new Error(`File '${this.CONFIG_LOCATION}' is corrupted: '${err.message}'`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
getDefaultConfig() {
|
|
32
|
-
return defaultConfig;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
createDefaultConfig() {
|
|
36
|
-
return fs.writeFileSync(this.CONFIG_LOCATION, JSON.stringify(this.getDefaultConfig(), null, "\t"));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
}
|
|
1
|
+
import { Injectable } from "@angular/core";
|
|
2
|
+
import defaultConfig from "./config.defaultConfig";
|
|
3
|
+
|
|
4
|
+
var path = nw.require("path");
|
|
5
|
+
var fs = nw.require("fs");
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class ConfigService {
|
|
9
|
+
|
|
10
|
+
DEFAULT_PORT = 8000
|
|
11
|
+
CONFIG_LOCATION = path.join(process.env.HOME, ".pro-xyrc.json");
|
|
12
|
+
|
|
13
|
+
configExists() {
|
|
14
|
+
return fs.existsSync(this.CONFIG_LOCATION);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getConfig() {
|
|
18
|
+
if (!this.configExists()) {
|
|
19
|
+
throw new Error(`Config file not found: ${this.CONFIG_LOCATION}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//not using require because JSON may have changed (and we need to read is again)
|
|
23
|
+
var configJson = fs.readFileSync(this.CONFIG_LOCATION, "utf8")
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(configJson);
|
|
26
|
+
} catch (err) {
|
|
27
|
+
throw new Error(`File '${this.CONFIG_LOCATION}' is corrupted: '${err.message}'`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getDefaultConfig() {
|
|
32
|
+
return defaultConfig;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
createDefaultConfig() {
|
|
36
|
+
return fs.writeFileSync(this.CONFIG_LOCATION, JSON.stringify(this.getDefaultConfig(), null, "\t"));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|