tooltwist
Version:
Tooltwist Command Line Interface
340 lines (302 loc) • 8.72 kB
JavaScript
var TARGET_DIR = '{{&PROJECT_ROOT}}';
var PHASE1_DIR = TARGET_DIR + '/.tooltwist/PHASE1';
var GENERATE_DIR = TARGET_DIR + '/.tooltwist/do_generate';
var PRODUCTION_DIR = TARGET_DIR + '/.tooltwist/outputs/production';
var PACKAGE_DIR = TARGET_DIR + '/DOCKER_PACKAGE';
var DOCKER_DIR = TARGET_DIR + '/.tooltwist/do_docker';
module.exports = function(grunt){
grunt.initConfig({
exec: {
generate_navpoints: {
cwd: TARGET_DIR,
command: 'tooltwist generate {{&PROJECT_NAME}} {{&GENERATE_OPTIONS}}'
},
docker_build: {
cwd: DOCKER_DIR,
command: './build.sh'
//docker build -t {{&CONTAINER_NAME}}-image .
},
docker_run: {
cwd: DOCKER_DIR,
command: './run.sh'
},
docker_stop: {
cwd: DOCKER_DIR,
command: './stop.sh'
},
docker_commit: {
cwd: DOCKER_DIR,
command: './commit.sh'
},
docker_publish: {
cwd: DOCKER_DIR,
command: './publish.sh'
},
"create-widget-marker-files": {
cwd: TARGET_DIR + '/.tooltwist',
command: 'for n in webdesign-projects/**/widgets ; do echo touch $n/_empty ; touch $n/_empty ; done'
}
},
mkdir: {
all: {
options: {
mode: 0700,
create: [
PACKAGE_DIR + '/site-conf.example/bin',
PACKAGE_DIR + '/site-conf.example/conf',
PACKAGE_DIR + '/site-conf.example/logs',
DOCKER_DIR + '/resources/ttsvr',
DOCKER_DIR + '/resources/ttsvr/WEB-INF',
DOCKER_DIR + '/resources/tomcat',
DOCKER_DIR + '/resources/site-conf'
]
}
}
},
copy: {
// Web assets before transformations
// These are the web assets from PHASE1/ttsvr/src/main/webapp (created in Phase 1)
// after they have been transformed by GeneratorUIM (e.g. had URLs adjusted)
"non-transformed-web-assets": {
expand: true,
dot: true,
cwd: TARGET_DIR + '/.tooltwist/PHASE1/ttsvr/exploded',
src: '**',
dest: DOCKER_DIR + '/resources/ttsvr',
},
// Web assets after transformations
// These are the web assets from PHASE1/ttsvr/src/main/webapp (created in Phase 1)
// after they have been transformed by GeneratorUIM (e.g. had URLs adjusted)
"transformed-web-assets-1": {
expand: true,
dot: true,
cwd: GENERATE_DIR + '/transformed-web-assets',
src: [
'audit_utils/**',
'browserTests/**',
'dashboard/**',
'dinaa/**',
'experiments/**',
'file_upload/**',
'frame/**',
'generated_documentation/**',
'generic/**',
'hierarchy-is-this-used/**',
'jasper/**',
'misc/**',
'sshterm/**',
'stylesheet/**',
'wf_queue/**',
'workflow/**',
],
dest: DOCKER_DIR + '/resources/ttsvr-1',
},
"transformed-web-assets-2": {
expand: true,
dot: true,
cwd: GENERATE_DIR + '/transformed-web-assets',
src: [
'tooltwist/**',
'ttStd/**',
],
dest: DOCKER_DIR + '/resources/ttsvr-2',
},
"transformed-web-assets-3": {
expand: true,
dot: true,
cwd: GENERATE_DIR + '/transformed-web-assets',
src: [ '**',
// WebContent, put here before creating war in PHASE1
'!src/**',
// Exploded war from PHASE1
'!exploded/**',
// Images as shown in the Designer, created during generate
'!designer/cropImage',
'!designer/frame',
// These generated files will come from work directory
//ZZZZ But why is cropImage etc already found here?
'!cropImage/**',
'!frame/**',
'!stylesheet/**',
'!navpoint/**',
// Files from part 1 above
'tooltwist/**',
'ttStd/**',
// Files from part 2 above
'audit_utils/**',
'browserTests/**',
'dashboard/**',
'dinaa/**',
'experiments/**',
'file_upload/**',
'frame/**',
'generated_documentation/**',
'generic/**',
'hierarchy-is-this-used/**',
'jasper/**',
'misc/**',
'sshterm/**',
'stylesheet/**',
'wf_queue/**',
'workflow/**'
],
dest: DOCKER_DIR + '/resources/ttsvr-3',
},
// Jars
// These were created by the Gradle build
"WEB-INF": {
expand: true,
dot: true,
cwd: TARGET_DIR + '/.tooltwist/PHASE1/ttsvr/exploded/WEB-INF',
src: '**',
dest: DOCKER_DIR + '/resources/ttsvr-3/WEB-INF',
},
// Navpoints, images, stylesheets, frames
// These files were created by GeneratorUIM
"generated-files": {
expand: true,
dot: true,
cwd: GENERATE_DIR + '/work',
src: '**',
dest: DOCKER_DIR + '/resources/ttsvr-3',
},
// The web design projects, pulled using git by the ToolTwist CLI
"webdesign-projects": {
expand: true,
dot: true,
cwd: TARGET_DIR + '/.tooltwist',
src: [
'webdesign-projects/**',
'!**/.git/**',
// temporarily require a widgets directory, so the project gets found
// '!**/widgets/**',
'!**/targets/**',
'!**/testing/**' ],
dest: DOCKER_DIR + '/resources/ttsvr-3/META-INF',
},
// Extension projects, created from JARs by the gradle build in Phase 1.
"extension-projects": {
expand: true,
dot: true,
cwd: TARGET_DIR + '/.tooltwist',
src: [ 'extension-projects/**',
// '!**/widgets/**',
'!**/config/db/fitmycar/**' ],
dest: DOCKER_DIR + '/resources/ttsvr-3/META-INF',
},
// Webdesign projects without the widget directories
"webdesign-projects": {
expand: true,
dot: true,
cwd: TARGET_DIR + '/.tooltwist',
src: [
'webdesign-projects/**',
'!**/.git/**',
'!**/widgets/**',
'!**/targets/**',
'!**/testing/**' ],
dest: DOCKER_DIR + '/resources/ttsvr-3/META-INF',
},
// Create the widget directories, with no content except marker files
// This is required so tooltwist recognises the project directories
"widget-marker-files": {
expand: true,
dot: true,
cwd: TARGET_DIR + '/.tooltwist',
src: 'webdesign-projects/**/widgets/_empty',
dest: DOCKER_DIR + '/resources/ttsvr-3/META-INF',
},
// Overwrite application files
// These are created by the 'tooltwist' command, using templates.
"override-ttsvr": {
expand: true,
dot: true,
cwd: PRODUCTION_DIR + '/ttsvr',
src: '**',
dest: DOCKER_DIR + '/resources/ttsvr-3',
},
// Overwrite tooltwist config files
// These are created by the 'tooltwist' command, using templates.
"override-tooltwist-config": {
expand: true,
dot: true,
cwd: PRODUCTION_DIR + '/site-conf',
src: [ '**' ],
dest: DOCKER_DIR + '/resources/site-conf'
},
// Overwrite Tomcat config files
// These are created by the 'tooltwist' command, using templates.
"override-tomcat-config": {
expand: true,
dot: true,
cwd: PRODUCTION_DIR + '/tomcat',
src: [ '**' ],
dest: DOCKER_DIR + '/resources/tomcat'
},
// Make the config files easy for the user to see.
"README": {
expand: true,
dot: true,
cwd: PRODUCTION_DIR,
src: [ 'README' ],
dest: PACKAGE_DIR
},
"example-config": {
expand: true,
dot: true,
cwd: PRODUCTION_DIR + '/site-conf',
src: [ '**' ],
dest: PACKAGE_DIR + '/site-conf.example'
}
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
// grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-war');
grunt.loadNpmTasks('grunt-mkdir');
{{#NOTYET}}
/*
grunt.loadNpmTasks('grunt-touch');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-git');
*/
/*
grunt.registerTask('default', [ 'copy', 'touch' ]);
*/
{{/NOTYET}}
grunt.registerTask('default', [
// Generate navpoints, images, frames, stylesheets.
'exec:generate_navpoints',
// Create directories
"mkdir",
// Copy the application across, piece by piece
// Option A
"copy:transformed-web-assets-1",
"copy:transformed-web-assets-2",
"copy:transformed-web-assets-3",
// option B
//"copy:non-transformed-web-assets",
"copy:WEB-INF",
"copy:generated-files",
"copy:webdesign-projects",
"copy:extension-projects",
// Widget directories
// We need to include empty widget directories, otherwise
// Tooltwist won't recognise the project directories. To do
// this we need to have marker files.
"exec:create-widget-marker-files",
"copy:widget-marker-files",
// Files created by 'tooltwist' command from templates.
"copy:override-ttsvr",
"copy:override-tooltwist-config",
"copy:override-tomcat-config",
// Copy files to the DOCKER_PACKAGE directory so the user can see them
"copy:README",
"copy:example-config",
// Create and push the Docker image
'exec:docker_build'
]);
};