@next-core/brick-container 3.0.9 → 3.0.10
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 +3 -2
- package/serve/env.js +89 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/brick-container",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.10",
|
|
4
4
|
"description": "Brick Container Server",
|
|
5
5
|
"homepage": "https://github.com/easyops-cn/next-core/tree/master/packages/brick-container",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@next-core/serve-helpers": "^1.0.3",
|
|
29
29
|
"body-parser": "^1.20.1",
|
|
30
|
+
"chalk": "^4.1.2",
|
|
30
31
|
"compression": "^1.7.4",
|
|
31
32
|
"express": "^4.18.2",
|
|
32
33
|
"http-proxy-middleware": "^2.0.6",
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"@next-core/runtime": "*",
|
|
54
55
|
"@next-core/utils": "*"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "e8ee2c283569644f14856a89b5662ccdc7452a83"
|
|
57
58
|
}
|
package/serve/env.js
CHANGED
|
@@ -1,27 +1,68 @@
|
|
|
1
1
|
import meow from "meow";
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
|
|
3
|
-
const cli = meow(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
remote
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
const cli = meow(
|
|
5
|
+
`
|
|
6
|
+
Usage
|
|
7
|
+
$ yarn serve [options]
|
|
8
|
+
|
|
9
|
+
Options
|
|
10
|
+
--no-remote Disable remote mode (Defaults to remote enabled)
|
|
11
|
+
--server Set remote server address, defaults to "https://dev.easyops.local"
|
|
12
|
+
--subdir Set base href to "/next/" instead of "/"
|
|
13
|
+
--local-micro-apps Specify local micro apps to be used in remote mode
|
|
14
|
+
--local-container Use local brick-container instead of remote in remote mode
|
|
15
|
+
--port Set local server listening port, defaults to "8081"
|
|
16
|
+
--verbose Print verbose logs
|
|
17
|
+
--help Show help message
|
|
18
|
+
--version Show brick container version
|
|
19
|
+
`,
|
|
20
|
+
{
|
|
21
|
+
importMeta: import.meta,
|
|
22
|
+
flags: {
|
|
23
|
+
subdir: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
},
|
|
26
|
+
server: {
|
|
27
|
+
type: "string",
|
|
28
|
+
},
|
|
29
|
+
remote: {
|
|
30
|
+
type: "boolean",
|
|
31
|
+
default: true,
|
|
32
|
+
},
|
|
33
|
+
localMicroApps: {
|
|
34
|
+
type: "string",
|
|
35
|
+
},
|
|
36
|
+
localContainer: {
|
|
37
|
+
type: "boolean",
|
|
38
|
+
},
|
|
39
|
+
port: {
|
|
40
|
+
type: "string",
|
|
41
|
+
default: "8081",
|
|
42
|
+
},
|
|
43
|
+
verbose: {
|
|
44
|
+
type: "boolean",
|
|
45
|
+
},
|
|
22
46
|
},
|
|
23
|
-
|
|
24
|
-
|
|
47
|
+
allowUnknownFlags: false,
|
|
48
|
+
autoHelp: false,
|
|
49
|
+
autoVersion: false,
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
if (cli.input.length > 0) {
|
|
54
|
+
console.error(chalk.red("Unexpected args received"));
|
|
55
|
+
// `process.exit(exitCode)` will be called in `cli.showHelp()`.
|
|
56
|
+
cli.showHelp();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (cli.flags.help) {
|
|
60
|
+
cli.showHelp(0);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (cli.flags.version) {
|
|
64
|
+
cli.showVersion();
|
|
65
|
+
}
|
|
25
66
|
|
|
26
67
|
export function getEnv(rootDir, runtimeFlags) {
|
|
27
68
|
const flags = {
|
|
@@ -36,10 +77,36 @@ export function getEnv(rootDir, runtimeFlags) {
|
|
|
36
77
|
baseHref: flags.subdir ? "/next/" : "/",
|
|
37
78
|
useLocalContainer: !flags.remote || flags.localContainer,
|
|
38
79
|
localMicroApps: flags.localMicroApps ? flags.localMicroApps.split(",") : [],
|
|
39
|
-
port:
|
|
80
|
+
port: Number(flags.port),
|
|
40
81
|
server: getServerPath(flags.server),
|
|
82
|
+
verbose: flags.verbose,
|
|
41
83
|
};
|
|
42
84
|
|
|
85
|
+
if (env.verbose) {
|
|
86
|
+
console.log("Configure:", env);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (env.localMicroApps.length > 0) {
|
|
90
|
+
console.log();
|
|
91
|
+
console.log("local micro-apps:", env.localMicroApps);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.log();
|
|
95
|
+
console.log(
|
|
96
|
+
chalk.bold.cyan("mode:"),
|
|
97
|
+
env.useRemote ? chalk.bgCyan("remote") : chalk.bgWhite("local")
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
console.log(
|
|
101
|
+
chalk.bold.cyan("container:"),
|
|
102
|
+
env.useLocalContainer ? chalk.bgWhite("local") : chalk.bgCyan("remote")
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
console.log(
|
|
106
|
+
chalk.bold.cyan("remote:"),
|
|
107
|
+
env.useRemote || !env.useLocalContainer ? env.server : "N/A"
|
|
108
|
+
);
|
|
109
|
+
|
|
43
110
|
return env;
|
|
44
111
|
}
|
|
45
112
|
|