@plugin-light/cli 1.0.19 → 1.0.20

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": "@plugin-light/cli",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "本地发布",
5
5
  "keywords": [
6
6
  "plugin-light",
@@ -31,7 +31,7 @@
31
31
  "axios": "^1.12.2",
32
32
  "t-comm": "latest",
33
33
  "@plugin-light/const": "^0.1.6",
34
- "@plugin-light/shared": "^1.0.25"
34
+ "@plugin-light/shared": "^1.0.27"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public",
@@ -13,6 +13,21 @@ const {
13
13
  const { PATH_MAP } = require('./helper');
14
14
 
15
15
 
16
+ /**
17
+ * JSON.stringify 后把内容(除首行)整体向右偏移 2 空格,
18
+ * 让数组/对象内容对齐到 "subPackages" / "condition" 键的下一层缩进。
19
+ *
20
+ * "subPackages" 键本身缩进 2 空格,其数组元素应缩进 4 空格;
21
+ * 而 JSON.stringify(x, null, 2) 的数组元素默认缩进 2 空格,需 +2 补齐。
22
+ */
23
+ function indentJson(value) {
24
+ return JSON.stringify(value, null, 2)
25
+ .split('\n')
26
+ .map((line, index) => (index === 0 ? line : ` ${line}`))
27
+ .join('\n');
28
+ }
29
+
30
+
16
31
  function writeDemoPagesJson(componentConfig, needAct = false) {
17
32
  const pagesJsonConfig = getPagesJsonConfig(componentConfig, needAct);
18
33
  const configPath = path.resolve(process.cwd(), PATH_MAP.DEMO_PAGES_JSON);
@@ -21,9 +36,9 @@ function writeDemoPagesJson(componentConfig, needAct = false) {
21
36
  });
22
37
  const condition = getPagesJsonCondition(componentConfig);
23
38
  const newData = data
24
- .replace(/"subPackages":\s*\[[\s\S]+(?="preloadRule)/m, `"subPackages": ${JSON.stringify(pagesJsonConfig, null, 2)},
39
+ .replace(/"subPackages":\s*\[[\s\S]+(?="preloadRule)/m, `"subPackages": ${indentJson(pagesJsonConfig)},
25
40
  `)
26
- .replace(/"condition":\s*\{[\s\S]+\]\s*\}/, `"condition": ${JSON.stringify(condition, null, 4)}`);
41
+ .replace(/"condition":\s*\{[\s\S]+\]\s*\}/, `"condition": ${indentJson(condition)}`);
27
42
 
28
43
 
29
44
  fs.writeFileSync(configPath, newData, {