This repository has been archived by the owner on Jan 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.coffee
185 lines (157 loc) · 4.14 KB
/
index.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
'use strict'
# Require main modules.
yeoman = require 'yeoman-generator'
chalk = require 'chalk'
yosay = require 'yosay'
module.exports = yeoman.generators.Base.extend(
#
# Init.
#
initializing: ->
@pkg = require('../package.json')
return
#
# Prompt the user for options.
#
prompting: ->
done = @async()
# Have Yeoman greet the user.
@log yosay('Welcome to the delightful' + chalk.red('DjangoAxiacore') + ' generator!')
prompts = [
{
type: 'input'
name: 'name'
message: 'Project slug'
default: @appname
}
{
type: 'input'
name: 'description'
message: 'Project description'
default: 'description'
}
{
type: 'list'
name: 'cssFramework'
message: 'What css framework do you want to use?'
choices: [
{
name: 'Materialize'
value: 'materialize'
checked: true
}
{
name: 'Bootstrap'
value: 'bootstrap'
checked: false
}
]
default: 'materialize'
}
{
type: 'confirm'
name: 'useCoffeeScript'
message: 'Would you like to use CoffeeScript?'
default: false
}
{
type: 'input'
name: 'adminSiteName'
message: 'Admin site name'
default: 'Administrador de ' + @appname
}
{
type: 'input'
name: 'dbName'
message: 'What\'s the name of your database?'
default: @appname
}
{
type: 'input'
name: 'dbUser'
message: 'What\'s the user of your database?'
default: 'django'
}
{
type: 'input'
name: 'dbPass'
message: 'What\'s your database password?'
default: 'django'
}
]
# Assign prompts settings.
@prompt prompts, ((props) ->
# App info.
@name = props.name
@description = props.description
@cssFramework = props.cssFramework
@useCoffeeScript = props.useCoffeeScript
# Database.
@dbName = props.dbName
@dbUser = props.dbUser
@dbPass = props.dbPass
@adminSiteName = props.adminSiteName
done()
).bind(this)
#
# Copy files.
#
writing:
app: ->
# Package.
@template '_package.json', 'package.json', this,
name: @name
description: @description
# Bower.
@template '_bower.json', 'bower.json', this,
name: @name
description: @description
# Gulpfile.
@template 'gulpfile.js', 'gulpfile.js', this,
useCoffeeScript: @useCoffeeScript
# Local settings.
@template 'local_settings.py', 'app/local_settings.py', this,
dbName: @dbName
dbUser: @dbUser
dbPass: @dbPass
# Gemfile.
@copy 'Gemfile', 'Gemfile'
projectfiles: ->
# Copy dotfiles and other files.
@copy 'editorconfig', '.editorconfig'
@copy 'jshintignore', '.jshintignore'
@copy 'requirements.txt', 'requirements.txt'
@copy 'LICENCE.md', 'LICENCE.md'
@copy 'gitignore', '.gitignore'
@copy 'bowerrc', '.bowerrc'
@copy 'manage.py', 'manage.py'
# Directories.
@directory 'conf', 'conf'
@directory 'doc', 'doc'
@directory 'app', 'app'
@directory 'bundle', '.bundle'
@directory 'shell-scripts', 'shell-scripts'
# Settings.
@template 'settings.py', 'app/settings.py', this, adminSiteName: @adminSiteName
# Are we using CoffeeScript.
@copy 'main.sample.coffee', 'app/static/coffeescript/main.coffee'
#
# Called after all files are copied.
#
install: ->
@installDependencies skipInstall: @options['skip-install']
that = this
# Initialize a git repository.
@spawnCommand('git', [ 'init' ]).on 'close', ->
# Set origin.
that.spawnCommand 'git', [
'remote'
'add'
'origin'
'git@bitbucket.org:axiacore/' + that.repoSlug + '.git'
]
# Install Gems.
@spawnCommand 'bundle', ['install']
# Repository creation.
@spawnCommand 'shell-scripts/prepare_environment.sh', [@dbName]
)