Skip to content

Commit

Permalink
Client script and style resources using Bower (#22)
Browse files Browse the repository at this point in the history
* Bower: jQuery, bootstrap, bootswatch + deploy

* Bower: +jquery-timeago and jquery-uitablefilter

* Grunt + bootswatch

* Grunt: Bootswatch support

* Temporary theme work

* Removing Bootstrap source

* Adding client script to gitignore

* Removing client scripts

* Adding Bower-related folders to gitignore

* No need for html5shiv

* Moving to Spacelab Bootswatch theme
  • Loading branch information
jeffwilcox committed Aug 22, 2016
1 parent f4624a0 commit 561ec12
Show file tree
Hide file tree
Showing 37 changed files with 816 additions and 9,589 deletions.
26 changes: 12 additions & 14 deletions .gitignore
@@ -1,27 +1,25 @@
# Logs
*.log

# Node
node_modules/
npm-debug.log

# Client script
bower_components/
.sass-cache/

# Static assets
public/
resources/scss/build.scss

# OS X
.DS_Store

# Local test files
# Local scripts
sync-*.js

# Local development environment scripts
bin/local*
bin/contoso
app.yaml

# Tooling
.vscode/

# Editors
.vscode/

# Other routes and components that need not be included here
docs/
routes/microsoft-specific*
routes/docs.js
views/docs/
public/css/docs.css
130 changes: 130 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,130 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
builddir: 'public/css',
buildscriptdir: 'public/js/',
buildrootdir: 'public/',
banner: '/*!\n' +
' * <%= pkg.name %> v<%= pkg.version %>\n' +
' * Homepage: <%= pkg.homepage %>\n' +
' * Copyright 2012-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed under <%= pkg.license %>\n' +
' * Based on Bootstrap\n' +
'*/\n',
concat: {
options: {
banner: '<%= banner %>',
stripBanners: false
},
dist: {
src: [],
dest: ''
}
},
copy: {
bootstrap: {
files: [
{
expand: true,
src: '**',
cwd: 'bower_components/bootstrap/dist/',
dest: '<%= buildrootdir %>',
},
]
},
jquery: {
files: [
{
expand: true,
src: '**',
cwd: 'bower_components/jQuery/dist/',
dest: '<%= buildscriptdir %>',
},
]
},
resources: {
files: [
{
expand: true,
src: '**',
cwd: 'resources/',
dest: '<%= buildrootdir %>',
},
]
},
timeago: {
files: [
{
expand: true,
src: 'jquery.timeago.js',
cwd: 'bower_components/jquery-timeago/',
dest: '<%= buildscriptdir %>',
},
]
},
uitablefilter: {
files: [
{
expand: true,
src: 'jquery.uitablefilter.js',
cwd: 'bower_components/jquery-uitablefilter/',
dest: '<%= buildscriptdir %>',
},
]
},
},
clean: {
build: {
src: ['*/build.scss', '!theme/build.scss']
}
},
});

grunt.registerTask('none', function () { });

grunt.registerTask('build_scss', 'build a regular theme from scss', function() {
var theme = 'resources/scss';
var compress = true;

var concatSrc;
var concatDest;
var scssDest;
var scssSrc;
var files = {};
var dist = {};
concatSrc = theme + '/_build.scss';
concatDest = theme + '/build.scss';
scssDest = '<%=builddir%>/bootstrap.css';
scssSrc = [theme + '/' + 'build.scss'];

dist = {src: concatSrc, dest: concatDest};
grunt.config('concat.dist', dist);
files = {};
files[scssDest] = scssSrc;
grunt.config('sass.dist.files', files);
grunt.config('sass.dist.options.style', 'expanded');
grunt.config('sass.dist.options.precision', 8);
grunt.config('sass.dist.options.unix-newlines', true);

grunt.task.run(['concat', 'sass', /*'prefix:' + scssDest,*/ 'clean:build',
compress ? 'compress_scss:' + scssDest + ':' + '<%=builddir%>/bootstrap.min.css' : 'none']);
});

grunt.registerTask('compress_scss', 'compress a generic css with sass', function(fileSrc, fileDst) {
var files = {}; files[fileDst] = fileSrc;
grunt.log.writeln('compressing file ' + fileSrc);

grunt.config('sass.dist.files', files);
grunt.config('sass.dist.options.style', 'compressed');
grunt.task.run(['sass:dist']);
});

grunt.registerTask('default', ['copy', 'build_scss']);
};
31 changes: 31 additions & 0 deletions bower.json
@@ -0,0 +1,31 @@
{
"name": "azure-oss-portal",
"description": "Azure Open Source Portal for GitHub",
"main": "",
"authors": [
"Jeff Wilcox <jwilcox@microsoft.com>"
],
"license": "MIT",
"keywords": [
"github",
"management",
"organization"
],
"homepage": "https://github.com/Azure/azure-oss-portal",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"jQuery": "^3.1.0",
"bootstrap": "^3.3.7",
"bootswatch": "^3.3.7",
"jquery-timeago": "timeago#^1.5.3",
"jquery-uitablefilter": "git://github.com/natinusala/jquery-uitablefilter.git",
"bootstrap-sass": "bootstrap-sass-official#^3.3.7"
}
}
55 changes: 48 additions & 7 deletions deploy.cmd
Expand Up @@ -66,7 +66,7 @@ IF DEFINED KUDU_SELECT_NODE_VERSION_CMD (
SET /p NODE_EXE=<"%DEPLOYMENT_TEMP%\__nodeVersion.tmp"
IF !ERRORLEVEL! NEQ 0 goto error
)

IF EXIST "%DEPLOYMENT_TEMP%\__npmVersion.tmp" (
SET /p NPM_JS_PATH=<"%DEPLOYMENT_TEMP%\__npmVersion.tmp"
IF !ERRORLEVEL! NEQ 0 goto error
Expand Down Expand Up @@ -96,25 +96,66 @@ echo Handling customized node.js deployment.
:: 1. Select node version
call :SelectNodeVersion

:: 2. Customize npm
:: 2. Clean all existing modules
IF EXIST "%DEPLOYMENT_SOURCE%\node_modules" (
pushd "%DEPLOYMENT_SOURCE%"
IF /I "%SKIP_NPM_CLEAN%" NEQ "1" (
echo Existing npm modules found, removing...
rmdir /s /q node_modules
IF !ERRORLEVEL! NEQ 0 goto error
)
popd
)

:: 3. Customize npm
IF EXIST "%DEPLOYMENT_SOURCE%\package.json" (
pushd "%DEPLOYMENT_SOURCE%"
call :ExecuteCmd !NPM_CMD! config set color false
echo Installing npm packages at the deploy source of %DEPLOYMENT_SOURCE%
call :ExecuteCmd !NPM_CMD! config set color false
IF !ERRORLEVEL! NEQ 0 goto error
call :ExecuteCmd !NPM_CMD! config set progress false
call :ExecuteCmd !NPM_CMD! config set progress false
IF !ERRORLEVEL! NEQ 0 goto error
popd
)

:: 3. Install npm packages
:: 4. Install npm packages
IF EXIST "%DEPLOYMENT_SOURCE%\package.json" (
pushd "%DEPLOYMENT_SOURCE%"
call :ExecuteCmd !NPM_CMD! install --production
IF !ERRORLEVEL! NEQ 0 goto error
popd
)

:: 4. KuduSync
:: 5. Install npm development packages
IF EXIST "%DEPLOYMENT_SOURCE%\package.json" (
pushd "%DEPLOYMENT_SOURCE%"
call :ExecuteCmd !NPM_CMD! install --only=dev
IF !ERRORLEVEL! NEQ 0 goto error
popd
)


:: 6. Bower
IF EXIST "%DEPLOYMENT_SOURCE%\bower.json" (
echo Installing Bower components...
pushd "%DEPLOYMENT_SOURCE%"
call node_modules\.bin\bower install
IF !ERRORLEVEL! NEQ 0 goto error
popd
)

:: 7. Grunt
IF EXIST "%DEPLOYMENT_SOURCE%\Gruntfile.js" (
pushd "%DEPLOYMENT_SOURCE%"
echo Grunting...
call :ExecuteCmd !NPM_CMD! install grunt-cli
IF !ERRORLEVEL! NEQ 0 goto error
call node_modules\.bin\grunt --no-color default
IF !ERRORLEVEL! NEQ 0 goto error
popd
)

:: 8. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_SOURCE%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
IF !ERRORLEVEL! NEQ 0 goto error
Expand Down Expand Up @@ -150,4 +191,4 @@ exit /b 1

:end
endlocal
echo Finished successfully.
echo Finished successfully.
9 changes: 8 additions & 1 deletion package.json
Expand Up @@ -54,8 +54,15 @@
"serve-favicon": "~2.3.0"
},
"devDependencies": {
"bower": "^1.7.9",
"chai": "^3.5.0",
"eslint": "^3.1.1",
"mocha": "^3.0.1"
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-sass": "^1.2.1",
"load-grunt-tasks": "^3.5.2",
"mocha": "^3.0.1",
"node-sass": "^3.8.0"
}
}
22 changes: 0 additions & 22 deletions public/css/BOOTSTRAP-LICENSE.txt

This file was deleted.

0 comments on commit 561ec12

Please sign in to comment.