Skip to content

Instantly share code, notes, and snippets.

@vvakame
Created February 28, 2013 02:32
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vvakame/5053711 to your computer and use it in GitHub Desktop.
Save vvakame/5053711 to your computer and use it in GitHub Desktop.
Slim3 + TypeScript なプロジェクトのGruntfile.jsとか run_server.sh も grunt start-server とかにするべきかなと思う
module.exports = function (grunt) {
grunt.initConfig({
typescript: {
client: { // --declarations --sourcemap --target ES5 --out client/scripts/main.js client/scripts/main.ts
src: ['src/main/typescript/Ignite.ts'],
dest: 'src/main/webapp/scripts/main.js',
options: {
target: 'es5',
base_path: 'src/main/typescript',
sourcemap: false,
declaration_file: false
}
},
client_test: {
src: ['src/test/typescript/MainSpec.ts'],
dest: 'src/test/typescript/main-spec.js',
options: {
target: 'es5',
sourcemap: false,
declaration_file: false
}
}
},
compass: {
dev: {
src: 'src/main/scss',
dest: 'src/main/webapp/css',
linecomments: true,
forcecompile: true,
require: [],
debugsass: true,
images: 'src/main/webapp/images',
relativeassets: true
},
prod: {
src: 'src/main/scss',
dest: 'src/main/webapp/css',
outputstyle: 'compressed',
linecomments: false,
forcecompile: true,
require: [],
debugsass: false,
images: 'src/main/webapp/images',
relativeassets: true
}
},
watch: {
typescript: {
files: ['<config:typescript.client.src>', '<config:typescript.client_test.src>'],
tasks: ['typescript', 'copy']
},
compass: {
files: ['<config:compass.dev.src>'],
tasks: ['compass:dev', 'copy']
}
},
concat: {
dist: {
src: [
'src/test/resources/typescript/testdata-header.js.template',
'src/test/resources/typescript/data/*.js',
'src/test/resources/typescript/testdata-footer.js.template'
],
dest: 'src/test/typescript/testdata.js'
}
},
clean: {
clientCss: {
src: [
'src/main/webapp/css/*.css'
]
},
clientScript: {
src: [
// client
'src/main/webapp/scripts/*.js',
'src/main/webapp/scripts/*.d.ts',
'src/main/webapp/scripts/*.js.map',
// client test
'src/test/typescript/*.js',
'src/test/typescript/*.js.map',
'src/test/typescript/*.d.ts'
]
},
serverData: {
src: [
// client test data
'src/test/resources/typescript/data'
]
},
bowerful: {
src: [
// bower installed
'src/main/webapp/scripts/libs'
]
}
},
jasmine: {
all: {
src: ['src/test/typescript/SpecRunner.html'],
errorReporting: true
}
},
testacular: {
unit: {
options: {
configFile: 'testacular.conf.js',
autoWatch: false,
browsers: ['PhantomJS'],
reporters: ['progress', 'junit'],
singleRun: true,
keepalive: true
}
}
},
bowerful: {
store: 'src/main/webapp/scripts/libs',
packages: {
"jquery": "1.9.1",
"angular": "1.0.4"
}
},
exec: {
tsd: {
cmd: function () {
return "tsd install jquery angular";
}
},
"open-jasmine": {
cmd: function () {
return "open src/test/typescript/SpecRunner.html";
}
}
}
});
grunt.registerTask('default', ['clean:clientCss', 'clean:clientScript', 'concat', 'typescript', 'compass:dev']);
grunt.registerTask('test', ['clean:clientScript', 'concat', 'typescript', 'testacular']);
grunt.registerTask('test-jasmine', ['clean:clientScript', 'concat', 'typescript', 'exec:open-jasmine']);
grunt.registerTask('setup', ['bowerful', 'exec:tsd']);
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-bowerful');
grunt.loadNpmTasks('grunt-typescript');
grunt.loadNpmTasks('grunt-compass');
grunt.loadNpmTasks('grunt-testacular');
grunt.loadNpmTasks('grunt-exec');
};
{
"name": "hoge-fuga",
"version": "0.0.1",
"private": true,
"engines": {
"node": "0.8.18",
"npm": "1.2.2"
},
"scripts": {
"start": "node app"
},
"devDependencies": {
"grunt": "0.4.0",
"tsd": "0.3.1",
"grunt-contrib-concat": "0.1.3",
"grunt-contrib-clean": "0.4.0",
"grunt-bowerful": "0.2.0",
"grunt-typescript": "0.0.12",
"grunt-compass": "0.3.9",
"grunt-testacular": "0.3.0",
"grunt-exec": "0.4.0"
},
"dependencies": {
}
}
#!/bin/sh
ISERROR=0
which mvn > /dev/null 2>&1
if [ $? -ne 0 ] ; then
echo "command not found: mvn"
echo "please install mvn. e.g. sudo port install maven3"
ISERROR=1
fi
mvn clean test && \
grunt && \
mvn clean appengine:devserver && \
echo "OK!"
#!/bin/sh
ISERROR=0
which npm > /dev/null 2>&1
if [ $? -ne 0 ] ; then
echo "command not found: npm"
echo "please install npm. e.g. sudo port install npm"
ISERROR=1
fi
which grunt > /dev/null 2>&1
if [ $? -ne 0 ] ; then
echo "command not found: grunt"
echo "please install grunt. e.g. npm install -g grunt-cli"
ISERROR=1
fi
which tsd > /dev/null 2>&1
if [ $? -ne 0 ] ; then
echo "command not found: tsd"
echo "please install tsd. e.g. npm install -g tsd"
ISERROR=1
fi
which testacular > /dev/null 2>&1
if [ $? -ne 0 ] ; then
echo "command not found: testacular"
echo "please install testacular. e.g. npm install -g testacular"
ISERROR=1
fi
if [ "${PHANTOMJS_BIN}" = "" ] ; then
echo "set environment variable PHANTOMJS_BIN"
echo "please install if you have not installed phantomjs. e.g. sudo port install phantomjs"
ISERROR=1
fi
if [ $ISERROR == 1 ] ; then
exit
fi
npm install && \
grunt setup && \
echo "OK!"
{
"localPath": "src/main/typescript/libs",
"repositoryType": "1",
"uri": "https://github.com/Diullei/tsd/raw/master/deploy/repository.json"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment