Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
bearyan committed Mar 12, 2020
0 parents commit f6520ea
Show file tree
Hide file tree
Showing 169 changed files with 404 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.DS_Store
node_modules

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
23 changes: 23 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
.cache

# local env files
.env.local
.env.*.local

build

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
49 changes: 49 additions & 0 deletions .picklogrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const pkg = require('./package');
const origin = pkg.repository.url;
const comparePath = `${origin}/compare/`;
const commitPath = `${origin}/commit/`;

module.exports = {
filters: [
{
name: 'Features',
regExp: /^(?:feat|add)/i,
},
{
name: 'Bugfixes',
regExp: /^fix/i,
},
],
parse(commits) {
// RegExp.prototype.toJSON = RegExp.prototype.toString; // JSON.stringify会调用正则表达式的toJSON
// return JSON.stringify(commits, null, 2); // output commits

let output = '';

commits.forEach(log => {
let date = new Date();
date = `${date.getFullYear()}-${('0' + (date.getMonth() + 1)).substr(
-2,
)}-${('0' + date.getDate()).substr(-2)}`;

let currentTag = log.tag || log.commits[0].h;
let prevTag = log.previousTag || log.commits[log.commits.length - 1].h;
output += `### [${currentTag}](${comparePath}${prevTag ||
''}...${currentTag}) (${date})\n\n`;

log.results.forEach(result => {
output += `#### ${result.filter.name}\n`;

result.commits.forEach(commit => {
output += `* ${commit.s}([${commit.h}](${commitPath}${commit.h}))\n`;
});

output += '\n';
});

output += '\n\n';
});

return output;
},
};
Empty file added CHANGELOG.md
Empty file.
72 changes: 72 additions & 0 deletions build/convert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const fs = require('fs');
const path = require('path');
const pkg = require('../package');
const srcDir = path.resolve('./src/assets');
const distDir = path.resolve('./dist/');
const rimraf = require('rimraf');
const svg2css = require('../src/libs/svg2css');
const cssHeaderText =
`/*!
* ${pkg.name} v${pkg.version} (${pkg.repository.url})
* Copyright ${new Date().getFullYear()} Tencent, Inc.
* Licensed under the ${pkg.license} license
*/
`;
const svgHeaderText =
`<!--
* ${pkg.name} v${pkg.version} (${pkg.repository.url})
* Copyright ${new Date().getFullYear()} Tencent, Inc.
* Licensed under the ${pkg.license} license
-->
`;

rimraf.sync(distDir);
fs.mkdirSync(distDir);

const ALL_FILE_NAME = 'weui-icon';

function writeFile(fileDirPath, fileName, content) {
const fileDir = path.resolve(distDir, fileDirPath);
if (!fs.existsSync(fileDir)) {
fs.mkdirSync(fileDir);
}

fs.appendFileSync(path.resolve(fileDir, fileName), '');
fs.writeFileSync(path.resolve(fileDir, fileName), content, 'utf-8');
}

// 根据assets的svg文件,生成对应的less文件
const svgDirs = fs.readdirSync(srcDir);
let convertMap = {};
let svgMap = {};
svgDirs.forEach(svgDir => {
const dirPath = path.resolve(srcDir, svgDir);
const svgFiles = fs.readdirSync(dirPath);
svgMap[svgDir] = {};

svgFiles.forEach(filePath => {
const fileName = path.basename(filePath, '.svg');
const svg = fs.readFileSync(path.resolve(dirPath, filePath), 'utf-8');
const singleContent = svg2css({
[`${svgDir}-${fileName}`]: svg,
});
convertMap[`${svgDir}-${fileName}`] = svg;

svgMap[svgDir][fileName] = svg;
writeFile(svgDir, `${fileName}.css`, `${cssHeaderText}${singleContent}`);
writeFile(svgDir, `${fileName}.svg`, `${svgHeaderText}${svg}`);
});
});

// 生成一个总的less文件
const allStyle = svg2css(convertMap);
writeFile('.', `${ALL_FILE_NAME}.css`, `${cssHeaderText}${allStyle}`);

// 生成一个map
writeFile(
'.',
`${ALL_FILE_NAME}.js`,
`${cssHeaderText}/* eslint-disable */\nmodule.exports = ${JSON.stringify(svgMap, null, 2)}`,
);
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "weui-icon",
"version": "0.0.0",
"main": "dist/weui-icon.css",
"dependencies": {
"rimraf": "^3.0.2",
"svgo": "^1.3.2"
},
"scripts": {
"convert": "svgo src/assets/* && node build/convert.js",
"build": "npm run convert",
"changelog": "picklog -lw CHANGELOG.md && git add -A .",
"version": "npm run build && npm run changelog",
"postversion": "git push && git push --tags && npm publish"
},
"repository": {
"type": "git",
"url": "https://github.com/weui/weui-icon"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/weui/weui-icon/issues"
}
}
1 change: 1 addition & 0 deletions src/assets/filled/add-friends.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/add2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/album.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/at.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/back2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/bellring_off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/bellring_on.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/camera.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/cellphone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/clip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/close2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/comment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/contacts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/delete_on.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/discover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/display.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/done.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/done2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/filled/email.svg
1 change: 1 addition & 0 deletions src/assets/filled/error.svg
1 change: 1 addition & 0 deletions src/assets/filled/eyes_off.svg
1 change: 1 addition & 0 deletions src/assets/filled/eyes_on.svg
1 change: 1 addition & 0 deletions src/assets/filled/folder.svg
1 change: 1 addition & 0 deletions src/assets/filled/group-detail.svg
1 change: 1 addition & 0 deletions src/assets/filled/help.svg
1 change: 1 addition & 0 deletions src/assets/filled/home.svg
1 change: 1 addition & 0 deletions src/assets/filled/imac.svg
1 change: 1 addition & 0 deletions src/assets/filled/info.svg
1 change: 1 addition & 0 deletions src/assets/filled/keyboard.svg
1 change: 1 addition & 0 deletions src/assets/filled/like.svg
1 change: 1 addition & 0 deletions src/assets/filled/link.svg
1 change: 1 addition & 0 deletions src/assets/filled/location.svg
1 change: 1 addition & 0 deletions src/assets/filled/lock.svg
1 change: 1 addition & 0 deletions src/assets/filled/max-window.svg
1 change: 1 addition & 0 deletions src/assets/filled/me.svg
Loading

0 comments on commit f6520ea

Please sign in to comment.