@abtnode/core 1.8.30 → 1.8.31

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.
@@ -283,15 +283,38 @@ class BlockletManager extends BaseBlockletManager {
283
283
  * @param {String} name custom component name
284
284
  *
285
285
  * @param {ConfigEntry} configs pre configs
286
+ * @param {Boolean} skipNavigation
286
287
  */
287
288
  async installComponent(
288
- { rootDid, mountPoint, url, file, did, diffVersion, deleteSet, title, name, configs, downloadTokenList },
289
+ {
290
+ rootDid,
291
+ mountPoint,
292
+ url,
293
+ file,
294
+ did,
295
+ diffVersion,
296
+ deleteSet,
297
+ title,
298
+ name,
299
+ configs,
300
+ downloadTokenList,
301
+ skipNavigation,
302
+ },
289
303
  context = {}
290
304
  ) {
291
305
  logger.debug('start install component', { rootDid, mountPoint, url });
292
306
 
293
307
  if (file) {
294
- return this._installComponentFromUpload({ rootDid, mountPoint, file, did, diffVersion, deleteSet, context });
308
+ return this._installComponentFromUpload({
309
+ rootDid,
310
+ mountPoint,
311
+ file,
312
+ did,
313
+ diffVersion,
314
+ deleteSet,
315
+ skipNavigation,
316
+ context,
317
+ });
295
318
  }
296
319
 
297
320
  if (url) {
@@ -305,6 +328,7 @@ class BlockletManager extends BaseBlockletManager {
305
328
  name,
306
329
  configs,
307
330
  downloadTokenList,
331
+ skipNavigation,
308
332
  });
309
333
  }
310
334
 
@@ -1348,7 +1372,7 @@ class BlockletManager extends BaseBlockletManager {
1348
1372
  return blocklet;
1349
1373
  }
1350
1374
 
1351
- async _devComponent({ folder, meta, rootDid, mountPoint }) {
1375
+ async _devComponent({ folder, meta, rootDid, mountPoint, skipNavigation = true }) {
1352
1376
  const { did, version } = meta;
1353
1377
 
1354
1378
  const existRoot = await states.blocklet.getBlocklet(rootDid);
@@ -1392,7 +1416,7 @@ class BlockletManager extends BaseBlockletManager {
1392
1416
  await this._downloadBlocklet(newBlocklet, existRoot);
1393
1417
  await states.blocklet.setBlockletStatus(rootDid, BlockletStatus.stopped);
1394
1418
 
1395
- await this._upsertDynamicNavigation(existRoot.meta.did, children[0]);
1419
+ await this._upsertDynamicNavigation(existRoot.meta.did, { skipNavigation });
1396
1420
 
1397
1421
  // Add environments
1398
1422
  await this._setConfigsFromMeta(rootDid);
@@ -1956,6 +1980,7 @@ class BlockletManager extends BaseBlockletManager {
1956
1980
  did: inputDid,
1957
1981
  configs,
1958
1982
  downloadTokenList,
1983
+ skipNavigation,
1959
1984
  }) {
1960
1985
  const blocklet = await this._getBlockletForInstallation(rootDid);
1961
1986
  if (!blocklet) {
@@ -2018,7 +2043,7 @@ class BlockletManager extends BaseBlockletManager {
2018
2043
  await states.blocklet.addChildren(rootDid, [newChild]);
2019
2044
 
2020
2045
  // update navigation
2021
- await this._upsertDynamicNavigation(blocklet.meta.did, newChild);
2046
+ await this._upsertDynamicNavigation(blocklet.meta.did, newChild, { skipNavigation });
2022
2047
 
2023
2048
  // update configs
2024
2049
  if (Array.isArray(configs)) {
@@ -2213,7 +2238,16 @@ class BlockletManager extends BaseBlockletManager {
2213
2238
  }
2214
2239
  }
2215
2240
 
2216
- async _installComponentFromUpload({ rootDid, mountPoint, file, did, diffVersion, deleteSet, context }) {
2241
+ async _installComponentFromUpload({
2242
+ rootDid,
2243
+ mountPoint,
2244
+ file,
2245
+ did,
2246
+ diffVersion,
2247
+ deleteSet,
2248
+ skipNavigation,
2249
+ context,
2250
+ }) {
2217
2251
  logger.info('install blocklet', { from: 'upload file' });
2218
2252
  // download
2219
2253
  const { cwd, tarFile } = await this._downloadFromUpload(file);
@@ -2280,7 +2314,7 @@ class BlockletManager extends BaseBlockletManager {
2280
2314
 
2281
2315
  checkDuplicateComponents(newBlocklet.children);
2282
2316
 
2283
- await this._upsertDynamicNavigation(newBlocklet.meta.did, newChild);
2317
+ await this._upsertDynamicNavigation(newBlocklet.meta.did, newChild, { skipNavigation });
2284
2318
 
2285
2319
  await this._downloadBlocklet(newBlocklet, oldBlocklet);
2286
2320
 
@@ -3410,13 +3444,17 @@ class BlockletManager extends BaseBlockletManager {
3410
3444
  return { did, name };
3411
3445
  }
3412
3446
 
3413
- async _upsertDynamicNavigation(did, child) {
3447
+ async _upsertDynamicNavigation(did, child, { skipNavigation } = {}) {
3414
3448
  const navigation = await states.blockletExtras.getSettings(did, 'navigation', []);
3415
3449
  const item = { title: child.meta.title, child: child.meta.name };
3416
3450
  const index = navigation.findIndex((x) => x.child === item.child);
3417
3451
  if (index > -1) {
3418
- navigation.splice(index, 1, item);
3419
- } else {
3452
+ if (skipNavigation) {
3453
+ navigation.splice(index, 1);
3454
+ } else {
3455
+ navigation.splice(index, 1, item);
3456
+ }
3457
+ } else if (!skipNavigation) {
3420
3458
  navigation.push(item);
3421
3459
  }
3422
3460
  await states.blockletExtras.setSettings(did, { navigation });
@@ -328,8 +328,8 @@ class TeamManager extends EventEmitter {
328
328
  if (this.cache[did].session) {
329
329
  await closeDatabase(this.cache[did].session.db);
330
330
  }
331
- } catch (err) {
332
- logger.error('Failed to close database', { did, err });
331
+ } catch (error) {
332
+ logger.error('Failed to close database', { did, error });
333
333
  }
334
334
  }
335
335
 
@@ -23,6 +23,7 @@ const normalizePathPrefix = require('@abtnode/util/lib/normalize-path-prefix');
23
23
  const hashFiles = require('@abtnode/util/lib/hash-files');
24
24
  const isPathPrefixEqual = require('@abtnode/util/lib/is-path-prefix-equal');
25
25
  const { BLOCKLET_MAX_MEM_LIMIT_IN_MB } = require('@abtnode/constant');
26
+ const formatBackSlash = require('@abtnode/util/lib/format-back-slash');
26
27
 
27
28
  const SCRIPT_ENGINES_WHITE_LIST = ['npm', 'npx', 'pnpm', 'yarn'];
28
29
 
@@ -259,8 +260,7 @@ const getAppSystemEnvironments = (blocklet, nodeInfo) => {
259
260
  const appName = title || name || result.name;
260
261
  const appDescription = description || result.description;
261
262
 
262
- // FIXME: we should use https here when possible, eg, when did-gateway is available
263
- const appUrl = `http://${getDidDomainForBlocklet({ name, daemonDid: nodeInfo.did, didDomain: nodeInfo.didDomain })}`;
263
+ const appUrl = `https://${getDidDomainForBlocklet({ name, daemonDid: nodeInfo.did, didDomain: nodeInfo.didDomain })}`;
264
264
 
265
265
  return {
266
266
  BLOCKLET_DID: did,
@@ -946,7 +946,7 @@ const pruneBlockletBundle = async ({ blocklets, installDir, blockletSettings })
946
946
  const fillAppDirs = async (dir, level = 'root') => {
947
947
  if (level === 'version') {
948
948
  appDirs.push({
949
- key: path.relative(installDir, dir),
949
+ key: formatBackSlash(path.relative(installDir, dir)),
950
950
  dir,
951
951
  });
952
952
 
@@ -974,7 +974,7 @@ const pruneBlockletBundle = async ({ blocklets, installDir, blockletSettings })
974
974
 
975
975
  const ensureBundleDirRemoved = async (dir) => {
976
976
  const relativeDir = path.relative(installDir, dir);
977
- const arr = relativeDir.split('/').filter(Boolean);
977
+ const arr = relativeDir.split(path.sep).filter(Boolean);
978
978
  const { length } = arr;
979
979
  const bundleName = arr[length - 2];
980
980
  const scopeName = length > 2 ? arr[length - 3] : '';
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.30",
6
+ "version": "1.8.31",
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.30",
23
- "@abtnode/certificate-manager": "1.8.30",
24
- "@abtnode/constant": "1.8.30",
25
- "@abtnode/cron": "1.8.30",
26
- "@abtnode/db": "1.8.30",
27
- "@abtnode/logger": "1.8.30",
28
- "@abtnode/queue": "1.8.30",
29
- "@abtnode/rbac": "1.8.30",
30
- "@abtnode/router-provider": "1.8.30",
31
- "@abtnode/static-server": "1.8.30",
32
- "@abtnode/timemachine": "1.8.30",
33
- "@abtnode/util": "1.8.30",
22
+ "@abtnode/auth": "1.8.31",
23
+ "@abtnode/certificate-manager": "1.8.31",
24
+ "@abtnode/constant": "1.8.31",
25
+ "@abtnode/cron": "1.8.31",
26
+ "@abtnode/db": "1.8.31",
27
+ "@abtnode/logger": "1.8.31",
28
+ "@abtnode/queue": "1.8.31",
29
+ "@abtnode/rbac": "1.8.31",
30
+ "@abtnode/router-provider": "1.8.31",
31
+ "@abtnode/static-server": "1.8.31",
32
+ "@abtnode/timemachine": "1.8.31",
33
+ "@abtnode/util": "1.8.31",
34
34
  "@arcblock/did": "1.17.23",
35
35
  "@arcblock/did-motif": "^1.1.10",
36
36
  "@arcblock/did-util": "1.17.23",
@@ -38,9 +38,9 @@
38
38
  "@arcblock/jwt": "^1.17.23",
39
39
  "@arcblock/pm2-events": "^0.0.5",
40
40
  "@arcblock/vc": "1.17.23",
41
- "@blocklet/constant": "1.8.30",
42
- "@blocklet/meta": "1.8.30",
43
- "@blocklet/sdk": "1.8.30",
41
+ "@blocklet/constant": "1.8.31",
42
+ "@blocklet/meta": "1.8.31",
43
+ "@blocklet/sdk": "1.8.31",
44
44
  "@fidm/x509": "^1.2.1",
45
45
  "@ocap/mcrypto": "1.17.23",
46
46
  "@ocap/util": "1.17.23",
@@ -57,7 +57,7 @@
57
57
  "is-base64": "^1.1.0",
58
58
  "is-ip": "^3.1.0",
59
59
  "is-url": "^1.2.4",
60
- "joi": "^17.6.2",
60
+ "joi": "17.6.3",
61
61
  "js-yaml": "^4.1.0",
62
62
  "lodash": "^4.17.21",
63
63
  "lru-cache": "^6.0.0",
@@ -81,5 +81,5 @@
81
81
  "express": "^4.18.2",
82
82
  "jest": "^27.5.1"
83
83
  },
84
- "gitHead": "cb294f4ee7382c6ef7692b6c2c33ad080fced13e"
84
+ "gitHead": "f3cc8becdca1b8c5e645eb8cf751fa780cf09cfe"
85
85
  }