From 7aa3c4da533cf23e8d47a3a6f35f15bb2096c2bb Mon Sep 17 00:00:00 2001 From: yangfan <18767120422@163.com> Date: Wed, 19 Aug 2020 11:31:29 +0800 Subject: [PATCH 01/13] feat: update debug config (#442) --- .gitignore | 1 + extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 540936137..5b9b200f7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* +.vscode node_modules .DS_Store diff --git a/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts b/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts index e567f8a57..b659c7217 100644 --- a/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts +++ b/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts @@ -21,8 +21,8 @@ const tasksConfigTemplate = ` [ { "label": "<%= startLabel %>", - "type": "npm", - "script": "start", + "command": "npm", + "args": ["run", "start", "--", "--disable-open"], "isBackground": true, "problemMatcher": { "pattern": { From 6986fb188b6cbd0d5576b598a934f0c4135efa92 Mon Sep 17 00:00:00 2001 From: yangfan <18767120422@163.com> Date: Wed, 19 Aug 2020 14:19:04 +0800 Subject: [PATCH 02/13] feat: support pegasus project debugger (#440) * feat: support * fix: prettier:fix * feat: update pegasus * fix: prettier:fix * feat: update * feat: update version --- extensions/iceworks-app/CHANGELOG.md | 3 +++ extensions/iceworks-app/package.json | 2 +- .../src/debugConfig/getDefaultConfigs.ts | 23 +++++++++++++------ .../iceworks-app/src/debugConfig/index.ts | 23 ++++++++++++++++--- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/extensions/iceworks-app/CHANGELOG.md b/extensions/iceworks-app/CHANGELOG.md index faadb3452..412648644 100644 --- a/extensions/iceworks-app/CHANGELOG.md +++ b/extensions/iceworks-app/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## 0.4.6 +- Support pegasus project debugger. + ## 0.4.5 - feat: add component-generator and component-creator quickPick. diff --git a/extensions/iceworks-app/package.json b/extensions/iceworks-app/package.json index 46399e7ff..928d552ad 100644 --- a/extensions/iceworks-app/package.json +++ b/extensions/iceworks-app/package.json @@ -3,7 +3,7 @@ "displayName": "Iceworks Application Viewer", "description": "Quick view your Universal Application(React/Rax/Vue, etc).", "publisher": "iceworks-team", - "version": "0.4.5", + "version": "0.4.6", "engines": { "vscode": "^1.41.0" }, diff --git a/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts b/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts index b659c7217..ca797af54 100644 --- a/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts +++ b/extensions/iceworks-app/src/debugConfig/getDefaultConfigs.ts @@ -1,5 +1,5 @@ import * as ejs from 'ejs'; -import { CONFIG_NAME, START_URL, CONFIG_START_LABEL, CONFIG_STOP_LABEL, IDebugConfig } from './index'; +import { CONFIG_NAME, BASE_URL, CONFIG_START_LABEL, CONFIG_STOP_LABEL, IDebugConfig } from './index'; const launchConfigTemplate = ` [ @@ -8,7 +8,7 @@ const launchConfigTemplate = ` "request": "launch", "name": "<%= configName %>", "url": "<%= startUrl %>", - "urlFilter": "<%= startUrl %>/**/*", + "urlFilter": "<%= baseUrl %>/**/*", "webRoot": "\${workspaceFolder}", "userDataDir": "\${workspaceFolder}/.vscode/chrome-debug-user-data", "preLaunchTask": "<%= startLabel %>", @@ -24,13 +24,20 @@ const tasksConfigTemplate = ` "command": "npm", "args": ["run", "start", "--", "--disable-open"], "isBackground": true, + <%_ if (isPegasusProject) { -%> + "options": { + "env": { + "PEGASUS_DEVKIT": "Iceworks" + } + }, + <%_ } -%> "problemMatcher": { "pattern": { "regexp": "ERROR in .*" }, "background": { "beginsPattern": ".*(@alib/build-scripts|ice\\\\.js|rax\\\\.js).*", - "endsPattern": ".*<%= startUrl %>.*" + "endsPattern": ".*<%= baseUrl %>.*" } } }, @@ -46,14 +53,15 @@ const tasksConfigTemplate = ` `; // https://code.visualstudio.com/docs/editor/debugging#_launch-configurations -export function getLaunchConfig(): IDebugConfig { +export function getLaunchConfig(launchUrl?: string): IDebugConfig { const DEBUG_LAUNCH_VERSION = '0.2.0'; return { version: DEBUG_LAUNCH_VERSION, configurations: JSON.parse( ejs.render(launchConfigTemplate, { configName: CONFIG_NAME, - startUrl: START_URL, + startUrl: launchUrl || BASE_URL, + baseUrl: BASE_URL, startLabel: CONFIG_START_LABEL, stopLabel: CONFIG_STOP_LABEL, }) @@ -62,13 +70,14 @@ export function getLaunchConfig(): IDebugConfig { } // https://code.visualstudio.com/docs/editor/tasks#vscode -export function getTasksConfig(): IDebugConfig { +export function getTasksConfig(isPegasusProject = false): IDebugConfig { const DEBUG_TASKS_VERSION = '2.0.0'; return { version: DEBUG_TASKS_VERSION, tasks: JSON.parse( ejs.render(tasksConfigTemplate, { - startUrl: START_URL, + baseUrl: BASE_URL, + isPegasusProject, startLabel: CONFIG_START_LABEL, stopLabel: CONFIG_STOP_LABEL, }) diff --git a/extensions/iceworks-app/src/debugConfig/index.ts b/extensions/iceworks-app/src/debugConfig/index.ts index 03df57e99..a8c88e563 100644 --- a/extensions/iceworks-app/src/debugConfig/index.ts +++ b/extensions/iceworks-app/src/debugConfig/index.ts @@ -5,10 +5,10 @@ import { parse } from 'comment-json'; import { getLaunchConfig, getTasksConfig } from './getDefaultConfigs'; // Iceworks debug config +export const BASE_URL = 'http://localhost:3333'; export const CONFIG_NAME = 'Iceworks Debug'; export const CONFIG_START_LABEL = 'Iceworks Start Background Tasks'; export const CONFIG_STOP_LABEL = 'Iceworks Stop Background Tasks'; -export const START_URL = 'http://localhost:3333'; export interface IDebugConfig { version?: string; @@ -35,9 +35,25 @@ export function setDebugConfig() { fs.mkdirSync(targetDir); } + // Set pegasus service url + let isPegasusProject = false; + let specialLaunchUrl = ''; + try { + const abcConfigFile = path.join(rootPath, 'abc.json'); + if (fs.existsSync(abcConfigFile)) { + const abcConfig = fs.readJSONSync(abcConfigFile); + if (abcConfig.type === 'pegasus' && abcConfig.group && abcConfig.name) { + isPegasusProject = true; + specialLaunchUrl = `${BASE_URL}/${abcConfig.group}/${abcConfig.name}`; + } + } + } catch (e) { + // ignore + } + // Set launch.json let launchConfig; - const defaultLaunchConfig = getLaunchConfig(); + const defaultLaunchConfig = getLaunchConfig(specialLaunchUrl); const launchConfigPath = path.join(targetDir, 'launch.json'); if (fs.existsSync(launchConfigPath)) { const configurations: any[] = []; @@ -55,8 +71,9 @@ export function setDebugConfig() { // Set tasks.json let tasksConfig; - const defaultTasksConfig = getTasksConfig(); + const defaultTasksConfig = getTasksConfig(isPegasusProject); const tasksConfigPath = path.join(targetDir, 'tasks.json'); + if (fs.existsSync(tasksConfigPath)) { const tasks: any[] = []; From ec0f8385cb621be629ba44aa1e4c80342d997af5 Mon Sep 17 00:00:00 2001 From: yangfan <18767120422@163.com> Date: Wed, 19 Aug 2020 15:31:01 +0800 Subject: [PATCH 03/13] feat: support create pegasus project (#439) * feat: init * feat: init service * fix: prettier:fix * feat: udpate * feat: update * fix: prettier:fix * feat: update version * feat: updaet review --- .gitignore | 2 +- .../iceworks-project-creator/CHANGELOG.md | 3 ++ .../iceworks-project-creator/package.json | 9 +++-- .../src/services/index.ts | 3 +- .../components/PegasusCard/index.module.scss | 40 +++++++++++++++++++ .../web/src/components/PegasusCard/index.tsx | 19 +++++++++ .../PegasusScaffoldContent/index.module.scss | 12 ++++++ .../PegasusScaffoldContent/index.tsx | 32 +++++++++++++++ .../web/src/locales/en-US.json | 1 + .../web/src/locales/zh-CN.json | 1 + .../components/ScaffoldMarket/index.tsx | 23 ++++++++++- .../web/src/pages/CreateProject/index.tsx | 1 + 12 files changed, 138 insertions(+), 8 deletions(-) create mode 100644 extensions/iceworks-project-creator/web/src/components/PegasusCard/index.module.scss create mode 100644 extensions/iceworks-project-creator/web/src/components/PegasusCard/index.tsx create mode 100644 extensions/iceworks-project-creator/web/src/components/PegasusScaffoldContent/index.module.scss create mode 100644 extensions/iceworks-project-creator/web/src/components/PegasusScaffoldContent/index.tsx diff --git a/.gitignore b/.gitignore index 5b9b200f7..f917e556d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,12 +5,12 @@ npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* -.vscode node_modules .DS_Store .eslintcache .happypack +.vscode coverage/ tmp/ .tmp/ diff --git a/extensions/iceworks-project-creator/CHANGELOG.md b/extensions/iceworks-project-creator/CHANGELOG.md index 3ebaf798b..1ac1f3798 100644 --- a/extensions/iceworks-project-creator/CHANGELOG.md +++ b/extensions/iceworks-project-creator/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## 0.3.7 +- feat: support create pegasus project + ## 0.3.6 - feat: disable form input when submitting diff --git a/extensions/iceworks-project-creator/package.json b/extensions/iceworks-project-creator/package.json index cb2b11a71..5cf8ec67c 100644 --- a/extensions/iceworks-project-creator/package.json +++ b/extensions/iceworks-project-creator/package.json @@ -3,7 +3,7 @@ "displayName": "Iceworks Application Creator", "description": "Quick create a Universal Application(React/Rax/Vue, etc).", "publisher": "iceworks-team", - "version": "0.3.6", + "version": "0.3.7", "engines": { "vscode": "^1.41.0" }, @@ -89,12 +89,13 @@ "webpack-cli": "^3.3.11" }, "dependencies": { - "@iceworks/recorder": "^0.1.0", "@iceworks/common-service": "^0.1.3", + "@iceworks/i18n": "^0.1.0", "@iceworks/material-service": "^0.1.3", + "@iceworks/pegasus-service": "^0.1.0", "@iceworks/project-service": "^0.1.4", - "@iceworks/vscode-webview": "^0.1.1", - "@iceworks/i18n": "^0.1.0" + "@iceworks/recorder": "^0.1.0", + "@iceworks/vscode-webview": "^0.1.1" }, "homepage": "https://github.com/ice-lab/iceworks/blob/master/extensions/iceworks-project-creator/README.md", "bugs": { diff --git a/extensions/iceworks-project-creator/src/services/index.ts b/extensions/iceworks-project-creator/src/services/index.ts index d2c0e00a5..d173045ea 100644 --- a/extensions/iceworks-project-creator/src/services/index.ts +++ b/extensions/iceworks-project-creator/src/services/index.ts @@ -1,5 +1,6 @@ import * as project from '@iceworks/project-service'; import * as material from '@iceworks/material-service'; import * as common from '@iceworks/common-service'; +import * as pegasus from '@iceworks/pegasus-service'; -export default { project, common, material }; +export default { project, common, material, pegasus }; diff --git a/extensions/iceworks-project-creator/web/src/components/PegasusCard/index.module.scss b/extensions/iceworks-project-creator/web/src/components/PegasusCard/index.module.scss new file mode 100644 index 000000000..5511c9f2f --- /dev/null +++ b/extensions/iceworks-project-creator/web/src/components/PegasusCard/index.module.scss @@ -0,0 +1,40 @@ +.container { + width: 160px; + border: 1px solid $color-fill1-4; + margin: 0 10px 20px 10px; + padding: 12px 10px; + cursor: pointer; + position: relative; + display: flex; + flex-direction: row; + align-items: center; + + .icon { + width: 24px; + height: 24px; + } + + .title { + margin: 0 5px; + color: white; + font-size: 16px; + font-weight: normal; + line-height: 1.5; + } + + .newTag { + position: absolute; + top: -5px; + right: 4px; + width: 28px; + height: 28px; + } + + &:hover { + border: 1px solid $color-notice-3; + } +} + +.active { + border: 1px solid $color-notice-3; +} diff --git a/extensions/iceworks-project-creator/web/src/components/PegasusCard/index.tsx b/extensions/iceworks-project-creator/web/src/components/PegasusCard/index.tsx new file mode 100644 index 000000000..6642de42e --- /dev/null +++ b/extensions/iceworks-project-creator/web/src/components/PegasusCard/index.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { useIntl } from 'react-intl'; +import classnames from 'classnames'; +import callService from '@/callService'; + +import styles from './index.module.scss'; + +export default (props) => { + const { onClick, selected } = props; + const intl = useIntl(); + + return ( +
+ + +

{intl.formatMessage({ id: 'web.iceworksProjectCreator.ScaffoldMarket.pegasus' })}

+
+ ); +}; diff --git a/extensions/iceworks-project-creator/web/src/components/PegasusScaffoldContent/index.module.scss b/extensions/iceworks-project-creator/web/src/components/PegasusScaffoldContent/index.module.scss new file mode 100644 index 000000000..d38b64837 --- /dev/null +++ b/extensions/iceworks-project-creator/web/src/components/PegasusScaffoldContent/index.module.scss @@ -0,0 +1,12 @@ +.container { + position: relative; + width: 100%; + height: 100%; + padding-left: 8px; + + .content { + border: none; + width: 100%; + height: 100%; + } +} diff --git a/extensions/iceworks-project-creator/web/src/components/PegasusScaffoldContent/index.tsx b/extensions/iceworks-project-creator/web/src/components/PegasusScaffoldContent/index.tsx new file mode 100644 index 000000000..606f3708f --- /dev/null +++ b/extensions/iceworks-project-creator/web/src/components/PegasusScaffoldContent/index.tsx @@ -0,0 +1,32 @@ +import React, { useEffect } from 'react'; +import callService from '@/callService'; + +import styles from './index.module.scss'; + +const PAYLOAD = { + keywords: { value: ['webbased-rax'] }, + terminal: { value: ['mobile', 'pc'] }, +}; +const URL = `https://banff.alibaba-inc.com/iframe/component?from=imgcook&fullScreen=true&payload=${encodeURIComponent( + JSON.stringify(PAYLOAD) +)}`; + +export default () => { + useEffect(() => { + // 监听天马 iframe 事件 + window.addEventListener('message', (event) => { + if (event.origin && (event.origin.includes('banff') || event.origin.includes('pegasus'))) { + if (event.data.type === 'init' && event.data.data.id) { + console.log('创建天马模块完毕...'); + callService('pegasus', 'init', event.data); + } + } + }); + }, []); + + return ( +
+