@abtnode/core 1.16.29-beta-e04c6f40 → 1.16.29-beta-88bdefe8
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 +25 -11
- package/lib/blocklet/project/util.js +9 -2
- package/package.json +22 -22
package/lib/api/team.js
CHANGED
|
@@ -2,7 +2,9 @@ const { EventEmitter } = require('events');
|
|
|
2
2
|
const pick = require('lodash/pick');
|
|
3
3
|
const defaults = require('lodash/defaults');
|
|
4
4
|
const cloneDeep = require('lodash/cloneDeep');
|
|
5
|
-
const { joinURL } = require('ufo');
|
|
5
|
+
const { joinURL, withQuery, resolveURL, withoutTrailingSlash } = require('ufo');
|
|
6
|
+
const axios = require('@abtnode/util/lib/axios');
|
|
7
|
+
const pRetry = require('p-retry');
|
|
6
8
|
|
|
7
9
|
const logger = require('@abtnode/logger')('@abtnode/core:api:team');
|
|
8
10
|
const {
|
|
@@ -12,7 +14,6 @@ const {
|
|
|
12
14
|
PASSPORT_STATUS,
|
|
13
15
|
WELLKNOWN_SERVICE_PATH_PREFIX,
|
|
14
16
|
MAX_USER_PAGE_SIZE,
|
|
15
|
-
STORE_DETAIL_PAGE_PATH_PREFIX,
|
|
16
17
|
MAIN_CHAIN_ENDPOINT,
|
|
17
18
|
USER_AVATAR_URL_PREFIX,
|
|
18
19
|
SESSION_TTL,
|
|
@@ -1331,14 +1332,27 @@ class TeamAPI extends EventEmitter {
|
|
|
1331
1332
|
logger.info('add store', { teamDid, url, scope });
|
|
1332
1333
|
|
|
1333
1334
|
const urlObj = new URL(url);
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
const
|
|
1340
|
-
|
|
1335
|
+
const jsonUrl = withQuery(resolveURL(url, '__blocklet__.js'), {
|
|
1336
|
+
type: 'json',
|
|
1337
|
+
});
|
|
1338
|
+
let blockletJson;
|
|
1339
|
+
try {
|
|
1340
|
+
const blockletFetchResult = await pRetry(
|
|
1341
|
+
() =>
|
|
1342
|
+
axios.get(jsonUrl, {
|
|
1343
|
+
headers: {
|
|
1344
|
+
'Content-Type': 'json',
|
|
1345
|
+
},
|
|
1346
|
+
}),
|
|
1347
|
+
{ retries: 3 }
|
|
1348
|
+
);
|
|
1349
|
+
blockletJson = blockletFetchResult?.data;
|
|
1350
|
+
} catch (error) {
|
|
1351
|
+
logger.error(`Failed to get Blockelt Store blockletMeta: ${url}`, { error });
|
|
1352
|
+
console.error(error);
|
|
1353
|
+
throw new Error(`Failed to get Blocklet Store blockletMeta, please check the url's validity: ${url}`);
|
|
1341
1354
|
}
|
|
1355
|
+
const newUrl = withoutTrailingSlash(joinURL(urlObj.origin, blockletJson?.prefix || '/'));
|
|
1342
1356
|
|
|
1343
1357
|
const sanitized = sanitizeUrl(newUrl);
|
|
1344
1358
|
|
|
@@ -1346,14 +1360,14 @@ class TeamAPI extends EventEmitter {
|
|
|
1346
1360
|
|
|
1347
1361
|
const exist = storeList.find((x) => x.url === sanitized);
|
|
1348
1362
|
if (exist) {
|
|
1349
|
-
throw new Error(`Blocklet
|
|
1363
|
+
throw new Error(`Blocklet Store already exist: ${sanitized}`);
|
|
1350
1364
|
}
|
|
1351
1365
|
|
|
1352
1366
|
const store = await StoreUtil.getStoreMeta(sanitized);
|
|
1353
1367
|
|
|
1354
1368
|
const existById = storeList.find((x) => x.id === store.id);
|
|
1355
1369
|
if (existById) {
|
|
1356
|
-
throw new Error(`Blocklet
|
|
1370
|
+
throw new Error(`Blocklet Store already exist: ${sanitized}`);
|
|
1357
1371
|
}
|
|
1358
1372
|
|
|
1359
1373
|
storeList.push({ ...store, scope, url: sanitized, protected: false });
|
|
@@ -161,10 +161,17 @@ const checkUploadExists = async (projectDir, action, releaseId, uploadedResource
|
|
|
161
161
|
}
|
|
162
162
|
fs.ensureDirSync(resourceDir);
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
try {
|
|
165
|
+
await expandBundle(uploadedFile, resourceDir);
|
|
166
|
+
} catch (err) {
|
|
167
|
+
throw new Error('When uploading resources from your disk, only zip archives are supported.');
|
|
168
|
+
}
|
|
169
|
+
|
|
165
170
|
const files = ['index.html', 'index.htm'];
|
|
166
171
|
if (files.every((file) => fs.existsSync(path.join(resourceDir, file)) === false)) {
|
|
167
|
-
throw new Error(
|
|
172
|
+
throw new Error(
|
|
173
|
+
`The uploaded resource does not contain an index.html file in the root directory of the archive: ${uploadedResource}`
|
|
174
|
+
);
|
|
168
175
|
}
|
|
169
176
|
};
|
|
170
177
|
|
package/package.json
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.29-beta-
|
|
6
|
+
"version": "1.16.29-beta-88bdefe8",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
10
10
|
"lib"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"lint": "eslint tests lib",
|
|
13
|
+
"lint": "eslint tests lib --ignore-pattern 'tests/assets/*'",
|
|
14
14
|
"lint:fix": "eslint --fix tests lib",
|
|
15
15
|
"test": "node tools/jest.js",
|
|
16
16
|
"coverage": "npm run test -- --coverage"
|
|
@@ -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.29-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.29-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.29-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.29-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.29-beta-
|
|
27
|
-
"@abtnode/logger": "1.16.29-beta-
|
|
28
|
-
"@abtnode/models": "1.16.29-beta-
|
|
29
|
-
"@abtnode/queue": "1.16.29-beta-
|
|
30
|
-
"@abtnode/rbac": "1.16.29-beta-
|
|
31
|
-
"@abtnode/router-provider": "1.16.29-beta-
|
|
32
|
-
"@abtnode/static-server": "1.16.29-beta-
|
|
33
|
-
"@abtnode/timemachine": "1.16.29-beta-
|
|
34
|
-
"@abtnode/util": "1.16.29-beta-
|
|
22
|
+
"@abtnode/analytics": "1.16.29-beta-88bdefe8",
|
|
23
|
+
"@abtnode/auth": "1.16.29-beta-88bdefe8",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.29-beta-88bdefe8",
|
|
25
|
+
"@abtnode/constant": "1.16.29-beta-88bdefe8",
|
|
26
|
+
"@abtnode/cron": "1.16.29-beta-88bdefe8",
|
|
27
|
+
"@abtnode/logger": "1.16.29-beta-88bdefe8",
|
|
28
|
+
"@abtnode/models": "1.16.29-beta-88bdefe8",
|
|
29
|
+
"@abtnode/queue": "1.16.29-beta-88bdefe8",
|
|
30
|
+
"@abtnode/rbac": "1.16.29-beta-88bdefe8",
|
|
31
|
+
"@abtnode/router-provider": "1.16.29-beta-88bdefe8",
|
|
32
|
+
"@abtnode/static-server": "1.16.29-beta-88bdefe8",
|
|
33
|
+
"@abtnode/timemachine": "1.16.29-beta-88bdefe8",
|
|
34
|
+
"@abtnode/util": "1.16.29-beta-88bdefe8",
|
|
35
35
|
"@arcblock/did": "1.18.123",
|
|
36
36
|
"@arcblock/did-auth": "1.18.123",
|
|
37
37
|
"@arcblock/did-ext": "^1.18.123",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
43
|
"@arcblock/validator": "^1.18.123",
|
|
44
44
|
"@arcblock/vc": "1.18.123",
|
|
45
|
-
"@blocklet/constant": "1.16.29-beta-
|
|
46
|
-
"@blocklet/env": "1.16.29-beta-
|
|
47
|
-
"@blocklet/meta": "1.16.29-beta-
|
|
48
|
-
"@blocklet/resolver": "1.16.29-beta-
|
|
49
|
-
"@blocklet/sdk": "1.16.29-beta-
|
|
50
|
-
"@blocklet/store": "1.16.29-beta-
|
|
45
|
+
"@blocklet/constant": "1.16.29-beta-88bdefe8",
|
|
46
|
+
"@blocklet/env": "1.16.29-beta-88bdefe8",
|
|
47
|
+
"@blocklet/meta": "1.16.29-beta-88bdefe8",
|
|
48
|
+
"@blocklet/resolver": "1.16.29-beta-88bdefe8",
|
|
49
|
+
"@blocklet/sdk": "1.16.29-beta-88bdefe8",
|
|
50
|
+
"@blocklet/store": "1.16.29-beta-88bdefe8",
|
|
51
51
|
"@did-space/client": "^0.5.1",
|
|
52
52
|
"@fidm/x509": "^1.2.1",
|
|
53
53
|
"@ocap/mcrypto": "1.18.123",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"jest": "^29.7.0",
|
|
104
104
|
"unzipper": "^0.10.11"
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "2a91288d21c8defe019e1debfc242b6ef708573e"
|
|
107
107
|
}
|