提交 f4919144 编写于 作者: B bryk

Merge branch 'master' into gulp-build

......@@ -3,3 +3,12 @@ Kubernetes Console is a general purpose, web-based UI for Kubernetes clusters. I
The console is currently under active development and is not ready for production use (yet!).
# Contribute:
Wish to contribute !! Great start [here](https://github.com/kubernetes/console/blob/master/CONTRIBUTING.md).
# License:
The work done has been licensed under Apache License 2.0.The license file can be found [here](https://github.com/kubernetes/console/blob/master/LICENSE). You can find out more about license,at
http://www.apache.org/licenses/LICENSE-2.0
// Copyright 2015 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Gulp tasks for compiling backend application.
*/
import child from 'child_process';
import del from 'del';
import gulp from 'gulp';
import lodash from 'lodash';
import path from 'path';
import conf from './conf';
/**
* External dependencies of the Go backend application.
*
* @type {!Array<string>}
*/
const goBackendDependencies = [
'github.com/golang/glog',
'github.com/spf13/pflag'
];
/**
* Spawns Go process with GOPATH placed in the backend tmp folder.
*
* @param {!Array<string>} args
* @param {function(?Error=)} doneFn
* @param {!Object<string, string>=} opt_env Optional environment variables to be concatenated with
* default ones.
*/
function spawnGoProcess(args, doneFn, opt_env) {
var goTask = child.spawn('go', args, {
env: lodash.merge(process.env, {GOPATH: conf.paths.backendTmp}, opt_env || {})
});
// Call Gulp callback on task exit. This has to be done to make Gulp dependency management
// work.
goTask.on('exit', function(code) {
if (code === 0) {
doneFn();
} else {
doneFn(new Error('Go command error, code:' + code));
}
});
goTask.stdout.on('data', function (data) {
console.log('' + data);
});
goTask.stderr.on('data', function (data) {
console.error('' + data);
});
}
/**
* Compiles backend application in development mode and places 'console' binary in the serve
* directory.
*/
gulp.task('backend', ['backend-dependencies'], function(doneFn) {
spawnGoProcess([
'build',
'-o', path.join(conf.paths.serve, 'console'),
path.join(conf.paths.backendSrc, 'console.go')
], doneFn);
});
/**
* Compiles backend application in production mode and places 'console' binary in the dist
* directory.
*
* The production binary difference from development binary is only that it contains all
* dependencies inside it and is targeted for Linux.
*/
gulp.task('backend:prod', ['backend-dependencies'], function(doneFn) {
let outputBinaryPath = path.join(conf.paths.dist, 'console');
// Delete output binary first. This is required because prod build does not override it.
del(outputBinaryPath)
.then(function() {
spawnGoProcess([
'build',
'-a',
'-installsuffix', 'cgo',
'-o', outputBinaryPath,
path.join(conf.paths.backendSrc, 'console.go')
], doneFn, {
// Disable cgo package. Required to run on scratch docker image.
CGO_ENABLED: '0',
// Scratch docker image is linux.
GOOS: 'linux'
});
}, function(error) {
doneFn(error);
});
});
/**
* Gets backend dependencies and places them in the backend tmp directory.
*
* TODO(bryk): Investigate switching to Godep: https://github.com/tools/godep
*/
gulp.task('backend-dependencies', [], function(doneFn) {
let args = ['get'].concat(goBackendDependencies);
spawnGoProcess(args, doneFn);
});
......@@ -35,17 +35,32 @@ export default {
app: path.join(basePath, 'src/app'),
assets: path.join(basePath, 'src/app/assets'),
base: basePath,
backendSrc: path.join(basePath, 'src/app/backend'),
backendTmp: path.join(basePath, '.tmp/backend'),
bowerComponents: path.join(basePath, 'bower_components'),
build: path.join(basePath, 'build'),
dist: path.join(basePath, 'dist'),
externs: path.join(basePath, 'src/app/externs'),
frontendSrc: path.join(basePath, 'src/app/frontend'),
frontendTest: path.join(basePath, 'src/test/frontend'),
integrationTest: path.join(basePath, 'src/test/integration'),
karmaConf: path.join(basePath, 'build/karma.conf.js'),
nodeModules: path.join(basePath, 'node_modules'),
partials: path.join(basePath, '.tmp/partials'),
prodTmp: path.join(basePath, '.tmp/prod'),
protractorConf: path.join(basePath, 'build/protractor.conf.js'),
serve: path.join(basePath, '.tmp/serve'),
src: path.join(basePath, 'src'),
tmp: path.join(basePath, '.tmp')
},
/**
* Frontend application constants.
*/
frontend: {
/**
* The name of the root Angular module, i.e., the module that bootstraps the application.
*/
rootModuleName: 'kubernetesConsole'
}
};
// Copyright 2015 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Configuration file for Protractor test runner.
*
* TODO(bryk): Start using ES6 in this file when supported.
*/
require('babel-core/register');
var conf = require('./conf');
var path = require('path');
/**
* Exported protractor config required by the framework.
*
* Schema can be found here: https://github.com/angular/protractor/blob/master/docs/referenceConf.js
*/
exports.config = {
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'http://localhost:3000',
specs: [path.join(conf.paths.integrationTest, '**/*.js')]
};
// Copyright 2015 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Gulp tasks for processing stylesheets.
*/
import browserSync from 'browser-sync';
import gulp from 'gulp';
import gulpAutoprefixer from 'gulp-autoprefixer';
import gulpFilter from 'gulp-filter';
import gulpMinifyCss from 'gulp-minify-css';
import gulpSourcemaps from 'gulp-sourcemaps';
import gulpSass from 'gulp-sass';
import path from 'path';
import gulpConcat from 'gulp-concat';
import conf from './conf';
/**
* Compiles stylesheets and places them into the serve folder. Each stylesheet file is compiled
* separately.
*/
gulp.task('styles', function () {
let sassOptions = {
style: 'expanded'
};
let cssFilter = gulpFilter('**/*.css', { restore: true });
return gulp.src(path.join(conf.paths.frontendSrc, '**/*.scss'))
.pipe(gulpSass(sassOptions))
.pipe(cssFilter)
.pipe(gulpSourcemaps.init({ loadMaps: true }))
.pipe(gulpAutoprefixer())
.pipe(gulpSourcemaps.write())
.pipe(cssFilter.restore)
.pipe(gulp.dest(conf.paths.serve))
// If BrowserSync is running, inform it that styles have changed.
.pipe(browserSync.stream());
});
/**
* Compiles stylesheets and places them into the prod tmp folder. Styles are compiled and minified
* into a single file.
*/
gulp.task('styles:prod', function () {
let sassOptions = {
style: 'compressed'
};
return gulp.src(path.join(conf.paths.frontendSrc, '**/*.scss'))
.pipe(gulpSass(sassOptions))
.pipe(gulpAutoprefixer())
.pipe(gulpConcat('app.css'))
.pipe(gulpMinifyCss())
.pipe(gulp.dest(conf.paths.prodTmp))
});
// Copyright 2015 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Root configuration file of the Gulp build system. It loads child modules which
* define specific Gulp tasks.
*
* Learn more at: http://gulpjs.com
*/
import './build/backend';
import './build/build';
import './build/index';
import './build/script';
import './build/serve';
import './build/style';
import './build/test';
// No business logic in this file.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册