@next-core/brick-container 3.2.0 → 3.2.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/brick-container",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Brick Container Server",
|
|
5
5
|
"homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/brick-container",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "cross-env NODE_ENV='production' build-next-bricks"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@next-core/serve-helpers": "^1.0.
|
|
28
|
+
"@next-core/serve-helpers": "^1.0.8",
|
|
29
29
|
"body-parser": "^1.20.1",
|
|
30
30
|
"chalk": "^4.1.2",
|
|
31
31
|
"compression": "^1.7.4",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"@next-core/runtime": "*",
|
|
58
58
|
"@next-core/utils": "*"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "13913a5884fcb6ea953ff92d02b0196f3dd70377"
|
|
61
61
|
}
|
package/serve/env.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import meow from "meow";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
+
import { getLocalBrickPackageNames } from "@next-core/serve-helpers";
|
|
3
4
|
import { getSizeCheckApp } from "./utils/sizeCheck.js";
|
|
4
5
|
|
|
5
6
|
const cli = meow(
|
|
@@ -11,7 +12,8 @@ const cli = meow(
|
|
|
11
12
|
--no-remote Disable remote mode (Defaults to remote enabled)
|
|
12
13
|
--server Set remote server address, defaults to "https://dev.easyops.local"
|
|
13
14
|
--subdir Set base href to "/next/" instead of "/"
|
|
14
|
-
--local-
|
|
15
|
+
--local-bricks Specify local brick packages to be used, defaults to use all local ones
|
|
16
|
+
--local-micro-apps Specify local micro apps to be used
|
|
15
17
|
--local-container Use local brick-container instead of remote in remote mode
|
|
16
18
|
--port Set local server listening port, defaults to "8081"
|
|
17
19
|
--size-check Enable size-check mode
|
|
@@ -32,6 +34,9 @@ const cli = meow(
|
|
|
32
34
|
type: "boolean",
|
|
33
35
|
default: true,
|
|
34
36
|
},
|
|
37
|
+
localBricks: {
|
|
38
|
+
type: "string",
|
|
39
|
+
},
|
|
35
40
|
localMicroApps: {
|
|
36
41
|
type: "string",
|
|
37
42
|
},
|
|
@@ -69,7 +74,7 @@ if (cli.flags.version) {
|
|
|
69
74
|
cli.showVersion();
|
|
70
75
|
}
|
|
71
76
|
|
|
72
|
-
export function getEnv(rootDir, runtimeFlags) {
|
|
77
|
+
export async function getEnv(rootDir, runtimeFlags) {
|
|
73
78
|
const flags = {
|
|
74
79
|
...cli.flags,
|
|
75
80
|
...runtimeFlags,
|
|
@@ -81,6 +86,7 @@ export function getEnv(rootDir, runtimeFlags) {
|
|
|
81
86
|
useRemote: flags.remote,
|
|
82
87
|
baseHref: flags.subdir ? "/next/" : "/",
|
|
83
88
|
useLocalContainer: !flags.remote || flags.localContainer,
|
|
89
|
+
localBricks: flags.localBricks ? flags.localBricks.split(",") : undefined,
|
|
84
90
|
localMicroApps: flags.localMicroApps ? flags.localMicroApps.split(",") : [],
|
|
85
91
|
port: Number(flags.port),
|
|
86
92
|
server: getServerPath(flags.server),
|
|
@@ -96,6 +102,14 @@ export function getEnv(rootDir, runtimeFlags) {
|
|
|
96
102
|
console.log("Configure:", env);
|
|
97
103
|
}
|
|
98
104
|
|
|
105
|
+
const validLocalBricks = await getLocalBrickPackageNames(
|
|
106
|
+
rootDir,
|
|
107
|
+
env.localBricks
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
console.log();
|
|
111
|
+
console.log("local brick packages:", validLocalBricks);
|
|
112
|
+
|
|
99
113
|
if (env.localMicroApps.length > 0) {
|
|
100
114
|
console.log();
|
|
101
115
|
console.log("local micro-apps:", env.localMicroApps);
|
package/serve/getProxy.js
CHANGED
|
@@ -7,8 +7,14 @@ import { injectIndexHtml } from "./utils/injectIndexHtml.js";
|
|
|
7
7
|
import { concatBrickPackages } from "./utils/concatBrickPackages.js";
|
|
8
8
|
|
|
9
9
|
export default function getProxy(env, getRawIndexHtml) {
|
|
10
|
-
const {
|
|
11
|
-
|
|
10
|
+
const {
|
|
11
|
+
rootDir,
|
|
12
|
+
localMicroApps,
|
|
13
|
+
baseHref,
|
|
14
|
+
useRemote,
|
|
15
|
+
useLocalContainer,
|
|
16
|
+
localBricks,
|
|
17
|
+
} = env;
|
|
12
18
|
if (useRemote) {
|
|
13
19
|
return [
|
|
14
20
|
{
|
|
@@ -33,7 +39,7 @@ export default function getProxy(env, getRawIndexHtml) {
|
|
|
33
39
|
|
|
34
40
|
const [storyboards, brickPackages] = await Promise.all([
|
|
35
41
|
getStoryboards({ rootDir, localMicroApps }),
|
|
36
|
-
getBrickPackages(rootDir),
|
|
42
|
+
getBrickPackages(rootDir, false, localBricks),
|
|
37
43
|
]);
|
|
38
44
|
|
|
39
45
|
// Todo: filter out local micro-apps and brick packages
|
|
@@ -181,7 +187,7 @@ export default function getProxy(env, getRawIndexHtml) {
|
|
|
181
187
|
const content = responseBuffer.toString("utf-8");
|
|
182
188
|
const result = JSON.parse(content);
|
|
183
189
|
result.brickPackages = concatBrickPackages(
|
|
184
|
-
await getBrickPackages(rootDir, true),
|
|
190
|
+
await getBrickPackages(rootDir, true, localBricks),
|
|
185
191
|
result.brickPackages
|
|
186
192
|
);
|
|
187
193
|
delete result.templatePackages;
|
package/serve/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
|
|
18
18
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
19
19
|
|
|
20
|
-
const env = getEnv(process.cwd());
|
|
20
|
+
const env = await getEnv(process.cwd());
|
|
21
21
|
const { baseHref, useLocalContainer, port, sizeCheck } = env;
|
|
22
22
|
const distDir = path.join(__dirname, "../dist");
|
|
23
23
|
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { getBrickPackages } from "@next-core/serve-helpers";
|
|
2
2
|
import { getStoryboards } from "../utils/getStoryboards.js";
|
|
3
3
|
|
|
4
|
-
export default function bootstrapJson({
|
|
4
|
+
export default function bootstrapJson({
|
|
5
|
+
rootDir,
|
|
6
|
+
localMicroApps,
|
|
7
|
+
localBricks,
|
|
8
|
+
}) {
|
|
5
9
|
/**
|
|
6
10
|
* @param {import("express").Request} req
|
|
7
11
|
* @param {import("express").Response} res
|
|
@@ -10,7 +14,7 @@ export default function bootstrapJson({ rootDir, localMicroApps }) {
|
|
|
10
14
|
if (req.path === "/" && req.method === "GET") {
|
|
11
15
|
const [storyboards, brickPackages] = await Promise.all([
|
|
12
16
|
getStoryboards({ rootDir, localMicroApps }),
|
|
13
|
-
getBrickPackages(rootDir),
|
|
17
|
+
getBrickPackages(rootDir, false, localBricks),
|
|
14
18
|
]);
|
|
15
19
|
|
|
16
20
|
res.json({
|
|
@@ -2,7 +2,10 @@ import { getBrickPackages } from "@next-core/serve-helpers";
|
|
|
2
2
|
import { getSingleStoryboard } from "../utils/getStoryboards.js";
|
|
3
3
|
import { getSizeCheckStoryboards } from "../utils/sizeCheck.js";
|
|
4
4
|
|
|
5
|
-
export default function standaloneBootstrapJson(
|
|
5
|
+
export default function standaloneBootstrapJson(
|
|
6
|
+
{ rootDir, localBricks },
|
|
7
|
+
appId
|
|
8
|
+
) {
|
|
6
9
|
/**
|
|
7
10
|
* @param {import("express").Request} req
|
|
8
11
|
* @param {import("express").Response} res
|
|
@@ -11,7 +14,7 @@ export default function standaloneBootstrapJson({ rootDir }, appId) {
|
|
|
11
14
|
if (req.path === "/" && req.method === "GET") {
|
|
12
15
|
const [storyboard, brickPackages] = await Promise.all([
|
|
13
16
|
getSingleStoryboard(rootDir, appId),
|
|
14
|
-
getBrickPackages(rootDir, true),
|
|
17
|
+
getBrickPackages(rootDir, true, localBricks),
|
|
15
18
|
]);
|
|
16
19
|
|
|
17
20
|
if (appId === "-size-check-") {
|