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

Feat/split extension package #30

Merged
merged 55 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
41ad9c6
feat: 初步抽离逻辑到wormhole中
Aug 16, 2024
c38773b
refactor: wormhole初步分离
Aug 20, 2024
2ed769d
chore: 暂时保存
Aug 23, 2024
6c9620f
chore: 初步分离
czhlin Aug 30, 2024
225215c
Merge branch 'feature/v1.0.0-czhlin' into feat/split-extension-package
JOU-amjs Aug 30, 2024
3ad72a6
feat: 分离出wormhole包
Sep 3, 2024
b6a5aaa
refactor: 重构work
Sep 4, 2024
93e478e
feat: 将模板拆分成一个包
Sep 4, 2024
a967057
chore: templates移动到packages里
Sep 4, 2024
fcb2224
refactor(vscode-extension): 将vscode插件移动到packages目录下
czhlin Sep 4, 2024
97a42d0
fix: alova.config模板区分项目类型
czhlin Sep 4, 2024
81bdf5b
fix(templates): 修复createApis模板中错误提示错误
Sep 5, 2024
aedc51b
chore: 合并release v0.0.10
Sep 5, 2024
13dcd22
Merge branch 'main' of github.com:alovajs/devtools into feat/split-ex…
Sep 5, 2024
befe59c
chore(wormhole): 调整tsconfig,移动templates
Sep 6, 2024
800ec19
build(wormhole): 使用unbuild打包wormhole
Sep 6, 2024
afc602e
build(wormhole): 修改wormhole的打包配置文件
czhlin Sep 7, 2024
988bd1a
fix(wormhole/openapi2data): 修复handleApi修改时unkown类型问题
Sep 9, 2024
9e2e687
chore(whormhole): 控制需要导出的文件
Sep 9, 2024
d6377f5
feat: 添加defaultRequire,默认都是require选项
Sep 10, 2024
af51cba
feat(wormhole): 添加node命名行
czhlin Sep 10, 2024
683c8f2
chore(wormhole): 添加没有配置文件提示
czhlin Sep 10, 2024
cf75e9c
feat: add vitest as unit test tool, change file operation synchronous…
JOU-amjs Sep 12, 2024
ad607fa
fix: transform to FormData when data contains blob
JOU-amjs Sep 13, 2024
64e0bb9
fix: detect `FormData` existence
JOU-amjs Sep 18, 2024
5005139
test(添加readconfig 测试): 修复readconfig没法跑通的问题
Sep 19, 2024
8c7a4c6
Merge pull request #37 from alovajs/test/splited-test-vitest
czhlin Sep 29, 2024
ea44aca
test: add `generate` unit tests
JOU-amjs Oct 13, 2024
6ec8235
test: add all `generate` tests
JOU-amjs Oct 14, 2024
da64987
feat: add features workspaces & import statement in config file, test…
JOU-amjs Oct 24, 2024
e7bf76a
chore: husky cli fix
JOU-amjs Oct 24, 2024
e73bfeb
feat(vscode-extension): 完成wormhole分离适配
Oct 24, 2024
481f3af
feat: 解决wormhole打包后esbuild找不到依赖
czhlin Oct 24, 2024
6667ced
fix(wormhole): 修复单元测试中toMatch处理多行文本问题/s
czhlin Oct 25, 2024
00be2df
Merge branch 'feat/split-extension-package-czhlin' into feat/split-ex…
czhlin Oct 25, 2024
f7a5cc1
feat(vscode-extension): 去除work模式、去掉依赖esbuild,改为用户提供@alova/wormhole包
Oct 25, 2024
ea7076d
fix(wormhole): 修复bin/acitons ora 是esm模块需要使用动态import加载
Oct 25, 2024
9e6868c
fix(vscode-extension): getWormhole改成返回代理对象,解决无法激活插件的问题
Nov 5, 2024
0a50bba
feat(vscode-extension): 添加wormhole没有安装时状态按钮置灰效果
Nov 5, 2024
937559c
feat(vscode-extension): 1.@alova/wormhole禁用状态 2.handleApi调试 3.支持monor…
Nov 6, 2024
21a3ca3
feat: wormhole and devtools splited is completed
JOU-amjs Nov 7, 2024
986e113
fix: initial version
JOU-amjs Nov 7, 2024
e7baff4
ci: add secret VSCE_PAT to env
JOU-amjs Nov 7, 2024
a9f2f74
test: correct test error
JOU-amjs Nov 7, 2024
86dca8f
chore: translate Chinese to English in all files
JOU-amjs Nov 7, 2024
6d0163b
Merge pull request #39 from alovajs/test/splited-test-vitest
czhlin Nov 8, 2024
18de3d7
docs: fill the comments
JOU-amjs Nov 8, 2024
f24565d
feat(wormhole): support response data types starting with 2xx in open…
Nov 8, 2024
9f32cef
fix(vscode-extension): fix alova status button status problem
Nov 8, 2024
49e37b8
Merge branch 'feat/split-extension-package' of https://github.com/alo…
JOU-amjs Nov 8, 2024
7e7c32d
chore: update pnpm-lock.yaml
JOU-amjs Nov 8, 2024
b18e7d4
ci: ci flows debug
JOU-amjs Nov 8, 2024
7cc8bfd
Merge branch 'feat/split-extension-package' of https://github.com/alo…
JOU-amjs Nov 8, 2024
4163652
Merge branch 'main' of https://github.com/alovajs/devtools into feat/…
JOU-amjs Nov 8, 2024
3c60f92
test: update snapshot file
JOU-amjs Nov 8, 2024
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
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
'no-multi-assign': 'off',
'consistent-return': 'off',
'no-restricted-exports': 'off',
'linebreak-style': ['error', 'unix'],
'linebreak-style': 'off',
'no-unused-vars': 'off',
'import/order': 'off',
'import/no-relative-packages': 'off',
Expand Down
7 changes: 6 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
enable-pre-post-scripts = true
enable-pre-post-scripts = true
link-workspace-packages = true
prefer-workspace-packages = true
recursive-install = true
# 使用淘宝镜像源
registry = https://registry.npmmirror.com
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个最好不用设置,到时我们配置github actions后是在github服务器上安装依赖的

