Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit e9857ef

Browse files
committedSep 13, 2017
feat: prep helper lib
1 parent d29e55a commit e9857ef

File tree

7 files changed

+1264
-0
lines changed

7 files changed

+1264
-0
lines changed
 

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
.*
3+
!.gitignore

‎LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2016-2017 - BootstrapVue
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

‎README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
# bootstrap-vue-helper-json
2+
3+
Bootstrap-Vue/Vetur intellisense reference definitions.

‎element-tags.json

+1,086
Large diffs are not rendered by default.

‎package-lock.json

+57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "bootstrap-vue-helper-json",
3+
"version": "1.0.0-beta.7",
4+
"description": "Bootstrap-Vue/Vetur intellisense reference definitions.",
5+
"main": "element-tags.json",
6+
"scripts": {
7+
"build": "scripts/generate-vetur-helpers.js"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/bootstrap-vue/bootstrap-vue-helper-json.git"
12+
},
13+
"keywords": ["bootstrap", "bootstrap-vue", "plugin", "vetur"],
14+
"author": "Alex Regan <alex.joseph.regan@gmail.com> (https://github.com/alexsasharegan)",
15+
"license": "MIT",
16+
"bugs": {
17+
"url": "https://github.com/bootstrap-vue/bootstrap-vue-helper-json/issues"
18+
},
19+
"homepage": "https://github.com/bootstrap-vue/bootstrap-vue-helper-json#readme",
20+
"devDependencies": {
21+
"bootstrap-vue": "^1.0.0-beta.7",
22+
"lodash": "^4.17.4"
23+
}
24+
}

‎scripts/generate-vetur-helpers.js

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env node
2+
const { resolve } = require("path")
3+
const { readFileSync, existsSync, writeFile } = require("fs")
4+
const { kebabCase } = require("lodash")
5+
const BV = require("bootstrap-vue/dist/bootstrap-vue")
6+
const cache = Object.create(null)
7+
cache["element-tags"] = {}
8+
9+
class JsonSet extends Set {
10+
toJSON() {
11+
return Array.from(this)
12+
}
13+
}
14+
15+
function $writeFile(path, data, options) {
16+
return new Promise((resolve, reject) => {
17+
writeFile(path, data, options, err => {
18+
err ? reject(err) : resolve()
19+
})
20+
})
21+
}
22+
23+
function cacheLibMeta() {
24+
BV.install({
25+
component(name, def) {
26+
const tagName = kebabCase(name)
27+
const metapath = resolve(
28+
require.resolve("bootstrap-vue"),
29+
"/docs/components/",
30+
tagName
31+
.split("-")
32+
.filter(s => s !== "b")
33+
.join("-"),
34+
"meta.json"
35+
)
36+
let metaDoc = {}
37+
if (existsSync(metapath)) {
38+
metaDoc = JSON.parse(readFileSync(metapath))
39+
}
40+
cache["element-tags"][tagName] = Object.keys(def.props || {}).reduce(
41+
(meta, prop) => {
42+
meta.attributes.add(kebabCase(prop))
43+
meta.description = metaDoc.description || `Bootstrap-Vue component: <${tagName}>`
44+
45+
if (metaDoc.components) {
46+
metaDoc.components.map(name => meta.subtags.add(kebabCase(name)))
47+
}
48+
if (metaDoc.events) {
49+
metaDoc.events.map(e => meta.attributes.add(e.event))
50+
}
51+
52+
return meta
53+
},
54+
{ attributes: new JsonSet(), subtags: new JsonSet(), description: "" }
55+
)
56+
},
57+
directive(name, def) {} // noop for now
58+
})
59+
}
60+
61+
function main() {
62+
cacheLibMeta()
63+
for (const basename in cache) {
64+
$writeFile(resolve(__dirname, "..", `${basename}.json`), JSON.stringify(cache[basename], null, 2)).catch(
65+
console.error
66+
)
67+
}
68+
}
69+
70+
main()

0 commit comments

Comments
 (0)
This repository has been archived.