Skip to content

Commit 4b10153

Browse files
committed
Upgrade to 2.0 plus additional edits
1 parent 9b34e6e commit 4b10153

File tree

9 files changed

+326
-98
lines changed

9 files changed

+326
-98
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ node_modules
22
.DS_Store
33
docs/_book
44
.vscode
5+
6+
# Byte-compiled / optimized / DLL files
7+
__pycache__/
8+
*.py[cod]
9+
*$py.class

deploy-docs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ cd _book
55
git init
66
git add -A
77
git commit -m 'update book'
8-
git push -f [email protected]:vuejs-templates/webpack.git master:gh-pages
8+
git push -f [email protected]:NdagiStanley/vue-django.git master:gh-pages

docs/README.md

+31-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,21 @@
1414
[![Updates](https://pyup.io/repos/github/NdagiStanley/vue-django/shield.svg)](https://pyup.io/repos/github/NdagiStanley/vue-django/)
1515
[![Python 3](https://pyup.io/repos/github/NdagiStanley/vue-django/python-3-shield.svg)](https://pyup.io/repos/github/NdagiStanley/vue-django/)
1616

17-
[https://vuedjango.herokuapp.com/](https://vuedjango.herokuapp.com/) is a deployed instance of this boilerplate.
17+
[https://vuedjango.herokuapp.com/](https://vuedjango.herokuapp.com/) is a deployed instance of this boilerplate. There is a docker image for vue-django that you can run to check it out locally:
18+
```bash
19+
docker run -p 8000:8000 stanmd/vue-django python manage.py runserver 0.0.0.0:8000
20+
```
1821

1922
<p align="center">
2023
<b>Listed in</b>
2124
<br>
2225
<a href="https://github.com/vuejs/awesome-vue#scaffold" target="_blank"><img src="https://camo.githubusercontent.com/224f79940611c6c12fb649128eca1cae31086d23/68747470733a2f2f7261776769742e636f6d2f7675656a732f617765736f6d652d7675652f6d61737465722f6c6f676f2e706e67" align="center" height="150" alt="Awesome VueJS"></a>
2326
</p>
2427

28+
<p align="center">
29+
<img src="http://i.imgur.com/sY3IpBE.png?1" align="center" height="500" alt="Vue-Django">
30+
</p>
31+
2532
## Usage of Vue-Django
2633

2734
This is a project template that includes `VueJS` and `Django` based on the [vue-cli](https://github.com/vuejs/vue-cli) templates. **It is recommended to use npm 3+ for a more efficient dependency tree.**
@@ -32,34 +39,50 @@ To use this template, scaffold a project with [vue-cli](https://github.com/vuejs
3239

3340
``` bash
3441
$ npm install -g vue-cli
42+
```
43+
44+
You might want to use ```sudo``` if you encounter permissions error
45+
46+
```bash
3547
$ vue init NdagiStanley/vue-django my-project
48+
```
49+
If you desire to use VueJS version 1.x run: `vue init NdagiStanley/vue-django#1.0 my-project` instead.
50+
51+
`my-project` can be replaced with the directory name you prefer. If you do decide on another name take care to replace the next occurence of `my-project` with your new directory name.
52+
53+
```bash
3654
$ cd my-project
3755
$ npm install
3856
$ npm run dev
3957
```
4058

41-
### Deploy with Django
59+
### Deploy with Django (Locally)
4260

43-
Ensure python and pip is installed.
61+
Ensure python and pip is installed. Preferably create a virtual environment for the project.
4462

4563
```bash
4664
$ npm run build
4765
$ pip install -r requirements.txt
4866
$ python format_index_html.py
4967
$ python manage.py collectstatic --noinput
50-
$ python manage.py runserver
68+
$ python manage.py runserver 0.0.0.0:8000
69+
```
70+
71+
The 5 commands above are contained in the `deploy.sh` so running the script is as good as running the aforementioned commands:
72+
```
73+
$ ./deploy.sh
5174
```
5275

53-
Open the app [here](localhost:8000)
76+
Open the app at [localhost:8000](localhost:8000)
5477

55-
### Deploy with Docker
78+
### Deploy with Docker (Locally)
5679

57-
Ensure that docker is running.
80+
Ensure that docker is installed and running. To install `docker` take your pick [here](https://www.docker.com/community-edition) based on your Operating System.
5881

5982
If you use docker in your workflow, there is a Dockerfile (that you can build an image from) in the root directory for you. `docker-compose` is the easiest way to get up and running. Simply run:
6083

6184
```bash
6285
$ docker-compose up
6386
```
6487

65-
Open the app [here](localhost:8000)
88+
Open the app at [localhost:8000](localhost:8000). You'll have to stop the Django server if you ran it earlier or change the port within the `deploy.sh` from `8000` to something else.

meta.js

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
module.exports = {
2+
"helpers": {
3+
"if_or": function (v1, v2, options) {
4+
if (v1 || v2) {
5+
return options.fn(this);
6+
}
7+
8+
return options.inverse(this);
9+
}
10+
},
11+
"prompts": {
12+
"name": {
13+
"type": "string",
14+
"required": true,
15+
"message": "Project name"
16+
},
17+
"version": {
18+
"type": "string",
19+
"required": true,
20+
"label": "Project version",
21+
"default": "0.1.0"
22+
},
23+
"description": {
24+
"type": "string",
25+
"required": false,
26+
"message": "Project description",
27+
"default": "A Django - Vue.js project"
28+
},
29+
"author": {
30+
"type": "string",
31+
"message": "Author"
32+
},
33+
"private": {
34+
"type": "boolean",
35+
"default": true
36+
},
37+
"build": {
38+
"type": "list",
39+
"message": "Vue build",
40+
"choices": [
41+
{
42+
"name": "Runtime + Compiler: recommended for most users",
43+
"value": "standalone",
44+
"short": "standalone"
45+
},
46+
{
47+
"name": "Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere",
48+
"value": "runtime",
49+
"short": "runtime"
50+
}
51+
]
52+
},
53+
"router": {
54+
"type": "confirm",
55+
"message": "Install vue-router?"
56+
},
57+
"lint": {
58+
"type": "confirm",
59+
"message": "Use ESLint to lint your code?"
60+
},
61+
"lintConfig": {
62+
"when": "lint",
63+
"type": "list",
64+
"message": "Pick an ESLint preset",
65+
"choices": [
66+
{
67+
"name": "Standard (https://github.com/standard/standard)",
68+
"value": "standard",
69+
"short": "Standard"
70+
},
71+
{
72+
"name": "Airbnb (https://github.com/airbnb/javascript)",
73+
"value": "airbnb",
74+
"short": "Airbnb"
75+
},
76+
{
77+
"name": "none (configure it yourself)",
78+
"value": "none",
79+
"short": "none"
80+
}
81+
]
82+
},
83+
"unit": {
84+
"type": "confirm",
85+
"message": "Setup unit tests"
86+
},
87+
"runner": {
88+
"when": "unit",
89+
"type": "list",
90+
"message": "Pick a test runner",
91+
"choices": [
92+
{
93+
"name": "Jest",
94+
"value": "jest",
95+
"short": "jest"
96+
},
97+
{
98+
"name": "Karma and Mocha",
99+
"value": "karma",
100+
"short": "karma"
101+
},
102+
{
103+
"name": "none (configure it yourself)",
104+
"value": "noTest",
105+
"short": "noTest"
106+
}
107+
]
108+
},
109+
"e2e": {
110+
"type": "confirm",
111+
"message": "Setup e2e tests with Nightwatch?"
112+
}
113+
},
114+
"filters": {
115+
".eslintrc.js": "lint",
116+
".eslintignore": "lint",
117+
"config/test.env.js": "unit || e2e",
118+
"build/webpack.test.conf.js": "e2e || (unit && runner === 'karma')",
119+
"test/unit/**/*": "unit",
120+
"test/unit/index.js": "unit && runner === 'karma'",
121+
"test/unit/jest.conf.js": "unit && runner === 'jest'",
122+
"test/unit/karma.conf.js": "unit && runner === 'karma'",
123+
"test/unit/specs/index.js": "unit && runner === 'karma'",
124+
"test/unit/setup.js": "unit && runner === 'jest'",
125+
"test/e2e/**/*": "e2e",
126+
"src/router/**/*": "router"
127+
},
128+
"completeMessage": "To get started:\n\n {{^inPlace}}cd {{destDirName}}\n {{/inPlace}}npm install\n npm run dev\n\nTo build and serve in Django:\n\n ./deploy.sh\n\nDocumentation can be found at https://goo.gl/V4eN7h"
129+
};

meta.json

-29
This file was deleted.

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
2-
"name": "vue-cli-template-webpack",
3-
"version": "1.0.0",
2+
"name": "vue-cli-template-vue-django-webpack",
3+
"version": "2.0.0",
44
"license": "MIT",
5-
"description": "A full-featured Webpack setup with hot-reload, lint-on-save, unit testing & css extraction.",
5+
"description": "A full-featured Webpack setup with hot-reload, lint-on-save, unit testing & css extraction integrated into a django application",
66
"scripts": {
77
"docs": "cd docs && gitbook serve",
88
"deploy-docs": "bash ./deploy-docs.sh"
9+
},
10+
"devDependencies": {
11+
"vue-cli": "^2.8.1"
912
}
1013
}

template/.gitignore

+34
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,37 @@ npm-debug.log
55
selenium-debug.log
66
test/unit/coverage
77
test/e2e/reports
8+
9+
# Byte-compiled / optimized / DLL files
10+
__pycache__/
11+
*.py[cod]
12+
*$py.class
13+
14+
# Unit test / coverage reports
15+
htmlcov/
16+
.tox/
17+
.coverage
18+
.coverage.*
19+
.cache
20+
nosetests.xml
21+
coverage.xml
22+
*.cover
23+
.hypothesis/
24+
25+
# Django stuff:
26+
*.log
27+
local_settings.py
28+
29+
# dotenv
30+
.env
31+
32+
# virtualenv
33+
.venv
34+
venv/
35+
ENV/
36+
37+
# mkdocs documentation
38+
/site
39+
40+
# mypy
41+
.mypy_cache/

template/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
FROM node
22
RUN apt-get update
3+
4+
# Install python, pip and python packages
35
RUN apt-get install -y python
46
RUN curl https://bootstrap.pypa.io/get-pip.py | python
57
WORKDIR /usr/bin/app
68
COPY requirements.txt .
79
RUN pip install -r requirements.txt
10+
11+
# Run the following commands for deployment
812
COPY . .
913
RUN npm run build
1014
RUN python format_index_html.py
1115
RUN python manage.py collectstatic --noinput
16+
17+
# EXPOSE port to be used
1218
EXPOSE 8000
19+
20+
# Set command to run as soon as container is up
1321
CMD python manage.py runserver 0.0.0.0:8000

0 commit comments

Comments
 (0)