@abtnode/core 1.16.15-beta-324519fc → 1.16.15-beta-58d50c9a
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/blocklet/manager/disk.js +18 -32
- package/lib/blocklet/migration.js +8 -0
- package/lib/locales/en.js +1 -1
- package/lib/locales/zh.js +1 -1
- package/lib/states/audit-log.js +7 -1
- package/lib/states/backup.js +4 -3
- package/lib/util/blocklet.js +0 -1
- package/package.json +20 -20
|
@@ -1565,7 +1565,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1565
1565
|
try {
|
|
1566
1566
|
const status = await getProcessState(component.env.processId);
|
|
1567
1567
|
const oldStatus = component.status;
|
|
1568
|
-
if (component.status !== status) {
|
|
1568
|
+
if (!isInProgress(status) && component.status !== status) {
|
|
1569
1569
|
component.status = status;
|
|
1570
1570
|
addToUpdates(component.meta.did, status);
|
|
1571
1571
|
logger.info('will sync status from pm2', { did, status, oldStatus, componentDid: component.meta.did });
|
|
@@ -1675,12 +1675,6 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1675
1675
|
const info = await states.node.read();
|
|
1676
1676
|
|
|
1677
1677
|
const crons = [
|
|
1678
|
-
{
|
|
1679
|
-
name: 'sync-blocklet-status',
|
|
1680
|
-
time: '*/60 * * * * *', // 60s
|
|
1681
|
-
fn: this._syncBlockletStatus.bind(this),
|
|
1682
|
-
options: { runOnInit: false },
|
|
1683
|
-
},
|
|
1684
1678
|
{
|
|
1685
1679
|
name: 'sync-blocklet-list',
|
|
1686
1680
|
time: '*/60 * * * * *', // 60s
|
|
@@ -2422,18 +2416,6 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
2422
2416
|
}
|
|
2423
2417
|
}
|
|
2424
2418
|
|
|
2425
|
-
async _syncBlockletStatus() {
|
|
2426
|
-
const run = async (blocklet) => {
|
|
2427
|
-
try {
|
|
2428
|
-
await this.status(blocklet.meta.did);
|
|
2429
|
-
} catch (err) {
|
|
2430
|
-
logger.error('sync blocklet status failed', { error: err });
|
|
2431
|
-
}
|
|
2432
|
-
};
|
|
2433
|
-
const blocklets = await states.blocklet.getBlocklets();
|
|
2434
|
-
blocklets.forEach(run);
|
|
2435
|
-
}
|
|
2436
|
-
|
|
2437
2419
|
async _getChildrenForInstallation(component) {
|
|
2438
2420
|
if (!component) {
|
|
2439
2421
|
return [];
|
|
@@ -2708,25 +2690,29 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
2708
2690
|
await this._runPostInstallHook(blocklet, context);
|
|
2709
2691
|
|
|
2710
2692
|
logger.info('start migration');
|
|
2711
|
-
|
|
2693
|
+
{
|
|
2712
2694
|
const oldVersions = {};
|
|
2713
2695
|
forEachBlockletSync(oldBlocklet, (b, { id }) => {
|
|
2714
2696
|
oldVersions[id] = b.meta.version;
|
|
2715
2697
|
});
|
|
2716
2698
|
const nodeEnvironments = await states.node.getEnvironments();
|
|
2717
|
-
const runMigration = (b, { id, ancestors }) => {
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2699
|
+
const runMigration = async (b, { id, ancestors }) => {
|
|
2700
|
+
try {
|
|
2701
|
+
await runMigrationScripts({
|
|
2702
|
+
blocklet: b,
|
|
2703
|
+
appDir: b.env.appDir,
|
|
2704
|
+
env: getRuntimeEnvironments(b, nodeEnvironments, ancestors),
|
|
2705
|
+
oldVersion: oldVersions[id],
|
|
2706
|
+
newVersion: b.meta.version,
|
|
2707
|
+
...getHooksOutputFiles(b),
|
|
2708
|
+
});
|
|
2709
|
+
} catch (error) {
|
|
2710
|
+
logger.error('Failed to run migration scripts', { appDid: did, title: b.meta.title, error });
|
|
2711
|
+
error.message = `Failed to run migration scripts for ${b.meta.title}: ${error.message}`;
|
|
2712
|
+
throw error;
|
|
2713
|
+
}
|
|
2725
2714
|
};
|
|
2726
2715
|
await forEachBlocklet(blocklet, runMigration, { parallel: true });
|
|
2727
|
-
} catch (error) {
|
|
2728
|
-
logger.error('Failed to migrate blocklet', { did, error });
|
|
2729
|
-
throw error;
|
|
2730
2716
|
}
|
|
2731
2717
|
logger.info('end migration');
|
|
2732
2718
|
|
|
@@ -2816,7 +2802,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
2816
2802
|
: BlockletEvents.componentUpgradeFailed;
|
|
2817
2803
|
|
|
2818
2804
|
this.emit(notificationEvent, {
|
|
2819
|
-
blocklet: { ...
|
|
2805
|
+
blocklet: { ...newBlocklet, componentDids, error: { message: err.message } },
|
|
2820
2806
|
context,
|
|
2821
2807
|
});
|
|
2822
2808
|
|
|
@@ -20,6 +20,8 @@ async function runScripts({
|
|
|
20
20
|
printInfo,
|
|
21
21
|
printSuccess,
|
|
22
22
|
printError,
|
|
23
|
+
output,
|
|
24
|
+
error,
|
|
23
25
|
}) {
|
|
24
26
|
// 获取所有待执行的脚本
|
|
25
27
|
let scripts = [];
|
|
@@ -57,6 +59,8 @@ async function runScripts({
|
|
|
57
59
|
cwd: appDir,
|
|
58
60
|
env: getSafeEnv(env),
|
|
59
61
|
silent: false,
|
|
62
|
+
output,
|
|
63
|
+
error,
|
|
60
64
|
});
|
|
61
65
|
printInfo(`Migration script executed: ${scriptPath}`);
|
|
62
66
|
} catch (migrationErr) {
|
|
@@ -101,6 +105,8 @@ module.exports = async ({
|
|
|
101
105
|
printInfo = logger.info,
|
|
102
106
|
printSuccess = logger.info,
|
|
103
107
|
printError = logger.error,
|
|
108
|
+
output,
|
|
109
|
+
error,
|
|
104
110
|
}) => {
|
|
105
111
|
if (!oldVersion) {
|
|
106
112
|
return;
|
|
@@ -128,6 +134,8 @@ module.exports = async ({
|
|
|
128
134
|
printError,
|
|
129
135
|
printInfo,
|
|
130
136
|
printSuccess,
|
|
137
|
+
output,
|
|
138
|
+
error,
|
|
131
139
|
});
|
|
132
140
|
|
|
133
141
|
fs.removeSync(backupDir);
|
package/lib/locales/en.js
CHANGED
|
@@ -13,7 +13,7 @@ module.exports = flat({
|
|
|
13
13
|
},
|
|
14
14
|
isFull: 'The current Space storage space is full, please expand the space and back up again',
|
|
15
15
|
lackOfSpace:
|
|
16
|
-
'The current available space in the storage is insufficient
|
|
16
|
+
'The current available space in the storage is insufficient, Please expand the space and perform the backup again',
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
});
|
package/lib/locales/zh.js
CHANGED
package/lib/states/audit-log.js
CHANGED
|
@@ -124,7 +124,11 @@ const getLogContent = async (action, args, context, result, info, node) => {
|
|
|
124
124
|
case 'upgradeBlocklet':
|
|
125
125
|
const actionName = result.action || 'upgraded';
|
|
126
126
|
if (result.resultStatus === 'failed') {
|
|
127
|
-
|
|
127
|
+
const errMsg = result.error?.message ? `: ${result.error.message}` : '';
|
|
128
|
+
return `${actionName} component failed: **${getComponentNamesWithVersion(
|
|
129
|
+
result,
|
|
130
|
+
result.componentDids
|
|
131
|
+
)}**${errMsg}`;
|
|
128
132
|
}
|
|
129
133
|
return `${actionName} component: **${getComponentNamesWithVersion(result, result.componentDids)}**`;
|
|
130
134
|
case 'deleteComponent':
|
|
@@ -231,6 +235,8 @@ const getLogContent = async (action, args, context, result, info, node) => {
|
|
|
231
235
|
return `${args.owner} ${args.reason}`;
|
|
232
236
|
case 'issuePassportToUser':
|
|
233
237
|
return `issued **${args.role}** passport to ${user}`;
|
|
238
|
+
case 'downloadLog':
|
|
239
|
+
return `download log for ${args.days} day${args.days > 1 ? 's' : ''}`;
|
|
234
240
|
|
|
235
241
|
// accessKeys
|
|
236
242
|
case 'createAccessKey':
|
package/lib/states/backup.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { Joi } = require('@arcblock/validator');
|
|
2
|
+
const { BACKUPS } = require('@abtnode/constant');
|
|
2
3
|
const BaseState = require('./base');
|
|
3
4
|
const {
|
|
4
5
|
validateBackupSuccess,
|
|
@@ -29,7 +30,7 @@ const validateBackup = Joi.object({
|
|
|
29
30
|
updatedAt: Joi.string().optional().default('').allow(''),
|
|
30
31
|
|
|
31
32
|
// 0 表示成功了,建议使用常量表示,默认是 1 表示错误的, null 表示备份中
|
|
32
|
-
status: Joi.number().optional().allow(
|
|
33
|
+
status: Joi.number().optional().allow(BACKUPS.STATUS.PROGRESS),
|
|
33
34
|
// 发生错误的时候可以用来存储错误下信息
|
|
34
35
|
message: Joi.string().optional().default('').allow(''),
|
|
35
36
|
|
|
@@ -101,7 +102,7 @@ class BackupState extends BaseState {
|
|
|
101
102
|
{
|
|
102
103
|
$set: {
|
|
103
104
|
...value,
|
|
104
|
-
status:
|
|
105
|
+
status: BACKUPS.STATUS.SUCCEEDED,
|
|
105
106
|
updatedAt: new Date().toISOString(),
|
|
106
107
|
},
|
|
107
108
|
}
|
|
@@ -127,7 +128,7 @@ class BackupState extends BaseState {
|
|
|
127
128
|
{
|
|
128
129
|
$set: {
|
|
129
130
|
...value,
|
|
130
|
-
status:
|
|
131
|
+
status: BACKUPS.STATUS.FAILED,
|
|
131
132
|
updatedAt: new Date().toISOString(),
|
|
132
133
|
},
|
|
133
134
|
}
|
package/lib/util/blocklet.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.15-beta-
|
|
6
|
+
"version": "1.16.15-beta-58d50c9a",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -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.15-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.15-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.15-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.15-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.15-beta-
|
|
27
|
-
"@abtnode/logger": "1.16.15-beta-
|
|
28
|
-
"@abtnode/models": "1.16.15-beta-
|
|
29
|
-
"@abtnode/queue": "1.16.15-beta-
|
|
30
|
-
"@abtnode/rbac": "1.16.15-beta-
|
|
31
|
-
"@abtnode/router-provider": "1.16.15-beta-
|
|
32
|
-
"@abtnode/static-server": "1.16.15-beta-
|
|
33
|
-
"@abtnode/timemachine": "1.16.15-beta-
|
|
34
|
-
"@abtnode/util": "1.16.15-beta-
|
|
22
|
+
"@abtnode/analytics": "1.16.15-beta-58d50c9a",
|
|
23
|
+
"@abtnode/auth": "1.16.15-beta-58d50c9a",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.15-beta-58d50c9a",
|
|
25
|
+
"@abtnode/constant": "1.16.15-beta-58d50c9a",
|
|
26
|
+
"@abtnode/cron": "1.16.15-beta-58d50c9a",
|
|
27
|
+
"@abtnode/logger": "1.16.15-beta-58d50c9a",
|
|
28
|
+
"@abtnode/models": "1.16.15-beta-58d50c9a",
|
|
29
|
+
"@abtnode/queue": "1.16.15-beta-58d50c9a",
|
|
30
|
+
"@abtnode/rbac": "1.16.15-beta-58d50c9a",
|
|
31
|
+
"@abtnode/router-provider": "1.16.15-beta-58d50c9a",
|
|
32
|
+
"@abtnode/static-server": "1.16.15-beta-58d50c9a",
|
|
33
|
+
"@abtnode/timemachine": "1.16.15-beta-58d50c9a",
|
|
34
|
+
"@abtnode/util": "1.16.15-beta-58d50c9a",
|
|
35
35
|
"@arcblock/did": "1.18.89",
|
|
36
36
|
"@arcblock/did-auth": "1.18.89",
|
|
37
37
|
"@arcblock/did-ext": "^1.18.89",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
43
|
"@arcblock/validator": "^1.18.89",
|
|
44
44
|
"@arcblock/vc": "1.18.89",
|
|
45
|
-
"@blocklet/constant": "1.16.15-beta-
|
|
46
|
-
"@blocklet/env": "1.16.15-beta-
|
|
47
|
-
"@blocklet/meta": "1.16.15-beta-
|
|
48
|
-
"@blocklet/resolver": "1.16.15-beta-
|
|
49
|
-
"@blocklet/sdk": "1.16.15-beta-
|
|
45
|
+
"@blocklet/constant": "1.16.15-beta-58d50c9a",
|
|
46
|
+
"@blocklet/env": "1.16.15-beta-58d50c9a",
|
|
47
|
+
"@blocklet/meta": "1.16.15-beta-58d50c9a",
|
|
48
|
+
"@blocklet/resolver": "1.16.15-beta-58d50c9a",
|
|
49
|
+
"@blocklet/sdk": "1.16.15-beta-58d50c9a",
|
|
50
50
|
"@did-space/client": "^0.2.165",
|
|
51
51
|
"@fidm/x509": "^1.2.1",
|
|
52
52
|
"@ocap/mcrypto": "1.18.89",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"jest": "^27.5.1",
|
|
101
101
|
"unzipper": "^0.10.11"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "c54236c1daace6451db561fa6b3eea21ba07bb4d"
|
|
104
104
|
}
|