Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #13 from ice-lab/release/2.5.1
Browse files Browse the repository at this point in the history
release 2.5.1
  • Loading branch information
imsobear committed Sep 5, 2019
2 parents 0eccc81 + 1f0fad1 commit 71695c4
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { commitlint } = require('@ice/spec');

module.exports = commitlint;
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.5.1

- [fix] 兼容 category 与 categories 字段

## 2.5.0

- [feat] 支持 react + ts 模板,移除 angular 模板
Expand Down
1 change: 0 additions & 1 deletion commitlint.config.js

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"dependencies": {},
"devDependencies": {
"@commitlint/cli": "^7.5.2",
"@commitlint/config-conventional": "^7.5.0",
"@ice/spec": "^0.1.5",
"eslint": "^6.0.1",
"husky": "^1.3.1"
Expand Down
11 changes: 8 additions & 3 deletions packages/ice-devtools/lib/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,20 @@ function generateMaterialsData(files, targetDir, type) {
// generate i18n data
const i18nData = generateI18nData({ title: materialConfig.title, description: pkg.description });

const {categories: originCategories, category: originCategory} = materialConfig;
// categories 字段:即将废弃,但是展示端还依赖该字段,因此短期内不能删除,同时需要兼容新的物料无 categories 字段
const categories = originCategories || (originCategory ? [originCategory] : []);
// category 字段:兼容老的物料无 category 字段
const category = originCategory || ((originCategories && originCategories[0]) ? originCategories[0] : '');

// details: ../utils/validate.js
const payload = {
name: materialConfig.name,
title: i18nData['zh-CN'].title || i18nData['en-US'].title,
description: i18nData['zh-CN'].description || i18nData['en-US'].description,
homepage: pkg.homepage || `${unpkgHost}/${npmName}@${pkg.version}/build/index.html`,
// TODO: 老物料展示依赖 categories,下个版本删除
categories: materialConfig.categories || [],
category: materialConfig.category,
categories,
category,
repository: (pkg.repository && pkg.repository.url) || pkg.repository,
source: {
type: 'npm',
Expand Down
2 changes: 1 addition & 1 deletion packages/ice-devtools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ice-devtools",
"version": "2.5.0",
"version": "2.5.1",
"description": "ice 物料开发者工具",
"main": "bin/ice-devtools.js",
"bin": {
Expand Down
4 changes: 4 additions & 0 deletions packages/ice-screenshot/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.2

- [feat] add timeout cli options

## 0.1.1

- [feat] Minify screenshot.
Expand Down
19 changes: 13 additions & 6 deletions packages/ice-screenshot/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const createServer = require('../utils/createServer');
const getPuppeteer = require('../utils/getPuppeteer');
const packageJSON = require('../package.json');

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

const cwd = process.cwd();
const DEFAULT_PORT = 8100;

Expand All @@ -26,10 +28,11 @@ async function exec() {
.option('-u, --url <url>', 'The target url or path to local server')
.option('-l, --local [local]', 'Set up a local server in [local] directory and take screenshot, defaults set up in `./`')
.option('-s, --selector <selector>', 'Select a element through CSS selector')
.option('-t, --timeout <timeout>', 'screenshot with a delay')
.option('-o, --output <output>', 'Output path')
.parse(process.argv);

const { url, selector, local } = program;
const { url, selector, local, timeout } = program;
const output = program.output || path.join(cwd, 'screenshot.png');

if (!url && !local) {
Expand All @@ -41,9 +44,9 @@ async function exec() {
if (local) {
const port = await detect(DEFAULT_PORT);
const serverPath = local === true ? cwd : local;
await screenshotWithLocalServer(serverPath, port, url, selector, output);
await screenshotWithLocalServer(serverPath, port, url, selector, output, timeout);
} else {
await screenshot(url, selector, output);
await screenshot(url, selector, output, timeout);
}
} catch (err) {
console.error(err);
Expand All @@ -60,7 +63,7 @@ async function exec() {
* @param {string} selector the target CSS selector
* @param {string} output output path
*/
async function screenshotWithLocalServer(serverPath, port, targetUrl, selector, output) {
async function screenshotWithLocalServer(serverPath, port, targetUrl, selector, output, timeout) {
targetUrl = targetUrl
? `http://127.0.0.1:${port}${targetUrl}`
: `http://127.0.0.1:${port}/build/index.html`; // default screenshot target
Expand All @@ -69,7 +72,7 @@ async function screenshotWithLocalServer(serverPath, port, targetUrl, selector,
console.log(chalk.white(`Create local server with port ${port}`));
console.log(chalk.white(`The screenshot target url: ${targetUrl}`));

await screenshot(targetUrl, selector, output);
await screenshot(targetUrl, selector, output, timeout);

server.close();
}
Expand All @@ -81,7 +84,7 @@ async function screenshotWithLocalServer(serverPath, port, targetUrl, selector,
* @param {string} selector screenshot target CSS selector
* @param {string} output output path
*/
async function screenshot(url, selector, output) {
async function screenshot(url, selector, output, timeout) {
// a terminal spinner
const spinner = ora('screenshoting ...').start();

Expand All @@ -104,6 +107,10 @@ async function screenshot(url, selector, output) {
// visit the target url
await page.goto(url);

if (timeout) {
await sleep(timeout);
}

// screenshot a element through CSS selector;
if (selector) {
const el = await page.$(selector);
Expand Down
2 changes: 1 addition & 1 deletion packages/ice-screenshot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/screenshot",
"version": "0.1.1",
"version": "0.1.3",
"description": "Take a screenshot of web page",
"main": "bin/index.js",
"bin": {
Expand Down

0 comments on commit 71695c4

Please sign in to comment.