@abtnode/core 1.16.24-beta-c8847287 → 1.16.24-beta-5334b8f2

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.
@@ -9,6 +9,7 @@ const defaultLogger = require('@abtnode/logger')('@abtnode/core:resolve-download
9
9
  const { getBlockletMeta } = require('../../util');
10
10
 
11
11
  const { ensureBlockletExpanded, expandTarball, getBundleDir } = require('../../util/blocklet');
12
+ const { installExternalDependencies } = require('../../util/install-external-dependencies');
12
13
 
13
14
  const asyncFs = fs.promises;
14
15
 
@@ -76,6 +77,8 @@ const resolveDownload = async (tarFile, dist, { removeTarFile = true, logger = d
76
77
  fs.mkdirSync(installDir, { recursive: true });
77
78
 
78
79
  await fs.move(downloadDir, installDir, { overwrite: true });
80
+
81
+ installExternalDependencies(installDir);
79
82
  } catch (error) {
80
83
  fs.removeSync(downloadDir);
81
84
  fs.removeSync(tmp);
@@ -142,6 +145,8 @@ const resolveDiffDownload = async (
142
145
  logger.info('Move downloadDir to installDir', { downloadDir, bundleDir });
143
146
  await fs.move(downloadDir, bundleDir, { overwrite: true });
144
147
 
148
+ installExternalDependencies(bundleDir);
149
+
145
150
  return { meta, installDir: bundleDir };
146
151
  } catch (error) {
147
152
  fs.removeSync(downloadDir);
@@ -745,7 +745,7 @@ class DiskBlockletManager extends BaseBlockletManager {
745
745
  blocklet1.meta.title
746
746
  }: ${error.message}`;
747
747
  this._createNotification(did, {
748
- title: '',
748
+ title: 'Component start failed',
749
749
  description,
750
750
  entityType: 'blocklet',
751
751
  entityId: did,
@@ -827,7 +827,7 @@ class DiskBlockletManager extends BaseBlockletManager {
827
827
  this.configSynchronizer.throttledSyncAppConfig(blocklet.meta.did);
828
828
 
829
829
  this._createNotification(did, {
830
- title: '',
830
+ title: 'Component stop succeed',
831
831
  description: `${
832
832
  componentDids?.length ? getComponentNamesWithVersion(blocklet, componentDids) : 'All components'
833
833
  } is successfully stopped for ${blocklet.meta.title}.`,
@@ -925,7 +925,7 @@ class DiskBlockletManager extends BaseBlockletManager {
925
925
  result.meta.title
926
926
  }: ${err.message || 'queue exception'}`;
927
927
  this._createNotification(did, {
928
- title: '',
928
+ title: 'Component restart failed',
929
929
  description,
930
930
  entityType: 'blocklet',
931
931
  entityId: did,
@@ -1140,7 +1140,7 @@ class DiskBlockletManager extends BaseBlockletManager {
1140
1140
  this.emit(BlockletEvents.upgraded, { blocklet: newBlocklet, context: { ...context, createAuditLog: false } }); // trigger router refresh
1141
1141
 
1142
1142
  this._createNotification(newBlocklet.meta.did, {
1143
- title: '',
1143
+ title: 'Component delete succeed',
1144
1144
  description: `${child.meta.title} is successfully deleted for ${newBlocklet.meta.title}.`,
1145
1145
  entityType: 'blocklet',
1146
1146
  entityId: newBlocklet.meta.did,
@@ -1482,27 +1482,28 @@ class DiskBlockletManager extends BaseBlockletManager {
1482
1482
 
1483
1483
  const shouldSendWalletNotification = observableConfigs.some((x) => newConfigs.some((y) => y.key === x));
1484
1484
  const receiverUsers = await this.teamManager.getOwnerAndAdminUsers(newState.appPid, 1);
1485
- const receiver = receiverUsers.map((x) => x.did);
1485
+ const receivers = receiverUsers.map((x) => x.did);
1486
1486
 
1487
- if (shouldSendWalletNotification && receiver) {
1487
+ if (shouldSendWalletNotification && receivers.length) {
1488
1488
  const nodeInfo = await states.node.read();
1489
1489
  const blockletInfo = getBlockletInfo(newState, nodeInfo.sk);
1490
- const walletExtra = await getWalletAppNotification(newState, blockletInfo);
1490
+ const { actions, attachments } = await getWalletAppNotification(newState, blockletInfo);
1491
1491
 
1492
- const notification = {
1493
- receiver,
1494
- teamDid: newState.appPid,
1495
- title: 'Blocklet Config Changed',
1496
- description: `Blocklet ${blockletInfo.name} config changed`,
1497
- action: `/blocklets/${did}/overview`,
1498
- entityType: 'blocklet',
1499
- entityId: newState.appPid,
1500
- severity: 'success',
1501
- blockletUrl: blockletInfo.appUrl,
1502
- extra: { wallet: walletExtra },
1492
+ const sender = {
1493
+ appDid: blockletInfo.wallet.address,
1494
+ appSk: blockletInfo.wallet.secretKey,
1503
1495
  };
1504
1496
 
1505
- await this.teamManager.createNotification(notification);
1497
+ await sendToUser(
1498
+ receivers,
1499
+ {
1500
+ title: 'Blocklet Config Changed',
1501
+ body: `Blocklet ${blockletInfo.name} config changed`,
1502
+ attachments,
1503
+ actions,
1504
+ },
1505
+ sender
1506
+ );
1506
1507
  }
1507
1508
  } catch (error) {
1508
1509
  logger.error('Failed to send wallet notification after updated config', { did, error });
@@ -2375,7 +2376,7 @@ class DiskBlockletManager extends BaseBlockletManager {
2375
2376
  },
2376
2377
  });
2377
2378
  this._createNotification(did, {
2378
- title: '',
2379
+ title: 'Component download failed',
2379
2380
  description: `${childrenToDownload
2380
2381
  .map((x) => `${x.meta.title}@${x.meta.version}`)
2381
2382
  .join(', ')} download failed for ${title}: ${err.message}`,
@@ -2539,7 +2540,7 @@ class DiskBlockletManager extends BaseBlockletManager {
2539
2540
  ? `${getComponentNamesWithVersion(blocklet, componentDids)} is successfully started for ${blocklet.meta.title}.`
2540
2541
  : `${blocklet.meta.title} is successfully started`;
2541
2542
  this._createNotification(did, {
2542
- title: '',
2543
+ title: 'Component start succeed',
2543
2544
  description,
2544
2545
  entityType: 'blocklet',
2545
2546
  entityId: did,
@@ -2565,7 +2566,7 @@ class DiskBlockletManager extends BaseBlockletManager {
2565
2566
  : `${blocklet.meta.title} start failed: ${error.message}`;
2566
2567
 
2567
2568
  this._createNotification(did, {
2568
- title: '',
2569
+ title: 'Component start failed',
2569
2570
  description,
2570
2571
  entityType: 'blocklet',
2571
2572
  entityId: did,
@@ -2887,7 +2888,7 @@ class DiskBlockletManager extends BaseBlockletManager {
2887
2888
  users,
2888
2889
  }) {
2889
2890
  this._createNotification(did, {
2890
- title: '',
2891
+ title: title.en,
2891
2892
  description: description.en,
2892
2893
  entityType: 'blocklet',
2893
2894
  entityId: did,
@@ -3307,7 +3308,6 @@ class DiskBlockletManager extends BaseBlockletManager {
3307
3308
  entityType: 'blocklet',
3308
3309
  entityId: did,
3309
3310
  severity: 'success',
3310
- receiver: blocklet?.controller?.nftOwner,
3311
3311
  extra: { wallet: walletExtra },
3312
3312
  });
3313
3313
  } catch (error) {
@@ -3406,7 +3406,7 @@ class DiskBlockletManager extends BaseBlockletManager {
3406
3406
  throw error;
3407
3407
  }
3408
3408
  };
3409
- await forEachComponentV2(blocklet, runMigration, { parallel: true, concurrencyLimit: 2 });
3409
+ await forEachComponentV2(blocklet, runMigration, { parallel: true, concurrencyLimit: 4 });
3410
3410
  }
3411
3411
  logger.info('done migration on upgrading', { did, componentDids });
3412
3412
 
@@ -3466,7 +3466,7 @@ class DiskBlockletManager extends BaseBlockletManager {
3466
3466
  this.emit(notificationEvent, { ...blocklet, componentDids, context });
3467
3467
 
3468
3468
  this._createNotification(did, {
3469
- title: '',
3469
+ title: `Component ${actionName} succeed`,
3470
3470
  description: `${getComponentNamesWithVersion(
3471
3471
  newBlocklet,
3472
3472
  componentDids
@@ -3522,7 +3522,7 @@ class DiskBlockletManager extends BaseBlockletManager {
3522
3522
  });
3523
3523
 
3524
3524
  this._createNotification(did, {
3525
- title: '',
3525
+ title: `Component ${actionName} failed`,
3526
3526
  description: `${getComponentNamesWithVersion(newBlocklet, componentDids)} ${actionName} failed for ${title}: ${
3527
3527
  err.message
3528
3528
  }.`,
@@ -3792,7 +3792,7 @@ class DiskBlockletManager extends BaseBlockletManager {
3792
3792
  ...getHooksOutputFiles(b),
3793
3793
  });
3794
3794
 
3795
- await forEachBlocklet(blocklet, hookFn, { parallel: true, concurrencyLimit: 2 });
3795
+ await forEachBlocklet(blocklet, hookFn, { parallel: true, concurrencyLimit: 4 });
3796
3796
  }
3797
3797
 
3798
3798
  async _createNotification(did, notification) {
@@ -3819,8 +3819,7 @@ class DiskBlockletManager extends BaseBlockletManager {
3819
3819
  const extra = await states.blockletExtras.getMeta(did);
3820
3820
  const isExternal = !!extra?.controller;
3821
3821
 
3822
- // 如果指定了 receiver, 或者是内部 blocklet, 则创建 notification
3823
- if (notification.receiver || !isExternal) {
3822
+ if (!isExternal) {
3824
3823
  await states.notification.create({ ...notification, blockletUrl });
3825
3824
  }
3826
3825
  await this.teamManager.createNotification({
@@ -196,7 +196,7 @@ const installComponentFromUrl = async ({
196
196
  });
197
197
 
198
198
  manager._createNotification(rootDid, {
199
- title: '',
199
+ title: `Component ${actionName} failed`,
200
200
  description: `${getComponentNamesWithVersion(newBlocklet, componentDids)} ${actionName} failed for ${
201
201
  newBlocklet.meta.title
202
202
  }: ${err.message || 'queue exception'}.`,
@@ -151,7 +151,7 @@ const upgrade = async ({ updateId, componentDids, context, states, manager }) =>
151
151
  });
152
152
 
153
153
  manager._createNotification(did, {
154
- title: '',
154
+ title: 'Component upgrade failed',
155
155
  description: `${getComponentNamesWithVersion(oldBlocklet, componentDids)} upgrade failed for ${
156
156
  oldBlocklet.meta.title
157
157
  }: ${err.message || 'queue exception'}.`,
@@ -67,7 +67,7 @@ module.exports = ({
67
67
  };
68
68
 
69
69
  // Listen events from eventHub and call eventHandler
70
- [...Object.values(BlockletEvents), ...Object.values(EVENTS)].forEach((name) => {
70
+ [...Object.values(BlockletEvents), ...Object.values(TeamEvents), ...Object.values(EVENTS)].forEach((name) => {
71
71
  eventHub.on(name, (data) => {
72
72
  if (name === BlockletEvents.removed) {
73
73
  // Cleanup cache in teamManager for every node instance
@@ -106,7 +106,6 @@ 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');
110
109
 
111
110
  /**
112
111
  * get blocklet engine info, default is node
@@ -565,9 +564,6 @@ const startBlockletProcess = async (
565
564
  const env = getRuntimeEnvironments(b, nodeEnvironments, ancestors);
566
565
  const startedAt = Date.now();
567
566
 
568
- // install external dependencies
569
- await Promise.resolve(installExternalDependencies(b, { env }));
570
-
571
567
  // run hook
572
568
  await preFlight(b, { env });
573
569
 
@@ -660,7 +656,7 @@ const startBlockletProcess = async (
660
656
  logger.error('blocklet post start failed', { processId, error: err });
661
657
  });
662
658
  },
663
- { parallel: true, concurrencyLimit: 2 }
659
+ { parallel: true, concurrencyLimit: 4 }
664
660
  );
665
661
  };
666
662
 
@@ -2,27 +2,38 @@ const { spawnSync } = require('child_process');
2
2
  const fs = require('fs-extra');
3
3
  const path = require('path');
4
4
 
5
- function installExternalDependencies(blocklet, { env }) {
6
- if (!env.BLOCKLET_APP_DIR) {
7
- throw new Error('BLOCKLET_APP_DIR is required');
5
+ function installExternalDependencies(appDir) {
6
+ if (!appDir) {
7
+ throw new Error('appDir is required');
8
+ }
9
+ if (!fs.existsSync(appDir)) {
10
+ throw new Error(`not a correct appDir directory: ${appDir}`);
8
11
  }
9
12
 
10
13
  // 读取 BLOCKLET_APP_DIR 的 package.json
11
- const packageJsonPath = path.resolve(env.BLOCKLET_APP_DIR, 'package.json');
14
+ const packageJsonPath = path.resolve(appDir, 'package.json');
15
+
12
16
  if (!fs.existsSync(packageJsonPath)) {
13
17
  return;
14
18
  }
15
19
 
16
20
  const packageJson = fs.readJsonSync(packageJsonPath);
17
21
 
18
- if (!packageJson.externalManager) {
22
+ // FIXME: 梁柱, 等未来所有的 blocklet 使用了正式版, 废弃 singleExternals
23
+ const { singleExternals, blockletExternalDependencies } = packageJson;
24
+ const externals = singleExternals || blockletExternalDependencies;
25
+ if (!externals || !externals?.length) {
19
26
  return;
20
27
  }
21
28
 
22
- const result = spawnSync(packageJson.externalManager, ['install'], {
23
- cwd: env.BLOCKLET_APP_DIR,
29
+ const result = spawnSync('npm', ['install'], {
30
+ cwd: appDir,
24
31
  stdio: 'pipe',
25
32
  shell: true,
33
+ env: {
34
+ ...process.env,
35
+ NODE_ENV: 'production',
36
+ },
26
37
  });
27
38
 
28
39
  if (result.status !== 0 && result.stderr && result.stderr.toString().trim()) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.24-beta-c8847287",
6
+ "version": "1.16.24-beta-5334b8f2",
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-c8847287",
23
- "@abtnode/auth": "1.16.24-beta-c8847287",
24
- "@abtnode/certificate-manager": "1.16.24-beta-c8847287",
25
- "@abtnode/constant": "1.16.24-beta-c8847287",
26
- "@abtnode/cron": "1.16.24-beta-c8847287",
27
- "@abtnode/logger": "1.16.24-beta-c8847287",
28
- "@abtnode/models": "1.16.24-beta-c8847287",
29
- "@abtnode/queue": "1.16.24-beta-c8847287",
30
- "@abtnode/rbac": "1.16.24-beta-c8847287",
31
- "@abtnode/router-provider": "1.16.24-beta-c8847287",
32
- "@abtnode/static-server": "1.16.24-beta-c8847287",
33
- "@abtnode/timemachine": "1.16.24-beta-c8847287",
34
- "@abtnode/util": "1.16.24-beta-c8847287",
22
+ "@abtnode/analytics": "1.16.24-beta-5334b8f2",
23
+ "@abtnode/auth": "1.16.24-beta-5334b8f2",
24
+ "@abtnode/certificate-manager": "1.16.24-beta-5334b8f2",
25
+ "@abtnode/constant": "1.16.24-beta-5334b8f2",
26
+ "@abtnode/cron": "1.16.24-beta-5334b8f2",
27
+ "@abtnode/logger": "1.16.24-beta-5334b8f2",
28
+ "@abtnode/models": "1.16.24-beta-5334b8f2",
29
+ "@abtnode/queue": "1.16.24-beta-5334b8f2",
30
+ "@abtnode/rbac": "1.16.24-beta-5334b8f2",
31
+ "@abtnode/router-provider": "1.16.24-beta-5334b8f2",
32
+ "@abtnode/static-server": "1.16.24-beta-5334b8f2",
33
+ "@abtnode/timemachine": "1.16.24-beta-5334b8f2",
34
+ "@abtnode/util": "1.16.24-beta-5334b8f2",
35
35
  "@arcblock/did": "1.18.110",
36
36
  "@arcblock/did-auth": "1.18.110",
37
37
  "@arcblock/did-ext": "^1.18.110",
@@ -42,12 +42,12 @@
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-c8847287",
46
- "@blocklet/env": "1.16.24-beta-c8847287",
47
- "@blocklet/meta": "1.16.24-beta-c8847287",
48
- "@blocklet/resolver": "1.16.24-beta-c8847287",
49
- "@blocklet/sdk": "1.16.24-beta-c8847287",
50
- "@did-space/client": "^0.3.64",
45
+ "@blocklet/constant": "1.16.24-beta-5334b8f2",
46
+ "@blocklet/env": "1.16.24-beta-5334b8f2",
47
+ "@blocklet/meta": "1.16.24-beta-5334b8f2",
48
+ "@blocklet/resolver": "1.16.24-beta-5334b8f2",
49
+ "@blocklet/sdk": "1.16.24-beta-5334b8f2",
50
+ "@did-space/client": "^0.3.67",
51
51
  "@fidm/x509": "^1.2.1",
52
52
  "@ocap/mcrypto": "1.18.110",
53
53
  "@ocap/util": "1.18.110",
@@ -102,5 +102,5 @@
102
102
  "jest": "^29.7.0",
103
103
  "unzipper": "^0.10.11"
104
104
  },
105
- "gitHead": "463311bdbd2cf425eb5c1fcf94e821053de1f7b1"
105
+ "gitHead": "dc7651d34cff0f2b57e528a78969957f6ce73c8e"
106
106
  }