-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release: ice-scripts/release-2.1.13 (#72)
* chore: changelog * feat: support stylus (#71) * feat: add ice-plugin-fusion-material (#69) * feat: add ice-plugin-fusion-material * feat: ice-plugin-fusion-materia ver_0.0.2 * feat: making ice-plugin-fusion-material plugin more easier to use * feat: make fusion-material plugin more easier to use * feat: fix lint problem * feat: add function to delete iframe tag in html * docs: update readme * docs: update package.json * chore: lock lerna version * chore: eslint rules * feat: support antd-mobile (#74) * feat: support stylus (#73) * feat(stylus): 添加stylus支持 * feat(stylus config): 全局配置选项和插件支持stylus * chore: changelog
- Loading branch information
Showing
21 changed files
with
323 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ module.exports = deepmerge(eslint, { | |
}, | ||
"rules": { | ||
"global-require": 1, | ||
"comma-dangle": 1 | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# Changelog | ||
|
||
## 0.1.5 | ||
|
||
- [feat] support libraryName | ||
|
||
## 0.1.3 | ||
|
||
- [fix] 兼容 options 为空 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# ice-plugin-fusion-material | ||
|
||
## 功能 | ||
|
||
本插件能够使用户运行`npm run build`时,自动生成区块或模板的截图与html文件,并保存于`build/views`文件夹下,同时在`package.json`中更新截图与html文件的路径地址。 | ||
|
||
## 使用方式 | ||
|
||
在`ice.config.js`中引入`ice-plugin-fusion-material`即可使用。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const screenShot = require('./utils/screenShot'); | ||
|
||
// Update package.json | ||
const updatePackageJson = (packageJsonPath, type, htmls, screenshots) => { | ||
const jsonData = fs.readFileSync(packageJsonPath, 'utf8'); | ||
const jsonObj = JSON.parse(jsonData); | ||
for (let i = 0; i < htmls.length; i++) { | ||
jsonObj[type].views[i].html = htmls[i]; | ||
jsonObj[type].views[i].screenshot = screenshots[i]; | ||
} | ||
fs.writeFileSync(packageJsonPath, JSON.stringify(jsonObj, null, ' ')); | ||
}; | ||
|
||
module.exports = ({ | ||
context, | ||
onHook, | ||
}) => { | ||
// after the build script finished | ||
onHook('afterBuild', () => { | ||
// get package.json and rootDir | ||
const { pkg, rootDir } = context; | ||
const packageJsonPath = path.join(rootDir, 'package.json'); | ||
const outputRootPath = path.join(rootDir, 'build', 'views'); | ||
fs.mkdirSync(outputRootPath); | ||
// get htmls and screenshots if blockConfig.views or scaffoldConfig.views exist | ||
const htmls = []; | ||
const screenshots = []; | ||
if (pkg.blockConfig && pkg.blockConfig.views) { | ||
// block type | ||
screenShot(rootDir, '/build/index.html', './build/views/block_view1.png', './build/views/block_view1.html', 2000); | ||
updatePackageJson(packageJsonPath, 'blockConfig', ['build/views/block_view1.html'], ['build/views/block_view1.png']); | ||
} | ||
else if (pkg.scaffoldConfig && pkg.scaffoldConfig.views) { | ||
// scaffold type | ||
for (let i = 0; i < pkg.scaffoldConfig.views.length; i++) { | ||
screenShot(rootDir, '/build/index.html', `./build/views/page${i}.png`, `./build/views/page${i}.html`, 2000, pkg.scaffoldConfig.views[i].path); | ||
htmls.push(`build/views/page${i}.html`); | ||
screenshots.push(`build/views/page${i}.png`); | ||
} | ||
updatePackageJson(packageJsonPath, 'scaffoldConfig', htmls, screenshots); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "ice-plugin-fusion-material", | ||
"version": "0.1.1", | ||
"description": "ice plugin fusion material", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "eslint --cache --ext .js,.jsx ./", | ||
"test": "echo \"test\"" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"puppeteer": "^2.0.0" | ||
}, | ||
"dependencies": { | ||
"chalk": "^2.4.2", | ||
"detect-port": "^1.3.0", | ||
"ora": "^4.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
const http = require('http'); | ||
const fs = require('fs'); | ||
const url = require('url'); | ||
const path = require('path'); | ||
const chalk = require('chalk'); | ||
|
||
module.exports = function (cwd, port) { | ||
const server = http | ||
.createServer((req, res) => { | ||
const pathname = cwd + url.parse(req.url).pathname; | ||
|
||
fs.exists(pathname, (exists) => { | ||
if (exists) { | ||
switch (path.extname(pathname)) { // set HTTP HEAD | ||
case '.html': | ||
res.writeHead(200, { 'Content-Type': 'text/html' }); | ||
break; | ||
case '.js': | ||
res.writeHead(200, { 'Content-Type': 'text/javascript' }); | ||
break; | ||
case '.css': | ||
res.writeHead(200, { 'Content-Type': 'text/css' }); | ||
break; | ||
case '.gif': | ||
res.writeHead(200, { 'Content-Type': 'image/gif' }); | ||
break; | ||
case '.jpg': | ||
res.writeHead(200, { 'Content-Type': 'image/jpeg' }); | ||
break; | ||
case '.png': | ||
res.writeHead(200, { 'Content-Type': 'image/png' }); | ||
break; | ||
default: | ||
res.writeHead(200, { | ||
'Content-Type': 'application/octet-stream', | ||
}); | ||
} | ||
fs.readFile(pathname, (_err, data) => { | ||
res.end(data); | ||
}); | ||
} else { | ||
res.writeHead(404, { 'Content-Type': 'text/html' }); | ||
res.end('<h1>404 Not Found</h1>'); | ||
console.log(chalk.yellow(`${pathname} Not Found.`)); | ||
} | ||
}); | ||
}) | ||
.listen(port, '127.0.0.1'); | ||
|
||
return server; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const spawn = require('cross-spawn'); | ||
const chalk = require('chalk'); | ||
|
||
function isNotFoundError(error = '') { | ||
return error.indexOf('Cannot find module') === 0; | ||
} | ||
|
||
/** | ||
* get Puppeteer(headless chromium) | ||
* | ||
* we don't want depend on puppeteer locally, | ||
* puppeteer takes a long to install | ||
* | ||
*/ | ||
module.exports = async function getPuppeteer() { | ||
try { | ||
// get Puppeteer from local node_modules | ||
// eslint-disable-next-line global-require | ||
return require('puppeteer'); | ||
} catch (error) { | ||
if (isNotFoundError(error.message)) { | ||
try { | ||
// get Puppeteer from global node_modules | ||
// eslint-disable-next-line global-require | ||
return require('import-global')('puppeteer'); | ||
} catch (importGlobalErr) { | ||
// if not found puppeteer from global node_modules | ||
// install it to global node_modules | ||
if (isNotFoundError(importGlobalErr.message)) { | ||
console.log(chalk.yellow('\n\nCannot find puppeteer in current environment.')); | ||
console.log(chalk.yellow('Installing globally puppeteer, please wait a moment.\n')); | ||
|
||
// set puppeteer download host | ||
// default download host has been blocking, use cnpm mirror | ||
// https://github.com/cnpm/cnpmjs.org/issues/1246#issuecomment-341631992 | ||
spawn.sync('npm', ['config', 'set', 'puppeteer_download_host=https://storage.googleapis.com.cnpmjs.org']); | ||
const result = spawn.sync('npm', ['install', '[email protected]', '-g', '--registry', 'https://registry.npm.taobao.org'], { stdio: 'inherit' }); | ||
spawn.sync('npm', ['config', 'delete', 'puppeteer_download_host']); | ||
|
||
// get spawn error, exit with code 1 | ||
if (result.error) { | ||
console.log(chalk.red('\n\nInstall Error. \nPlease install puppeteer using the following commands:')); | ||
console.log(chalk.white('\n npm uninstall puppeteer -g')); | ||
console.log(chalk.white('\n PUPPETEER_DOWNLOAD_HOST=https://storage.googleapis.com.cnpmjs.org npm i puppeteer -g --registry=https://registry.npm.taobao.org')); | ||
console.log(chalk.white('\n screenshot -u http://www.example.com\n')); | ||
process.exit(1); | ||
} | ||
|
||
console.log(chalk.green('\nPuppeteer installed.\n')); | ||
// eslint-disable-next-line global-require | ||
return require('import-global')('puppeteer'); | ||
} | ||
throw Error(importGlobalErr); | ||
} | ||
} | ||
throw Error(error); | ||
} | ||
}; |
Oops, something went wrong.