Skip to content

Commit

Permalink
release: 0.9.2 (#531)
Browse files Browse the repository at this point in the history
* fix: create router page error

* chore: router-service package version

* fix: create rax-app page import error

* chore: page-service version

* fix: lint

* fix: repeat create router

* feat: Time Steward (#528)

* feat: Initial release

* fix: remove unuseful codetime

* fix: code time init

* refactor: rename

* chore: make code simple

* refactor: using recorder

* refactor: user logic

* docs: security and privacy

* style: import order

* style: shorthand

* refactor: rename packageJson interface

* refactor: logo

* docs: add more section

* docs: add beta description

* docs: style

Co-authored-by: 新影 <xinying.ykk@alibaba-inc.com>
Co-authored-by: alvinhui <alvin.hui@qq.com>

* fix: create router pagename param (#537)

* fix: comment

* fix: lint

* chore: version

* fix: comment

Co-authored-by: luhc228 <luhengchang228@gmail.com>
Co-authored-by: yincoco <524404942@qq.com>
Co-authored-by: 新影 <xinying.ykk@alibaba-inc.com>
Co-authored-by: Hengchang Lu <44047106+luhc228@users.noreply.github.com>
  • Loading branch information
5 people authored Sep 14, 2020
1 parent e3346f1 commit f019d65
Show file tree
Hide file tree
Showing 21 changed files with 406 additions and 18 deletions.
11 changes: 11 additions & 0 deletions extensions/iceworks-time-steward/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.vscode/**
.vscode-test/**
out/test/**
src/**
.gitignore
vsc-extension-quickstart.md
**/tsconfig.json
**/tslint.json
**/*.map
**/*.ts
node_modules
5 changes: 5 additions & 0 deletions extensions/iceworks-time-steward/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change Log

## 0.1.0

- Initial release
24 changes: 24 additions & 0 deletions extensions/iceworks-time-steward/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
English | [简体中文](https://github.com/ice-lab/iceworks/blob/master/extensions/iceworks-time-steward/README.zh-CN.md)

# Iceworks Time Steward(Beta)

[![Version for VS Code Extension](https://vsmarketplacebadge.apphb.com/version-short/iceworks-team.iceworks-time-steward.svg?logo=visual-studio-code)](https://marketplace.visualstudio.com/items?itemName=iceworks-team.iceworks-time-steward)
[![Installs](https://vsmarketplacebadge.apphb.com/installs-short/iceworks-team.iceworks-time-steward.svg)](https://marketplace.visualstudio.com/items?itemName=iceworks-team.iceworks-time-steward)
[![Rating](https://vsmarketplacebadge.apphb.com/rating-short/iceworks-team.iceworks-time-steward.svg)](https://marketplace.visualstudio.com/items?itemName=iceworks-team.iceworks-time-steward)
[![The MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)

Metrics, insights, and time tracking automatically generated from your programming activity.

## Security and Privacy

**We never access your code**: We do not process, send, or store your proprietary code. We only provide metrics about programming. Time Steward is an open source plugin, we make it easy to see the data we collect.

**Your data is private**: We will never share your individually identifiable data with anyone.

## Check Data

This plugin is still in the internal testing stage, please contact the author to check the data.

## More

See the [Iceworks](https://marketplace.visualstudio.com/items?itemName=iceworks-team.iceworks) to know more features.
24 changes: 24 additions & 0 deletions extensions/iceworks-time-steward/README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
简体中文 | [English](https://github.com/ice-lab/iceworks/blob/master/extensions/iceworks-time-steward/README.md)

# Iceworks 时间管家(Beta)

[![Version for VS Code Extension](https://vsmarketplacebadge.apphb.com/version-short/iceworks-team.iceworks-time-steward.svg?logo=visual-studio-code)](https://marketplace.visualstudio.com/items?itemName=iceworks-team.iceworks-time-steward)
[![Installs](https://vsmarketplacebadge.apphb.com/installs-short/iceworks-team.iceworks-time-steward.svg)](https://marketplace.visualstudio.com/items?itemName=iceworks-team.iceworks-time-steward)
[![Rating](https://vsmarketplacebadge.apphb.com/rating-short/iceworks-team.iceworks-time-steward.svg)](https://marketplace.visualstudio.com/items?itemName=iceworks-team.iceworks-time-steward)
[![The MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)

自动生成你的编程时间统计和效率度量,提供优化建议。

## 如何查看数据

插件当前仍在内测阶段,数据查看需联系作者。

## 安全和隐私

**我们从不访问您的代码**:我们不处理、发送或存储您的代码,我们只提供有关编程的度量。时间管家是开源的,你可以很容易地看到我们收集了什么数据。

**您的数据是私有的**:我们永远不会与任何人共享您的个人数据。

## 更多

访问 [Iceworks](https://marketplace.visualstudio.com/items?itemName=iceworks-team.iceworks) 获取更多功能。
Binary file added extensions/iceworks-time-steward/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions extensions/iceworks-time-steward/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "iceworks-time-steward",
"displayName": "Iceworks Time Steward(Beta)",
"description": "Metrics, insights, and time tracking automatically generated from your programming activity.",
"publisher": "iceworks-team",
"version": "0.1.0",
"engines": {
"vscode": "^1.41.0"
},
"categories": [
"Other"
],
"keywords": [
"Time",
"Metrics",
"Insights",
"Tracker",
"Time Tracking",
"Timer"
],
"icon": "assets/logo.png",
"activationEvents": [
"*"
],
"repository": {
"type": "git",
"url": "https://github.com/ice-lab/iceworks.git"
},
"main": "./build/extension.js",
"scripts": {
"vscode:prepublish": "rm -rf build && webpack --mode production",
"webpack": "webpack --mode development",
"webpack-dev": "webpack --mode development --watch",
"compile": "tsc -p ./tsconfig.json"
},
"devDependencies": {
"@types/node": "^12.11.7",
"@types/vscode": "^1.41.0",
"@types/request": "^2.48.5",
"ts-loader": "^8.0.3",
"typescript": "^3.6.4",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
},
"dependencies": {
"@iceworks/common-service": "^0.1.14",
"@iceworks/recorder": "^0.1.1"
},
"homepage": "https://github.com/ice-lab/iceworks/blob/master/extensions/iceworks-time-steward/README.md",
"bugs": {
"url": "https://github.com/ice-lab/iceworks/issues",
"email": "iceworksteam@163.com"
}
}
23 changes: 23 additions & 0 deletions extensions/iceworks-time-steward/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as vscode from 'vscode';
import { getUserInfo, checkIsAliInternal } from '@iceworks/common-service';
import { Timer } from './timer';

let timer: Timer;

export async function activate() {
console.info('start timer');
let user = { name: vscode.env.machineId };

const isAliInternal = await checkIsAliInternal();
if (isAliInternal) {
user = await getUserInfo();
}

timer = new Timer(user);
timer.initialize();
}

export function deactivate() {
timer.dispose();
console.info('timer has been disabled!');
}
123 changes: 123 additions & 0 deletions extensions/iceworks-time-steward/src/timer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import * as vscode from 'vscode';
import * as fs from 'fs';
import { Recorder } from '@iceworks/recorder';
import { IPackageJson } from './typings/package';

// eslint-disable-next-line
const { name, version } = require('../package.json');
const recorder = new Recorder(name, version);

export class Timer {
private disposable: vscode.Disposable;

private lastFile: string = '';

private lastHeartbeat: number = 0;

private user;

constructor(user) {
this.user = user;
}

public initialize(): void {
this.setupEventListeners();
}

private setupEventListeners(): void {
// subscribe to selection change and editor activation events
const subscriptions: vscode.Disposable[] = [];

// 监听光标位置变化
vscode.window.onDidChangeTextEditorSelection(this.onChange, this, subscriptions);
// 监听左侧文件树当前激活的文件变化
vscode.window.onDidChangeActiveTextEditor(this.onChange, this, subscriptions);
// 监听保存事件
vscode.workspace.onDidSaveTextDocument(this.onSave, this, subscriptions);
// 监听编辑器失去焦点的变化情况
vscode.window.onDidChangeWindowState(this.onFocus, this, subscriptions);

// create a combined disposable from both event subscriptions
this.disposable = vscode.Disposable.from(...subscriptions);
}

public dispose() {
this.disposable.dispose();
}

private onChange(): void {
this.onEvent(false);
}

private onSave(): void {
this.onEvent(true);
}

private onFocus(event: { focused: boolean }): void {
if (!event.focused) {
this.onEvent(true);
this.lastHeartbeat = 0;
}
}

private onEvent(isWrite: boolean): void {
const editor = vscode.window.activeTextEditor;
if (editor) {
const doc = editor.document;
if (doc) {
const file: string = doc.fileName;
if (file) {
const time: number = Date.now();
const enoughTimePassed = this.enoughTimePassed(time);
console.info(`isWrite:${isWrite}; enoughTimePassed: ${enoughTimePassed}; lastFile: ${this.lastFile}`);
/**
* 发送规则:
* 1. 保存时必然发送
* 2. 切换文件时必然发送
* 3. 在同一个文件里面每隔2分钟发送一次
*/
if (isWrite || enoughTimePassed || this.lastFile !== file) {
const project = this.getProjectName(file);
const subTime = time - this.lastHeartbeat;
const { name } = this.user;
if (this.lastHeartbeat !== 0) {
recorder.record({
module: 'main',
action: 'tracking',
data: {
user: name,
timestamp: subTime,
project,
},
});
}

this.lastFile = file;
this.lastHeartbeat = time;
}
}
}
}
}

private enoughTimePassed(time: number): boolean {
return this.lastHeartbeat + 120000 < time;
}

private getProjectName(file: string): string {
const uri = vscode.Uri.file(file);
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
if (workspaceFolder) {
try {
const packageJsonResultObj: IPackageJson = JSON.parse(
fs.readFileSync(`${workspaceFolder.uri.path}/package.json`, 'utf-8')
);
return packageJsonResultObj.name;
} catch (e) {
console.error(e.message);
}
return workspaceFolder.name;
}
return '';
}
}
3 changes: 3 additions & 0 deletions extensions/iceworks-time-steward/src/typings/package.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface IPackageJson {
name: string;
}
9 changes: 9 additions & 0 deletions extensions/iceworks-time-steward/tsconfig.extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2019",
"lib": ["ES2019"],
"sourceMap": true,
"strict": true /* enable all strict type-checking options */
}
}
21 changes: 21 additions & 0 deletions extensions/iceworks-time-steward/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "out",
"moduleResolution": "node",
"lib": ["es2018"],
"sourceMap": true,
"rootDir": ".",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"importHelpers": true,
"removeComments": true,
"noImplicitAny": false,
"strictPropertyInitialization": false
},
"exclude": ["node_modules"]
}
44 changes: 44 additions & 0 deletions extensions/iceworks-time-steward/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const path = require('path');

const tsConfigPath = path.join(__dirname, 'tsconfig.json');

const config = {
target: 'node',
entry: './src/index.ts',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'extension.js',
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]',
},
externals: {
vscode: 'commonjs vscode',
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
configFile: tsConfigPath,
},
},
],
},
],
},
};

module.exports = (env, argv) => {
if (argv.mode === 'development') {
config.devtool = 'source-map';
}

return config;
};
6 changes: 6 additions & 0 deletions extensions/iceworks-ui-builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 0.1.14

- fix: fail to use lazy to import page component in `routes.js`
- fix: `import React from 'react';` occurs in Rax page
- fix: the page component name in `routes.js` has capital error

## 0.1.13

- docs: update text for find component and generate page
Expand Down
2 changes: 1 addition & 1 deletion extensions/iceworks-ui-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Iceworks UI Builder",
"description": "Build UI by low-code way",
"publisher": "iceworks-team",
"version": "0.1.13",
"version": "0.1.14",
"engines": {
"vscode": "^1.41.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,18 @@ export default ({
setIsCreating(true);
let pageIndexPath = '';
try {
pageIndexPath = await callService('page', 'createPage', {
const result = await callService('page', 'createPage', {
...selectedPage,
pageName: values.pageName,
templateData,
});

pageIndexPath = result.pageIndexPath;
const { pageName } = result;

if (isConfigurableRouter) {
try {
await callService('router', 'create', values);
await callService('router', 'create', { ...values, pageName });
} catch (error) {
Notification.error({ content: error.message });
}
Expand Down
Loading

0 comments on commit f019d65

Please sign in to comment.