@abtnode/core 1.16.45-beta-20250620-082630-c0c76051 → 1.16.45-beta-20250624-134945-a23c15fc

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.
@@ -123,6 +123,7 @@ const {
123
123
  getUserAvatarUrl,
124
124
  } = require('@abtnode/auth/lib/util/federated');
125
125
  const toBlockletDid = require('@blocklet/meta/lib/did');
126
+ const { updateComponentDid, removeUploadFile } = require('@abtnode/util/lib/upload-component');
126
127
 
127
128
  const groupBy = require('lodash/groupBy');
128
129
  const { isDidDomain, isCustomDomain } = require('@abtnode/util/lib/url-evaluation');
@@ -155,7 +156,6 @@ const {
155
156
  getConfigFromPreferences,
156
157
  validateAppConfig,
157
158
  checkDuplicateMountPoint,
158
- validateStore,
159
159
  isRotatingAppSk,
160
160
  checkVersionCompatibility,
161
161
  updateBlockletFallbackLogo,
@@ -664,9 +664,16 @@ class DiskBlockletManager extends BaseBlockletManager {
664
664
  }
665
665
 
666
666
  if (url) {
667
- const info = await states.node.read();
668
- if (isInServerlessMode(info)) {
669
- validateStore(info, url);
667
+ // 如果是 file 协议的 URI,那么就认为是上传的文件
668
+ const isUploadFile = url.startsWith('file://');
669
+ // 需要判断是否是上传的文件,如果是上传的文件,需要判断是否要更新 did,走升级的逻辑
670
+ // 不需要阻塞流程,如果失败了,就新建一个组件
671
+ try {
672
+ if (isUploadFile && did) {
673
+ await updateComponentDid(url, did);
674
+ }
675
+ } catch (error) {
676
+ logger.error('update component did failed', { error });
670
677
  }
671
678
 
672
679
  return installComponentFromUrl({
@@ -683,6 +690,7 @@ class DiskBlockletManager extends BaseBlockletManager {
683
690
  states,
684
691
  manager: this,
685
692
  onlyRequired,
693
+ isUploadFile,
686
694
  });
687
695
  }
688
696
 
@@ -773,7 +781,7 @@ class DiskBlockletManager extends BaseBlockletManager {
773
781
  this._start({ blocklet, throwOnError, checkHealthImmediately, e2eMode, componentDids: [x] }, context)
774
782
  );
775
783
  await pAll(tasks, { concurrency: 4 }).catch((err) => {
776
- throw new Error(err.errors.join(', '));
784
+ throw new Error(err.errors ? err.errors.join(', ') : err);
777
785
  });
778
786
  }
779
787
  }
@@ -2946,6 +2954,8 @@ class DiskBlockletManager extends BaseBlockletManager {
2946
2954
  skipCheckStatusBeforeDownload,
2947
2955
  componentDids,
2948
2956
  skipCheckIntegrity,
2957
+ shouldCleanUploadFile,
2958
+ url,
2949
2959
  } = params;
2950
2960
  logger.info('_downloadAndInstall', { did: blocklet?.meta?.did });
2951
2961
  const { meta } = blocklet;
@@ -3131,6 +3141,8 @@ class DiskBlockletManager extends BaseBlockletManager {
3131
3141
  componentDids,
3132
3142
  context,
3133
3143
  action: postAction,
3144
+ shouldCleanUploadFile,
3145
+ url,
3134
3146
  });
3135
3147
 
3136
3148
  const newBlocklet = await this.getBlocklet(did);
@@ -4263,7 +4275,21 @@ class DiskBlockletManager extends BaseBlockletManager {
4263
4275
  logger.info('done migration on upgrading', { did, componentDids });
4264
4276
  }
4265
4277
 
