This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.coffee
99 lines (82 loc) · 3.35 KB
/
Gruntfile.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
# node requirements
path = require "path"
fs = require "fs"
cp = require "child_process"
async = require "async"
# meta informations
application_name = "AppTemplate"
# ExtJS location, Ext.Router location, sencha CMD version
sencha_base = path.resolve "../../js/Sencha"
process.env.SENCHA_VERSION="5.1.3.61"
module.exports = (grunt) ->
# Do grunt-related things in here
grunt.initConfig
pkg: grunt.file.readJSON("package.json")
# config
cfg:
version_file: "static/resources/version.json"
# watch files
watch:
options:
livereload: yes
app:
files: [
"src/#{application_name}/app.coffee",
"src/#{application_name}/app/**/*"
"static/index.html"
]
tasks: [
"coffee"
"copy"
"bump_version"
]
copy:
wttemplate:
files: [
cwd: "static"
src: ["app.json", "app.js", "app/*.js", "app/**/*.js"]
dest: "static/build/windchill/#{application_name}/static"
expand: yes
]
# coffee compile task
coffee:
app:
options: # coffee compile options
sourceMap: yes
expand: yes # use dynamic glob patterns when expanding src
cwd: "src/#{application_name}" # all src paths are relative to here
src: [ "*.coffee","**/*.coffee" ]
dest: "static"
ext: ".js"
grunt.loadNpmTasks "grunt-node-webkit-builder"
grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks "grunt-contrib-watch"
grunt.loadNpmTasks "grunt-contrib-uglify"
grunt.loadNpmTasks "grunt-contrib-copy"
grunt.loadNpmTasks "grunt-notify"
grunt.registerTask "default", ["watch"]
grunt.registerTask "build", ["coffee", "copy", "sencha"]
grunt.registerTask "version", "show the web app version", ->
version_file = grunt.config.get "cfg.version_file"
version = JSON.parse fs.readFileSync version_file
grunt.log.write "#{version.name} v#{version.version} - build #{version.build} - date #{version.date}"
grunt.registerTask "bump_version", "bump the web app version", ->
grunt.log.write "bumping version ...."
version_file = grunt.config.get "cfg.version_file"
version = JSON.parse fs.readFileSync version_file
version.build += 1
d = new Date()
version.date = "#{d.getFullYear()}-#{d.getMonth()+1}-#{d.getDate()}"
fs.writeFileSync version_file, JSON.stringify version
grunt.log.write "#{version.name} v#{version.version} - build #{version.build} - date #{version.date}"
grunt.registerTask "sencha", "build the application with 'sencha cmd'", ->
done = @async()
cmd = cp.exec "sencha app build", {cwd: "static"}
cmd.stdout.on "data", (data) ->
grunt.log.write "stdout: " + data
cmd.stderr.on "data", (data) ->
grunt.log.write "stderr: " + data
cmd.on 'close', (code) ->
grunt.log.write 'child process exited with code ' + code
done(code)
# vim: set nolist ts=4 sw=4 expandtab :