@genesislcap/build-kit 14.144.1-alpha-82ebae3.0 → 14.144.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/README.md +15 -1
- package/cert/localhost.crt +25 -0
- package/cert/localhost.key +28 -0
- package/dist/cert/localhost.crt +25 -0
- package/dist/cert/localhost.key +28 -0
- package/dist/utils/https.d.ts +15 -0
- package/dist/utils/https.d.ts.map +1 -0
- package/dist/utils/https.js +25 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -0
- package/dist/utils/proxy.d.ts +82 -0
- package/dist/utils/proxy.d.ts.map +1 -0
- package/dist/utils/proxy.js +93 -0
- package/package.json +7 -4
- package/src/utils/https.ts +29 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/proxy.ts +139 -0
- package/test/utils/https.test.ts +14 -0
- package/test/utils/proxy.test.ts +95 -0
package/README.md
CHANGED
|
@@ -17,9 +17,23 @@ Build context contains user configuration, CLI command details (dev/prod/analyze
|
|
|
17
17
|
|
|
18
18
|
See [@genesislcap/ts-builder](../ts-builder/README.md) for an example.
|
|
19
19
|
|
|
20
|
+
# Development SSL Certificates
|
|
21
|
+
|
|
22
|
+
`@genesislcap/build-kit` bundles a `localhost.crt` and `localhost.key` file which bundlers may apply to their development server options.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { getDevCertOptions } from '@genesislcap/build-kit';
|
|
26
|
+
...
|
|
27
|
+
{
|
|
28
|
+
options: getDevCertOptions(),
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Please follow the [Development-SSL-Certificate](https://www.notion.so/genesisglobal/Development-SSL-Certificates-30cfd42948674d0db511d04c1adb59db) guide to complete local machine setup.
|
|
33
|
+
|
|
20
34
|
## License
|
|
21
35
|
|
|
22
36
|
Note: this project provides front end dependencies and uses licensed components listed in the next section, thus licenses for those components are required during development. Contact [Genesis Global](https://genesis.global/contact-us/) for more details.
|
|
23
37
|
|
|
24
38
|
### Licensed components
|
|
25
|
-
Genesis low-code platform
|
|
39
|
+
Genesis low-code platform
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIEKzCCApOgAwIBAgIRAJ2DkMm20NkXjwvT0PHJCo0wDQYJKoZIhvcNAQELBQAw
|
|
3
|
+
YzEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMRwwGgYDVQQLDBNydW5u
|
|
4
|
+
ZXJAZnYtYXozMzktNjA5MSMwIQYDVQQDDBpta2NlcnQgcnVubmVyQGZ2LWF6MzM5
|
|
5
|
+
LTYwOTAeFw0yMjEyMjIwODMxNTRaFw0yNTAzMjIwODMxNTRaMEcxJzAlBgNVBAoT
|
|
6
|
+
Hm1rY2VydCBkZXZlbG9wbWVudCBjZXJ0aWZpY2F0ZTEcMBoGA1UECwwTcnVubmVy
|
|
7
|
+
QGZ2LWF6NDE3LTI0MTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN4X
|
|
8
|
+
hSYzKgfdIeeeMg5jpYNUJVXDjkpWI5cz73nvNztW0GAZi7vn+ts2iheP26eY4dI7
|
|
9
|
+
XaynT7JXqkqabJxFz5McgvPye9KV0foTBfTXy1Gg5AnsEgrni1zNmmJna6zB0Ybm
|
|
10
|
+
aMAeFfcOR+suhFti13R5ppstgg1MgzFWsaJYNSfziBqyj7E9CTBRWmPKIrzzdsQl
|
|
11
|
+
LBriGuLrgPesIdKfYfEgy5tHJLNgpQVwTGSzibknZdmSU+T9da7hfmiOtcKq1E3J
|
|
12
|
+
PMwIThxmh9QCDlqsKh+5qywagVllG2OaUQxJfGrq5Ihe56XzG/2ZeZuZl8H+NM3o
|
|
13
|
+
Rw2fMosW1g0pVEkazR0CAwEAAaN2MHQwDgYDVR0PAQH/BAQDAgWgMBMGA1UdJQQM
|
|
14
|
+
MAoGCCsGAQU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OV8zO
|
|
27
|
+
1vSzX8HjCcx1AkcATKDA9J3e
|
|
28
|
+
-----END PRIVATE KEY-----
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export type DevCertOptions = {
|
|
6
|
+
cert: Buffer;
|
|
7
|
+
key: Buffer;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Get default dev cert options.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare const getDevCertOptions: () => DevCertOptions | undefined;
|
|
15
|
+
//# sourceMappingURL=https.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"https.d.ts","sourceRoot":"","sources":["../../src/utils/https.ts"],"names":[],"mappings":";AAIA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAO,cAAc,GAAG,SAWrD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDevCertOptions = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const consola_1 = tslib_1.__importDefault(require("consola"));
|
|
8
|
+
/**
|
|
9
|
+
* Get default dev cert options.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
const getDevCertOptions = () => {
|
|
14
|
+
const certDir = (0, node_path_1.resolve)(__dirname, '../../cert/');
|
|
15
|
+
const cert = (0, node_path_1.resolve)(certDir, 'localhost.crt');
|
|
16
|
+
const key = (0, node_path_1.resolve)(certDir, 'localhost.key');
|
|
17
|
+
if ((0, node_fs_1.existsSync)(cert) && (0, node_fs_1.existsSync)(key)) {
|
|
18
|
+
return {
|
|
19
|
+
cert: (0, node_fs_1.readFileSync)(cert),
|
|
20
|
+
key: (0, node_fs_1.readFileSync)(key),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
consola_1.default.warn(`Could not load the default development certificates from ${certDir}.`);
|
|
24
|
+
};
|
|
25
|
+
exports.getDevCertOptions = getDevCertOptions;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -8,9 +8,11 @@ export * from './env';
|
|
|
8
8
|
export * from './federation';
|
|
9
9
|
export * from './fs';
|
|
10
10
|
export * from './handlebars';
|
|
11
|
+
export * from './https';
|
|
11
12
|
export * from './json';
|
|
12
13
|
export * from './npm';
|
|
13
14
|
export * from './prompts';
|
|
15
|
+
export * from './proxy';
|
|
14
16
|
export * from './object';
|
|
15
17
|
export * from './seed.fetching';
|
|
16
18
|
export * from './seed.meta';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,MAAM,CAAC;AACrB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,MAAM,CAAC;AACrB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -11,9 +11,11 @@ tslib_1.__exportStar(require("./env"), exports);
|
|
|
11
11
|
tslib_1.__exportStar(require("./federation"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./fs"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./handlebars"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./https"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./json"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./npm"), exports);
|
|
16
17
|
tslib_1.__exportStar(require("./prompts"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./proxy"), exports);
|
|
17
19
|
tslib_1.__exportStar(require("./object"), exports);
|
|
18
20
|
tslib_1.__exportStar(require("./seed.fetching"), exports);
|
|
19
21
|
tslib_1.__exportStar(require("./seed.meta"), exports);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ServerOptions } from 'http-proxy';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export declare const getPort: (packageJson: any) => number;
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare const convertWsEndpointToHTTP: (endpoint?: string, socketExt?: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Config to create a development proxy for a specific path.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export type DevProxyConfig = {
|
|
16
|
+
target?: string;
|
|
17
|
+
path?: string;
|
|
18
|
+
options?: ServerOptions;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Config to create development proxies for an array of paths.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export type DevProxiesConfig = Omit<DevProxyConfig, 'path'> & {
|
|
26
|
+
paths?: string[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Object containing entries for each proxy keyed by path.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export type DevProxies = Record<string, ServerOptions> & {};
|
|
34
|
+
/**
|
|
35
|
+
* Create development proxy for a specific path.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const proxy = createDevProxy({ path: '/sm', target: process.env.API_HOST, options: {...} });
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Applicable when running in dev mode and a valid target and path is set.
|
|
44
|
+
*
|
|
45
|
+
* @privateRemarks
|
|
46
|
+
* It is important to guard for the case where neither target nor path is set by returning undefined.
|
|
47
|
+
* Proxies with empty string targets will cause blow ups in vite, whereas webpack seems to tolerate them.
|
|
48
|
+
*
|
|
49
|
+
* @param config - A {@link DevProxyConfig}.
|
|
50
|
+
* @returns A {@link DevProxies} object or undefined.
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export declare const createDevProxy: (config: DevProxyConfig) => DevProxies | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Create development proxies for an array of paths.
|
|
57
|
+
*
|
|
58
|
+
* @example Create default development proxies
|
|
59
|
+
* ```ts
|
|
60
|
+
* const proxy = createDevProxies();
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Create custom development proxies
|
|
64
|
+
* ```ts
|
|
65
|
+
* const proxy = createDevProxies({ paths: ['/foo', '/bar'], target: 'http://mydomain.com' });
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* `process.env.API_HOST` will be used as the target if `config.target` is not set. Undefined will be returned if
|
|
70
|
+
* neither are available.
|
|
71
|
+
*
|
|
72
|
+
* @privateRemarks
|
|
73
|
+
* It is important to guard for the case where neither target nor API_HOST are set by returning undefined.
|
|
74
|
+
* Proxies with empty string targets will cause blow ups in vite, whereas webpack seems to tolerate them.
|
|
75
|
+
*
|
|
76
|
+
* @param config - An optional {@link DevProxiesConfig}.
|
|
77
|
+
* @returns A {@link DevProxies} object or undefined.
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare const createDevProxies: (config?: DevProxiesConfig) => DevProxies | undefined;
|
|
82
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/utils/proxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD;;GAEG;AACH,eAAO,MAAM,OAAO,wBAAkB,MACwC,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,uBAAuB,mDAGnC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,GAAG;IAC5D,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc,WAAY,cAAc,KAAG,UAAU,GAAG,SAmBpE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,gBAAgB,YAAY,gBAAgB,KAAQ,UAAU,GAAG,SA0B7E,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDevProxies = exports.createDevProxy = exports.convertWsEndpointToHTTP = exports.getPort = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const consola_1 = tslib_1.__importDefault(require("consola"));
|
|
6
|
+
const portfinder_sync_1 = tslib_1.__importDefault(require("portfinder-sync"));
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
const getPort = (packageJson) => { var _a; return portfinder_sync_1.default.getPort(((_a = packageJson.config) === null || _a === void 0 ? void 0 : _a.PORT) || process.env.PORT || 9000); };
|
|
11
|
+
exports.getPort = getPort;
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
const convertWsEndpointToHTTP = (endpoint = '', socketExt = '') => {
|
|
16
|
+
const protocolUpdate = endpoint.replace(/^ws(s)?:\/\//, 'http$1://');
|
|
17
|
+
return socketExt ? protocolUpdate.replace(`/${socketExt}`, '') : protocolUpdate;
|
|
18
|
+
};
|
|
19
|
+
exports.convertWsEndpointToHTTP = convertWsEndpointToHTTP;
|
|
20
|
+
/**
|
|
21
|
+
* Create development proxy for a specific path.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const proxy = createDevProxy({ path: '/sm', target: process.env.API_HOST, options: {...} });
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* Applicable when running in dev mode and a valid target and path is set.
|
|
30
|
+
*
|
|
31
|
+
* @privateRemarks
|
|
32
|
+
* It is important to guard for the case where neither target nor path is set by returning undefined.
|
|
33
|
+
* Proxies with empty string targets will cause blow ups in vite, whereas webpack seems to tolerate them.
|
|
34
|
+
*
|
|
35
|
+
* @param config - A {@link DevProxyConfig}.
|
|
36
|
+
* @returns A {@link DevProxies} object or undefined.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
const createDevProxy = (config) => {
|
|
41
|
+
var _a;
|
|
42
|
+
if (!config.target || !config.path) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
const { options, path, target } = config;
|
|
46
|
+
return {
|
|
47
|
+
[path]: Object.assign(Object.assign({ target, secure: false, changeOrigin: true, cookieDomainRewrite: 'localhost', ws: true }, (options !== null && options !== void 0 ? options : {})), { headers: Object.assign({ origin: target }, ((_a = options === null || options === void 0 ? void 0 : options.headers) !== null && _a !== void 0 ? _a : {})) }),
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
exports.createDevProxy = createDevProxy;
|
|
51
|
+
/**
|
|
52
|
+
* Create development proxies for an array of paths.
|
|
53
|
+
*
|
|
54
|
+
* @example Create default development proxies
|
|
55
|
+
* ```ts
|
|
56
|
+
* const proxy = createDevProxies();
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example Create custom development proxies
|
|
60
|
+
* ```ts
|
|
61
|
+
* const proxy = createDevProxies({ paths: ['/foo', '/bar'], target: 'http://mydomain.com' });
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* `process.env.API_HOST` will be used as the target if `config.target` is not set. Undefined will be returned if
|
|
66
|
+
* neither are available.
|
|
67
|
+
*
|
|
68
|
+
* @privateRemarks
|
|
69
|
+
* It is important to guard for the case where neither target nor API_HOST are set by returning undefined.
|
|
70
|
+
* Proxies with empty string targets will cause blow ups in vite, whereas webpack seems to tolerate them.
|
|
71
|
+
*
|
|
72
|
+
* @param config - An optional {@link DevProxiesConfig}.
|
|
73
|
+
* @returns A {@link DevProxies} object or undefined.
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
const createDevProxies = (config = {}) => {
|
|
78
|
+
var _a;
|
|
79
|
+
if (!config.target && !process.env.API_HOST) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const socketExt = process.env.SOCKET_EXT || 'gwf';
|
|
83
|
+
const paths = Array.isArray(config.paths) ? config.paths : ['/sm', '/sso', `/${socketExt}`];
|
|
84
|
+
const target = (_a = config.target) !== null && _a !== void 0 ? _a : (0, exports.convertWsEndpointToHTTP)(process.env.API_HOST, socketExt);
|
|
85
|
+
const defaultConfig = Object.assign(Object.assign({}, config), { target });
|
|
86
|
+
const proxies = paths.reduce((prev, curr) => (Object.assign(Object.assign({}, prev), (0, exports.createDevProxy)(Object.assign(Object.assign({}, defaultConfig), { path: curr })))), {});
|
|
87
|
+
if (Object.keys(proxies).length) {
|
|
88
|
+
consola_1.default.info('Dev Proxies:');
|
|
89
|
+
console.table(proxies);
|
|
90
|
+
}
|
|
91
|
+
return proxies;
|
|
92
|
+
};
|
|
93
|
+
exports.createDevProxies = createDevProxies;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/build-kit",
|
|
3
3
|
"description": "Build utilities & types",
|
|
4
|
-
"version": "14.144.1
|
|
4
|
+
"version": "14.144.1",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"node": ">=20.0.0"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "npm run clean && tsc -b ./tsconfig.json",
|
|
12
|
+
"build": "npm run clean && tsc -b ./tsconfig.json && npm run copyfiles",
|
|
13
|
+
"copyfiles": "copyfiles --verbose cert/*.* ./dist",
|
|
13
14
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
14
15
|
"dev": "tsc -b ./tsconfig.json -w",
|
|
15
16
|
"test": "uvu -r tsm --tsmconfig ../uvu-playwright-builder/config/tsm.ts -r @esbuild-kit/cjs-loader -r ../uvu-playwright-builder/config/jsdom.setup.ts . 'test.ts' --i dist --i coverage"
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
"inquirer": "^8.2.3",
|
|
28
29
|
"jiti": "^1.18.2",
|
|
29
30
|
"pkg-types": "^1.0.2",
|
|
31
|
+
"portfinder-sync": "^0.0.2",
|
|
30
32
|
"pretty-ms": "^7.0.0",
|
|
31
33
|
"rimraf": "^5.0.0",
|
|
32
34
|
"tmp": "0.2.1",
|
|
@@ -34,7 +36,8 @@
|
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@esbuild-kit/cjs-loader": "2.4.2",
|
|
37
|
-
"@genesislcap/foundation-testing": "14.144.1
|
|
39
|
+
"@genesislcap/foundation-testing": "14.144.1",
|
|
40
|
+
"@types/http-proxy": "^1.17.8",
|
|
38
41
|
"@types/node": "^20.8.7",
|
|
39
42
|
"tsm": "^2.2.1",
|
|
40
43
|
"typescript": "^4.5.5",
|
|
@@ -48,5 +51,5 @@
|
|
|
48
51
|
"publishConfig": {
|
|
49
52
|
"access": "public"
|
|
50
53
|
},
|
|
51
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "35ac01f58ce5a5502d34247e49ab93d0888cd3f7"
|
|
52
55
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import consola from 'consola';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export type DevCertOptions = {
|
|
9
|
+
cert: Buffer;
|
|
10
|
+
key: Buffer;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get default dev cert options.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export const getDevCertOptions = (): DevCertOptions | undefined => {
|
|
19
|
+
const certDir = resolve(__dirname, '../../cert/');
|
|
20
|
+
const cert = resolve(certDir, 'localhost.crt');
|
|
21
|
+
const key = resolve(certDir, 'localhost.key');
|
|
22
|
+
if (existsSync(cert) && existsSync(key)) {
|
|
23
|
+
return {
|
|
24
|
+
cert: readFileSync(cert),
|
|
25
|
+
key: readFileSync(key),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
consola.warn(`Could not load the default development certificates from ${certDir}.`);
|
|
29
|
+
};
|
package/src/utils/index.ts
CHANGED
|
@@ -8,9 +8,11 @@ export * from './env';
|
|
|
8
8
|
export * from './federation';
|
|
9
9
|
export * from './fs';
|
|
10
10
|
export * from './handlebars';
|
|
11
|
+
export * from './https';
|
|
11
12
|
export * from './json';
|
|
12
13
|
export * from './npm';
|
|
13
14
|
export * from './prompts';
|
|
15
|
+
export * from './proxy';
|
|
14
16
|
export * from './object';
|
|
15
17
|
export * from './seed.fetching';
|
|
16
18
|
export * from './seed.meta';
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import consola from 'consola';
|
|
2
|
+
import type { ServerOptions } from 'http-proxy';
|
|
3
|
+
import portfinderSync from 'portfinder-sync';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export const getPort = (packageJson): number =>
|
|
9
|
+
portfinderSync.getPort(packageJson.config?.PORT || process.env.PORT || 9000);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export const convertWsEndpointToHTTP = (endpoint = '', socketExt = '') => {
|
|
15
|
+
const protocolUpdate = endpoint.replace(/^ws(s)?:\/\//, 'http$1://');
|
|
16
|
+
return socketExt ? protocolUpdate.replace(`/${socketExt}`, '') : protocolUpdate;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Config to create a development proxy for a specific path.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export type DevProxyConfig = {
|
|
25
|
+
target?: string;
|
|
26
|
+
path?: string;
|
|
27
|
+
options?: ServerOptions;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Config to create development proxies for an array of paths.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export type DevProxiesConfig = Omit<DevProxyConfig, 'path'> & {
|
|
36
|
+
paths?: string[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Object containing entries for each proxy keyed by path.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export type DevProxies = Record<string, ServerOptions> & {};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Create development proxy for a specific path.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const proxy = createDevProxy({ path: '/sm', target: process.env.API_HOST, options: {...} });
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* Applicable when running in dev mode and a valid target and path is set.
|
|
56
|
+
*
|
|
57
|
+
* @privateRemarks
|
|
58
|
+
* It is important to guard for the case where neither target nor path is set by returning undefined.
|
|
59
|
+
* Proxies with empty string targets will cause blow ups in vite, whereas webpack seems to tolerate them.
|
|
60
|
+
*
|
|
61
|
+
* @param config - A {@link DevProxyConfig}.
|
|
62
|
+
* @returns A {@link DevProxies} object or undefined.
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
export const createDevProxy = (config: DevProxyConfig): DevProxies | undefined => {
|
|
67
|
+
if (!config.target || !config.path) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const { options, path, target } = config;
|
|
71
|
+
return {
|
|
72
|
+
[path]: {
|
|
73
|
+
target,
|
|
74
|
+
secure: false,
|
|
75
|
+
changeOrigin: true,
|
|
76
|
+
cookieDomainRewrite: 'localhost',
|
|
77
|
+
ws: true,
|
|
78
|
+
...(options ?? {}),
|
|
79
|
+
headers: {
|
|
80
|
+
origin: target,
|
|
81
|
+
...(options?.headers ?? {}),
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Create development proxies for an array of paths.
|
|
89
|
+
*
|
|
90
|
+
* @example Create default development proxies
|
|
91
|
+
* ```ts
|
|
92
|
+
* const proxy = createDevProxies();
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @example Create custom development proxies
|
|
96
|
+
* ```ts
|
|
97
|
+
* const proxy = createDevProxies({ paths: ['/foo', '/bar'], target: 'http://mydomain.com' });
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @remarks
|
|
101
|
+
* `process.env.API_HOST` will be used as the target if `config.target` is not set. Undefined will be returned if
|
|
102
|
+
* neither are available.
|
|
103
|
+
*
|
|
104
|
+
* @privateRemarks
|
|
105
|
+
* It is important to guard for the case where neither target nor API_HOST are set by returning undefined.
|
|
106
|
+
* Proxies with empty string targets will cause blow ups in vite, whereas webpack seems to tolerate them.
|
|
107
|
+
*
|
|
108
|
+
* @param config - An optional {@link DevProxiesConfig}.
|
|
109
|
+
* @returns A {@link DevProxies} object or undefined.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export const createDevProxies = (config: DevProxiesConfig = {}): DevProxies | undefined => {
|
|
114
|
+
if (!config.target && !process.env.API_HOST) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
const socketExt = process.env.SOCKET_EXT || 'gwf';
|
|
118
|
+
const paths = Array.isArray(config.paths) ? config.paths : ['/sm', '/sso', `/${socketExt}`];
|
|
119
|
+
const target = config.target ?? convertWsEndpointToHTTP(process.env.API_HOST, socketExt);
|
|
120
|
+
const defaultConfig: DevProxyConfig = {
|
|
121
|
+
...config,
|
|
122
|
+
target,
|
|
123
|
+
};
|
|
124
|
+
const proxies = paths.reduce(
|
|
125
|
+
(prev, curr) => ({
|
|
126
|
+
...prev,
|
|
127
|
+
...createDevProxy({
|
|
128
|
+
...defaultConfig,
|
|
129
|
+
path: curr,
|
|
130
|
+
}),
|
|
131
|
+
}),
|
|
132
|
+
{},
|
|
133
|
+
);
|
|
134
|
+
if (Object.keys(proxies).length) {
|
|
135
|
+
consola.info('Dev Proxies:');
|
|
136
|
+
console.table(proxies);
|
|
137
|
+
}
|
|
138
|
+
return proxies;
|
|
139
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
|
|
2
|
+
import { getDevCertOptions } from '../../src/utils/https';
|
|
3
|
+
|
|
4
|
+
const suite = createLogicSuite('https dev server');
|
|
5
|
+
|
|
6
|
+
suite('should have default cert options', () => {
|
|
7
|
+
const options = getDevCertOptions();
|
|
8
|
+
assert.ok(
|
|
9
|
+
options,
|
|
10
|
+
'Dev server cert options could not be created. Please ensure the local cert and key is available in build-kit/cert and is being published.',
|
|
11
|
+
);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
suite.run();
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
|
|
2
|
+
import type { ServerOptions } from 'http-proxy';
|
|
3
|
+
import type { DevProxies } from '../../src/utils/proxy';
|
|
4
|
+
import { convertWsEndpointToHTTP, createDevProxies, createDevProxy } from '../../src/utils/proxy';
|
|
5
|
+
|
|
6
|
+
const suite = createLogicSuite('dev server proxies');
|
|
7
|
+
|
|
8
|
+
suite('should convert websocket to http endpoints as expected', ({ runCases }) => {
|
|
9
|
+
runCases(convertWsEndpointToHTTP, [
|
|
10
|
+
[
|
|
11
|
+
['wss://public-foundation.genesislab.global/gwf/', 'gwf'],
|
|
12
|
+
'https://public-foundation.genesislab.global/',
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
['wss://public-foundation.genesislab.global/gwf/'],
|
|
16
|
+
'https://public-foundation.genesislab.global/gwf/',
|
|
17
|
+
],
|
|
18
|
+
[['wss://public-foundation.genesislab.global'], 'https://public-foundation.genesislab.global'],
|
|
19
|
+
[
|
|
20
|
+
['ws://public-foundation.genesislab.global/gwf/', 'gwf'],
|
|
21
|
+
'http://public-foundation.genesislab.global/',
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
['ws://public-foundation.genesislab.global/gwf/'],
|
|
25
|
+
'http://public-foundation.genesislab.global/gwf/',
|
|
26
|
+
],
|
|
27
|
+
[['ws://public-foundation.genesislab.global'], 'http://public-foundation.genesislab.global'],
|
|
28
|
+
[['wss://localhost:6060/gwf/', 'gwf'], 'https://localhost:6060/'],
|
|
29
|
+
[['ws://localhost:6060/gwf/', 'gwf'], 'http://localhost:6060/'],
|
|
30
|
+
[['ws://localhost:6060/gwf/'], 'http://localhost:6060/gwf/'],
|
|
31
|
+
[['ws://localhost:6060'], 'http://localhost:6060'],
|
|
32
|
+
]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
suite('createDevProxy should return the expected proxy for given target', () => {
|
|
36
|
+
const proxy = createDevProxy({
|
|
37
|
+
target: 'https://rte.ie',
|
|
38
|
+
path: '/api',
|
|
39
|
+
options: {
|
|
40
|
+
ws: false,
|
|
41
|
+
cookieDomainRewrite: {
|
|
42
|
+
'old.domain': 'new.domain',
|
|
43
|
+
'*': '',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const expectedProxy: DevProxies = {
|
|
48
|
+
['/api']: {
|
|
49
|
+
target: 'https://rte.ie',
|
|
50
|
+
secure: false,
|
|
51
|
+
changeOrigin: true,
|
|
52
|
+
cookieDomainRewrite: {
|
|
53
|
+
'old.domain': 'new.domain',
|
|
54
|
+
'*': '',
|
|
55
|
+
},
|
|
56
|
+
ws: false,
|
|
57
|
+
headers: {
|
|
58
|
+
origin: 'https://rte.ie',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
assert.equal(proxy, expectedProxy);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
suite('createDevProxy should return undefined when no target or API_HOST is set', () => {
|
|
66
|
+
assert.not.ok(createDevProxy({ path: '/api' }));
|
|
67
|
+
assert.not.ok(createDevProxy({}));
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
suite('createDevProxies should return default proxies for given target', () => {
|
|
71
|
+
const proxies = createDevProxies({ target: 'https://rte.ie' });
|
|
72
|
+
const expectedServerOptions: ServerOptions = {
|
|
73
|
+
target: 'https://rte.ie',
|
|
74
|
+
secure: false,
|
|
75
|
+
changeOrigin: true,
|
|
76
|
+
cookieDomainRewrite: 'localhost',
|
|
77
|
+
ws: true,
|
|
78
|
+
headers: {
|
|
79
|
+
origin: 'https://rte.ie',
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
const expectedProxies: DevProxies = {
|
|
83
|
+
['/sm']: expectedServerOptions,
|
|
84
|
+
['/sso']: expectedServerOptions,
|
|
85
|
+
['/gwf']: expectedServerOptions,
|
|
86
|
+
};
|
|
87
|
+
assert.equal(proxies, expectedProxies);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
suite('createDevProxies should return undefined when no target or API_HOST is set', () => {
|
|
91
|
+
assert.not.ok(createDevProxies({ paths: ['/sm', '/gwf'] }));
|
|
92
|
+
assert.not.ok(createDevProxies());
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
suite.run();
|