@abtnode/core 1.8.65-beta-5405baf2 → 1.8.65-beta-bfcc12ce

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.
package/lib/api/team.js CHANGED
@@ -178,6 +178,7 @@ class TeamAPI extends EventEmitter {
178
178
  'passports',
179
179
  'firstLoginAt',
180
180
  'lastLoginAt',
181
+ 'lastLoginIp',
181
182
  'remark',
182
183
  'avatar',
183
184
  'locale',
@@ -32,7 +32,10 @@ const isMetaFileExist = (dir) => {
32
32
  * }}
33
33
  * @returns {boolean}
34
34
  */
35
- const needDownload = (component, { installDir, logger = defaultLogger, cachedBundles = [] } = {}) => {
35
+ const needDownload = (
36
+ component,
37
+ { installDir, logger = defaultLogger, cachedBundles = [], skipCheckIntegrity } = {}
38
+ ) => {
36
39
  if (component.mode === BLOCKLET_MODES.DEVELOPMENT) {
37
40
  return false;
38
41
  }
@@ -62,10 +65,15 @@ const needDownload = (component, { installDir, logger = defaultLogger, cachedBun
62
65
  return false;
63
66
  }
64
67
 
68
+ if (skipCheckIntegrity) {
69
+ return false;
70
+ }
71
+
65
72
  // check integrity
66
73
 
67
74
  const cachedBundle = cachedBundles.find((x) => x.bundleId === bundleId);
68
75
 
76
+ // FIXME: 不是新安装的组件不应该 check, 不应该 block 安装成功 https://github.com/blocklet/launcher/actions/runs/4184577090/jobs/7250416272
69
77
  if (!cachedBundle) {
70
78
  return true;
71
79
  }
@@ -84,10 +92,12 @@ const needDownload = (component, { installDir, logger = defaultLogger, cachedBun
84
92
  class BlockletDownloader extends EventEmitter {
85
93
  /**
86
94
  * @param {{
95
+ * installDir: string,
96
+ * downloadDir: string,
87
97
  * cache: {
88
98
  * set: (key: string, value: any) => Promise
89
99
  * get: (key: string) => Promise<any>
90
- * }
100
+ * },
91
101
  * }}
92
102
  */
93
103
  constructor({ installDir, downloadDir, cache, logger = defaultLogger }) {
@@ -106,20 +116,25 @@ class BlockletDownloader extends EventEmitter {
106
116
 
107
117
  /**
108
118
  * @param {{}} blocklet
109
- * @param {{}} [context={}]
119
+ * @param {{
120
+ * preDownload: ({ downloadList: Array<meta>, downloadComponentIds: Array<string> }) => any
121
+ * postDownload: ({ downloadList: Array<meta>, downloadComponentIds: Array<string>, isCancelled: boolean }) => any
122
+ * skipCheckIntegrity: boolean
123
+ * }} [options={}]
110
124
  * @return {*}
111
125
  */
112
- async download(blocklet, context = {}) {
126
+ async download(blocklet, options = {}) {
113
127
  const {
114
128
  meta: { name, did },
115
129
  } = blocklet;
116
130
 
117
131
  this.logger.info('Download Blocklet', { name, did });
118
132
 
119
- const { preDownload = () => {}, postDownload = () => {} } = context;
133
+ const { preDownload = () => {}, postDownload = () => {}, skipCheckIntegrity } = options;
120
134
 
121
135
  const { downloadComponentIds, downloadList } = await this.getDownloadList({
122
136
  blocklet,
137
+ skipCheckIntegrity,
123
138
  });
124
139
 
125
140
  await preDownload({ downloadList, downloadComponentIds });
@@ -133,13 +148,15 @@ class BlockletDownloader extends EventEmitter {
133
148
  const tasks = [];
134
149
  for (const meta of downloadList) {
135
150
  const url = meta.dist.tarball;
136
- tasks.push(this.bundleDownloader.download(meta, did, url, context));
151
+ tasks.push(this.bundleDownloader.download(meta, did, url, options));
137
152
  }
138
153
  const results = await Promise.all(tasks);
139
154
 
140
- await postDownload({ downloadList, downloadComponentIds });
155
+ const isCancelled = results.some((x) => x.isCancelled);
156
+
157
+ await postDownload({ downloadList, downloadComponentIds, isCancelled });
141
158
 
142
- if (results.find((x) => x.isCancelled)) {
159
+ if (isCancelled) {
143
160
  return { isCancelled: true };
144
161
  }
145
162
  } catch (error) {
@@ -160,11 +177,11 @@ class BlockletDownloader extends EventEmitter {
160
177
  * blocklet;
161
178
  * }}
162
179
  * @returns {{
163
- * downloadList: Array<blockletMeta>;
164
- * downloadComponentIds: Array<string>;
180
+ * downloadList: Array<import('@abtnode/client').BlockletMeta>;
181
+ * downloadComponentIds: Array<string>; // like: "z8ia1i2yq67x39vruqQTbkVcwCnqRGx8zSPsJ/z8iZwubkNdA1BfEUwc5NJpY2Jnfm7yEbyvmKS"
165
182
  * }}
166
183
  */
167
- async getDownloadList({ blocklet }) {
184
+ async getDownloadList({ blocklet, skipCheckIntegrity }) {
168
185
  const downloadComponentIds = [];
169
186
  const metas = {};
170
187
 
@@ -178,7 +195,11 @@ class BlockletDownloader extends EventEmitter {
178
195
  return;
179
196
  }
180
197
 
181
- const needComponentDownload = needDownload(component, { installDir: this.installDir, cachedBundles });
198
+ const needComponentDownload = needDownload(component, {
199
+ installDir: this.installDir,
200
+ cachedBundles,
201
+ skipCheckIntegrity,
202
+ });
182
203
  if (!needComponentDownload) {
183
204
  this.logger.info(`skip download existed bundle ${bundleId}`, { source: component.source });
184
205
  return;