@abtnode/core 1.8.19 → 1.8.21

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.
@@ -16,10 +16,10 @@ const runUserHook = async (processId, hookName, args) => {
16
16
  return;
17
17
  }
18
18
 
19
- logger.info(`run hook:${hookName}:`, { hook });
19
+ logger.info(`run hook:${hookName}:`, { processId, hook });
20
20
  await runScript(hook, [processId, hookName].join(':'), { cwd: appDir, env: getSafeEnv(env), silent });
21
21
  } catch (error) {
22
- logger.error(`run ${hook} error:`, { error });
22
+ logger.error(`run ${hook} error:`, { processId, error });
23
23
 
24
24
  if (notification) {
25
25
  notification.create({
@@ -32,12 +32,11 @@ const runUserHook = async (processId, hookName, args) => {
32
32
  }
33
33
 
34
34
  if (exitOnError) {
35
- throw new Error(`Run [${hookName}] failed: ${error.message}`);
35
+ throw new Error(`Run [${processId} - ${hookName}] failed: ${error.message}`);
36
36
  }
37
37
  }
38
38
  };
39
39
 
40
- const preDeploy = (processId, ...args) => runUserHook(processId, 'pre-deploy', ...args);
41
40
  const preInstall = (processId, ...args) => runUserHook(processId, 'pre-install', ...args);
42
41
  const postInstall = (processId, ...args) => runUserHook(processId, 'post-install', ...args);
43
42
  const preConfig = (processId, ...args) => runUserHook(processId, 'pre-config', ...args);
@@ -56,8 +55,8 @@ const preStart = async (blocklet, options) => {
56
55
  return runUserHook(blocklet.env.processId, 'pre-start', options);
57
56
  };
58
57
 
59
- const postStart = (processId, ...args) => runUserHook(processId, 'post-start', ...args);
58
+ const postStart = (blocklet, ...args) => runUserHook(blocklet.env.processId, 'post-start', ...args);
60
59
  const preUninstall = (processId, ...args) => runUserHook(processId, 'pre-uninstall', ...args);
61
60
  const preStop = (processId, ...args) => runUserHook(processId, 'pre-stop', ...args);
62
61
 
63
- module.exports = { preDeploy, preInstall, postInstall, preStart, postStart, preUninstall, preStop, preConfig };
62
+ module.exports = { preInstall, postInstall, preStart, postStart, preUninstall, preStop, preConfig };
@@ -560,12 +560,30 @@ class BlockletManager extends BaseBlockletManager {
560
560
  }),
561
561
  });
562
562
 
