Skip to content

Commit

Permalink
updated base files
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Feb 3, 2015
1 parent 45df872 commit e670820
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -15,6 +15,7 @@ out/
# Private Files
.env
.idea
.cake_task_cache


# =====================================
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
@@ -1,11 +1,11 @@
# v1.3.23 October 11, 2014
# February 2, 2015
# https://github.com/bevry/base
language: node_js
# ensure npm@1 is the latest 0.8 compatible version (needed to ensure modules are installed correctly)
# install npm@1 so we can install npm@2 so we can ensure we have the latest version (can't install npm@2 directly on 0.8 as their bundled npm is too old)
# ensure coffee-script is installed (needed for cake commands)
# ensure dev dependencies are installed (handled via npm install)
# ensure test dependencies are installed (handled via cake install)
install: "npm install -g npm@1 && npm install coffee-script && npm install && ./node_modules/.bin/cake install"
install: "npm install -g npm@1 && npm install -g npm@2 && npm install coffee-script && npm install && ./node_modules/.bin/cake install"
# ensure our application is compiled before we run our tests
before_script: "./node_modules/.bin/cake compile"
script: "npm test"
Expand Down
104 changes: 60 additions & 44 deletions Cakefile
@@ -1,4 +1,4 @@
# v1.3.20 June 16, 2014
# February 2, 2015
# https://github.com/bevry/base


Expand Down Expand Up @@ -45,14 +45,30 @@ config.DOCPAD_OUT_PATH = "out"
for own key,value of (PACKAGE_DATA.cakeConfiguration or {})
config[key] = value

for own key,value of config
config[key] = pathUtil.resolve(APP_PATH, value) if value
#for own key,value of config
# config[key] = pathUtil.resolve(APP_PATH, value) if value
# ^ causes issues with biscotto, as it just wants relative paths


# =====================================
# Generic

{spawn, exec} = require('child_process')
child_process = require('child_process')

spawn = (command, args, opts) ->
if opts.output is true
console.log(command, args.join(' '))
opts.stdio = 'inherit'
return child_process.spawn(command, args, opts)
exec = (command, opts, next) ->
if opts.output is true
console.log(command)
return child_process.exec command, opts, (err, stdout, stderr) ->
console.log(stdout)
console.log(stderr)
next()
else
return child_process.exec(command, opts, next)

safe = (next,fn) ->
next ?= (err) -> console.log(err.stack ? err)
Expand Down Expand Up @@ -100,25 +116,25 @@ actions =
)

# rm
console.log('clean')
spawn('rm', args, {stdio:'inherit', cwd:APP_PATH}).on('close', safe next)
console.log('\nclean:')
spawn('rm', args, {output:true, cwd:APP_PATH}).on('close', safe next)

install: (opts,next) ->
# Prepare
(next = opts; opts = {}) unless next?

