Commit faed4de7 authored by rockyl's avatar rockyl

增加scilla构建过程

parents
Pipeline #82494 failed with stages
in 0 seconds
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless
/**
* Created by rockyl on 2018/7/9.
*/
const gulp = require('gulp');
const rollup = require('rollup');
const {uglify} = require('rollup-plugin-uglify');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const typescript = require('rollup-plugin-typescript2');
let currentMode = 'debug';
let version, releasePath;
let completeCallback;
exports.setCallback = function (callback) {
completeCallback = callback;
};
gulp.task('compileTs', async function () {
let plugins = [
resolve({
browser: true,
}),
typescript({
typescript: require('typescript'),
include: ['**/*.ts', '../common/**/*.ts', '../../src/**/*.ts'],
}),
commonjs(),
];
if (currentMode === 'build') {
plugins.push(uglify());
}
let file = currentMode === 'debug' ?
`debug/bundle.js` :
releasePath + 'bundle.js';
let writeConfig = {
file,
format: 'cjs',
};
if (currentMode === 'debug') {
writeConfig.sourcemap = true;
}
const bundle = await rollup.rollup({
input: './src/main.ts',
plugins,
});
await bundle.write(writeConfig);
});
gulp.task('watch', function () {
gulp.watch('src/**', ['compile']);
});
gulp.task('dev', ['compileTs', 'watch'], function(cb){
completeCallback && completeCallback('success');
cb();
});
gulp.task('compile', ['compileTs'], function(cb){
completeCallback && completeCallback('success');
cb();
});
gulp.task('build', async function () {
currentMode = 'build';
version = Math.floor(Date.now() / 1000).toString();
releasePath = `dist/${version}/`;
gulp.start(['compileTs', ], function(){
console.log('build success! \nversion:', version);
completeCallback && completeCallback(version);
});
});
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
/**
* Created by rockyl on 2018/7/6.
*/
const gutil = require('gulp-util');
const chalk = require('chalk');
const prettyTime = require('pretty-hrtime');
let gulpConfigFile;
let gulpConfig;
let cb;
exports.loadGulpFile = function (file) {
gulpConfig = require(gulpConfigFile = file);
};
exports.setTsConfig = function (tsConfig){
//gulpConfig.setTsConfig(tsConfig);
};
exports.startGulpTask = function(tasks = ['default'], callback){
gulpConfig.setCallback(cb = callback);
const gulpInst = require('gulp');
logEvents(gulpInst);
process.nextTick(function() {
gulpInst.start.apply(gulpInst, tasks);
});
};
// Format orchestrator errors
function formatError(e) {
if (!e.err) {
return e.message;
}
// PluginError
if (typeof e.err.showStack === 'boolean') {
return e.err.toString();
}
// Normal error
if (e.err.stack) {
return e.err.stack;
}
// Unknown (string, number, etc.)
return new Error(String(e.err)).stack;
}
// Wire up logging events
function logEvents(gulpInst) {
// Total hack due to poor error management in orchestrator
gulpInst.on('err', function() {
//failed = true;
});
gulpInst.on('task_start', function(e) {
// TODO: batch these
// so when 5 tasks start at once it only logs one time with all 5
gutil.log('Starting', '\'' + chalk.cyan(e.task) + '\'...');
});
gulpInst.on('task_stop', function(e) {
var time = prettyTime(e.hrDuration);
gutil.log(
'Finished', '\'' + chalk.cyan(e.task) + '\'',
'after', chalk.magenta(time)
);
});
gulpInst.on('task_err', function(e) {
var msg = formatError(e);
var time = prettyTime(e.hrDuration);
gutil.log(
'\'' + chalk.cyan(e.task) + '\'',
chalk.red('errored after'),
chalk.magenta(time)
);
if (e.err && e.err.loc) {
let {file, line, column} = e.err.loc;
gutil.log(`[${line}, ${column}] ` + file);
}
gutil.log(msg);
cb(new Error('task_err'))
});
gulpInst.on('task_not_found', function(err) {
gutil.log(
chalk.red('Task \'' + err.task + '\' is not in your gulpfile')
);
gutil.log('Please check the documentation for proper gulpfile formatting');
process.exit(1);
});
}
\ No newline at end of file
/**
* Created by rockyl on 2018/8/3.
*/
const path = require('path');
const {loadGulpFile, startGulpTask, setTsConfig} = require('./gulp-helper');
const gulpFile = path.resolve(__dirname, 'dev-config', 'gulpfile.js');
loadGulpFile(gulpFile);
exports.runGulp = function (task) {
return new Promise((resolve, reject)=>{
startGulpTask([task], function(result){
if(typeof result === 'string'){
resolve(result);
}else{
reject(result);
}
});
})
};
/**
* Created by rockyl on 2018/9/18.
*
* build process for scilla
*/
const {runGulp} = require('./gulp-init');
exports.dev = function(){
return runGulp('dev');
};
exports.compile = function(){
return runGulp('compile');
};
exports.build = async function(){
const result = await runGulp('build');
console.log(result);
return result;
};
This diff is collapsed.
{
"name": "game-cli-build-process-scilla",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"gulp": "^3.9.1",
"rollup": "^0.66.6",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-typescript2": "^0.18.0",
"rollup-plugin-uglify": "^6.0.0",
"typescript": "^3.1.6"
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment