esa-cli 0.0.2-beta.20 → 0.0.2-beta.22

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.
@@ -16,7 +16,7 @@ import promptParameter from '../../utils/prompt.js';
16
16
  import { validateAndInitializeProject, generateCodeVersion } from '../common/utils.js';
17
17
  const commit = {
18
18
  command: 'commit [entry]',
19
- describe: `📥 ${t('commit_describe').d('Commit your code, save as a new version')}`,
19
+ describe: `📦 ${t('commit_describe').d('Commit your code, save as a new version')}`,
20
20
  builder: (yargs) => {
21
21
  return yargs
22
22
  .option('minify', {
@@ -61,6 +61,9 @@ export function commitRoutineWithAssets(requestParams, zipBuffer) {
61
61
  if (uploadSuccess) {
62
62
  break;
63
63
  }
64
+ if (i < 2) {
65
+ yield new Promise((resolve) => setTimeout(resolve, 2000));
66
+ }
64
67
  }
65
68
  return {
66
69
  isSuccess: uploadSuccess,
@@ -4,7 +4,7 @@ import deploymentsList from './list.js';
4
4
  let yargsIns;
5
5
  const deploymentsCommand = {
6
6
  command: 'deployments [script]',
7
- describe: `🚀 ${t('deployments_describe').d('Manage your deployments')}`,
7
+ describe: `📜 ${t('deployments_describe').d('Manage your deployments')}`,
8
8
  builder: (yargs) => {
9
9
  yargsIns = yargs;
10
10
  return yargs
@@ -1,5 +1,30 @@
1
+ import path from 'path';
2
+ import fs from 'fs';
3
+ import { getRoot } from '../../../utils/fileUtils/base.js';
4
+ import t from '../../../i18n/index.js';
1
5
  class EdgeKV {
2
- constructor() { }
6
+ constructor() {
7
+ const root = getRoot();
8
+ const kvPath = path.join(root, 'kv.json');
9
+ if (fs.existsSync(kvPath)) {
10
+ try {
11
+ const kvJson = fs.readFileSync(kvPath, 'utf8');
12
+ const kvJsonObj = JSON.parse(kvJson);
13
+ console.log(kvJsonObj);
14
+ Object.keys(kvJsonObj).forEach((namespace) => {
15
+ const childMap = new Map();
16
+ Object.keys(kvJsonObj[namespace]).forEach((key) => {
17
+ childMap.set(key, JSON.stringify(kvJsonObj[namespace][key]));
18
+ });
19
+ EdgeKV.store.set(namespace, childMap);
20
+ });
21
+ console.log(EdgeKV.store);
22
+ }
23
+ catch (err) {
24
+ console.log(t('kv_parse_failed').d('kv.json parse failed, use empty local kv store.'));
25
+ }
26
+ }
27
+ }
3
28
  get(key, namespace) {
4
29
  const store = EdgeKV.store.get(namespace);
5
30
  if (!store || !store.has(key)) {
@@ -134,10 +134,10 @@ class EdgeKV {
134
134
  );
135
135
  }
136
136
  case 'stream':
137
- const stream = fetchRes.body;
137
+ const value = await fetchRes.text();
138
138
  return new ReadableStream({
139
139
  start(controller) {
140
- controller.enqueue(new TextEncoder().encode('hello world'));
140
+ controller.enqueue(new TextEncoder().encode(value));
141
141
  controller.close();
142
142
  }
143
143
  });
@@ -14,7 +14,7 @@ import { getProjectConfig } from '../../utils/fileUtils/index.js';
14
14
  import { bindRoutineWithDomain, checkDirectory, checkIsLoginSuccess, validDomain, validName } from '../utils.js';
15
15
  const addDomain = {
16
16
  command: 'add <domain>',
17
- describe: `📥 ${t('domain_add_describe').d('Bind a domain to a routine')}`,
17
+ describe: `🔗 ${t('domain_add_describe').d('Bind a domain to a routine')}`,
18
18
  builder: (yargs) => {
19
19
  return yargs
20
20
  .positional('domain', {
@@ -5,7 +5,7 @@ import listDomain from './list.js';
5
5
  let yargsIns;
6
6
  const domainCommand = {
7
7
  command: 'domain [script]',
8
- describe: `🚀 ${t('domain_describe').d('Manage the domain names bound to your routine')}`,
8
+ describe: `🔗 ${t('domain_describe').d('Manage the domain names bound to your routine')}`,
9
9
  builder: (yargs) => {
10
10
  yargsIns = yargs;
11
11
  return yargs
@@ -12,7 +12,7 @@ import logger from '../libs/logger.js';
12
12
  import { getCliConfig, updateCliConfigFile } from '../utils/fileUtils/index.js';
13
13
  const logout = {
14
14
  command: 'logout',
15
- describe: `📥 ${t('logout_describe').d('Logout')}`,
15
+ describe: `🚪 ${t('logout_describe').d('Logout')}`,
16
16
  builder: (yargs) => {
17
17
  return yargs;
18
18
  },
@@ -17,8 +17,8 @@ import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
17
17
  import { routeBuilder } from '../../components/routeBuilder.js';
18
18
  import { transferRouteToRuleString } from './helper.js';
19
19
  const addRoute = {
20
- command: 'add',
21
- describe: `📥 ${t('route_add_describe').d('Bind a Route to a routine')}`,
20
+ command: 'add [route] [site]',
21
+ describe: `🚄 ${t('route_add_describe').d('Bind a Route to a routine')}`,
22
22
  builder: (yargs) => {
23
23
  return yargs
24
24
  .option('route', {
@@ -5,7 +5,7 @@ import listRoute from './list.js';
5
5
  let yargsIns;
6
6
  const routeCommand = {
7
7
  command: 'route [script]',
8
- describe: `🚀 ${t('route_describe').d('Manage the routes bound to your routine')}`,
8
+ describe: `🚄 ${t('route_describe').d('Manage the routes bound to your routine')}`,
9
9
  builder: (yargs) => {
10
10
  yargsIns = yargs;
11
11
  return yargs
@@ -4,7 +4,7 @@ import routineList from './list.js';
4
4
  let yargsIns;
5
5
  const routineCommand = {
6
6
  command: 'routine [script]',
7
- describe: `🚀 ${t('routine_describe').d('Manage your routine')}`,
7
+ describe: `🧭 ${t('routine_describe').d('Manage your routine')}`,
8
8
  builder: (yargs) => {
9
9
  yargsIns = yargs;
10
10
  return yargs
@@ -3,7 +3,7 @@ import siteList from './list.js';
3
3
  let yargsIns;
4
4
  const siteCommand = {
5
5
  command: 'site [script]',
6
- describe: `🚀 ${t('site_describe').d('Manage your sites')}`,
6
+ describe: `📈 ${t('site_describe').d('Manage your sites')}`,
7
7
  builder: (yargs) => {
8
8
  yargsIns = yargs;
9
9
  return yargs
@@ -1306,5 +1306,9 @@
1306
1306
  "route_builder_instructions": {
1307
1307
  "en": "Press Enter to continue, Ctrl+C to cancel",
1308
1308
  "zh_CN": "按回车键继续,Ctrl+C 取消"
1309
+ },
1310
+ "kv_parse_failed": {
1311
+ "en": "kv.json parse failed, use empty local kv store.",
1312
+ "zh_CN": "kv.json 解析失败,使用空本地 kv 存储。"
1309
1313
  }
1310
1314
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esa-cli",
3
- "version": "0.0.2-beta.20",
3
+ "version": "0.0.2-beta.22",
4
4
  "description": "A CLI for operating Alibaba Cloud ESA EdgeRoutine (Edge Functions).",
5
5
  "main": "bin/enter.cjs",
6
6
  "type": "module",
@@ -54,6 +54,7 @@
54
54
  "@types/yargs": "^17.0.32",
55
55
  "@typescript-eslint/eslint-plugin": "^6.21.0",
56
56
  "@typescript-eslint/parser": "^6.9.1",
57
+ "eslint-plugin-react": "latest",
57
58
  "husky": "^8.0.3",
58
59
  "jsdom": "^25.0.1",
59
60
  "lint-staged": "^15.0.2",