@next-core/brick-container 3.0.8 → 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.
Files changed (2) hide show
  1. package/package.json +4 -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.8",
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",
@@ -37,7 +38,7 @@
37
38
  "ws": "^8.13.0"
38
39
  },
39
40
  "devDependencies": {
40
- "@next-core/build-next-bricks": "^1.1.1",
41
+ "@next-core/build-next-bricks": "^1.1.2",
41
42
  "@next-core/http": "^1.0.2",
42
43
  "@next-core/i18n": "^1.0.4",
43
44
  "@next-core/runtime": "^1.0.6",
@@ -53,5 +54,5 @@
53
54
  "@next-core/runtime": "*",
54
55
  "@next-core/utils": "*"
55
56
  },
56
- "gitHead": "f4639c59925a6f007fdf03630bcb9a9b0163cd8b"
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
- importMeta: import.meta,
5
- flags: {
6
- subdir: {
7
- type: "boolean",
8
- },
9
- server: {
10
- type: "string",
11
- },
12
- remote: {
13
- type: "boolean",
14
- default: true,
15
- },
16
- localMicroApps: {
17
- type: "string",
18
- },
19
- localContainer: {
20
- type: "boolean",
21
- default: true,
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: 8081,
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