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kveRV2
zuIXX7DqZ`3^eY8_|Ho9av||w)Nq+p7&=m9%zVR)O6bEXVf_JQ
zLdN>)-eTv6qX-bOzj)LR7ais&HX5yXv7OOXX~%d_z+M7Kl38y|?+=%*U0U&=gl_Qq
z?8dk&)WeK=xAGG{y$^hM!P-LC3Kr&?2_?;w*CbCvzsJay;mRK+_aRgSFR7E?NyMC&
h(FN;GWnd99zlX$EP2Vj7e!OYkzCAX(3wEB0{6AQ7tStZl
diff --git a/extensions/iceworks-project-creator/web/src/assets/pc.svg b/extensions/iceworks-project-creator/web/src/assets/pc.svg
new file mode 100644
index 000000000..00a792b7e
--- /dev/null
+++ b/extensions/iceworks-project-creator/web/src/assets/pc.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/extensions/iceworks-project-creator/web/src/assets/ts.svg b/extensions/iceworks-project-creator/web/src/assets/ts.svg
index 8fb815312..76ceca398 100644
--- a/extensions/iceworks-project-creator/web/src/assets/ts.svg
+++ b/extensions/iceworks-project-creator/web/src/assets/ts.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/extensions/iceworks-project-creator/web/src/assets/wireless.svg b/extensions/iceworks-project-creator/web/src/assets/wireless.svg
new file mode 100644
index 000000000..577e51fd5
--- /dev/null
+++ b/extensions/iceworks-project-creator/web/src/assets/wireless.svg
@@ -0,0 +1,20 @@
+
+
+
diff --git a/extensions/iceworks-project-creator/web/src/pages/CreateProject/components/ScaffoldMarket/index.module.scss b/extensions/iceworks-project-creator/web/src/pages/CreateProject/components/ScaffoldMarket/index.module.scss
index 218371a8d..febf96222 100644
--- a/extensions/iceworks-project-creator/web/src/pages/CreateProject/components/ScaffoldMarket/index.module.scss
+++ b/extensions/iceworks-project-creator/web/src/pages/CreateProject/components/ScaffoldMarket/index.module.scss
@@ -37,7 +37,7 @@
.loading {
width: 100%;
- height: 100%;
+ height: 90%;
}
.mainScaffolds {
diff --git a/extensions/iceworks-project-creator/web/src/pages/CreateProject/components/ScaffoldMarket/index.tsx b/extensions/iceworks-project-creator/web/src/pages/CreateProject/components/ScaffoldMarket/index.tsx
index e0f67aea1..a2706e1a0 100644
--- a/extensions/iceworks-project-creator/web/src/pages/CreateProject/components/ScaffoldMarket/index.tsx
+++ b/extensions/iceworks-project-creator/web/src/pages/CreateProject/components/ScaffoldMarket/index.tsx
@@ -7,13 +7,13 @@ import NotFound from '@/components/NotFound';
import callService from '@/callService';
import { IMaterialSource, IMaterialScaffold } from '@iceworks/material-utils';
import { mainScaffoldsList, tsScaffoldsList, jsScaffoldsList } from '@/constant';
+import { IScaffoldMarket } from '@/types';
import styles from './index.module.scss';
const projectTypes = ['react', 'rax', 'vue'];
-const ScaffoldMarket = ({ onScaffoldSelect, children, onOpenConfigPanel, materialSources }) => {
+const ScaffoldMarket = ({ onScaffoldSelect, curProjectField, children, onOpenConfigPanel, materialSources }) => {
const [selectedSource, setSelectedSource] = useState({});
- const [SelectedMaterial, setSelectedMaterial] = useState(null);
const [mainScaffolds, setMainScaffolds] = useState([]);
const [otherScaffolds, setOtherScaffolds] = useState([]);
const [loading, setLoading] = useState(false);
@@ -26,7 +26,6 @@ const ScaffoldMarket = ({ onScaffoldSelect, children, onOpenConfigPanel, materia
const { mainScaffolds, otherScaffolds } = data as any;
setMainScaffolds(mainScaffolds);
setOtherScaffolds(otherScaffolds);
- setSelectedMaterial(null);
} catch (err) {
// ignore
} finally {
@@ -34,12 +33,11 @@ const ScaffoldMarket = ({ onScaffoldSelect, children, onOpenConfigPanel, materia
}
}
- function onScaffoldMaterialClick(scaffold) {
- setSelectedMaterial(scaffold.name);
- onScaffoldSelect(scaffold);
+ function onScaffoldClick(scaffold) {
+ onScaffoldSelect(selectedSource, scaffold);
}
- async function getScaffolds(source: string) {
+ async function getScaffolds(source: string): Promise {
try {
const scaffolds = await callService('project', 'getScaffolds', source) as IMaterialScaffold[];
let main = scaffolds.filter(scaffold => mainScaffoldsList.includes(scaffold.source.npm));
@@ -61,13 +59,18 @@ const ScaffoldMarket = ({ onScaffoldSelect, children, onOpenConfigPanel, materia
if (!materialSources.length) {
return;
}
- setSelectedSource(materialSources[0]);
- const source = materialSources[0].source;
+ const selectedSource = curProjectField.source ? curProjectField.source : materialSources[0]
+ setSelectedSource(selectedSource);
+ const source = selectedSource.source;
const data = await getScaffolds(source);
- const { mainScaffolds, otherScaffolds } = data as any;
+ const { mainScaffolds, otherScaffolds } = data as IScaffoldMarket;
setMainScaffolds(mainScaffolds);
setOtherScaffolds(otherScaffolds);
+ if (mainScaffolds.length > 0) {
+ const selectedScaffold = curProjectField.scaffold ? curProjectField.scaffold : mainScaffolds[0];
+ onScaffoldSelect(selectedSource, selectedScaffold);
+ }
} catch (error) {
Notification.error({ content: error.message });
} finally {
@@ -84,12 +87,18 @@ const ScaffoldMarket = ({ onScaffoldSelect, children, onOpenConfigPanel, materia
{materialSources && materialSources.map(item => {
+ let iconName = 'app';
const projectType = item.type.toLocaleLowerCase();
+ if (item.client) {
+ iconName = item.client.toLocaleLowerCase();
+ } else if (projectTypes.includes(projectType)) {
+ iconName = projectType;
+ }
return
- {}
+ {}
{item.name}
}
@@ -125,8 +134,8 @@ const ScaffoldMarket = ({ onScaffoldSelect, children, onOpenConfigPanel, materia
}
content={item.description}
media={item.screenshot}
- selected={SelectedMaterial === item.name}
- onClick={() => onScaffoldMaterialClick(item)}
+ selected={curProjectField.scaffold.name === item.name}
+ onClick={() => onScaffoldClick(item)}
/>
)
}) :
@@ -153,8 +162,8 @@ const ScaffoldMarket = ({ onScaffoldSelect, children, onOpenConfigPanel, materia
}
content={item.description}
media={item.screenshot}
- selected={SelectedMaterial === item.name}
- onClick={() => onScaffoldMaterialClick(item)}
+ selected={curProjectField.scaffold.name === item.name}
+ onClick={() => onScaffoldClick(item)}
/>
)
})}
diff --git a/extensions/iceworks-project-creator/web/src/pages/CreateProject/index.tsx b/extensions/iceworks-project-creator/web/src/pages/CreateProject/index.tsx
index e33079136..17d64e4e1 100644
--- a/extensions/iceworks-project-creator/web/src/pages/CreateProject/index.tsx
+++ b/extensions/iceworks-project-creator/web/src/pages/CreateProject/index.tsx
@@ -25,7 +25,7 @@ const CreateProject: React.FC = () => {
const [materialSources, setMaterialSources] = useState
>([]);
const existProjectsRef = useRef([]);
const steps = [
-
+
,
@@ -73,14 +73,11 @@ const CreateProject: React.FC = () => {
};
function goPrev() {
- if (currentStep === 1) {
- setCurProjectField({ ...curProjectField, scaffold: null });
- }
setStep(currentStep - 1);
};
- function onScaffoldSelect(scaffold) {
- setCurProjectField({ ...curProjectField, scaffold })
+ function onScaffoldSelect(source, scaffold) {
+ setCurProjectField({ ...curProjectField, scaffold, source });
};
async function onScaffoldSubmit() {
diff --git a/extensions/iceworks-project-creator/web/src/types.ts b/extensions/iceworks-project-creator/web/src/types.ts
index 89ac8013a..0b6cc02e7 100644
--- a/extensions/iceworks-project-creator/web/src/types.ts
+++ b/extensions/iceworks-project-creator/web/src/types.ts
@@ -1,9 +1,10 @@
-import { IMaterialScaffold } from '@iceworks/material-utils';
+import { IMaterialScaffold, IMaterialSource } from '@iceworks/material-utils';
export interface IProjectField {
projectName: string;
projectPath: string;
- scaffold: IMaterialScaffold | null;
+ scaffold: IMaterialScaffold;
+ source: IMaterialSource;
scaffoldType: string;
}
@@ -27,4 +28,9 @@ export interface IGitLabGroup {
'name': string;
'path': string;
'web_url': string;
+}
+
+export interface IScaffoldMarket {
+ mainScaffolds: IMaterialScaffold[];
+ otherScaffolds: IMaterialScaffold[];
}
\ No newline at end of file
diff --git a/packages/material-service/package.json b/packages/material-service/package.json
index 320df6382..99843c2b9 100644
--- a/packages/material-service/package.json
+++ b/packages/material-service/package.json
@@ -1,6 +1,6 @@
{
"name": "@iceworks/material-service",
- "version": "0.1.7",
+ "version": "0.2.0",
"description": "Iceworks material service for VSCode extension.",
"files": [
"lib"
diff --git a/packages/material-service/src/index.ts b/packages/material-service/src/index.ts
index e56337090..21ed34f6c 100644
--- a/packages/material-service/src/index.ts
+++ b/packages/material-service/src/index.ts
@@ -13,12 +13,14 @@ const OFFICAL_MATERIAL_SOURCES = [
{
name: 'PC Web',
type: 'react',
+ client: 'pc',
source: ICE_MATERIAL_SOURCE,
description: '基于 Fusion 基础组件和 ICE 脚手架的官方物料'
},
{
name: '无线跨端',
type: 'rax',
+ client: 'wireless',
source: 'https://ice.alicdn.com/assets/materials/rax-materials.json',
description: '基于 Rax 组件和 Rax 脚手架的官方物料'
}
@@ -27,6 +29,7 @@ const OFFICAL_MATERIAL_SOURCES_FOR_EXTERNAL = [
{
name: 'Vue 物料源',
type: 'vue',
+ client: 'pc',
source: 'https://ice.alicdn.com/assets/materials/vue-materials.json',
description: '基于 Element, Vue CLI 的 Vue 官方物料'
}
From 05c75ad474b51b2495f1587df20a5ff916f7c890 Mon Sep 17 00:00:00 2001
From: yangfan <18767120422@163.com>
Date: Fri, 10 Jul 2020 10:57:18 +0800
Subject: [PATCH 05/26] feat: support SASS style preview for icejs (#206)
* fix: selector undefined
* feat: support scss
* feat: add changelog
---
extensions/iceworks-style-helper/CHANGELOG.md | 4 ++++
extensions/iceworks-style-helper/package.json | 2 +-
.../iceworks-style-helper/src/styleInfoViewer/findStyle.ts | 6 +++---
.../src/styleInfoViewer/findStyleDependencies.ts | 5 ++++-
.../src/styleInfoViewer/findStyleSelectors.ts | 6 ++++--
5 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/extensions/iceworks-style-helper/CHANGELOG.md b/extensions/iceworks-style-helper/CHANGELOG.md
index 5aa50039b..21c3401fa 100644
--- a/extensions/iceworks-style-helper/CHANGELOG.md
+++ b/extensions/iceworks-style-helper/CHANGELOG.md
@@ -1,5 +1,9 @@
# Change Log
+## 0.3.1
+
+Support ICE css module style preview and completion.
+
## 0.3.0
Add Sass Variables Helper:
diff --git a/extensions/iceworks-style-helper/package.json b/extensions/iceworks-style-helper/package.json
index ca8f14697..26eab0e45 100644
--- a/extensions/iceworks-style-helper/package.json
+++ b/extensions/iceworks-style-helper/package.json
@@ -3,7 +3,7 @@
"displayName": "Iceworks Style Helper",
"description": "Easily write styles in JSX.",
"publisher": "iceworks-team",
- "version": "0.3.0",
+ "version": "0.3.1",
"engines": {
"vscode": "^1.41.0"
},
diff --git a/extensions/iceworks-style-helper/src/styleInfoViewer/findStyle.ts b/extensions/iceworks-style-helper/src/styleInfoViewer/findStyle.ts
index d8fafb509..c6d09edeb 100644
--- a/extensions/iceworks-style-helper/src/styleInfoViewer/findStyle.ts
+++ b/extensions/iceworks-style-helper/src/styleInfoViewer/findStyle.ts
@@ -30,9 +30,9 @@ export function findStyle(directory: string, className: string, styleDependencie
for (let i = 0, l = styleDependencies.length; i < l; i++) {
const file = path.join(directory, styleDependencies[i].source);
const stylesheet = css.parse(fs.readFileSync(file, 'utf-8')).stylesheet;
-
- matched = stylesheet.rules.find(rule => rule.selectors.includes(`.${className}`));
-
+
+ matched = stylesheet.rules.find(rule => rule.selectors && rule.selectors.includes(`.${className}`));
+
// Just find one matched stylesheet.
if (matched) {
matched.file = file;
diff --git a/extensions/iceworks-style-helper/src/styleInfoViewer/findStyleDependencies.ts b/extensions/iceworks-style-helper/src/styleInfoViewer/findStyleDependencies.ts
index c31ab1abb..78fc7a844 100644
--- a/extensions/iceworks-style-helper/src/styleInfoViewer/findStyleDependencies.ts
+++ b/extensions/iceworks-style-helper/src/styleInfoViewer/findStyleDependencies.ts
@@ -2,6 +2,8 @@ import * as fs from 'fs';
import * as babelParser from '@babel/parser';
import traverse from '@babel/traverse';
+const supportFiles = ['css', 'scss', 'sass'];
+
// import styles from './xxx.css'; -> { source: './xxx.css', identifier: 'styles' }
// import './xxx.css'; -> { source: './xxx.css', identifier: null }
export interface IStyleDependency {
@@ -23,7 +25,8 @@ export function findStyleDependencies(file: string) {
traverse(ast, {
ImportDeclaration(path) {
const { node } = path;
- if (/\.css$/i.test(node.source.value)) {
+ // Example /\.css$|\.scss$|\.sass$/
+ if (new RegExp(`${supportFiles.map(supportFile => `\\.${supportFile}$`).join('|')}`, 'i').test(node.source.value)) {
StyleDependencies.push({
source: node.source.value,
// Just return first identifier.
diff --git a/extensions/iceworks-style-helper/src/styleInfoViewer/findStyleSelectors.ts b/extensions/iceworks-style-helper/src/styleInfoViewer/findStyleSelectors.ts
index 722afd495..23ff5bb59 100644
--- a/extensions/iceworks-style-helper/src/styleInfoViewer/findStyleSelectors.ts
+++ b/extensions/iceworks-style-helper/src/styleInfoViewer/findStyleSelectors.ts
@@ -14,10 +14,12 @@ export default function findStyleSelectors(directory: string, styleDependencies:
// eslint-disable-next-line
stylesheet.rules.forEach((rule: IStyle) => {
- selectors = selectors.concat(rule.selectors);
+ if (rule.selectors) {
+ selectors = selectors.concat(rule.selectors);
+ }
});
}
-
+
return selectors;
};
From 3938f3f208fcaa4f04b847b78d62c36fefd94b32 Mon Sep 17 00:00:00 2001
From: yangfan <18767120422@163.com>
Date: Fri, 10 Jul 2020 14:09:08 +0800
Subject: [PATCH 06/26] feat: supprot className (#210)
---
extensions/iceworks-style-helper/CHANGELOG.md | 3 ++-
extensions/iceworks-style-helper/README.en.md | 4 ++++
extensions/iceworks-style-helper/README.md | 4 ++++
extensions/iceworks-style-helper/package.json | 5 ++++-
.../src/styleInfoViewer/index.ts | 12 ++++++++----
5 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/extensions/iceworks-style-helper/CHANGELOG.md b/extensions/iceworks-style-helper/CHANGELOG.md
index 21c3401fa..44ef473aa 100644
--- a/extensions/iceworks-style-helper/CHANGELOG.md
+++ b/extensions/iceworks-style-helper/CHANGELOG.md
@@ -2,7 +2,8 @@
## 0.3.1
-Support ICE css module style preview and completion.
+- Support ICE css module style preview and completion.
+- Support className preview, definition and completion.
## 0.3.0
diff --git a/extensions/iceworks-style-helper/README.en.md b/extensions/iceworks-style-helper/README.en.md
index 2f794fb7f..77b57c30f 100644
--- a/extensions/iceworks-style-helper/README.en.md
+++ b/extensions/iceworks-style-helper/README.en.md
@@ -21,6 +21,10 @@ Write styles easier in [JSX](https://reactjs.org/docs/introducing-jsx.html), fri
![demo](https://img.alicdn.com/tfs/TB1UDGht.Y1gK0jSZFMXXaWcVXa-1468-906.gif)
+* When editing the 'className' attribute of a component in a JSX file, an automatic completion reminder will be given:
+
+ ![demo](https://img.alicdn.com/tfs/TB1JqP0Nfb2gK0jSZK9XXaEgFXa-900-561.gif)
+
### Class name
When editing the 'class' name of a CSS, LESS or SASS file, an automatic completion reminder will be given:
diff --git a/extensions/iceworks-style-helper/README.md b/extensions/iceworks-style-helper/README.md
index 61cc00aa8..5ac5cdabe 100644
--- a/extensions/iceworks-style-helper/README.md
+++ b/extensions/iceworks-style-helper/README.md
@@ -20,6 +20,10 @@
![使用示例](https://img.alicdn.com/tfs/TB1pb1ltYY1gK0jSZTEXXXDQVXa-1468-906.gif)
![使用示例](https://img.alicdn.com/tfs/TB1UDGht.Y1gK0jSZFMXXaWcVXa-1468-906.gif)
+
+* 在 JSX 文件中编辑组件的 `className` 属性时给予自动补全提醒,预览及条跳转:
+
+ ![使用示例](https://img.alicdn.com/tfs/TB1JqP0Nfb2gK0jSZK9XXaEgFXa-900-561.gif)
### 样式文件
diff --git a/extensions/iceworks-style-helper/package.json b/extensions/iceworks-style-helper/package.json
index 26eab0e45..c2271d3f7 100644
--- a/extensions/iceworks-style-helper/package.json
+++ b/extensions/iceworks-style-helper/package.json
@@ -15,7 +15,10 @@
"Rax",
"React",
"JSX",
- "Inline Style"
+ "Inline Style",
+ "Style",
+ "CSS",
+ "ClassName"
],
"icon": "assets/logo.png",
"activationEvents": [
diff --git a/extensions/iceworks-style-helper/src/styleInfoViewer/index.ts b/extensions/iceworks-style-helper/src/styleInfoViewer/index.ts
index 480d45f6b..3c227e4d9 100644
--- a/extensions/iceworks-style-helper/src/styleInfoViewer/index.ts
+++ b/extensions/iceworks-style-helper/src/styleInfoViewer/index.ts
@@ -51,7 +51,12 @@ function provideCompletionItems(document: vscode.TextDocument, position: vscode.
const styleDependencies = findStyleDependencies(fileName);
for (let i = 0, l = styleDependencies.length; i < l; i++) {
- if (styleDependencies[i].identifier && new RegExp(`${styleDependencies[i].identifier}\\.$`).test(word)) {
+ if (
+ // className=xxx
+ /className=/.test(line.text) ||
+ // style={styles.xxx}
+ (styleDependencies[i].identifier && new RegExp(`${styleDependencies[i].identifier}\\.$`).test(word))
+ ) {
return findStyleSelectors(directory, styleDependencies).map((selector: string) => {
// Remove class selector `.`, When use styles.xxx.
return new vscode.CompletionItem(selector.replace('.', ''), vscode.CompletionItemKind.Variable);
@@ -83,9 +88,8 @@ export default function styleInfoViewer(context: vscode.ExtensionContext) {
vscode.languages.registerCompletionItemProvider(
language,
{ provideCompletionItems },
- // match [styles identifier].xxx
- // Example: `import test from './xxx.css'` match test.xxx;
- '.'
+ // eslint-disable-next-line
+ '.', '\"', '\'', ' ',
)
);
});
From c0bdcc1f26692b385200a52628bc23c08504e581 Mon Sep 17 00:00:00 2001
From: Hengchang Lu <44047106+luhc228@users.noreply.github.com>
Date: Fri, 10 Jul 2020 14:21:00 +0800
Subject: [PATCH 07/26] feat: add material import to edit context (#203)
* feat: open material-import to editor-context
* chore: update change log
* feat: editor context
* chore: nls
* chore: typo
* fix: comment
---
extensions/iceworks-material-import/CHANGELOG.md | 4 ++++
extensions/iceworks-material-import/package.json | 13 +++++++++++--
packages/common-service/src/index.ts | 4 ++++
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/extensions/iceworks-material-import/CHANGELOG.md b/extensions/iceworks-material-import/CHANGELOG.md
index fdbdbc8e1..25c634440 100644
--- a/extensions/iceworks-material-import/CHANGELOG.md
+++ b/extensions/iceworks-material-import/CHANGELOG.md
@@ -1,5 +1,9 @@
# Change Log
+## 0.1.2
+
+- feat: quick activate iceworks-material-import extensions by editor context
+
## 0.1.1
- style: better style of the webview
diff --git a/extensions/iceworks-material-import/package.json b/extensions/iceworks-material-import/package.json
index 313f582f1..4128ede4d 100644
--- a/extensions/iceworks-material-import/package.json
+++ b/extensions/iceworks-material-import/package.json
@@ -3,7 +3,7 @@
"displayName": "Iceworks Material Import",
"description": "Quick import material in a visual way.",
"publisher": "iceworks-team",
- "version": "0.1.1",
+ "version": "0.1.2",
"engines": {
"vscode": "^1.41.0"
},
@@ -33,7 +33,16 @@
"command": "iceworks-material-import.start",
"title": "%iceworksMaterialImport.commands.start.title%"
}
- ]
+ ],
+ "menus": {
+ "editor/context": [
+ {
+ "command": "iceworks-material-import.start",
+ "group": "iceworksMaterialImport",
+ "when": "editorTextFocus && iceworks:isJSXFile"
+ }
+ ]
+ }
},
"scripts": {
"vscode:prepublish": "rm -rf build && npm run build:web && webpack --mode production",
diff --git a/packages/common-service/src/index.ts b/packages/common-service/src/index.ts
index 7abdb08ec..33ca842dc 100644
--- a/packages/common-service/src/index.ts
+++ b/packages/common-service/src/index.ts
@@ -68,6 +68,10 @@ export function onChangeActiveTextEditor(context: vscode.ExtensionContext) {
vscode.window.onDidChangeActiveTextEditor(
editor => {
if (editor) {
+ const fsPath = editor.document.uri.fsPath;
+ const isJSXFile = fsPath.match(/^.*\.(jsx?|tsx)$/g);
+ vscode.commands.executeCommand('setContext', 'iceworks:isJSXFile', isJSXFile);
+
// save active text editor id
const { id } = editor as any;
console.log('activeTextEditor Id', id);
From ee4979e06fbe1c997fe1332813c5b15d5c6c2849 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=AE=B8=E6=96=87=E6=B6=9B?=
Date: Fri, 10 Jul 2020 14:54:52 +0800
Subject: [PATCH 08/26] feat: automatically open application creator on first
installation (#211)
* feat: automatically open application creator on first installation
* docs: add changlog
* chore: change key
---
extensions/iceworks-app/src/extension.ts | 3 +-
.../iceworks-project-creator/CHANGELOG.md | 1 +
.../iceworks-project-creator/package.json | 3 +-
.../iceworks-project-creator/src/extension.ts | 29 ++++++++++++++-----
4 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/extensions/iceworks-app/src/extension.ts b/extensions/iceworks-app/src/extension.ts
index d5c892f6f..df9bde2f1 100644
--- a/extensions/iceworks-app/src/extension.ts
+++ b/extensions/iceworks-app/src/extension.ts
@@ -54,8 +54,9 @@ export async function activate(context: vscode.ExtensionContext) {
const projectType = await getProjectType();
const isNotTargetProject = projectType === 'unknown';
vscode.commands.executeCommand('setContext', 'iceworks:isNotTargetProject', isNotTargetProject);
- if (isNotTargetProject)
+ if (isNotTargetProject) {
vscode.commands.executeCommand('iceworks-project-creator.start');
+ }
} catch (e) {
vscode.commands.executeCommand('setContext', 'iceworks:isNotTargetProject', true);
vscode.commands.executeCommand('iceworks-project-creator.start');
diff --git a/extensions/iceworks-project-creator/CHANGELOG.md b/extensions/iceworks-project-creator/CHANGELOG.md
index 8e6f5b873..d1593636a 100644
--- a/extensions/iceworks-project-creator/CHANGELOG.md
+++ b/extensions/iceworks-project-creator/CHANGELOG.md
@@ -3,6 +3,7 @@
## 0.2.0
- feat: default select a scaffold
+- feat: automatically open application creator on first installation
## 0.1.9
diff --git a/extensions/iceworks-project-creator/package.json b/extensions/iceworks-project-creator/package.json
index 0529bdb43..90cfd085f 100644
--- a/extensions/iceworks-project-creator/package.json
+++ b/extensions/iceworks-project-creator/package.json
@@ -19,7 +19,8 @@
],
"icon": "assets/logo.png",
"activationEvents": [
- "onCommand:iceworks-project-creator.start"
+ "onCommand:iceworks-project-creator.start",
+ "onStartupFinished"
],
"main": "./build/extension.js",
"contributes": {
diff --git a/extensions/iceworks-project-creator/src/extension.ts b/extensions/iceworks-project-creator/src/extension.ts
index 5c5b1c2d9..54ebf2296 100644
--- a/extensions/iceworks-project-creator/src/extension.ts
+++ b/extensions/iceworks-project-creator/src/extension.ts
@@ -13,22 +13,35 @@ export function activate(context: vscode.ExtensionContext) {
// data collection
const logger = new Logger(name, globalState);
- logger.recordDAU();
- logger.recordActivate(version);
// auto set configuration
initExtension(context);
+ let webviewPanel: vscode.WebviewPanel;
+
function activeWebview() {
- const webviewPanel: vscode.WebviewPanel = window.createWebviewPanel('iceworks', '创建应用 - Iceworks', ViewColumn.One, {
- enableScripts: true,
- retainContextWhenHidden: true,
- });
- webviewPanel.webview.html = getHtmlForWebview(extensionPath);
- connectService(webviewPanel, context, { services, logger });
+ logger.recordDAU();
+ logger.recordActivate(version);
+
+ if (webviewPanel) {
+ webviewPanel.reveal();
+ } else {
+ webviewPanel = window.createWebviewPanel('iceworks', '创建应用 - Iceworks', ViewColumn.One, {
+ enableScripts: true,
+ retainContextWhenHidden: true,
+ });
+ webviewPanel.webview.html = getHtmlForWebview(extensionPath);
+ connectService(webviewPanel, context, { services, logger });
+ }
}
subscriptions.push(vscode.commands.registerCommand('iceworks-project-creator.start', function () {
activeWebview();
}));
+
+ const stateKey = 'iceworks.projectCreator.autoActivedWebview';
+ if (!globalState.get(stateKey)) {
+ activeWebview();
+ globalState.update(stateKey, true);
+ }
}
From 45e2992c50991185ca38ce797627feb8c99d316a Mon Sep 17 00:00:00 2001
From: Hengchang Lu <44047106+luhc228@users.noreply.github.com>
Date: Fri, 10 Jul 2020 14:55:54 +0800
Subject: [PATCH 09/26] feat: iceworks project viewer style(#177)
* feat: add stop command
* feat: add stop command
* feat: auto install deps
* feat: refresh when file changed
* fix: fix terminal dispose
* fix: treeItem class name
* fix: comment
* feat: add inputboxs
* chore: inputBox text
---
extensions/iceworks-app/CHANGELOG.md | 5 ++
extensions/iceworks-app/assets/dark/stop.svg | 1 +
extensions/iceworks-app/assets/light/stop.svg | 1 +
extensions/iceworks-app/package.json | 17 +++-
.../src/commands/executeCommand.ts | 28 +++++++
.../iceworks-app/src/commands/stopCommand.ts | 9 +++
extensions/iceworks-app/src/constants.ts | 2 +
extensions/iceworks-app/src/extension.ts | 10 ++-
.../src/inputBoxs/showDepsInputBox.ts | 14 ++++
extensions/iceworks-app/src/openEntryFile.ts | 14 ++++
.../src/quickPicks/showDepsQuickPick.ts | 17 ++++
.../showExtensionsQuickPick.ts} | 15 +---
.../statusBar/createExtensionsStatusBar.ts | 10 +++
extensions/iceworks-app/src/utils.ts | 56 -------------
.../iceworks-app/src/views/componentsView.ts | 80 ++++++++++++-------
.../src/views/nodeDependenciesView.ts | 77 ++++++++----------
.../iceworks-app/src/views/npmScriptsView.ts | 56 ++++++++-----
.../iceworks-app/src/views/pagesView.ts | 32 +++++---
packages/common-service/package.json | 4 +-
packages/common-service/src/index.ts | 6 +-
20 files changed, 271 insertions(+), 183 deletions(-)
create mode 100644 extensions/iceworks-app/assets/dark/stop.svg
create mode 100644 extensions/iceworks-app/assets/light/stop.svg
create mode 100644 extensions/iceworks-app/src/commands/executeCommand.ts
create mode 100644 extensions/iceworks-app/src/commands/stopCommand.ts
create mode 100644 extensions/iceworks-app/src/inputBoxs/showDepsInputBox.ts
create mode 100644 extensions/iceworks-app/src/openEntryFile.ts
create mode 100644 extensions/iceworks-app/src/quickPicks/showDepsQuickPick.ts
rename extensions/iceworks-app/src/{createStatusBarItem.ts => quickPicks/showExtensionsQuickPick.ts} (68%)
create mode 100644 extensions/iceworks-app/src/statusBar/createExtensionsStatusBar.ts
delete mode 100644 extensions/iceworks-app/src/utils.ts
diff --git a/extensions/iceworks-app/CHANGELOG.md b/extensions/iceworks-app/CHANGELOG.md
index 5bdd916e9..296e43945 100644
--- a/extensions/iceworks-app/CHANGELOG.md
+++ b/extensions/iceworks-app/CHANGELOG.md
@@ -1,5 +1,10 @@
# Change Log
+## 0.2.0
+- feat: install dependencies automatically when node_modules does not exist
+- feat: refresh dependencies list、pages list and components list automatically
+- feat: support stopping scripts
+
## 0.1.34
- feat: add Iceworks status bar entry
diff --git a/extensions/iceworks-app/assets/dark/stop.svg b/extensions/iceworks-app/assets/dark/stop.svg
new file mode 100644
index 000000000..6ed5ae5af
--- /dev/null
+++ b/extensions/iceworks-app/assets/dark/stop.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/extensions/iceworks-app/assets/light/stop.svg b/extensions/iceworks-app/assets/light/stop.svg
new file mode 100644
index 000000000..2538b4940
--- /dev/null
+++ b/extensions/iceworks-app/assets/light/stop.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/extensions/iceworks-app/package.json b/extensions/iceworks-app/package.json
index b8d5fc055..0a7adc1af 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.1.34",
+ "version": "0.2.0",
"engines": {
"vscode": "^1.41.0"
},
@@ -108,6 +108,14 @@
"dark": "assets/dark/run.svg"
}
},
+ {
+ "command": "iceworksApp.npmScripts.stop",
+ "title": "%iceworksApp.npmScripts.stop.title%",
+ "icon": {
+ "light": "assets/light/stop.svg",
+ "dark": "assets/dark/stop.svg"
+ }
+ },
{
"command": "iceworksApp.pages.add",
"title": "%iceworksApp.command.pages.add.title%",
@@ -252,7 +260,12 @@
],
"view/item/context": [
{
- "command": "iceworksApp.npmScripts.executeCommand",
+ "command": "iceworksApp.npmScripts.run",
+ "when": "view == npmScripts && viewItem == script",
+ "group": "inline"
+ },
+ {
+ "command": "iceworksApp.npmScripts.stop",
"when": "view == npmScripts && viewItem == script",
"group": "inline"
},
diff --git a/extensions/iceworks-app/src/commands/executeCommand.ts b/extensions/iceworks-app/src/commands/executeCommand.ts
new file mode 100644
index 000000000..53ee58d89
--- /dev/null
+++ b/extensions/iceworks-app/src/commands/executeCommand.ts
@@ -0,0 +1,28 @@
+import * as vscode from 'vscode';
+import { Terminal, TerminalOptions } from 'vscode';
+import { ITerminalMap } from '../types';
+
+export default function executeCommand(terminalMapping: ITerminalMap, script: vscode.Command, id?: string) {
+ if (!script.arguments) {
+ return;
+ }
+ const args = script.arguments;
+ const [cwd, command] = args;
+ if (!command) {
+ return;
+ }
+
+ const terminalId = id || command;
+ let terminal: Terminal;
+
+ if (terminalMapping.has(terminalId)) {
+ terminal = terminalMapping.get(terminalId)!;
+ } else {
+ const terminalOptions: TerminalOptions = { cwd, name: command };
+ terminal = vscode.window.createTerminal(terminalOptions);
+ terminalMapping.set(terminalId, terminal);
+ }
+
+ terminal.show();
+ terminal.sendText(command);
+}
\ No newline at end of file
diff --git a/extensions/iceworks-app/src/commands/stopCommand.ts b/extensions/iceworks-app/src/commands/stopCommand.ts
new file mode 100644
index 000000000..e6c4b7f53
--- /dev/null
+++ b/extensions/iceworks-app/src/commands/stopCommand.ts
@@ -0,0 +1,9 @@
+import { ITerminalMap } from '../types';
+
+export default function stopCommand(terminalMapping: ITerminalMap, scriptId: string) {
+ const currentTerminal = terminalMapping.get(scriptId);
+ if (currentTerminal) {
+ currentTerminal.dispose();
+ terminalMapping.delete(scriptId);
+ }
+}
\ No newline at end of file
diff --git a/extensions/iceworks-app/src/constants.ts b/extensions/iceworks-app/src/constants.ts
index 9d63cbd32..a82ac4134 100644
--- a/extensions/iceworks-app/src/constants.ts
+++ b/extensions/iceworks-app/src/constants.ts
@@ -11,3 +11,5 @@ export const nodeDepTypes: NodeDepTypes[] = [
'dependencies',
'devDependencies'
];
+
+export const showExtensionsQuickPickCommandId = 'iceworksApp.showExtensionsQuickPick';
diff --git a/extensions/iceworks-app/src/extension.ts b/extensions/iceworks-app/src/extension.ts
index df9bde2f1..f58b6a428 100644
--- a/extensions/iceworks-app/src/extension.ts
+++ b/extensions/iceworks-app/src/extension.ts
@@ -9,7 +9,9 @@ import { createComponentsTreeProvider } from './views/componentsView';
import { createPagesTreeProvider } from './views/pagesView';
import { ITerminalMap } from './types';
import services from './services';
-import { createStatusBarItem, openCommandPaletteCommandId, registerOpenCommandPalette } from './createStatusBarItem';
+import { showExtensionsQuickPickCommandId } from './constants';
+import showExtensionsQuickPick from './quickPicks/showExtensionsQuickPick';
+import createExtensionsStatusBar from './statusBar/createExtensionsStatusBar';
// eslint-disable-next-line
const { name, version } = require('../package.json');
@@ -27,9 +29,9 @@ export async function activate(context: vscode.ExtensionContext) {
initExtension(context);
// init statusBarItem
- const statusBarItem = createStatusBarItem();
- subscriptions.push(vscode.commands.registerCommand(openCommandPaletteCommandId, registerOpenCommandPalette));
- subscriptions.push(statusBarItem);
+ const extensionsStatusBar = createExtensionsStatusBar();
+ subscriptions.push(vscode.commands.registerCommand(showExtensionsQuickPickCommandId, showExtensionsQuickPick));
+ subscriptions.push(extensionsStatusBar);
// init webview
function activeWebview() {
const webviewPanel: vscode.WebviewPanel = window.createWebviewPanel('iceworks', '设置 - Iceworks', ViewColumn.One, {
diff --git a/extensions/iceworks-app/src/inputBoxs/showDepsInputBox.ts b/extensions/iceworks-app/src/inputBoxs/showDepsInputBox.ts
new file mode 100644
index 000000000..47b5e72b2
--- /dev/null
+++ b/extensions/iceworks-app/src/inputBoxs/showDepsInputBox.ts
@@ -0,0 +1,14 @@
+import * as vscode from 'vscode';
+import { NodeDepTypes, ITerminalMap } from '../types';
+import executeCommand from '../commands/executeCommand';
+
+export default async function showDepsInputBox(terminals: ITerminalMap, nodeDependenciesInstance: any, depType: NodeDepTypes) {
+ const result = await vscode.window.showInputBox({
+ placeHolder: '例如: lodash react@latest',
+ prompt: `请输入需要添加到 ${depType} 的依赖名称, 支持通过空格添加多个依赖`
+ });
+ if (!result) {
+ return;
+ }
+ executeCommand(terminals, nodeDependenciesInstance.getAddDependencyScript(depType, result));
+}
diff --git a/extensions/iceworks-app/src/openEntryFile.ts b/extensions/iceworks-app/src/openEntryFile.ts
new file mode 100644
index 000000000..057ebd9bf
--- /dev/null
+++ b/extensions/iceworks-app/src/openEntryFile.ts
@@ -0,0 +1,14 @@
+import * as path from 'path';
+import * as vscode from 'vscode';
+import * as fsExtra from 'fs-extra';
+import { entryFileSuffix } from './constants';
+
+export default function openEntryFile(p: string) {
+ const currentSuffix = entryFileSuffix.find((suffix) => fsExtra.pathExistsSync(path.join(p, `index${suffix}`)));
+ if (currentSuffix) {
+ const resource = vscode.Uri.file(path.join(p, `index${currentSuffix}`));
+ vscode.window.showTextDocument(resource);
+ } else {
+ vscode.window.showErrorMessage('Entry file not found.');
+ }
+}
diff --git a/extensions/iceworks-app/src/quickPicks/showDepsQuickPick.ts b/extensions/iceworks-app/src/quickPicks/showDepsQuickPick.ts
new file mode 100644
index 000000000..0b31f98d7
--- /dev/null
+++ b/extensions/iceworks-app/src/quickPicks/showDepsQuickPick.ts
@@ -0,0 +1,17 @@
+import * as vscode from 'vscode';
+import { nodeDepTypes } from '../constants';
+import { NodeDepTypes, ITerminalMap } from '../types';
+import showDepsInputBox from '../inputBoxs/showDepsInputBox';
+
+export default function showDepsQuickPick(terminals: ITerminalMap, nodeDependenciesInstance: any) {
+ const quickPick = vscode.window.createQuickPick();
+ quickPick.items = nodeDepTypes.map(label => ({ label, detail: `Install ${label}` }));
+ quickPick.onDidChangeSelection(selection => {
+ if (selection[0]) {
+ showDepsInputBox(terminals, nodeDependenciesInstance, selection[0].label as NodeDepTypes)
+ .catch(console.error);
+ }
+ });
+ quickPick.onDidHide(() => quickPick.dispose());
+ quickPick.show();
+};
\ No newline at end of file
diff --git a/extensions/iceworks-app/src/createStatusBarItem.ts b/extensions/iceworks-app/src/quickPicks/showExtensionsQuickPick.ts
similarity index 68%
rename from extensions/iceworks-app/src/createStatusBarItem.ts
rename to extensions/iceworks-app/src/quickPicks/showExtensionsQuickPick.ts
index d4b87453a..2d55d9d64 100644
--- a/extensions/iceworks-app/src/createStatusBarItem.ts
+++ b/extensions/iceworks-app/src/quickPicks/showExtensionsQuickPick.ts
@@ -1,16 +1,7 @@
import * as vscode from 'vscode';
-const { window } = vscode;
+const { window, commands } = vscode;
-export const openCommandPaletteCommandId = 'iceworksApp.openVSCodePanel';
-
-export function createStatusBarItem() {
- const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
- statusBarItem.text = 'Iceworks';
- statusBarItem.command = openCommandPaletteCommandId;
- statusBarItem.show();
- return statusBarItem;
-}
const extensionOptions = [
{ label: 'Iceworks 创建应用', detail: '快速创建多端应用(例如:React/Rax/Vue...)', command: 'iceworks-project-creator.start', },
{ label: 'Iceworks 生成页面', detail: '使用低代码的方式生成网页视图', command: 'iceworks-page-builder.create', },
@@ -18,13 +9,13 @@ const extensionOptions = [
{ label: 'Iceworks 导入物料', detail: '使用可视化的方式添加物料到应用中', command: 'iceworks-material-import.start' },
]
-export function registerOpenCommandPalette() {
+export default function showExtensionsQuickPick() {
const quickPick = window.createQuickPick();
quickPick.items = extensionOptions.map((options) => ({ label: options.label, detail: options.detail }));
quickPick.onDidChangeSelection(selection => {
if (selection[0]) {
const currentExtension = extensionOptions.find(option => option.label === selection[0].label)!;
- vscode.commands.executeCommand(currentExtension.command);
+ commands.executeCommand(currentExtension.command);
quickPick.dispose();
}
});
diff --git a/extensions/iceworks-app/src/statusBar/createExtensionsStatusBar.ts b/extensions/iceworks-app/src/statusBar/createExtensionsStatusBar.ts
new file mode 100644
index 000000000..21c6711f9
--- /dev/null
+++ b/extensions/iceworks-app/src/statusBar/createExtensionsStatusBar.ts
@@ -0,0 +1,10 @@
+import * as vscode from 'vscode';
+import { showExtensionsQuickPickCommandId } from '../constants';
+
+export default function createExtensionsStatusBar() {
+ const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
+ statusBarItem.text = 'Iceworks';
+ statusBarItem.command = showExtensionsQuickPickCommandId;
+ statusBarItem.show();
+ return statusBarItem;
+}
\ No newline at end of file
diff --git a/extensions/iceworks-app/src/utils.ts b/extensions/iceworks-app/src/utils.ts
deleted file mode 100644
index 467d8c7e1..000000000
--- a/extensions/iceworks-app/src/utils.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import * as path from 'path';
-import * as fse from 'fs-extra';
-import * as vscode from 'vscode';
-import { Terminal, TerminalOptions } from 'vscode';
-import { entryFileSuffix } from './constants';
-import { ITerminalMap } from './types';
-
-export function createTerminalName(cwd: string, command: string): string {
- return `${path.basename(cwd)} - ${command}`;
-}
-
-export function pathExists(p: string) {
- try {
- fse.accessSync(p);
- } catch (err) {
- return false;
- }
- return true;
-}
-
-export function executeCommand(terminalMapping: ITerminalMap, script: vscode.Command) {
- if (!script.arguments) {
- return;
- }
- const args = script.arguments;
- const [cwd, command] = args;
- let terminalName = args[2];
- if (!command) {
- return;
- }
- terminalName = terminalName || command;
- const name: string = createTerminalName(cwd, terminalName);
-
- let terminal: Terminal;
-
- if (terminalMapping.has(name)) {
- terminal = terminalMapping.get(name)!;
- } else {
- const terminalOptions: TerminalOptions = { cwd, name };
- terminal = vscode.window.createTerminal(terminalOptions);
- terminalMapping.set(name, terminal);
- }
-
- terminal.show();
- terminal.sendText(command);
-}
-
-export function openEntryFile(p: string) {
- const currentSuffix = entryFileSuffix.find(suffix => pathExists(path.join(p, `index${suffix}`)));
- if (currentSuffix) {
- const resource = vscode.Uri.file(path.join(p, `index${currentSuffix}`));
- vscode.window.showTextDocument(resource);
- } else {
- vscode.window.showErrorMessage('Entry file not found.');
- }
-}
diff --git a/extensions/iceworks-app/src/views/componentsView.ts b/extensions/iceworks-app/src/views/componentsView.ts
index 26c051232..30b4d9b69 100644
--- a/extensions/iceworks-app/src/views/componentsView.ts
+++ b/extensions/iceworks-app/src/views/componentsView.ts
@@ -1,16 +1,18 @@
import * as vscode from 'vscode';
import * as fse from 'fs-extra';
import * as path from 'path';
-import { pathExists, openEntryFile } from '../utils';
+import { checkPathExists } from '@iceworks/common-service';
+import { componentsPath } from '@iceworks/project-service';
+import openEntryFile from '../openEntryFile';
-class ComponentsProvider implements vscode.TreeDataProvider {
+class ComponentsProvider implements vscode.TreeDataProvider {
private workspaceRoot: string;
private extensionContext: vscode.ExtensionContext;
- private onDidChange: vscode.EventEmitter = new vscode.EventEmitter();
+ private onDidChange: vscode.EventEmitter = new vscode.EventEmitter();
- readonly onDidChangeTreeData: vscode.Event = this.onDidChange.event;
+ readonly onDidChangeTreeData: vscode.Event = this.onDidChange.event;
constructor(context: vscode.ExtensionContext, workspaceRoot: string) {
this.extensionContext = context;
@@ -21,54 +23,64 @@ class ComponentsProvider implements vscode.TreeDataProvider {
this.onDidChange.fire(undefined);
}
- getTreeItem(element: Component): vscode.TreeItem {
+ getTreeItem(element: ComponentTreeItem): vscode.TreeItem {
return element;
}
- getChildren() {
+ async getChildren() {
if (!this.workspaceRoot) {
return Promise.resolve([]);
}
const componentsPath = path.join(this.workspaceRoot, 'src', 'components');
- if (pathExists(componentsPath)) {
- const components = this.getComponents(componentsPath);
- return Promise.resolve(components);
- } else {
+ try {
+ const isComponentPathExists = await checkPathExists(componentsPath);
+ if (isComponentPathExists) {
+ const components = this.getComponents(componentsPath);
+ return Promise.resolve(components);
+ } else {
+ return Promise.resolve([]);
+ }
+ } catch (error) {
return Promise.resolve([]);
}
}
private async getComponents(componentsPath: string) {
- if (pathExists(componentsPath)) {
- const toComponent = (componentName: string) => {
- const pageEntryPath = path.join(componentsPath, componentName);
-
- const cmdObj: vscode.Command = {
- command: 'iceworksApp.components.openFile',
- title: 'Open File',
- arguments: [pageEntryPath]
- };
+ try {
+ const isComponentPathExists = await checkPathExists(componentsPath);
+ if (isComponentPathExists) {
+ const toComponent = (componentName: string) => {
+ const pageEntryPath = path.join(componentsPath, componentName);
+
+ const command: vscode.Command = {
+ command: 'iceworksApp.components.openFile',
+ title: 'Open File',
+ arguments: [pageEntryPath]
+ };
- return new Component(this.extensionContext, componentName, cmdObj);
- };
- const dirNames = await fse.readdir(componentsPath);
- // except file
- const componentNames = dirNames.filter(dirname => {
- const stat = fse.statSync(path.join(componentsPath, dirname));
- return stat.isDirectory();
- });
- return componentNames.map(componentName => toComponent(componentName));
- } else {
+ return new ComponentTreeItem(this.extensionContext, componentName, command);
+ };
+ const dirNames = await fse.readdir(componentsPath);
+ // except file
+ const componentNames = dirNames.filter(dirname => {
+ const stat = fse.statSync(path.join(componentsPath, dirname));
+ return stat.isDirectory();
+ });
+ return componentNames.map(componentName => toComponent(componentName));
+ } else {
+ return [];
+ }
+ } catch (e) {
return [];
}
}
}
-class Component extends vscode.TreeItem {
+class ComponentTreeItem extends vscode.TreeItem {
constructor(
public readonly extensionContext: vscode.ExtensionContext,
public readonly label: string,
- public readonly command?: vscode.Command
+ public readonly command: vscode.Command
) {
super(label);
}
@@ -90,4 +102,10 @@ export function createComponentsTreeProvider(context: vscode.ExtensionContext, r
});
vscode.commands.registerCommand('iceworksApp.components.refresh', () => componentsProvider.refresh());
vscode.commands.registerCommand('iceworksApp.components.openFile', (p) => openEntryFile(p));
+
+ const pattern = path.join(componentsPath);
+ const fileWatcher = vscode.workspace.createFileSystemWatcher(pattern);
+ fileWatcher.onDidChange(() => componentsProvider.refresh());
+ fileWatcher.onDidCreate(() => componentsProvider.refresh());
+ fileWatcher.onDidDelete(() => componentsProvider.refresh());
}
\ No newline at end of file
diff --git a/extensions/iceworks-app/src/views/nodeDependenciesView.ts b/extensions/iceworks-app/src/views/nodeDependenciesView.ts
index 25b242e58..f078a9a89 100644
--- a/extensions/iceworks-app/src/views/nodeDependenciesView.ts
+++ b/extensions/iceworks-app/src/views/nodeDependenciesView.ts
@@ -8,22 +8,25 @@ import { getPackageLocalVersion } from 'ice-npm-utils';
import {
getDataFromSettingJson,
createNpmCommand,
+ checkPathExists
} from '@iceworks/common-service';
-import { pathExists, executeCommand } from '../utils';
-import { NodeDepTypes, ITerminalMap } from '../types';
+import { dependencyDir } from '@iceworks/project-service';
+import executeCommand from '../commands/executeCommand';
+import { NodeDepTypes } from '../types';
import { nodeDepTypes } from '../constants';
-
+import showDepsInputBox from '../inputBoxs/showDepsInputBox';
+import showDepsQuickPick from '../quickPicks/showDepsQuickPick';
const rimrafAsync = util.promisify(rimraf);
-class DepNodeProvider implements vscode.TreeDataProvider {
+class DepNodeProvider implements vscode.TreeDataProvider {
private workspaceRoot: string;
private extensionContext: vscode.ExtensionContext;
- private onDidChange: vscode.EventEmitter = new vscode.EventEmitter();
+ private onDidChange: vscode.EventEmitter = new vscode.EventEmitter();
- readonly onDidChangeTreeData: vscode.Event = this.onDidChange.event;
+ readonly onDidChangeTreeData: vscode.Event = this.onDidChange.event;
packageJsonPath: string;
@@ -41,11 +44,11 @@ class DepNodeProvider implements vscode.TreeDataProvider {
this.onDidChange.fire(undefined);
}
- getTreeItem(element: DependencyNode): vscode.TreeItem {
+ getTreeItem(element: DependencyTreeItem): vscode.TreeItem {
return element;
}
- getChildren(element?: DependencyNode) {
+ getChildren(element?: DependencyTreeItem) {
if (!this.workspaceRoot) {
return Promise.resolve([]);
}
@@ -56,7 +59,7 @@ class DepNodeProvider implements vscode.TreeDataProvider {
return deps;
} else {
return Promise.resolve(
- nodeDepTypes.map(nodeDepType => new DependencyNode(this.extensionContext, nodeDepType, vscode.TreeItemCollapsibleState.Collapsed)));
+ nodeDepTypes.map(nodeDepType => new DependencyTreeItem(this.extensionContext, nodeDepType, vscode.TreeItemCollapsibleState.Collapsed, nodeDepType)));
}
}
@@ -70,11 +73,11 @@ class DepNodeProvider implements vscode.TreeDataProvider {
};
private async getDepsInPackageJson(packageJsonPath: string, label: NodeDepTypes) {
- if (pathExists(packageJsonPath)) {
+ if (await checkPathExists(packageJsonPath)) {
const packageJson = JSON.parse(await fse.readFile(packageJsonPath, 'utf-8'));
const workspaceDir: string = path.dirname(packageJsonPath);
- let deps: DependencyNode[] = [];
+ let deps: DependencyTreeItem[] = [];
if (packageJson[label]) {
deps = await Promise.all(Object.keys(packageJson[label]).map(async dep => {
const version = this.getDepVersion(dep);
@@ -105,14 +108,14 @@ class DepNodeProvider implements vscode.TreeDataProvider {
};
};
- public packageJsonExists() {
- return pathExists(this.packageJsonPath);
+ public async packageJsonExists() {
+ return await checkPathExists(this.packageJsonPath);
}
public async getReinstallScript() {
const workspaceDir: string = path.dirname(this.packageJsonPath);
const nodeModulesPath = path.join(workspaceDir, 'node_modules');
- if (pathExists(nodeModulesPath)) {
+ if (await checkPathExists(nodeModulesPath)) {
await rimrafAsync(nodeModulesPath);
}
const npmCommand = createNpmCommand('install');
@@ -147,16 +150,18 @@ class DepNodeProvider implements vscode.TreeDataProvider {
}
}
-class DependencyNode extends vscode.TreeItem {
+class DependencyTreeItem extends vscode.TreeItem {
constructor(
public readonly extensionContext: vscode.ExtensionContext,
public readonly label: string,
public readonly collapsibleState: vscode.TreeItemCollapsibleState,
+ public readonly id: string,
public readonly command?: vscode.Command,
public readonly version?: string,
public readonly outDated?: boolean
) {
super(label, collapsibleState);
+ this.id = id;
}
get description(): string {
@@ -181,40 +186,26 @@ export function createNodeDependenciesTreeProvider(context, rootPath, terminals)
const nodeDependenciesProvider = new DepNodeProvider(context, rootPath);
vscode.window.registerTreeDataProvider('nodeDependencies', nodeDependenciesProvider);
vscode.commands.registerCommand('iceworksApp.nodeDependencies.refresh', () => nodeDependenciesProvider.refresh());
- vscode.commands.registerCommand('iceworksApp.nodeDependencies.upgrade', (node: DependencyNode) => executeCommand(terminals, node.command!));
+ vscode.commands.registerCommand('iceworksApp.nodeDependencies.upgrade', (node: DependencyTreeItem) => {
+ if (node.command)
+ executeCommand(terminals, node.command, node.id);
+ });
vscode.commands.registerCommand('iceworksApp.nodeDependencies.reinstall', async () => {
- if (nodeDependenciesProvider.packageJsonExists()) {
+ if (await nodeDependenciesProvider.packageJsonExists()) {
const script = await nodeDependenciesProvider.getReinstallScript();
executeCommand(terminals, script!);
}
});
- context.subscriptions.push(vscode.commands.registerCommand('iceworksApp.nodeDependencies.dependencies.add', () => showDepInputBox(terminals, nodeDependenciesProvider, 'dependencies')));
- context.subscriptions.push(vscode.commands.registerCommand('iceworksApp.nodeDependencies.devDependencies.add', () => showDepInputBox(terminals, nodeDependenciesProvider, 'devDependencies')));
- context.subscriptions.push(vscode.commands.registerCommand('iceworksApp.nodeDependencies.addDepsAndDevDeps', () => addDepCommandHandler(terminals, nodeDependenciesProvider)));
-}
+ context.subscriptions.push(vscode.commands.registerCommand('iceworksApp.nodeDependencies.dependencies.add', () => showDepsInputBox(terminals, nodeDependenciesProvider, 'dependencies')));
+ context.subscriptions.push(vscode.commands.registerCommand('iceworksApp.nodeDependencies.devDependencies.add', () => showDepsInputBox(terminals, nodeDependenciesProvider, 'devDependencies')));
+ context.subscriptions.push(vscode.commands.registerCommand('iceworksApp.nodeDependencies.addDepsAndDevDeps', () => showDepsQuickPick(terminals, nodeDependenciesProvider)));
-export function addDepCommandHandler(terminals: ITerminalMap, nodeDependenciesInstance: any) {
- const quickPick = vscode.window.createQuickPick();
- quickPick.items = nodeDepTypes.map(label => ({ label, detail: `Install ${label}` }));
- quickPick.onDidChangeSelection(selection => {
- if (selection[0]) {
- showDepInputBox(terminals, nodeDependenciesInstance, selection[0].label as NodeDepTypes)
- .catch(console.error);
- }
- });
- quickPick.onDidHide(() => quickPick.dispose());
- quickPick.show();
-};
-
-async function showDepInputBox(terminals: ITerminalMap, nodeDependenciesInstance: any, depType: NodeDepTypes) {
- const result = await vscode.window.showInputBox({
- placeHolder: 'Please input the module name you want to install. For example lodash / loadsh@latest',
- });
- if (!result) {
- return;
- }
- executeCommand(terminals, nodeDependenciesInstance.getAddDependencyScript(depType, result));
+ const pattern = path.join(rootPath, dependencyDir);
+ const fileWatcher = vscode.workspace.createFileSystemWatcher(pattern);
+ fileWatcher.onDidChange(() => nodeDependenciesProvider.refresh());
+ fileWatcher.onDidCreate(() => nodeDependenciesProvider.refresh());
+ fileWatcher.onDidDelete(() => nodeDependenciesProvider.refresh());
}
function toDep(extensionContext: vscode.ExtensionContext, workspaceDir: string, moduleName: string, version: string, outdated: boolean) {
@@ -228,5 +219,5 @@ function toDep(extensionContext: vscode.ExtensionContext, workspaceDir: string,
arguments: [workspaceDir, npmCommand]
} :
undefined;
- return new DependencyNode(extensionContext, moduleName, vscode.TreeItemCollapsibleState.None, command, version, outdated);
+ return new DependencyTreeItem(extensionContext, moduleName, vscode.TreeItemCollapsibleState.None, `dependency-${moduleName}`, command, version, outdated);
};
diff --git a/extensions/iceworks-app/src/views/npmScriptsView.ts b/extensions/iceworks-app/src/views/npmScriptsView.ts
index 886694e1b..6e614d0bc 100644
--- a/extensions/iceworks-app/src/views/npmScriptsView.ts
+++ b/extensions/iceworks-app/src/views/npmScriptsView.ts
@@ -1,25 +1,27 @@
import * as vscode from 'vscode';
import * as fse from 'fs-extra';
import * as path from 'path';
-import { createNpmCommand } from '@iceworks/common-service'
-import { pathExists, executeCommand } from '../utils';
+import { createNpmCommand, checkPathExists } from '@iceworks/common-service';
+import { dependencyDir, packageJSONFilename } from '@iceworks/project-service';
+import executeCommand from '../commands/executeCommand';
+import stopCommand from '../commands/stopCommand';
import { ITerminalMap } from '../types';
-export class NpmScriptsProvider implements vscode.TreeDataProvider