Skip to content

Commit

Permalink
Merge pull request #89 from NYULibraries/stage
Browse files Browse the repository at this point in the history
browse by category
  • Loading branch information
ekate authored Oct 28, 2019
2 parents 9ef1869 + b4bbcb8 commit 7a51799
Show file tree
Hide file tree
Showing 97 changed files with 4,487 additions and 4,815 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
node_modules
28 changes: 28 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
"env": {
"browser": true,
"node": true,
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017
},
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
};
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ source/json/datasources/*.json
# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules
./node_modules

design/*

Expand Down
7 changes: 7 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"esversion": 8,
"node": true,
"globalstrict": true,
"unused": true,
"undef": true
}
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Usage example
# 1) Build container image
# $ docker build -t nyudlts/aco:latest .
# 2) Run container
# $ docker run -d --name=aco -p 8000:80 nyudlts/aco:latest

# Stage 1
FROM node:10.15.1 as node

RUN apt-get update -qq \
&& apt-get install -y build-essential ruby-full \
&& gem install compass

WORKDIR /usr/src/app

COPY . .

RUN npm install -g grunt-cli \
&& npm install \
&& npm run-script build-docker

# Stage 2
FROM httpd:2.4-alpine

RUN sed -i '/LoadModule rewrite_module/s/^#//g' /usr/local/apache2/conf/httpd.conf

RUN { \
echo 'IncludeOptional conf.d/*.conf'; \
} >> /usr/local/apache2/conf/httpd.conf \
&& mkdir /usr/local/apache2/conf.d

COPY --from=node /usr/src/app/build /usr/local/apache2/htdocs/aco

COPY --from=node /usr/src/app/source/robots.txt /usr/local/apache2/htdocs/robots.txt

COPY ./httpd.conf /usr/local/apache2/conf.d/aco.conf
147 changes: 69 additions & 78 deletions Gruntconfigurations.js
Original file line number Diff line number Diff line change
@@ -1,109 +1,92 @@

var grunt = require('grunt') ;
const grunt = require('grunt');

function project () {
var projectConfiguration ;
var projectConfigurationFile = __dirname + '/source/json/conf.json' ;
if ( grunt.file.isFile ( projectConfigurationFile ) ) {
projectConfiguration = grunt.file.readJSON ( projectConfigurationFile ) ;
const projectConfigurationFile = `${__dirname}/source/json/conf.js`;
if (grunt.file.isFile(projectConfigurationFile)) {
return require(projectConfigurationFile);
}
return projectConfiguration ;
}

function htmlminify () {
var htmlminifyConfiguration = {} ;
var htmlminifyConfigurationFile = __dirname + '/source/json/htmlminify.json' ;
if ( grunt.file.isFile ( htmlminifyConfigurationFile ) ) {
htmlminifyConfiguration = grunt.file.readJSON ( htmlminifyConfigurationFile ) ;
htmlminifyConfiguration = htmlminifyConfiguration.htmlminify
let htmlminifyConfiguration = {};
let htmlminifyConfigurationFile = `${__dirname}/source/json/htmlminify.json`;
if ( grunt.file.isFile(htmlminifyConfigurationFile)) {
htmlminifyConfiguration = grunt.file.readJSON(htmlminifyConfigurationFile);
htmlminifyConfiguration = htmlminifyConfiguration.htmlminify;
}
return htmlminifyConfiguration ;
}

function curl () {
if ( grunt.file.isFile( __dirname + '/source/json/curl.json' ) ) {
var curlConfiguration = grunt.file.readJSON( __dirname + '/source/json/curl.json' ) ;
return curlConfiguration.curl ;
const curlConfigurationPath = `${__dirname}/source/json/curl.js`;
if (grunt.file.isFile(curlConfigurationPath)) {
return require(curlConfigurationPath).curl;
}
}

function js () {

var js_conf;

if ( grunt.file.isFile( __dirname + '/source/json/js.json' ) ) {
js_conf = grunt.file.readJSON( __dirname + '/source/json/js.json' ) ;
let js_conf;
if (grunt.file.isFile(`${__dirname}/source/json/js.json`)) {
js_conf = grunt.file.readJSON(`${__dirname}/source/json/js.json`);
}

else {
// default JS configuration
js_conf = {
js : {
build : "external", // options: inline, external
style : "expanded" // options: compressed, expanded
}
};
js: {
build: 'external', // options: inline, external
style: 'expanded' // options: compressed, expanded
}
};
}

return js_conf ;

return js_conf;
}

/** merge with compass */
function sass () {

var sass_conf;

if ( grunt.file.isFile( __dirname + '/source/json/sass.json' ) ) {
sass_conf = grunt.file.readJSON( __dirname + '/source/json/sass.json' ) ;
let sass_conf;
if (grunt.file.isFile(`${__dirname}/source/json/sass.json`)) {
sass_conf = grunt.file.readJSON(`${__dirname}/source/json/sass.json`);
}

else {
// default SASS configuration
sass_conf = {
sass : {
build : "external", // options: inline, external
// build : "external", // options: inline, external
sass: {
build: 'external', // options: inline, external
// for options; see: https://github.com/gruntjs/grunt-contrib-sass
options : {
style : "expanded", // options: nested, compact, compressed, expanded
debugInfo : false,
lineNumbers : true,
options: {
style: 'expanded', // options: nested, compact, compressed, expanded
debugInfo: false,
lineNumbers: true,
trace: false
}
}
};
};
}

return {
dist: {
options: sass_conf.sass.options,
files: { 'build/css/style.css': __dirname + '/source/sass/style.scss' },
build : sass_conf.sass.build
files: {
'build/css/style.css': `${__dirname}/source/sass/style.scss`
},
build: sass_conf.sass.build
}
} ;

};
}

function compass () {

var projectConfiguration = project () ;

var projectConfiguration = project();
// outputStyle: nested, expanded, compact, compressed
// noLineComments: true, false
// httpPath: String , default to "/"

var compass_conf;

if ( grunt.file.isFile ( __dirname + '/source/json/compass.json' ) ) {
compass_conf = grunt.file.readJSON ( __dirname + '/source/json/compass.json' ) ;
if (grunt.file.isFile(`${__dirname}/source/json/compass.json`)) {
compass_conf = grunt.file.readJSON(`${__dirname}/source/json/compass.json`);
}

return {
dist: {
options: {
dist: {
options: {
basePath: __dirname,
sassDir: __dirname + '/source/sass',
sassDir:`${__dirname}/source/sass`,
outputStyle: 'expanded',
imagesDir: 'images',
javascriptsDir: 'js',
Expand All @@ -112,35 +95,44 @@ function compass () {
}
}
}

}

function copy () {
function copy() {
return {
main: {
files: [
{ expand: true, cwd: 'source/images', src: '**/*', dest: 'build/images'},
{ expand: true, cwd: 'source', src: 'robots.txt', dest: 'build'},
]
{
expand: true,
cwd: 'source/images',
src: '**/*',
dest: 'build/images'
},
{
expand: true,
cwd: 'source',
src: 'robots.txt',
dest: 'build'
}
]
}
};
}

function clean () {
return [
__dirname + '/build/*',
__dirname + '/source/json/datasources/*.json'
return [
`${__dirname}/build/*`,
`${__dirname}/source/json/datasources/*.json`
];
}

function watch () {
return {
files: [
__dirname + '/source/js/*.js',
__dirname + '/source/json/*.json',
__dirname + '/source/sass/*.scss',
__dirname + '/source/views/*.mustache',
__dirname + '/source/views/*.hbs'
`${__dirname}/source/js/*.js`,
`${__dirname}/source/json/*.json`,
`${__dirname}/source/sass/*.scss`,
`${__dirname}/source/views/*.mustache`,
`${__dirname}/source/views/*.hbs`
],
tasks: [
'clean',
Expand All @@ -153,12 +145,11 @@ function watch () {
}

function uglify () {
function targetsCallback() {
var targets = {};
grunt.file.recurse(__dirname + '/source/js/', function callback (abspath, rootdir, subdir, filename) {
if ( filename.match('.js') ) {
var name = filename.replace('.js', '');
targets['build/js/' + name + '.min.js'] = abspath;
function targetsCallback () {
let targets = {};
grunt.file.recurse(`${__dirname}/source/js/`, (abspath, rootdir, subdir, filename) => {
if (filename.match('.js')) {
targets[`build/js/${filename.replace('.js', '')}.min.js`] = abspath;
}
});
return targets;
Expand Down
38 changes: 19 additions & 19 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
module.exports = function(grunt) {
module.exports = function (grunt) {

/** task to run */
var tasks = ['clean', 'copy', 'uglify', 'compass', 'curl', 'writeHTML'] ;
const tasks = ['clean', 'copy', 'uglify', 'compass', 'curl', 'writeHTML'];

var configuration = require('./Gruntconfigurations');
var taskConfiguration = {
const configuration = require('./Gruntconfigurations');

let taskConfiguration = {
pkg: grunt.file.readJSON('package.json'),
clean: configuration.clean(),
copy: configuration.copy(),
uglify: configuration.uglify(),
watch: configuration.watch(),
compass : configuration.compass()
clean: configuration.clean(),
copy: configuration.copy(),
uglify: configuration.uglify(),
watch: configuration.watch(),
compass: configuration.compass()
};

if (grunt.file.isFile( __dirname + '/source/json/curl.json')) {
taskConfiguration.curl = configuration.curl();
if (grunt.file.isFile(`${__dirname}/source/json/curl.js`)) {
taskConfiguration.curl = configuration.curl();
}

/** project configuration */
grunt.initConfig(taskConfiguration);
/** load modules and tasks */
grunt.loadNpmTasks('grunt-curl');

/** load modules and tasks */
grunt.loadNpmTasks('grunt-curl');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-writeHTML');
require('./lib/task')(grunt);

/** register the task */
grunt.registerTask('default', tasks) ;
grunt.registerTask('default', tasks);

};
Loading

0 comments on commit 7a51799

Please sign in to comment.