Skip to content

Commit fb2603d

Browse files
authored
Bump 0.0.11 (#93)
* Bump 0.0.11 * doc: update CHANGELOG * Bump 0.0.11 * fix: loading of profile management * fix: loading of profile management * fix: errors of loading profiles * fix: errors of switching profiles * CHANGELOG
1 parent 6959970 commit fb2603d

File tree

8 files changed

+135
-70
lines changed

8 files changed

+135
-70
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Release Notes
22

3+
## 0.0.11(2024-06-26)
4+
5+
- Profiles management: You can switch between profiles or add a new one.
6+
- Guide special products to web debugging.
7+
- Fixed some UI issues.
8+
- Update User-Agent.
9+
310
## 0.0.10(2024-05-17)
411

512
- SDK code documentation has been enhanced with the Code Sample link.

media/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@alicloud/console-components": "^1.6.2",
16+
"@ant-design/icons": "^5.3.7",
1617
"@monaco-editor/react": "^4.6.0",
1718
"@vercel/ncc": "^0.38.1",
1819
"@vscode-elements/elements": "^1.3.0",

media/src/components/ProfileManager/ProfileManagerIndex.tsx

Lines changed: 83 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import { Button, Form, Input, Message } from "@alicloud/console-components";
66
import React from "react";
77
import { PontUIService } from "../../service/UIService";
8+
import { message } from "antd";
9+
import { LoadingOutlined } from "@ant-design/icons";
810

911
export class ProfileManagerIndexProps {}
1012

@@ -30,7 +32,10 @@ export const ProfileManagerIndex: React.FC<ProfileManagerIndexProps> = (props) =
3032
</div>
3133
{status === "success" ? (
3234
<div className="my-4 text-base">
33-
<Message type="success">新增成功!</Message>
35+
<div className="flex w-[100%] rounded-sm bg-[#d8f5d8] px-4 py-2 text-sm">
36+
<div className="codicon codicon-pass-filled success m-[2px] mr-1 leading-5 text-green-600"></div>
37+
<div className="text-[12px] leading-5 text-gray-600">新增成功!</div>
38+
</div>
3439
<div className="my-8 flex justify-end">
3540
<Button
3641
type="primary"
@@ -51,72 +56,84 @@ export const ProfileManagerIndex: React.FC<ProfileManagerIndexProps> = (props) =
5156
</div>
5257
</div>
5358
) : (
54-
<Form labelAlign="left">
55-
<Form.Item label={<span className="text-sm font-medium">Profile 名称</span>} required>
56-
<span className="text-gray-500">用于区别不同的 profiles。</span>
57-
<Input id="profileName" name="profileName" placeholder="请输入字符串" />
58-
</Form.Item>
59-
<Form.Item label={<span className="text-sm font-medium">Access Key</span>} required>
60-
<span className="text-gray-500">
61-
获取方式请参见
62-
<a
63-
href="https://help.aliyun.com/zh/ram/user-guide/create-an-accesskey-pair#title-ebf-nrl-l0i"
64-
target="_blank"
65-
>
66-
创建 RAM 用户的 AccessKey
67-
</a>
68-
69-
</span>
70-
<Input id="accessKey" name="accessKey" placeholder="指定您的AccessKey ID" />
71-
</Form.Item>
72-
<Form.Item label={<span className="text-sm font-medium">Secret Key</span>} required>
73-
<span className="text-gray-500">
74-
获取方式请参见
75-
<a
76-
href="https://help.aliyun.com/zh/ram/user-guide/create-an-accesskey-pair#title-ebf-nrl-l0i"
77-
target="_blank"
59+
<div>
60+
{status === "loading" ? (
61+
<div className="my-4 flex w-[100%] rounded-sm bg-[#f6f6f6] px-4 py-2 text-sm">
62+
<LoadingOutlined />
63+
<div className="ml-2 text-[12px] leading-5 text-gray-600">写入中...</div>
64+
</div>
65+
) : null}
66+
<Form labelAlign="left">
67+
<Form.Item label={<span className="text-sm font-medium">Profile 名称</span>} required>
68+
<span className="text-gray-500">用于区别不同的 profiles。</span>
69+
<Input id="profileName" name="profileName" placeholder="请输入字符串" />
70+
</Form.Item>
71+
<Form.Item label={<span className="text-sm font-medium">Access Key</span>} required>
72+
<span className="text-gray-500">
73+
获取方式请参见
74+
<a
75+
href="https://help.aliyun.com/zh/ram/user-guide/create-an-accesskey-pair#title-ebf-nrl-l0i"
76+
target="_blank"
77+
>
78+
创建 RAM 用户的 AccessKey
79+
</a>
80+
81+
</span>
82+
<Input id="accessKey" name="accessKey" placeholder="指定您的AccessKey ID" />
83+
</Form.Item>
84+
<Form.Item label={<span className="text-sm font-medium">Secret Key</span>} required>
85+
<span className="text-gray-500">
86+
获取方式请参见
87+
<a
88+
href="https://help.aliyun.com/zh/ram/user-guide/create-an-accesskey-pair#title-ebf-nrl-l0i"
89+
target="_blank"
90+
>
91+
创建 RAM 用户的 AccessKey
92+
</a>
93+
94+
</span>
95+
<Input id="secretKey" name="secretKey" placeholder="指定您的AccessKey Secret" />
96+
</Form.Item>
97+
<Form.Item label={<span className="text-sm font-medium">默认 Region Id</span>} required>
98+
<span className="text-gray-500">
99+
阿里云支持的 Region Id ,请参见
100+
<a
101+
href="https://help.aliyun.com/zh/ecs/product-overview/regions-and-zones#concept-2459516"
102+
target="_blank"
103+
>
104+
地域和可用区
105+
</a>
106+
107+
</span>
108+
<Input id="defaultRegionId" name="defaultRegionId" placeholder="指定默认区域的Region Id" />
109+
</Form.Item>
110+
<div className="flex">
111+
<Form.Submit
112+
validate
113+
type="primary"
114+
onClick={(submitValue, errors) => {
115+
if (errors) {
116+
return;
117+
} else {
118+
setStatus("loading");
119+
PontUIService.addNewAKProfile(submitValue).then((res) => {
120+
if (res.success === true) {
121+
setStatus("success");
122+
} else {
123+
message.error("添加失败,请重试");
124+
setStatus("edit");
125+
}
126+
});
127+
}
128+
}}
129+
className="text-right"
78130
>
79-
创建 RAM 用户的 AccessKey
80-
</a>
81-
82-
</span>
83-
<Input id="secretKey" name="secretKey" placeholder="指定您的AccessKey Secret" />
84-
</Form.Item>
85-
<Form.Item label={<span className="text-sm font-medium">默认 Region Id</span>} required>
86-
<span className="text-gray-500">
87-
阿里云支持的 Region Id ,请参见
88-
<a
89-
href="https://help.aliyun.com/zh/ecs/product-overview/regions-and-zones#concept-2459516"
90-
target="_blank"
91-
>
92-
地域和可用区
93-
</a>
94-
95-
</span>
96-
<Input id="defaultRegionId" name="defaultRegionId" placeholder="指定默认区域的Region Id" />
97-
</Form.Item>
98-
<div className="flex">
99-
<Form.Submit
100-
validate
101-
type="primary"
102-
onClick={(submitValue, errors) => {
103-
if (errors) {
104-
return;
105-
} else {
106-
PontUIService.addNewAKProfile(submitValue).then((res) => {
107-
if (res.success === true) {
108-
setStatus("success");
109-
}
110-
});
111-
}
112-
}}
113-
className="text-right"
114-
>
115-
新增
116-
</Form.Submit>
117-
<Form.Reset style={{ marginLeft: 10 }}>重置</Form.Reset>
118-
</div>
119-
</Form>
131+
新增
132+
</Form.Submit>
133+
<Form.Reset style={{ marginLeft: 10 }}>重置</Form.Reset>
134+
</div>
135+
</Form>
136+
</div>
120137
)}
121138
</div>
122139
</div>

media/yarn.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@
9292
resolved "https://registry.npmmirror.com/@ant-design/icons-svg/-/icons-svg-4.3.1.tgz#4b2f65a17d4d32b526baa6414aca2117382bf8da"
9393
integrity sha512-4QBZg8ccyC6LPIRii7A0bZUk3+lEDCLnhB+FVsflGdcWPPmV+j3fire4AwwoqHV/BibgvBmR9ZIo4s867smv+g==
9494

95+
"@ant-design/icons-svg@^4.4.0":
96+
version "4.4.2"
97+
resolved "https://registry.npmmirror.com/@ant-design/icons-svg/-/icons-svg-4.4.2.tgz#ed2be7fb4d82ac7e1d45a54a5b06d6cecf8be6f6"
98+
integrity sha512-vHbT+zJEVzllwP+CM+ul7reTEfBR0vgxFe7+lREAsAA7YGsYpboiq2sQNeQeRvh09GfQgs/GyFEvZpJ9cLXpXA==
99+
95100
"@ant-design/icons@^5.2.6":
96101
version "5.2.6"
97102
resolved "https://registry.npmmirror.com/@ant-design/icons/-/icons-5.2.6.tgz#2d4a9a37f531eb2a20cebec01d6fb69cf593900d"
@@ -103,6 +108,17 @@
103108
classnames "^2.2.6"
104109
rc-util "^5.31.1"
105110

111+
"@ant-design/icons@^5.3.7":
112+
version "5.3.7"
113+
resolved "https://registry.npmmirror.com/@ant-design/icons/-/icons-5.3.7.tgz#d9f3654bf7934ee5faba43f91b5a187f5309ec68"
114+
integrity sha512-bCPXTAg66f5bdccM4TT21SQBDO1Ek2gho9h3nO9DAKXJP4sq+5VBjrQMSxMVXSB3HyEz+cUbHQ5+6ogxCOpaew==
115+
dependencies:
116+
"@ant-design/colors" "^7.0.0"
117+
"@ant-design/icons-svg" "^4.4.0"
118+
"@babel/runtime" "^7.11.2"
119+
classnames "^2.2.6"
120+
rc-util "^5.31.1"
121+
106122
"@ant-design/react-slick@~1.0.2":
107123
version "1.0.2"
108124
resolved "https://registry.npmmirror.com/@ant-design/react-slick/-/react-slick-1.0.2.tgz#241bb412aeacf7ff5d50c61fa5db66773fde6b56"
@@ -5644,6 +5660,7 @@ string-convert@^0.2.0:
56445660
integrity sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==
56455661

56465662
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
5663+
name string-width-cjs
56475664
version "4.2.3"
56485665
resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
56495666
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Alibaba Cloud API Toolkit",
44
"description": "The Alibaba Cloud API Toolkit for VSCode makes it easier to access Alibaba Cloud services.",
55
"author": "Alibaba Cloud SDK Team",
6-
"version": "0.0.10",
6+
"version": "0.0.11",
77
"private": true,
88
"publisher": "alibabacloud-openapi",
99
"license": "Apache-2.0",

src/Service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ export class AlicloudAPIService {
353353
response,
354354
};
355355
} else {
356-
let result = await vscode.window.showErrorMessage("请完成AK/SK配置后,再发起调用", "查看配置方法", "取消");
357-
if (result === "查看配置方法") {
358-
vscode.env.openExternal(vscode.Uri.parse("https://github.com/aliyun/aliyun-cli?tab=readme-ov-file#configure"));
356+
let result = await vscode.window.showErrorMessage("请完成AK/SK配置后,再发起调用", "去配置", "取消");
357+
if (result === "去配置") {
358+
this.openProfileManager();
359359
}
360360
}
361361
}

