Skip to content

Commit

Permalink
chore: iceworks/release-2.17.0 (#1497)
Browse files Browse the repository at this point in the history
* Iceworks/add lint (#1480)

* feat: add lint

* chore: yarn.lock

* chore: network

* fix: fix iceworks error  (#1532)

* chore: add git error log

* feat: upgrate template-builder v2 (#1512)

* chore: timeout 配置更改;注释增加

* feat: 日志服务添加

* feat: Iceworks download process optim (#1564)

* 添加下载流程日志,如 `正在请求区块数据 => 正在解压区块 => 安装依赖` 等详细步骤日志
* 添加具体的容错处理,之前的下载流程没有补获具体的步骤错误,统一都是区块下载失败,这里改成了具体的错误具体抛出
* 部分下载代码重构
* 默认使用 cnpm 源进行下载

![image](https://user-images.githubusercontent.com/3995814/53929078-7cebab80-40c7-11e9-8ebe-564d6ead536c.png)


* 如果不是使用的 cnpm 源则给出提示,推荐使用 cnpm 源进行下载


![image](https://user-images.githubusercontent.com/3995814/53929380-8c1f2900-40c8-11e9-9b88-13f35d9e9e34.png)


fix: #1564  2 、10

* Iceworks/bug fix 7 8 (#1576)

对常见问题 #1544 7,8的修复
1. 添加pluginHoc 统一用cdcatch封装一层
2. 移除git插件ipcRenderer的focus事件监听,这里同denpendies一样,频繁触发会导致react报错(问题7)
3. 问题8,对于git插件不可用的用户提示关闭

* Iceworks/component display (#1538)

* feat: 组件市场 - 结构

* 组件市场展示

1. 飞冰物料源,基础组件和业务组件合并
2. 组件展示以是否已下载状态
3. 组件下载之后,显示引用方法复制,点击可复制引用方法代码

* 组件市场 下载

* chore: 组件下载完之后局部刷新;添加进度

* lint

* chore: 样式微调

* fix:some bug

* Iceworks/bug fix 21 (#1573)

物料源请求失败处理:
1. CI中添加物料更新时自动发包(@icedesign/materails-db)逻辑,使用unpkg作为备份物料源
2. 当正常物料源因为超时无法访问时,自动切换备份物料源。
2. 增加 备份数据也无法访问时的错误处理逻辑。

* chore: code review

* chore: code optim

* chore: hidden speedtest

* fix: merge bug

* chore: materials-db-publish

* chore: opt

* chore: yarn install

* chore: yarn reinstall

* fix: yarn.lock registry

* fix: 文案优化

* fix: 区分物料源加载失败和基础组件加载失败的错误

* fix: iceworks bugs (#1589)

* fix: 内网环境判断逻辑优化&移除无用的 is-alibaba

* fix: bug

* fix: backupSource set

* chore: materials backup set

* fix: iceworks/oss bugfix (#1590)

* chore: update template-builder version

* fix: iceBaseComponents 不存在的情况

* chore: defaultMaterials 合并 (#1601)

* fix: 初始选中 (#1603)
  • Loading branch information
fenglai0802 authored and imsobear committed Mar 12, 2019
1 parent 1193593 commit 3703f01
Show file tree
Hide file tree
Showing 178 changed files with 5,455 additions and 2,861 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,6 +7,7 @@ mochawesome-report
package-lock.json
yarn.lock
yarn-error.log
tempDir

*/blocks/**/lib/
*/layouts/**/lib/
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -24,7 +24,6 @@
"@vue/cli-service": "^3.0.0-beta.6",
"@vue/eslint-config-airbnb": "^3.0.0-beta.6",
"@vue/eslint-config-standard": "^3.0.0-rc.7",
"vue-template-compiler": "^2.5.17",
"ali-oss": "^5.1.1",
"babel-core": "^6.26.0",
"babel-eslint": "^8.1.2",
Expand Down Expand Up @@ -58,8 +57,10 @@
"request": "^2.83.0",
"request-promise": "^4.2.2",
"rimraf": "^2.6.2",
"semver": "^5.6.0",
"semver-regex": "^1.0.0",
"uppercamelcase": "^3.0.0"
"uppercamelcase": "^3.0.0",
"vue-template-compiler": "^2.5.17"
},
"config": {
"ghooks": {
Expand Down
73 changes: 73 additions & 0 deletions scripts/materials-db-publish.js
@@ -0,0 +1,73 @@
const npmRequestJson = require('npm-request-json');
const path = require('path');
const fs = require('fs');
const { exec } = require('child_process');
const rimraf = require("rimraf");
const semver = require("semver");

function publishMaterialsDB() {

// 1. 创建临时文件夹
const tempDir = path.join(__dirname, 'tempDir');
rimraf.sync(tempDir); // 初始化删除
fs.mkdirSync(tempDir);
const tempLibDir = path.join(tempDir, 'lib');
fs.mkdirSync(tempLibDir);

// 2 同步build下物料源配置文件到 tempDir/src 下
const buildPath = path.resolve(__dirname, '../build');
fs.readdirSync(buildPath).map(
(filename) => {
const from = path.join(buildPath, filename);
const to = path.join(tempLibDir, filename);
fs.copyFileSync(from, to);
}
);

// 3. 创建 package.json 文件
const pkgConfig = {
"name": "@icedesign/materails-db",
"version": "1.0.0",
"description": "iceworks 官方物料源备份数据",
"main": "lib",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"publishConfig": {
"registry": "http://registry.npmjs.com",
"access": "public"
}
};
// 获取已发布版本号
const NPM_REGISTRY = process.env.NPM_REGISTRY || 'registry.npmjs.com';
const registry = `https://${NPM_REGISTRY}`;
return npmRequestJson({
name: pkgConfig.name,
version: 'latest',
registry,
})
.then((pkgData) => {
// 版本号自增1
pkgConfig.version = semver.inc(pkgData.version, 'patch');
const pkgPath = path.join(tempDir, 'package.json');
fs.writeFileSync(pkgPath, JSON.stringify(pkgConfig));
// 4. 发布
exec('npm publish', {
cwd: tempDir
}, (error, stdout, stderr) => {
if(error) {
console.error(error);
rimraf.sync(tempDir);
throw error;
}
console.log('发布完成: ' + stdout);
rimraf.sync(tempDir);
})
})
}

module.exports = {
publishMaterialsDB
}
18 changes: 6 additions & 12 deletions scripts/sync-db.js
Expand Up @@ -3,6 +3,7 @@ const co = require('co');
const { readdirSync, readFileSync, writeFile } = require('fs');
const path = require('path');
const request = require('request');
const { publishMaterialsDB } = require('./materials-db-publish');
const scaffolds = require('./scaffolds');

if (
Expand Down Expand Up @@ -43,19 +44,12 @@ sortScaffoldMaterials()
);

const tasks = files.map(createUploadTask);

Promise.all(tasks)
.then(() => {
console.log('All Done');
})
.catch((err) => {
console.log('upload err', err);
});
return Promise.all(tasks);
})
.then(publishMaterialsDB) // 物料源数据发布到npm,作为兜底备份
.then(()=> {
console.log('all done');
})
.catch((err) => {
console.log('sort err', err);
});

/**
* 按照下载量进行排序推荐
*/
Expand Down
16 changes: 16 additions & 0 deletions tools/iceworks/.eslintignore
@@ -0,0 +1,16 @@
# 忽略目录
build/
dist/
node_modules/
out/
tests/
binary/
bin-win32/
bin-darwin/

# node 覆盖率文件
coverage/

# 忽略文件
**/*-min.js
**/*.min.js
76 changes: 76 additions & 0 deletions tools/iceworks/.eslintrc
@@ -0,0 +1,76 @@
{
"root": true,
"parser": "babel-eslint",
"extends": "eslint-config-airbnb",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"env": {
"browser": true,
"mocha": true,
"node": true,
"commonjs": true
},
"plugins": ["react", "babel"],
"rules": {
"arrow-parens": [2, "always"],
"no-console": 0,
"no-use-before-define": 0,
"react/forbid-prop-types": 0,
"jsx-a11y/label-has-for": 0,
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/anchor-has-content": 0,
"jsx-a11y/click-events-have-key-events": 0,
"jsx-a11y/anchor-is-valid": 0,
"react/no-array-index-key": 0,
"func-names": 0,
"arrow-body-style": 0,
"react/sort-comp": 0,
"react/prop-types": 0,
"react/jsx-first-prop-new-line": 0,
"react/react-in-jsx-scope": 0,
"react/jsx-filename-extension": [
1,
{
"extensions": [".js", ".jsx"]
}
],
"import/extensions": 0,
"import/no-unresolved": 0,
"import/no-extraneous-dependencies": 0,
"import/prefer-default-export": 0,
"prefer-destructuring": 0,
"no-param-reassign": 0,
"no-return-assign": 0,
"max-len": 0,
"consistent-return": 0,
"no-redeclare": 0,
"react/require-extension": 0,
"react/no-danger": 0,
"comma-dangle": ["error", "always-multiline"],
"function-paren-newline": 0,
"object-curly-newline": 0,
"no-restricted-globals": 0,
"react/prefer-stateless-function": 0,
"react/jsx-no-bind": 0,
"no-plusplus": 0,
"global-require": 0,
"no-case-declarations": 0,
"class-methods-use-this": 0,
"prefer-promise-reject-errors": 0,
"no-underscore-dangle": 0,
"one-var": 0,
"one-var-declaration-per-line": 0,
"no-return-await": 0,
"import/no-dynamic-require": 0,
"no-restricted-syntax": 0,
"no-await-in-loop": 0,
"no-useless-escape": 0,
"no-continue": 0,
"prefer-const": 0
}
}
2 changes: 1 addition & 1 deletion tools/iceworks/README.md
Expand Up @@ -16,7 +16,7 @@
开发调试

```
nvm use 8 // 安装 >= 8.10.0 && < 9 的版本
// 保证 Node.js 版本 >= 8.10.0 && < 9 的版本
yarn install
yarn dev
yarn start
Expand Down
47 changes: 47 additions & 0 deletions tools/iceworks/app/main/alilog.js
@@ -0,0 +1,47 @@
const request = require('request');
const { app } = require('electron');


/**
* 阿里云 SLS 服务,日志上报方法
* @param {string} topic 类型:info / error
* @param {object} data 健值参数
* data = {
* type: '', // 标识具体action /
* }
*/
const report = (data = {}, topic = 'info') => {
// SLS config:配置参照 https://help.aliyun.com/document_detail/31752.html?spm=a2c4g.11186623.6.707.614f8bdceHbp2w&accounttraceid=3835f51f-2862-4a2c-a8e7-fc695d89c700
const project = 'iceworks';
const logstore = 'iceworks-log';
const host = 'cn-hangzhou.log.aliyuncs.com';
let url = `http://${project}.${host}/logstores/${logstore}/track?`;
// log 基础信息,保留字段, 如果传入参数有这些字段会被覆盖。
const baseData = {
__topic__: topic, // 日志类型
APIVersion: '0.6.0', // sls 必须的参数
platform: `${process.platform}_${process.arch}`, // app 信息
version: app.getVersion(), // iceworks版本信息
};

// 构造参数
const totalData = Object.assign(data, baseData);
const dataKeyArray = Object.keys(totalData);
const param = dataKeyArray.reduce((finnalStr, currentKey, index) => {
const currentData = typeof totalData[currentKey] === 'string'
? totalData[currentKey]
: JSON.stringify(totalData[currentKey]);
return `${finnalStr}${currentKey}=${currentData}${dataKeyArray.length - 1 === index ? '' : '&'}`;
}, '');

url += param;

request({
url,
timeout: 2000,
});
};

module.exports = {
report,
};
2 changes: 1 addition & 1 deletion tools/iceworks/app/main/app.js
Expand Up @@ -95,7 +95,7 @@ exports.registerShortcut = (app, windows) => {
log.info('shortcutKey register success', shortcutKey);
log.report('app', {
action: 'shortcut-key',
shortcutKey: shortcutKey,
shortcutKey,
});
}

Expand Down
12 changes: 6 additions & 6 deletions tools/iceworks/app/main/autoUpdater.js
Expand Up @@ -13,8 +13,8 @@ let win = null;
function sendStatusToWindow(event, meta = null) {
log.info(event, meta);
sendToWebContents(win, 'updater-message', {
event: event,
meta: meta,
event,
meta,
});
}

Expand Down Expand Up @@ -84,25 +84,25 @@ const Updater = {
// 每间隔三小时监测软件更新
}, 1000 * 60 * 60 * 3);

ipcMain.on('updater-check', (event, data) => {
ipcMain.on('updater-check', () => {
// 检查更新
autoUpdater.checkForUpdates().catch((e) => {
sendStatusToWindow('error', e);
log.error('Failed handling checkForUpdates:', e);
});
});
ipcMain.on('updater-close', (event, data) => {
ipcMain.on('updater-close', () => {
// 关闭
win.close();
});
ipcMain.on('updater-start', (event, data) => {
ipcMain.on('updater-start', () => {
// 开始下载
autoUpdater.downloadUpdate().catch((e) => {
sendStatusToWindow('error', e);
log.error('Failed handling downloadUpdate:', e);
});
});
ipcMain.on('updater-install', (event, data) => {
ipcMain.on('updater-install', () => {
// 退出并安装
autoUpdater.quitAndInstall();
});
Expand Down

0 comments on commit 3703f01

Please sign in to comment.