Skip to content

Commit d761b23

Browse files
authored
Merge pull request #85 from leezng/dev
pre release
2 parents 1cf857b + ab6688a commit d761b23

File tree

11 files changed

+14412
-86
lines changed

11 files changed

+14412
-86
lines changed

.github/workflows/bump-version.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
8+
jobs:
9+
bump-version:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Code
13+
uses: actions/checkout@v2
14+
15+
- name: Automated Version Bump
16+
uses: phips28/[email protected]
17+
env:
18+
GITHUB_USER: ${{ secrets.CI_NAME }}
19+
GITHUB_EMAIL: ${{ secrets.CI_EMAIL }}
20+
21+
publish-npm:
22+
needs: bump-version
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout Code
26+
uses: actions/checkout@v2
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@v1
30+
with:
31+
node-version: 12
32+
registry-url: https://registry.npmjs.org/
33+
34+
- name: Publish
35+
run: |
36+
npm ci
37+
npm run build
38+
npm publish
39+
env:
40+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
42+
publish-gpr:
43+
needs: bump-version
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout Code
47+
uses: actions/checkout@v2
48+
49+
- name: Set up Node.js
50+
uses: actions/setup-node@v1
51+
with:
52+
node-version: 12
53+
registry-url: https://npm.pkg.github.com/
54+
55+
- name: Publish
56+
run: |
57+
npm ci
58+
npm run build
59+
npm publish
60+
env:
61+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/gh-pages.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Gh Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Code
13+
uses: actions/checkout@v2
14+
15+
- name: Install
16+
run: npm install
17+
18+
- name: Build
19+
run: npm run build:example
20+
21+
- name: Deploy
22+
uses: peaceiris/actions-gh-pages@v3
23+
with:
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
publish_dir: ./example-dist
26+
user_name: ${{ secrets.CI_NAME }}
27+
user_email: ${{ secrets.CI_EMAIL }}

.github/workflows/lint.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
run-linters:
7+
name: Run Linters
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: 12
18+
19+
- name: Lint
20+
run: |
21+
npm install
22+
npm run lint

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
node_modules/
33
example-dist/
44
dist/
5+
lib/
6+
react/
57
npm-debug.log*
68
yarn-debug.log*
79
yarn-error.log*
810
test/e2e/reports
911
selenium-debug.log
10-
react/
1112

1213
# Editor directories and files
1314
.idea

.travis.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

README.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ A vue 2.x component for rendering JSON data as a tree structure.
1818

1919
## Install
2020

21-
```js
22-
npm install vue-json-pretty
21+
```bash
22+
npm install vue-json-pretty --save
2323
```
2424

2525
## Usage
2626

27-
```html
27+
The CSS file is included separately and needs to be imported manually. You can either import CSS globally in your app (if supported by your framework) or directly from the component.
28+
29+
```vue
2830
<template>
2931
<div>
3032
...
@@ -35,16 +37,39 @@ npm install vue-json-pretty
3537
</vue-json-pretty>
3638
</div>
3739
</template>
38-
```
3940
40-
```js
41+
<script>
4142
import VueJsonPretty from 'vue-json-pretty'
43+
import 'vue-json-pretty/lib/styles.css';
4244
4345
export default {
4446
components: {
4547
VueJsonPretty
4648
}
4749
}
50+
</script>
51+
```
52+
53+
## Nuxt.js
54+
55+
1. In `plugins/vue-json-pretty.js`
56+
57+
```
58+
import Vue from 'vue'
59+
import VueJsonPretty from 'vue-json-pretty'
60+
61+
Vue.component("vue-json-pretty", VueJsonPretty);
62+
```
63+
64+
2. In `nuxt.config.js`
65+
66+
```js
67+
css: [
68+
'vue-json-pretty/lib/styles.css'
69+
],
70+
plugins: [
71+
'@/plugins/vue-json-pretty'
72+
],
4873
```
4974

5075
## Props
@@ -68,6 +93,7 @@ export default {
6893
| showSelectController | higher | whether to show the select controller at left | boolean | false |
6994
| selectOnClickNode | higher | whether to change selected value when click node | boolean | true |
7095
| highlightSelectedNode | higher | highlight current node when selected | boolean | true |
96+
| collapsedOnClickBrackets | higher | collapsed control | boolean | true |
7197
| customValueFormatter | higher | a function that can return different html or strings to display for values in the data. | Function(data, key, parent, defaultFormatted) | - |
7298

7399
## Events
@@ -76,3 +102,8 @@ export default {
76102
|---------- |-------- |---------- |
77103
| click | triggered when a data item is clicked | (path, data) |
78104
| change | triggered when the selected value changed (only the selectableType not null) | (newVal, oldVal) |
105+
106+
## Major Contributors
107+
108+
[![](https://avatars3.githubusercontent.com/u/153197?v=3&s=50)](https://github.com/rchl)
109+
[![](https://avatars1.githubusercontent.com/u/445616?v=3&s=50)](https://github.com/blackmad)

build/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ exports.cssLoaders = function (options) {
3434

3535
// Extract CSS when that option is specified
3636
// (which is the case during production build)
37-
if (options.extract && !!!process.env.DIST_ENV) {
37+
if (options.extract) {
3838
return ['vue-style-loader'].concat([MiniCssExtractPlugin.loader].concat(loaders))
3939
} else {
4040
return ['vue-style-loader'].concat(loaders)

build/webpack.prod.conf.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
1010
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
1111
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
1212

13-
const isDist = !!process.env.DIST_ENV
14-
const distPath = '../dist'
13+
const isExampleEnv = process.env.EXAMPLE_ENV
14+
const distPath = '../lib'
1515

1616
const env = process.env.NODE_ENV === 'testing'
1717
? require('../config/test.env')
@@ -36,35 +36,31 @@ const webpackConfig = merge(baseWebpackConfig, {
3636
new webpack.DefinePlugin({
3737
'process.env': env
3838
}),
39-
new CopyWebpackPlugin({
40-
patterns: [
41-
{
42-
from: path.resolve(__dirname, '../README.md'),
43-
to: isDist ? path.resolve(__dirname, distPath) : config.build.assetsRoot
44-
}
45-
],
46-
}),
4739
]
4840
})
4941

50-
if (isDist) {
42+
if (!isExampleEnv) {
5143
webpackConfig.entry = {
5244
'vue-json-pretty': './src/index.js'
5345
}
5446
webpackConfig.output = {
5547
path: path.resolve(__dirname, distPath),
5648
filename: `${distPath}/[name].js`,
49+
globalObject: 'this',
5750
library: 'VueJsonPretty',
5851
libraryTarget: 'umd'
5952
}
6053
webpackConfig.plugins.push(
61-
new CopyWebpackPlugin({
62-
patterns: [
63-
{
64-
from: path.resolve(__dirname, '../package.json'),
65-
to: path.resolve(__dirname, distPath)
66-
}
67-
],
54+
// extract css into its own file
55+
new MiniCssExtractPlugin({
56+
filename: 'styles.css'
57+
}),
58+
// Compress extracted CSS. We are using this plugin so that possible
59+
// duplicated CSS from different components can be deduped.
60+
new OptimizeCSSPlugin({
61+
cssProcessorOptions: {
62+
safe: true
63+
}
6864
}),
6965
)
7066
} else {

0 commit comments

Comments
 (0)