├── .commitlintrc.json
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── meta.js
├── package-lock.json
├── package.json
├── release.config.js
└── template
├── .DS_Store
├── .babelrc
├── .commitlintrc.json
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .github
├── CODE_OF_CONDUCT.md
├── COMMIT_CONVENTION.md
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE.md
└── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── .npmignore
├── .nvmrc
├── .storybook
├── config.js
└── webpack.config.js
├── LICENSE.md
├── README.md
├── jest.config.js
├── jest.setup.js
├── package.json
├── rollup.config.js
├── src
├── __tests__
│ └── index.js
├── components
│ ├── HelloWorld.vue
│ └── __tests__
│ │ ├── HelloWorld.js
│ │ └── __snapshots__
│ │ └── HelloWorld.js.snap
├── index.js
└── index.umd.js
└── stories
└── index.stories.js
/.commitlintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "@commitlint/config-conventional"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.gitignore.io/api/node,visualstudiocode
2 |
3 | ### Node ###
4 | # Logs
5 | logs
6 | *.log
7 | npm-debug.log*
8 | yarn-debug.log*
9 | yarn-error.log*
10 |
11 | # Runtime data
12 | pids
13 | *.pid
14 | *.seed
15 | *.pid.lock
16 |
17 | # Directory for instrumented libs generated by jscoverage/JSCover
18 | lib-cov
19 |
20 | # Coverage directory used by tools like istanbul
21 | coverage
22 |
23 | # nyc test coverage
24 | .nyc_output
25 |
26 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
27 | .grunt
28 |
29 | # Bower dependency directory (https://bower.io/)
30 | bower_components
31 |
32 | # node-waf configuration
33 | .lock-wscript
34 |
35 | # Compiled binary addons (http://nodejs.org/api/addons.html)
36 | build/Release
37 |
38 | # Dependency directories
39 | node_modules/
40 | jspm_packages/
41 |
42 | # Typescript v1 declaration files
43 | typings/
44 |
45 | # Optional npm cache directory
46 | .npm
47 |
48 | # Optional eslint cache
49 | .eslintcache
50 |
51 | # Optional REPL history
52 | .node_repl_history
53 |
54 | # Output of 'npm pack'
55 | *.tgz
56 |
57 | # Yarn Integrity file
58 | .yarn-integrity
59 |
60 | # dotenv environment variables file
61 | .env
62 |
63 | # Generated code
64 | dist/
65 |
66 | ### VisualStudioCode ###
67 | .vscode/*
68 | !.vscode/settings.json
69 | !.vscode/tasks.json
70 | !.vscode/launch.json
71 | !.vscode/extensions.json
72 |
73 | # End of https://www.gitignore.io/api/node,visualstudiocode
74 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | cache:
3 | directories:
4 | - ~/.npm
5 | notifications:
6 | email: false
7 | node_js:
8 | - '9'
9 | - '8'
10 | after_success:
11 | - npm install -g travis-deploy-once@4
12 | - travis-deploy-once "npm run semantic-release"
13 | branches:
14 | except:
15 | - /^v\d+\.\d+\.\d+$/
16 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 | ## [1.2.2](https://github.com/julon/vue-cli-template-library/compare/v1.2.1...v1.2.2) (2018-03-10)
3 |
4 |
5 | ### Bug Fixes
6 |
7 | * add release.config.js ([e2af552](https://github.com/julon/vue-cli-template-library/commit/e2af552))
8 |
9 |
10 | ## [1.2.1](https://github.com/julon/vue-cli-template-library/compare/6a11b7671e6a07a4d366cc67da987aab790b7c94...v1.2.1) (2018-01-19)
11 |
12 |
13 | ### Bug Fixes
14 |
15 | * add dependencies property test ([47a2ef1](https://github.com/julon/vue-cli-template-library/commit/47a2ef1))
16 | * replace globals func by assign to merge obj ([f7c316f](https://github.com/julon/vue-cli-template-library/commit/f7c316f))
17 |
18 |
19 | # [1.2.0](https://github.com/julon/vue-cli-template-library/compare/e24dbfe0b5a1876dc89f9f06839896d59eb84310...v1.2.0) (2018-01-19)
20 |
21 |
22 | ### Bug Fixes
23 |
24 | * using npm instead of yarn in scripts ([6a11b76](https://github.com/julon/vue-cli-template-library/commit/6a11b76))
25 |
26 |
27 | ### Features
28 |
29 | * **build:** add globals and externals ([586aa9a](https://github.com/julon/vue-cli-template-library/commit/586aa9a))
30 |
31 |
32 | ## [1.1.7](https://github.com/julon/vue-cli-template-library/compare/86901db27f73f731cd78cebee06c8b64b1a58ca3...v1.1.7) (2018-01-17)
33 |
34 |
35 | ### Bug Fixes
36 |
37 | * **package:** bump packages versions in template ([e24dbfe](https://github.com/julon/vue-cli-template-library/commit/e24dbfe))
38 |
39 |
40 | ## [1.1.6](https://github.com/julon/vue-cli-template-library/compare/e14a2478feb6d99ec84af52d07f3a07969672c97...v1.1.6) (2018-01-11)
41 |
42 |
43 | ### Bug Fixes
44 |
45 | * remove unused alias @ support ([86901db](https://github.com/julon/vue-cli-template-library/commit/86901db))
46 |
47 |
48 | ## [1.1.5](https://github.com/julon/vue-cli-template-library/compare/83a77e09b49e970f1047a446636fcee0511a6cc7...v1.1.5) (2018-01-10)
49 |
50 |
51 | ### Bug Fixes
52 |
53 | * add complete message in meta and update docs ([e14a247](https://github.com/julon/vue-cli-template-library/commit/e14a247))
54 |
55 |
56 | ## [1.1.4](https://github.com/julon/vue-cli-template-library/compare/fd1640fff063d04b578e56b98213dc125376cfea...v1.1.4) (2018-01-09)
57 |
58 |
59 | ### Bug Fixes
60 |
61 | * update license.md ([83a77e0](https://github.com/julon/vue-cli-template-library/commit/83a77e0))
62 |
63 |
64 | ## [1.1.3](https://github.com/julon/vue-cli-template-library/compare/e4fca996214f63c26a6cb3b717d75aa79306b0b8...v1.1.3) (2018-01-08)
65 |
66 |
67 | ### Bug Fixes
68 |
69 | * change regex of jest transform ([fd1640f](https://github.com/julon/vue-cli-template-library/commit/fd1640f))
70 |
71 |
72 | ## [1.1.2](https://github.com/julon/vue-cli-template-library/compare/b35a4c70d94d8775410c5d7494feba75c95f901b...v1.1.2) (2018-01-07)
73 |
74 |
75 | ### Bug Fixes
76 |
77 | * move documentation to Contributing.md ([e4fca99](https://github.com/julon/vue-cli-template-library/commit/e4fca99))
78 |
79 |
80 | ## [1.1.1](https://github.com/julon/vue-cli-template-library/compare/42189801ce39fe4ff74ab05c1ccc9ff257996ce7...v1.1.1) (2018-01-07)
81 |
82 |
83 | ### Bug Fixes
84 |
85 | * Update the README ([b35a4c7](https://github.com/julon/vue-cli-template-library/commit/b35a4c7))
86 |
87 |
88 | # [1.1.0](https://github.com/julon/vue-cli-template-library/compare/572e2ff82c6e7b9a41582cf3fbef971bd47e89a2...v1.1.0) (2018-01-07)
89 |
90 |
91 | ### Features
92 |
93 | * Update the README ([4218980](https://github.com/julon/vue-cli-template-library/commit/4218980))
94 |
95 |
96 | # 1.0.0 (2018-01-07)
97 |
98 |
99 | ### Features
100 |
101 | * add vue-lib-template files ([71e72ef](https://github.com/julon/vue-lib-template/commit/71e72ef))
102 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright 2017 Julon Lou
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-cli-template-library
2 | 
3 | [](https://github.com/semantic-release/semantic-release)
4 | 
5 | 
6 | [](https://greenkeeper.io/)
7 |
8 | > Template for developing open-source vue.js libraries
9 |
10 | > You fell in love with Vue.js and want to create your own unit-tested and documented library to share with everyone but you don't want to spend the whole time set things up? This template is for you! It will take care of managing versioning and publishing to github and npm automatically, so you just need to focus on commiting your pieces of code. Packed with best-practices stuff(linters, preprocessors..) and publishable skeleton.
11 |
12 | > Rollup + Jest + Babel + Storybook + TravisCI + SemanticRelease + ❤️
13 |
14 | ## Usage
15 |
16 | ```bash
17 | $ npm install -g vue-cli
18 | $ vue init julon/vue-cli-template-library my-project
19 | $ cd my-project
20 | $ npm install
21 | $ npm run storybook
22 | ```
23 |
24 | ## What's included
25 |
26 | * `npm run build` : Production-ready build.
27 | * Export to CommonJS, ES Modules, UMD(dev & minified)
28 | * CSS is embedded in the JS by default
29 | * Using Rollup to compute Vue, ES6 js files
30 | * Pugjs and Stylus supported in vue files
31 | * `npm run storybook` : The UI Development Environment
32 | * Based on webpack
33 | * Pre-configured to work out of the box
34 | * `npm run test` : eslint & Unit-test with Jest
35 | * Supports ES2015+ in test files
36 | * Use `npm run test:watch` to start Jest in watch-mode
37 | * Use `npm run test:update` to start Jest and update component snapshot
38 | * `npm run lint`
39 | * Rules based on prettier:recommended, vue:recommended
40 | * Import errors and warning detection
41 | * Use `npm run lint:fix` to fix eslint errors
42 | * `npm run cz` : Commitizen support
43 | * Loaded with Conventional-changelog rules
44 | * Entrypoint to semantic-release automation
45 | * Semantic-release auto-deployment configuration
46 | * Auto-generate changelog
47 | * Auto-commit computed package version in git
48 | * Auto-release in github
49 | * Auto-publish to npm
50 | * Enable this features by using the semantic-release-cli
51 |
52 |
53 | ## Fork It And Make Your Own
54 | You can fork this repo to create your own boilerplate, and use it with vue-cli:
55 | ```bash
56 | vue init username/repo my-project
57 | ```
--------------------------------------------------------------------------------
/meta.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | prompts: {
3 | name: {
4 | type: "string",
5 | required: true,
6 | label: "Project name (kebab-case only)"
7 | },
8 | description: {
9 | type: "string",
10 | required: true,
11 | label: "Project description",
12 | default: "A Vue.js 2.0 library project"
13 | },
14 | author: {
15 | type: "string",
16 | label: "Author"
17 | },
18 | email: {
19 | type: "string",
20 | required: true,
21 | label: "Email"
22 | },
23 | repos: {
24 | type: "string",
25 | required: true,
26 | label: "Github repository URL",
27 | default: "user/repository"
28 | }
29 | },
30 | "skipInterpolation": "src/**/*.{html,vue}",
31 | "completeMessage": "To get started and/or setup your automatic deployment, please read the contributing documentation: {{destDirName}}/.github/CONTRIBUTING.md"
32 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-cli-template-library",
3 | "version": "1.2.1",
4 | "license": "MIT",
5 | "description": "Template for developing open-source vue.js libraries",
6 | "repository": {
7 | "type": "git",
8 | "url": "https://github.com/julon/vue-cli-template-library.git"
9 | },
10 | "bugs": {
11 | "url": "https://github.com/julon/vue-cli-template-library/issues"
12 | },
13 | "homepage": "https://github.com/julon/vue-cli-template-library#readme",
14 | "keywords": [
15 | "vue",
16 | "vue-component",
17 | "vue-library",
18 | "vue-template"
19 | ],
20 | "scripts": {
21 | "cz": "git-cz",
22 | "commitmsg": "commitlint -e $GIT_PARAMS",
23 | "semantic-release": "semantic-release"
24 | },
25 | "devDependencies": {
26 | "@commitlint/cli": "^6.0.2",
27 | "@commitlint/config-conventional": "^6.0.4",
28 | "@semantic-release/changelog": "^2.0.1",
29 | "@semantic-release/git": "^4.0.1",
30 | "@semantic-release/github": "^4.2.7",
31 | "@semantic-release/npm": "^3.2.2",
32 | "commitizen": "^2.9.6",
33 | "cz-conventional-changelog": "^2.1.0",
34 | "husky": "^0.14.3",
35 | "semantic-release": "^15.0.2",
36 | "vue-cli": "^2.9.3"
37 | },
38 | "config": {
39 | "commitizen": {
40 | "path": "cz-conventional-changelog"
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/release.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | verifyConditions: [
3 | "@semantic-release/changelog",
4 | "@semantic-release/npm",
5 | "@semantic-release/git",
6 | "@semantic-release/github"
7 | ],
8 | getLastRelease: "@semantic-release/npm",
9 | prepare: ["@semantic-release/changelog", "@semantic-release/git"],
10 | publish: ["@semantic-release/npm", "@semantic-release/github"]
11 | };
12 |
--------------------------------------------------------------------------------
/template/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/julon/vue-cli-template-library/a3555d873deb59a1724392963711b889a4ccc974/template/.DS_Store
--------------------------------------------------------------------------------
/template/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["vue-app", {
4 | "modules": false
5 | }]
6 | ],
7 | "plugins": [
8 | ["module-resolver", {
9 | "extensions": [".js", ".vue", ".json"]
10 | }]
11 | ],
12 | "env": {
13 | "test": {
14 | "plugins": ["dynamic-import-node"]
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/template/.commitlintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "@commitlint/config-conventional"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/template/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | indent_size = 2
7 | indent_style = space
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/template/.eslintignore:
--------------------------------------------------------------------------------
1 | .github/
2 | _book/
3 | docs/
4 | coverage/
5 | dist/
--------------------------------------------------------------------------------
/template/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // https://eslint.org/docs/user-guide/configuring
2 |
3 | module.exports = {
4 | root: true,
5 | parserOptions: {
6 | parser: 'babel-eslint',
7 | ecmaVersion: 2017,
8 | sourceType: 'module'
9 | },
10 | plugins: ['html', 'vue'],
11 | extends: [
12 | 'eslint:recommended',
13 | 'plugin:prettier/recommended',
14 | 'plugin:vue/recommended',
15 | 'plugin:import/errors',
16 | 'plugin:import/warnings'
17 | ],
18 | env: {
19 | browser: true,
20 | node: true,
21 | commonjs: true,
22 | es6: true,
23 | jest: true
24 | },
25 | rules: {
26 | // allow async-await
27 | 'generator-star-spacing': 'off',
28 | // don't require .vue extension when importing
29 | 'import/extensions': ['error', 'always', {
30 | 'js': 'never',
31 | 'vue': 'never'
32 | }],
33 | // disallow reassignment of function parameters
34 | // disallow parameter object manipulation except for specific exclusions
35 | 'no-param-reassign': ['error', {
36 | props: true,
37 | ignorePropertyModificationsFor: [
38 | 'state', // for vuex state
39 | 'acc', // for reduce accumulators
40 | 'e' // for e.returnvalue
41 | ]
42 | }],
43 | // allow optionalDependencies
44 | 'import/no-extraneous-dependencies': ['error', {
45 | optionalDependencies: ['test/index.js']
46 | }],
47 | // allow debugger during development
48 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
49 | },
50 | "settings": {
51 | // resolve using plugin babel module resolver
52 | "import/resolver": {
53 | "babel-module": {}
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/template/.github/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6 |
7 | ## Our Standards
8 |
9 | Examples of behavior that contributes to creating a positive environment include:
10 |
11 | * Using welcoming and inclusive language
12 | * Being respectful of differing viewpoints and experiences
13 | * Gracefully accepting constructive criticism
14 | * Focusing on what is best for the community
15 | * Showing empathy towards other community members
16 |
17 | Examples of unacceptable behavior by participants include:
18 |
19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances
20 | * Trolling, insulting/derogatory comments, and personal or political attacks
21 | * Public or private harassment
22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission
23 | * Other conduct which could reasonably be considered inappropriate in a professional setting
24 |
25 | ## Our Responsibilities
26 |
27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28 |
29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30 |
31 | ## Scope
32 |
33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34 |
35 | ## Enforcement
36 |
37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at {{ email }}. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38 |
39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40 |
41 | ## Attribution
42 |
43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44 |
45 | [homepage]: http://contributor-covenant.org
46 | [version]: http://contributor-covenant.org/version/1/4/
--------------------------------------------------------------------------------
/template/.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/blob/master/packages/conventional-changelog-angular/convention.md).
4 |
5 | #### Examples
6 |
7 | Appears under "Features" header, `compiler` subheader:
8 |
9 | ```
10 | feat(compiler): add 'comments' option
11 | ```
12 |
13 | Appears under "Bug Fixes" header, `v-model` subheader, with a link to issue #28:
14 |
15 | ```
16 | fix(v-model): handle events on blur
17 |
18 | close #28
19 | ```
20 |
21 | Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation:
22 |
23 | ```
24 | perf(core): improve vdom diffing by removing 'foo' option
25 |
26 | BREAKING CHANGE: The 'foo' option has been removed.
27 | ```
28 |
29 | 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.
30 |
31 | ```
32 | revert: feat(compiler): add 'comments' option
33 |
34 | This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
35 | ```
36 |
37 | ### Full Message Format
38 |
39 | A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**:
40 |
41 | ```
42 | ():
43 |
44 |
45 |
46 |
23 |
24 | ### ES6
25 | ```js
26 | //
27 | // You can register a component manually
28 | //
29 | import { HelloWorld } from '{{ name }}';
30 |
31 | export default {
32 | ...
33 | components: {
34 | HelloWorld
35 | },
36 | ...
37 | };
38 |
39 | //
40 | // or register the whole module with vue
41 | //
42 | import ModuleLibrary from '{{ name }}';
43 |
44 | // Install this library
45 | Vue.use(ModuleLibrary);
46 | ```
47 |
48 | ### CommonJS
49 | ```js
50 | //
51 | // You can register a component manually
52 | //
53 | var Vue = require('vue');
54 | var ModuleLibrary = require('{{ name }}');
55 |
56 | var YourComponent = Vue.extend({
57 | ...
58 | components: {
59 | 'hello-world': ModuleLibrary.HelloWorld
60 | },
61 | ...
62 | });
63 |
64 | //
65 | // or register the whole module with vue
66 | //
67 | var Vue = require('vue');
68 | var ModuleLibrary = require('{{ name }}');
69 |
70 | // Install this library
71 | Vue.use(ModuleLibrary);
72 | ```
73 |
74 | ### Browser
75 |
76 | ```html
77 |
78 |
79 |
80 | ```
81 |
82 | ### After that, you can use it in your templates:
83 |
84 | ```html
85 |
86 | ```
87 |
88 | ## Changelog
89 |
90 | See the GitHub [release history](https://github.com/{{ repos }}/releases).
91 |
92 | ## Contributing
93 |
94 | See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
95 |
--------------------------------------------------------------------------------
/template/jest.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 |
3 | module.exports = {
4 | rootDir: path.resolve(__dirname, "./"),
5 | moduleFileExtensions: ["js", "json", "vue"],
6 | transform: {
7 | ".*\\.js$": "/node_modules/babel-jest",
8 | ".*\\.vue$": "/node_modules/vue-jest"
9 | },
10 | snapshotSerializers: ["/node_modules/jest-serializer-vue"],
11 | setupFiles: ["/jest.setup"],
12 | mapCoverage: true,
13 | coverageDirectory: "/coverage",
14 | collectCoverageFrom: [
15 | "src/**/*.{js,vue}",
16 | "!src/index.umd.js",
17 | "!**/node_modules/**"
18 | ]
19 | };
20 |
--------------------------------------------------------------------------------
/template/jest.setup.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 |
3 | Vue.config.productionTip = false;
4 |
--------------------------------------------------------------------------------
/template/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "{{ name }}",
3 | "description": "{{ description }}",
4 | "version": "0.0.0-development",
5 | "license": "MIT",
6 | "main": "dist/{{ name }}.common.js",
7 | "module": "dist/{{ name }}.esm.js",
8 | "unpkg": "dist/{{ name }}.js",
9 | "jsdelivr": "dist/{{ name }}.js",
10 | "files": [
11 | "src",
12 | "dist/*.js"
13 | ],
14 | "author": "{{ author }}",
15 | "repository": {
16 | "type": "git",
17 | "url": "https://github.com/{{ repos }}.git"
18 | },
19 | "bugs": {
20 | "url": "https://github.com/{{ repos }}/issues"
21 | },
22 | "homepage": "https://github.com/{{ repos }}#readme",
23 | "keywords": [
24 | "vue",
25 | "vue-component",
26 | "vue-library"
27 | ],
28 | "engines": {
29 | "node": ">=8.9.0"
30 | },
31 | "scripts": {
32 | "build": "npm run build:cjs && npm run build:es && npm run build:umd:dev && npm run build:umd:prod",
33 | "build:cjs": "rollup -c --environment TARGET:cjs",
34 | "build:es": "rollup -c --environment TARGET:esm",
35 | "build:umd:dev": "rollup -c --environment TARGET:umd-dev",
36 | "build:umd:prod": "rollup -c --environment TARGET:umd-prod",
37 | "storybook": "start-storybook -p 9001 -c .storybook",
38 | "storybook:build": "build-storybook -c .storybook -o docs/dist/stories",
39 | "precommit": "lint-staged",
40 | "cz": "git-cz",
41 | "commitmsg": "commitlint -e $GIT_PARAMS",
42 | "test": "npm run lint && jest --verbose --coverage",
43 | "test:update": "jest --verbose --updateSnapshot",
44 | "test:watch": "jest --verbose --watchAll --notify",
45 | "lint": "eslint --ext .js,.vue .",
46 | "lint:fix": "eslint --ext .js,.vue . --fix",
47 | "prepublishOnly": "npm run build",
48 | "semantic-release": "semantic-release"
49 | },
50 | "devDependencies": {
51 | "@commitlint/cli": "^6.0.2",
52 | "@commitlint/config-conventional": "^5.2.3",
53 | "@semantic-release/changelog": "^1.0.0",
54 | "@semantic-release/git": "^2.0.1",
55 | "@semantic-release/github": "^3.0.1",
56 | "@semantic-release/npm": "^2.6.1",
57 | "@storybook/vue": "^3.3.3",
58 | "babel-core": "^6.26.0",
59 | "babel-eslint": "^8.1.2",
60 | "babel-jest": "^22.0.4",
61 | "babel-plugin-dynamic-import-node": "^1.2.0",
62 | "babel-plugin-module-resolver": "^3.0.0",
63 | "babel-preset-vue-app": "^2.0.0",
64 | "commitizen": "^2.9.6",
65 | "cz-conventional-changelog": "^2.1.0",
66 | "eslint": "^4.14.0",
67 | "eslint-config-prettier": "^2.9.0",
68 | "eslint-import-resolver-babel-module": "^4.0.0",
69 | "eslint-plugin-html": "^4.0.1",
70 | "eslint-plugin-import": "^2.8.0",
71 | "eslint-plugin-jest": "^21.5.0",
72 | "eslint-plugin-prettier": "2.4.0",
73 | "eslint-plugin-vue": "^4.0.1",
74 | "husky": "^0.14.3",
75 | "jest": "^22.0.4",
76 | "jest-serializer-html": "^5.0.0",
77 | "jest-serializer-vue": "^0.3.0",
78 | "jest-vue-preprocessor": "^1.3.1",
79 | "lint-staged": "^6.0.0",
80 | "lodash": "^4.17.4",
81 | "prettier": "^1.9.2",
82 | "rollup": "^0.54.0",
83 | "rollup-plugin-babel": "^3.0.3",
84 | "rollup-plugin-commonjs": "^8.2.6",
85 | "rollup-plugin-filesize": "^1.5.0",
86 | "rollup-plugin-json": "^2.3.0",
87 | "rollup-plugin-license": "^0.5.0",
88 | "rollup-plugin-node-resolve": "^3.0.0",
89 | "rollup-plugin-replace": "^2.0.0",
90 | "rollup-plugin-uglify": "^2.0.1",
91 | "rollup-plugin-vue": "^3.0.0",
92 | "semantic-release": "^12.2.2",
93 | "stylus": "^0.54.5",
94 | "stylus-loader": "^3.0.1",
95 | "uglify-es": "^3.3.4",
96 | "vue": "^2.5.13",
97 | "vue-jest": "^1.4.0",
98 | "vue-loader": "^13.6.2",
99 | "vue-template-compiler": "^2.5.13"
100 | },
101 | "config": {
102 | "commitizen": {
103 | "path": "cz-conventional-changelog"
104 | }
105 | },
106 | "lint-staged": {
107 | "*.{js,vue}": [
108 | "eslint --fix",
109 | "git add"
110 | ]
111 | },
112 | "release": {
113 | "verifyConditions": [
114 | "@semantic-release/changelog",
115 | "@semantic-release/npm",
116 | "@semantic-release/git",
117 | "@semantic-release/github"
118 | ],
119 | "getLastRelease": "@semantic-release/npm",
120 | "publish": [
121 | "@semantic-release/changelog",
122 | "@semantic-release/npm",
123 | "@semantic-release/git",
124 | "@semantic-release/github"
125 | ]
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/template/rollup.config.js:
--------------------------------------------------------------------------------
1 | import { camelCase } from "lodash";
2 | import path from "path";
3 | import babel from "rollup-plugin-babel";
4 | import commonjs from "rollup-plugin-commonjs";
5 | import filesize from "rollup-plugin-filesize";
6 | import json from "rollup-plugin-json";
7 | import license from "rollup-plugin-license";
8 | import resolve from "rollup-plugin-node-resolve";
9 | import replace from "rollup-plugin-replace";
10 | import uglify from "rollup-plugin-uglify";
11 | import vue from "rollup-plugin-vue";
12 | import { minify } from "uglify-es";
13 |
14 | import pack from "./package.json";
15 |
16 | const projectName = "{{ name }}";
17 |
18 | // compute globals from dependencies
19 | const globals = pack.dependencies && Object.assign({}, ...Object.keys(pack.dependencies).map((key) => ({
20 | [key]: camelCase(key)
21 | })));
22 |
23 | const builds = {
24 | // (CommonJS). Used by bundlers e.g. Webpack & Browserify
25 | cjs: {
26 | entry: "src/index.js",
27 | dest: `dist/${projectName}.common.js`,
28 | format: "cjs"
29 | },
30 | // (ES Modules). Used by bundlers that support ES Modules,
31 | // e.g. Rollup & Webpack 2
32 | esm: {
33 | entry: "src/index.js",
34 | dest: `dist/${projectName}.esm.js`,
35 | format: "es"
36 | },
37 | // build (Browser)
38 | "umd-dev": {
39 | entry: "src/index.umd.js",
40 | dest: `dist/${projectName}.js`,
41 | format: "umd",
42 | env: "development"
43 | },
44 | // production build (Browser)
45 | "umd-prod": {
46 | entry: "src/index.umd.js",
47 | dest: `dist/${projectName}.min.js`,
48 | format: "umd",
49 | env: "production"
50 | }
51 | };
52 |
53 | function genConfig(name) {
54 | const opts = builds[name];
55 | const config = {
56 | input: opts.entry,
57 | external: (id) => pack.dependencies && pack.dependencies[id], // exclude dependencies from build
58 | plugins: [
59 | resolve({
60 | browser: true,
61 | jsnext: true,
62 | preferBuiltins: false,
63 | extensions: [".js", ".json", ".vue"]
64 | }),
65 | commonjs(),
66 | vue({ compileTemplate: true, css: true }),
67 | json(),
68 | babel({
69 | exclude: "node_modules/**",
70 | runtimeHelpers: true
71 | }),
72 | filesize()
73 | ].concat(opts.plugins || []),
74 | output: {
75 | exports: "named",
76 | file: opts.dest,
77 | format: opts.format,
78 | // define globals in window from external dependencies
79 | globals,
80 | name: opts.moduleName || projectName
81 | }
82 | };
83 |
84 | if (opts.env) {
85 | config.plugins.push(
86 | replace({
87 | "process.env.NODE_ENV": JSON.stringify(opts.env)
88 | })
89 | );
90 |
91 | // minify on production targets
92 | if (opts.env === "production") {
93 | config.plugins.push(uglify({}, minify));
94 | }
95 | }
96 |
97 | // output a license to builds
98 | config.plugins.push(
99 | license({
100 | sourceMap: true,
101 | banner: {
102 | file: path.resolve("LICENSE.md")
103 | }
104 | })
105 | );
106 |
107 | Object.defineProperty(config, "_name", {
108 | enumerable: false,
109 | value: name
110 | });
111 |
112 | return config;
113 | }
114 |
115 | const target = process.env.TARGET || "umd-prod";
116 | module.exports = genConfig(target);
117 |
--------------------------------------------------------------------------------
/template/src/__tests__/index.js:
--------------------------------------------------------------------------------
1 | import ModuleLibrary from "../index";
2 |
3 | test("Should register all components when installed", () => {
4 | const component = jest.fn();
5 | const Vue = { component };
6 |
7 | ModuleLibrary.install(Vue);
8 |
9 | // Test if a particular component was registered
10 | expect(component).toBeCalledWith("hello-world", expect.any(Object));
11 |
12 | // Test how many times component got registered
13 | const totalOfComponents = 1;
14 | expect(component).toHaveBeenCalledTimes(totalOfComponents);
15 | });
16 |
--------------------------------------------------------------------------------
/template/src/components/HelloWorld.vue:
--------------------------------------------------------------------------------
1 |
2 | .hello
3 | h1 {{ msg }}
4 | .cat(v-for="category in categories")
5 | h2 {{ category.title }}
6 | ul
7 | li(v-for="link in category.links")
8 | a(:href="link.href" target="_blank") {{ link.label }}
9 |
10 |
11 |
45 |
46 |
47 |
59 |
--------------------------------------------------------------------------------
/template/src/components/__tests__/HelloWorld.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import HelloWorld from "../HelloWorld";
3 |
4 | describe("Hello.vue", () => {
5 | const Constructor = Vue.extend(HelloWorld);
6 | const vm = new Constructor().$mount();
7 | test("should render correct contents", () => {
8 | expect(vm.$el.querySelector(".hello h1").textContent).toEqual(
9 | "Welcome to Your Vue.js Library"
10 | );
11 | });
12 | test("should match the snapshot", () => {
13 | expect(vm.$el).toMatchSnapshot();
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/template/src/components/__tests__/__snapshots__/HelloWorld.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`Hello.vue should match the snapshot 1`] = `
4 |
7 |
8 | Welcome to Your Vue.js Library
9 |
10 |
13 |
14 | Essential Links
15 |
16 |
58 |
59 |
62 |
63 | Ecosystem
64 |
65 |
99 |
100 |
101 | `;
102 |
--------------------------------------------------------------------------------
/template/src/index.js:
--------------------------------------------------------------------------------
1 | import HelloWorld from "./components/HelloWorld";
2 |
3 | const LibraryModule = {
4 | HelloWorld,
5 |
6 | install(Vue) {
7 | // Register components with vue
8 | Vue.component("hello-world", HelloWorld);
9 | }
10 | };
11 |
12 | // Export library
13 | export default LibraryModule;
14 |
15 | // Export components
16 | export { HelloWorld };
17 |
--------------------------------------------------------------------------------
/template/src/index.umd.js:
--------------------------------------------------------------------------------
1 | import LibraryModule, * as LibraryComponents from "./index";
2 |
3 | // Automatically register components if Vue is available globally
4 | if (typeof window !== "undefined" && window.Vue) {
5 | window.Vue.use(LibraryModule);
6 | }
7 |
8 | export default LibraryComponents;
9 |
--------------------------------------------------------------------------------
/template/stories/index.stories.js:
--------------------------------------------------------------------------------
1 | import { storiesOf } from "@storybook/vue";
2 |
3 | // Add more stories here to live develop your components
4 | storiesOf("HelloWorld", module).add("story as a template", () => ({
5 | template: ``
6 | }));
7 |
--------------------------------------------------------------------------------