61 changes: 5 additions & 56 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,21 @@
{
"name": "alova-vscode-extension",
"name": "@alova/devtools",
"displayName": "Alova",
"description": "Generate and search APIs without API documentation any more",
"version": "0.0.10",
"description": "The devtools for alova.js",
Copy link
Contributor

@JOU-amjs JOU-amjs Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个描述是我改的😂

"version": "0.0.9",
"engines": {
"vscode": "^1.89.0",
"node": ">=18.19.0",
"pnpm": ">=8.6.12"
},
"categories": [
"Other"
],
"activationEvents": [
"workspaceContains:**/*.ts",
"workspaceContains:**/*.js"
],
"main": "./out/extension.js",
"icon": "resources/icon.png",
"contributes": {
"commands": [
{
"command": "Generate APIs",
"category": "Alova",
"title": "alova refresh"
}
],
"icons": {
"alova-icon-id": {
"description": "alova icon",
"default": {
"fontPath": "./resources/logo.ttf",
"fontCharacter": "\\E900"
}
}
}
},
"scripts": {
"vscode:prepublish": "pnpm run package",
"compile": "pnpm run check-types && pnpm run lint:fix && tsx esbuild.ts",
"watch": "npm-run-all -p watch:*",
"watch:esbuild": "tsx esbuild.ts --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"package": "pnpm run check-types && pnpm run lint:fix && tsx esbuild.ts --production",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "pnpm run compile-tests && pnpm run compile && pnpm run lint",
"check-types": "tsc --noEmit",
"lint": "eslint . --ext .js,.ts",
"lint:fix": "npm run lint -- --fix",
"format": "prettier --check .",
"format:fix": "prettier --write .",
"test": "vscode-test",
"api-test": "tsx scripts/api-test.ts",
"commit": "git-cz && git push",
"prepare": "husky && pnpm api-test",
"pack:pre": "vsce package --no-dependencies --pre-release",
"release:pre": "vsce publish --no-dependencies --pre-release",
"pack": "vsce package --no-dependencies",
"release": "vsce publish --no-dependencies"
"prepare": "husky && pnpm api-test"
},
"publisher": "Alova",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -73,26 +29,20 @@
"*.js,*.ts": "npm run lint:fix"
},
"devDependencies": {
"@alova/wormhole": "workspace:^",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@types/js-yaml": "^4.0.9",
"@types/lodash": "^4.17.5",
"@types/mocha": "^10.0.6",
"@types/mustache": "^4.2.5",
"@types/node": "18.x",
"@types/node-fetch": "^2.6.11",
"@types/serialize-javascript": "^5.0.4",
"@types/swagger2openapi": "^7.0.4",
"@types/vscode": "^1.89.0",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.3.9",
"@vscode/vsce": "^2.29.0",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"esbuild": "^0.23.0",
"esbuild-plugin-alias": "^0.2.1",
"eslint": "^8.57.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^18.0.0",
Expand Down Expand Up @@ -121,7 +71,6 @@
"lodash": "^4.17.21",
"node-fetch": "^2.7.0",
"openapi-types": "^12.1.3",
"serialize-javascript": "^6.0.2",
"swagger2openapi": "^7.0.8"
}
}
71 changes: 71 additions & 0 deletions packages/templates/alova.config.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{{#if (eq type "typescript")}}import type { Config } from '@alova/wormhole';


{{/if}}// For more config detailed visit:
// https://alova.js.org/tutorial/getting-started/extension-integration
{{#if (not type "typescript")}}/**
* @type {{#raw "{ " }}{{/raw}}import('@alova/wormhole').Config{{#raw " }" }}{{/raw}}
*/{{/if}}
{{#if (eq moduleType "ESModule")}}export default {{#if (eq type "typescript")}}<Config>{{/if}}{{else if (eq moduleType "commonJs")}}module.exports ={{/if}}{{#raw "{ " }}{{/raw}}
generator: [
{
/**
* file input. support:
* 1. openapi json file url
* 2. local file
*/
input: 'http://localhost:3000',

/**
* input file platform. Currently only swagger is supported.
* When this parameter is specified, the input field only needs to specify the document address without specifying the openapi file
*/
platform: 'swagger',

/**
* output path of interface file and type file.
* Multiple generators cannot have the same address, otherwise the generated code will overwrite each other.
*/
output: 'src/api',

/**
* the mediaType of the generated response data. default is `application/json`
*/
// responseMediaType: 'application/json',

/**
* the bodyMediaType of the generated request body data. default is `application/json`
*/
// bodyMediaType: 'application/json',

/**
* the generated api version. options are `2` or `3`, default is `auto`.
*/
// version: 'auto',

/**
* type of generated code. The options ​​are `auto/ts/typescript/module/commonjs`.
*/
// type: 'auto',

/**
* exported global api name, you can access the generated api globally through this name, default is `Apis`.
* it is required when multiple generators are configured, and it cannot be repeated
*/
// global: 'Apis',

/**
* filter or convert the generated api information, return an apiDescriptor, if this function is not specified, the apiDescripor object is not converted
*/
// handleApi: apiDescriptor => {
// return apiDescriptor;
// }
}
],

/**
* extension only
* whether to automatically update the interface, enabled by default, check every 5 minutes, closed when set to `false`
*/
// autoUpdate: true
{{#raw "};" }}{{/raw}}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const createFunctionalProxy = (array, alovaInstance, configMap) => {
const apiPathKey = array.join('.');
const apiItem = apiDefinitions[apiPathKey];
if (!apiItem) {
throw new Error(`the api path of \`${apiItem}\` is not found`);
throw new Error(`the api path of \`${apiPathKey}\` is not found`);
}
const mergedConfig = {
...configMap[apiPathKey],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const createFunctionalProxy = (array, alovaInstance, configMap) => {
const apiPathKey = array.join('.');
const apiItem = apiDefinitions[apiPathKey];
if (!apiItem) {
throw new Error(`the api path of \`${apiItem}\` is not found`);
throw new Error(`the api path of \`${apiPathKey}\` is not found`);
}
const mergedConfig = {
...configMap[apiPathKey],
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions packages/templates/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default (filePath: string) => import(`./${filePath}.handlebars`);
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const createFunctionalProxy = (array, alovaInstance, configMap) => {
const apiPathKey = array.join('.');
const apiItem = apiDefinitions[apiPathKey];
if (!apiItem) {
throw new Error(`the api path of \`${apiItem}\` is not found`);
throw new Error(`the api path of \`${apiPathKey}\` is not found`);
}
const mergedConfig = {
...configMap[apiPathKey],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const createFunctionalProxy = (array, alovaInstance, configMap) => {
const apiPathKey = array.join('.');
const apiItem = apiDefinitions[apiPathKey];
if (!apiItem) {
throw new Error(`the api path of \`${apiItem}\` is not found`);
throw new Error(`the api path of \`${apiPathKey}\` is not found`);
}
const mergedConfig = {
...configMap[apiPathKey],
Expand Down
13 changes: 13 additions & 0 deletions packages/templates/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@alova/templates",
"version": "1.0.0",
"description": "",
"main": "index.ts",
"module": "index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const createFunctionalProxy = (
const apiPathKey = array.join('.') as keyof typeof apiDefinitions;
const apiItem = apiDefinitions[apiPathKey];
if (!apiItem) {
throw new Error(`the api path of \`${apiItem}\` is not found`);
throw new Error(`the api path of \`${apiPathKey}\` is not found`);
}
const mergedConfig = {
...configMap[apiPathKey],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const createFunctionalProxy = (
const apiPathKey = array.join('.') as keyof typeof apiDefinitions;
const apiItem = apiDefinitions[apiPathKey];
if (!apiItem) {
throw new Error(`the api path of \`${apiItem}\` is not found`);
throw new Error(`the api path of \`${apiPathKey}\` is not found`);
}
const mergedConfig = {
...configMap[apiPathKey],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions .vscodeignore → packages/vscode-extension/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ vsc-extension-quickstart.md
pnpm-lock.yaml
pnpm-workspace.yaml
design/**
templates/**
packages/**
test/**
.husky/**
9 changes: 9 additions & 0 deletions packages/vscode-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Change Log

All notable changes to the "helloworld" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]

- Initial release
21 changes: 21 additions & 0 deletions packages/vscode-extension/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 alovajs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
27 changes: 27 additions & 0 deletions packages/vscode-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# VSCode extension for alova

## features

1. Automatically generate request code and response data types, and experience IntelliSense for response in js projects.
2. Embed API documents in the code to experience the effect of checking and using APIs.
3. Update APIs regularly and actively notify front-end developers, no longer relying on server-side developers to notify.

> [Detailed documentation](https://alova.js.org/tutorial/getting-started/extension-integration).

## View API completed information

You can view the complted API information in the Editor with the IntelliSense feature.

![](https://alova.js.org/img/vscode-api-doc.png)

## Quick access to API

Using the trigger word `a->` to trigger apis quick positioning.

### Search by url

![](https://alova.js.org/img/vscode-query-with-url.png)

### Search by description

![](https://alova.js.org/img/vscode-query-with-description.png)
3 changes: 3 additions & 0 deletions esbuild.ts → packages/vscode-extension/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const esbuildProblemMatcherPlugin: Plugin = {
async function main() {
const ctx = await esbuild.context({
entryPoints: ['src/extension.ts', 'src/work.ts'],
loader: {
'.handlebars': 'text'
},
bundle: true,
format: 'cjs',
minify: production,
Expand Down
Loading