├── .npmignore ├── CNANGELOG.md ├── docs ├── DevOps │ ├── jenkins.md │ ├── deploy.md │ ├── README.md │ └── sentry.md ├── .vuepress │ ├── styles │ │ ├── palette.styl │ │ └── index.styl │ ├── dist │ │ ├── dev-x5.png │ │ ├── favicon.ico │ │ ├── dev-debug.png │ │ ├── sentry-bg.jpg │ │ ├── dev-inspect.png │ │ ├── assets │ │ │ └── img │ │ │ │ └── search.83621669.svg │ │ └── 404.html │ ├── public │ │ ├── logo.png │ │ ├── dev-x5.png │ │ ├── favicon.ico │ │ ├── logo-1.png │ │ ├── dev-debug.png │ │ ├── sentry-bg.jpg │ │ └── dev-inspect.png │ └── config.js ├── post │ ├── README.md │ ├── 4-css-grid.md │ ├── 1-sentry-source-analysis.md │ └── 3-axios-source-analysis.md ├── qa.md └── packages.md ├── packages └── @w6s │ ├── cli │ ├── .gitignore │ ├── README.md │ ├── templates │ │ ├── H5 │ │ │ ├── template.json │ │ │ └── template │ │ │ │ ├── .browserslistrc │ │ │ │ ├── src │ │ │ │ ├── styles │ │ │ │ │ └── index.scss │ │ │ │ ├── shims-vue.d.ts │ │ │ │ ├── assets │ │ │ │ │ └── logo.png │ │ │ │ ├── typings │ │ │ │ │ └── Common.ts │ │ │ │ ├── locales │ │ │ │ │ └── zh-CN.json │ │ │ │ ├── store │ │ │ │ │ ├── index.ts │ │ │ │ │ └── modules │ │ │ │ │ │ └── Counter.ts │ │ │ │ ├── api │ │ │ │ │ └── user.ts │ │ │ │ ├── shims-tsx.d.ts │ │ │ │ ├── utils │ │ │ │ │ ├── getEnvConfig.ts │ │ │ │ │ └── http │ │ │ │ │ │ └── https.ts │ │ │ │ ├── main.ts │ │ │ │ ├── views │ │ │ │ │ ├── Home.vue │ │ │ │ │ └── About.vue │ │ │ │ ├── router │ │ │ │ │ └── index.ts │ │ │ │ ├── App.vue │ │ │ │ ├── i18n.ts │ │ │ │ └── components │ │ │ │ │ └── HelloWorld.vue │ │ │ │ ├── DEPLOY.md │ │ │ │ ├── .eslintrc.js │ │ │ │ ├── stylelint.config.js │ │ │ │ ├── .env │ │ │ │ ├── commitlint.config.js │ │ │ │ ├── .env.development │ │ │ │ ├── .prettierrc.json │ │ │ │ ├── public │ │ │ │ ├── favicon.ico │ │ │ │ └── index.html │ │ │ │ ├── .editorconfig │ │ │ │ ├── README.md │ │ │ │ ├── babel.config.js │ │ │ │ ├── .gitignore │ │ │ │ ├── w6s.config.js │ │ │ │ ├── Jenkinsfile │ │ │ │ ├── tsconfig.json │ │ │ │ ├── package.json │ │ │ │ └── mock │ │ │ │ └── index.js │ │ └── admin │ │ │ ├── template.json │ │ │ └── template │ │ │ ├── .browserslistrc │ │ │ ├── .eslintrc.js │ │ │ ├── DEPLOY.md │ │ │ ├── src │ │ │ ├── locales │ │ │ │ └── zh-CN.json │ │ │ ├── shims-vue.d.ts │ │ │ ├── assets │ │ │ │ └── 404-images │ │ │ │ │ ├── 404.png │ │ │ │ │ └── 404-cloud.png │ │ │ ├── styles │ │ │ │ ├── _mixins.scss │ │ │ │ ├── _variables.scss.d.ts │ │ │ │ ├── _svgicon.scss │ │ │ │ ├── element-variables.scss │ │ │ │ ├── _variables.scss │ │ │ │ ├── _transition.scss │ │ │ │ └── index.scss │ │ │ ├── layout │ │ │ │ ├── components │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── Sidebar │ │ │ │ │ │ ├── SidebarItemLink.vue │ │ │ │ │ │ ├── index.vue │ │ │ │ │ │ └── SidebarItem.vue │ │ │ │ │ ├── AppMain.vue │ │ │ │ │ └── Navbar │ │ │ │ │ │ └── index.vue │ │ │ │ ├── mixin │ │ │ │ │ └── resize.ts │ │ │ │ └── index.vue │ │ │ ├── api │ │ │ │ └── user.ts │ │ │ ├── icons │ │ │ │ ├── components │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── user.ts │ │ │ │ │ ├── nested.ts │ │ │ │ │ ├── password.ts │ │ │ │ │ ├── hamburger.ts │ │ │ │ │ ├── eye-off.ts │ │ │ │ │ ├── eye-on.ts │ │ │ │ │ └── dashboard.ts │ │ │ │ ├── README.md │ │ │ │ └── svg │ │ │ │ │ ├── user.svg │ │ │ │ │ ├── nested.svg │ │ │ │ │ ├── password.svg │ │ │ │ │ ├── hamburger.svg │ │ │ │ │ ├── eye-off.svg │ │ │ │ │ ├── eye-on.svg │ │ │ │ │ └── dashboard.svg │ │ │ ├── App.vue │ │ │ ├── views │ │ │ │ ├── nested │ │ │ │ │ ├── menu2 │ │ │ │ │ │ └── index.vue │ │ │ │ │ └── menu1 │ │ │ │ │ │ ├── menu1-2 │ │ │ │ │ │ ├── menu1-2-1 │ │ │ │ │ │ │ └── index.vue │ │ │ │ │ │ ├── menu1-2-2 │ │ │ │ │ │ │ └── index.vue │ │ │ │ │ │ └── index.vue │ │ │ │ │ │ ├── menu1-1 │ │ │ │ │ │ └── index.vue │ │ │ │ │ │ └── index.vue │ │ │ │ ├── dashboard │ │ │ │ │ └── index.vue │ │ │ │ └── login │ │ │ │ │ └── index.vue │ │ │ ├── store │ │ │ │ ├── index.ts │ │ │ │ └── modules │ │ │ │ │ ├── user.ts │ │ │ │ │ └── app.ts │ │ │ ├── utils │ │ │ │ ├── getEnvConfig.ts │ │ │ │ ├── cookies.ts │ │ │ │ └── request.ts │ │ │ ├── components │ │ │ │ ├── Hamburger │ │ │ │ │ └── index.vue │ │ │ │ └── Breadcrumb │ │ │ │ │ └── index.vue │ │ │ ├── permission.ts │ │ │ ├── main.ts │ │ │ ├── i18n.ts │ │ │ └── router.ts │ │ │ ├── .env │ │ │ ├── commitlint.config.js │ │ │ ├── .env.development │ │ │ ├── .prettierrc.json │ │ │ ├── public │ │ │ ├── favicon.ico │ │ │ └── index.html │ │ │ ├── stylelint.config.js │ │ │ ├── .editorconfig │ │ │ ├── mock │ │ │ └── index.js │ │ │ ├── README.md │ │ │ ├── babel.config.js │ │ │ ├── .gitignore │ │ │ ├── tsconfig.json │ │ │ ├── w6s.config.js │ │ │ ├── Jenkinsfile │ │ │ └── package.json │ ├── bin │ │ ├── w6s-qrcode │ │ ├── w6s-serve │ │ ├── w6s-deploy │ │ ├── w6s │ │ ├── w6s-set-mirror │ │ └── w6s-init │ ├── lib │ │ ├── prompt.js │ │ ├── get-last-version.js │ │ ├── git-user.js │ │ ├── logCompleteMsg.js │ │ ├── mirror.js │ │ ├── clone.js │ │ ├── executeCommand.js │ │ └── generate.js │ └── package.json │ ├── mock-plugin │ ├── README.md │ ├── babel.config.js │ ├── lib │ │ ├── default.config.js │ │ ├── watcher.js │ │ └── mockMiddleware.js │ ├── package.json │ └── index.js │ ├── cli-script │ ├── .gitignore │ ├── README.md │ ├── bin │ │ └── cli-script.js │ ├── lib │ │ ├── utils.js │ │ └── index.js │ └── package.json │ ├── vconsole-plugin │ ├── README.md │ ├── package.json │ └── index.js │ ├── cli-deploy │ ├── .prettierrc │ ├── README.md │ ├── lib │ │ ├── log.js │ │ └── deploy.js │ ├── bin │ │ └── index.js │ ├── package.json │ └── template │ │ └── deploy.config.js │ ├── style-resources-loader-plugin │ ├── README.md │ ├── package.json │ └── index.js │ ├── sentry-plugin │ ├── README.md │ ├── package.json │ ├── index.js │ └── utils.js │ ├── create-file-plugin │ ├── README.md │ ├── package.json │ └── index.js │ ├── stylelint-plugin │ ├── index.js │ ├── package.json │ └── README.md │ └── cli-shared-utils │ ├── package.json │ ├── index.js │ └── lib │ ├── pkg.js │ ├── checkNodeVersion.js │ ├── env.js │ └── logger.js ├── .eslintignore ├── .editorconfig ├── .travis.yml ├── .eslintrc.js ├── scripts ├── deploy.sh └── verifyCommitMsg.js ├── lerna.json ├── .gitignore ├── README.md ├── LICENSE ├── package.json └── .github └── COMMIT_CONVENTION.md /.npmignore: -------------------------------------------------------------------------------- 1 | demos -------------------------------------------------------------------------------- /CNANGELOG.md: -------------------------------------------------------------------------------- 1 | ### v2.0.0 2 | -------------------------------------------------------------------------------- /docs/DevOps/jenkins.md: -------------------------------------------------------------------------------- 1 | # Jenkins -------------------------------------------------------------------------------- /packages/@w6s/cli/.gitignore: -------------------------------------------------------------------------------- 1 | /demo -------------------------------------------------------------------------------- /packages/@w6s/mock-plugin/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/@w6s/cli-script/.gitignore: -------------------------------------------------------------------------------- 1 | /demo -------------------------------------------------------------------------------- /packages/@w6s/cli/README.md: -------------------------------------------------------------------------------- 1 | ### @w6s/cli 2 | -------------------------------------------------------------------------------- /packages/@w6s/cli-script/README.md: -------------------------------------------------------------------------------- 1 | ### @w6s/cli-script -------------------------------------------------------------------------------- /packages/@w6s/vconsole-plugin/README.md: -------------------------------------------------------------------------------- 1 | ## vconsole -------------------------------------------------------------------------------- /packages/@w6s/cli-deploy/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120 3 | } 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "bash": ["yarn", "yarn serve"] 3 | } -------------------------------------------------------------------------------- /packages/@w6s/style-resources-loader-plugin/README.md: -------------------------------------------------------------------------------- 1 | ## style-resources-loader-plugin -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "bash": ["yarn", "yarn serve"] 3 | } -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | template 3 | temp 4 | entry-wc.js 5 | dist 6 | __testfixtures__ 7 | -------------------------------------------------------------------------------- /docs/.vuepress/styles/palette.styl: -------------------------------------------------------------------------------- 1 | $accentColor = #279AFC 2 | $accentDarkColor = $accentColor 3 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/styles/index.scss: -------------------------------------------------------------------------------- 1 | // stylelint no-empty-source: 0 2 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /docs/.vuepress/dist/dev-x5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/dist/dev-x5.png -------------------------------------------------------------------------------- /docs/.vuepress/dist/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/dist/favicon.ico -------------------------------------------------------------------------------- /docs/.vuepress/public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/public/logo.png -------------------------------------------------------------------------------- /docs/.vuepress/styles/index.styl: -------------------------------------------------------------------------------- 1 | ::-webkit-scrollbar-thumb { 2 | width 0 3 | height 0 4 | display none 5 | } -------------------------------------------------------------------------------- /packages/@w6s/mock-plugin/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "presets": ["@babel/preset-env"] 3 | }; 4 | -------------------------------------------------------------------------------- /docs/.vuepress/dist/dev-debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/dist/dev-debug.png -------------------------------------------------------------------------------- /docs/.vuepress/dist/sentry-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/dist/sentry-bg.jpg -------------------------------------------------------------------------------- /docs/.vuepress/public/dev-x5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/public/dev-x5.png -------------------------------------------------------------------------------- /docs/.vuepress/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/public/favicon.ico -------------------------------------------------------------------------------- /docs/.vuepress/public/logo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/public/logo-1.png -------------------------------------------------------------------------------- /packages/@w6s/sentry-plugin/README.md: -------------------------------------------------------------------------------- 1 | ## sentry-plugin 2 | 3 | [在线文档](https://open.workplus.io/w6s-cli/sentry.html) -------------------------------------------------------------------------------- /docs/.vuepress/dist/dev-inspect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/dist/dev-inspect.png -------------------------------------------------------------------------------- /docs/.vuepress/public/dev-debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/public/dev-debug.png -------------------------------------------------------------------------------- /docs/.vuepress/public/sentry-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/public/sentry-bg.jpg -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/DEPLOY.md: -------------------------------------------------------------------------------- 1 | # 项目配置说明 2 | 3 | 4 | 5 | - VUE_APP_BASE_API 应用的接口访问地址 -------------------------------------------------------------------------------- /docs/.vuepress/public/dev-inspect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/docs/.vuepress/public/dev-inspect.png -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ['@w6s'], 4 | }; 5 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ['@w6s'], 4 | }; 5 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/DEPLOY.md: -------------------------------------------------------------------------------- 1 | # 项目配置说明 2 | 3 | 4 | 5 | - VUE_APP_BASE_API 应用的接口访问地址 -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/locales/zh-CN.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": { 3 | "title": "@w6s/admin" 4 | } 5 | } -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/stylelint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@w6s/stylelint-config'], 3 | }; 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/.env: -------------------------------------------------------------------------------- 1 | VUE_APP_BASE_API=/ 2 | VUE_APP_I18N_LOCALE=zh-CN 3 | VUE_APP_I18N_FALLBACK_LOCALE=zh-CN 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | }; 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/.env: -------------------------------------------------------------------------------- 1 | VUE_APP_BASE_API=/ 2 | VUE_APP_I18N_LOCALE=zh-CN 3 | VUE_APP_I18N_FALLBACK_LOCALE=zh-CN 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/.env.development: -------------------------------------------------------------------------------- 1 | VUE_APP_BASE_API=/ 2 | VUE_APP_I18N_LOCALE=zh-CN 3 | VUE_APP_I18N_FALLBACK_LOCALE=zh-CN 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | }; 4 | -------------------------------------------------------------------------------- /packages/@w6s/create-file-plugin/README.md: -------------------------------------------------------------------------------- 1 | # @w6s/create-file-plugin 2 | 3 | [点击查看详细文档](https://open.workplus.io/dev/start/plugin.html#create-file) -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all", 4 | "printWidth": 100 5 | } 6 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import Vue from 'vue'; 3 | 4 | export default Vue; 5 | } 6 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/.env.development: -------------------------------------------------------------------------------- 1 | VUE_APP_BASE_API=/ 2 | VUE_APP_I18N_LOCALE=zh-CN 3 | VUE_APP_I18N_FALLBACK_LOCALE=zh-CN 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all", 4 | "printWidth": 80 5 | } 6 | -------------------------------------------------------------------------------- /packages/@w6s/stylelint-plugin/index.js: -------------------------------------------------------------------------------- 1 | const styleLintPlugin = require('@w6s/vue-cli-plugin-stylelint'); 2 | 3 | module.exports = styleLintPlugin; 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import Vue from 'vue'; 3 | 4 | export default Vue; 5 | } 6 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/packages/@w6s/cli/templates/H5/template/public/favicon.ico -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/packages/@w6s/cli/templates/H5/template/src/assets/logo.png -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = false 8 | insert_final_newline = false -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/typings/Common.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | namespace Common { 3 | export type PlainObject = { [name: string]: any }; 4 | } 5 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/packages/@w6s/cli/templates/admin/template/public/favicon.ico -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/stylelint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@w6s/stylelint-config'], 3 | rules: { 4 | 'max-nesting-depth': 4, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/locales/zh-CN.json: -------------------------------------------------------------------------------- 1 | { 2 | "message": { 3 | "title": "Hello @w6s/cli", 4 | "description": "A CLI for scaffolding starter projects." 5 | } 6 | } -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/assets/404-images/404.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/packages/@w6s/cli/templates/admin/template/src/assets/404-images/404.png -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/store/index.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Vuex from 'vuex'; 3 | 4 | Vue.use(Vuex); 5 | 6 | export default new Vuex.Store({ 7 | state: {}, 8 | }); 9 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/assets/404-images/404-cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorkPlusFE/cli/HEAD/packages/@w6s/cli/templates/admin/template/src/assets/404-images/404-cloud.png -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/styles/_mixins.scss: -------------------------------------------------------------------------------- 1 | /* stylelint-disable at-rule-no-unknown */ 2 | @mixin clearfix { 3 | &::after { 4 | content: ''; 5 | display: table; 6 | clear: both; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{js,jsx,ts,tsx,vue}] 2 | indent_style = space 3 | indent_size = 2 4 | end_of_line = lf 5 | trim_trailing_whitespace = true 6 | insert_final_newline = true 7 | max_line_length = 100 8 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{js,jsx,ts,tsx,vue}] 2 | indent_style = space 3 | indent_size = 2 4 | end_of_line = lf 5 | trim_trailing_whitespace = true 6 | insert_final_newline = true 7 | max_line_length = 100 8 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/mock/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'POST /user/login': function (req, res) { 3 | return res.json({ 4 | code: 20000, 5 | data: { token: 'admin-token' }, 6 | }); 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /packages/@w6s/mock-plugin/lib/default.config.js: -------------------------------------------------------------------------------- 1 | const defaultConfig = { 2 | entry: 'mock/index.js', 3 | mockDir: 'mock', 4 | prefix: '/mock', 5 | 6 | disable: false, 7 | log: true, 8 | }; 9 | 10 | module.exports = defaultConfig; -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/api/user.ts: -------------------------------------------------------------------------------- 1 | import { apiGet } from '@/utils/http/https'; 2 | 3 | export const getUserDetail = () => apiGet('/mock/api/user'); 4 | export const getUsers = () => apiGet('/mock/api/list?limit=20&skip=0'); 5 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/layout/components/index.ts: -------------------------------------------------------------------------------- 1 | export { default as AppMain } from './AppMain.vue'; 2 | export { default as Navbar } from './Navbar/index.vue'; 3 | export { default as Sidebar } from './Sidebar/index.vue'; 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/api/user.ts: -------------------------------------------------------------------------------- 1 | import request from '@/utils/request'; 2 | 3 | export function login(data: any) { 4 | return request({ 5 | url: '/user/login', 6 | method: 'post', 7 | data, 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/components/index.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | import './dashboard'; 3 | import './eye-off'; 4 | import './eye-on'; 5 | import './hamburger'; 6 | import './nested'; 7 | import './password'; 8 | import './user'; 9 | -------------------------------------------------------------------------------- /docs/.vuepress/dist/assets/img/search.83621669.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /packages/@w6s/cli-deploy/README.md: -------------------------------------------------------------------------------- 1 | ## @w6s/cli-deploy 2 | 3 | [![npm version](https://badge.fury.io/js/%40w6s%2Fcli-deploy.svg)](https://badge.fury.io/js/%40w6s%2Fcli-deploy) 4 | 5 | [查看详细使用文档](https://open.workplus.io/dev/DevOps/deploy.html) 6 | 7 | ### license 8 | 9 | MIT -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/styles/_variables.scss.d.ts: -------------------------------------------------------------------------------- 1 | export interface ScssVariables { 2 | menuBg: string; 3 | menuText: string; 4 | menuActiveText: string; 5 | } 6 | 7 | export const variables: ScssVariables; 8 | 9 | export default variables; 10 | -------------------------------------------------------------------------------- /packages/@w6s/cli/bin/w6s-qrcode: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const execa = require('execa'); 4 | 5 | const binPath = require.resolve('qrcode/bin/qrcode'); 6 | const argv = process.argv.slice(2); 7 | 8 | execa( 9 | binPath, 10 | argv, 11 | { stdio: 'inherit' } 12 | ); 13 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/README.md: -------------------------------------------------------------------------------- 1 | # vue-svgicon 2 | 3 | * 所有的 svg 组件都是由 `vue-svgicon` 生成的 4 | * 每当在 `icons/svg` 文件夹内添加 icon 之后,可以通过执行 `yarn svg` 来重新生成所有组件 (在此之前需要全局安装 `vue-svgicon` 或使用 `npx`) 5 | * 详细文档请见:[https://github.com/MMF-FE/vue-svgicon](https://github.com/MMF-FE/vue-svgicon) 6 | -------------------------------------------------------------------------------- /packages/@w6s/vconsole-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w6s/vconsole-plugin", 3 | "version": "1.2.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "publishConfig": { 7 | "access": "public" 8 | }, 9 | "dependencies": { 10 | "vconsole-webpack-plugin": "^1.5.1" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/README.md: -------------------------------------------------------------------------------- 1 | # <%= name %> 2 | 3 | > <%= description %> 4 | 5 | ## 快速开始 6 | 7 | ```bash 8 | # 安装依赖 9 | yarn 10 | 11 | # 运行项目 12 | yarn dev 13 | 14 | # 项目打包 15 | yarn build 16 | ``` 17 | 18 | 更多使用说明,请查看[WorkPlusFE 开发手册](https://open.workplus.io/dev/start/)。 19 | 20 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/README.md: -------------------------------------------------------------------------------- 1 | # <%= name %> 2 | 3 | > <%= description %> 4 | 5 | ## 快速开始 6 | 7 | ```bash 8 | # 安装依赖 9 | yarn 10 | 11 | # 运行项目 12 | yarn dev 13 | 14 | # 项目打包 15 | yarn build 16 | ``` 17 | 18 | 更多使用说明,请查看[WorkPlusFE 开发手册](https://open.workplus.io/dev/start/)。 19 | 20 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['@vue/cli-plugin-babel/preset'], 3 | plugins: [ 4 | [ 5 | 'component', 6 | { 7 | libraryName: 'element-ui', 8 | styleLibraryName: 'theme-chalk', 9 | }, 10 | ], 11 | ], 12 | }; 13 | -------------------------------------------------------------------------------- /packages/@w6s/style-resources-loader-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w6s/style-resources-loader-plugin", 3 | "version": "1.2.0", 4 | "main": "index.js", 5 | "publishConfig": { 6 | "access": "public" 7 | }, 8 | "license": "MIT", 9 | "dependencies": { 10 | "style-resources-loader": "^1.3.3" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['@vue/cli-plugin-babel/preset'], 3 | plugins: [ 4 | [ 5 | 'import', 6 | { 7 | libraryName: 'vant', 8 | libraryDirectory: 'es', 9 | style: true, 10 | }, 11 | 'vant', 12 | ], 13 | ], 14 | }; 15 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | -------------------------------------------------------------------------------- /packages/@w6s/cli/bin/w6s-serve: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const execa = require('execa'); 4 | 5 | const binPath = require.resolve('serve/bin/serve.js'); 6 | 7 | let serveArgv = process.argv.slice(2); 8 | if (serveArgv.length === 0) serveArgv = ['./']; 9 | 10 | execa( 11 | binPath, 12 | serveArgv, 13 | { stdio: 'inherit' } 14 | ); 15 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /packages/@w6s/cli-deploy/lib/log.js: -------------------------------------------------------------------------------- 1 | const ora = require("ora"); 2 | const chalk = require("chalk"); 3 | 4 | function successLog(message) { 5 | ora().succeed(chalk.greenBright.bold(message)); 6 | } 7 | 8 | function errorLog(message) { 9 | ora().fail(chalk.redBright.bold(message)); 10 | } 11 | 12 | module.exports = { 13 | successLog, 14 | errorLog 15 | }; 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - lts/* 4 | install: 5 | - yarn 6 | script: 7 | - yarn docs:build 8 | deploy: 9 | provider: pages 10 | skip_cleanup: true 11 | local_dir: docs/.vuepress/dist 12 | github_token: $GITHUB_TOKEN # 在 GitHub 中生成,用于允许 Travis 向你的仓库推送代码。在 Travis 的项目设置页面进行配置,设置为 secure variable 13 | keep_history: true 14 | on: 15 | branch: master -------------------------------------------------------------------------------- /packages/@w6s/cli/bin/w6s-deploy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const execa = require('execa'); 4 | 5 | const binPath = require.resolve('@w6s/cli-deploy/bin/index.js'); 6 | const argv = process.argv.slice(2); 7 | 8 | if (argv.length > 0 && argv[0] === '--env') { 9 | argv.unshift('deploy'); 10 | } 11 | 12 | execa( 13 | binPath, 14 | argv, 15 | { stdio: 'inherit' } 16 | ); 17 | -------------------------------------------------------------------------------- /packages/@w6s/cli/lib/prompt.js: -------------------------------------------------------------------------------- 1 | const inquirer = require('inquirer'); 2 | 3 | function consolePrompt(message, choices) { 4 | const question = { 5 | message, 6 | choices, 7 | type: 'list', 8 | name: 'answer', 9 | }; 10 | return inquirer 11 | .prompt([ question ]) 12 | .then(({ answer }) => answer); 13 | }; 14 | 15 | module.exports = consolePrompt; 16 | -------------------------------------------------------------------------------- /packages/@w6s/stylelint-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w6s/stylelint-plugin", 3 | "version": "1.2.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "publishConfig": { 7 | "access": "public" 8 | }, 9 | "dependencies": { 10 | "@w6s/vue-cli-plugin-stylelint": "^1.0.0" 11 | }, 12 | "peerDependencies": { 13 | "stylelint": "^13.10.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/views/nested/menu2/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/svg/user.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/@w6s/vconsole-plugin/index.js: -------------------------------------------------------------------------------- 1 | const VConsolePlugin = require('vconsole-webpack-plugin'); 2 | 3 | module.exports = (api, projectOptions) => { 4 | const vconsole = projectOptions.pluginOptions.vconsole || {}; 5 | 6 | api.configureWebpack((webpackConfig) => { 7 | webpackConfig.plugins.push(new VConsolePlugin({ 8 | enable: false, 9 | ...vconsole, 10 | })); 11 | }); 12 | }; 13 | -------------------------------------------------------------------------------- /packages/@w6s/cli-shared-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w6s/cli-shared-utils", 3 | "publishConfig": { 4 | "access": "public" 5 | }, 6 | "version": "1.2.2", 7 | "main": "index.js", 8 | "license": "MIT", 9 | "author": "WorkPlusFE", 10 | "dependencies": { 11 | "chalk": "^4.0.0", 12 | "read-pkg": "^5.2.0", 13 | "readline": "^1.3.0", 14 | "semver": "^7.3.2", 15 | "strip-ansi": "^6.0.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/views/nested/menu1/menu1-2/menu1-2-1/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/views/nested/menu1/menu1-2/menu1-2-2/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/store/index.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Vuex from 'vuex'; 3 | import { AppState } from './modules/app'; 4 | import { UserState } from './modules/user'; 5 | 6 | Vue.use(Vuex); 7 | 8 | export interface RootState { 9 | app: AppState; 10 | user: UserState; 11 | } 12 | 13 | // Declare empty store first, dynamically register all modules later. 14 | export default new Vuex.Store({}); 15 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/shims-tsx.d.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/no-unused-vars 2 | import Vue, { VNode } from 'vue'; 3 | 4 | declare global { 5 | namespace JSX { 6 | // tslint:disable no-empty-interface 7 | type Element = VNode; 8 | // tslint:disable no-empty-interface 9 | type ElementClass = Vue; 10 | interface IntrinsicElements { 11 | [elem: string]: any; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/@w6s/sentry-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w6s/sentry-plugin", 3 | "version": "1.2.2", 4 | "main": "index.js", 5 | "publishConfig": { 6 | "access": "public" 7 | }, 8 | "license": "MIT", 9 | "dependencies": { 10 | "@w6s/cli-shared-utils": "^1.2.2", 11 | "colors": "^1.4.0", 12 | "execa": "^4.0.1", 13 | "uuid": "^8.0.0", 14 | "webpack": "^4.43.0", 15 | "webpack-sentry-plugin": "^2.0.3" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | 'airbnb-base', 4 | 'prettier' 5 | ], 6 | plugins: [ 7 | "node" 8 | ], 9 | env: { 10 | "jest": true 11 | }, 12 | globals: { 13 | name: 'off' 14 | }, 15 | rules: { 16 | "no-console": 0, 17 | "no-shadow": 0, 18 | "no-underscore-dangle": 0, 19 | "no-restricted-syntax": 0, 20 | "no-unused-vars": ["error", { "argsIgnorePattern": "colors" }], 21 | }, 22 | } 23 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/layout/components/Sidebar/SidebarItemLink.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 17 | -------------------------------------------------------------------------------- /packages/@w6s/cli-shared-utils/index.js: -------------------------------------------------------------------------------- 1 | const { checkNodeVersion } = require('./lib/checkNodeVersion'); 2 | const { hasYarn, isWindows, isLinux, isMac, isProd } = require('./lib/env'); 3 | const logger = require('./lib/logger'); 4 | const { resolvePkg, isPlugin } = require('./lib/pkg'); 5 | 6 | module.exports = { 7 | checkNodeVersion, 8 | hasYarn, 9 | isWindows, 10 | isLinux, 11 | isMac, 12 | logger, 13 | resolvePkg, 14 | isPlugin, 15 | isProd, 16 | }; -------------------------------------------------------------------------------- /packages/@w6s/cli/lib/get-last-version.js: -------------------------------------------------------------------------------- 1 | const latestVersion = require('latest-version'); 2 | 3 | async function getCliScriptLastVersion() { 4 | const version = await latestVersion('@w6s/cli-script'); 5 | return version; 6 | }; 7 | 8 | async function getJsSdkLastVersion() { 9 | const version = await latestVersion('@w6s/sdk'); 10 | return version; 11 | }; 12 | 13 | module.exports = { 14 | getCliScriptLastVersion, 15 | getJsSdkLastVersion, 16 | }; 17 | -------------------------------------------------------------------------------- /packages/@w6s/cli-shared-utils/lib/pkg.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | const readPkg = require('read-pkg'); 4 | 5 | const pluginRE = /^(@vue\/|vue-|@[\w-]+(\.)?[\w-]+\/vue-)cli-plugin-/; 6 | 7 | exports.resolvePkg = function (context) { 8 | if (fs.existsSync(path.join(context, 'package.json'))) { 9 | return readPkg.sync({ cwd: context }); 10 | } 11 | return {}; 12 | }; 13 | 14 | exports.isPlugin = id => pluginRE.test(id); 15 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/views/nested/menu1/menu1-1/index.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 17 | -------------------------------------------------------------------------------- /packages/@w6s/create-file-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w6s/create-file-plugin", 3 | "version": "1.1.4", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "publishConfig": { 7 | "access": "public" 8 | }, 9 | "dependencies": { 10 | "@w6s/cli-shared-utils": "^1.2.2", 11 | "copy-webpack-plugin": "5.1.1", 12 | "create-file-webpack": "^1.0.2", 13 | "git-revision-webpack-plugin": "^3.0.6", 14 | "is-git-repository": "^2.0.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/utils/getEnvConfig.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | export default (): Promise => { 4 | if (process.env.NODE_ENV === 'production') { 5 | return new Promise((resolve) => { 6 | axios.get('config.json').then(({ data }) => { 7 | resolve(data.VUE_APP_BASE_API); 8 | }); 9 | }); 10 | } 11 | return new Promise((resolve) => { 12 | resolve(process.env.VUE_APP_BASE_API as string); 13 | }); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/utils/getEnvConfig.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | export default (): Promise => { 4 | if (process.env.NODE_ENV === 'production') { 5 | return new Promise((resolve) => { 6 | axios.get('config.json').then(({ data }) => { 7 | resolve(data.VUE_APP_BASE_API); 8 | }); 9 | }); 10 | } 11 | return new Promise((resolve) => { 12 | resolve(process.env.VUE_APP_BASE_API as string); 13 | }); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/@w6s/cli/lib/git-user.js: -------------------------------------------------------------------------------- 1 | const exec = require('child_process').execSync; 2 | 3 | module.exports = function gitUser() { 4 | let name; let email; 5 | 6 | try { 7 | name = exec('git config --get user.name') 8 | email = exec('git config --get user.email') 9 | } catch (err) { 10 | console.log(err); 11 | } 12 | 13 | name = name && name.toString().trim() 14 | email = email && (` <${ email.toString().trim() }>`) 15 | return (name || '') + (email || '') 16 | }; 17 | -------------------------------------------------------------------------------- /packages/@w6s/cli-shared-utils/lib/checkNodeVersion.js: -------------------------------------------------------------------------------- 1 | const semver = require('semver'); 2 | const logger = require('./logger'); 3 | 4 | function checkNodeVersion (wanted) { 5 | if (!semver.satisfies(process.version, wanted)) { 6 | logger.error( 7 | `You are using Node ${process.version}, but @w6s/cli-script ` + 8 | `requires Node ${wanted}.\nPlease upgrade your Node version.` 9 | ) 10 | process.exit(1) 11 | } 12 | } 13 | 14 | module.exports = { 15 | checkNodeVersion, 16 | }; 17 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/views/nested/menu1/index.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 19 | -------------------------------------------------------------------------------- /scripts/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 确保脚本抛出遇到的错误 4 | set -e 5 | 6 | # 生成静态文件 7 | yarn docs:build 8 | 9 | # 进入生成的文件夹 10 | cd docs/.vuepress/dist 11 | 12 | # 如果是发布到自定义域名 13 | # echo 'www.example.com' > CNAME 14 | 15 | git init 16 | git add -A 17 | git commit -m 'deploy' 18 | 19 | # 如果发布到 https://.github.io 20 | # git push -f git@github.com:/.github.io.git master 21 | 22 | # 如果发布到 https://.github.io/ 23 | git push -f git@github.com:WorkPlusFE/w6s-cli.git master:gh-pages 24 | 25 | cd - -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/views/dashboard/index.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 13 | 14 | 26 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/svg/nested.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/svg/password.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/layout/components/AppMain.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 17 | 18 | 23 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/views/nested/menu1/menu1-2/index.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 19 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/main.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import getEnvConfig from '@/utils/getEnvConfig'; 3 | import service from '@/utils/http/https'; 4 | 5 | import i18n from './i18n'; 6 | import App from './App.vue'; 7 | import router from './router'; 8 | import store from './store'; 9 | 10 | Vue.config.productionTip = false; 11 | 12 | getEnvConfig().then((baseUrl) => { 13 | service.defaults.baseURL = baseUrl; 14 | new Vue({ 15 | router, 16 | store, 17 | i18n, 18 | render: (h) => h(App), 19 | }).$mount('#app'); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/components/user.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | /* tslint:disable */ 3 | // @ts-ignore 4 | import icon from 'vue-svgicon'; 5 | icon.register({ 6 | user: { 7 | width: 130, 8 | height: 130, 9 | viewBox: '0 0 130 130', 10 | data: 11 | '', 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/svg/hamburger.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/utils/cookies.ts: -------------------------------------------------------------------------------- 1 | import Cookies from 'js-cookie'; 2 | 3 | // App 4 | const sidebarStatusKey = 'sidebar_status'; 5 | export const getSidebarStatus = () => Cookies.get(sidebarStatusKey); 6 | export const setSidebarStatus = (sidebarStatus: string) => 7 | Cookies.set(sidebarStatusKey, sidebarStatus); 8 | 9 | // User 10 | const tokenKey = 'v_admin_token'; 11 | export const getToken = () => Cookies.get(tokenKey); 12 | export const setToken = (token: string) => Cookies.set(tokenKey, token); 13 | export const removeToken = () => Cookies.remove(tokenKey); 14 | -------------------------------------------------------------------------------- /packages/@w6s/cli-deploy/bin/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const program = require("commander"); 4 | const Deploy = require("../lib/deploy"); 5 | const packageInfo = require("../package.json"); 6 | 7 | const deploy = new Deploy(); 8 | 9 | program.version(packageInfo.version); 10 | 11 | program 12 | .command("init") 13 | .description("初始化配置文件") 14 | .action(() => deploy.initConfigFile()); 15 | 16 | program 17 | .command("deploy") 18 | .option("--env ") 19 | .description("执行部署操作") 20 | .action((option) => deploy.start(option.env)); 21 | 22 | program.parse(program.argv); 23 | -------------------------------------------------------------------------------- /packages/@w6s/mock-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w6s/mock-plugin", 3 | "version": "1.2.2", 4 | "publishConfig": { 5 | "access": "public" 6 | }, 7 | "main": "index.js", 8 | "author": "WorkPlusFE", 9 | "license": "MIT", 10 | "dependencies": { 11 | "@babel/core": "^7.9.6", 12 | "@babel/preset-env": "^7.9.6", 13 | "@babel/register": "^7.9.0", 14 | "@w6s/cli-shared-utils": "^1.2.2", 15 | "babel-loader": "^8.1.0", 16 | "body-parser": "^1.19.0", 17 | "chokidar": "^3.4.0", 18 | "express": "^4.17.1", 19 | "path-to-regexp": "^6.1.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/@w6s/cli/lib/logCompleteMsg.js: -------------------------------------------------------------------------------- 1 | const cons = require('consolidate'); 2 | 3 | require('colors'); 4 | 5 | const logCompleteMsg = (opts, currentFolder) => { 6 | if (!opts) return; 7 | 8 | console.log('\n 执行以下命令启动项目: \n'.green); 9 | if (currentFolder) { 10 | console.log(` cd ${opts.name}\n`); 11 | } 12 | console.log(` yarn && yarn serve`); 13 | 14 | console.log(`\n 需了解更多,请查看开发文档:`); 15 | console.log(' https://open.workplus.io/dev/start/'.green); 16 | console.log('\n 🖖 Happy coding, Good luck!'); 17 | }; 18 | 19 | module.exports = { 20 | logCompleteMsg, 21 | }; 22 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/styles/_svgicon.scss: -------------------------------------------------------------------------------- 1 | /* Recommended css code for vue-svgicon */ 2 | .svg-icon { 3 | display: inline-block; 4 | width: 16px; 5 | height: 16px; 6 | color: inherit; 7 | fill: none; 8 | stroke: currentColor; 9 | vertical-align: -0.15em; 10 | } 11 | 12 | .svg-fill { 13 | fill: currentColor; 14 | stroke: none; 15 | } 16 | 17 | .svg-up { 18 | transform: rotate(0deg); 19 | } 20 | 21 | .svg-right { 22 | transform: rotate(90deg); 23 | } 24 | 25 | .svg-down { 26 | transform: rotate(180deg); 27 | } 28 | 29 | .svg-left { 30 | transform: rotate(-90deg); 31 | } 32 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmClient": "yarn", 3 | "useWorkspaces": true, 4 | "version": "independent", 5 | "packages": [ 6 | "packages/@w6s/cli*", 7 | "packages/@w6s/*-plugin" 8 | ], 9 | "changelog": { 10 | "repo": "WorkPlusFE/w6s-cli", 11 | "labels": { 12 | "PR: New Feature": ":rocket: New Features", 13 | "PR: Breaking Change": ":boom: Breaking Changes", 14 | "PR: Bug Fix": ":bug: Bug Fix", 15 | "PR: Documentation": ":memo: Documentation", 16 | "PR: Internal": ":house: Internal", 17 | "PR: Underlying Tools": ":hammer: Underlying Tools" 18 | }, 19 | "cacheDir": ".changelog" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/@w6s/cli-shared-utils/lib/env.js: -------------------------------------------------------------------------------- 1 | const { execSync } = require('child_process'); 2 | 3 | let hasYarn; 4 | // env detection 5 | exports.hasYarn = () => { 6 | if (hasYarn != null) { 7 | return hasYarn; 8 | } 9 | try { 10 | execSync('yarn --version', { stdio: 'ignore' }); 11 | hasYarn = true; 12 | return true; 13 | } catch (e) { 14 | hasYarn = false; 15 | return false; 16 | } 17 | }; 18 | 19 | // OS 20 | exports.isWindows = process.platform === 'win32'; 21 | exports.isMac = process.platform === 'darwin'; 22 | exports.isLinux = process.platform === 'linux'; 23 | 24 | // node env 25 | exports.isProd = () => process.env.NODE_ENV === 'production'; -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/svg/eye-off.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/styles/element-variables.scss: -------------------------------------------------------------------------------- 1 | /* Element Variables */ 2 | 3 | // Override Element UI variables 4 | $--color-primary: #1890ff; 5 | $--color-success: #13ce66; 6 | $--color-warning: #ffba00; 7 | $--color-danger: #ff4949; 8 | $--color-info: #5d5d5d; 9 | $--button-font-weight: 400; 10 | $--color-text-regular: #1f2d3d; 11 | $--border-color-light: #dfe4ed; 12 | $--border-color-lighter: #e6ebf5; 13 | $--table-border: 1px solid#dfe6ec; 14 | 15 | // Icon font path, required 16 | $--font-path: '~element-ui/lib/theme-chalk/fonts'; 17 | 18 | // Apply overrided variables in Element UI 19 | @import '~element-ui/packages/theme-chalk/src/index'; 20 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 22 | 23 | 31 | -------------------------------------------------------------------------------- /packages/@w6s/mock-plugin/index.js: -------------------------------------------------------------------------------- 1 | const mockMiddleware = require('./lib/mockMiddleware'); 2 | const defaultConfig = require('./lib/default.config'); 3 | 4 | module.exports = (api, options) => { 5 | let mockOptions = (options.pluginOptions && options.pluginOptions.mock) || {}; 6 | mockOptions = { 7 | ...defaultConfig, 8 | ...mockOptions, 9 | }; 10 | 11 | // disable mock server 12 | if (mockOptions.disable || process.env.NODE_ENV !== 'development') return; 13 | 14 | mockOptions.entry = api.resolve(mockOptions.entry); 15 | mockOptions.mockDir = api.resolve(mockOptions.mockDir); 16 | 17 | api.configureDevServer((app) => { 18 | app.use(mockMiddleware(mockOptions)); 19 | }); 20 | }; 21 | -------------------------------------------------------------------------------- /packages/@w6s/cli-deploy/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w6s/cli-deploy", 3 | "version": "1.1.0", 4 | "main": "./bin/index.js", 5 | "publishConfig": { 6 | "access": "public" 7 | }, 8 | "author": { 9 | "name": "lwy1010", 10 | "url": "https://github.com/lwy1010" 11 | }, 12 | "contributors": [ 13 | { 14 | "name": "hejx", 15 | "url": "https://github.com/hejianxian" 16 | } 17 | ], 18 | "bin": { 19 | "w6s-cli-deploy": "./bin/index.js" 20 | }, 21 | "dependencies": { 22 | "chalk": "^4.1.0", 23 | "commander": "^6.2.0", 24 | "execa": "^4.1.0", 25 | "inquirer": "^7.3.3", 26 | "node-ssh": "^11.1.1", 27 | "ora": "^5.1.0" 28 | }, 29 | "license": "MIT" 30 | } 31 | -------------------------------------------------------------------------------- /packages/@w6s/cli-deploy/template/deploy.config.js: -------------------------------------------------------------------------------- 1 | const templateConfig = `module.exports = { 2 | envConfig: { 3 | // 名为dev的部署环境的配置示例 4 | dev: { 5 | // 本地私钥地址,非必填 6 | privateKey: "", 7 | // 私钥的密码,非必填 8 | passphrase: "", 9 | // 服务器地址,如192.168.0.1 10 | host: "192.168.0.1", 11 | // ssh的端口,非必填,默认22 12 | port: "22", 13 | // 用户名,如root 14 | username: "root", 15 | // 服务器密码,非必填,执行部署命令可以手动输入以确保信息安全 16 | password: "", 17 | // 要部署到服务器的路径 18 | uploadPath: "/home/workplus", 19 | // 打包命令 20 | preCommand: "npm run build", 21 | // 打包出来的目录名 22 | distPath: "dist", 23 | }, 24 | }, 25 | };`; 26 | 27 | module.exports = templateConfig; 28 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/router/index.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import VueRouter, { RouteConfig } from 'vue-router'; 3 | import Home from '../views/Home.vue'; 4 | 5 | Vue.use(VueRouter); 6 | 7 | const routes: Array = [ 8 | { 9 | path: '/', 10 | name: 'Home', 11 | component: Home, 12 | }, 13 | { 14 | path: '/about', 15 | name: 'About', 16 | // route level code-splitting 17 | // this generates a separate chunk (about.[hash].js) for this route 18 | // which is lazy-loaded when the route is visited. 19 | component: () => import('../views/About.vue'), 20 | }, 21 | ]; 22 | 23 | const router = new VueRouter({ 24 | routes, 25 | }); 26 | 27 | export default router; 28 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/App.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 33 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/w6s.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parallel: false, 3 | pluginOptions: { 4 | lintStyleOnBuild: true, 5 | mock: { 6 | entry: 'mock/index.js', 7 | mockDir: 'mock', 8 | prefix: '/mock', 9 | 10 | disable: false, 11 | log: true, 12 | }, 13 | i18n: { 14 | locale: 'zh-CN', 15 | fallbackLocale: 'en', 16 | localeDir: 'locales', 17 | enableInSFC: false, 18 | }, 19 | vconsole: { 20 | enable: process.env.NODE_ENV === 'development', 21 | }, 22 | styleResourcesLoader: { 23 | preProcessor: 'scss', 24 | patterns: ['./styles/*/*.scss'], 25 | }, 26 | }, 27 | devServer: { 28 | port: 8088, 29 | }, 30 | }; 31 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/components/nested.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | /* tslint:disable */ 3 | // @ts-ignore 4 | import icon from 'vue-svgicon'; 5 | icon.register({ 6 | nested: { 7 | width: 128, 8 | height: 128, 9 | viewBox: '0 0 128 128', 10 | data: 11 | '', 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/components/password.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | /* tslint:disable */ 3 | // @ts-ignore 4 | import icon from 'vue-svgicon'; 5 | icon.register({ 6 | password: { 7 | width: 128, 8 | height: 128, 9 | viewBox: '0 0 128 128', 10 | data: 11 | '', 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/components/Hamburger/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 21 | 22 | 31 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/components/hamburger.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | /* tslint:disable */ 3 | // @ts-ignore 4 | import icon from 'vue-svgicon'; 5 | icon.register({ 6 | hamburger: { 7 | width: 64, 8 | height: 64, 9 | viewBox: '0 0 1024 1024', 10 | data: 11 | '', 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "esnext", 5 | "strict": true, 6 | "jsx": "preserve", 7 | "importHelpers": true, 8 | "moduleResolution": "node", 9 | "experimentalDecorators": true, 10 | "esModuleInterop": true, 11 | "allowSyntheticDefaultImports": true, 12 | "sourceMap": true, 13 | "baseUrl": ".", 14 | "types": ["node", "webpack-env"], 15 | "paths": { 16 | "@/*": ["src/*"] 17 | }, 18 | "lib": ["esnext", "dom", "dom.iterable", "scripthost"] 19 | }, 20 | "include": [ 21 | "src/**/*.ts", 22 | "src/**/*.tsx", 23 | "src/**/*.vue", 24 | "tests/**/*.ts", 25 | "tests/**/*.tsx" 26 | ], 27 | "exclude": ["node_modules"] 28 | } 29 | -------------------------------------------------------------------------------- /docs/post/README.md: -------------------------------------------------------------------------------- 1 | # 团队内部文章 2 | 3 | 此栏目为高科前端团队内部文章集合,多为内部分享后形成的文章。 4 | 5 | ## 文章规范 6 | 7 | - **文章名字:** 8 | 9 | 文章文件应该创建到 `/post` 文件夹中,以递增的数字开头,且必须为`英文`,例如: 10 | 11 | > **/post/1-sentry-source-analysis.md** 12 | 13 | 若需要新增一篇文章,开头数字应该为`2`: 14 | 15 | > **/post/2-something.md** 16 | 17 | 发布时,脚本会以数字的倒序将文章进行排序,数字越大的,越靠前。 18 | 19 | - **文章内容:** 20 | 21 | 此栏目非正式的博客系统,所以不会存在相关的发布数据,请按照以下方式添加发布者和发布时间: 22 | 23 | ```md 24 | # 这是标题 25 | 26 | > 某某某 / 2020--11-03 27 | ``` 28 | 29 | 此外,标题应该严格按照 MarkDown #号标题的级别进行使用。 30 | 31 | - **文章图片:** 32 | 33 | 1、文章内部图片,请保证清晰度不受影响的情况下,尺寸要足够的小; 34 | 35 | 2、图片文件应该放置到`.vuepress/public/`文件夹中,在引用时,需要注意路径的问题。 36 | 37 | 例如在 public 文件夹中,存在 test.jpg 图片,请使用以下方式引入: 38 | 39 | ```md 40 | 41 |

