Skip to content

Commit 48e1ef7

Browse files
authored
Merge pull request #13 from vue-styleguidist/build-rollup
use rollup to maintain the library
2 parents 0b3af06 + 8493d4a commit 48e1ef7

24 files changed

+1479
-121
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
node_modules
33
/dist
44

5+
# tests artefact
6+
/tests/e2e/videos
7+
58
# local env files
69
.env.local
710
.env.*.local

.travis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@ branches:
2222
only:
2323
- master
2424

25+
stages:
26+
- test
27+
- name: demo
28+
if: type != pull_request AND branch = master
29+
- name: release
30+
if: type != pull_request AND branch = master
31+
2532
jobs:
2633
include:
2734
- stage: test
2835
script:
36+
- npx danger ci
2937
- yarn lint
3038
- yarn test:unit --runInBand
31-
- npx danger ci
39+
- yarn test:e2e --headless
3240

3341
- stage: demo
3442
script: yarn build:demo

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
21
# vue-live
32

43
A lightweight playground for live editing VueJs code in the browser
54

65
[![Build Status](https://travis-ci.com/vue-styleguidist/vue-live.svg?branch=master)](https://travis-ci.com/vue-styleguidist/vue-live)
76
[![NPM Version](https://img.shields.io/npm/v/vue-live.svg)](https://www.npmjs.com/package/vue-live) [![NPM Downloads](https://img.shields.io/npm/dm/vue-live.svg)](https://www.npmjs.com/package/vue-live)
7+
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
88

9-
----
9+
---
1010

1111
## Usage
1212

1313
The simplest way to render components is as a VueJs template:
1414

15-
``` vue
15+
```vue
1616
<template>
1717
<VueLive :code="`<date-picker />`" :components="{ DatePicker }">
1818
</template>
@@ -36,26 +36,31 @@ export default {
3636
Check out the [demo](http://vue-live.surge.sh) for alernative syntaxes to write your showcases.
3737

3838
## How to contribute
39+
3940
```
4041
yarn install
4142
```
4243

4344
### Compiles and hot-reloads for development
45+
4446
```
4547
yarn serve
4648
```
4749

4850
### Compiles and minifies for production
51+
4952
```
5053
yarn build
5154
```
5255

5356
### Run your tests
57+
5458
```
5559
yarn test:unit
5660
```
5761

5862
### Lints and fixes files
63+
5964
```
6065
yarn lint
6166
```

cypress.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"pluginsFile": "tests/e2e/plugins/index.js"
3+
}

dangerfile.js

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// eslint-disable-next-line import/no-unresolved, import/extensions
2-
import { danger, warn } from "danger";
1+
/* eslint-disable */
2+
const fs = require("fs");
3+
const path = require("path");
4+
const validateMessage = require("validate-commit-msg");
35

46
const packageChanged = danger.git.modified_files.includes("package.json");
57
const lockfileChanged = danger.git.modified_files.includes("yarn.lock");
@@ -13,3 +15,43 @@ if (!packageChanged && lockfileChanged) {
1315
warn(`Changes were made to \`yarn.lock\`, but not to \`package.json\`.
1416
Please remove \`yarn.lock\` changes from your pull request. Try to run \`git checkout master -- yarn.lock\` and commit changes.`);
1517
}
18+
19+
// Check test exclusion (.only) is included
20+
var modifiedSpecFiles = danger.git.modified_files.filter(function(filePath) {
21+
return filePath.match(/__tests__\/.+\.(js|jsx|ts|tsx)$/gi);
22+
});
23+
24+
var testFilesIncludeExclusion = modifiedSpecFiles.reduce(function(acc, value) {
25+
var content = fs.readFileSync(value).toString();
26+
var invalid =
27+
content.indexOf("it.only") >= 0 || content.indexOf("describe.only") >= 0;
28+
if (invalid) {
29+
acc.push(path.basename(value));
30+
}
31+
return acc;
32+
}, []);
33+
34+
if (testFilesIncludeExclusion.length > 0) {
35+
fail("an `only` was left in tests (" + testFilesIncludeExclusion + ")");
36+
}
37+
38+
//validate commit message in PR if it conforms conventional change log, notify if it doesn't.
39+
var messageConventionValid = danger.git.commits.reduce(function(acc, value) {
40+
var valid = validateMessage(value.message);
41+
return valid && acc;
42+
}, true);
43+
44+
let errorCount = 0;
45+
46+
if (!messageConventionValid) {
47+
warn(
48+
"commit message does not follows conventional change log (" +
49+
++errorCount +
50+
")"
51+
);
52+
markdown(
53+
"> (" +
54+
errorCount +
55+
") : vue-live uses conventional change log to generate changelog automatically. It seems some of commit messages are not following those, please check [contributing guideline](https://github.com/ReactiveX/rxjs/blob/master/CONTRIBUTING.md#commit-message-format) and update commit messages."
56+
);
57+
}

demo/CustomLayout.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,28 @@
3333
text-align: center;
3434
border-radius: 0 10px 10px 0;
3535
}
36+
37+
@media only screen and (max-width: 1000px) {
38+
.preview-code {
39+
width: 90vw;
40+
}
41+
}
42+
43+
@media only screen and (max-width: 568px) {
44+
.preview-code {
45+
display: block;
46+
}
47+
48+
.preview-code > div {
49+
width: auto;
50+
}
51+
52+
.preview-code > div:first-child {
53+
border-radius: 10px 10px 0 0;
54+
}
55+
56+
.preview-code > div:last-child {
57+
border-radius: 0 0 10px 10px;
58+
}
59+
}
3660
</style>

package.json

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
{
22
"name": "vue-live",
33
"version": "0.0.0-dev",
4+
"author": "Bart Ledoux <ledouxb@me.com>",
45
"scripts": {
56
"serve": "vue-cli-service serve",
6-
"build": "cross-env LIB_MAKING=true vue-cli-service build --target lib --entry ./src/index.js",
7-
"build:demo": "vue-cli-service build",
7+
"build": "rollup -c",
88
"lint": "vue-cli-service lint",
9+
"build:demo": "vue-cli-service build",
10+
"start": "vue-cli-service serve",
11+
"test:e2e": "vue-cli-service test:e2e",
912
"test:unit": "vue-cli-service test:unit"
1013
},
11-
"license": "MIT",
12-
"repository": {
13-
"type": "git",
14-
"url": "git+https://github.com/vue-styleguidist/vue-live.git"
15-
},
16-
"bugs": {
17-
"url": "https://github.com/vue-styleguidist/vue-live/issues"
18-
},
19-
"author": "Bart Ledoux <ledouxb@me.com>",
20-
"main": "./dist/vue-live.common.js",
21-
"files": [
22-
"./dist"
23-
],
2414
"dependencies": {
2515
"acorn": "^6.1.1",
2616
"buble": "^0.19.7",
@@ -34,6 +24,7 @@
3424
},
3525
"devDependencies": {
3626
"@vue/cli-plugin-babel": "^3.6.0",
27+
"@vue/cli-plugin-e2e-cypress": "^3.7.0",
3728
"@vue/cli-plugin-eslint": "^3.6.0",
3829
"@vue/cli-plugin-unit-jest": "^3.6.3",
3930
"@vue/cli-service": "^3.6.0",
@@ -45,6 +36,14 @@
4536
"eslint": "^5.16.0",
4637
"eslint-plugin-vue": "^5.0.0",
4738
"raw-loader": "^2.0.0",
39+
"rollup": "^1.11.2",
40+
"rollup-plugin-babel": "^4.3.2",
41+
"rollup-plugin-commonjs": "^9.3.4",
42+
"rollup-plugin-css-only": "^1.0.0",
43+
"rollup-plugin-json": "^4.0.0",
44+
"rollup-plugin-node-resolve": "^4.2.3",
45+
"rollup-plugin-vue": "^5.0.0",
46+
"validate-commit-msg": "^2.14.0",
4847
"vuejs-datepicker": "^1.5.4"
4948
},
5049
"eslintConfig": {
@@ -89,5 +88,17 @@
8988
"> 1%",
9089
"last 2 versions",
9190
"not ie <= 8"
92-
]
91+
],
92+
"bugs": {
93+
"url": "https://github.com/vue-styleguidist/vue-live/issues"
94+
},
95+
"files": [
96+
"./dist"
97+
],
98+
"license": "MIT",
99+
"main": "./dist/vue-live.common.js",
100+
"repository": {
101+
"type": "git",
102+
"url": "git+https://github.com/vue-styleguidist/vue-live.git"
103+
}
93104
}

rollup.config.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as path from "path";
2+
import cjs from "rollup-plugin-commonjs";
3+
import node from "rollup-plugin-node-resolve";
4+
import babel from "rollup-plugin-babel";
5+
import vue from "rollup-plugin-vue";
6+
import css from "rollup-plugin-css-only";
7+
import json from "rollup-plugin-json";
8+
9+
const resolve = _path => path.resolve(__dirname, _path);
10+
11+
export default {
12+
input: resolve("./src/main.js"),
13+
output: {
14+
file: resolve(`./dist/vue-live.common.js`),
15+
format: "cjs"
16+
},
17+
plugins: [
18+
cjs(),
19+
node(),
20+
babel({
21+
babelrc: false,
22+
presets: [["@vue/babel-preset-app", { useBuiltIns: false }]],
23+
extensions: [".js"],
24+
runtimeHelpers: true
25+
}),
26+
vue(),
27+
css(),
28+
json()
29+
],
30+
external: [
31+
"acorn",
32+
"buble",
33+
"walkes",
34+
"hash-sum",
35+
"vue-template-compiler",
36+
"rewrite-imports",
37+
"prismjs",
38+
"prismjs/themes/prism-tomorrow.css",
39+
"prismjs/components/prism-jsx.min",
40+
"vue-prism-editor/dist/VuePrismEditor.css",
41+
"vue-prism-editor"
42+
]
43+
};

src/Preview.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
</template>
77

88
<script>
9-
import { transform } from "buble";
109
import compileCode, { isCodeVueSfc } from "./utils/compileCode";
1110
import getVars from "./utils/getVars";
1211
import getVueConfigObject from "./utils/getVueConfigObject";
@@ -71,7 +70,7 @@ export default {
7170
// it can be:
7271
// - a script setting up variables => we set up the data property of renderedComponent
7372
// - a `new Vue()` script that will return a full config object
74-
script = transform(renderedComponent.script).code;
73+
script = renderedComponent.script;
7574
data = getVueConfigObject(script, listVars) || {};
7675
}
7776
if (renderedComponent.html) {

src/VueLive.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ import "vue-prism-editor/dist/VuePrismEditor.css";
2222
import "prismjs/components/prism-jsx.min";
2323
2424
import PrismEditor from "vue-prism-editor";
25-
import Preview from "./Preview";
26-
import VueLiveLayout from "./VueLiveDefaultLayout";
2725
import hash from "hash-sum";
2826
27+
import Preview from "./Preview.vue";
28+
import VueLiveLayout from "./VueLiveDefaultLayout.vue";
29+
2930
const LANG_TO_PRISM = {
3031
vue: "html",
3132
js: "jsx"

0 commit comments

Comments
 (0)