@next-core/build-next-bricks 1.16.1 → 1.18.0

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/build-next-bricks",
3
- "version": "1.16.1",
3
+ "version": "1.18.0",
4
4
  "description": "Build next bricks",
5
5
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/build-next-bricks",
6
6
  "license": "GPL-3.0",
@@ -54,7 +54,7 @@
54
54
  "webpack": "^5.89.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@next-core/brick-manifest": "^0.6.0"
57
+ "@next-core/brick-manifest": "^0.7.0"
58
58
  },
59
- "gitHead": "e73c5a94e382600a40cf164d63ead2d5a5ef2c56"
59
+ "gitHead": "48ac4bbeff115c782d19fcfce56c3a093d565438"
60
60
  }
@@ -19,6 +19,7 @@ export default class EmitBricksJsonPlugin {
19
19
  this.manifest = options.manifest;
20
20
  this.types = options.types;
21
21
  this.examples = options.examples;
22
+ this.deprecatedElements = options.deprecatedElements;
22
23
  }
23
24
 
24
25
  /**
@@ -57,6 +58,7 @@ export default class EmitBricksJsonPlugin {
57
58
  processors: this.processors,
58
59
  dependencies: this.dependencies,
59
60
  filePath: jsFilePath,
61
+ deprecatedElements: this.deprecatedElements,
60
62
  },
61
63
  null,
62
64
  2
@@ -89,6 +91,7 @@ export default class EmitBricksJsonPlugin {
89
91
  console.log("Defined elements:", this.elements);
90
92
  console.log("Defined processors:", this.processors);
91
93
  console.log("Found dependencies:", this.dependencies);
94
+ console.log("Found deprecated elements:", this.deprecatedElements);
92
95
  callback();
93
96
  }
94
97
  );
package/src/build.js CHANGED
@@ -83,20 +83,53 @@ async function getWebpackConfig(config) {
83
83
  packageDir,
84
84
  "../../shared/common-bricks/common-bricks.json"
85
85
  );
86
+
87
+ const deprecatedBricksJsonFile = path.join(
88
+ packageDir,
89
+ "../../shared/common-bricks/deprecated-bricks.json"
90
+ );
91
+
92
+ const deprecatedBricksJson = existsSync(deprecatedBricksJsonFile)
93
+ ? JSON.parse(await readFile(deprecatedBricksJsonFile, "utf-8"))
94
+ : {};
95
+
86
96
  if (existsSync(commonBricksJsonFile)) {
87
97
  const commonBricksJson = JSON.parse(
88
98
  await readFile(commonBricksJsonFile, "utf-8")
89
99
  );
90
100
 
91
- /** @type {Set<string, string>} */
101
+ /** @type {Map<string, string | string[]>} */
92
102
  const commonBricksMap = new Map();
93
103
  for (const [pkg, bricks] of Object.entries(commonBricksJson)) {
94
104
  for (const brick of bricks) {
95
105
  const existedPkg = commonBricksMap.get(brick);
96
106
  if (existedPkg && existedPkg !== pkg) {
97
- throw new Error(
98
- `Conflicted common brick: "${brick}" in package "${existedPkg}" and "${pkg}"`
99
- );
107
+ if (Array.isArray(existedPkg)) {
108
+ const pkgs = existedPkg.concat(pkg);
109
+
110
+ const othersPkgs = pkgs.filter(
111
+ (p) => !deprecatedBricksJson[p]?.includes(brick)
112
+ );
113
+
114
+ throw new Error(
115
+ `Conflicted common brick: "${brick}" in package "${othersPkgs[0]}" and "${othersPkgs[1]}"`
116
+ );
117
+ } else {
118
+ const existedPkgDeprecated = deprecatedBricksJson[existedPkg];
119
+ const pkgDeprecated = deprecatedBricksJson[pkg];
120
+
121
+ if (
122
+ (existedPkgDeprecated && existedPkgDeprecated.includes(brick)) ||
123
+ (pkgDeprecated && pkgDeprecated.includes(brick))
124
+ ) {
125
+ commonBricksMap.set(brick, [pkg].concat(existedPkg));
126
+ continue;
127
+ }
128
+
129
+ throw new Error(
130
+ `Conflicted common brick: "${brick}" in package "${existedPkg}" and "${pkg}"`
131
+ );
132
+ }
100
133
  }
101
134
  commonBricksMap.set(brick, pkg);
102
135
  }
@@ -470,6 +503,12 @@ async function getWebpackConfig(config) {
470
503
  manifest: config.manifest,
471
504
  types: config.types,
472
505
  examples: config.examples,
506
+ deprecatedElements: Object.prototype.hasOwnProperty.call(
507
+ deprecatedBricksJson,
508
+ packageName
509
+ )
510
+ ? deprecatedBricksJson[packageName]
511
+ : undefined,
473
512
  }),
474
513
  ]
475
514
  : []),
@@ -105,6 +105,9 @@ export default function makeBrickManifest(name, alias, nodePath, source) {
105
105
  }
106
106
  break;
107
107
  }
108
+ case "insider": {
109
+ manifest.insider = true;
110
+ }
108
111
  }
109
112
  }
110
113
  }