Skip to content

Commit 5500c4e

Browse files
Merge pull request #5 from jawa-the-hutt/feature/mylmz10-add-nvw-template
Added NVW templates
2 parents ed8c5c9 + 1df0593 commit 5500c4e

File tree

172 files changed

+3173
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+3173
-36
lines changed

Diff for: generator/index.js

+34-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = (api, options, rootOptions) => {
1616

1717
if(options.isNativeOnly)
1818
options.isNVW = false;
19-
19+
2020
const commonRenderOptions = {
2121
applicationName: api.generator.pkg.name,
2222
applicationVersion: api.generator.pkg.version,
@@ -54,6 +54,7 @@ module.exports = (api, options, rootOptions) => {
5454
},
5555
dependencies: {
5656
'nativescript-vue': '^2.0.2',
57+
'nativescript-vue-web': '^0.8.0',
5758
'tns-core-modules': '^4.2.1',
5859
},
5960
devDependencies: {
@@ -98,6 +99,10 @@ module.exports = (api, options, rootOptions) => {
9899
delete pkg.browserslist
99100
}
100101

102+
if(options.isNativeOnly || !options.isNVW){
103+
delete pkg.dependencies['nativescript-vue-web']
104+
}
105+
101106
})
102107

103108

@@ -111,25 +116,39 @@ module.exports = (api, options, rootOptions) => {
111116
// New Project and not using Nativescript-Vue-Web
112117
if(!options.isNVW && !options.isNativeOnly) {
113118
api.render('./templates/simple/without-nvw/new', commonRenderOptions)
114-
119+
115120
if(api.hasPlugin('vue-router')){
116121
api.injectImports('src/main.js', `import router from '~/router'`)
117122
api.injectRootOptions('src/main.js', `router`)
118123
}
119-
124+
120125
if(api.hasPlugin('vuex')){
121126
api.injectImports('src/main.js', `import store from '~/store'`)
122127
api.injectRootOptions('src/main.js', `store`)
123128
api.injectImports('app/main.js', `import store from 'src/store'`)
124129
api.injectRootOptions('app/main.js', `store`)
125-
130+
126131
}
127-
}
132+
}
128133

129134
// New Project and is using Nativescript-Vue-Web
130135
if(options.isNVW && !options.isNativeOnly) {
131-
132-
}
136+
console.log("burası");
137+
api.render('./templates/simple/with-nvw/new', commonRenderOptions);
138+
139+
if(api.hasPlugin('vue-router')){
140+
api.injectImports('src/main.js', `import router from '~/router'`)
141+
api.injectRootOptions('src/main.js', `router`)
142+
}
143+
144+
if(api.hasPlugin('vuex')){
145+
api.injectImports('src/main.js', `import store from '~/store'`)
146+
api.injectRootOptions('src/main.js', `store`)
147+
api.injectImports('app/main.js', `import store from 'src/store'`)
148+
api.injectRootOptions('app/main.js', `store`)
149+
150+
}
151+
}
133152

134153
// New Project & Native Only -- should never be able to use Nativescript-Vue-Web
135154
if(!options.isNVW && options.isNativeOnly) {
@@ -139,19 +158,19 @@ module.exports = (api, options, rootOptions) => {
139158
if(options.isNativeOnly && options.isNVW) {
140159
// should never reach this block of code
141160
}
142-
161+
143162

144163
} else { // Exising Project
145164

146165
// Existing Project and not using Nativescript-Vue-Web
147166
if(!options.isNVW && !options.isNativeOnly) {
148167
api.render('./templates/simple/without-nvw/existing', commonRenderOptions)
149-
}
168+
}
150169

151170
// Existing Project and is using Nativescript-Vue-Web
152171
if(options.isNVW && !options.isNativeOnly) {
153-
154-
}
172+
173+
}
155174

