Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump 0.0.11 #93

Merged
merged 10 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release Notes

## 0.0.11(2024-06-26)

- Profiles management: You can switch between profiles or add a new one.
- Guide special products to web debugging.
- Fixed some UI issues.
- Update User-Agent.

## 0.0.10(2024-05-17)

- SDK code documentation has been enhanced with the Code Sample link.
Expand Down
1 change: 1 addition & 0 deletions media/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"@alicloud/console-components": "^1.6.2",
"@ant-design/icons": "^5.3.7",
"@monaco-editor/react": "^4.6.0",
"@vercel/ncc": "^0.38.1",
"@vscode-elements/elements": "^1.3.0",
Expand Down
149 changes: 83 additions & 66 deletions media/src/components/ProfileManager/ProfileManagerIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import { Button, Form, Input, Message } from "@alicloud/console-components";
import React from "react";
import { PontUIService } from "../../service/UIService";
import { message } from "antd";
import { LoadingOutlined } from "@ant-design/icons";

export class ProfileManagerIndexProps {}

Expand All @@ -30,7 +32,10 @@ export const ProfileManagerIndex: React.FC<ProfileManagerIndexProps> = (props) =
</div>
{status === "success" ? (
<div className="my-4 text-base">
<Message type="success">新增成功!</Message>
<div className="flex w-[100%] rounded-sm bg-[#d8f5d8] px-4 py-2 text-sm">
<div className="codicon codicon-pass-filled success m-[2px] mr-1 leading-5 text-green-600"></div>
<div className="text-[12px] leading-5 text-gray-600">新增成功!</div>
</div>
<div className="my-8 flex justify-end">
<Button
type="primary"
Expand All @@ -51,72 +56,84 @@ export const ProfileManagerIndex: React.FC<ProfileManagerIndexProps> = (props) =
</div>
</div>
) : (
<Form labelAlign="left">
<Form.Item label={<span className="text-sm font-medium">Profile 名称</span>} required>
<span className="text-gray-500">用于区别不同的 profiles。</span>
<Input id="profileName" name="profileName" placeholder="请输入字符串" />
</Form.Item>
<Form.Item label={<span className="text-sm font-medium">Access Key</span>} required>
<span className="text-gray-500">
获取方式请参见
<a
href="https://help.aliyun.com/zh/ram/user-guide/create-an-accesskey-pair#title-ebf-nrl-l0i"
target="_blank"
>
创建 RAM 用户的 AccessKey
</a>
</span>
<Input id="accessKey" name="accessKey" placeholder="指定您的AccessKey ID" />
</Form.Item>
<Form.Item label={<span className="text-sm font-medium">Secret Key</span>} required>
<span className="text-gray-500">
获取方式请参见
<a
href="https://help.aliyun.com/zh/ram/user-guide/create-an-accesskey-pair#title-ebf-nrl-l0i"
target="_blank"
<div>
{status === "loading" ? (
<div className="my-4 flex w-[100%] rounded-sm bg-[#f6f6f6] px-4 py-2 text-sm">
<LoadingOutlined />
<div className="ml-2 text-[12px] leading-5 text-gray-600">写入中...</div>
</div>
) : null}
<Form labelAlign="left">
<Form.Item label={<span className="text-sm font-medium">Profile 名称</span>} required>
<span className="text-gray-500">用于区别不同的 profiles。</span>
<Input id="profileName" name="profileName" placeholder="请输入字符串" />
</Form.Item>
<Form.Item label={<span className="text-sm font-medium">Access Key</span>} required>
<span className="text-gray-500">
获取方式请参见
<a
href="https://help.aliyun.com/zh/ram/user-guide/create-an-accesskey-pair#title-ebf-nrl-l0i"
target="_blank"
>
创建 RAM 用户的 AccessKey
</a>
</span>
<Input id="accessKey" name="accessKey" placeholder="指定您的AccessKey ID" />
</Form.Item>
<Form.Item label={<span className="text-sm font-medium">Secret Key</span>} required>
<span className="text-gray-500">
获取方式请参见
<a
href="https://help.aliyun.com/zh/ram/user-guide/create-an-accesskey-pair#title-ebf-nrl-l0i"
target="_blank"
>
创建 RAM 用户的 AccessKey
</a>
</span>
<Input id="secretKey" name="secretKey" placeholder="指定您的AccessKey Secret" />
</Form.Item>
<Form.Item label={<span className="text-sm font-medium">默认 Region Id</span>} required>
<span className="text-gray-500">
阿里云支持的 Region Id ,请参见
<a
href="https://help.aliyun.com/zh/ecs/product-overview/regions-and-zones#concept-2459516"
target="_blank"
>
地域和可用区
</a>
</span>
<Input id="defaultRegionId" name="defaultRegionId" placeholder="指定默认区域的Region Id" />
</Form.Item>
<div className="flex">
<Form.Submit
validate
type="primary"
onClick={(submitValue, errors) => {
if (errors) {
return;
} else {
setStatus("loading");
PontUIService.addNewAKProfile(submitValue).then((res) => {
if (res.success === true) {
setStatus("success");
} else {
message.error("添加失败,请重试");
setStatus("edit");
}
});
}
}}
className="text-right"
>
创建 RAM 用户的 AccessKey
</a>
</span>
<Input id="secretKey" name="secretKey" placeholder="指定您的AccessKey Secret" />
</Form.Item>
<Form.Item label={<span className="text-sm font-medium">默认 Region Id</span>} required>
<span className="text-gray-500">
阿里云支持的 Region Id ,请参见
<a
href="https://help.aliyun.com/zh/ecs/product-overview/regions-and-zones#concept-2459516"
target="_blank"
>
地域和可用区
</a>
</span>
<Input id="defaultRegionId" name="defaultRegionId" placeholder="指定默认区域的Region Id" />
</Form.Item>
<div className="flex">
<Form.Submit
validate
type="primary"
onClick={(submitValue, errors) => {
if (errors) {
return;
} else {
PontUIService.addNewAKProfile(submitValue).then((res) => {
if (res.success === true) {
setStatus("success");
}
});
}
}}
className="text-right"
>
新增
</Form.Submit>
<Form.Reset style={{ marginLeft: 10 }}>重置</Form.Reset>
</div>
</Form>
新增
</Form.Submit>
<Form.Reset style={{ marginLeft: 10 }}>重置</Form.Reset>
</div>
</Form>
</div>
)}
</div>
</div>
Expand Down
17 changes: 17 additions & 0 deletions media/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
resolved "https://registry.npmmirror.com/@ant-design/icons-svg/-/icons-svg-4.3.1.tgz#4b2f65a17d4d32b526baa6414aca2117382bf8da"
integrity sha512-4QBZg8ccyC6LPIRii7A0bZUk3+lEDCLnhB+FVsflGdcWPPmV+j3fire4AwwoqHV/BibgvBmR9ZIo4s867smv+g==