42 | test 43 |

44 | ``` -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/w6s.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | transpileDependencies: ['vuex-module-decorators'], 5 | pluginOptions: { 6 | mock: { 7 | entry: 'mock/index.js', 8 | mockDir: 'mock', 9 | prefix: '', 10 | 11 | disable: false, 12 | log: true, 13 | }, 14 | i18n: { 15 | locale: 'zh-CN', 16 | fallbackLocale: 'en', 17 | localeDir: 'locales', 18 | enableInSFC: false, 19 | }, 20 | styleResourcesLoader: { 21 | preProcessor: 'scss', 22 | patterns: [ 23 | path.resolve(__dirname, 'src/styles/_variables.scss'), 24 | path.resolve(__dirname, 'src/styles/_mixins.scss'), 25 | ], 26 | }, 27 | }, 28 | devServer: { 29 | port: 8089, 30 | }, 31 | }; 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | 39 | demos 40 | 41 | packages/test/** 42 | 43 | dist 44 | 45 | .DS_Store -------------------------------------------------------------------------------- /packages/@w6s/cli-script/bin/cli-script.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const { checkNodeVersion, logger } = require('@w6s/cli-shared-utils'); 4 | const minimist = require('minimist'); 5 | const { engines } = require('../package.json'); 6 | const { runService } = require('../lib'); 7 | 8 | checkNodeVersion(engines.node); 9 | 10 | const rawArgv = process.argv.slice(2); 11 | const args = minimist(rawArgv, { 12 | boolean: [ 13 | // build 14 | 'modern', 15 | 'report', 16 | 'report-json', 17 | 'inline-vue', 18 | 'watch', 19 | // serve 20 | 'open', 21 | 'copy', 22 | 'https', 23 | // inspect 24 | 'verbose', 25 | ], 26 | }); 27 | 28 | const command = args._[0]; 29 | 30 | runService(command, args, rawArgv).catch((err) => { 31 | logger.error(err); 32 | process.exit(1); 33 | }); 34 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/Jenkinsfile: -------------------------------------------------------------------------------- 1 | def repoName = "<%= name %>" 2 | def version = env.BRANCH_NAME 3 | 4 | pipeline { 5 | agent any 6 | environment { 7 | CI = 'true' 8 | } 9 | stages { 10 | stage("Git Checkout") { 11 | steps { 12 | checkout scm 13 | } 14 | } 15 | stage("Bootstrap && Build") { 16 | agent { 17 | docker { 18 | image 'node:10.23.0-alpine3.10' 19 | args '-e HOME=/tmp -e NPM_CONFIG_PREFIX=/tmp/.npm' 20 | reuseNode true 21 | } 22 | } 23 | steps { 24 | sh 'npm config set registry https://registry.npm.taobao.org' 25 | sh 'npm install' 26 | sh 'npm run build' 27 | } 28 | } 29 | stage("Deploy") { 30 | steps { 31 | sh 'echo "Deploy"' 32 | } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/Jenkinsfile: -------------------------------------------------------------------------------- 1 | def repoName = "<%= name %>" 2 | def version = env.BRANCH_NAME 3 | 4 | pipeline { 5 | agent any 6 | environment { 7 | CI = 'true' 8 | } 9 | stages { 10 | stage("Git Checkout") { 11 | steps { 12 | checkout scm 13 | } 14 | } 15 | stage("Bootstrap && Build") { 16 | agent { 17 | docker { 18 | image 'node:10.23.0-alpine3.10' 19 | args '-e HOME=/tmp -e NPM_CONFIG_PREFIX=/tmp/.npm' 20 | reuseNode true 21 | } 22 | } 23 | steps { 24 | sh 'npm config set registry https://registry.npm.taobao.org' 25 | sh 'npm install' 26 | sh 'npm run build' 27 | } 28 | } 29 | stage("Deploy") { 30 | steps { 31 | sh 'echo "Deploy"' 32 | } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # @w6s/cli 2 | 3 | [![npm version](https://badge.fury.io/js/%40w6s%2Fcli.svg)](https://badge.fury.io/js/%40w6s%2Fcli) [![Build Status](https://travis-ci.org/WorkPlusFE/cli.svg?branch=master)](https://travis-ci.org/WorkPlusFE/cli) 4 | 5 | A CLI for scaffolding starter projects. 6 | 7 | 👉 [查看 CLI 使用文档](https://open.workplus.io/dev/DevOps/) 8 | 9 | ## 安装 10 | 11 | 版本要求:`nodejs >= 10`: 12 | 13 | ```bash 14 | npm install -g @w6s/cli 15 | 16 | # Or 17 | yarn global add @w6s/cli 18 | ``` 19 | 20 | ## 创建一个项目 21 | 22 | ```bash 23 | # 进入某个文件路径,若不传入项目名称,将在当前目录创建 24 | $ w6s init 25 | ``` 26 | 27 | 当前支持两种项目模版,`Admin`及`H5`,分别对应管理后台类型项目及轻应用 H5 项目。 28 | 29 | ```bash 30 | ? 请选择项目类型 (Use arrow keys) 31 | ❯ 管理后台项目 32 | 移动端H5轻应用项目 33 | ``` 34 | 35 | 选择后,将自动创建项目,可选择直接安装依赖并启动。 36 | 37 | 更多命令,请通过`w6s --help`进行查看。 38 | 39 | ## License 40 | 41 | MIT 42 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/components/eye-off.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | /* tslint:disable */ 3 | // @ts-ignore 4 | import icon from 'vue-svgicon'; 5 | icon.register({ 6 | 'eye-off': { 7 | width: 128, 8 | height: 64, 9 | viewBox: '0 0 128 64', 10 | data: 11 | '', 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "esnext", 5 | "strict": true, 6 | "jsx": "preserve", 7 | "importHelpers": true, 8 | "moduleResolution": "node", 9 | "experimentalDecorators": true, 10 | "esModuleInterop": true, 11 | "allowSyntheticDefaultImports": true, 12 | "sourceMap": true, 13 | "baseUrl": ".", 14 | "types": [ 15 | "webpack-env", 16 | "node", 17 | "webpack" 18 | ], 19 | "paths": { 20 | "@/*": [ 21 | "src/*" 22 | ] 23 | }, 24 | "lib": [ 25 | "esnext", 26 | "dom", 27 | "dom.iterable", 28 | "scripthost" 29 | ] 30 | }, 31 | "include": [ 32 | "src/**/*.ts", 33 | "src/**/*.tsx", 34 | "src/**/*.vue" 35 | ], 36 | "exclude": [ 37 | "node_modules" 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /packages/@w6s/style-resources-loader-plugin/index.js: -------------------------------------------------------------------------------- 1 | const defaultPluginOptions = { 2 | preProcessor: 'scss', 3 | patterns: ['./styles/*/*.scss'], 4 | }; 5 | 6 | module.exports = (api, projectOptions) => { 7 | const currentPluginOptions = projectOptions.pluginOptions.styleResourcesLoader 8 | || projectOptions.pluginOptions['style-resources-loader'] 9 | || {}; 10 | const pluginOptions = { 11 | ...defaultPluginOptions, 12 | ...currentPluginOptions, 13 | }; 14 | api.chainWebpack((webpackConfig) => { 15 | [ 16 | 'normal', 17 | 'normal-modules', 18 | 'vue', 19 | 'vue-modules' 20 | ].forEach((oneOf) => { 21 | webpackConfig.module.rule(pluginOptions.preProcessor).oneOf(oneOf) 22 | .use('style-resources-loader') 23 | .loader('style-resources-loader') 24 | .options({ 25 | patterns: pluginOptions.patterns 26 | }); 27 | }); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/permission.ts: -------------------------------------------------------------------------------- 1 | import NProgress from 'nprogress'; 2 | import 'nprogress/nprogress.css'; 3 | import { Route } from 'vue-router'; 4 | import router from './router'; 5 | import { UserModule } from './store/modules/user'; 6 | 7 | NProgress.configure({ showSpinner: false }); 8 | 9 | const whiteList = ['/login']; 10 | 11 | router.beforeEach(async (to: Route, _: Route, next: any) => { 12 | // Start progress bar 13 | NProgress.start(); 14 | if (UserModule.token) { 15 | if (to.path === '/login') { 16 | next({ path: '/' }); 17 | NProgress.done(); 18 | } else { 19 | next(); 20 | NProgress.done(); 21 | } 22 | } else if (whiteList.indexOf(to.path) !== -1) { 23 | next(); 24 | } else { 25 | next(`/login?redirect=${to.path}`); 26 | NProgress.done(); 27 | } 28 | }); 29 | 30 | router.afterEach(() => { 31 | // Finish progress bar 32 | NProgress.done(); 33 | }); 34 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/main.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | 3 | import 'normalize.css'; 4 | import ElementUI from 'element-ui'; 5 | import SvgIcon from 'vue-svgicon'; 6 | 7 | import '@/styles/element-variables.scss'; 8 | import '@/styles/index.scss'; 9 | 10 | import App from '@/App.vue'; 11 | import store from '@/store'; 12 | import router from '@/router'; 13 | import '@/icons/components'; 14 | import '@/permission'; 15 | 16 | import getEnvConfig from '@/utils/getEnvConfig'; 17 | import service from '@/utils/request'; 18 | import i18n from './i18n'; 19 | 20 | Vue.use(ElementUI); 21 | Vue.use(SvgIcon, { 22 | tagName: 'svg-icon', 23 | defaultWidth: '1em', 24 | defaultHeight: '1em', 25 | }); 26 | 27 | Vue.config.productionTip = false; 28 | 29 | getEnvConfig().then((baseUrl) => { 30 | service.defaults.baseURL = baseUrl; 31 | new Vue({ 32 | router, 33 | store, 34 | i18n, 35 | render: (h) => h(App), 36 | }).$mount('#app'); 37 | }); 38 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/styles/_variables.scss: -------------------------------------------------------------------------------- 1 | /* Variables */ 2 | 3 | // Base color 4 | $blue: #324157; 5 | $light-blue: #3a71a8; 6 | $red: #c03639; 7 | $pink: #e65d6e; 8 | $green: #30b08f; 9 | $tiffany: #4ab7bd; 10 | $yellow: #fec171; 11 | $panGreen: #30b08f; 12 | 13 | // Sidebar 14 | $sideBarWidth: 210px; 15 | $subMenuBg: #1f2d3d; 16 | $subMenuHover: #001528; 17 | $subMenuActiveText: #f4f4f5; 18 | $menuBg: #304156; 19 | $menuText: #bfcbd9; 20 | $menuActiveText: #409eff; // Also see settings.sidebarTextTheme 21 | 22 | // Login page 23 | $lightGray: #eee; 24 | $darkGray: #889aa4; 25 | $loginBg: #2d3a4b; 26 | $loginCursorColor: #fff; 27 | 28 | // The :export directive is the magic sauce for webpack 29 | // https://mattferderer.com/use-sass-variables-in-typescript-and-javascript 30 | /* stylelint-disable selector-pseudo-class-no-unknown,property-no-unknown */ 31 | :export { 32 | menuBg: $menuBg; 33 | menuText: $menuText; 34 | menuActiveText: $menuActiveText; 35 | } 36 | -------------------------------------------------------------------------------- /packages/@w6s/sentry-plugin/index.js: -------------------------------------------------------------------------------- 1 | const SentryPlugin = require('webpack-sentry-plugin'); 2 | const { isProd } = require('@w6s/cli-shared-utils'); 3 | const { getGitSha, isLegalOptions } = require('./utils'); 4 | 5 | const defaultPluginOptions = { 6 | deleteAfterCompile: true, 7 | suppressConflictError: true, 8 | include: /\.js/ig, 9 | baseSentryURL: 'https://sentry.workplus.io/api/0', 10 | organization: 'sentry', 11 | }; 12 | 13 | module.exports = (api, projectOptions) => { 14 | if (!isProd()) return; 15 | 16 | const receivedOptions = projectOptions.pluginOptions.sentry || {}; 17 | if (!receivedOptions.enable) return; 18 | if (!isLegalOptions(receivedOptions)) return; 19 | 20 | const sentryPluginOptions = { 21 | ...defaultPluginOptions, 22 | release: getGitSha(), 23 | ...receivedOptions, 24 | }; 25 | 26 | api.chainWebpack(webpackConfig => { 27 | webpackConfig.plugin('SentryPlugin') 28 | .use(SentryPlugin, [sentryPluginOptions]); 29 | }); 30 | }; 31 | -------------------------------------------------------------------------------- /packages/@w6s/mock-plugin/lib/watcher.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const chokidar = require('chokidar'); 3 | const { logger } = require('@w6s/cli-shared-utils'); 4 | 5 | const rootPath = path.join(__dirname, '..'); 6 | 7 | module.exports = (mockDir, entry, callback) => { 8 | chokidar.watch(mockDir, { 9 | ignoreInitial: false 10 | }).on('all', (event) => { 11 | if (event === 'add' || event === 'change') { 12 | try { 13 | delete require.cache[require.resolve(entry)]; 14 | 15 | /* eslint global-require:0 import/no-dynamic-require:0 */ 16 | require("@babel/register")({ 17 | root: rootPath, 18 | ignore: [/node_modules/], 19 | }); 20 | const mockModule = require(entry); 21 | 22 | if (callback && typeof callback === 'function') { 23 | callback(mockModule); 24 | } 25 | } catch (err) { 26 | logger.error(`Done: Hot Mocker file replacement failed!\n${err.stack}`); 27 | } 28 | } 29 | }); 30 | }; 31 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/store/modules/Counter.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Module, 3 | VuexModule, 4 | Mutation, 5 | Action, 6 | getModule, 7 | } from 'vuex-module-decorators'; 8 | import store from '..'; 9 | 10 | @Module({ 11 | dynamic: true, 12 | store, 13 | name: 'counter', 14 | }) 15 | class Counter extends VuexModule { 16 | count = 0; 17 | 18 | @Mutation 19 | increment(delta: number) { 20 | this.count += delta; 21 | } 22 | 23 | @Mutation 24 | decrement(delta: number) { 25 | this.count -= delta; 26 | } 27 | 28 | get countNum() { 29 | return this.count; 30 | } 31 | 32 | // action 'incr' commits mutation 'increment' when done with return value as payload 33 | @Action({ commit: 'increment' }) 34 | incr() { 35 | return 5; 36 | } 37 | 38 | // action 'decr' commits mutation 'decrement' when done with return value as payload 39 | @Action({ commit: 'decrement' }) 40 | decr() { 41 | return 5; 42 | } 43 | } 44 | 45 | export default getModule(Counter); 46 | -------------------------------------------------------------------------------- /scripts/verifyCommitMsg.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk') // eslint-disable-line 2 | const msgPath = process.env.GIT_PARAMS 3 | const msg = require('fs').readFileSync(msgPath, 'utf-8').trim() 4 | 5 | const commitRE = /^(v\d+\.\d+\.\d+(-(alpha|beta|rc.\d+))?)|((revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|ci|chore|types)(\(.+\))?!?: .{1,50})/ 6 | 7 | if (!commitRE.test(msg)) { 8 | console.log() 9 | console.error( 10 | ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red(`invalid commit message format.`)}\n\n` + 11 | chalk.red(` Proper commit message format is required for automated changelog generation. Examples:\n\n`) + 12 | ` ${chalk.green(`feat(compiler): add 'comments' option`)}\n` + 13 | ` ${chalk.green(`fix(v-model): handle events on blur (close #28)`)}\n\n` + 14 | chalk.red(` See .github/COMMIT_CONVENTION.md for more details.\n`) + 15 | chalk.red(` You can also use ${chalk.cyan(`npm run commit`)} to interactively generate a commit message.\n`) 16 | ) 17 | process.exit(1) 18 | } 19 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/svg/eye-on.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/styles/_transition.scss: -------------------------------------------------------------------------------- 1 | /* Global transition */ 2 | // See https://vuejs.org/v2/guide/transitions.html for detail 3 | 4 | // fade 5 | .fade-enter-active, 6 | .fade-leave-active { 7 | transition: opacity 0.28s; 8 | } 9 | 10 | .fade-enter, 11 | .fade-leave-active { 12 | opacity: 0; 13 | } 14 | 15 | // fade-transform 16 | .fade-transform-leave-active, 17 | .fade-transform-enter-active { 18 | transition: all 0.5s; 19 | } 20 | 21 | .fade-transform-enter { 22 | opacity: 0; 23 | transform: translateX(-30px); 24 | } 25 | 26 | .fade-transform-leave-to { 27 | opacity: 0; 28 | transform: translateX(30px); 29 | } 30 | 31 | // breadcrumb 32 | .breadcrumb-enter-active, 33 | .breadcrumb-leave-active { 34 | transition: all 0.5s; 35 | } 36 | 37 | .breadcrumb-enter, 38 | .breadcrumb-leave-active { 39 | opacity: 0; 40 | transform: translateX(20px); 41 | } 42 | 43 | .breadcrumb-move { 44 | transition: all 0.5s; 45 | } 46 | 47 | .breadcrumb-leave-active { 48 | position: absolute; 49 | } 50 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/store/modules/user.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Module, 3 | VuexModule, 4 | Action, 5 | Mutation, 6 | getModule, 7 | } from 'vuex-module-decorators'; 8 | 9 | import store from '@/store'; 10 | import { getToken, setToken } from '@/utils/cookies'; 11 | import { login } from '@/api/user'; 12 | 13 | export interface UserState { 14 | token: string; 15 | name: string; 16 | } 17 | 18 | @Module({ dynamic: true, name: 'user', store }) 19 | class User extends VuexModule implements UserState { 20 | token = getToken() || ''; 21 | 22 | name = ''; 23 | 24 | @Mutation 25 | SET_TOKEN(token: string) { 26 | this.token = token; 27 | } 28 | 29 | @Action 30 | async Login(userInfo: { username: string; password: string }) { 31 | const { password } = userInfo; 32 | 33 | let { username } = userInfo; 34 | username = username.trim(); 35 | const { data } = await login({ username, password }); 36 | setToken(data.token); 37 | this.SET_TOKEN(data.token); 38 | } 39 | } 40 | 41 | export const UserModule = getModule(User); 42 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/styles/index.scss: -------------------------------------------------------------------------------- 1 | // @import './variables.scss'; // Already imported in style-resources-loader 2 | // @import './mixins.scss'; // Already imported in style-resources-loader 3 | @import './transition.scss'; 4 | @import './svgicon.scss'; 5 | 6 | /* Global scss */ 7 | 8 | body { 9 | height: 100%; 10 | -moz-osx-font-smoothing: grayscale; 11 | -webkit-font-smoothing: antialiased; 12 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica Neue, 13 | Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif; 14 | } 15 | 16 | html { 17 | height: 100%; 18 | } 19 | 20 | #app { 21 | height: 100%; 22 | } 23 | 24 | *, 25 | *::before, 26 | *::after { 27 | box-sizing: border-box; 28 | } 29 | 30 | a, 31 | a:focus, 32 | a:hover { 33 | color: inherit; 34 | outline: none; 35 | text-decoration: none; 36 | } 37 | 38 | div:focus { 39 | outline: none; 40 | } 41 | 42 | /* stylelint-disable at-rule-no-unknown */ 43 | .clearfix { 44 | @include clearfix; 45 | } 46 | 47 | .app-container { 48 | padding: 20px; 49 | } 50 | -------------------------------------------------------------------------------- /packages/@w6s/sentry-plugin/utils.js: -------------------------------------------------------------------------------- 1 | require('colors'); 2 | 3 | const execa = require('execa'); 4 | const { v4: uuidv4 } = require('uuid'); 5 | const { logger } = require('@w6s/cli-shared-utils'); 6 | 7 | const getGitSha = () => { 8 | let hash = ''; 9 | try { 10 | hash = execa.shellSync('git rev-parse HEAD').stdout; 11 | } catch (err) { 12 | hash = uuidv4(); 13 | logger.warn('Have not commit, will use random uuid as release', 'Sentry'); 14 | }; 15 | return hash.substr(0, 7); 16 | }; 17 | 18 | /** 19 | * Sentry options are required 20 | * 1、organization 21 | * 2、project 22 | * 3、apiKey 23 | * 4、release (auto) 24 | */ 25 | const isLegalOptions = (options) => { 26 | const requiredOptions = ['organization', 'project', 'apiKey', 'baseSentryURL']; 27 | for (let i = 0; i < requiredOptions.length; i += 1) { 28 | const key = requiredOptions[i]; 29 | if (options[key] === '') { 30 | logger.error(`[${key}] is required`); 31 | return false; 32 | } 33 | } 34 | return true; 35 | }; 36 | 37 | module.exports = { 38 | getGitSha, 39 | isLegalOptions, 40 | }; 41 | -------------------------------------------------------------------------------- /packages/@w6s/cli-script/lib/utils.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const { resolvePkg, isPlugin, logger } = require("@w6s/cli-shared-utils"); 3 | 4 | const idToPlugin = (id) => ({ 5 | id: id.replace(/^.\//, 'built-in:'), 6 | apply: require(id), 7 | }); 8 | 9 | /* eslint import/no-dynamic-require:0 global-require:0 */ 10 | exports.toPlugin = id => ({ id, apply: require(id) }); 11 | exports.w6sConfigFileExists = configPath => fs.existsSync(configPath); 12 | 13 | exports.getRootProjectPlugins = (ctx) => { 14 | const pkg = resolvePkg(ctx); 15 | return Object.keys(pkg.devDependencies || {}) 16 | .concat(Object.keys(pkg.dependencies || {})) 17 | .filter(isPlugin) 18 | .map(id => { 19 | if ( 20 | pkg.optionalDependencies && 21 | id in pkg.optionalDependencies 22 | ) { 23 | let apply = () => {}; 24 | try { 25 | apply = require(id); 26 | } catch (e) { 27 | logger.warn(`Optional dependency ${id} is not installed.`); 28 | } 29 | 30 | return { id, apply }; 31 | } 32 | return idToPlugin(id); 33 | 34 | }); 35 | }; 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 WorkPlusFE 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/components/eye-on.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | /* tslint:disable */ 3 | // @ts-ignore 4 | import icon from 'vue-svgicon'; 5 | icon.register({ 6 | 'eye-on': { 7 | width: 128, 8 | height: 128, 9 | viewBox: '0 0 1024 1024', 10 | data: 11 | '', 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /packages/@w6s/cli/lib/mirror.js: -------------------------------------------------------------------------------- 1 | const MIRRORS_CONFIG = { 2 | 'taobao-mirror': '{{shell}} registry https://r.npm.taobao.org', 3 | 'node-gyp': '{{shell}} disturl https://npm.taobao.org/dist', 4 | 'node-sass': '{{shell}} sass_binary_site https://npm.taobao.org/mirrors/node-sass', 5 | 'electron': '{{shell}} electron_mirror https://npm.taobao.org/mirrors/electron/', 6 | 'puppeteer': '{{shell}} puppeteer_download_host https://npm.taobao.org/mirrors', 7 | 'chromedriver': '{{shell}} chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver', 8 | 'operadriver': '{{shell}} operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver', 9 | 'phantomjs': '{{shell}} phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs', 10 | 'selenium': '{{shell}} selenium_cdnurl https://npm.taobao.org/mirrors/selenium', 11 | 'node-inspector': '{{shell}} node_inspector_cdnurl https://npm.taobao.org/mirrors/node-inspector', 12 | }; 13 | 14 | exports.getMirrorByType = (package, mirrors) => { 15 | const shell = package.toLowerCase() === 'yarn' ? 'yarn config set' : 'npm set'; 16 | return mirrors.map((mirror) => MIRRORS_CONFIG[mirror].replace('{{shell}}', shell)); 17 | }; -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/i18n.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import VueI18n, { LocaleMessages } from 'vue-i18n'; 3 | 4 | Vue.use(VueI18n); 5 | 6 | function loadLocaleMessages() { 7 | const context = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i); 8 | const messages: LocaleMessages = {}; 9 | context.keys().forEach((key) => { 10 | const matched = key.match(/([A-Za-z0-9-_]+)\./i); 11 | if (matched && matched.length > 1) { 12 | const locale = matched[1]; 13 | messages[locale] = context(key); 14 | } 15 | }); 16 | return { context, messages }; 17 | } 18 | 19 | const { context, messages } = loadLocaleMessages(); 20 | 21 | const i18n = new VueI18n({ 22 | locale: process.env.VUE_APP_I18N_LOCALE || 'en', 23 | fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', 24 | messages, 25 | }); 26 | 27 | if (module.hot) { 28 | module.hot.accept(context.id, () => { 29 | /* eslint no-shadow:0 */ 30 | const { messages } = loadLocaleMessages(); 31 | Object.keys(messages).forEach((locale) => i18n.setLocaleMessage(locale, messages[locale])); 32 | }); 33 | } 34 | 35 | export default i18n; 36 | -------------------------------------------------------------------------------- /packages/@w6s/cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w6s/cli", 3 | "version": "2.3.4", 4 | "description": "@w6s/cli", 5 | "main": "index.js", 6 | "bin": { 7 | "w6s": "bin/w6s" 8 | }, 9 | "publishConfig": { 10 | "access": "public" 11 | }, 12 | "license": "MIT", 13 | "author": "WorkPlusFE", 14 | "dependencies": { 15 | "@w6s/cli-deploy": "^1.1.0", 16 | "@w6s/cli-shared-utils": "^1.2.2", 17 | "async": "^3.2.0", 18 | "colors": "^1.4.0", 19 | "commander": "^5.1.0", 20 | "consolidate": "^0.15.1", 21 | "download-git-repo": "^3.0.2", 22 | "envinfo": "^7.7.3", 23 | "execa": "^4.0.0", 24 | "figlet": "^1.4.0", 25 | "inquirer": "^7.1.0", 26 | "latest-version": "^5.1.0", 27 | "metalsmith": "^2.3.0", 28 | "ora": "^4.0.4", 29 | "portfinder": "^1.0.25", 30 | "qrcode": "^1.4.4", 31 | "read-metadata": "^1.0.0", 32 | "readline": "^1.3.0", 33 | "request": "^2.88.2", 34 | "rimraf": "^3.0.2", 35 | "serve": "^11.3.0", 36 | "uid": "^1.0.0", 37 | "underscore": "^1.10.2", 38 | "validate-npm-package-name": "^3.0.0" 39 | }, 40 | "engines": { 41 | "node": ">=10" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/i18n.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import VueI18n, { LocaleMessages } from 'vue-i18n'; 3 | 4 | Vue.use(VueI18n); 5 | 6 | function loadLocaleMessages() { 7 | const context = require.context( 8 | './locales', 9 | true, 10 | /[A-Za-z0-9-_,\s]+\.json$/i, 11 | ); 12 | const messages: LocaleMessages = {}; 13 | context.keys().forEach((key) => { 14 | const matched = key.match(/([A-Za-z0-9-_]+)\./i); 15 | if (matched && matched.length > 1) { 16 | const locale = matched[1]; 17 | messages[locale] = context(key); 18 | } 19 | }); 20 | return { context, messages }; 21 | } 22 | 23 | const { context, messages } = loadLocaleMessages(); 24 | 25 | const i18n = new VueI18n({ 26 | locale: process.env.VUE_APP_I18N_LOCALE || 'en', 27 | fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', 28 | messages, 29 | }); 30 | 31 | if (module.hot) { 32 | module.hot.accept(context.id, () => { 33 | /* eslint no-shadow:0 */ 34 | const { messages } = loadLocaleMessages(); 35 | Object.keys(messages).forEach((locale) => 36 | i18n.setLocaleMessage(locale, messages[locale])); 37 | }); 38 | } 39 | 40 | export default i18n; 41 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/utils/request.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | import { Message } from 'element-ui'; 3 | import { UserModule } from '@/store/modules/user'; 4 | 5 | const service = axios.create({ 6 | timeout: 5000, 7 | }); 8 | 9 | // Request interceptors 10 | service.interceptors.request.use( 11 | // code == 20000: success 12 | // code == 50001: invalid user (user not exist) 13 | (config) => { 14 | if (UserModule.token) { 15 | config.headers['X-Access-Token'] = UserModule.token; 16 | } 17 | return config; 18 | }, 19 | (error) => error, 20 | ); 21 | 22 | // Response interceptors 23 | service.interceptors.response.use( 24 | (response) => { 25 | const res = response.data; 26 | if (res.code !== 20000) { 27 | Message({ 28 | message: res.message || 'Error', 29 | type: 'error', 30 | duration: 5 * 1000, 31 | }); 32 | return Promise.reject(new Error(res.message || 'Error')); 33 | } 34 | return res; 35 | }, 36 | (error) => { 37 | Message({ 38 | message: error.message, 39 | type: 'error', 40 | duration: 5 * 1000, 41 | }); 42 | return Promise.reject(error); 43 | }, 44 | ); 45 | 46 | export default service; 47 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/svg/dashboard.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/@w6s/cli/bin/w6s: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('colors'); 4 | 5 | const program = require('commander'); 6 | const figlet = require('figlet'); 7 | 8 | if (process.argv.length < 3) { 9 | console.log(figlet.textSync("@ w6s / cli").white); 10 | console.log(' =================================================='.white); 11 | } 12 | 13 | program 14 | .version(require('../package').version) 15 | .usage(' [options]') 16 | .command('init ', 'create a new project') 17 | .command('serve', 'http-server like, start a local static server') 18 | .command('deploy', 'automatically publish front-end resources') 19 | .command('set-mirror', 'set NPM or Yarn mirrors to Taobao sources, such as electron, node-sass') 20 | .command('qrcode', 'draw QRcode in terminal window') 21 | 22 | program 23 | .command('env') 24 | .description('print debugging information about your environment') 25 | .action((cmd) => { 26 | console.log('\n Environment Info:'.green); 27 | require('envinfo').run( 28 | { 29 | System: ['OS', 'CPU'], 30 | Binaries: ['Node', 'Yarn', 'npm'], 31 | Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'], 32 | }, 33 | { 34 | showNotFound: true, 35 | duplicates: true, 36 | fullTree: true 37 | } 38 | ).then(console.log); 39 | }); 40 | 41 | program.parse(process.argv); -------------------------------------------------------------------------------- /docs/qa.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: auto 3 | --- 4 | 5 | # 常见问题 6 | 7 | ## 如何控制 NodeJs 版本 8 | 9 | 推荐使用以下两个工具: 10 | 11 | * [nvm - POSIX-compliant bash script to manage multiple active node.js versions](https://github.com/nvm-sh/nvm) 12 | * [n - Interactively Manage Your Node.js Versions](https://github.com/tj/n) 13 | 14 | ## 如何更新 Yarn 版本 15 | 16 | 针对 MacOS,在 shell 中敲入以下内容即可: 17 | 18 | ```bash 19 | curl --compressed -o- -L https://yarnpkg.com/install.sh | bash 20 | ``` 21 | 22 | ## 如何设置淘宝源 23 | 24 | 在 shell 中敲入以下内容: 25 | 26 | ```bash 27 | # 淘宝 npm 镜像 28 | npm set registry https://r.npm.taobao.org 29 | # node-gyp 编译依赖的 node 镜像 30 | npm set disturl https://npm.taobao.org/dist 31 | 32 | # node-sass 二进制包镜像 33 | npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass 34 | # electron 二进制包镜像 35 | npm set electron_mirror https://npm.taobao.org/mirrors/electron/ 36 | # puppeteer 二进制包镜像 37 | npm set puppeteer_download_host https://npm.taobao.org/mirrors 38 | # chromedriver 二进制包镜像 39 | npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver 40 | # operadriver 二进制包镜像 41 | npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver 42 | # phantomjs 二进制包镜像 43 | npm set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs 44 | # selenium 二进制包镜像 45 | npm set selenium_cdnurl https://npm.taobao.org/mirrors/selenium 46 | # node-inspector 二进制包镜像 47 | npm set node_inspector_cdnurl https://npm.taobao.org/mirrors/node-inspector 48 | ``` -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/icons/components/dashboard.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | /* tslint:disable */ 3 | // @ts-ignore 4 | import icon from 'vue-svgicon'; 5 | icon.register({ 6 | dashboard: { 7 | width: 128, 8 | height: 100, 9 | viewBox: '0 0 128 100', 10 | data: 11 | '', 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= name %>", 3 | "version": "1.0.0", 4 | "private": true, 5 | "description": "<%= description %>", 6 | "author": "<%= author %>", 7 | "scripts": { 8 | "dev": "w6s-cli-script serve --open", 9 | "serve": "w6s-cli-script serve --open", 10 | "build": "w6s-cli-script build", 11 | "lint": "w6s-cli-script lint", 12 | "lint:style": "w6s-cli-script lint:style", 13 | "i18n:report": "w6s-cli-script i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'", 14 | "inspect": "w6s-cli-script inspect" 15 | }, 16 | "dependencies": { 17 | "@w6s/sdk": "^<%= SDKVersion %>", 18 | "axios": "^0.21.1", 19 | "core-js": "^3.6.5", 20 | "vant": "^2.8.1", 21 | "vue": "^2.6.12", 22 | "vue-class-component": "^7.2.3", 23 | "vue-i18n": "^8.17.5", 24 | "vue-property-decorator": "^8.4.1", 25 | "vue-router": "^3.1.6", 26 | "vuex": "^3.1.3", 27 | "vuex-module-decorators": "^0.17.0" 28 | }, 29 | "devDependencies": { 30 | "@w6s/cli-script": "^<%= cliScriptVersion %>" 31 | }, 32 | "husky": { 33 | "hooks": { 34 | "pre-commit": "lint-staged", 35 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" 36 | } 37 | }, 38 | "lint-staged": { 39 | "*.{js,jsx,vue,ts,tsx}": [ 40 | "w6s-cli-script lint", 41 | "w6s-cli-script lint:style" 42 | ] 43 | }, 44 | "engines": { 45 | "node": ">=10" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /packages/@w6s/cli/lib/clone.js: -------------------------------------------------------------------------------- 1 | require('colors'); 2 | 3 | const download = require('download-git-repo'); 4 | const ora = require('ora'); 5 | const exists = require('fs').existsSync; 6 | const uid = require('uid'); 7 | const inquirer = require('inquirer'); 8 | const remove = require('rimraf').sync; 9 | const { logger } = require('@w6s/cli-shared-utils'); 10 | 11 | const generate = require('./generate.js'); 12 | 13 | const handleDownloadGitRepo = (source, dest) => new Promise((resolve) => { 14 | download(source, dest, (err) => { 15 | if (err) { 16 | throw new Error(err); 17 | } 18 | resolve(); 19 | }); 20 | }); 21 | 22 | function run(name, template, destination) { 23 | if (exists(template)) { 24 | console.log('\n # 开始创建项目,请正确填写各项内容 \n'.gray); 25 | return generate(name, template, destination); 26 | } 27 | console.log(''); 28 | const spinner = ora(`获取 "${template}" 项目模版...`); 29 | 30 | const tmp = `/tmp/template${uid()}`; // unique backup 31 | spinner.start(); 32 | 33 | return handleDownloadGitRepo(`workplus-templates/${template}`, tmp) 34 | .then(() => { 35 | spinner.text = `下载 "${template}" 成功`; 36 | spinner.succeed(); 37 | console.log('\n # 开始创建项目 \n'.gray); 38 | process.on('exit', () => { 39 | remove(tmp); // remove backup files 40 | }); 41 | }) 42 | .then(() => generate(name, tmp, destination)); 43 | 44 | }; 45 | 46 | const clone = (name, template, destination) => run(name, template, destination); 47 | 48 | module.exports = clone; -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/layout/mixin/resize.ts: -------------------------------------------------------------------------------- 1 | import { Component, Vue, Watch } from 'vue-property-decorator'; 2 | import { AppModule, DeviceType } from '@/store/modules/app'; 3 | 4 | const WIDTH = 992; // refer to Bootstrap's responsive design 5 | 6 | @Component({ 7 | name: 'ResizeMixin', 8 | }) 9 | export default class extends Vue { 10 | get device() { 11 | return AppModule.device; 12 | } 13 | 14 | get sidebar() { 15 | return AppModule.sidebar; 16 | } 17 | 18 | @Watch('$route') 19 | private onRouteChange() { 20 | if (this.device === DeviceType.Mobile && this.sidebar.opened) { 21 | AppModule.CloseSideBar(false); 22 | } 23 | } 24 | 25 | beforeMount() { 26 | window.addEventListener('resize', this.resizeHandler); 27 | } 28 | 29 | mounted() { 30 | const isMobile = this.isMobile(); 31 | if (isMobile) { 32 | AppModule.ToggleDevice(DeviceType.Mobile); 33 | AppModule.CloseSideBar(true); 34 | } 35 | } 36 | 37 | beforeDestroy() { 38 | window.removeEventListener('resize', this.resizeHandler); 39 | } 40 | 41 | private isMobile() { 42 | const rect = document.body.getBoundingClientRect(); 43 | return rect.width - 1 < WIDTH; 44 | } 45 | 46 | private resizeHandler() { 47 | if (!document.hidden) { 48 | const isMobile = this.isMobile(); 49 | AppModule.ToggleDevice(isMobile ? DeviceType.Mobile : DeviceType.Desktop); 50 | if (isMobile) { 51 | AppModule.CloseSideBar(true); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/mock/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'GET /api/user': { 3 | username: 'admin', 4 | sex: 5, 5 | }, 6 | 'GET /api/list': function (req, res) { 7 | let query = req.query || {}; 8 | return res.json({ 9 | limit: query.limit, 10 | offset: query.offset, 11 | list: [{ 12 | username: 'admin1', 13 | sex: 1, 14 | }, { 15 | username: 'admin2', 16 | sex: 0, 17 | }] 18 | }) 19 | }, 20 | 'GET /api/userinfo/:id': (req, res) => { 21 | return res.json({ 22 | id: req.params.id, 23 | username: 'kenny', 24 | }); 25 | }, 26 | 'POST /api/login/account': (req, res) => { 27 | const { password, username } = req.body; 28 | if (password === '888888' && username === 'admin') { 29 | return res.json({ 30 | status: 'ok', 31 | token: 'sdfsdfsdfdsf', 32 | }); 33 | } else { 34 | return res.json({ 35 | status: 'error', 36 | code: 403, 37 | }); 38 | } 39 | }, 40 | 'DELETE /api/user/:id': (req, res) => { 41 | // console.log(req.params.id); 42 | res.send({ status: 'ok', message: 'delete success!' }); 43 | }, 44 | 'PUT /api/user/:id': (req, res) => { 45 | // console.log(req.params.id); 46 | // console.log(req.body); 47 | res.send({ status: 'ok', message: 'update success!' }); 48 | }, 49 | } 50 | -------------------------------------------------------------------------------- /packages/@w6s/cli-shared-utils/lib/logger.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk'); 2 | const stripAnsi = require('strip-ansi'); 3 | const readline = require('readline'); 4 | 5 | const format = (label, msg) => { 6 | return msg.split('\n').map((line, i) => { 7 | return i === 0 8 | ? `${label} ${line}` 9 | : line.padStart(stripAnsi(label).length) 10 | }).join('\n'); 11 | }; 12 | 13 | const chalkTag = msg => chalk.bgBlackBright.white.dim(` ${msg} `); 14 | 15 | exports.log = (msg = '', tag = null) => { 16 | if (tag) { 17 | console.log(format(chalkTag(tag), msg)); 18 | } else { 19 | console.log(msg); 20 | } 21 | } 22 | 23 | exports.info = (msg, tag = null) => { 24 | console.log(format(chalk.bgBlue.black(' INFO ') + (tag ? chalkTag(tag) : ''), msg)); 25 | } 26 | 27 | exports.done = (msg, tag = null) => { 28 | console.log(format(chalk.bgGreen.black(' DONE ') + (tag ? chalkTag(tag) : ''), msg)); 29 | } 30 | 31 | exports.warn = (msg, tag = null) => { 32 | console.warn(format(chalk.bgYellow.black(' WARN ') + (tag ? chalkTag(tag) : ''), chalk.yellow(msg))); 33 | } 34 | 35 | exports.error = (msg, tag = null) => { 36 | console.error(format(chalk.bgRed(' ERROR ') + (tag ? chalkTag(tag) : ''), chalk.red(msg))); 37 | if (msg instanceof Error) { 38 | console.error(msg.stack); 39 | } 40 | } 41 | 42 | exports.clearConsole = title => { 43 | if (process.stdout.isTTY) { 44 | const blank = '\n'.repeat(process.stdout.rows); 45 | console.log(blank); 46 | readline.cursorTo(process.stdout, 0, 0); 47 | readline.clearScreenDown(process.stdout); 48 | if (title) { 49 | console.log(title); 50 | } 51 | } 52 | }; 53 | -------------------------------------------------------------------------------- /docs/.vuepress/dist/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | WorkPlusFE 开发手册 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