156175
// Existing Project & Native Only -- should never be able to use Nativescript-Vue-Web
157176
if(!options.isNVW && options.isNativeOnly) {
@@ -164,10 +183,10 @@ module.exports = (api, options, rootOptions) => {
164183

165184
}
166185

167-
168-
169186

170-
187+
188+
189+
171190
api.onCreateComplete(() => {
172191

173192
const newline = process.platform === 'win32' ? '\r\n' : '\n';
@@ -253,6 +272,6 @@ module.exports = (api, options, rootOptions) => {
253272

254273
})
255274

256-
275+
257276

258277
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<%_ if (!rootOptions.router) { _%>
2+
<%# This code is the same as having a router. #%>
3+
<%# Setting this space aside for future possible use in the template #%>
4+
<template>
5+
<Page>
6+
<ActionBar :title="navbarTitle"/>
7+
<GridLayout rows="auto, auto">
8+
<Button text="Home" @tap="goToHomePage" row="0"/>
9+
<Button text="About" @tap="goToAboutPage" row="1"/>
10+
</GridLayout>
11+
</Page>
12+
</template>
13+
<script>
14+
// ~ is an alias to /src
15+
import Home from '~/views/Home';
16+
import About from '~/views/About';
17+
18+
export default {
19+
20+
data() {
21+
return {
22+
navbarTitle: 'App.android.vue',
23+
}
24+
},
25+
methods: {
26+
goToHomePage() {
27+
this.$navigateTo(Home);
28+
},
29+
goToAboutPage() {
30+
this.$navigateTo(About);
31+
}
32+
}
33+
}
34+
35+
</script>
36+
<%_ } else { _%>
37+
<%# This code is the same as not having a router. #%>
38+
<%# See note above #%>
39+
<template>
40+
<Page>
41+
<ActionBar :title="navbarTitle"/>
42+
<GridLayout rows="auto, auto">
43+
<Button text="Home" @tap="goToHomePage" row="0"/>
44+
<Button text="About" @tap="goToAboutPage" row="1"/>
45+
</GridLayout>
46+
</Page>
47+
</template>
48+
<script>
49+
// ~ is an alias to /src
50+
import Home from '~/views/Home';
51+
import About from '~/views/About';
52+
53+
export default {
54+
55+
data() {
56+
return {
57+
navbarTitle: 'App.android.vue',
58+
}
59+
},
60+
methods: {
61+
goToHomePage() {
62+
this.$navigateTo(Home);
63+
},
64+
goToAboutPage() {
65+
this.$navigateTo(About);
66+
}
67+
}
68+
}
69+
70+
</script>
71+
<%_ } _%>
72+
73+
<%_ if (rootOptions.cssPreprocessor !== 'stylus') { _%>
74+
<style<%-
75+
rootOptions.cssPreprocessor
76+
? ` lang="${
77+
rootOptions.cssPreprocessor === 'sass'
78+
? 'scss'
79+
: rootOptions.cssPreprocessor
80+
}"`
81+
: ``
82+
%>>
83+
ActionBar {
84+
color: #42b983;
85+
}
86+
</style>
87+
<%_ } else { _%>
88+
<style lang="stylus">
89+
ActionBar
90+
color: #42b983
91+
</style>
92+
<%_ } _%>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<%_ if (!rootOptions.router) { _%>
2+
<%# This code is the same as having a router. #%>
3+
<%# Setting this space aside for future possible use in the template #%>
4+
<template>
5+
<Page>
6+
<ActionBar :title="navbarTitle"/>
7+
<GridLayout rows="auto, auto">
8+
<Button text="Home" @tap="goToHomePage" row="0"/>
9+
<Button text="About" @tap="goToAboutPage" row="1"/>
10+
</GridLayout>
11+
</Page>
12+
</template>
13+
<script>
14+
// ~ is an alias to /src
15+
import Home from '~/views/Home';
16+
import About from '~/views/About';
17+
18+
export default {
19+
20+
data() {
21+
return {
22+
navbarTitle: 'App.ios.vue',
23+
}
24+
},
25+
methods: {
26+
goToHomePage() {
27+
this.$navigateTo(Home);
28+
},
29+
goToAboutPage() {
30+
this.$navigateTo(About);
31+
}
32+
}
33+
}
34+
35+
</script>
36+
<%_ } else { _%>
37+
<%# This code is the same as not having a router. #%>
38+
<%# See note above #%>
39+
<template>
40+
<Page>
41+
<ActionBar :title="navbarTitle"/>
42+
<GridLayout rows="auto, auto">
43+
<Button text="Home" @tap="goToHomePage" row="0"/>
44+
<Button text="About" @tap="goToAboutPage" row="1"/>
45+
</GridLayout>
46+
</Page>
47+
</template>
48+
<script>
49+
// ~ is an alias to /src
50+
import Home from '~/views/Home';
51+
import About from '~/views/About';
52+
53+
export default {
54+
55+
data() {
56+
return {
57+
navbarTitle: 'App.ios.vue',
58+
}
59+
},
60+
methods: {
61+
goToHomePage() {
62+
this.$navigateTo(Home);
63+
},
64+
goToAboutPage() {
65+
this.$navigateTo(About);
66+
}
67+
}
68+
}
69+
70+
</script>
71+
<%_ } _%>
72+
73+
<%_ if (rootOptions.cssPreprocessor !== 'stylus') { _%>
74+
<style<%-
75+
rootOptions.cssPreprocessor
76+
? ` lang="${
77+
rootOptions.cssPreprocessor === 'sass'
78+
? 'scss'
79+
: rootOptions.cssPreprocessor
80+
}"`
81+
: ``
82+
%>>
83+
ActionBar {
84+
color: #42b983;
85+
}
86+
</style>
87+
<%_ } else { _%>
88+
<style lang="stylus">
89+
ActionBar
90+
color: #42b983
91+
</style>
92+
<%_ } _%>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<%_ if (!rootOptions.router) { _%>
2+
<%# This code is the same as having a router. #%>
3+
<%# Setting this space aside for future possible use in the template #%>
4+
<template>
5+
<Page>
6+
<ActionBar :title="navbarTitle"/>
7+
<GridLayout rows="auto, auto">
8+
<Button text="Home" @tap="goToHomePage" row="0"/>
9+
<Button text="About" @tap="goToAboutPage" row="1"/>
10+
</GridLayout>
11+
</Page>
12+
</template>
13+
<script>
14+
// ~ is an alias to /src
15+
import Home from '~/views/Home';
16+
import About from '~/views/About';
17+
18+
export default {
19+
20+
data() {
21+
return {
22+
navbarTitle: 'App.native.vue',
23+
}
24+
},
25+
methods: {
26+
goToHomePage() {
27+
this.$navigateTo(Home);
28+
},
29+
goToAboutPage() {
30+
this.$navigateTo(About);
31+
}
32+
}
33+
}
34+
35+
</script>
36+
<%_ } else { _%>
37+
<%# This code is the same as not having a router. #%>
38+
<%# See note above #%>
39+
<template>
40+
<Page>
41+
<ActionBar :title="navbarTitle"/>
42+
<GridLayout rows="auto, auto">
43+
<Button text="Home" @tap="goToHomePage" row="0"/>
44+
<Button text="About" @tap="goToAboutPage" row="1"/>
45+
</GridLayout>
46+
</Page>
47+
</template>
48+
<script>
49+
// ~ is an alias to /src
50+
import Home from '~/views/Home';
51+
import About from '~/views/About';
52+
53+
export default {
54+
55+
data() {
56+
return {
57+
navbarTitle: 'App.native.vue',
58+
}
59+
},
60+
methods: {
61+
goToHomePage() {
62+
this.$navigateTo(Home);
63+
},
64+
goToAboutPage() {
65+
this.$navigateTo(About);
66+
}
67+
}
68+
}
69+
70+
</script>
71+
<%_ } _%>
72+
73+
<%_ if (rootOptions.cssPreprocessor !== 'stylus') { _%>
74+
<style<%-
75+
rootOptions.cssPreprocessor
76+
? ` lang="${
77+
rootOptions.cssPreprocessor === 'sass'
78+
? 'scss'
79+
: rootOptions.cssPreprocessor
80+
}"`
81+
: ``
82+
%>>
83+
ActionBar {
84+
color: #42b983;
85+
}
86+
</style>
87+
<%_ } else { _%>
88+
<style lang="stylus">
89+
ActionBar
90+
color: #42b983
91+
</style>
92+
<%_ } _%>

0 commit comments

Comments
 (0)