-
Notifications
You must be signed in to change notification settings - Fork 1
/
Cakefile
146 lines (128 loc) · 4.69 KB
/
Cakefile
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
###
#+--------------------------------------------------------------------+
#| Cakefile
#+--------------------------------------------------------------------+
#| Copyright DarkOverlordOfData (c) 2014-2015
#+--------------------------------------------------------------------+
#|
#| workflow
#|
#| workflow is free software; you can copy, modify, and distribute
#| it under the terms of the MIT License
#|
#+--------------------------------------------------------------------+
#
# | -- .settings for vscode
# | | -- launch.json F5 to run
# | | -- settings.json ide preferences
# | + -- tasks.json npm script runner
# | -- bin public tools
# | -- build compiled output
# | -- example example using the lib
# | -- lib sources for this project - library or application
# | -- node_modules npm dependencies
# | -- packages local repository
# | -- test unit tests
# | -- tools private tools
# | | -- compiler.jar closure compiler
# | | -- convert.coffee coffee2closure script
# | | -- diff.coffee diff_match_patch script
# | + -- server.js for F5 in vscode
# | -- web application root. For library, this uses example
# | | -- index.html default web page
# | | -- main.js* cocos2d default script
# | | -- project.json* cocos2d manifest
# | | -- frameworks* cocos2d lib
# | | -- res resources
# | + -- src transpiler target, respository pre-builts
# | | -- {lib}
# | | -- example
# | + -- ...
# | -- .bowerrc defines ./packages repository
# | -- travis.yaml* ci template
# | -- bower.json module name, packages
# | -- Cakefile misc tasks
# | -- changes.md change log
# | -- conf.json* jsdoc configuration
# | -- csconfig.json* coffeescript source file list
# | -- gulpfile.js npm script runner for webstorm ide
# | -- index.js require entry point
# | -- jsconfig.json javascript source file list
# | -- LF insert \n between source files with cat
# | -- license.md take your pick - MIT/GPL3
# | -- package.json node project info
# + -- tsconfig.json* typescript project file
#
###
###
* config
*
* inject scripts into package.json
*
###
task 'config', 'generate package.json:scripts', (options) ->
project = require('./package.json')
scripts = require('./package.scripts')
for name, script of scripts(project, options)
if Array.isArray(script)
script = script.join(' & ')
project.scripts[name] = (script || '').split('\n').join(' && ')
require('fs').writeFileSync('./package.json', JSON.stringify(project, null, ' '), 'utf8')
###
* cocos
*
* run cocos to build android apk
###
task 'cocos', 'run the cocos2d generator', (options) ->
require('child_process').exec """
cd web && cocos compile -p android --ndk-mode debug --android-studio
""", (err, out) ->
throw err if err
console.log out
###
* get patch
*
* get dependencies
###
task 'get', 'get dependencies from bower repository', (options) ->
#patch "web/src/jmatch3/jmatch3.js", "tools/patch/jmatch3.js.patch"
#patch "web/src/tween.ts/tween.min.js", "tools/patch/tween.min.js.patch"
###
* Patch
*
* @see https://code.google.com/p/google-diff-match-patch/
*
* @param {string} source filename
* @param {string} changes patch filename
###
patch = (source, changes) ->
DiffMatchPatch = require('./tools/diff_match_patch/javascript/diff_match_patch_uncompressed.js').diff_match_patch
dmp = new DiffMatchPatch()
orig = fs.readFileSync(source, 'utf8')
delta = fs.readFileSync(changes, 'utf8')
results = dmp.patch_apply(dmp.patch_fromText(delta), orig)
fs.writeFileSync(source, results[0])
###
* version bump
*
* bump the version number
* write the version source file
*
* cake -v patch version
* cake -v minor version
* cale -v major version
###
task 'version', 'bump the version', (options) ->
options.version ?= 'patch'
project = require('./package.json')
###
*
* Q but doesn't npm already do thsi?
* A if fails from the ide because I track my workspace in git
###
project.version = require('semver').inc(project.version, options.version)
fs.writeFileSync('./package.json', JSON.stringify(project, null, ' '))
liquid = require('liquid.coffee')
tpl = fs.readFileSync('./lib/src/build.ts.tpl', 'utf8')
fs.writeFileSync('./lib/src/build.ts', liquid.Template.parse(tpl).render(VERSION: project.version))
task 'test', 'test', (options) ->