@blocklet/launcher-util 2.0.23 → 2.0.25

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.
@@ -0,0 +1,31 @@
1
+ const flat = require('flat');
2
+ const { SERVERLESS_INSTANCE_STATUS, INSTANCE_STATUS } = require('../constant');
3
+
4
+ module.exports = flat({
5
+ common: {
6
+ duration: 'Duration',
7
+ },
8
+ serverlessInstance: {
9
+ appStatus: {
10
+ [SERVERLESS_INSTANCE_STATUS.launching]: 'Launching',
11
+ [SERVERLESS_INSTANCE_STATUS.running]: 'Running',
12
+ [SERVERLESS_INSTANCE_STATUS.expired]: 'Expired',
13
+ },
14
+ },
15
+ dedicatedInstance: {
16
+ appStatus: {
17
+ [INSTANCE_STATUS.unknown]: 'Unknown',
18
+ [INSTANCE_STATUS.pending]: 'Pending',
19
+ [INSTANCE_STATUS.starting]: 'Starting',
20
+ [INSTANCE_STATUS.running]: 'Running',
21
+ [INSTANCE_STATUS.restarting]: 'Restarting',
22
+ [INSTANCE_STATUS.stopping]: 'Stopping',
23
+ [INSTANCE_STATUS.stopped]: 'Stopped',
24
+ [INSTANCE_STATUS.terminated]: 'Terminated',
25
+ [INSTANCE_STATUS.expired]: 'Expired',
26
+ [INSTANCE_STATUS.error]: 'Error',
27
+ [INSTANCE_STATUS.waiting]: 'Waiting',
28
+ [INSTANCE_STATUS.underMaintenance]: 'Under-Maintenance',
29
+ },
30
+ },
31
+ });
@@ -0,0 +1,31 @@
1
+ const flat = require('flat');
2
+ const { SERVERLESS_INSTANCE_STATUS, INSTANCE_STATUS } = require('../constant');
3
+
4
+ module.exports = flat({
5
+ common: {
6
+ duration: '时长',
7
+ },
8
+ serverlessInstance: {
9
+ appStatus: {
10
+ [SERVERLESS_INSTANCE_STATUS.launching]: '启动中',
11
+ [SERVERLESS_INSTANCE_STATUS.running]: '运行中',
12
+ [SERVERLESS_INSTANCE_STATUS.expired]: '已过期',
13
+ },
14
+ },
15
+ dedicatedInstance: {
16
+ appStatus: {
17
+ [INSTANCE_STATUS.unknown]: '位置',
18
+ [INSTANCE_STATUS.pending]: '待处理',
19
+ [INSTANCE_STATUS.starting]: '启动中',
20
+ [INSTANCE_STATUS.running]: '运行中',
21
+ [INSTANCE_STATUS.restarting]: '重启中',
22
+ [INSTANCE_STATUS.stopping]: '停止中',
23
+ [INSTANCE_STATUS.stopped]: '已停止',
24
+ [INSTANCE_STATUS.terminated]: '已终止',
25
+ [INSTANCE_STATUS.expired]: '已过期',
26
+ [INSTANCE_STATUS.error]: '错误',
27
+ [INSTANCE_STATUS.waiting]: '等待中',
28
+ [INSTANCE_STATUS.underMaintenance]: '维护中',
29
+ },
30
+ },
31
+ });
package/lib/util.js CHANGED
@@ -34,6 +34,13 @@ const DURATION_LOCALE = {
34
34
  },
35
35
  };
36
36
 
37
+ const formatPeriod = (duration) => {
38
+ const value = Number(duration.slice(0, duration.length - 1));
39
+ const unit = duration[duration.length - 1];
40
+
41
+ return { value, unit };
42
+ };
43
+
37
44
  const prettyDurationUnit = ({ value, unit }, locale) => {
38
45
  if (!Object.keys(DURATION_LOCALE).includes(locale)) {
39
46
  // eslint-disable-next-line no-param-reassign
@@ -96,6 +103,7 @@ const getExplorerUrl = ({ address, type = 'txs', chainHost }) => {
96
103
  };
97
104
 
98
105
  module.exports = {
106
+ formatPeriod,
99
107
  calculatePrice,
100
108
  prettyDurationUnit,
101
109
  prettyDuration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-util",
3
- "version": "2.0.23",
3
+ "version": "2.0.25",
4
4
  "description": "Common constants",
5
5
  "keywords": [
6
6
  "constant"
@@ -34,6 +34,7 @@
34
34
  "@blocklet/sdk": "^1.16.3",
35
35
  "@ocap/util": "^1.18.67",
36
36
  "axios": "^0.26.1",
37
+ "flat": "^5.0.2",
37
38
  "lodash.get": "^4.4.2",
38
39
  "lodash.pick": "^4.4.0",
39
40
  "moment": "^2.29.4",
@@ -41,5 +42,5 @@
41
42
  "nodemailer": "^6.9.1",
42
43
  "url-join": "^4.0.1"
43
44
  },
44
- "gitHead": "b279acae792d80c496430bafe6a13c34358e7385"
45
+ "gitHead": "219486bea0d20fa0a034b6e9538d749cd5a4b4cd"
45
46
  }
File without changes