4266
- async _upgradeBlocklet({ newBlocklet, oldBlocklet, componentDids, action, context = {} }) {
4278
+ _cleanUploadFile(url) {
4279
+ setTimeout(() => {
4280
+ removeUploadFile(url);
4281
+ }, 10000); // 10s 后删除上传的文件
4282
+ }
4283
+
4284
+ async _upgradeBlocklet({
4285
+ newBlocklet,
4286
+ oldBlocklet,
4287
+ componentDids,
4288
+ action,
4289
+ context = {},
4290
+ shouldCleanUploadFile,
4291
+ url,
4292
+ }) {
4267
4293
  const { meta, source, deployedFrom, children } = newBlocklet;
4268
4294
  const { did, version, name } = meta;
4269
4295
  const title = getDisplayName(newBlocklet);
@@ -4386,6 +4412,10 @@ class DiskBlockletManager extends BaseBlockletManager {
4386
4412
  severity: 'success',
4387
4413
  });
4388
4414
 
4415
+ if (shouldCleanUploadFile && url) {
4416
+ this._cleanUploadFile(url);
4417
+ }
4418
+
4389
4419
  if (isInstallAction && process.env.NODE_ENV !== 'test') {
4390
4420
  this.start({ did, componentDids });
4391
4421
  }
@@ -35,6 +35,7 @@ const installComponentFromUrl = async ({
35
35
  manager,
36
36
  states,
37
37
  onlyRequired,
38
+ isUploadFile,
38
39
  }) => {
39
40
  const blocklet = await states.blocklet.getBlocklet(rootDid);
40
41
  if (!blocklet) {
@@ -115,6 +116,7 @@ const installComponentFromUrl = async ({
115
116
  let newChildren = filterDuplicateComponents(dynamicComponents, blocklet.children).map((x) => ({
116
117
  ...x,
117
118
  installedAt: x.installedAt || new Date(),
119
+ ...(isUploadFile ? { bundleSource: null } : {}),
118
120
  }));
119
121
 
120
122
  if (onlyRequired) {
@@ -164,6 +166,8 @@ const installComponentFromUrl = async ({
164
166
  addedComponentDids: componentDids,
165
167
  context,
166
168
  postAction: action,
169
+ shouldCleanUploadFile: isUploadFile,
170
+ url,
167
171
  };
168
172
 
169
173
  // backup rollback data
@@ -568,7 +568,7 @@ module.exports = Object.freeze({
568
568
  DEFAULT_SERVICE_PATH: '/.abtnode/service',
569
569
  DEFAULT_HTTP_PORT: 80,
570
570
  DEFAULT_HTTPS_PORT: 443,
571
- MAX_UPLOAD_FILE_SIZE: 500, // unit: MB
571
+ MAX_UPLOAD_FILE_SIZE: 100, // unit: MB
572
572
  DEFAULT_DAEMON_PORT: 8089,
573
573
  MAX_NGINX_WORKER_CONNECTIONS: 10240,
574
574
 
@@ -3,6 +3,7 @@ const fs = require('fs-extra');
3
3
  const fg = require('fast-glob');
4
4
  const { isValid: isValidDid } = require('@arcblock/did');
5
5
  const { PROJECT, BLOCKLET_RESOURCE_DIR, BLOCKLET_META_FILE } = require('@blocklet/constant');
6
+ const { hasHtmlFile } = require('@abtnode/util/lib/upload-component');
6
7
  const { expandBundle, APP_CONFIG_IMAGE_KEYS } = require('../../util');
7
8
 
8
9
  const COMPONENT_CONFIG_MAP_DIR = '.component_config';
@@ -206,11 +207,6 @@ const checkUploadExists = async (projectDir, action, releaseId, uploadedResource
206
207
  throw new Error('Only zip or gz archives are supported as resources.');
207
208
  }
208
209
 
209
- const hasHtmlFile = (dir) => {
210
- const files = ['index.html', 'index.htm'];
211
- return files.some((file) => fs.existsSync(path.join(dir, file)));
212
- };
213
-
214
210
  if (!hasHtmlFile(resourceDir)) {
215
211
  const entries = fs.readdirSync(resourceDir, { withFileTypes: true });
216
212
  const dirs = entries.filter((e) => e.isDirectory());
@@ -1,41 +1,4 @@
1
- const archiver = require('archiver');
2
- const { ensureDirSync, existsSync, removeSync, createWriteStream } = require('fs-extra');
3
- const { dirname } = require('path');
4
- const StreamZip = require('node-stream-zip');
5
-
6
- /**
7
- *
8
- *
9
- * @param {string} source ~/abc/ 通常是一个文件夹
10
- * @param {string} target abc.zip 压缩包的名称
11
- * @return {*}
12
- */
13
- function dirToZip(source, target) {
14
- return new Promise((resolve, reject) => {
15
- ensureDirSync(dirname(target));
16
-
17
- if (existsSync(target)) {
18
- removeSync(target);
19
- }
20
-
21
- const output = createWriteStream(target);
22
- const archive = archiver('zip', { level: 9 });
23
- archive.on('error', (err) => reject(err));
24
- output.on('close', () => resolve());
25
-
26
- archive.directory(source, false);
27
-
28
- archive.pipe(output);
29
- archive.finalize();
30
- });
31
- }
32
-
33
- async function zipToDir(source, target) {
34
- // eslint-disable-next-line new-cap
35
- const zip = new StreamZip.async({ file: source });
36
- await zip.extract(null, target);
37
- await zip.close();
38
- }
1
+ const { dirToZip, zipToDir } = require('@abtnode/util/lib/zip');
39
2
 
40
3
  module.exports = {
41
4
  dirToZip,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.45-beta-20250620-082630-c0c76051",
6
+ "version": "1.16.45-beta-20250624-134945-a23c15fc",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,22 +19,22 @@
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.45-beta-20250620-082630-c0c76051",
23
- "@abtnode/auth": "1.16.45-beta-20250620-082630-c0c76051",
24
- "@abtnode/certificate-manager": "1.16.45-beta-20250620-082630-c0c76051",
25
- "@abtnode/client": "1.16.45-beta-20250620-082630-c0c76051",
26
- "@abtnode/constant": "1.16.45-beta-20250620-082630-c0c76051",
27
- "@abtnode/cron": "1.16.45-beta-20250620-082630-c0c76051",
28
- "@abtnode/db-cache": "1.16.45-beta-20250620-082630-c0c76051",
29
- "@abtnode/docker-utils": "1.16.45-beta-20250620-082630-c0c76051",
30
- "@abtnode/logger": "1.16.45-beta-20250620-082630-c0c76051",
31
- "@abtnode/models": "1.16.45-beta-20250620-082630-c0c76051",
32
- "@abtnode/queue": "1.16.45-beta-20250620-082630-c0c76051",
33
- "@abtnode/rbac": "1.16.45-beta-20250620-082630-c0c76051",
34
- "@abtnode/router-provider": "1.16.45-beta-20250620-082630-c0c76051",
35
- "@abtnode/static-server": "1.16.45-beta-20250620-082630-c0c76051",
36
- "@abtnode/timemachine": "1.16.45-beta-20250620-082630-c0c76051",
37
- "@abtnode/util": "1.16.45-beta-20250620-082630-c0c76051",
22
+ "@abtnode/analytics": "1.16.45-beta-20250624-134945-a23c15fc",
23
+ "@abtnode/auth": "1.16.45-beta-20250624-134945-a23c15fc",
24
+ "@abtnode/certificate-manager": "1.16.45-beta-20250624-134945-a23c15fc",
25
+ "@abtnode/client": "1.16.45-beta-20250624-134945-a23c15fc",
26
+ "@abtnode/constant": "1.16.45-beta-20250624-134945-a23c15fc",
27
+ "@abtnode/cron": "1.16.45-beta-20250624-134945-a23c15fc",
28
+ "@abtnode/db-cache": "1.16.45-beta-20250624-134945-a23c15fc",
29
+ "@abtnode/docker-utils": "1.16.45-beta-20250624-134945-a23c15fc",
30
+ "@abtnode/logger": "1.16.45-beta-20250624-134945-a23c15fc",
31
+ "@abtnode/models": "1.16.45-beta-20250624-134945-a23c15fc",
32
+ "@abtnode/queue": "1.16.45-beta-20250624-134945-a23c15fc",
33
+ "@abtnode/rbac": "1.16.45-beta-20250624-134945-a23c15fc",
34
+ "@abtnode/router-provider": "1.16.45-beta-20250624-134945-a23c15fc",
35
+ "@abtnode/static-server": "1.16.45-beta-20250624-134945-a23c15fc",
36
+ "@abtnode/timemachine": "1.16.45-beta-20250624-134945-a23c15fc",
37
+ "@abtnode/util": "1.16.45-beta-20250624-134945-a23c15fc",
38
38
  "@arcblock/did": "1.20.14",
39
39
  "@arcblock/did-auth": "1.20.14",
40
40
  "@arcblock/did-ext": "1.20.14",
@@ -45,14 +45,14 @@
45
45
  "@arcblock/pm2-events": "^0.0.5",
46
46
  "@arcblock/validator": "1.20.14",
47
47
  "@arcblock/vc": "1.20.14",
48
- "@blocklet/constant": "1.16.45-beta-20250620-082630-c0c76051",
48
+ "@blocklet/constant": "1.16.45-beta-20250624-134945-a23c15fc",
49
49
  "@blocklet/did-space-js": "^1.0.62",
50
- "@blocklet/env": "1.16.45-beta-20250620-082630-c0c76051",
50
+ "@blocklet/env": "1.16.45-beta-20250624-134945-a23c15fc",
51
51
  "@blocklet/error": "^0.2.5",
52
- "@blocklet/meta": "1.16.45-beta-20250620-082630-c0c76051",
53
- "@blocklet/resolver": "1.16.45-beta-20250620-082630-c0c76051",
54
- "@blocklet/sdk": "1.16.45-beta-20250620-082630-c0c76051",
55
- "@blocklet/store": "1.16.45-beta-20250620-082630-c0c76051",
52
+ "@blocklet/meta": "1.16.45-beta-20250624-134945-a23c15fc",
53
+ "@blocklet/resolver": "1.16.45-beta-20250624-134945-a23c15fc",
54
+ "@blocklet/sdk": "1.16.45-beta-20250624-134945-a23c15fc",
55
+ "@blocklet/store": "1.16.45-beta-20250624-134945-a23c15fc",
56
56
  "@blocklet/theme": "^2.13.70",
57
57
  "@fidm/x509": "^1.2.1",
58
58
  "@ocap/mcrypto": "1.20.14",
@@ -116,5 +116,5 @@
116
116
  "jest": "^29.7.0",
117
117
  "unzipper": "^0.10.11"
118
118
  },
119
- "gitHead": "70151f84be54392ce491a1f40976e533286d06b8"
119
+ "gitHead": "3b56a1dbe3fea9df0d6b644a1821afae9b376ee8"
120
120
  }