src/commands.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import * as fs from "fs-extra";
1818
import { Product } from "./types";
1919
import { codeSampleProvider } from "./plugins/generate";
2020
import { generateImport } from "./common/generateImport";
21+
import { getProfileInfoInstance } from "./profileManager";
2122

2223
const path = require("path");
2324

@@ -274,6 +275,8 @@ export class AlicloudApiCommands {
274275
});
275276

276277
vscode.commands.registerCommand("alicloud.api.restart", async () => {
278+
const profileInfo = await getProfileInfoInstance();
279+
await profileInfo.refreshProfiles();
277280
await vscode.window.withProgress(
278281
{
279282
location: vscode.ProgressLocation.Window,

src/profileManager.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,31 @@ export class ProfileManager {
7171
await this.saveProfiles(config);
7272
}
7373

74+
async checkAliyunDir() {
75+
const filePath = path.join(os.homedir(), ".aliyun");
76+
const { R_OK, W_OK } = fs.constants;
77+
try {
78+
// 检测写入权限
79+
await fsx.access(os.homedir(), R_OK | W_OK);
80+
// 检查文件夹是否存在
81+
fs.stat(filePath, async (err) => {
82+
if (err && err.code === "ENOENT") {
83+
// 不存在,创建它
84+
await fs.promises.mkdir(filePath);
85+
}
86+
});
87+
} catch (ex) {
88+
console.error("创建文件夹时出错:", ex);
89+
}
90+
}
91+
7492
async loadProfiles() {
7593
const configFilePath = path.join(os.homedir(), ".aliyun/config.json");
7694
const { R_OK, W_OK } = fs.constants;
7795
try {
96+
await this.checkAliyunDir();
7897
await fsx.access(configFilePath, R_OK | W_OK);
98+
// 检查 dirTest 文件夹是否存在
7999
const content = await fsx.readFile(configFilePath, "utf-8");
80100
return JSON.parse(content);
81101
} catch (ex) {

0 commit comments

Comments
 (0)