@abtnode/core 1.16.24-beta-64150e24 → 1.16.24-beta-3d2e25fd

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.
@@ -113,7 +113,6 @@ const installComponentFromUrl = async ({
113
113
  if (onlyRequired) {
114
114
  newChildren = filterRequiredComponents(newChild, newChildren);
115
115
  }
116
-
117
116
  blocklet.children.push(...newChildren);
118
117
 
119
118
  checkVersionCompatibility(blocklet.children);
@@ -106,6 +106,7 @@ const { validate: validateEngine, get: getEngine } = require('../blocklet/manage
106
106
  const isRequirementsSatisfied = require('./requirement');
107
107
  const { getDidDomainForBlocklet } = require('./get-domain-for-blocklet');
108
108
  const { expandBundle, findInterfacePortByName, prettyURL, templateReplace, getServerDidDomain } = require('./index');
109
+ const { installExternalDependencies } = require('./install-external-dependencies');
109
110
 
110
111
  /**
111
112
  * get blocklet engine info, default is node
@@ -564,6 +565,9 @@ const startBlockletProcess = async (
564
565
  const env = getRuntimeEnvironments(b, nodeEnvironments, ancestors);
565
566
  const startedAt = Date.now();
566
567
 
568
+ // install external dependencies
569
+ await Promise.resolve(installExternalDependencies(b, { env }));
570
+
567
571
  // run hook
568
572
  await preFlight(b, { env });
569
573
 
@@ -8,7 +8,40 @@ const { filterDuplicateComponents, parseComponents } = require('./blocklet');
8
8
  async function getDynamicComponents({ url }) {
9
9
  const rawMeta = await axios.get(url).then((res) => res.data);
10
10
  const { dynamicComponents } = await parseComponents({ meta: rawMeta });
11
- return filterDuplicateComponents(dynamicComponents);
11
+
12
+ const components = filterDuplicateComponents(dynamicComponents);
13
+
14
+ const requiredComponents = {};
15
+ rawMeta.components?.forEach((component) => {
16
+ if (component.required) {
17
+ requiredComponents[component.source?.name || component.name] = true;
18
+ }
19
+ });
20
+
21
+ const subRequiredComponents = {};
22
+ components.forEach((component) => {
23
+ component.required = !!requiredComponents[component.meta?.name || component.meta?.did];
24
+ if (component.required && component.meta?.components) {
25
+ component.meta.components.forEach((subComponent) => {
26
+ if (subComponent.required) {
27
+ if (subComponent.source?.name) {
28
+ subRequiredComponents[subComponent.source?.name] = true;
29
+ }
30
+ subRequiredComponents[subComponent.name] = true;
31
+ }
32
+ });
33
+ }
34
+ });
35
+ components.forEach((component) => {
36
+ if (subRequiredComponents[component.meta?.name || component.meta?.did]) {
37
+ component.required = true;
38
+ }
39
+ });
40
+
41
+ // eslint-disable-next-line no-nested-ternary
42
+ components.sort((a, b) => (a.required === b.required ? 0 : a.required ? -1 : 1));
43
+
44
+ return components;
12
45
  }
13
46
 
14
47
  module.exports = getDynamicComponents;
@@ -0,0 +1,35 @@
1
+ const { spawnSync } = require('child_process');
2
+ const fs = require('fs-extra');
3
+ const path = require('path');
4
+
5
+ function installExternalDependencies(blocklet, { env }) {
6
+ if (!env.BLOCKLET_APP_DIR) {
7
+ throw new Error('BLOCKLET_APP_DIR is required');
8
+ }
9
+
10
+ // 读取 BLOCKLET_APP_DIR 的 package.json
11
+ const packageJsonPath = path.resolve(env.BLOCKLET_APP_DIR, 'package.json');
12
+ if (!fs.existsSync(packageJsonPath)) {
13
+ return;
14
+ }
15
+
16
+ const packageJson = fs.readJsonSync(packageJsonPath);
17
+
18
+ if (!packageJson.externalManager) {
19
+ return;
20
+ }
21
+
22
+ const result = spawnSync(packageJson.externalManager, ['install'], {
23
+ cwd: env.BLOCKLET_APP_DIR,
24
+ stdio: 'pipe',
25
+ shell: true,
26
+ });
27
+
28
+ if (result.status !== 0 && result.stderr && result.stderr.toString().trim()) {
29
+ throw new Error(result.stderr.toString());
30
+ }
31
+ if (result.error) {
32
+ throw result.error;
33
+ }
34
+ }
35
+ module.exports = { installExternalDependencies };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.24-beta-64150e24",
6
+ "version": "1.16.24-beta-3d2e25fd",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,19 +19,19 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@abtnode/analytics": "1.16.24-beta-64150e24",
23
- "@abtnode/auth": "1.16.24-beta-64150e24",
24
- "@abtnode/certificate-manager": "1.16.24-beta-64150e24",
25
- "@abtnode/constant": "1.16.24-beta-64150e24",
26
- "@abtnode/cron": "1.16.24-beta-64150e24",
27
- "@abtnode/logger": "1.16.24-beta-64150e24",
28
- "@abtnode/models": "1.16.24-beta-64150e24",
29
- "@abtnode/queue": "1.16.24-beta-64150e24",
30
- "@abtnode/rbac": "1.16.24-beta-64150e24",
31
- "@abtnode/router-provider": "1.16.24-beta-64150e24",
32
- "@abtnode/static-server": "1.16.24-beta-64150e24",
33
- "@abtnode/timemachine": "1.16.24-beta-64150e24",
34
- "@abtnode/util": "1.16.24-beta-64150e24",
22
+ "@abtnode/analytics": "1.16.24-beta-3d2e25fd",
23
+ "@abtnode/auth": "1.16.24-beta-3d2e25fd",
24
+ "@abtnode/certificate-manager": "1.16.24-beta-3d2e25fd",
25
+ "@abtnode/constant": "1.16.24-beta-3d2e25fd",
26
+ "@abtnode/cron": "1.16.24-beta-3d2e25fd",
27
+ "@abtnode/logger": "1.16.24-beta-3d2e25fd",
28
+ "@abtnode/models": "1.16.24-beta-3d2e25fd",
29
+ "@abtnode/queue": "1.16.24-beta-3d2e25fd",
30
+ "@abtnode/rbac": "1.16.24-beta-3d2e25fd",
31
+ "@abtnode/router-provider": "1.16.24-beta-3d2e25fd",
32
+ "@abtnode/static-server": "1.16.24-beta-3d2e25fd",
33
+ "@abtnode/timemachine": "1.16.24-beta-3d2e25fd",
34
+ "@abtnode/util": "1.16.24-beta-3d2e25fd",
35
35
  "@arcblock/did": "1.18.110",
36
36
  "@arcblock/did-auth": "1.18.110",
37
37
  "@arcblock/did-ext": "^1.18.110",
@@ -42,11 +42,11 @@
42
42
  "@arcblock/pm2-events": "^0.0.5",
43
43
  "@arcblock/validator": "^1.18.110",
44
44
  "@arcblock/vc": "1.18.110",
45
- "@blocklet/constant": "1.16.24-beta-64150e24",
46
- "@blocklet/env": "1.16.24-beta-64150e24",
47
- "@blocklet/meta": "1.16.24-beta-64150e24",
48
- "@blocklet/resolver": "1.16.24-beta-64150e24",
49
- "@blocklet/sdk": "1.16.24-beta-64150e24",
45
+ "@blocklet/constant": "1.16.24-beta-3d2e25fd",
46
+ "@blocklet/env": "1.16.24-beta-3d2e25fd",
47
+ "@blocklet/meta": "1.16.24-beta-3d2e25fd",
48
+ "@blocklet/resolver": "1.16.24-beta-3d2e25fd",
49
+ "@blocklet/sdk": "1.16.24-beta-3d2e25fd",
50
50
  "@did-space/client": "^0.3.64",
51
51
  "@fidm/x509": "^1.2.1",
52
52
  "@ocap/mcrypto": "1.18.110",
@@ -102,5 +102,5 @@
102
102
  "jest": "^29.7.0",
103
103
  "unzipper": "^0.10.11"
104
104
  },
105
- "gitHead": "30c91a8e2790a0527ba336497f5032ba54ed4225"
105
+ "gitHead": "6dce348d0d02a6c0ef5735a0b73bfd8b2e1503fd"
106
106
  }