@umijs/bundler-utils 4.0.0-canary.20220429.4 → 4.0.0-canary.20220506.3
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/dist/https.js +54 -67
- package/dist/index.js +3 -14
- package/package.json +2 -2
package/dist/https.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -22,67 +13,63 @@ const defaultHttpsHosts = [
|
|
|
22
13
|
'127.0.0.1',
|
|
23
14
|
];
|
|
24
15
|
// vite mode requires a key cert
|
|
25
|
-
function resolveHttpsConfig(httpsConfig) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
throw new Error(`[HTTPS] mkcert not found.`);
|
|
51
|
-
}
|
|
52
|
-
let { key, cert, hosts } = httpsConfig;
|
|
53
|
-
hosts = hosts || defaultHttpsHosts;
|
|
54
|
-
if (!key || !cert) {
|
|
55
|
-
key = (0, path_1.join)(__dirname, 'umi.key.pem');
|
|
56
|
-
cert = (0, path_1.join)(__dirname, 'umi.pem');
|
|
16
|
+
async function resolveHttpsConfig(httpsConfig) {
|
|
17
|
+
// Check if mkcert is installed
|
|
18
|
+
try {
|
|
19
|
+
await utils_1.execa.execa('mkcert', ['--version']);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
utils_1.logger.error('[HTTPS] The mkcert has not been installed.');
|
|
23
|
+
utils_1.logger.info('[HTTPS] Please follow the guide to install manually.');
|
|
24
|
+
switch (process.platform) {
|
|
25
|
+
case 'darwin':
|
|
26
|
+
console.log(utils_1.chalk.green('$ brew install mkcert'));
|
|
27
|
+
console.log(utils_1.chalk.gray('# If you use firefox, please install nss.'));
|
|
28
|
+
console.log(utils_1.chalk.green('$ brew install nss'));
|
|
29
|
+
console.log(utils_1.chalk.green('$ mkcert -install'));
|
|
30
|
+
break;
|
|
31
|
+
case 'win32':
|
|
32
|
+
console.log(utils_1.chalk.green('Checkout https://github.com/FiloSottile/mkcert#windows'));
|
|
33
|
+
break;
|
|
34
|
+
case 'linux':
|
|
35
|
+
console.log(utils_1.chalk.green('Checkout https://github.com/FiloSottile/mkcert#linux'));
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
break;
|
|
57
39
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
40
|
+
throw new Error(`[HTTPS] mkcert not found.`);
|
|
41
|
+
}
|
|
42
|
+
let { key, cert, hosts } = httpsConfig;
|
|
43
|
+
hosts = hosts || defaultHttpsHosts;
|
|
44
|
+
if (!key || !cert) {
|
|
45
|
+
key = (0, path_1.join)(__dirname, 'umi.key.pem');
|
|
46
|
+
cert = (0, path_1.join)(__dirname, 'umi.pem');
|
|
47
|
+
}
|
|
48
|
+
// Generate cert and key files if they are not exist.
|
|
49
|
+
if (!(0, fs_1.existsSync)(key) || !(0, fs_1.existsSync)(cert)) {
|
|
50
|
+
utils_1.logger.wait('[HTTPS] Generating cert and key files...');
|
|
51
|
+
await utils_1.execa.execa('mkcert', [
|
|
52
|
+
'-cert-file',
|
|
71
53
|
cert,
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
'-key-file',
|
|
55
|
+
key,
|
|
56
|
+
...hosts,
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
key,
|
|
61
|
+
cert,
|
|
62
|
+
};
|
|
74
63
|
}
|
|
75
64
|
exports.resolveHttpsConfig = resolveHttpsConfig;
|
|
76
|
-
function createHttpsServer(app, httpsConfig) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return http2Service;
|
|
86
|
-
});
|
|
65
|
+
async function createHttpsServer(app, httpsConfig) {
|
|
66
|
+
utils_1.logger.wait('[HTTPS] Starting service in https mode...');
|
|
67
|
+
const { key, cert } = await resolveHttpsConfig(httpsConfig);
|
|
68
|
+
// Create server
|
|
69
|
+
const http2Service = spdy_1.default.createServer({
|
|
70
|
+
key: (0, fs_1.readFileSync)(key, 'utf-8'),
|
|
71
|
+
cert: (0, fs_1.readFileSync)(cert, 'utf-8'),
|
|
72
|
+
}, app);
|
|
73
|
+
return http2Service;
|
|
87
74
|
}
|
|
88
75
|
exports.createHttpsServer = createHttpsServer;
|
package/dist/index.js
CHANGED
|
@@ -13,26 +13,15 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
17
|
exports.isDepPath = exports.parseModuleSync = exports.parseModule = void 0;
|
|
27
18
|
const es_module_lexer_1 = require("@umijs/bundler-utils/compiled/es-module-lexer");
|
|
28
19
|
const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
|
|
29
20
|
const utils_1 = require("@umijs/utils");
|
|
30
21
|
const path_1 = require("path");
|
|
31
|
-
function parseModule(opts) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return parseModuleSync(opts);
|
|
35
|
-
});
|
|
22
|
+
async function parseModule(opts) {
|
|
23
|
+
await es_module_lexer_1.init;
|
|
24
|
+
return parseModuleSync(opts);
|
|
36
25
|
}
|
|
37
26
|
exports.parseModule = parseModule;
|
|
38
27
|
function parseModuleSync(opts) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-utils",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20220506.3",
|
|
4
4
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-utils#readme",
|
|
5
5
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
6
6
|
"repository": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dev": "pnpm build -- --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@umijs/utils": "4.0.0-canary.
|
|
23
|
+
"@umijs/utils": "4.0.0-canary.20220506.3",
|
|
24
24
|
"esbuild": "0.14.36",
|
|
25
25
|
"regenerate-unicode-properties": "10.0.1",
|
|
26
26
|
"spdy": "^4.0.2"
|