"@ant-design/icons-svg@^4.4.0":
version "4.4.2"
resolved "https://registry.npmmirror.com/@ant-design/icons-svg/-/icons-svg-4.4.2.tgz#ed2be7fb4d82ac7e1d45a54a5b06d6cecf8be6f6"
integrity sha512-vHbT+zJEVzllwP+CM+ul7reTEfBR0vgxFe7+lREAsAA7YGsYpboiq2sQNeQeRvh09GfQgs/GyFEvZpJ9cLXpXA==

"@ant-design/icons@^5.2.6":
version "5.2.6"
resolved "https://registry.npmmirror.com/@ant-design/icons/-/icons-5.2.6.tgz#2d4a9a37f531eb2a20cebec01d6fb69cf593900d"
Expand All @@ -103,6 +108,17 @@
classnames "^2.2.6"
rc-util "^5.31.1"

"@ant-design/icons@^5.3.7":
version "5.3.7"
resolved "https://registry.npmmirror.com/@ant-design/icons/-/icons-5.3.7.tgz#d9f3654bf7934ee5faba43f91b5a187f5309ec68"
integrity sha512-bCPXTAg66f5bdccM4TT21SQBDO1Ek2gho9h3nO9DAKXJP4sq+5VBjrQMSxMVXSB3HyEz+cUbHQ5+6ogxCOpaew==
dependencies:
"@ant-design/colors" "^7.0.0"
"@ant-design/icons-svg" "^4.4.0"
"@babel/runtime" "^7.11.2"
classnames "^2.2.6"
rc-util "^5.31.1"

"@ant-design/react-slick@~1.0.2":
version "1.0.2"
resolved "https://registry.npmmirror.com/@ant-design/react-slick/-/react-slick-1.0.2.tgz#241bb412aeacf7ff5d50c61fa5db66773fde6b56"
Expand Down Expand Up @@ -5644,6 +5660,7 @@ string-convert@^0.2.0:
integrity sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
name string-width-cjs
version "4.2.3"
resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Alibaba Cloud API Toolkit",
"description": "The Alibaba Cloud API Toolkit for VSCode makes it easier to access Alibaba Cloud services.",
"author": "Alibaba Cloud SDK Team",
"version": "0.0.10",
"version": "0.0.11",
"private": true,
"publisher": "alibabacloud-openapi",
"license": "Apache-2.0",
Expand Down
6 changes: 3 additions & 3 deletions src/Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ export class AlicloudAPIService {
response,
};
} else {
let result = await vscode.window.showErrorMessage("请完成AK/SK配置后,再发起调用", "查看配置方法", "取消");
if (result === "查看配置方法") {
vscode.env.openExternal(vscode.Uri.parse("https://github.com/aliyun/aliyun-cli?tab=readme-ov-file#configure"));
let result = await vscode.window.showErrorMessage("请完成AK/SK配置后,再发起调用", "去配置", "取消");
if (result === "去配置") {
this.openProfileManager();
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as fs from "fs-extra";
import { Product } from "./types";
import { codeSampleProvider } from "./plugins/generate";
import { generateImport } from "./common/generateImport";
import { getProfileInfoInstance } from "./profileManager";

const path = require("path");

Expand Down Expand Up @@ -274,6 +275,8 @@ export class AlicloudApiCommands {
});

vscode.commands.registerCommand("alicloud.api.restart", async () => {
const profileInfo = await getProfileInfoInstance();
await profileInfo.refreshProfiles();
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Window,
Expand Down
20 changes: 20 additions & 0 deletions src/profileManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,31 @@ export class ProfileManager {
await this.saveProfiles(config);
}

async checkAliyunDir() {
const filePath = path.join(os.homedir(), ".aliyun");
const { R_OK, W_OK } = fs.constants;
try {
// 检测写入权限
await fsx.access(os.homedir(), R_OK | W_OK);
// 检查文件夹是否存在
fs.stat(filePath, async (err) => {
if (err && err.code === "ENOENT") {
// 不存在,创建它
await fs.promises.mkdir(filePath);
}
});
} catch (ex) {
console.error("创建文件夹时出错:", ex);
}
}

async loadProfiles() {
const configFilePath = path.join(os.homedir(), ".aliyun/config.json");
const { R_OK, W_OK } = fs.constants;
try {
await this.checkAliyunDir();
await fsx.access(configFilePath, R_OK | W_OK);
// 检查 dirTest 文件夹是否存在
const content = await fsx.readFile(configFilePath, "utf-8");
return JSON.parse(content);
} catch (ex) {
Expand Down
Loading