563
- return this._deleteBlocklet({ did, keepData, keepLogsDir, keepConfigs }, context);
563
+ const doc = await this._deleteBlocklet({ did, keepData, keepLogsDir, keepConfigs }, context);
564
+ states.notification.create({
565
+ title: 'Blocklet Deleted',
566
+ description: `Blocklet ${doc.meta.name}@${doc.meta.version} is deleted.`,
567
+ entityType: 'blocklet',
568
+ entityId: doc.meta.did,
569
+ severity: 'success',
570
+ });
571
+ return doc;
564
572
  } catch (err) {
565
573
  // If we installed a corrupted blocklet accidentally, just cleanup the disk and state db
566
574
  if (err.code === 'BLOCKLET_CORRUPTED') {
567
575
  logger.info('blocklet is corrupted, will delete again', { did });
568
- return this._deleteBlocklet({ did, keepData, keepLogsDir, keepConfigs }, context);
576
+ const doc = await this._deleteBlocklet({ did, keepData, keepLogsDir, keepConfigs }, context);
577
+
578
+ states.notification.create({
579
+ title: 'Blocklet Deleted',
580
+ description: `Blocklet ${doc.meta.name}@${doc.meta.version} is deleted.`,
581
+ entityType: 'blocklet',
582
+ entityId: doc.meta.did,
583
+ severity: 'success',
584
+ });
585
+
586
+ return doc;
569
587
  }
570
588
 
571
589
  throw err;
@@ -681,6 +699,16 @@ class BlockletManager extends BaseBlockletManager {
681
699
 
682
700
  const newBlocklet = await this.ensureBlocklet(rootDid);
683
701
  this.emit(BlockletEvents.upgraded, { blocklet: newBlocklet, context }); // trigger router refresh
702
+
703
+ states.notification.create({
704
+ title: 'Component Deleted',
705
+ description: `Component ${child.meta.name} of ${newBlocklet.meta.name} is successfully deleted.`,
706
+ entityType: 'blocklet',
707
+ entityId: newBlocklet.meta.did,
708
+ severity: 'success',
709
+ action: `/blocklets/${newBlocklet.meta.did}/components`,
710
+ });
711
+
684
712
  return newBlocklet;
685
713
  }
686
714
 
@@ -1167,7 +1195,7 @@ class BlockletManager extends BaseBlockletManager {
1167
1195
  // ============================================================================================
1168
1196
 
1169
1197
  /**
1170
- * After the dev function finished, the caller should send a BlockletEvents.deployed event to the daemon
1198
+ * After the dev function finished, the caller should send a BlockletEvents.installed event to the daemon
1171
1199
  * @returns {Object} blocklet
1172
1200
  */
1173
1201
  async dev(folder, { rootDid, mountPoint } = {}) {
package/lib/event.js CHANGED
@@ -163,7 +163,7 @@ module.exports = ({
163
163
  const handleBlockletEvent = async (eventName, payload) => {
164
164
  const blocklet = payload.blocklet || payload;
165
165
 
166
- if ([BlockletEvents.deployed, BlockletEvents.installed].includes(eventName)) {
166
+ if ([BlockletEvents.installed].includes(eventName)) {
167
167
  await handleBlockletAdd(eventName, payload);
168
168
 
169
169
  try {
@@ -220,21 +220,17 @@ const fillBlockletConfigs = (blocklet, configs) => {
220
220
  };
221
221
 
222
222
  const ensureBlockletExpanded = async (meta, appDir) => {
223
- const { main } = meta;
224
-
225
- if (main === BLOCKLET_BUNDLE_FILE) {
226
- const bundlePath = path.join(appDir, BLOCKLET_BUNDLE_FILE);
227
- if (fs.existsSync(bundlePath)) {
228
- try {
229
- const nodeModulesPath = path.join(appDir, 'node_modules');
230
- if (fs.existsSync(nodeModulesPath)) {
231
- fs.removeSync(nodeModulesPath);
232
- }
233
- await expandBundle(bundlePath, appDir);
234
- fs.removeSync(bundlePath);
235
- } catch (err) {
236
- throw new Error(`Failed to expand blocklet bundle: ${err.message}`);
223
+ const bundlePath = path.join(appDir, BLOCKLET_BUNDLE_FILE);
224
+ if (fs.existsSync(bundlePath)) {
225
+ try {
226
+ const nodeModulesPath = path.join(appDir, 'node_modules');
227
+ if (fs.existsSync(nodeModulesPath)) {
228
+ fs.removeSync(nodeModulesPath);
237
229
  }
230
+ await expandBundle(bundlePath, appDir);
231
+ fs.removeSync(bundlePath);
232
+ } catch (err) {
233
+ throw new Error(`Failed to expand blocklet bundle: ${err.message}`);
238
234
  }
239
235
  }
240
236
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.19",
6
+ "version": "1.8.21",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,18 +19,18 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@abtnode/auth": "1.8.19",
23
- "@abtnode/certificate-manager": "1.8.19",
24
- "@abtnode/constant": "1.8.19",
25
- "@abtnode/cron": "1.8.19",
26
- "@abtnode/db": "1.8.19",
27
- "@abtnode/logger": "1.8.19",
28
- "@abtnode/queue": "1.8.19",
29
- "@abtnode/rbac": "1.8.19",
30
- "@abtnode/router-provider": "1.8.19",
31
- "@abtnode/static-server": "1.8.19",
32
- "@abtnode/timemachine": "1.8.19",
33
- "@abtnode/util": "1.8.19",
22
+ "@abtnode/auth": "1.8.21",
23
+ "@abtnode/certificate-manager": "1.8.21",
24
+ "@abtnode/constant": "1.8.21",
25
+ "@abtnode/cron": "1.8.21",
26
+ "@abtnode/db": "1.8.21",
27
+ "@abtnode/logger": "1.8.21",
28
+ "@abtnode/queue": "1.8.21",
29
+ "@abtnode/rbac": "1.8.21",
30
+ "@abtnode/router-provider": "1.8.21",
31
+ "@abtnode/static-server": "1.8.21",
32
+ "@abtnode/timemachine": "1.8.21",
33
+ "@abtnode/util": "1.8.21",
34
34
  "@arcblock/did": "1.17.19",
35
35
  "@arcblock/did-motif": "^1.1.10",
36
36
  "@arcblock/did-util": "1.17.19",
@@ -38,8 +38,8 @@
38
38
  "@arcblock/jwt": "^1.17.19",
39
39
  "@arcblock/pm2-events": "^0.0.5",
40
40
  "@arcblock/vc": "1.17.19",
41
- "@blocklet/meta": "1.8.19",
42
- "@blocklet/sdk": "1.8.19",
41
+ "@blocklet/meta": "1.8.21",
42
+ "@blocklet/sdk": "1.8.21",
43
43
  "@fidm/x509": "^1.2.1",
44
44
  "@ocap/mcrypto": "1.17.19",
45
45
  "@ocap/util": "1.17.19",
@@ -80,5 +80,5 @@
80
80
  "express": "^4.18.1",
81
81
  "jest": "^27.5.1"
82
82
  },
83
- "gitHead": "19d3e21ad3658e79a3ec60394d6c77793af7deb3"
83
+ "gitHead": "f990cddd5ef18ece7ada5d7573b8e0652d74abdc"
84
84
  }