404

Looks like we've got some broken links.
15 | Take me home. 16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= name %>", 3 | "description": "<%= description %>", 4 | "private": true, 5 | "version": "1.0.0", 6 | "author": "<%= author %>", 7 | "scripts": { 8 | "dev": "w6s-cli-script serve --open", 9 | "serve": "w6s-cli-script serve --open", 10 | "build": "w6s-cli-script build", 11 | "lint": "w6s-cli-script lint", 12 | "lint:style": "w6s-cli-script lint:style", 13 | "i18n:report": "w6s-cli-script i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'", 14 | "inspect": "w6s-cli-script inspect", 15 | "svg": "vsvg -s ./src/icons/svg -t ./src/icons/components --ext ts --es6" 16 | }, 17 | "dependencies": { 18 | "axios": "^0.21.1", 19 | "core-js": "^3.6.5", 20 | "element-ui": "^2.9.2", 21 | "js-cookie": "^2.2.0", 22 | "normalize.css": "^8.0.1", 23 | "nprogress": "^0.2.0", 24 | "path-to-regexp": "^6.1.0", 25 | "register-service-worker": "^1.6.2", 26 | "vue": "^2.6.12", 27 | "vue-svgicon": "^3.2.6", 28 | "vue-class-component": "^7.2.3", 29 | "vue-i18n": "^8.17.5", 30 | "vue-property-decorator": "^8.4.1", 31 | "vue-router": "^3.1.6", 32 | "vuex": "^3.1.3", 33 | "vuex-module-decorators": "^0.17.0" 34 | }, 35 | "devDependencies": { 36 | "@types/js-cookie": "^2.2.6", 37 | "@types/nprogress": "^0.2.0", 38 | "@w6s/cli-script": "^<%= cliScriptVersion %>" 39 | }, 40 | "husky": { 41 | "hooks": { 42 | "pre-commit": "lint-staged", 43 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" 44 | } 45 | }, 46 | "lint-staged": { 47 | "*.{js,jsx,vue,ts,tsx}": [ 48 | "w6s-cli-script lint", 49 | "w6s-cli-script lint:style" 50 | ] 51 | }, 52 | "engines": { 53 | "node": ">=10" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 39 | 40 | 41 | 65 | -------------------------------------------------------------------------------- /packages/@w6s/stylelint-plugin/README.md: -------------------------------------------------------------------------------- 1 | # @ascendancyy/vue-cli-plugin-stylelint 2 | 3 | > stylelint plugin for vue-cli 4 | 5 | ## Injected commands 6 | 7 | - **`vue-cli-service lint:style`** 8 | 9 | ``` 10 | Usage: vue-cli-service lint:style [options] [...files] 11 | 12 | Options: 13 | 14 | --no-fix do not auto-fix errors 15 | --options list additional stylelint cli options 16 | ``` 17 | 18 | Lints and fixes files. If no specific files are given, it lints all vue files, html files, and stylesheets in `src`. 19 | 20 | ## Configuration (vue.config.js, "vue" in package.json) 21 | 22 | Lint on (re)build with `stylelint-webpack-plugin` can be enabled with the `lintStyleOnBuild` option. You can also provide additional options to stylelint. See available options on the stylelint [website](https://stylelint.io/user-guide/node-api/#options). 23 | 24 | ``` js 25 | module.exports = { 26 | // ... 27 | pluginOptions: { 28 | lintStyleOnBuild: true, 29 | stylelint: { 30 | fix: true, // boolean (default: true) 31 | files: '', // string | [string] (default: ['src/**/*.{vue,htm,html,css,sss,less,scss}']) 32 | // See https://stylelint.io/developer-guide/formatters/ 33 | formatter: () => {} // function (default: require('stylelint-codeframe-formatter')) 34 | // etc... 35 | } 36 | } 37 | } 38 | ``` 39 | 40 | ## Installing in an already created project 41 | 42 | ``` 43 | npm install -D @ascendancyy/vue-cli-plugin-stylelint 44 | vue invoke @ascendancyy/vue-cli-plugin-stylelint 45 | ``` 46 | 47 | > There is also a shorthand to invoke the plugin 48 | > `vue invoke @ascendancyy/stylelint` 49 | 50 | ## webpack-chain Injections 51 | 52 | - `config.plugin('stylelint')` 53 | - `config.plugin('stylelint').use('stylelint-webpack-plugin')` 54 | - `config.plugin('friendly-errors').tap(/* Adds additional transformer and formatter */)` 55 | -------------------------------------------------------------------------------- /packages/@w6s/cli-script/lib/index.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const Service = require('@vue/cli-service'); 3 | const { toPlugin, w6sConfigFileExists, getRootProjectPlugins } = require('./utils'); 4 | 5 | const babelPlugin = toPlugin('@vue/cli-plugin-babel'); 6 | const eslintPlugin = toPlugin('@vue/cli-plugin-eslint'); 7 | const typeScriptPlugin = toPlugin('@vue/cli-plugin-typescript'); 8 | const vConsolePlugin = toPlugin('@w6s/vconsole-plugin'); 9 | const styleResourcesLoaderPlugin = toPlugin('@w6s/style-resources-loader-plugin'); 10 | const sentryPlugin = toPlugin('@w6s/sentry-plugin'); 11 | const mockPlugin = toPlugin('@w6s/mock-plugin'); 12 | const stylelintPlugin = toPlugin('@w6s/stylelint-plugin'); 13 | const i18nPlugin = toPlugin('vue-cli-plugin-i18n'); 14 | const createFilePlugin = toPlugin('@w6s/create-file-plugin'); 15 | 16 | const context = process.cwd(); 17 | 18 | // w6s.config.js 19 | const configPath = path.resolve(context, 'w6s.config.js'); 20 | if (configPath && w6sConfigFileExists(configPath)) { 21 | process.env.VUE_CLI_SERVICE_CONFIG_PATH = configPath; 22 | } 23 | 24 | const createService = (command) => { 25 | const projectPlugins = getRootProjectPlugins(context) || []; 26 | const inlinePlugins = [ 27 | babelPlugin, 28 | typeScriptPlugin, 29 | vConsolePlugin, 30 | sentryPlugin, 31 | styleResourcesLoaderPlugin, 32 | mockPlugin, 33 | stylelintPlugin, 34 | i18nPlugin, 35 | eslintPlugin, 36 | createFilePlugin, 37 | ...projectPlugins, 38 | ]; 39 | 40 | return new Service(context, { 41 | projectOptions: { 42 | compiler: true, 43 | lintOnSave: 'default', 44 | }, 45 | inlineOptions: { 46 | parallel: false, // disable thread-loader 47 | }, 48 | plugins: inlinePlugins, 49 | }); 50 | }; 51 | 52 | exports.runService = (command, args, rawArgv) => createService(command).run(command, args, rawArgv); 53 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/store/modules/app.ts: -------------------------------------------------------------------------------- 1 | import { 2 | VuexModule, 3 | Module, 4 | Mutation, 5 | Action, 6 | getModule, 7 | } from 'vuex-module-decorators'; 8 | import { getSidebarStatus, setSidebarStatus } from '@/utils/cookies'; 9 | import store from '@/store'; 10 | 11 | export enum DeviceType { 12 | Mobile, 13 | Desktop, 14 | } 15 | 16 | export interface AppState { 17 | device: DeviceType; 18 | sidebar: { 19 | opened: boolean; 20 | withoutAnimation: boolean; 21 | }; 22 | } 23 | 24 | @Module({ dynamic: true, store, name: 'app' }) 25 | class App extends VuexModule implements AppState { 26 | public sidebar = { 27 | opened: getSidebarStatus() !== 'closed', 28 | withoutAnimation: false, 29 | }; 30 | 31 | public device = DeviceType.Desktop; 32 | 33 | @Mutation 34 | private TOGGLE_SIDEBAR(withoutAnimation: boolean) { 35 | this.sidebar.opened = !this.sidebar.opened; 36 | this.sidebar.withoutAnimation = withoutAnimation; 37 | if (this.sidebar.opened) { 38 | setSidebarStatus('opened'); 39 | } else { 40 | setSidebarStatus('closed'); 41 | } 42 | } 43 | 44 | @Mutation 45 | private CLOSE_SIDEBAR(withoutAnimation: boolean) { 46 | this.sidebar.opened = false; 47 | this.sidebar.withoutAnimation = withoutAnimation; 48 | setSidebarStatus('closed'); 49 | } 50 | 51 | @Mutation 52 | private TOGGLE_DEVICE(device: DeviceType) { 53 | this.device = device; 54 | } 55 | 56 | @Action 57 | public ToggleSideBar(withoutAnimation: boolean) { 58 | this.TOGGLE_SIDEBAR(withoutAnimation); 59 | } 60 | 61 | @Action 62 | public CloseSideBar(withoutAnimation: boolean) { 63 | this.CLOSE_SIDEBAR(withoutAnimation); 64 | } 65 | 66 | @Action 67 | public ToggleDevice(device: DeviceType) { 68 | this.TOGGLE_DEVICE(device); 69 | } 70 | } 71 | 72 | export const AppModule = getModule(App); 73 | -------------------------------------------------------------------------------- /docs/DevOps/deploy.md: -------------------------------------------------------------------------------- 1 | # cli-deploy 2 | 3 | 项目发布是项目开发过程中,必不可少的一环。为了简化前端项目资源的部署步骤,避免繁琐的 shell 脚本编写及人为操作,`w6s-cli`根据常见的部署场景,提供了自动化部署的功能,支持开发、测试、生产多环境配置,一键即可自动完成部署。 4 | 5 | [仓库地址](https://github.com/WorkPlusFE/cli/tree/master/packages/%40w6s/cli-deploy) 6 | 7 | 8 | ## 安装 9 | 10 | 要使用发布功能,可以单独安装`@w6s/cli-deploy`,或者使用`w6s-cli`提供的`deploy`命令。 11 | 12 | 安装`@w6s/cli-deploy`: 13 | 14 | ```bash 15 | yarn global add @w6s/cli-deploy 16 | # or 17 | npm install -g @w6s/cli-deploy 18 | ``` 19 | 20 | ## 初始化配置文件 21 | 22 | 安装成功后,执行以下命令: 23 | 24 | ```bash 25 | w6s-cli-deploy init 26 | ``` 27 | 28 | 执行初始化命令后,会在当前目录生成`deploy.config.js`配置文件,具体配置内容和说明如下: 29 | 30 | ```js 31 | module.exports = { 32 | envConfig: { 33 | // 名为 dev 的环境配置 34 | dev: { 35 | host: "192.168.0.1", 36 | port: 22, 37 | username: "root", 38 | password: "123456", 39 | distPath: "dist", 40 | uploadPath: "/home/workplus", 41 | privateKey: "", 42 | passphrase: "", 43 | preCommand: "npm run build", 44 | }, 45 | }, 46 | }; 47 | ``` 48 | 49 | 所有的环境配置,都应添加到`envConfig`中,你可以根据实际情况,添加多个不同的环境配置。 50 | 51 | 以下为一个环境中可配置的所有字段的说明: 52 | 53 | - `host` 54 | 55 | 服务器地址,如 192.168.0.1 56 | 57 | - `port` 58 | 59 | ssh 的端口,一般默认 22 60 | 61 | - `username` 62 | 63 | 用户名,如 root 64 | 65 | - `password` 66 | 67 | 服务器密码,非必须,执行部署命令可以手动输入以确保信息安全 68 | 69 | - `uploadPath` 70 | 71 | 要部署到服务器的目录路径,应为绝对路径 72 | 73 | - `privateKey` 74 | 75 | 本地私钥地址,应为绝对路径,非必填;若有值,将会带密钥的方式进行 ssh 链接,否则使用账号密码的方式 76 | 77 | - `passphrase` 78 | 79 | 对应私钥的密码,非必须,可为空 80 | 81 | - `preCommand` 82 | 83 | 发布前需执行的命令,非必须 84 | 85 | - `distPath` 86 | 87 | 本地待上传的文件目录 88 | 89 | ## 自动化部署 90 | 91 | `@w6s/cli-deploy`支持多环境发布,使用`deploy`命令,传入 env 环境名字,一键自动发布。 92 | 93 | ```sh 94 | w6s-cli-deploy deploy --env <环境名称> 95 | ``` 96 | 97 | 例如发布到上方 dev 环境,执行以下命令即可: 98 | 99 | ```sh 100 | w6s-cli-deploy deploy --env dev 101 | ``` -------------------------------------------------------------------------------- /packages/@w6s/cli-script/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w6s/cli-script", 3 | "version": "1.2.4", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "bin": { 7 | "w6s-cli-script": "bin/cli-script.js" 8 | }, 9 | "author": "WorkPlusFE", 10 | "dependencies": { 11 | "@commitlint/cli": "^8.3.5", 12 | "@commitlint/config-conventional": "^8.3.4", 13 | "@types/node": "10.17.32", 14 | "@types/webpack": "^4.41.13", 15 | "@types/webpack-env": "^1.15.2", 16 | "@typescript-eslint/eslint-plugin": "^2.30.0", 17 | "@typescript-eslint/parser": "^2.30.0", 18 | "@vue/cli-plugin-babel": "^4.3.1", 19 | "@vue/cli-plugin-eslint": "^4.3.1", 20 | "@vue/cli-plugin-typescript": "^4.3.1", 21 | "@vue/cli-service": "^4.3.1", 22 | "@vue/eslint-config-airbnb": "^5.0.2", 23 | "@vue/eslint-config-prettier": "^6.0.0", 24 | "@vue/eslint-config-typescript": "^5.0.2", 25 | "@w6s/cli-shared-utils": "^1.2.2", 26 | "@w6s/create-file-plugin": "^1.1.4", 27 | "@w6s/eslint-config": "^1.1.1", 28 | "@w6s/mock-plugin": "^1.2.2", 29 | "@w6s/sentry-plugin": "^1.2.2", 30 | "@w6s/style-resources-loader-plugin": "^1.2.0", 31 | "@w6s/stylelint-config": "^1.1.0", 32 | "@w6s/stylelint-plugin": "^1.2.0", 33 | "@w6s/vconsole-plugin": "^1.2.0", 34 | "babel-plugin-component": "^1.1.1", 35 | "babel-plugin-import": "^1.13.0", 36 | "eslint": "^6.8.0", 37 | "eslint-plugin-import": "^2.20.2", 38 | "eslint-plugin-prettier": "^3.1.3", 39 | "eslint-plugin-vue": "^6.2.2", 40 | "husky": "^4.2.5", 41 | "lint-staged": "^10.2.4", 42 | "minimist": "^1.2.5", 43 | "prettier": "^2.0.5", 44 | "sass": "^1.32.8", 45 | "sass-loader": "^8.0.2", 46 | "stylelint": "^13.5.0", 47 | "stylelint-scss": "^3.17.2", 48 | "typescript": "^3.8.3", 49 | "vue-cli-plugin-i18n": "^1.0.1", 50 | "vue-template-compiler": "^2.6.12", 51 | "webpack": "^4.43.0" 52 | }, 53 | "publishConfig": { 54 | "access": "public" 55 | }, 56 | "engines": { 57 | "node": ">=10" 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /packages/@w6s/create-file-plugin/index.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const CreateFileWebpack = require('create-file-webpack'); 3 | const GitRevisionPlugin = require('git-revision-webpack-plugin'); 4 | const CopyFilePlugin = require('copy-webpack-plugin'); 5 | const { logger, isProd } = require('@w6s/cli-shared-utils'); 6 | const isGit = require('is-git-repository'); 7 | 8 | const getGitMessage = () => { 9 | try { 10 | if (!isGit()) { 11 | console.log(''); 12 | logger.info(' 当前为非 Git 项目!'); 13 | return {}; 14 | }; 15 | 16 | const gitRevision = new GitRevisionPlugin(); 17 | const BRANCH_NAME = gitRevision.branch(); 18 | const COMMIT_HASH = gitRevision.commithash(); 19 | 20 | return { BRANCH_NAME, COMMIT_HASH }; 21 | } catch (error) { 22 | logger.error(error); 23 | return {}; 24 | } 25 | }; 26 | 27 | const rootPath = process.cwd(); 28 | 29 | const setupCreateFilePlugin = (envObj, fileName, outputDir) => { 30 | const gitMessage = getGitMessage(); 31 | const baseConfigInfo = { 32 | PACK_TIME: new Date().toLocaleString(), 33 | ...gitMessage, 34 | }; 35 | 36 | const vueEnvObj = {}; 37 | for (const prop in envObj) { 38 | if (prop.includes('VUE_APP_')) { 39 | vueEnvObj[prop] = envObj[prop]; 40 | } 41 | } 42 | 43 | return new CreateFileWebpack({ 44 | path: outputDir, 45 | fileName, 46 | content: JSON.stringify({ ...baseConfigInfo, ...vueEnvObj }), 47 | }); 48 | }; 49 | 50 | module.exports = (api, projectOptions) => { 51 | if (!isProd()) return; 52 | 53 | const outputDir = projectOptions.outputDir || 'dist'; 54 | const opts = projectOptions.pluginOptions.outputConfigFile || {}; 55 | const fileName = opts.fileName || 'config.json'; 56 | const descriptionFile = opts.descriptionFile || 'DEPLOY.md'; 57 | 58 | api.configureWebpack((webpackConfig) => { 59 | webpackConfig.plugins.push( 60 | setupCreateFilePlugin(process.env, fileName, outputDir), 61 | // 文件默认输出到 output 目录 62 | new CopyFilePlugin([ 63 | { 64 | from: `${descriptionFile}`, 65 | }, 66 | ]) 67 | ); 68 | }); 69 | }; 70 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/layout/index.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 40 | 41 | 97 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "workspaces": { 4 | "packages": [ 5 | "packages/@w6s/*", 6 | "packages/test/*" 7 | ] 8 | }, 9 | "scripts": { 10 | "lint": "eslint --fix packages/**/*.js packages/**/bin/*", 11 | "lint-without-fix": "eslint packages/**/*.js packages/**/bin/*", 12 | "test": "jest", 13 | "docs:dev": "vuepress dev docs", 14 | "docs:build": "vuepress build docs", 15 | "docs:deploy": "./scripts/deploy.sh", 16 | "release": "lerna publish --no-commit-hooks", 17 | "release:force": "lerna publish --no-commit-hooks --force-publish" 18 | }, 19 | "gitHooks": { 20 | "pre-commit": "lint-staged", 21 | "commit-msg": "node scripts/verifyCommitMsg.js" 22 | }, 23 | "lint-staged": { 24 | "*.{js}": [ 25 | "eslint --fix", 26 | "git add" 27 | ], 28 | "packages/**/bin/*": [ 29 | "eslint --fix", 30 | "git add" 31 | ] 32 | }, 33 | "jest": { 34 | "testEnvironment": "node", 35 | "setupFiles": [], 36 | "testMatch": [ 37 | "**/__tests__/**/*.spec.js" 38 | ] 39 | }, 40 | "dependencies": { 41 | "vue": "2.6.12", 42 | "vue-server-renderer": "2.6.12", 43 | "vuepress-theme-default-prefers-color-scheme": "^2.0.0" 44 | }, 45 | "devDependencies": { 46 | "chalk": "^4.0.0", 47 | "eslint": "6.8.0", 48 | "eslint-config-airbnb-base": "14.1.0", 49 | "eslint-config-prettier": "^6.11.0", 50 | "eslint-plugin-import": "^2.20.1", 51 | "eslint-plugin-node": "^11.1.0", 52 | "jest": "^25.4.0", 53 | "lerna": "^3.20.2", 54 | "lerna-changelog": "^1.0.1", 55 | "lint-staged": "^10.1.7", 56 | "vuepress": "^1.7.1", 57 | "yorkie": "^2.0.0" 58 | }, 59 | "preferGlobal": true, 60 | "publishConfig": { 61 | "access": "public" 62 | }, 63 | "repository": { 64 | "type": "git", 65 | "url": "git+https://github.com/WorkPlusFE/w6s-cli.git" 66 | }, 67 | "keywords": [ 68 | "cli", 69 | "workplus-cli", 70 | "w6s-cli", 71 | "workplus", 72 | "w6s" 73 | ], 74 | "author": "WorkPlusFE", 75 | "license": "MIT", 76 | "bugs": { 77 | "url": "https://github.com/WorkPlusFE/w6s-cli/issues" 78 | }, 79 | "homepage": "https://github.com/WorkPlusFE/w6s-cli#readme", 80 | "engines": { 81 | "node": ">=10" 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/layout/components/Sidebar/index.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 59 | 60 | 86 | 87 | 98 | -------------------------------------------------------------------------------- /docs/.vuepress/config.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | 4 | const postPath = path.resolve(__dirname, '../post'); 5 | 6 | function getPostFileList() { 7 | try { 8 | const files = fs.readdirSync(postPath, 'utf-8'); 9 | const getNumber = (name) => name.split('-').shift(); 10 | return files.filter(file => file !== 'README.md').sort((a, b) => getNumber(a) < getNumber(b)); 11 | } catch (error) { 12 | console.log(error); 13 | return []; 14 | } 15 | } 16 | 17 | module.exports = { 18 | title: 'FED', 19 | base: '/dev/', 20 | head: [ 21 | ['link', { rel: 'icon', href: '/favicon.ico' }], 22 | ], 23 | theme: 'default-prefers-color-scheme', 24 | themeConfig: { 25 | overrideTheme: { light: [6, 18], dark: [18, 6] }, 26 | logo: '/logo.png', 27 | displayAllHeaders: true, 28 | nav: [ 29 | { text: '项目创建', link: '/' }, 30 | { text: 'DevOps', link: '/DevOps/' }, 31 | { text: '工具/库', link: '/packages' }, 32 | { text: '文章', link: '/post/' }, 33 | { text: '常见问题', link: '/qa' }, 34 | { 35 | text: '其他', 36 | items: [ 37 | { text: '开放平台', link: 'https://open.workplus.io/v4/' }, 38 | { text: 'Cordova 文档', link: 'https://open.workplus.io/cordova/' }, 39 | { text: 'GitHub', link: 'https://github.com/WorkPlusFE/' }, 40 | ] 41 | }, 42 | ], 43 | sidebar: { 44 | '/DevOps/': [ 45 | { 46 | title: '开发与发布', 47 | collapsable: false, 48 | sidebarDepth: 2, 49 | children: [ 50 | '', 51 | 'deploy', 52 | ] 53 | }, { 54 | title: '日志埋点', 55 | collapsable: false, 56 | sidebarDepth: 2, 57 | children: [ 58 | 'sentry', 59 | ] 60 | }, { 61 | title: '持续集成', 62 | collapsable: false, 63 | sidebarDepth: 2, 64 | children: [ 65 | 'jenkins', 66 | ] 67 | } 68 | ], 69 | '/post/': [ 70 | { 71 | title: '团队文章', 72 | collapsable: false, 73 | sidebarDepth: 0, 74 | children: getPostFileList() 75 | } 76 | ] 77 | }, 78 | lastUpdated: '最后更新时间', 79 | search: false, 80 | 81 | docsRepo: 'WorkPlusFE/cli', 82 | docsDir: 'docs', 83 | docsBranch: 'master', 84 | editLinks: true, 85 | editLinkText: '帮助 WorkPlusFE 改善此页面!' 86 | }, 87 | } -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/views/About.vue: -------------------------------------------------------------------------------- 1 | 31 | 32 | 87 | 88 | 97 | -------------------------------------------------------------------------------- /packages/@w6s/cli/lib/executeCommand.js: -------------------------------------------------------------------------------- 1 | // @vue/cli executeCommand.js 2 | const execa = require('execa'); 3 | const EventEmitter = require('events'); 4 | const readline = require('readline'); 5 | 6 | class InstallProgress extends EventEmitter { 7 | constructor () { 8 | super(); 9 | 10 | this._progress = -1; 11 | } 12 | 13 | get progress () { 14 | return this._progress; 15 | } 16 | 17 | set progress (value) { 18 | this._progress = value; 19 | this.emit('progress', value); 20 | } 21 | 22 | get enabled () { 23 | return this._progress !== -1; 24 | } 25 | 26 | set enabled (value) { 27 | this.progress = value ? 0 : -1; 28 | } 29 | 30 | log (value) { 31 | this.emit('log', value); 32 | } 33 | } 34 | 35 | function toStartOfLine (stream) { 36 | readline.cursorTo(stream, 0); 37 | } 38 | 39 | function renderProgressBar (curr, total) { 40 | const ratio = Math.min(Math.max(curr / total, 0), 1); 41 | const bar = ` ${curr}/${total}`; 42 | const availableSpace = Math.max(0, process.stderr.columns - bar.length - 3); 43 | const width = Math.min(total, availableSpace); 44 | const completeLength = Math.round(width * ratio); 45 | const complete = `#`.repeat(completeLength); 46 | const incomplete = `-`.repeat(width - completeLength); 47 | toStartOfLine(process.stderr); 48 | process.stderr.write(`[${complete}${incomplete}]${bar}`); 49 | } 50 | 51 | /* eslint no-multi-assign:0 */ 52 | const progress = exports.progress = new InstallProgress(); 53 | exports.executeCommand = function executeCommand (command, args, cwd) { 54 | 55 | return new Promise((resolve, reject) => { 56 | progress.enabled = false; 57 | 58 | const child = execa(command, args, { 59 | cwd, 60 | stdio: ['inherit', 'inherit', command === 'yarn' ? 'pipe' : 'inherit'] 61 | }); 62 | 63 | if (command === 'yarn') { 64 | child.stderr.on('data', (buf) => { 65 | const str = buf.toString(); 66 | if (/warning/.test(str)) { 67 | return; 68 | } 69 | 70 | // progress bar 71 | const progressBarMatch = str.match(/\[.*\] (\d+)\/(\d+)/); 72 | if (progressBarMatch) { 73 | // since yarn is in a child process, it's unable to get the width of 74 | // the terminal. reimplement the progress bar ourselves! 75 | renderProgressBar(progressBarMatch[1], progressBarMatch[2]); 76 | return; 77 | } 78 | 79 | process.stderr.write(buf); 80 | }) 81 | } 82 | 83 | child.on('close', (code) => { 84 | if (code !== 0) { 85 | /* eslint prefer-promise-reject-errors:0 */ 86 | reject(`command failed: ${command} ${args.join(' ')}`); 87 | return; 88 | } 89 | resolve(); 90 | }) 91 | }) 92 | } 93 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/layout/components/Navbar/index.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 40 | 41 | 120 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/admin/template/src/components/Breadcrumb/index.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 79 | 80 | 98 | -------------------------------------------------------------------------------- /docs/DevOps/README.md: -------------------------------------------------------------------------------- 1 | # w6s-cli 2 | 3 | npm 4 | 5 | `@w6s/cli`是团队内部指定使用的 cli 工具,除了用于快速创建项目初始架构,还包含一些常用的功能,例如启动静态文件服务、设置配置等。 6 | 7 | ## 安装 8 | 9 | 环境要求: 10 | 11 | * Node.js 版本 >=10 12 | * [Yarn](https://yarnpkg.com/) (推荐使用) / npm 13 | 14 | > 使用 Yarn 的理由:性能更好,使用更方便 15 | 16 | 通过以下命令进行安装: 17 | 18 | ```bash 19 | yarn global add @w6s/cli 20 | # or 21 | npm install -g @w6s/cli 22 | ``` 23 | 24 | 安装成功后,在 shell 中键入`w6s`,即可看到相关功能说明,如下: 25 | 26 | 27 | ```bash 28 | Usage: w6s [options] 29 | 30 | Options: 31 | -V, --version output the version number 32 | -h, --help display help for command 33 | 34 | Commands: 35 | init create a new project 36 | serve http-server like, start a local static server 37 | deploy automatically publish front-end resources 38 | set-mirror set NPM or Yarn mirrors to Taobao sources, such as electron, node-sass 39 | qrcode draw QRcode in terminal window 40 | env print debugging information about your environment 41 | help [command] display help for command 42 | ``` 43 | 44 | ## 项目创建 45 | 46 | 通过`w6s init`命令,可快速创建内置项目架构,包括轻应用的`移动端H5轻应用项目`及通用的管理后台`管理后台项目`: 47 | 48 | ```bash 49 | ? 请选择项目类型 (Use arrow keys) 50 | ❯ 管理后台项目 51 | 移动端H5轻应用项目 52 | ``` 53 | 54 | 项目模版的详细说明,请查看[项目创建](/)栏目。 55 | 56 | ## 文件静态服务 57 | 58 | 用于启动一个静态文件服务,常用于应用打包后的本地调试。 59 | 60 | 该功能是集成了[serve](https://github.com/vercel/serve#readme)模块,详细使用方法,可通过输入`w6s serve --help`进行查看。 61 | 62 | ## 资源发布 63 | 64 | w6s-cli 集成了`@w6s/cli-deploy`的功能,详细说明文档,请查看[cli-deploy](/DevOps/deploy.html)。 65 | 66 | ## 设置源 67 | 68 | 通过使用`w6s set-mirror`命令,可以对`Yarn`和`NPM`包管理器设置 mirror,如下: 69 | 70 | ```bash 71 | ? 请选择包管理器 Yarn 72 | ? 请选择需要设置源的工具或库 (Press to select, to toggle all, to invert selection) 73 | ❯◉ taobao-mirror 74 | ◉ node-sass 75 | ◯ node-gyp 76 | ◯ electron 77 | ◯ puppeteer 78 | ◯ chromedriver 79 | ◯ operadriver 80 | ◯ phantomjs 81 | ◯ selenium 82 | ◯ node-inspector 83 | ``` 84 | 85 | 可以重复设置,若需要删除,请自行在相关配置文件编辑处理。 86 | 87 | ## 生成二维码 88 | 89 | 用于生成二维码,例如一个应用的访问地址,通过输入`ws6 qrcode `,即可在 shell 上生成二维码,方便手机扫码调试。 90 | 91 | 详细使用方法,可通过输入`w6s qrcode --help`进行查看。 92 | 93 | ## 显示环境配置 94 | 95 | 输出当前设备的一些软件或工具的版本信息,例如: 96 | 97 | ```bash 98 | Environment Info: 99 | 100 | System: 101 | OS: macOS 10.15.4 102 | CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz 103 | Binaries: 104 | Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node 105 | Yarn: 1.22.4 - ~/.nvm/versions/node/v10.16.0/bin/yarn 106 | npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm 107 | Browsers: 108 | Chrome: 85.0.4183.102 109 | Edge: Not Found 110 | Firefox: 57.0 111 | Safari: 13.1 112 | ``` 113 | -------------------------------------------------------------------------------- /packages/@w6s/cli/bin/w6s-set-mirror: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('colors'); 4 | 5 | const execa = require('execa'); 6 | const inquirer = require('inquirer'); 7 | const { hasYarn, logger } = require('@w6s/cli-shared-utils'); 8 | const mirror = require('../lib/mirror'); 9 | const cons = require('consolidate'); 10 | 11 | const getPackageType = () => { 12 | const message = '请选择包管理器'; 13 | const choices = [{ name: 'NPM', checked: false }]; 14 | 15 | if (hasYarn()) { 16 | choices.unshift({ name: 'Yarn', checked: true }); 17 | } else { 18 | choices[0].checked = true; 19 | console.log(''); 20 | logger.info('亲,这边建议你使用 Yarn 包管理工具喔!:)\n'); 21 | } 22 | 23 | return inquirer.prompt([{ 24 | type: 'checkbox', 25 | message, 26 | choices, 27 | name: 'answer', 28 | default: { 29 | checked: true, 30 | }, 31 | validate: function (input) { 32 | const done = this.async(); 33 | if (input.length === 0) { 34 | done('至少选择一种!'); 35 | return; 36 | } 37 | done(null, true); 38 | } 39 | }]).then((answers) => { 40 | if (answers.answer) return answers.answer; 41 | return process.exit(1); 42 | }); 43 | }; 44 | 45 | const selectMirror = (packages) => { 46 | const message = '请选择需要设置源的工具或库'; 47 | const mirrors = [ 48 | { 49 | name: 'taobao-mirror', 50 | checked: true, 51 | }, 52 | { 53 | name: 'node-sass', 54 | checked: true, 55 | }, 56 | 'node-gyp', 57 | 'electron', 58 | 'puppeteer', 59 | 'chromedriver', 60 | 'operadriver', 61 | 'phantomjs', 62 | 'selenium', 63 | 'node-inspector' 64 | ]; 65 | 66 | return inquirer.prompt([{ 67 | type: 'checkbox', 68 | choices: mirrors, 69 | name: 'answer', 70 | message, 71 | pageSize: 10, 72 | validate: function (input) { 73 | const done = this.async(); 74 | if (input.length === 0) { 75 | done('至少选择一种!'); 76 | return; 77 | } 78 | done(null, true); 79 | } 80 | }]).then((answers) => { 81 | if (answers.answer) return answers.answer; 82 | return process.exit(1); 83 | }); 84 | }; 85 | 86 | const setAllMirrors = (packages, mirrors) => { 87 | packages.forEach(package => { 88 | console.log(''); 89 | const shells = mirror.getMirrorByType(package, mirrors); 90 | shells.forEach(shell => { 91 | execa.command(shell); 92 | console.log(`${shell}`.green); 93 | }); 94 | }); 95 | }; 96 | 97 | try { 98 | async function setMirror() { 99 | const packages = await getPackageType(); 100 | const mirrors = await selectMirror(); 101 | 102 | setAllMirrors(packages, mirrors); 103 | 104 | console.log(''); 105 | logger.done(`🚀 Done, enjoy the speed! \n`); 106 | }; 107 | 108 | setMirror(); 109 | } catch (error) { 110 | console.log(error); 111 | process.exit(1); 112 | } 113 | -------------------------------------------------------------------------------- /packages/@w6s/cli/templates/H5/template/src/utils/http/https.ts: -------------------------------------------------------------------------------- 1 | import axios, { AxiosResponse } from 'axios'; 2 | 3 | const service = axios.create({ 4 | timeout: 5000, 5 | }); 6 | 7 | // Request interceptors 8 | service.interceptors.request.use( 9 | (config) => config, 10 | (error) => { 11 | Promise.reject(error); 12 | }, 13 | ); 14 | 15 | // Response interceptors 16 | service.interceptors.response.use( 17 | (response) => response.data, 18 | (error) => Promise.reject(error), 19 | ); 20 | 21 | /** 22 | * 请求接口传参处理 23 | * @param params 请求接口的传参 24 | */ 25 | export function handleData(params: T): T { 26 | const data = Object.create(null); 27 | // 过滤掉空传参 (undefined || '' || null) 28 | Object.keys(params).forEach((k) => { 29 | if (params[k] !== undefined || params[k] !== null || String(params[k]) !== '') { 30 | data[k] = params[k]; 31 | } 32 | }); 33 | return data; 34 | } 35 | 36 | /** 37 | * Get请求 38 | * @export 39 | * @template T 40 | * @param {string} url 接口地址 41 | * @param {Common.PlainObject} [params={}] 接口传参 42 | * @param {boolean} [cache=false] 43 | * @returns {Promise>} 44 | */ 45 | export function apiGet( 46 | url: string, 47 | params: Common.PlainObject = {}, 48 | headers: Common.PlainObject = {}, 49 | ): Promise> { 50 | return service 51 | .get(url, { params, headers }) 52 | .then((res) => res) 53 | .catch((err) => { 54 | throw err; 55 | }); 56 | } 57 | 58 | /** 59 | * Post请求 60 | * @export 61 | * @template T 62 | * @param {string} url 接口地址 63 | * @param {Common.PlainObject} [params={}] 接口传参 64 | * @returns {Promise>} 65 | */ 66 | export function apiPost( 67 | url: string, 68 | params: Common.PlainObject = {}, 69 | headers: Common.PlainObject = {}, 70 | ): Promise> { 71 | const param = handleData(params); 72 | return service 73 | .post(url, param, { headers }) 74 | .then((res) => res) 75 | .catch((err) => { 76 | throw err; 77 | }); 78 | } 79 | 80 | /** 81 | * Put请求 82 | * @export 83 | * @template T 84 | * @param {string} url 接口地址 85 | * @param {Common.PlainObject} [params={}] 接口传参 86 | * @returns {Promise>} 87 | */ 88 | export function apiPut( 89 | url: string, 90 | params: Common.PlainObject = {}, 91 | headers: Common.PlainObject = {}, 92 | ): Promise> { 93 | const param = handleData(params); 94 | return service 95 | .put(url, param, { headers }) 96 | .then((res) => res) 97 | .catch((err) => { 98 | throw err; 99 | }); 100 | } 101 | 102 | /** 103 | * Delete请求 104 | * @export 105 | * @template T 106 | * @param {string} url 接口地址 107 | * @param {Common.PlainObject} [params={}] 接口传参 108 | * @returns {Promise>} 109 | */ 110 | export function apiDelete( 111 | url: string, 112 | params: Common.PlainObject = {}, 113 | headers: Common.PlainObject = {}, 114 | ): Promise> { 115 | const param = handleData(params); 116 | return service 117 | .put(url, param, { headers }) 118 | .then((res) => res) 119 | .catch((err) => { 120 | throw err; 121 | }); 122 | } 123 | 124 | export default service; 125 | -------------------------------------------------------------------------------- /.github/COMMIT_CONVENTION.md: -------------------------------------------------------------------------------- 1 | ## Git Commit Message Convention 2 | 3 | > This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular). 4 | 5 | #### TL;DR: 6 | 7 | Messages must be matched by the following regex: 8 | 9 | ``` js 10 | /^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|ci|chore|types)(\(.+\))?: .{1,50}/ 11 | ``` 12 | 13 | #### Examples 14 | 15 | Appears under "Features" header, `compiler` subheader: 16 | 17 | ``` 18 | feat(compiler): add 'comments' option 19 | ``` 20 | 21 | Appears under "Bug Fixes" header, `v-model` subheader, with a link to issue #28: 22 | 23 | ``` 24 | fix(v-model): handle events on blur 25 | 26 | close #28 27 | ``` 28 | 29 | Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation: 30 | 31 | ``` 32 | perf(core): improve vdom diffing by removing 'foo' option 33 | 34 | BREAKING CHANGE: The 'foo' option has been removed. 35 | ``` 36 | 37 | The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header. 38 | 39 | ``` 40 | revert: feat(compiler): add 'comments' option 41 | 42 | This reverts commit 667ecc1654a317a13331b17617d973392f415f02. 43 | ``` 44 | 45 | ### Full Message Format 46 | 47 | A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: 48 | 49 | ``` 50 | (): 51 | 52 | 53 | 54 |