Skip to content

Commit

Permalink
Release 1.3.0 (#906)
Browse files Browse the repository at this point in the history
* fix: override.files neo work

* feat: update

* Feat/prop types auto complete (#902)

* feat: complete proptypes

* feat: code snippets (#903)

* feat: auto fill content in store's files

* docs: update changelog (#909)

* refactor: variable rename

* fix: dashboard error in external (#911)

* feat: import auto complete (#905)

* feat: import-auto-complete

* feat: export types (#904)

* feat: import auto completion  (#914)

* feat: import auto complete

* feat: update release (#913)

* fix: code snippets (#915)

* fix: code snippets

* feat: update registry

Co-authored-by: GiveMe-A-Name <[email protected]>
Co-authored-by: Hengchang Lu <[email protected]>
Co-authored-by: GiveMe-A-Name <[email protected]>
  • Loading branch information
4 people authored Jul 22, 2021
1 parent 2c3e7e4 commit dfe740b
Show file tree
Hide file tree
Showing 48 changed files with 6,340 additions and 5,717 deletions.
4 changes: 4 additions & 0 deletions extensions/application-manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 1.0.3

- fix: can not get project info in dashboard when in external

## 1.0.2

- feat: add loading status when reinstalling dependencies
Expand Down
2 changes: 1 addition & 1 deletion extensions/application-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Application Manager",
"description": "Quick view your Universal Application(React/Rax/Vue, etc).",
"publisher": "iceworks-team",
"version": "1.0.2",
"version": "1.0.3",
"engines": {
"vscode": "^1.41.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export default {
effects: () => ({
async refresh() {
this.setState({ inited: true });
const basic = await callService('project', 'getProjectBaseInfo');
const git = await callService('project', 'getProjectGitInfo');
const def = await callService('project', 'getProjectDefInfo', CLIENT_TOKEN);
const [basic, git, def] = await Promise.all([
await callService('project', 'getProjectBaseInfo'),
await callService('project', 'getProjectGitInfo'),
await callService('project', 'getProjectDefInfo', CLIENT_TOKEN),
]);
this.setState({
basic,
git,
Expand Down
9 changes: 9 additions & 0 deletions extensions/appworks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## [1.3.0](https://github.com/appworks-lab/pack/releases/tag/v1.3.0)

- feat: add jsx files propTypes auto complete [#902](https://github.com/appworks-lab/pack/pull/902)
- feat: add code snippets [#903](https://github.com/appworks-lab/pack/pull/903)
- feat: auto fill content in store's files when create [#908](https://github.com/appworks-lab/pack/pull/908)
- feat: add auto complete when import modules [#905](https://github.com/appworks-lab/pack/pull/905)
- fix: dashboard show 404 and 500 error [#911](https://github.com/appworks-lab/pack/pull/911)
- fix: eslint config `overrides` not work [#901](https://github.com/appworks-lab/pack/pull/901)

## [1.2.1](https://github.com/appworks-lab/pack/releases/tag/v1.2.1)

- feat: support double click to select scaffold [#895](https://github.com/appworks-lab/pack/pull/895)
Expand Down
2 changes: 1 addition & 1 deletion extensions/appworks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "AppWorks",
"description": "Application Development Pack, provide visualization and intelligent technology to build Universal Application faster and better, support Web / H5 / MiniProgram(小程序) Application.",
"publisher": "iceworks-team",
"version": "1.2.1",
"version": "1.3.0",
"engines": {
"vscode": "^1.41.0"
},
Expand Down
4 changes: 4 additions & 0 deletions extensions/doctor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log


## 1.1.2

- feat: update @appworks/doctor to support custom config set extends and plugins.
## 1.1.1

- fix: empty project show wrong CodeMod notice.
Expand Down
4 changes: 2 additions & 2 deletions extensions/doctor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Doctor",
"description": "A free security and quality audit tool for modern DevOps teams",
"publisher": "iceworks-team",
"version": "1.1.1",
"version": "1.1.2",
"engines": {
"vscode": "^1.41.0"
},
Expand Down Expand Up @@ -82,7 +82,7 @@
"@appworks/common-service": "^0.1.0",
"@appworks/connector": "^0.1.0",
"@appworks/constant": "^0.1.0",
"@appworks/doctor": "^0.2.0",
"@appworks/doctor": "^0.2.1",
"@appworks/project-service": "^0.1.0",
"@appworks/recorder": "^0.1.0",
"@appworks/storage": "^0.1.0",
Expand Down
7 changes: 7 additions & 0 deletions extensions/material-helper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 1.0.7

- feat: add import auxiliary
- feat: add code snippets that provide for ICE/RAX project
- feat: support React Component propTypes auto complete
- feat: auto fill content when store.[t|j]s & models/xx.[t|j].s files create

## 1.0.6

- fix: command `Find Components In Current File` not working.
Expand Down
25 changes: 22 additions & 3 deletions extensions/material-helper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Component Helper",
"description": "Easily use Component in React/Vue/Rax.",
"publisher": "iceworks-team",
"version": "1.0.6",
"version": "1.0.7",
"main": "./build/extension.js",
"engines": {
"vscode": "^1.41.0"
Expand All @@ -19,7 +19,8 @@
"JSX",
"Component",
"Props",
"appworks"
"appworks",
"snippets"
],
"icon": "assets/logo.png",
"activationEvents": [
Expand Down Expand Up @@ -335,7 +336,25 @@
"description": "%iceworksMaterialHelper.configuration.properties.appworks.generateComponentPath.description%"
}
}
}
},
"snippets": [
{
"language": "javascript",
"path": "./snippets/snippets.json"
},
{
"language": "typescript",
"path": "./snippets/snippets.json"
},
{
"language": "javascriptreact",
"path": "./snippets/snippets.json"
},
{
"language": "typescriptreact",
"path": "./snippets/snippets.json"
}
]
},
"scripts": {
"vscode:prepublish": "rm -rf build && npm run build:web && npm run build:extension",
Expand Down
32 changes: 32 additions & 0 deletions extensions/material-helper/snippets/snippets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"lazy import": {
"prefix": "lazy",
"body": "const ${2:componentName} = lazy(() => import('${1:component}'));"
},
"lazy import with chunkName": {
"prefix": "lazy",
"body": "const ${3:componentName} = lazy(() => import(/* webpackChunkName: '${2:chunkName}' */ '${1:component}'));"
},
"useRequest": {
"prefix": "useRequest",
"body": "const { data, error, loading, request } = useRequest(${1:service});"
},
"mtopRequest": {
"prefix": "mtopRequest",
"body": [
"Mtop.request({",
"\tapi: '${1:api}',",
"\tv: '${2:version}',",
"\tdata: ${3:data},",
"}).then(",
"\t(value) => { ${4}}",
").catch(",
"\t(error) => { ${5}}",
");"
]
},
"mtopConfig": {
"prefix": "mtopConfig",
"body": "Mtop.config('${1:configKey}', '${2:configValue}')"
}
}
109 changes: 109 additions & 0 deletions extensions/material-helper/src/autoFillContent/autoFillInStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import * as vscode from 'vscode';
import * as path from 'path';
import { getProjectFramework } from '@appworks/project-service';
import * as ejs from 'ejs';
import * as util from 'util';
import * as fs from 'fs';

const renderFileAsync = util.promisify(ejs.renderFile);
const writeFileAsync = util.promisify(fs.writeFile);

enum CreateFileTypes {
Null,
Store,
Models,
}

function checkIsTsorJsFile(filename: string) {
return ['.js', '.ts'].includes(path.extname(filename));
}


/**
* check the file is or not validate Store.[t|j]s file
* conditions:
* 1. the filename must is store.[t|j]s
* 2. the filePath must start with xxx/src or xxx/src/pages/xxx;
*/

function checkIsValidateStoreFile(srcDir: string, filePath: string, filename: string): boolean {
const pagesDir = 'src/pages';
// the file's directory is or not xxx/src | xxx/src/pages/xxx/
const isInValidateDir = !!vscode.workspace.workspaceFolders?.find((workspaceFolder) => {
return (
// It prevent user create store.[t|j]s file in models folder,
!filePath.endsWith('/models') &&
(
path.join(workspaceFolder.uri.fsPath, srcDir) === filePath ||
filePath.startsWith(path.join(workspaceFolder.uri.fsPath, pagesDir))
)
);
});

const storeFilenames = ['store.ts', 'store.js'];
return storeFilenames.includes(filename) && isInValidateDir;
}


/**
* check the file is or not validate model file
* conditions:
* 1. file must .js or .ts filename extension;
*
*/
function checkIsValidateInModelsFolder(srcDir: string, filePath: string, filename: string): boolean {
// models folder
// Example: xxx/models/xx.[t|j]s;
const modelsDir = '/models';
const isInValidateModelsDir = !!vscode.workspace.workspaceFolders?.find((workspaceFolder) => {
return (
filePath.includes(path.join(workspaceFolder.uri.fsPath, srcDir)) &&
filePath.endsWith(modelsDir)
);
});
return isInValidateModelsDir && checkIsTsorJsFile(filename);
}

function getCreateFileType(file: vscode.Uri): CreateFileTypes {
const { fsPath } = file;
const srcDir = 'src';
const filename = path.basename(fsPath);
const filePath = path.dirname(fsPath);
if (checkIsValidateStoreFile(srcDir, filePath, filename)) {
return CreateFileTypes.Store;
} else if (checkIsValidateInModelsFolder(srcDir, filePath, filename)) {
return CreateFileTypes.Models;
} else {
return CreateFileTypes.Null;
}
}

async function checkIsValidate(file: vscode.Uri, projectFramework: string): Promise<[CreateFileTypes, boolean]> {
if (['rax-app', 'icejs'].includes(projectFramework)) {
const createFileType = getCreateFileType(file);
return [createFileType, createFileType !== CreateFileTypes.Null];
}
return [CreateFileTypes.Null, false];
}

async function fillContent(
file: vscode.Uri,
projectFramework: string,
createFileType: CreateFileTypes,
) {
const { fsPath: newFsPath } = file;
const dependency = projectFramework === 'icejs' ? 'ice' : 'rax-app';
const templateName = createFileType === CreateFileTypes.Models ? 'models' : 'store';
const templatePath = path.join(__dirname, `${templateName}.ts.ejs`);
const content = await renderFileAsync(templatePath, { dependency });
await writeFileAsync(newFsPath, content);
}

export default async (file: vscode.Uri) => {
const projectFramework = await getProjectFramework();
const [createFileType, isValidate] = await checkIsValidate(file, projectFramework);
if (isValidate) {
// auto fill content with the type of file;
await fillContent(file, projectFramework, createFileType);
}
};
2 changes: 2 additions & 0 deletions extensions/material-helper/src/autoFillContent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as upperFirst from 'lodash.upperfirst';
import * as camelCase from 'lodash.camelcase';
import { getProjectLanguageType, getProjectType } from '@appworks/project-utils';
import { getDataFromSettingJson } from '@appworks/common-service';
import autoFillInStore from './autoFillInStore';

const renderFileAsync = util.promisify(ejs.renderFile);
const writeFileAsync = util.promisify(fs.writeFile);
Expand Down Expand Up @@ -95,6 +96,7 @@ export default function () {
}
}
}
await autoFillInStore(file);
}));
});

Expand Down
8 changes: 7 additions & 1 deletion extensions/material-helper/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { registerDebugCommand } from './utils/debugMaterials';
import { createComponentsTreeView } from './views/componentsView';
import { createPagesTreeView } from './views/pagesView';
import mtopAutoComplete from './mtopAutoComplete';
import importAutoComplete from './importAutoComplete';
import propTypesAutoComplete from './propTypesAutoComplete';

const { window, ViewColumn } = vscode;

Expand Down Expand Up @@ -121,10 +123,14 @@ export function activate(context: vscode.ExtensionContext) {
mtopAutoComplete();
registerComponentDocSupport();
autoFillContent();

// views
createComponentsTreeView(context);
createPagesTreeView(context);

importAutoComplete();
// help user complete React Component's propTypes;
propTypesAutoComplete();
}

export function deactivate() { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as vscode from 'vscode';
import getBabelParserPlugins from '../utils/getBabelParserPlugins';
import { parse } from '@babel/parser';
import traverse, { NodePath } from '@babel/traverse';
import { ImportDeclaration } from '@babel/types';
import { join } from 'path';

export default (doc: vscode.TextDocument): Set<string> => {
const importSet: Set<string> = new Set();
const documentText = doc.getText();
try {
const ast = parse(documentText, {
sourceType: 'module',
plugins: getBabelParserPlugins('jsx'),
});
traverse(ast, {
ImportDeclaration(path: NodePath<ImportDeclaration>) {
const { node } = path;
const moduleName = node.source.value;
importSet.add(join(moduleName));
},
});
} catch (e) {
console.log(e);
}

return importSet;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as vscode from 'vscode';
import * as path from 'path';
import getFilenameWithoutExtname from './getFilenameWithoutExtname';

export default function getCompletionItem(itemText: string, moduleValue?: string): vscode.CompletionItem {
// if moduleName is undefined, get it from filename;
const moduleName = moduleValue || getFilenameWithoutExtname(path.basename(itemText));
const completionItem = new vscode.CompletionItem(`import ${moduleName} from '${itemText}';`, vscode.CompletionItemKind.Variable);
// special deal with { };
moduleValue = moduleValue === '{ }' ? '{ ${1} }' : `\${1:${moduleName}}`;
completionItem.detail = 'AppWorks';
completionItem.insertText = new vscode.SnippetString(`import ${moduleValue} from '${itemText}';`);
return completionItem;
}
Loading

0 comments on commit dfe740b

Please sign in to comment.