commit 900b5d70637dd68035b4028700dcafbb2c8d2ff8 Author: niunai Date: Tue Dec 27 20:11:05 2016 +0800 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..4db9f4538 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.log* +.cache +.DS_Store +.idea +packages/**/lib +lib/* +!lib/index.js +!lib/style.css +node_modules +example/dist diff --git a/build/bin/build-all.js b/build/bin/build-all.js new file mode 100644 index 000000000..e1014ed74 --- /dev/null +++ b/build/bin/build-all.js @@ -0,0 +1,25 @@ +'use strict'; + +const components = require('../../components.json'); +const execSync = require('child_process').execSync; +const existsSync = require('fs').existsSync; +const path = require('path'); + +let componentPaths = []; + +delete components.font; + +Object.keys(components).forEach(key => { + const filePath = path.join(__dirname, `../../packages/${key}/cooking.conf.js`); + + if (existsSync(filePath)) { + componentPaths.push(`packages/${key}/cooking.conf.js`); + } +}); + +const paths = componentPaths.join(','); +const cli = `node_modules/.bin/cooking build -c ${paths} -p`; + +execSync(cli, { + stdio: 'inherit' +}); diff --git a/build/bin/build-entry.js b/build/bin/build-entry.js new file mode 100644 index 000000000..9cfc5dcb7 --- /dev/null +++ b/build/bin/build-entry.js @@ -0,0 +1,84 @@ +var Components = require('../../components.json'); +var fs = require('fs'); +var render = require('json-templater/string'); +var uppercamelcase = require('uppercamelcase'); +var path = require('path'); + +var OUTPUT_PATH = path.join(__dirname, '../../src/index.js'); +var IMPORT_TEMPLATE = 'import {{name}} from \'../packages/{{package}}/index.js\';'; +var ISNTALL_COMPONENT_TEMPLATE = ' Vue.component({{name}}.name, {{name}});'; +var MAIN_TEMPLATE = `{{include}} +import '../src/assets/font/iconfont.css'; + +const install = function(Vue) { + if (install.installed) return; + +{{install}} + Vue.use(InfiniteScroll); + Vue.use(Lazyload, { + loading: require('./assets/loading-spin.svg'), + try: 3 + }); + + Vue.$messagebox = Vue.prototype.$messagebox = MessageBox; + Vue.$toast = Vue.prototype.$toast = Toast; + Vue.$indicator = Vue.prototype.$indicator = Indicator; +}; + +// auto install +if (typeof window !== 'undefined' && window.Vue) { + install(window.Vue); +}; + +module.exports = { + install, + version: '{{version}}', +{{list}} +}; +`; + +delete Components.font; + +var ComponentNames = Object.keys(Components); + +var includeComponentTemplate = []; +var installTemplate = []; +var listTemplate = []; + +ComponentNames.forEach(name => { + var componentName = uppercamelcase(name); + + includeComponentTemplate.push(render(IMPORT_TEMPLATE, { + name: componentName, + package: name + })); + + if ([ + // directives + 'InfiniteScroll', + 'Lazyload', + + // services + 'MessageBox', + 'Toast', + 'Indicator' + ].indexOf(componentName) === -1) { + installTemplate.push(render(ISNTALL_COMPONENT_TEMPLATE, { + name: componentName, + component: name + })); + } + + listTemplate.push(` ${componentName}`); +}); + +var template = render(MAIN_TEMPLATE, { + include: includeComponentTemplate.join('\n'), + install: installTemplate.join('\n'), + version: process.env.VERSION || require('../../package.json').version, + list: listTemplate.join(',\n') +}); + +fs.writeFileSync(OUTPUT_PATH, template); +console.log('[build entry] DONE:', OUTPUT_PATH); + diff --git a/build/config.js b/build/config.js new file mode 100644 index 000000000..9133a90ae --- /dev/null +++ b/build/config.js @@ -0,0 +1,30 @@ +var Components = require('../components.json'); +var path = require('path'); +var dependencies = require('../package.json').dependencies; +var externals = {}; + +Object.keys(Components).forEach(function(key) { + externals[`oxygen/packages/${key}/index.js`] = `oxygen/lib/${key}`; + externals[`oxygen/packages/${key}/style.css`] = `oxygen/lib/${key}/style.css`; +}); +Object.keys(dependencies).forEach(function(key) { + externals[key] = key; +}); +exports.externals = Object.assign({ + vue: { + root: 'Vue', + commonjs: 'vue', + commonjs2: 'vue', + amd: 'vue' + } +}, externals); + +exports.alias = { + 'oxygen': path.join(__dirname, '..'), + 'src': path.join(__dirname, '../src') +}; + +exports.jsexclude = /node_modules|lib/; + +exports.extends = ['vue2', 'buble']; + diff --git a/build/release.sh b/build/release.sh new file mode 100644 index 000000000..ca8499955 --- /dev/null +++ b/build/release.sh @@ -0,0 +1,23 @@ +set -e +echo "[Mint UI for Vue 2.0]Enter release version: " +read VERSION + +read -p "Releasing $VERSION - are you sure? (y/n)" -n 1 -r +echo # (optional) move to a new line +if [[ $REPLY =~ ^[Yy]$ ]] +then + echo "Releasing $VERSION ..." + + # build + VERSION=$VERSION npm run dist + + # commit + git add -A + git commit -m "[build] $VERSION" + npm version $VERSION --message "[release] $VERSION" + + # publish + git push eleme refs/tags/v$VERSION + git push eleme master + npm publish +fi diff --git a/components.json b/components.json new file mode 100644 index 000000000..adec1b0b2 --- /dev/null +++ b/components.json @@ -0,0 +1,3 @@ +{ + "cell": "./packages/cell/index.js" +} diff --git a/lerna.json b/lerna.json new file mode 100644 index 000000000..69dc0d691 --- /dev/null +++ b/lerna.json @@ -0,0 +1,4 @@ +{ + "lerna": "2.0.0-beta.31", + "version": "independent" +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..9d60834e6 --- /dev/null +++ b/package.json @@ -0,0 +1,62 @@ +{ + "name": "oxygen", + "version": "0.0.1", + "description": "有赞vue wap组件库", + "main": "lib/oxygen.common.js", + "style": "lib/style.css", + "files": [ + "lib", + "src", + "packages" + ], + "scripts": { + "dev": "npm run bootstrap && npm run build:entry", + "bootstrap": "npm i", + "dist": "npm run clean && npm run build:entry", + "deploy": "npm run build:entry", + "build:entry": "node build/bin/build-entry", + "pub": "sh build/release.sh", + "pub:all": "node build/bin/build-all.js && lerna publish", + "clean": "rimraf lib && rimraf packages/*/lib" + }, + "repository": { + "type": "git", + "url": "git@gitlab.qima-inc.com:fe/oxygen.git" + }, + "keywords": [ + "youzan", + "vue" + ], + "author": "youzanfe", + "license": "ISC", + "dependencies": { + "array-find-index": "^1.0.2", + "raf.js": "0.0.4", + "wind-dom": "0.0.3" + }, + "devDependencies": { + "css-loader": "^0.25.0", + "extract-text-webpack-plugin": "^1.0.1", + "fastclick": "^1.0.6", + "file-loader": "^0.9.0", + "gh-pages": "^0.11.0", + "html-loader": "^0.4.3", + "html-webpack-plugin": "^2.22.0", + "json-loader": "^0.5.4", + "json-templater": "^1.0.4", + "lerna": "2.0.0-beta.31", + "my-local-ip": "^1.0.0", + "postcss": "^5.2.0", + "postcss-loader": "^0.13.0", + "rimraf": "^2.5.4", + "style-loader": "^0.13.1", + "uppercamelcase": "^1.1.0", + "url-loader": "^0.5.7", + "vue": "^2.1.7", + "vue-loader": "^9.5.3", + "vue-router": "^2.0.0", + "webpack": "^1.13.2", + "webpack-dev-server": "^1.15.1", + "webpack-shell-plugin": "^0.4.3" + } +} diff --git a/packages/cell/README.md b/packages/cell/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/packages/cell/cooking.conf.js b/packages/cell/cooking.conf.js new file mode 100644 index 000000000..c23f782c5 --- /dev/null +++ b/packages/cell/cooking.conf.js @@ -0,0 +1,19 @@ +var cooking = require('cooking'); +var path = require('path'); +var config = require('../../build/config'); + +cooking.set({ + entry: { + index: path.join(__dirname, 'index.js') + }, + dist: path.join(__dirname, 'lib'), + template: false, + format: 'umd', + moduleName: 'OxygenCell', + extractCSS: 'style.css', + extends: config.extends, + alias: config.alias, + externals: config.externals +}); + +module.exports = cooking.resolve(); diff --git a/packages/cell/index.js b/packages/cell/index.js new file mode 100644 index 000000000..895397c6f --- /dev/null +++ b/packages/cell/index.js @@ -0,0 +1,2 @@ +import Cell from './src/cell.vue'; +module.exports = Cell; diff --git a/packages/cell/package.json b/packages/cell/package.json new file mode 100644 index 000000000..c800e13c1 --- /dev/null +++ b/packages/cell/package.json @@ -0,0 +1,8 @@ +{ + "name": "oxygen-cell", + "description": "", + "version": "0.1.5", + "main": "lib/index.js", + "author": "elemefe", + "dependencies": {} +} diff --git a/packages/cell/src/cell.vue b/packages/cell/src/cell.vue new file mode 100644 index 000000000..24c3603d8 --- /dev/null +++ b/packages/cell/src/cell.vue @@ -0,0 +1,204 @@ + + + + + diff --git a/src/index.js b/src/index.js new file mode 100644 index 000000000..ea55d05e2 --- /dev/null +++ b/src/index.js @@ -0,0 +1,51 @@ +import Button from '../packages/button/index.js'; +import Cell from '../packages/cell/index.js'; +import Field from '../packages/field/index.js'; +import Popup from '../packages/popup/index.js'; +import Picker from '../packages/picker/index.js'; +import Toast from '../packages/toast/index.js'; +import Indicator from '../packages/indicator/index.js'; +import MessageBox from '../packages/message-box/index.js'; +import Lazyload from '../packages/lazyload/index.js'; +import Spinner from '../packages/spinner/index.js'; +import '../src/assets/font/iconfont.css'; + +const install = function(Vue) { + if (install.installed) return; + + Vue.component(Button.name, Button); + Vue.component(Cell.name, Cell); + Vue.component(Field.name, Field); + Vue.component(Popup.name, Popup); + Vue.component(Picker.name, Picker); + Vue.component(Spinner.name, Spinner); + Vue.use(InfiniteScroll); + Vue.use(Lazyload, { + loading: require('./assets/loading-spin.svg'), + try: 3 + }); + + Vue.$messagebox = Vue.prototype.$messagebox = MessageBox; + Vue.$toast = Vue.prototype.$toast = Toast; + Vue.$indicator = Vue.prototype.$indicator = Indicator; +}; + +// auto install +if (typeof window !== 'undefined' && window.Vue) { + install(window.Vue); +}; + +module.exports = { + install, + version: '1.0.0', + Button, + Cell, + Field, + Popup, + Picker, + Toast, + Indicator, + MessageBox, + Lazyload, + Spinner +}; diff --git a/src/style/empty.css b/src/style/empty.css new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/style/empty.css @@ -0,0 +1 @@ + diff --git a/src/style/var.css b/src/style/var.css new file mode 100644 index 000000000..bd285c933 --- /dev/null +++ b/src/style/var.css @@ -0,0 +1,10 @@ +/* UI标准色 */ +$o2-c-orange: #f60; +$o2-c-green: #06bf04; +$o2-c-red: #ed5050; +$o2-c-black: #333; +$o2-c-gray-darker: #666; +$o2-c-gray-dark: #999; +$o2-c-gray: #c9c9c9; +$o2-c-gray-light: #e5e5e5; +$o2-c-background: #f8f8f8;