Skip to content

Commit

Permalink
Merge branch 'main' into web
Browse files Browse the repository at this point in the history
  • Loading branch information
scarqin committed Jan 20, 2023
2 parents ab87b02 + 8aa1735 commit 80bf58a
Show file tree
Hide file tree
Showing 302 changed files with 15,590 additions and 11,705 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ out/
!src/workbench/node/server/**/*.js
!/api/*.js
!/scripts/*.js
!/tools/*.js
!*.config.js
!.*.js
!upload.js
Expand Down
6 changes: 5 additions & 1 deletion donkey.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ module.exports = {
// schema: "./output/entities"
// typeorm: "./output/typeorm"
],
remoteBase: ''
remoteBase: '',
paramsFill: {
projectUuid: 'this.store.getCurrentProjectID',
workSpaceUuid: 'this.store.getCurrentWorkspaceUuid'
}
};
2 changes: 1 addition & 1 deletion e2e/api.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ wait
goto "http://localhost:4200"

find:
[input "Search"] [button { width: 32px }]=addBtn
[input 'Search'] [button 'xpath:body > eo-root > eo-pages > div > div > div > eo-api > nz-layout > nz-sider > div > nz-content > nz-tabset > div > div > div.ant-tabs-tabpane.ant-tabs-tabpane-active.ng-star-inserted > div > pc-api-group-tree > header > div']=addBtn

addBtn -> hover

Expand Down
2 changes: 1 addition & 1 deletion e2e/group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test('test', async ({ page }) => {
await page.goto('http://www.postcat.com');
await page.locator('body').click();
//Add group
await page.locator('eo-api-group-tree:has-text("GET获取城市今日天气GET新冠全国疫情") path').nth(1).hover();
await page.locator('pc-api-group-tree:has-text("GET获取城市今日天气GET新冠全国疫情") path').nth(1).hover();
await page.getByText('新建分组').click();
await page.getByLabel('分组名称').click();
await page.getByLabel('分组名称').fill('test');
Expand Down
7 changes: 5 additions & 2 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
"license": "MIT",
"scripts": {
"test": "playwright test",
"test:watch":"playwright test --headed"
"test:watch": "playwright test --headed"
},
"devDependencies": {
"@playwright/test": "^1.27.0",
"playwright": "^1.27.0"
},
"dependencies": {
"ark-pkg": "0.5.1"
}
}
}
55 changes: 55 additions & 0 deletions e2e/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# yarn lockfile v1


"@lukeed/csprng@^1.0.0":
version "1.0.1"
resolved "https://registry.npmmirror.com/@lukeed/csprng/-/csprng-1.0.1.tgz#625e93a0edb2c830e3c52ce2d67b9d53377c6a66"
integrity sha512-uSvJdwQU5nK+Vdf6zxcWAY2A8r7uqe+gePwLWzJ+fsQehq18pc0I2hJKwypZ2aLM90+Er9u1xn4iLJPZ+xlL4g==

"@playwright/test@^1.27.0":
version "1.27.1"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.27.1.tgz#9364d1e02021261211c8ff586d903faa79ce95c4"
Expand All @@ -15,6 +20,44 @@
resolved "https://registry.npmjs.org/@types/node/-/node-18.7.11.tgz#486e72cfccde88da24e1f23ff1b7d8bfb64e6250"
integrity sha512-KZhFpSLlmK/sdocfSAjqPETTMd0ug6HIMIAwkwUpU79olnZdQtMxpQP+G1wDzCH7na+FltSIhbaZuKdwZ8RDrw==

ark-pkg@0.5.1:
version "0.5.1"
resolved "https://registry.npmmirror.com/ark-pkg/-/ark-pkg-0.5.1.tgz#4690d6d8cf9053f8a55339a22b6ba0b7885baff4"
integrity sha512-lDyI6jq9b/gHrkSAXlnUL8hAvNRX8pUZVyxxaBQ7TKXQx1Os3AwwSzYHZY9USbSeTe5RwGbb67wOZ/X1o/T/Ng==
dependencies:
uid "^2.0.0"
colors "^1.4.0"
commander "^9.4.0"
figlet "^1.5.2"
js-md5 "^0.7.3"
lodash "^4.17.21"
prettier "^2.7.1"

colors@^1.4.0:
version "1.4.0"
resolved "https://registry.npmmirror.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78"
integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==

commander@^9.4.0:
version "9.5.0"
resolved "https://registry.npmmirror.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30"
integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==

figlet@^1.5.2:
version "1.5.2"
resolved "https://registry.npmmirror.com/figlet/-/figlet-1.5.2.tgz#dda34ff233c9a48e36fcff6741aeb5bafe49b634"
integrity sha512-WOn21V8AhyE1QqVfPIVxe3tupJacq1xGkPTB4iagT6o+P2cAgEOOwIxMftr4+ZCTI6d551ij9j61DFr0nsP2uQ==

js-md5@^0.7.3:
version "0.7.3"
resolved "https://registry.npmmirror.com/js-md5/-/js-md5-0.7.3.tgz#b4f2fbb0b327455f598d6727e38ec272cd09c3f2"
integrity sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ==

lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==

playwright-core@1.27.1:
version "1.27.1"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.27.1.tgz#840ef662e55a3ed759d8b5d3d00a5f885a7184f4"
Expand All @@ -26,3 +69,15 @@ playwright@^1.27.0:
integrity sha512-xXYZ7m36yTtC+oFgqH0eTgullGztKSRMb4yuwLPl8IYSmgBM88QiB+3IWb1mRIC9/NNwcgbG0RwtFlg+EAFQHQ==
dependencies:
playwright-core "1.27.1"

prettier@^2.7.1:
version "2.8.2"
resolved "https://registry.npmmirror.com/prettier/-/prettier-2.8.2.tgz#c4ea1b5b454d7c4b59966db2e06ed7eec5dfd160"
integrity sha512-BtRV9BcncDyI2tsuS19zzhzoxD8Dh8LiCx7j7tHzrkz8GFXAexeWFdi22mjE1d16dftH2qNaytVxqiRTGlMfpw==

uid@^2.0.0:
version "2.0.1"
resolved "https://registry.npmmirror.com/uid/-/uid-2.0.1.tgz#a3f57c962828ea65256cd622fc363028cdf4526b"
integrity sha512-PF+1AnZgycpAIEmNtjxGBVmKbZAQguaa4pBUq6KNaGEcpzZ2klCNZLM34tsjp76maN00TttiiUf6zkIBpJQm2A==
dependencies:
"@lukeed/csprng" "^1.0.0"
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "postcat",
"souceLocale": "zh-Hans",
"version": "0.0.1-beta",
"version": "0.1.0-beta",
"main": "out/app/electron-main/main.js",
"description": "A lightweight, extensible API tool",
"homepage": "https://github.com/eolinker/postcat.git",
Expand Down Expand Up @@ -41,15 +41,13 @@
"@grpc/proto-loader": "0.7.3",
"@koa/cors": "3.3.0",
"axios": "0.27.2",
"content-disposition": "^0.5.4",
"cors": "2.8.5",
"crypto-js": "4.1.1",
"electron-log": "^4.4.8",
"electron-store": "8.0.2",
"electron-updater": "^5.0.5",
"express": "4.18.1",
"fix-path": "3.0.0",
"form-data": "^4.0.0",
"http-server": "14.1.1",
"iconv-lite": "^0.6.3",
"jquery": "3.6.1",
Expand Down
10 changes: 0 additions & 10 deletions scripts/upgradeComponent.js

This file was deleted.

5 changes: 3 additions & 2 deletions src/app/electron-main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ class EoBrowserWindow {
//Watch win event
private watch() {
// Reload page when load page url error
this.win.webContents.on('did-fail-load', (event, errorCode) => {
console.error('did-fail-load', errorCode);
this.win.webContents.on('did-fail-load', (event, errorCode, errorDescription, validatedURL, isMainFrame) => {
//* Extension url error
if (!isMainFrame) return;
this.loadURL();
});
this.win.on('resize', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/platform/common/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ModuleInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager';
import { ExtensionInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager';
/**
* Single extension i18 service,chain call
*/
export class TranslateService {
// Default key in package.json translate replace directly
defaultKeys = ['title', 'description', 'author', 'logo'];
constructor(private module: ModuleInfo, private locale) {}
constructor(private module: ExtensionInfo, private locale) {}
translate() {
return this.translateDefaultKey().translateVariableKey().get();
}
Expand Down
53 changes: 26 additions & 27 deletions src/platform/node/extension-manager/lib/core.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import * as path from 'path';
import { ModuleHandlerOptions, ModuleInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager';
import { fileExists, readFile, readJson } from 'eo/shared/node/file';
import { getLocaleData } from 'eo/platform/node/i18n';
import { LanguageService } from 'eo/app/electron-main/language.service';
import { TranslateService } from 'eo/platform/common/i18n';
import { getLocaleData } from 'eo/platform/node/i18n';
import { fileExists, readFile, readJson } from 'eo/shared/node/file';
import { ModuleHandlerOptions, ExtensionInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager';

import * as path from 'path';
/**
* 核心模块管理器
*
* @class CoreHandler
*/
export class CoreHandler {
Expand All @@ -28,51 +30,48 @@ export class CoreHandler {
throw new Error(`Package file [${packageJsonFile}] does not exist.`);
}
}

/**
* 获取模块package.json信息
*
* @param {string} name 模块名称
*/
info(name: string): ModuleInfo {
let moduleInfo: ModuleInfo;
info(name: string): ExtensionInfo {
let extensionInfo: ExtensionInfo;
try {
const baseDir: string = this.getModuleDir(name);
moduleInfo = readJson(path.join(baseDir, 'package.json')) as ModuleInfo;
moduleInfo.baseDir = baseDir;
extensionInfo = readJson(path.join(baseDir, 'package.json')) as ExtensionInfo;
extensionInfo.baseDir = baseDir;
// Get language locale
//!Warn:baseDir must be set before get locale file
const lang = LanguageService.get();
if (moduleInfo.features?.i18n) {
const locale = getLocaleData(moduleInfo, lang);
if (extensionInfo.features?.i18n) {
const locale = getLocaleData(extensionInfo, lang);
if (locale) {
let translateService = new TranslateService(moduleInfo, locale);
moduleInfo = translateService.translate();
let translateService = new TranslateService(extensionInfo, locale);
extensionInfo = translateService.translate();
}
}
// Check that the file exists locally
moduleInfo.introduction =
readFile(path.join(baseDir, `README.${lang}.md`)) || readFile(path.join(baseDir, `README.md`));
if(moduleInfo.main){
moduleInfo.main = 'file://' + path.join(moduleInfo.baseDir, moduleInfo.main);
}
if(moduleInfo.node){
moduleInfo.node = 'file://' + path.join(moduleInfo.baseDir, moduleInfo.node);
extensionInfo.introduction = readFile(path.join(baseDir, `README.${lang}.md`)) || readFile(path.join(baseDir, `README.md`));
if (extensionInfo.main) {
extensionInfo.main = `file://${path.join(extensionInfo.baseDir, extensionInfo.main)}`;
}
if (moduleInfo.logo?.length > 0 && !moduleInfo.logo.startsWith('http') && !moduleInfo.logo.includes('icon-')) {
moduleInfo.logo = 'file://' + path.join(moduleInfo.baseDir, moduleInfo.logo);
if (extensionInfo.node) {
extensionInfo.node = `file://${path.join(extensionInfo.baseDir, extensionInfo.node)}`;
}
if (typeof moduleInfo.author === 'object') {
moduleInfo.author = moduleInfo.author['name'] || '';
if (extensionInfo.logo?.length > 0 && !extensionInfo.logo.startsWith('http') && !extensionInfo.logo.includes('icon-')) {
extensionInfo.logo = `file://${path.join(extensionInfo.baseDir, extensionInfo.logo)}`;
}
} catch (e) {
console.log(`Get module ${moduleInfo?.name} error:${e}`);
moduleInfo = {} as ModuleInfo;
console.log(`Get module ${extensionInfo?.name} error:${e}`);
extensionInfo = {} as ExtensionInfo;
}
return moduleInfo;
return extensionInfo;
}

/**
* 获取模块目录
*
* @param name
* @returns
*/
Expand Down
Loading

1 comment on commit 80bf58a

@vercel
Copy link

@vercel vercel bot commented on 80bf58a Jan 20, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.