# Steps
step1 = ->
console.log('npm install (for app)')
spawn(NPM, ['install'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step2)
console.log('\nnpm install (for app):')
spawn(NPM, ['install'], {output:true, cwd:APP_PATH}).on('close', safe next, step2)
step2 = ->
return step3() if !config.TEST_PATH or !fsUtil.existsSync(config.TEST_PATH)
console.log('npm install (for test)')
spawn(NPM, ['install'], {stdio:'inherit', cwd:config.TEST_PATH}).on('close', safe next, step3)
console.log('\nnpm install (for test):')
spawn(NPM, ['install'], {output:true, cwd:config.TEST_PATH}).on('close', safe next, step3)
step3 = ->
return step4() if !fsUtil.existsSync(DOCPAD_PATH)
console.log('npm install (for docpad tests)')
spawn(NPM, ['install'], {stdio:'inherit', cwd:DOCPAD_PATH}).on('close', safe next, step4)
console.log('\nnpm install (for docpad tests):')
spawn(NPM, ['install'], {output:true, cwd:DOCPAD_PATH}).on('close', safe next, step4)
step4 = next

# Start
Expand All @@ -130,16 +146,16 @@ actions =

# Steps
step1 = ->
console.log('cake install')
console.log('\ncake install')
actions.install(opts, safe next, step2)
step2 = ->
return step3() if !config.COFFEE_SRC_PATH or !fsUtil.existsSync(COFFEE)
console.log('coffee compile')
spawn(NODE, [COFFEE, '-co', config.COFFEE_OUT_PATH, config.COFFEE_SRC_PATH], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step3)
console.log('\ncoffee compile:')
spawn(NODE, [COFFEE, '-co', config.COFFEE_OUT_PATH, config.COFFEE_SRC_PATH], {output:true, cwd:APP_PATH}).on('close', safe next, step3)
step3 = ->
return step4() if !config.DOCPAD_SRC_PATH or !fsUtil.existsSync(DOCPAD)
console.log('docpad generate')
spawn(NODE, [DOCPAD, 'generate'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step4)
console.log('\ndocpad generate:')
spawn(NODE, [DOCPAD, 'generate'], {output:true, cwd:APP_PATH}).on('close', safe next, step4)
step4 = next

# Start
Expand All @@ -151,17 +167,17 @@ actions =

# Steps
step1 = ->
console.log('cake install')
console.log('\ncake install')
actions.install(opts, safe next, step2)
step2 = ->
return step3() if !config.COFFEE_SRC_PATH or !fsUtil.existsSync(COFFEE)
console.log('coffee watch')
spawn(NODE, [COFFEE, '-wco', config.COFFEE_OUT_PATH, config.COFFEE_SRC_PATH], {stdio:'inherit', cwd:APP_PATH}).on('close', safe) # background
console.log('\ncoffee watch:')
spawn(NODE, [COFFEE, '-wco', config.COFFEE_OUT_PATH, config.COFFEE_SRC_PATH], {output:true, cwd:APP_PATH}).on('close', safe) # background
step3() # continue while coffee runs in background
step3 = ->
return step4() if !config.DOCPAD_SRC_PATH or !fsUtil.existsSync(DOCPAD)
console.log('docpad run')
spawn(NODE, [DOCPAD, 'run'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe) # background
console.log('\ndocpad run:')
spawn(NODE, [DOCPAD, 'run'], {output:true, cwd:APP_PATH}).on('close', safe) # background
step4() # continue while docpad runs in background
step4 = next

Expand All @@ -174,11 +190,11 @@ actions =

# Steps
step1 = ->
console.log('cake compile')
console.log('\ncake compile')
actions.compile(opts, safe next, step2)
step2 = ->
console.log('npm test')
spawn(NPM, ['test'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step3)
console.log('\nnpm test:')
spawn(NPM, ['test'], {output:true, cwd:APP_PATH}).on('close', safe next, step3)
step3 = next

# Start
Expand All @@ -190,24 +206,24 @@ actions =

# Steps
step1 = ->
console.log('cake compile')
console.log('\ncake compile')
actions.compile(opts, safe next, step2)
step2 = ->
return step3() if !fsUtil.existsSync(PROJECTZ)
console.log('projectz compile')
spawn(NODE, [PROJECTZ, 'compile'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step3)
console.log('\nprojectz compile')
spawn(NODE, [PROJECTZ, 'compile'], {output:true, cwd:APP_PATH}).on('close', safe next, step3)
step3 = ->
return step4() if !config.DOCCO_SRC_PATH or !fsUtil.existsSync(DOCCO)
console.log('docco compile')
exec("#{NODE} #{DOCCO} -o #{config.DOCCO_OUT_PATH} #{config.DOCCO_SRC_PATH}", {stdio:'inherit', cwd:APP_PATH}, safe next, step4)
console.log('\ndocco compile:')
exec("#{NODE} #{DOCCO} -o #{config.DOCCO_OUT_PATH} #{config.DOCCO_SRC_PATH}", {output:true, cwd:APP_PATH}, safe next, step4)
step4 = ->
return step5() if !config.BISCOTTO_SRC_PATH or !fsUtil.existsSync(BISCOTTO)
console.log('biscotto compile')
exec("""#{BISCOTTO} --name #{PACKAGE_DATA.title or PACKAGE_DATA.name} --title "#{PACKAGE_DATA.title or PACKAGE_DATA.name} API Documentation" --readme README.md --output-dir #{config.BISCOTTO_OUT_PATH} #{config.BISCOTTO_SRC_PATH} - LICENSE.md HISTORY.md""", {stdio:'inherit', cwd:APP_PATH}, safe next, step5)
console.log('\nbiscotto compile:')
exec("""#{BISCOTTO} -n #{PACKAGE_DATA.title or PACKAGE_DATA.name} --title "#{PACKAGE_DATA.title or PACKAGE_DATA.name} API Documentation" -r README.md -o #{config.BISCOTTO_OUT_PATH} #{config.BISCOTTO_SRC_PATH} - LICENSE.md HISTORY.md""", {output:true, cwd:APP_PATH}, safe next, step5)
step5 = ->
console.log('cake test')
actions.test(opts, safe next, step5)
step5 = next
console.log('\ncake test')
actions.test(opts, safe next, step6)
step6 = next

# Start
step1()
Expand All @@ -218,20 +234,20 @@ actions =

# Steps
step1 = ->
console.log('cake prepublish')
console.log('\ncake prepublish')
actions.prepublish(opts, safe next, step2)
step2 = ->
console.log('npm publish')
spawn(NPM, ['publish'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step3)
console.log('\nnpm publish:')
spawn(NPM, ['publish'], {output:true, cwd:APP_PATH}).on('close', safe next, step3)
step3 = ->
console.log('git tag')
spawn(GIT, ['tag', 'v'+PACKAGE_DATA.version, '-a'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step4)
console.log('\ngit tag:')
spawn(GIT, ['tag', 'v'+PACKAGE_DATA.version, '-a'], {output:true, cwd:APP_PATH}).on('close', safe next, step4)
step4 = ->
console.log('git push origin master')
spawn(GIT, ['push', 'origin', 'master'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step5)
console.log('\ngit push origin master:')
spawn(GIT, ['push', 'origin', 'master'], {output:true, cwd:APP_PATH}).on('close', safe next, step5)
step5 = ->
console.log('git push tags')
spawn(GIT, ['push', 'origin', '--tags'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step6)
console.log('\ngit push tags:')
spawn(GIT, ['push', 'origin', '--tags'], {output:true, cwd:APP_PATH}).on('close', safe next, step6)
step6 = next

# Start
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -34,9 +34,9 @@
"taskgroup": "~4.0.5"
},
"devDependencies": {
"coffee-script": "~1.8.0",
"coffee-script": "^1.9.0",
"docpad": "6",
"projectz": "~0.3.17"
"projectz": "^0.3.17"
},
"main": "./out/cachr.plugin.js",
"scripts": {
Expand Down

0 comments on commit e670820

Please sign in to comment.