Skip to content

Commit e0dc44f

Browse files
committed
🎉 initial commit
0 parents  commit e0dc44f

File tree

6 files changed

+76
-0
lines changed

6 files changed

+76
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Vue CLI plugin for UI5-Webcomponents
2+

generator/index.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
let ui5 = `\nVue.config.ignoredElements = [/^ui5-/];`;
2+
3+
module.exports = (api, opts, rootOptions) => {
4+
api.extendPackage({
5+
dependencies: {
6+
"@ui5/webcomponents": "^0.9.0"
7+
}
8+
});
9+
if (opts.addExample) {
10+
api.render('./template', {
11+
...opts,
12+
});
13+
}
14+
api.onCreateComplete(() => {
15+
// inject to main.js
16+
const fs = require('fs');
17+
const ext = api.hasPlugin('typescript') ?
18+
'ts' :
19+
'js';
20+
const mainPath = api.resolve(`./src/main.${ext}`);
21+
// get content
22+
let contentMain = fs.readFileSync(mainPath, {
23+
encoding: 'utf-8'
24+
});
25+
const lines = contentMain
26+
.split(/\r?\n/g)
27+
.reverse();
28+
29+
// inject import
30+
const lastImportIndex = lines.findIndex(line => line.match(/^import/));
31+
lines[lastImportIndex] += ui5;
32+
33+
// modify app
34+
contentMain = lines
35+
.reverse()
36+
.join('\n');
37+
fs.writeFileSync(mainPath, contentMain, {
38+
encoding: 'utf-8'
39+
});
40+
});
41+
}

generator/template/src/UI5Example.vue

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<template>
2+
<ui5-button>Button</ui5-button>
3+
</template>
4+
<script>
5+
import "@ui5/webcomponents/dist/Button";
6+
export default {};
7+
</script>
8+

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = (api, opts) => {}

package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "vue-cli-plugin-ui5-webcomponents",
3+
"version": "0.0.1",
4+
"description": "",
5+
"main": "index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/CodesOfRa/vue-cli-plugin-ui5-webcomponents.git"
9+
},
10+
"keywords": [
11+
"vue",
12+
"vue-cli",
13+
"ui5"
14+
],
15+
"author": "Ramona Biscoveanu",
16+
"license": "ISC",
17+
"homepage": "https://github.com/CodesOfRa/vue-cli-plugin-ui5-webcomponents#readme"
18+
}

prompts.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = [{
2+
name: `addExample`,
3+
type: 'confirm',
4+
message: 'Do you want to add an example component to components folder?',
5+
default: false
6+
}];

0 commit comments

Comments
 (0)