Skip to content

Feat/market logo #3

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

Merged
merged 2 commits into from
Dec 27, 2023
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
6 changes: 5 additions & 1 deletion README.en-US.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Alibaba Cloud API Toolkit

[![Version](https://img.shields.io/visual-studio-marketplace/v/alibabacloud-openapi.vscode-alicloud-api)](https://marketplace.visualstudio.com/items?itemName=alibabacloud-openapi.vscode-alicloud-api)
[![Installs](https://img.shields.io/visual-studio-marketplace/i/alibabacloud-openapi.vscode-alicloud-api)](https://marketplace.visualstudio.com/items?itemName=alibabacloud-openapi.vscode-alicloud-api)
[![Ratings](https://img.shields.io/visual-studio-marketplace/r/alibabacloud-openapi.vscode-alicloud-api)](https://marketplace.visualstudio.com/items?itemName=alibabacloud-openapi.vscode-alicloud-api)

The Alibaba Cloud API Toolkit for VSCode makes it easier to access Alibaba Cloud services.

## Features
Expand All @@ -16,7 +20,7 @@ Click to debug, you can link to Aliyun OpenAPI portal for online API trial.

## Extension UI Guide

![VSCode Extension Guide](https://img.alicdn.com/imgextra/i2/O1CN01VJNeqk1NKrbDtTotP_!!6000000001552-0-tps-2310-1524.jpg)
![VSCode Extension Guide](https://img.alicdn.com/imgextra/i1/O1CN01iYMtwm27arlqDq7V3_!!6000000007814-0-tps-2328-1540.jpg)

* Product Searching `ctrl+cmd+k`

Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# Alibaba Cloud API Toolkit

The Alibaba Cloud API Toolkit for VSCode makes it easier to access Alibaba Cloud services.
[![Version](https://img.shields.io/visual-studio-marketplace/v/alibabacloud-openapi.vscode-alicloud-api)](https://marketplace.visualstudio.com/items?itemName=alibabacloud-openapi.vscode-alicloud-api)
[![Installs](https://img.shields.io/visual-studio-marketplace/i/alibabacloud-openapi.vscode-alicloud-api)](https://marketplace.visualstudio.com/items?itemName=alibabacloud-openapi.vscode-alicloud-api)
[![Ratings](https://img.shields.io/visual-studio-marketplace/r/alibabacloud-openapi.vscode-alicloud-api)](https://marketplace.visualstudio.com/items?itemName=alibabacloud-openapi.vscode-alicloud-api)
![beta](https://img.shields.io/badge/beta-version)

简体中文 | [English]()
Alibaba Cloud API Toolkit 是一个轻量化的阿里云 API 工具,支持在 VS Code 中快速查阅阿里云产品的 API.

## Features
简体中文 | [English](./README.en-US.md)

* **阿里云产品订阅:** 插件提供了一键订阅阿里云产品的功能,你可以通过 `ctrl+cmd+o` 搜索和订阅阿里云产品。
## 功能

* **API 搜索:** 你可以通过 `ctrl+cmd+p` 搜索并查看已订阅的 API 文档。
* **阿里云产品订阅:** 插件提供了一键订阅阿里云产品的功能,你可以通过 `ctrl+cmd+k` 搜索和订阅阿里云产品。

* **API 搜索:** 你可以通过 `ctrl+cmd+l` 搜索并查看已订阅的 API 文档。

* **API 文档预览:** 点击 API 可以打开一个新的标签页,并显示对应的 API 文档,包括描述、请求参数、响应参数和错误码。在文档中点击调试按钮,可以链接到阿里云 OpenAPI 门户进行在线 API 试用。

Expand Down
69 changes: 37 additions & 32 deletions media/src/components/APIPage/APIDocument/ApiParamsDoc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { SemixJsonSchema } from "semix-core";
import * as PontSpec from "pontx-spec";
import { getRefSchema } from "../../utils";
import { InnerSchemaTable } from "semix-schema-table";
import { Card } from "@alicloud/console-components";

export class PontxParamsDocProps {
parameters?: PontSpec.Parameter[];
Expand Down Expand Up @@ -45,38 +46,42 @@ export const ApiParamsDoc: React.FC<PontxParamsDocProps> = (props) => {
return React.useMemo(() => {
return (
<div className="api-params-doc">
<InnerSchemaTable
name=""
renderExpandIcon={(node, onExpand) => {
return (
<div
className="relative flex items-center justify-center cursor-pointer rounded hover:bg-darken-3"
style={{
marginLeft: -23.5,
width: 20,
height: 20,
marginRight: 3,
textAlign: "center",
}}
onClick={() => {
onExpand(node);
}}
>
<i className={node.isExpanded ? "codicon codicon-chevron-down" : "codicon codicon-chevron-right"}></i>
</div>
);
}}
renderEmpty={() => {
return (
<tr>
<td colSpan={2} style={{ padding: "15px 0", textAlign: "center" }}>
无参数定义
</td>
</tr>
);
}}
schema={schema}
/>
{props.parameters?.length ? (
<InnerSchemaTable
name=""
renderExpandIcon={(node, onExpand) => {
return (
<div
className="relative flex items-center justify-center cursor-pointer rounded hover:bg-darken-3"
style={{
marginLeft: -23.5,
width: 20,
height: 20,
marginRight: 3,
textAlign: "center",
}}
onClick={() => {
onExpand(node);
}}
>
<i className={node.isExpanded ? "codicon codicon-chevron-down" : "codicon codicon-chevron-right"}></i>
</div>
);
}}
renderEmpty={() => {
return (
<tr>
<td colSpan={2} style={{ padding: "15px 0", textAlign: "center" }}>
无参数定义
</td>
</tr>
);
}}
schema={schema}
/>
) : (
<div style={{padding:20,fontSize:14}}>调用该 OpenAPI 无需参数。</div>
)}
</div>
);
}, [schema, propSchemaCnt, props.schemas]);
Expand Down
38 changes: 7 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "vscode-alicloud-api",
"displayName": "Alibaba Cloud API Toolkit",
"description": "",
"description": "The Alibaba Cloud API Toolkit for VSCode makes it easier to access Alibaba Cloud services.",
"author": "Alibaba Cloud SDK Team",
"version": "0.0.1",
"private": true,
"publisher": "AlibabaCloud",
"license": "MIT",
"publisher": "alibabacloud-openapi",
"license": "Apache-2.0",
"engines": {
"vscode": "^1.47.0"
},
Expand Down Expand Up @@ -34,16 +35,6 @@
"title": "生成本地代码",
"icon": "$(debug-start)"
},
{
"command": "alicloud.api.generateMocks",
"title": "生成Mocks代码",
"icon": "$(issues)"
},
{
"command": "alicloud.api.regenerateAPIMocks",
"title": "重新生成 API Mocks代码",
"icon": "$(issues)"
},
{
"command": "alicloud.api.restart",
"title": "重启 Alibaba Cloud API Toolkit",
Expand Down Expand Up @@ -72,11 +63,6 @@
"command": "alicloud.api.removeSubscriptions",
"icon": "$(notebook-delete-cell)",
"title": "取消订阅"
},
{
"command": "alicloud.api.viewMocks",
"icon": "$(go-to-file)",
"title": "查看Mocks数据"
}
],
"keybindings": [
Expand Down Expand Up @@ -151,19 +137,9 @@
{
"command": "alicloud.api.openDocument",
"group": "navigation"
},
{
"command": "alicloud.api.viewMocks",
"group": "navigation"
}
],
"editor/title": [
{
"command": "alicloud.api.regenerateAPIMocks",
"when": "resourcePath =~ /mocks/ && resourceFilename =~ /.ts$/ && resourceFilename != 'index.ts'",
"group": "navigation"
}
],
"editor/title": [],
"view/title": [
{
"command": "alicloud.api.restart",
Expand Down Expand Up @@ -209,7 +185,7 @@
"build:media": "cd media && npm run build:ncc",
"reinstall": "rimraf node_modules && npm i",
"afterinstall": "cd ../../ && lerna bootstrap",
"build:ncc": "rimraf dist && ncc build ./src/extension.ts -o dist -m --license licenses.txt && mv dist/index.js dist/extension.js && mv dist/license.txt ./LICENSE.txt",
"build:ncc": "rimraf dist && ncc build ./src/extension.ts -o dist -m --license licenses.txt && mv dist/index.js dist/extension.js",
"vscode:prepublish": "npm run build:ncc",
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node --minify",
"esbuild": "npm run esbuild-base -- --sourcemap",
Expand Down Expand Up @@ -245,7 +221,7 @@
"urllib": "^2.36.1",
"xml2js": "^0.4.23"
},
"icon": "resources/alibabacloud.png",
"icon": "resources/aliyun_logo_128x128.png",
"repository": {
"url": "git@github.com:aliyun/alibabacloud-api-vscode-toolkit.git",
"type": "git"
Expand Down
Binary file added resources/aliyun_logo_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 47 additions & 47 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,39 +136,39 @@ export class AlicloudApiCommands {
});
});

vscode.commands.registerCommand("alicloud.api.regenerateAPIMocks", async (event) => {
const filePaths: string[] = (event.path || "")?.split("/");
const lastMocksIndex = filePaths.lastIndexOf("mocks");
const names = filePaths.slice(lastMocksIndex + 1);
names.push(names.pop().replace(".ts", ""));

if (service.pontManager.localPontSpecs?.[0]?.name) {
showProgress("重新生成 API Mocks", service.pontManager, async (log) => {
log("代码生成中...");
await wait(100);

let specName, modName, apiName;
if (names.length === 3) {
[specName, modName, apiName] = names;
} else {
[specName, apiName] = names;
}
const mocksPlugin = await service.pontManager.innerManagerConfig.plugins.mocks?.instance;
const mocksOptions = await service.pontManager.innerManagerConfig.plugins.mocks?.options;
const mocksCode = await mocksPlugin.getAPIMockCode(
service.pontManager,
mocksOptions,
apiName,
modName,
specName,
);
fs.writeFileSync(event.path, mocksCode, "utf-8");

log("API Mocks 生成成功!");
vscode.window.showInformationMessage("API Mocks生成成功!");
});
}
});
// vscode.commands.registerCommand("alicloud.api.regenerateAPIMocks", async (event) => {
// const filePaths: string[] = (event.path || "")?.split("/");
// const lastMocksIndex = filePaths.lastIndexOf("mocks");
// const names = filePaths.slice(lastMocksIndex + 1);
// names.push(names.pop().replace(".ts", ""));

// if (service.pontManager.localPontSpecs?.[0]?.name) {
// showProgress("重新生成 API Mocks", service.pontManager, async (log) => {
// log("代码生成中...");
// await wait(100);

// let specName, modName, apiName;
// if (names.length === 3) {
// [specName, modName, apiName] = names;
// } else {
// [specName, apiName] = names;
// }
// const mocksPlugin = await service.pontManager.innerManagerConfig.plugins.mocks?.instance;
// const mocksOptions = await service.pontManager.innerManagerConfig.plugins.mocks?.options;
// const mocksCode = await mocksPlugin.getAPIMockCode(
// service.pontManager,
// mocksOptions,
// apiName,
// modName,
// specName,
// );
// fs.writeFileSync(event.path, mocksCode, "utf-8");

// log("API Mocks 生成成功!");
// vscode.window.showInformationMessage("API Mocks生成成功!");
// });
// }
// });

vscode.commands.registerCommand("alicloud.api.fetchRemote", (config) => {
const pontManager = service.pontManager;
Expand Down Expand Up @@ -245,20 +245,20 @@ export class AlicloudApiCommands {
spec: spec?.apis?.[`${result.apiKey}`],
});
});
vscode.commands.registerTextEditorCommand("alicloud.api.viewMocks", async (editor, edit) => {
const isSingleSpec = PontManager.checkIsSingleSpec(service.pontManager);
const result = (await findInterface(editor, !isSingleSpec, service.pontManager)) || ({} as any);
const spec = PontManager.getSpec(service.pontManager, result.specName);

if (!result.apiName) {
vscode.window.showErrorMessage("未找到该 OpenAPI");
return;
}

const namespace = [result.specName, result.modName, result.apiName].filter((id) => id).join("/");
const mocksFilePath = path.join(service.pontManager.innerManagerConfig.outDir, "mocks", namespace + ".ts");
vscode.commands.executeCommand("vscode.open", vscode.Uri.file(mocksFilePath));
});
// vscode.commands.registerTextEditorCommand("alicloud.api.viewMocks", async (editor, edit) => {
// const isSingleSpec = PontManager.checkIsSingleSpec(service.pontManager);
// const result = (await findInterface(editor, !isSingleSpec, service.pontManager)) || ({} as any);
// const spec = PontManager.getSpec(service.pontManager, result.specName);

// if (!result.apiName) {
// vscode.window.showErrorMessage("未找到该 OpenAPI");
// return;
// }

// const namespace = [result.specName, result.modName, result.apiName].filter((id) => id).join("/");
// const mocksFilePath = path.join(service.pontManager.innerManagerConfig.outDir, "mocks", namespace + ".ts");
// vscode.commands.executeCommand("vscode.open", vscode.Uri.file(mocksFilePath));
// });

// vscode.commands.registerCommand('alicloud.api.refreshPontExplorer', () => {
// service.treeDataProvider.refresh();
Expand Down