Move build functionality into Makefile.
This commit is contained in:
parent
0fe7e6e11e
commit
9c4354d4f3
161
Gruntfile.coffee
161
Gruntfile.coffee
@ -15,109 +15,22 @@ module.exports = (grunt) ->
|
||||
|
||||
BIN: ['node_modules', '.bin', ''].join(path.sep)
|
||||
|
||||
sources: grunt.file.expand [
|
||||
'src/General/Config.coffee'
|
||||
'src/General/Globals.coffee'
|
||||
'src/General/$.coffee'
|
||||
'src/classes/Callbacks.coffee'
|
||||
'src/classes/Board.coffee'
|
||||
'src/classes/Thread.coffee'
|
||||
'src/classes/CatalogThread.coffee'
|
||||
'src/classes/Post.coffee'
|
||||
'src/classes/Clone.coffee'
|
||||
'src/classes/DataBoard.coffee'
|
||||
'src/classes/Notice.coffee'
|
||||
'src/classes/RandomAccessList.coffee'
|
||||
'src/classes/SimpleDict.coffee'
|
||||
'src/classes/Set.coffee'
|
||||
'src/classes/Connection.coffee'
|
||||
'src/classes/Fetcher.coffee'
|
||||
'src/General/Polyfill.coffee'
|
||||
'src/General/Header.coffee'
|
||||
'src/General/Index.coffee'
|
||||
'src/General/Build.coffee'
|
||||
'src/General/Get.coffee'
|
||||
'src/General/UI.coffee'
|
||||
'src/General/Notice.coffee'
|
||||
'src/General/CrossOrigin.coffee'
|
||||
'src/General/BuildTest.coffee'
|
||||
'src/Filtering/*.coffee'
|
||||
'src/Quotelinks/*.coffee'
|
||||
'src/Posting/QR.coffee'
|
||||
'src/Posting/Captcha.coffee'
|
||||
'src/Posting/*.coffee'
|
||||
'src/Images/*.coffee'
|
||||
'src/Linkification/*.coffee'
|
||||
'src/Menu/*.coffee'
|
||||
'src/Monitoring/*.coffee'
|
||||
'src/Archive/*.coffee'
|
||||
'src/Miscellaneous/*.coffee'
|
||||
'src/General/Settings.coffee'
|
||||
'src/General/Main.coffee'
|
||||
]
|
||||
|
||||
icons: ['icon128.png', 'icon16.png', 'icon48.png']
|
||||
|
||||
builds:
|
||||
("4chan-X#{c}.crx updates#{c}.xml 4chan-X#{c}.user.js 4chan-X#{c}.meta.js" for c in ['', '-beta']).join(' ').split(' ').concat [
|
||||
'4chan-X-noupdate.crx', '4chan-X-noupdate.user.js', '4chan-X.zip'
|
||||
]
|
||||
|
||||
concurrent:
|
||||
build: [
|
||||
'build-crx'
|
||||
'build-userscript'
|
||||
]
|
||||
|
||||
shell:
|
||||
options:
|
||||
stdout: true
|
||||
stderr: true
|
||||
failOnError: true
|
||||
build:
|
||||
command: 'make'
|
||||
full:
|
||||
command: """
|
||||
make clean
|
||||
make all
|
||||
""".split('\n').join('&&')
|
||||
clean:
|
||||
command: 'node tools/clean.js'
|
||||
general:
|
||||
command: """
|
||||
<%= BIN %>coffee tools/templates.coffee src/meta/jshint.json .jshintrc
|
||||
node tools/cat.js <%= sources.join(' ') %> tmp/script.coffee
|
||||
""".split('\n').join('&&')
|
||||
crx:
|
||||
command: """
|
||||
<%= BIN %>coffee tools/templates.coffee tmp/script.coffee tmp/script-crx.coffee type=crx
|
||||
<%= BIN %>coffee --no-header -c tmp/script-crx.coffee
|
||||
<%= BIN %>coffee --no-header -o tmp -c src/General/eventPage.coffee
|
||||
<%= BIN %>jshint tmp/script-crx.js tmp/eventPage.js
|
||||
""".split('\n').join('&&')
|
||||
'crx-channel':
|
||||
command: (channel='') -> """
|
||||
<%= BIN %>coffee tools/templates.coffee src/meta/updates.xml testbuilds/updates#{channel}.xml type=crx channel=#{channel}
|
||||
<%= BIN %>coffee tools/templates.coffee src/meta/manifest.json testbuilds/crx#{channel}/manifest.json type=crx channel=#{channel}
|
||||
node tools/cat.js src/meta/botproc.js LICENSE src/meta/usestrict.js tmp/script-crx.js testbuilds/crx#{channel}/script.js
|
||||
<%= icons.map(file => `node tools/cp.js src/meta/${file} testbuilds/crx#{channel}/${file}`).join('&&') %>
|
||||
node tools/cp.js tmp/eventPage.js testbuilds/crx#{channel}/eventPage.js
|
||||
node tools/zip-crx.js #{channel}
|
||||
""".split('\n').join('&&')
|
||||
'copy-zip':
|
||||
command: 'node tools/cp.js testbuilds/<%= pkg.name %>-noupdate.crx.zip testbuilds/<%= pkg.name %>.zip'
|
||||
userscript:
|
||||
command: """
|
||||
<%= BIN %>coffee tools/templates.coffee tmp/script.coffee tmp/script-userscript.coffee type=userscript
|
||||
<%= BIN %>coffee --no-header -c tmp/script-userscript.coffee
|
||||
<%= BIN %>jshint tmp/script-userscript.js
|
||||
""".split('\n').join('&&')
|
||||
'userscript-channel':
|
||||
command: (channel='') -> """
|
||||
<%= BIN %>coffee tools/templates.coffee src/meta/metadata.js testbuilds/<%= pkg.name %>#{channel}.meta.js type=userscript channel=#{channel}
|
||||
node tools/cat.js src/meta/botproc.js testbuilds/<%= pkg.name %>#{channel}.meta.js LICENSE src/meta/usestrict.js tmp/script-userscript.js testbuilds/<%= pkg.name %>#{channel}.user.js
|
||||
""".split('\n').join('&&')
|
||||
install:
|
||||
command: 'node tools/install.js'
|
||||
sign:
|
||||
command: (channel='') -> "node tools/sign.js #{channel}"
|
||||
'copy-builds':
|
||||
command: '<%= builds.map(file => `node tools/cp.js testbuilds/${file} builds/${file}`).join("&&") %>'
|
||||
command: 'make clean'
|
||||
markdown:
|
||||
command: 'node tools/markdown.js'
|
||||
command: 'make test.html'
|
||||
commit:
|
||||
command: """
|
||||
git commit -am "Release <%= pkg.meta.name %> v<%= pkg.meta.version %>."
|
||||
@ -176,8 +89,6 @@ module.exports = (grunt) ->
|
||||
<%= BIN %>coffee tools/templates.coffee redirect.html captchas.html url=#{process.env.url || 'https://www.4chan.org/feedback'}
|
||||
aws s3 cp captchas.html s3://<%= pkg.meta.awsBucket %> --cache-control "max-age=0" --content-type "text/html; charset=utf-8"
|
||||
""".split('\n').join('&&')
|
||||
npm:
|
||||
command: 'npm install'
|
||||
update:
|
||||
command: """
|
||||
npm install --save-dev <%= Object.keys(pkg.devDependencies).filter(function(name) {return /^\\^/.test(pkg.devDependencies[name]);}).map(function(name) {return name+'@latest';}).join(' ') %>
|
||||
@ -203,6 +114,9 @@ module.exports = (grunt) ->
|
||||
'build'
|
||||
]
|
||||
|
||||
for task in ['clean', 'markdown', 'push', 'captchas']
|
||||
grunt.registerTask task, ["shell:#{task}"]
|
||||
|
||||
grunt.registerTask 'set-tests', 'Set whether to include testing code', (value) ->
|
||||
try
|
||||
oldValue = grunt.file.readJSON '.tests_enabled'
|
||||
@ -211,49 +125,18 @@ module.exports = (grunt) ->
|
||||
grunt.file.write '.tests_enabled', value
|
||||
|
||||
grunt.registerTask 'build', [
|
||||
'shell:npm'
|
||||
'set-tests:false'
|
||||
'shell:general'
|
||||
'concurrent:build'
|
||||
'shell:build'
|
||||
]
|
||||
|
||||
grunt.registerTask 'build-tests', [
|
||||
'shell:npm'
|
||||
'set-tests:true'
|
||||
'shell:general'
|
||||
'concurrent:build'
|
||||
]
|
||||
|
||||
grunt.registerTask 'build-crx', [
|
||||
'shell:crx'
|
||||
'shell:crx-channel'
|
||||
'shell:crx-channel:-beta'
|
||||
'shell:crx-channel:-noupdate'
|
||||
'shell:copy-zip'
|
||||
]
|
||||
|
||||
grunt.registerTask 'sign', [
|
||||
'shell:sign'
|
||||
'shell:sign:-beta'
|
||||
'shell:sign:-noupdate'
|
||||
]
|
||||
|
||||
grunt.registerTask 'build-userscript', [
|
||||
'shell:userscript'
|
||||
'shell:userscript-channel'
|
||||
'shell:userscript-channel:-beta'
|
||||
'shell:userscript-channel:-noupdate'
|
||||
'shell:install'
|
||||
]
|
||||
|
||||
grunt.registerTask 'clean', [
|
||||
'shell:clean'
|
||||
'shell:build'
|
||||
]
|
||||
|
||||
grunt.registerTask 'full', [
|
||||
'build'
|
||||
'sign'
|
||||
'shell:copy-builds'
|
||||
'set-tests:false'
|
||||
'shell:full'
|
||||
]
|
||||
|
||||
grunt.registerTask 'tag', 'Tag a new release', (version) ->
|
||||
@ -295,10 +178,6 @@ module.exports = (grunt) ->
|
||||
'popd'
|
||||
]
|
||||
|
||||
grunt.registerTask 'markdown', [
|
||||
'shell:markdown'
|
||||
]
|
||||
|
||||
grunt.registerTask 'web', [
|
||||
'shell:markdown'
|
||||
'pushd'
|
||||
@ -306,10 +185,6 @@ module.exports = (grunt) ->
|
||||
'popd'
|
||||
]
|
||||
|
||||
grunt.registerTask 'push', [
|
||||
'shell:push'
|
||||
]
|
||||
|
||||
grunt.registerTask 'aws', [
|
||||
'pushd'
|
||||
'shell:aws'
|
||||
@ -322,10 +197,6 @@ module.exports = (grunt) ->
|
||||
'popd'
|
||||
]
|
||||
|
||||
grunt.registerTask 'captchas', [
|
||||
'shell:captchas'
|
||||
]
|
||||
|
||||
grunt.registerTask 'setversion', 'Set the version number', (version) ->
|
||||
data = grunt.file.readJSON 'version.json'
|
||||
oldversion = data.version
|
||||
|
||||
165
Makefile
Normal file
165
Makefile
Normal file
@ -0,0 +1,165 @@
|
||||
name := 4chan-X
|
||||
BIN := node_modules/.bin/
|
||||
coffee := $(BIN)coffee -c --no-header
|
||||
coffee_deps := node_modules/coffee-script/package.json
|
||||
template := $(BIN)coffee tools/templates.coffee
|
||||
template_deps := \
|
||||
package.json version.json \
|
||||
tools/templates.coffee \
|
||||
node_modules/coffee-script/package.json node_modules/fs-extra/package.json node_modules/lodash/package.json node_modules/glob/package.json
|
||||
cp := node tools/cp.js
|
||||
cp_deps := tools/cp.js node_modules/fs-extra/package.json
|
||||
cat := node tools/cat.js
|
||||
cat_deps := tools/cat.js node_modules/fs-extra/package.json
|
||||
jshint_deps := .jshintrc node_modules/jshint/package.json
|
||||
|
||||
sources := \
|
||||
src/General/Config.coffee \
|
||||
src/General/Globals.coffee \
|
||||
src/General/$$.coffee \
|
||||
src/classes/Callbacks.coffee \
|
||||
src/classes/Board.coffee \
|
||||
src/classes/Thread.coffee \
|
||||
src/classes/CatalogThread.coffee \
|
||||
src/classes/Post.coffee \
|
||||
src/classes/Clone.coffee \
|
||||
src/classes/DataBoard.coffee \
|
||||
src/classes/Notice.coffee \
|
||||
src/classes/RandomAccessList.coffee \
|
||||
src/classes/SimpleDict.coffee \
|
||||
src/classes/Set.coffee \
|
||||
src/classes/Connection.coffee \
|
||||
src/classes/Fetcher.coffee \
|
||||
src/General/Polyfill.coffee \
|
||||
src/General/Header.coffee \
|
||||
src/General/Index.coffee \
|
||||
src/General/Build.coffee \
|
||||
src/General/Get.coffee \
|
||||
src/General/UI.coffee \
|
||||
src/General/CrossOrigin.coffee \
|
||||
src/General/BuildTest.coffee \
|
||||
$(sort $(wildcard src/Filtering/*.coffee)) \
|
||||
$(sort $(wildcard src/Quotelinks/*.coffee)) \
|
||||
src/Posting/QR.coffee \
|
||||
src/Posting/Captcha.coffee \
|
||||
$(sort $(wildcard src/Posting/Captcha.*.coffee)) \
|
||||
src/Posting/PassLink.coffee \
|
||||
src/Posting/PostSuccessful.coffee \
|
||||
$(sort $(wildcard src/Posting/QR.*.coffee)) \
|
||||
$(sort $(wildcard src/Images/*.coffee)) \
|
||||
$(sort $(wildcard src/Linkification/*.coffee)) \
|
||||
$(sort $(wildcard src/Menu/*.coffee)) \
|
||||
$(sort $(wildcard src/Monitoring/*.coffee)) \
|
||||
$(sort $(wildcard src/Archive/*.coffee)) \
|
||||
$(sort $(wildcard src/Miscellaneous/*.coffee)) \
|
||||
src/General/Settings.coffee \
|
||||
src/General/Main.coffee
|
||||
|
||||
imports := \
|
||||
node_modules/font-awesome/package.json \
|
||||
$(wildcard src/Linkification/icons/*.png) \
|
||||
src/Archive/archives.json \
|
||||
src/meta/icon48.png \
|
||||
$(wildcard src/Monitoring/Favicon/*/*.png) \
|
||||
src/Monitoring/Favicon/dead.gif \
|
||||
src/meta/icon128.png \
|
||||
src/Monitoring/beep.wav \
|
||||
src/Miscellaneous/banners.json \
|
||||
$(wildcard src/*/*.html) \
|
||||
$(wildcard src/*/*/*.html) \
|
||||
$(wildcard src/css/*.css) \
|
||||
.tests_enabled
|
||||
|
||||
builds := \
|
||||
$(foreach c,. -beta.,$(name)$(c)crx updates$(c)xml $(name)$(c)user.js $(name)$(c)meta.js) \
|
||||
$(name)-noupdate.crx \
|
||||
$(name)-noupdate.user.js \
|
||||
$(name).zip
|
||||
|
||||
default : install
|
||||
|
||||
all : builds
|
||||
|
||||
node_modules/%/package.json : npm-shrinkwrap.json
|
||||
npm install $*
|
||||
|
||||
.tests_enabled :
|
||||
echo false> .tests_enabled
|
||||
|
||||
tmp/script.coffee : $(sources) $(cat_deps)
|
||||
$(cat) $(sources) $@
|
||||
|
||||
tmp/script-%.coffee : tmp/script.coffee $(imports) $(template_deps)
|
||||
$(template) $< $@ type=$*
|
||||
|
||||
tmp/script-%.js : tmp/script-%.coffee $(coffee_deps)
|
||||
$(coffee) $<
|
||||
|
||||
tmp/eventPage.js : src/General/eventPage.coffee $(coffee_deps)
|
||||
$(coffee) -o tmp src/General/eventPage.coffee
|
||||
|
||||
define rules_channel
|
||||
|
||||
testbuilds/crx$1/script.js : src/meta/botproc.js LICENSE src/meta/usestrict.js tmp/script-crx.js $(cat_deps)
|
||||
$(cat) src/meta/botproc.js LICENSE src/meta/usestrict.js tmp/script-crx.js $$@
|
||||
|
||||
testbuilds/crx$1/eventPage.js : tmp/eventPage.js $(cp_deps)
|
||||
$(cp) $$< $$@
|
||||
|
||||
testbuilds/crx$1/icon%.png : src/meta/icon%.png $(cp_deps)
|
||||
$(cp) $$< $$@
|
||||
|
||||
testbuilds/crx$1/manifest.json : src/meta/manifest.json $(template_deps)
|
||||
$(template) $$< $$@ type=crx channel=$1
|
||||
|
||||
testbuilds/updates$1.xml : src/meta/updates.xml $(template_deps)
|
||||
$(template) $$< $$@ type=crx channel=$1
|
||||
|
||||
testbuilds/$(name)$1.crx.zip : \
|
||||
$(foreach f,script.js eventPage.js icon16.png icon48.png icon128.png manifest.json,testbuilds/crx$1/$(f)) \
|
||||
package.json version.json tools/zip-crx.js node_modules/jszip/package.json
|
||||
node tools/zip-crx.js $1
|
||||
|
||||
testbuilds/$(name)$1.crx : testbuilds/$(name)$1.crx.zip package.json tools/sign.js node_modules/crx/package.json
|
||||
node tools/sign.js $1
|
||||
|
||||
testbuilds/$(name)$1.meta.js : src/meta/metadata.js src/meta/icon48.png $(template_deps)
|
||||
$(template) $$< $$@ type=userscript channel=$1
|
||||
|
||||
testbuilds/$(name)$1.user.js : src/meta/botproc.js testbuilds/$(name)$1.meta.js LICENSE src/meta/usestrict.js tmp/script-userscript.js $(cat_deps)
|
||||
$(cat) src/meta/botproc.js testbuilds/$(name)$1.meta.js LICENSE src/meta/usestrict.js tmp/script-userscript.js $$@
|
||||
|
||||
endef
|
||||
|
||||
$(eval $(call rules_channel,))
|
||||
$(eval $(call rules_channel,-beta))
|
||||
$(eval $(call rules_channel,-noupdate))
|
||||
|
||||
testbuilds/$(name).zip : testbuilds/$(name)-noupdate.crx.zip $(cp_deps)
|
||||
$(cp) $< $@
|
||||
|
||||
builds/% : testbuilds/% jshint $(cp_deps)
|
||||
$(cp) $< $@
|
||||
|
||||
test.html : README.md template.jst tools/markdown.js node_modules/marked/package.json node_modules/lodash/package.json
|
||||
node tools/markdown.js
|
||||
|
||||
.jshintrc: tools/templates.coffee src/meta/jshint.json $(template_deps)
|
||||
$(template) src/meta/jshint.json .jshintrc
|
||||
|
||||
.SECONDARY :
|
||||
|
||||
.PHONY: default all clean testbuilds builds jshint install
|
||||
|
||||
clean : tools/clean.js node_modules/fs-extra/package.json
|
||||
node tools/clean.js
|
||||
|
||||
testbuilds : $(foreach f,$(builds),testbuilds/$(f))
|
||||
|
||||
builds : $(foreach f,$(builds),builds/$(f))
|
||||
|
||||
jshint : tmp/script-crx.js tmp/eventPage.js tmp/script-userscript.js $(jshint_deps)
|
||||
$(BIN)jshint tmp/script-crx.js tmp/eventPage.js tmp/script-userscript.js
|
||||
|
||||
install : testbuilds jshint install.json tools/install.js node_modules/fs-extra/package.json
|
||||
node tools/install.js
|
||||
Loading…
x
Reference in New Issue
Block a user